feat(snippets): a snippet has notes; when_to_use is the situation it is ranked on (#4378)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / integration (push) Successful in 50s
CI & Build / TypeScript typecheck (push) Successful in 53s
CI & Build / Python tests (push) Successful in 1m37s
CI & Build / Build & push image (push) Successful in 34s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / integration (push) Successful in 50s
CI & Build / TypeScript typecheck (push) Successful in 53s
CI & Build / Python tests (push) Successful in 1m37s
CI & Build / Build & push image (push) Successful in 34s
A snippet had no field for prose, so what a session learned about one went into when_to_use — the trigger joined onto every chunk it is embedded as. A sweep found write-ups of up to 3 KB there, headings and all. - notes: stored after the code under `## Notes`, parsed back from the body, carried by every path that rebuilds it (update, merge, un-merge). A snippet with no notes composes the body it always did. - create/update_snippet (MCP) take notes and return trigger_advice when when_to_use is long, headed or multi-paragraph. Advice, not a refusal. - Tool docs, the reusing-code skill and the editor hint describe the trigger as the situation and point the explanation at notes. - Editor gains a Notes field; the detail view renders it as markdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,10 @@ logger = logging.getLogger(__name__)
|
||||
snippets_bp = Blueprint("snippets", __name__, url_prefix="/api/snippets")
|
||||
|
||||
# Fields the create/update payload may carry, mapped straight to the service.
|
||||
_STR_FIELDS = ("name", "code", "language", "signature", "when_to_use", "repo", "path", "symbol")
|
||||
_STR_FIELDS = (
|
||||
"name", "code", "language", "signature", "when_to_use", "repo", "path", "symbol",
|
||||
"notes",
|
||||
)
|
||||
|
||||
|
||||
async def _load_snippet(uid: int, snippet_id: int):
|
||||
@@ -106,6 +109,7 @@ async def create_snippet_route():
|
||||
path=data.get("path", ""),
|
||||
symbol=data.get("symbol", ""),
|
||||
locations=data.get("locations"),
|
||||
notes=data.get("notes", ""),
|
||||
),
|
||||
project_id=project_id,
|
||||
is_task=False,
|
||||
@@ -139,6 +143,7 @@ async def create_snippet_route():
|
||||
locations=data.get("locations"),
|
||||
tags=data.get("tags"),
|
||||
project_id=project_id,
|
||||
notes=data.get("notes", ""),
|
||||
)
|
||||
if data.get("system_ids") is not None:
|
||||
await systems_svc.set_record_systems(uid, note.id, data["system_ids"])
|
||||
|
||||
Reference in New Issue
Block a user