Skip to content

Latest commit

 

History

History
97 lines (63 loc) · 9.88 KB

INSTALL.md

File metadata and controls

97 lines (63 loc) · 9.88 KB

Running the plugin from a clone

This page is for working on CodePlumb. To install it, see the README.

Install

git clone https://github.com/jbknick/codeplumb.git
cd codeplumb
pnpm install && pnpm build
claude --plugin-dir /absolute/path/to/codeplumb/plugin

pnpm build writes plugin/dist/ (CLI, MCP server, explorer) and plugin/deps/ (native dependency lockfiles). --plugin-dir loads plugin/ in place, so after a rebuild run /reload-plugins. A run from the clone uses the workspace node_modules and installs nothing.

Check the manifests without a session: claude plugin validate plugin and claude plugin validate .claude-plugin/marketplace.json.

Standalone MCP harnesses (Codex, Cursor and the rest) store data under ~/.codeplumb/data. Set CODEPLUMB_DATA_DIR to change it. In Antigravity, the hooks keep data under PLUGIN_DATA, as they use CLAUDE_PLUGIN_DATA in Claude Code. Antigravity can't add a note to the agent's context, so at the end of a turn with findings the Stop hook asks the agent for one more step with the note as the reason.

First run

An installed plugin has no node_modules, so it installs SQLite and the parsers once with your Node's npm. Any Node other than 26 stops bin/codeplumb with one line saying so.

The first session prints CodePlumb: installing dependencies (first run). Hooks stay quiet until the install finishes, and the MCP server waits up to 120 s. The packages go under deps/ in the plugin data directory and survive updates. The embedding runtime installs the first time something is embedded. If an install fails, the error names logs/deps.log, and the next command tries again.

Protocol package

Each release carries codeplumb-protocol-<version>.tgz (wire schemas, routes, limits, a test double) and its .sha256. It isn't on a registry. Depend on it by URL and check the checksum:

"@codeplumb/protocol": "https://github.com/jbknick/codeplumb/releases/download/v<version>/codeplumb-protocol-<version>.tgz"

It exports . and ./testing, and depends only on zod.

Where the data lives

Each repo gets one data directory, under the plugin data dir Claude Code assigns (~/.claude/plugins/data/codeplumb-codeplumb/), in repos/<hash>/. Repos listed in one codeplumb-workspace.json share workspaces/<hash>/. A terminal run from a clone has no plugin data dir and uses ~/.codeplumb/data instead.

codeplumb init prints the directory as data: and codeplumb backlog as Data:, so you can confirm the CLI and the MCP server share a store. To check from a clone's terminal, set CLAUDE_PLUGIN_DATA to the data: path /codeplumb:init printed.

Read-only commands (backlog, usage, heal) and the hooks never create a data directory. Uninstalling the plugin deletes the directory and every index in it.

After an upgrade

When an update changes the store schema, the first non-hook command rebuilds the index and says why in one line. Hooks leave a stale index alone, and the session-start hook reminds you to run /codeplumb:init. Descriptions and embeddings are lost, so run /codeplumb:sync afterwards.

To start over, run codeplumb uninstall in the repo and then /codeplumb:init.

Describing a large repo

/codeplumb:init starts 4 background describer agents. Each run ends after 15 claims (about 150 functions) and reports MORE WORK. The skill then starts a fresh describer with the same worker id, and the server hands it any batch the last run left unsubmitted. An unsubmitted claim expires after 10 minutes, so /codeplumb:sync picks up after an interruption.

codeplumb backlog --failed lists failed functions with the rule that rejected them. --retry-failed queues them again.

Operator check (an interactive session is required)

This is the acceptance check for the plugin. It makes real model calls (Haiku) on a copy of a fixture. Use only fixtures/, never a private repo.

  1. Copy the fixture to a scratch git repo outside this clone:

    FX=$(mktemp -d)/pnpm-turbo && cp -R fixtures/pnpm-turbo "$FX" && cd "$FX" \
      && git init -q && git add -A && git -c user.email=t@t -c user.name=t commit -qm init
  2. Start Claude Code in $FX (cd "$FX" && claude). Start it as claude --plugin-dir <clone path>/plugin. Check /plugin shows codeplumb enabled with no errors and /mcp shows plugin:codeplumb:codeplumb connected.

  3. In a second terminal, set export CLAUDE_PLUGIN_DATA=<dir>, the plugin data dir Claude Code made for this session (the newest codeplumb-* folder in ls -t ~/.claude/plugins/data; /codeplumb:init prints the same path as data:) and G=<clone path>/plugin/bin/codeplumb, and run cd "$FX" && "$G" init --estimate once, so you know the total. Run "$G" backlog --json and note total (call it N) then note the time right before you start step 4 (date +%s, call it T0).

  4. In the session run /codeplumb:init. Expect the estimate, then the question. Answer "everything". Expect 4 background describer agents.

  5. Watch progress: watch -n 10 "cd $FX && $G backlog --json". byStatus.pending falls in steps of 10 per agent and reaches 0; claimed returns to 0 once every agent finishes. failed should stay 0 or small; "$G" backlog --failed names the rule each one failed. data_dir must match the data: line of /codeplumb:init. On a backlog above about 600 functions, expect describers to report MORE WORK and the session to start fresh ones with the same ids until the backlog is done.

  6. When pending and claimed are both 0, note the time (T1). Functions per minute = N_done / ((T1 - T0) / 60), where N_done = N - failed. Also run "$G" usage and "$G" search <word>, and confirm git -C "$FX" status --porcelain is empty (nothing is written into the repo).

  7. Check the tool limit: in the session, ask /agents (or the transcript of a describer) and confirm it only called codeplumb_claim_batch and codeplumb_submit_descriptions.

  8. Record N, T1 - T0, functions per minute and the failed count in the PR.

