diff --git a/TODO-MCP.md b/TODO-MCP.md index ca73a22..5671284 100644 --- a/TODO-MCP.md +++ b/TODO-MCP.md @@ -397,6 +397,53 @@ Depends on M4 and M5 merged. — done 2026-09-23 as round 3b (d 96k, −10 % vs base; a 111k, the opt-in was not discovered), written up in `mcp_analysis.md` (aba39e5) +## M7. The lean catalogue (0.58; PLAN §10 — owner's steer 2026-09-23) + +Nine tools, the model-visible catalogue under 3 500 bytes, instructions +under 400, short answers, no dry_run/paging, edits told to be trusted. +Feature README `docs/features/mcp-lean-catalogue`. One dev (Opus), one QA +(Opus), on trunk. + +- [ ] registry: `TOOLS` holds exactly `hierarchy, find, outline, read, + check, rename, port, edit_item, format` in that order; `title` and + `structuredContent` removed from the wire (`Answer` is text only); + `Param.description` gone; `wire.rs` pins the names, the order, the + byte budgets (≤ 3 500 model-visible, ≤ 400 instructions) and that no + schema names `dry_run`, `limit`, `offset`, `in`, `template`, + `overrides`, `force` +- [ ] `hierarchy`: no root → counts line + top modules; down = instance + tree with instantiation `file:line`; `up`; `peek`; cap 300; + unknown-root refusal with near matches; opentitan instance set + identical to the old tool (test against `tests/opentitan.rs` truth) +- [ ] `find`: declarations + `refs` uses grouped one file per line + + `unresolved:`; macros found; near-match refusal +- [ ] `outline` (`file` xor `unit`), `read` (design-wide lookup, ambiguity + refusal), `check` (`ok` when clean; old `diagnostics` line set + preserved on the fixtures) +- [ ] `rename` (name-based, `file` disambiguates), `port` (add xor remove), + `edit_item` (four ops, the M4 verifier unchanged, `attacks.rs` green + unchanged), `format` (path or glob, `fix`) +- [ ] instructions ≤ 400 bytes per PLAN §10.3; resources render through + the new renderers +- [ ] tests: the old suites that exercise dropped tools are ported to the + surviving tool or deleted with a line in the README saying which; + every kept invariant (verifier attacks, all-or-nothing writes, roots, + freshness, cache read-only) keeps its test +- [ ] docs: feature README; `docs/site/.../guides/agents.md` table + regenerated by `mcp_smoke.js --tool-table` (+ the promises paragraph: + no dry_run); extension README/CHANGELOG; `CHANGELOG.md` 0.58.0 notes + (unreleased); `docs/topo.md` §2.8 rows; PLAN §4.3/§4.5 marked + superseded by §10 +- [ ] QA: attack the byte budget (a description that grows), the caps, the + ambiguity refusals, `peek` on a multi-line instantiation with + comments, `port add` after a non-existent port, `edit_item delete` + of a used item, `format` with a glob that matches nothing; differential + `hierarchy`/`check` against the 0.57.0 binary on the fixtures and the + eval clone +- [ ] census round 4 (lead): tasks a–d on the lean binary (`bin/lucisv-mcp-r5`), + base arm reused from round 3; written up in `mcp_analysis.md` +- [ ] release 0.58.0 when round 4 meets PLAN §10.5 + ## Open questions for the owner (answer before the lane that needs it) 1. **Engine bump** (M5): if `vsce` accepts the contribution point on diff --git a/docs/mcp/PLAN.md b/docs/mcp/PLAN.md index 0e8a7d8..8dcd3c3 100644 --- a/docs/mcp/PLAN.md +++ b/docs/mcp/PLAN.md @@ -473,3 +473,95 @@ are serial (same crate, same registry). M6 closes the block with a release. Roles per CLAUDE.md: one Opus dev then one Sonnet QA per lane, in a worktree branched from trunk; the lead reviews and merges; the block ships as a minor release (`0.56.0` if it lands before anything else does). + +## 10. The lean catalogue (0.58 — the owner's steer of 2026-09-23) + +The census (`mcp_analysis.md`) showed the server correct on every run and +dearer than plain file reads on every small task, for three reasons: a +5 400-token catalogue read every session, answers that carry more than the +question needs, and an agent that dry-runs and re-checks what it was told +to trust. The owner's ruling: **accuracy over breadth.** The server's +distinct value is the *hierarchy* of the project — where things are, as +`file:line`, with a way to peek at the code — and bulk edits that a file +write cannot do safely. So: nine tools, the whole model-visible catalogue +(`name` + `description` + `inputSchema` of every tool, compact JSON) **under +3 500 bytes** (≈ 1 000 tokens) and `instructions` under 400 bytes, both +pinned by test; short answers by default; no `dry_run`, no paging arguments; +edits are file writes the agent is told to trust. + +### 10.1 The nine tools + +Arguments carry no per-argument descriptions — the one-sentence tool +description names them. Each schema is `{type, properties, required, +additionalProperties: false}` with `type` alone per property (an `enum` +where one applies). `title` and `structuredContent` are gone; a result is +its text. The `annotations` stay (`readOnlyHint`, `destructiveHint: false`) +— hosts use them, the model never sees them. + +| tool | arguments | answers | +|---|---|---| +| `hierarchy` | `root?`, `up?` (bool), `depth?` (1–20, default 1), `peek?` (bool) | Without `root`: one line `N files, M modules, K top` then the top modules as `name file:line`. With `root`, down: the instance tree, one line per instance, two spaces per level: `instance: module file:line` where `file:line` is the **instantiation site**. `up`: every instantiation of `root`, `parent.instance file:line`, all levels up to `depth`. `peek: true` appends each instantiation statement's source under its line (indented, as written, at most 12 lines each then `…`). Cap 300 lines then `… and N more`. Unknown `root`: a refusal that lists up to 10 contains-matches. | +| `find` | `name`, `refs?` (bool) | Every declaration of `name` (whole-name, any case-exact): `kind name file:line`, then, with `refs`, per declaration its uses as `file:line` (one file per line, lines joined with `,` when several are in one file: `ip/uart/rtl/uart.sv:120,133,140`), then `unresolved:` and the textual mentions (strings, comments, macro text) the same way. No declaration: up to 20 contains-matches of declarations as a refusal (`no declaration named X; similar: …`). Cap 300 lines. | +| `outline` | `file?` **or** `unit?` (exactly one) | `file`: its declarations as a tree with line ranges, two spaces per level: `kind name start–end`, parse errors first as `error line: message`. `unit`: its `file:line`, then parameters `param name = default` and ports `dir type[range] name` in declaration order, one per line; interfaces add modports, packages their exports. No template, no counts. Cap 300 lines. | +| `read` | `item`, `file?` | The item's source, exact bytes, preceded by one line `file:start–end`. Selector as today's `read_item` (`name`, `kind:name`, `name@LINE`, `always@LINE`). Without `file` the item is looked up design-wide; several matches → a refusal listing them as `file:line`. | +| `check` | `file?` | Parse errors, missing closers and lint findings of `file` or the whole design, `file:line:col severity message [rule]`, errors first, cap 200 lines then `… and N more`. Clean: `ok` (one word). | +| `rename` | `name`, `new_name`, `file?` | Renames the declaration `name` (in `file` when the name is declared in more than one place; ambiguity without `file` is a refusal that lists the declarations) and every resolved use, `.name`/`.*` shorthand included (M3.5). Answer: `renamed N sites in M files` and, only when any, `unresolved:` lines as in `find`. | +| `port` | `module`, `add?` (a port declaration), `after?`, `remove?` (a port name) | Exactly one of `add`/`remove`. `add` inserts the ANSI port (after port `after`, else last) and connects it by name in every instantiation; `remove` deletes the port and its connection everywhere, refused while the module body uses it. Answer: `added|removed port X in module M: N instantiations in K files` and any `unresolved:` lines. | +| `edit_item` | `file`, `op` (`replace` / `insert_before` / `insert_after` / `delete`), `item`, `text?` | The M4 structural edits under one name, same verifier, same rules: `replace` keeps kind and names; `insert_*` anchors on `item` (or `end` / `end@UNIT`); `delete` takes the item and its leading comments and is refused while its names are used (sites listed) or it holds a `` `define ``. No `force`, no `rename`. Answer: `replaced|inserted|deleted ITEM file:start–end` (the new lines). | +| `format` | `files` (a path or a glob), `fix?` (bool) | Formats every matching file; `fix` applies the safe lint fixes first. Answer: `formatted N files (M unchanged)`; a refusal per file the safety net rejects, the rest still written. | + +Dropped from the catalogue (the engines stay in the CLI and the LSP): +`project_overview`, `list_units`, `unit_interface`, `read_item`, +`search_symbols`, `defines`, `definition`, `references`, `diagnostics`, +`fix_lint`, `expand_wildcard`, `convert_ports`, `organize_imports`, +`inline_module`, `propagate_ports`, `remove_port`, `add_port`, +`extract_module`, `replace_item`, `insert_item`, `delete_item`, +`instantiate`. A `\`define` is found by `find` like any declaration +(`macro NAME file:line`). + +### 10.2 Rendering rules (replacing §4.5) + +- One line per fact, root-relative paths, `file:line`, no headers, no + blank lines, no trailing hints (`check:` is gone — the instructions say + when to check). +- Fixed caps per tool (300 / 200 lines) with one `… and N more` line; no + `limit`/`offset`. Narrowing is by a better question (`root`, `file`, + `depth`). +- Counts only where they are the answer (`hierarchy` without `root`, + `rename`, `port`, `format`). +- Refusals are one sentence, `isError: true`, and when a name is unknown + they list the near matches so the next call is right. + +### 10.3 Instructions (≤ 400 bytes) + +> lucisv-mcp answers from the SystemVerilog sources on disk (save first). +> Use it before reading files: hierarchy for the instance tree and top +> modules, find for where a name is declared and used, outline for a file +> or a unit's ports, read for one item's source, check after edits. Edits +> (rename, port, edit_item, format) are verified, all-or-nothing writes to +> disk: call them like a file write, no dry run. Paths are root-relative, +> lines 1-based. + +### 10.4 What stays + +Transport, freshness, roots, the filelist, the cache reader, the resources +(`lucisv://overview`, `unit/{name}`, `file/{path}/outline` render through the +new renderers; `lucisv://rules` stays), the apply path (all-or-nothing, +re-read before write, atomic inside the roots), the M4 verifier and its +attack tests, the unresolved-mentions scan, the extension provider and the +packaging. `mcp_smoke.js --tool-table` keeps working and regenerates the +Agents guide's table. + +### 10.5 Acceptance + +- `tools/list`: exactly the nine names above, in that order; the + model-visible bytes ≤ 3 500, `instructions` ≤ 400 — a test in `wire.rs` + computes both. +- No `dry_run`, `limit`, `offset`, `in`, `template`, `overrides`, `force` + argument anywhere. +- The eval tasks a–d (`~/.cache/lucisv-eval/tasks`) re-run as census round + 4 on the lean binary, all four correct, and the mcp arm at or under the + base arm on a and d; b and c within +10 %. +- The M4 attack suite green unchanged; `check` on the fixtures identical to + the old `diagnostics` line set; `hierarchy` on opentitan's `top_earlgrey` + identical instance set to the old tool.