Skip to content

feat(recall): surface source-file anchors for codebase hits - #240

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
m0Nst3r873:feature/recall-gating
Jul 24, 2026
Merged

feat(recall): surface source-file anchors for codebase hits#240
jeff-r2026 merged 1 commit into
Tencent:mainfrom
m0Nst3r873:feature/recall-gating

Conversation

@m0Nst3r873

Copy link
Copy Markdown
Collaborator

Summary

Resolves #233. teamwiki code-knowledge pages carry source: file paths in
their 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; add
    sanitizeSources() to keep only in-repo file-path anchors (drop URLs and
    bare directories); thread sources through PageDocCodeKnowledgeResult.
  • recall.ts: formatResults emits a Sources: line (before the
    snippet) for hits that carry anchors. Plain learnings/docs entries are
    unaffected.
  • agents/teamai-recall.md: 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) plus a suggested reading
    order. Derived solely from existing graph data — no invented relationships.
  • docs: note the Sources: line in README (EN + zh-CN).

Test Plan

  • npx tsc --noEmit — clean
  • npx vitest run — 1773 passed (added source three-state, sanitize,
    extensionless-file, and formatResults Sources: cases)
  • npm run build — OK
  • Real CLI: teamai recall "..." --depth lookup surfaces file anchors
    (e.g. Sources: src/providers/github/gh-cli.ts, ...); --depth context
    no longer leaks the repo-URL noise (sanitized)
  • End-to-end subagent simulation ("how to add a hook handler"): produces
    entry file + directed dependency chain + reading order

Known limitations (follow-up)

  • Facts pages that carry the richest anchors are outside the context
    whitelist and rank low under BM25 for edit queries; this PR relies on the
    subagent's targeted graph-index.json read to bypass that. Fixing the
    retrieval ranking itself is deferred to a separate change.

🤖 Generated with Claude Code

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>
@jeff-r2026
jeff-r2026 merged commit acfd233 into Tencent:main Jul 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: distinguish architecture vs. procedural knowledge in recall

2 participants