Skip to content

feat: opt-in structural repo map provider - #1320

Open
SK-DEV-AI wants to merge 7 commits into
1jehuang:masterfrom
SK-DEV-AI:feat/repomap-provider
Open

SK-DEV-AI wants to merge 7 commits into
1jehuang:masterfrom
SK-DEV-AI:feat/repomap-provider

Conversation

@SK-DEV-AI

Copy link
Copy Markdown

Closes #1230 as built, exactly the agreed boundary: read-only provider, never core, never default-on.

Regex grammar sets (Rust, TS/JS, Python; unlisted extensions yield nothing, never fail), file-reference graph (unique-owner edges only, ambiguous names carry none), hand-rolled PageRank with seed personalization, token-budgeted stubs without bodies. No tree-sitter, no petgraph, no new dependencies.

Cache under .jcode/cache/repomap.json keyed per file by mtime+size; stale files rebuild alone. Tool registers only when repomap_token_budget > 0 (default 2000, 0 disables and the tool is unregistered so models never see a dead tool); env JCODE_REPOMAP_TOKEN_BUDGET wins over file, registered in the CONFIG_ENV_KEYS fingerprint, documented in the default file. Measured prototype numbers from the thread (1350 files / 4.6s cold / 0.066s warm at 61x) carry over: same graph shape, per-file invalidation preserved.

Tests: 13 engine + 3 tool, all green. Clippy and fmt clean.

@greptile-apps

greptile-apps Bot commented Sep 19, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

Safe to merge; there are no outstanding blocking concerns.

Summary

Adds an opt-in structural repository-map tool that extracts symbol stubs, ranks files using references and recent co-change history, and caches per-file parsing results.

  • Registers the tool only when its configured token budget is nonzero.
  • Supports configuration-file and environment-variable overrides while remaining disabled by default.
  • Adds bounded source reads, symlink protections, token-budget enforcement, and comprehensive engine/tool tests.
  • Supports both SHA-1 and SHA-256 Git object IDs when parsing co-change history.

Reviews (7) · Last reviewed commit: "fix(review): accept SHA-256 commit marke..."

Comment thread crates/jcode-config-types/src/lib.rs
Comment thread crates/jcode-base/src/repomap.rs
Comment thread crates/jcode-base/src/repomap.rs Outdated
Comment thread crates/jcode-base/src/repomap.rs Outdated
Comment thread crates/jcode-base/src/repomap.rs
Comment thread crates/jcode-base/src/repomap.rs Outdated
@greptile-apps

This comment has been minimized.

@github-actions github-actions Bot added area: config Configuration, defaults, and environment overrides. area: tools Agent tools, integrations, and tool execution. type: feature Adds a new user-facing capability. labels Sep 19, 2026
Comment thread crates/jcode-base/src/repomap.rs
Comment thread crates/jcode-base/src/repomap.rs
Closes 1jehuang#1230 as built, exactly the agreed boundary: read-only provider,
never core, never default-on. Regex grammar sets (Rust, TS/JS, Python;
unlisted extensions yield nothing, never fail), file-reference graph
(unique-owner edges only, ambiguous names carry none), hand-rolled
PageRank with seed personalization, token-budgeted stubs without bodies.
No tree-sitter, no petgraph, no new dependencies.

Cache under .jcode/cache/repomap.json keyed per file by mtime+size;
stale files rebuild alone. Tool registers only when
repomap_token_budget > 0 (default 2000, 0 disables); env
JCODE_REPOMAP_TOKEN_BUDGET wins over file, registered in the
CONFIG_ENV_KEYS fingerprint, documented in the default file.

Tests: 13 engine (extraction rs/ts/py, skip dirs, hub rank, seed
personalization, ambiguous/unique edges, budget truncation, budget-0
disable, cache rebuild + byte-identical warm hit, seeds end to end,
empty tree) + 3 tool (stubs, budget-0 notice, missing dir errors).
Clippy clean, fmt clean.
…ardening

- Default budget 2000 -> 0: the provider is opt-in, so the default must
  not register the tool. Opt in via file or JCODE_REPOMAP_TOKEN_BUDGET.
- Symlink confinement (both security findings): the walker never follows
  file/dir symlinks and every candidate is canonicalized under the root;
  the cache writer refuses symlinked .jcode/cache components and
  destination. Reads bounded at 2MB per file (no-symbol skip above).
- First block over budget yields no map (was: always emitted).
- Fingerprint mtime millis -> nanos plus size (same-ms equal-length
  edits no longer reuse stale symbols).
- Dropped the export-specific fn patterns overlapping the general
  optional-export ones (ts/js emitted every exported fn twice).
- Renamed DEFAULT_TOKEN_BUDGET to DEFAULT_REPOMAP_TOKEN_BUDGET (a
  different 200_000 const of the same name already exists).
Dedicated research pass (Aider RepoMap pipeline, 2025-26 refinements:
multi-anchor personalization, co-change signals for the base-module
blind spot):

- Seeds accept symbol names, not just path prefixes: naming an
  identifier personalizes the teleport toward the files defining it.
  Case-insensitive substring; documented on the tool schema.
- Recent-history co-change pairs (>=2 shared commits in the last 200)
  become bidirectional reference edges, so dependents boost their base
  even though no reference edge points back. Single shared commits
  ignored (bulk adds/renames are noise). Fail-soft outside git repos;
  repo-nested roots rebased via show-toplevel.
- Synthetic-graph tests point at isolated roots so they never inherit
  real co-change edges from the checkout the suite runs in.
@SK-DEV-AI
SK-DEV-AI force-pushed the feat/repomap-provider branch from 8053699 to 93d8747 Compare September 20, 2026 11:39
Comment thread crates/jcode-base/src/repomap.rs Outdated
Comment thread crates/jcode-base/src/repomap.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: config Configuration, defaults, and environment overrides. area: tools Agent tools, integrations, and tool execution. type: feature Adds a new user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PageRank repo-map as the zero-config structural context floor

1 participant