Skip to content

Add the repository map (repo_map tool, pinned core/repo-map, lsp map) - #149

Merged
leonardoaraujosantos merged 14 commits into
mainfrom
feat/repository-map
Nov 19, 2026
Merged

leonardoaraujosantos merged 14 commits into
mainfrom
feat/repository-map

Conversation

@leonardoaraujosantos

@leonardoaraujosantos leonardoaraujosantos commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Implements the OpenSpec change add-repository-map: a ranked, token-budgeted map of the repository's files and definitions for the agent.

What changes

  • Index (cyber-tools/src/repo_map/): tree-sitter tag queries for Rust, Python, JS/JSX, TypeScript, TSX, Go, C, C++, Java, Solidity and Bash (pinned grammar crates); the grep/glob ignore-aware walk with default excludes, .gitattributes linguist attributes and include/exclude globs; a content-addressed SQLite cache at <cache>/repo-map/index.db (0600, WAL) shared across worktrees; bounded builds (max files, build timeout, 250 ms parse timeout) with a cross-process lock, partial resume and GC.
  • Ranking and rendering: personalized PageRank over the reference graph (focus paths/symbols, Session files), deterministic, binary-searched rendering into the token budget with container rows.
  • repo_map tool: read-only, offered in plan mode and untrusted checkouts, hides read-denied files, refreshes first and waits at most 10 s for a build. Edit tools mark files dirty.
  • Epoch-pinned Context Sources (system-context): observed only when a baseline renders, never reconciled, omitted after a 2 s bound; core/repo-map is the first, in trusted checkouts only; /context marks it pinned.
  • Profiles: repo_map: { context_tokens, tool_tokens } with window caps; top-level repo_map config key.
  • Inspection: GET /api/v1/lsp/map, POST /api/v1/lsp/map/rebuild, cyber lsp map (server or in-process), TUI /map.
  • Privacy: counts-only repo_map.build span; the index is never in backups/exports.
  • CI: a binary-size gate (+12 MiB over the base branch).
  • Docs: local-core guide, features, ROADMAP; NOTICE for the adapted MIT tag queries.

Spec deviations (spec updated in the first commit)

Measured on this repository, the spec'd ranking filled the map with map/clone/format and local variable names. So: queries capture call/type/import references (identifier fallback only for Bash), m(x) adds a ×10 boost for distinctive names and ×0.1 for ubiquitous ones, focus symbols personalize their definers/referrers, and focus files render first. Ignored files are not walked (no ignored reason); pruned default directories count once; .cyber/ (agent configuration) is a default exclude; container rows end at the body (impl Server).

Not done here

  • 0.1: improve-model-protocol-fidelity is not archivable yet (its live tests need keys).
  • 9.1/9.2: the with/without-map eval needs provider keys and a local model.
  • 9.3: the 50 000-file benchmark (a release build was stopped when local disk ran out).

Local gate: fmt, clippy -D warnings on all touched crates, scoped nextest runs, openspec validate --all --strict, spec_lint (0 errors, same warnings as main), spec_inventory --check. sdk/openapi.json, the TS SDK and docs/cli.md were regenerated on a CI runner because local disk was exhausted at the time.

@leonardoaraujosantos
leonardoaraujosantos force-pushed the feat/repository-map branch 2 times, most recently from abf4e66 to da8a6b5 Compare November 19, 2026 05:34
Reference captures replace the identifier fallback where a query has them,
so local variables no longer link files; ranking damps ubiquitous names and
boosts distinctive ones, focus symbols personalize their definers and
referrers, and focus files render first. Ignored files are not walked, so
they carry no exclusion reason; pruned default directories count once.
Container rows end at the body, like every signature.
…nd inspection

cyber-tools gains a repo_map module: tree-sitter tag queries for eleven
bundled languages, an ignore-aware walk with default excludes and
.gitattributes linguist attributes, a content-addressed SQLite cache at
<cache>/repo-map/index.db shared across worktrees, bounded builds with a
cross-process lock, personalized PageRank over the reference graph and a
binary-searched renderer that fits a token budget.

The read-only repo_map tool is offered when repo_map.enabled holds, also in
plan mode, and hides files whose read rule denies them. Context Sources can
now be epoch-pinned: observed only when a baseline renders, skipped by
reconciliation and omitted after a 2 s bound. core/repo-map is the first
such source, in trusted checkouts only.

Model profiles gain repo_map budgets with window caps; the top-level
repo_map key configures the map. The server adds GET /lsp/map and POST
/lsp/map/rebuild, the CLI cyber lsp map, and telemetry a counts-only
repo_map.build span.
/map [<path>] loads GET /lsp/map at the Session model's tool budget and
opens a view with the index status header; r rebuilds, Enter opens the
selected path in the file explorer and Esc closes. A disabled map shows a
message and opens nothing.
On pull requests, build the stripped release binary for the base and the
head and fail when the head is more than 12 MiB larger.
… lsp map

Also run the TUI map screens on the default test runtime.
Workspace crates are fingerprinted by mtime, so the head build reused the
base build's artifacts.
The commands catalog must name every TUI slash command. Agent configuration
under .cyber/ is not code, and listing it leaked skill paths into the
baseline map. TUI screens drive a keyword-matching scripted model, so their
fixture keeps the map out of the baseline.
@leonardoaraujosantos
leonardoaraujosantos merged commit 3981734 into main Nov 19, 2026
39 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.

1 participant