feat(mcp): codemap://files/{path} + codemap://symbols/{name} resources (§ 1.8)#67
Conversation
§ 1.8 from research note. Two new MCP / HTTP resources reusing
existing substrate (no schema bump):
codemap://files/{path}
- Per-file roll-up: {path, language, line_count, symbols, imports,
exports, coverage}.
- imports.specifiers parsed inline (callers don't need JSON.parse).
- coverage is {measured_symbols, avg_coverage_pct, per_symbol} when
ingested, else null.
- URI-encode the path; query is fail-closed (returns undefined when
path not in index — distinguishes "unknown URI" from "valid URI,
empty roll-up").
codemap://symbols/{name}
- Returns {matches, disambiguation?} envelope (reuses
findSymbolsByName + buildShowResult from show-engine — same shape
as `show <name>` per PR #39).
- Optional ?in=<path-prefix> query parameter mirrors `show --in`
(directory prefix or exact file). Uses the WHATWG URL parser.
- Empty name → undefined; multi-match → disambiguation block.
Caching policy:
- Catalog-style resources (recipes, schema, skill) lazy-cache (existing
pattern).
- Data-shaped resources (files, symbols) read LIVE every call — no
caching. Index can change between requests under --watch; caching
would silently serve stale data.
Both available over MCP read_resource AND HTTP GET /resources/
{encoded-uri} via the existing dispatcher (no new transport plumbing
needed; readResource() switch extended).
Tests:
- 9 new tests in resource-handlers.test.ts cover both endpoints +
listResources advertising. Pattern mirrors mcp-server.test.ts (use
initCodemap + resolveCodemapConfig + tmpdir fixture).
- bun run check passes (format, lint, typecheck, all 23 golden
queries).
Rule 10 lockstep: both templates/agents/ and .agents/ codemap rule +
skill updated:
- Rule body — Resources bullet extended with new URIs + caching policy.
- Skill body — per-URI bullet for each new resource with shape spec.
Patch changeset: pre-v1; additive resources; no schema bump; no
breaking change to existing resource consumers.
Files: 7 changed (1 src impl, 1 src test, 4 lockstep, 1 changeset).
🦋 Changeset detectedLatest commit: 4ed406b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 49 minutes and 10 seconds.Comment |
Summary
Ships § 1.8 from research note — two new MCP / HTTP resources for direct agent reads:
codemap://files/{path}— per-file roll-up (symbols, imports, exports, coverage)codemap://symbols/{name}— symbol lookup with{matches, disambiguation?}envelope +?in=<path-prefix>filterSaves the recipe-compose round-trip when the agent just wants "everything about this file" or "where is this symbol?".
What lands
codemap://files/{path}{ "path": "src/foo.ts", "language": "ts", "line_count": 30, "symbols": [...], "imports": [{"source": "...", "resolved_path": "...", "specifiers": ["bar"], "is_type_only": false, "line_number": 1}], "exports": [...], "coverage": null | {"measured_symbols": 5, "avg_coverage_pct": 78.4, "per_symbol": [...]} }imports.specifiersparsed inline (callers don't needJSON.parse).undefinedwhen path not in index — distinguishes "unknown URI" from "valid URI, empty roll-up".codemap://symbols/{name}{ "matches": [{"name": "foo", "kind": "function", "file_path": "src/foo.ts", "line_start": 5, "line_end": 15, "signature": "function foo(): void"}], "disambiguation": {"n": 2, "by_kind": {"function": 2}, "files": ["src/foo.ts", "src/legacy/foo.ts"], "hint": "Multiple matches. Narrow with --kind <kind> or --in <path>."} }findSymbolsByName+buildShowResultfromapplication/show-engine.ts(same shape asshow <name>per PR feat(show + snippet): targeted-read CLI verbs + MCP tools #39).?in=<path-prefix>mirrorsshow --in <path>(directory prefix or exact file).Caching policy
codemap://recipes,codemap://schema,codemap://skillcodemap://files/{path},codemap://symbols/{name}--watch; caching would serve stale dataImplementation notes
readResource()switch extended; both MCPread_resourceand HTTPGET /resources/{encoded-uri}light up via the existing dispatcher.application/resource-handlers.tsfile as the existing handlers; consistent with the engine-reuse pattern from PR refactor: lift cli/* engine helpers into application/* (close all layer-reversal imports) #41.Test plan
resource-handlers.test.ts— single match, multi-match, disambiguation,?infilter, URI-decode, unknown path, empty name, listResources advertisingbun run checkpasses — format, lint, typecheck, all 23 golden queriesDoc-governance compliance
templates/agents/AND.agents/codemap rule + skill updated with new URI templates + caching policy.Out of scope
codemap://files/{path}with?coverage=true|falsefilter to opt out of expensive coverage roll-up — premature optimization; current single-row + per-file coverage scan is fast enough on real-world projects.codemap://symbols/{name}?kind=<k>filter —findSymbolsByNamealready supports it via the engine; not exposed in this PR's URI surface to keep the v1 contract small. Add if demand emerges.