feat(recall): surface source-file anchors for codebase hits - #240
Merged
Conversation
teamwiki code-knowledge pages carry `source:` file paths in frontmatter, but recall discarded them (only the title was regex-scraped), so an agent doing an edit got architecture prose without knowing which files to touch. - code-knowledge-recall: parse frontmatter via gray-matter, sanitize the source list to in-repo file anchors (drop URLs and bare directories), and thread it through PageDoc -> CodeKnowledgeResult - recall: emit a `Sources:` line (before the snippet) for hits that carry anchors; plain learnings/docs entries are unaffected - teamai-recall subagent: for edit/change queries, use --depth lookup and build a "Change entry points" section from graph-index.json forward edges (1-3 entry files, skip self-edges, cap 10) with a suggested reading order - docs: note the Sources line in README (EN + zh-CN) Closes Tencent#233 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4 tasks
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
Resolves #233. teamwiki code-knowledge pages carry
source:file paths intheir frontmatter, but recall discarded them — only the title was
regex-scraped. An agent doing an edit received architecture prose without
knowing which files a change touches, so it fell back to exploring the
codebase anyway (exactly the pain reported in #233).
This surfaces the source-file anchors and lets the recall subagent turn
them into an actionable "how to change X" starting point.
Changes
code-knowledge-recall.ts: parse frontmatter via gray-matter; addsanitizeSources()to keep only in-repo file-path anchors (drop URLs andbare directories); thread
sourcesthroughPageDoc→CodeKnowledgeResult.recall.ts:formatResultsemits aSources:line (before thesnippet) for hits that carry anchors. Plain learnings/docs entries are
unaffected.
agents/teamai-recall.md: for edit/change queries, use--depth lookupand build a
Change entry pointssection fromgraph-index.jsonforwardedges (1–3 entry files, skip self-edges, cap 10) plus a suggested reading
order. Derived solely from existing graph data — no invented relationships.
Sources:line in README (EN + zh-CN).Test Plan
npx tsc --noEmit— cleannpx vitest run— 1773 passed (added source three-state, sanitize,extensionless-file, and formatResults
Sources:cases)npm run build— OKteamai recall "..." --depth lookupsurfaces file anchors(e.g.
Sources: src/providers/github/gh-cli.ts, ...);--depth contextno longer leaks the repo-URL noise (sanitized)
entry file + directed dependency chain + reading order
Known limitations (follow-up)
contextwhitelist and rank low under BM25 for edit queries; this PR relies on the
subagent's targeted
graph-index.jsonread to bypass that. Fixing theretrieval ranking itself is deferred to a separate change.
🤖 Generated with Claude Code