Feature/563 template recommender - #736
Merged
Nanle-code merged 4 commits intoJul 29, 2026
Merged
Conversation
|
@mubking is attempting to deploy a commit to the nanle-code's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@mubking Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
hello |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #563: an AI-enhanced contract template recommendation system for the
Stellar Dev Dashboard. Users describe what they want to build in plain language,
and the system ranks contract templates by fit, explains why each was suggested,
hands the chosen template to the existing customizer, and learns from which
templates users actually pick.
Closes #563.
What's included
src/lib/templateRecommendation.ts) — a pure,browser-safe scoring function that ranks templates against a requirement using
tag overlap, category match, keyword hits, and a feedback boost. Every result
carries a score and human-readable reasons.
src/lib/templateFeedbackStore.ts) — records whichtemplate a user chose for a given requirement (IndexedDB with in-memory
fallback) and feeds that back into future rankings. This is the "improves with
usage" mechanism.
src/lib/templateManager.ts) — addedtags,useCases, and astatusfield toContractTemplate, plus agetReadyTemplates()helper. Grew the library from 4 to 27 templates.src/components/templates/TemplateRecommender.jsx) — requirement input,ranked suggestions with reasons, and handoff to the existing
TemplateCustomizer.src/lib/templateRecommendation.test.ts) — accuracy andfeedback-loop coverage (details below).
Acceptance criteria
accuracy (the single highest-ranked template must be the expected one) across
30 realistically-phrased requirements that avoid quoting template names. The
suite asserts ≥85%; it currently passes at 100% on this set.
the existing
TemplateCustomizer, reusing the current customization flowrather than duplicating it.
similar future requirements, verified by test; boosts do not leak across
unrelated requirements.
Scope note (please read)
This PR ships 27 templates: 12 fully specified and 15 discovery-ready
work-in-progress stubs (
status: 'wip'), not the 50+ in the criteria. The WIPstubs carry real tags and use-cases so the recommender surfaces them, but their
constructor/method detail is still to be written, and they are excluded from
deployment (
getReadyTemplates()filters them out; the UI disables "Use thistemplate" for them). I chose depth over filler for this first pass and would
rather flag the gap than pad the count. Happy to complete the remaining stubs to
real templates in a follow-up, or in this PR if you'd prefer to hold it.
Design decisions worth flagging
src/ml/scoringEngine.js? It's Node-only(
@tensorflow/tfjs-node) and scores transactions for fraud, so it can't run inthe browser dashboard and doesn't address template fit. The recommender instead
uses a transparent, deterministic scoring function — which also makes the 85%
criterion provable in a unit test rather than flaky.
TemplateLibrary.jsxloads contract templates fromtemplateManager.ts, and the issue is about contract templates, so this buildson
templateManager.ts. The separate transaction-template system(
templateLibrary.ts) is untouched.Also included
@tensorflow/tfjs-nodeto4.22.0inpackage.json(was^5.0.0,which does not exist on npm and blocks
npm install).Testing
Follow-ups
Complete the 15 WIP stubs into fully-specified templates to reach 50+.
Mount
TemplateRecommenderintoTemplateLibrary.jsxas a tab/panel (not yetwired — flagged for review since it touches existing UI).
Closes AI-Enhanced Contract Template Library #563