Hooks check (PostToolUse, Stop and SessionStart)

No model calls and no description run are needed for this one. Do it in the same scratch repo $FX with the plugin installed (the index must exist: run "$G" init first).

  1. Run claude plugin validate plugin; it must pass and list the hooks. In the session, /hooks shows SessionStart, PostToolUse and Stop entries from the codeplumb plugin.
  2. Start a new session in $FX. If you ran "$G" init, no line appears (or CodePlumb: N functions await descriptions ... when the backlog is at or above the threshold). In a repo that has no index, the line is CodePlumb: run /codeplumb:init to index this repo.
  3. Ask Claude: "Create apps/web/src/lib/new.ts with a slugify(input: string): string function that lowercases, trims, turns whitespace into dashes, strips anything outside a-z, 0-9 and dash, collapses repeated dashes and trims leading and trailing dashes." At the end of that turn (the Stop hook; the edit itself prints nothing), Claude should say it saw a CodePlumb note and switch to import { slugify } from './slug' (or tell you it exists). The note itself is in the transcript (ctrl+o) as CodePlumb: slugify (apps/web/src/lib/new.ts:1) looks like slugify in apps/web/src/lib/slug.ts:1 [exact 1.00]. Import it: ... (the tier may be near if Claude words the function differently).
  4. Ask Claude to add import { db } from "@acme/db" to a file in apps/web/src. Expect CodePlumb: Declare "@acme/db" in apps/web/package.json (line N).
  5. Ask for an unrelated edit (a new constant). Expect no CodePlumb text at all.
  6. git -C "$FX" status --porcelain shows only the files Claude wrote, nothing from CodePlumb. Run git add -A && git commit -m t after "$G" hooks install: the same findings appear on stderr in the Bash output and the commit succeeds.
  7. Ask Claude, in one request, to add import { db } from "@acme/db" to a file in apps/web/src and to add "@acme/db": "workspace:*" to apps/web/package.json. Expect no CodePlumb text: the check runs once the turn's edits are done.
  8. Time one hook run by hand (without a session id the edit is settled at once): time (echo '{"tool_name":"Write","tool_input":{"file_path":"'"$FX"'/apps/web/src/lib/new.ts"},"cwd":"'"$FX"'"}' | "$G" hook post-tool-use); record it in the PR.

Explainer check (/codeplumb:explain, /codeplumb:overview, /codeplumb:map)

Interactive session required: it makes real model calls (Sonnet). Use the scratch repo $FX of the first check, with the plugin installed and the index built ("$G" init). Descriptions are not needed; run /codeplumb:init first if you want the explainer to see them.

  1. In the session in $FX run /codeplumb:explain formatRelativeDate. Expect an answer of at most 200 words that names packages/utils/src/date.ts:1 (where it is defined), its callers or the fact that nothing calls it, and path:line references for every claim. In the transcript (ctrl+o) the explainer subagent used only codeplumb_*, Read, Grep or Glob calls. Record the answer in the issue.
  2. Run /codeplumb:overview @acme/utils. Expect an overview of at most 1,200 characters, then "$G" usage shows a row with task overview and source explainer. Run it again: it returns the same text at once with no subagent and no new usage row.
  3. Edit a function in packages/utils/src/date.ts (add a statement) and run /codeplumb:overview @acme/utils again: a new overview is written.
  4. Run /codeplumb:map project-map ws:@acme/utils. Expect a http://127.0.0.1:<port>/... link; open it. Select the @acme/utils workspace: the inspector shows "Overview — generated, may be wrong" with the text from step 3. Select @acme/web: it shows "Run /codeplumb:overview ws:@acme/web in Claude Code".
  5. git -C "$FX" status --porcelain is empty (nothing was written into the repo) and /agents shows explainer with no Write, Edit or Bash tool.

Clean up with "$G" uninstall in $FX.