Repository navigation
fix(setup): resolve comdev MCP dirs from the registered index.js - #2199
Conversation
The refresh commands built the npm-install directory as mcp/<server>, but the registered names (ponymail, apache-projects) are not the directories (mcp/ponymail-mcp, mcp/apache-projects-mcp), so every printed cd failed. Under the sandbox the agent also cannot read ~/.claude.json and handed the operator an unresolved <comdev> placeholder. Take the server dir from the index.js in the registration, print only resolved paths, and give a self-resolving jq check for when the registration cannot be read. A test runs that check against a fake registration and a real checkout. Generated-by: Claude Code (Opus 5.5)
Address adversarial-review findings on the self-resolving fallback: merge the check and refresh loops into one script with refresh=no|yes, cover every registration (user, per-project, ./.mcp.json), skip a checkout whose origin is not apache/comdev, that is off main, or whose fetch failed, print the compare link, and fast-forward to the checked origin/main only. Tests run it under bash and zsh with upstream ahead. Generated-by: Claude Code (Opus 5.5)
Address the second adversarial review: read only ~/.claude.json, never a writable ./.mcp.json; match the origin exactly against apache/comdev on GitHub via git remote get-url --all, so insteadOf rewrites, extra URLs and lookalike hosts are skipped; compare and fast-forward to the fetched commit; keep git and npm off the loop's stdin; report a missing jq or malformed JSON; retry npm install on the next run. Run it in a subshell with no # comments so a paste into interactive zsh works. Generated-by: Claude Code (Opus 5.5)
Address the third adversarial review: refresh=<commit> fast-forwards to exactly the commit the operator reviewed, only when it is on the main just fetched, so a later push is never pulled in unseen and two servers sharing a checkout end on one commit; run fetch and merge with core.hooksPath=/dev/null; accept only absolute index.js args; skip unexpected JSON shapes instead of aborting. Generated-by: Claude Code (Opus 5.5)
Address the fourth adversarial review: take only a full commit hash in refresh=, check every checkout before changing any, and leave alone one with local changes or already past the reviewed commit, so npm install runs only on the reviewed tree; confirm HEAD ends at that commit. State that the script trusts the checkout's own .git/config. Generated-by: Claude Code (Opus 5.5)
Address the fifth adversarial review: the hash check's [!0-9a-f] made interactive zsh fail with "event not found" (history expansion), so use [^0-9a-f] and test a real paste into zsh -f -i. Say which line to edit for refresh=, and name local commits as well as an advanced checkout when HEAD is not an ancestor of the reviewed commit. Generated-by: Claude Code (Opus 5.5)
|
@potiuk heads-up:
The PR run stayed green because both workspace hooks' I have a small fix ready (the |
|
Update: this also turns |
|
Fix in #2202. |
|
@potiuk one more thing I noticed while testing #2202, separate from the lint fix:
Adding |
prek on main has failed since #2199: ruff format wants to wrap three long lines in the isolated-setup-update comdev MCP test, and mypy rejects passing `REAL_GIT` (`str | None` from `shutil.which`) into the `subprocess.run` argument list. The test class is already skipped when git is missing, so `_git` now asserts that invariant, which narrows the type. No behaviour change: 24 passed, 1 skipped (needs zsh). Generated-by: Claude Code (Opus 5.5)
|
@potiuk update: #2202 is merged (approved by Kaap10), and |
* fix(ci): run workspace checks on plugins and ai-tutors The ruff, ruff-format and mypy workspace hooks filtered on `tools/` paths only, so a pull request that changed Python under `plugins/` or `ai-tutors/` skipped all three while `main` still checked them. That is how the formatting and typing break in #2199 reached `main`. Extend the shared filter to the two members and pin it with a test that runs every member path through each hook's pattern. Generated-by: OpenCode v2.3.2 (DeepSeek V4.1 Flash 1017) * fix(ci): widen workspace hook filters to every member path The previous filter only recognised `src/`, `tests/` and a top-level `pyproject.toml` under a `tools/` member, and only a top-level `pyproject.toml` under `plugins/`. Scripts at a member root, such as `tools/dev/check-doc-sync.py`, and nested member configs under `plugins/magpie-*/tools/` still skipped ruff and mypy on a pull request. Match Python and `pyproject.toml` anywhere under the three trees, the same scope `workspace-pytest` already uses. Derive the test paths from `git ls-files` filtered by the workspace members so a new member or a new layout inside one cannot slip past, and pin the deliberate Markdown-only skip with a negative case. --------- Co-authored-by: Kavya Katal <[email protected]>
Summary
comdev-mcp.mdandsetup updateStep 6e built thenpm installdirectory asmcp/<server>. That uses the registered server names (ponymail,apache-projects), but theapache/comdevdirectories aremcp/ponymail-mcpandmcp/apache-projects-mcp.<server-dir>is now the directory holding theindex.jsin the registeredargs, and<root>comes fromgit rev-parse --show-toplevel. Printed commands must carry resolved absolute paths, never a placeholder.~/.claude.json, so the agent handed the operator an unresolved<comdev>placeholder.comdev-mcp.mdgains When the registration cannot be read: one script the operator pastes into bash or zsh.index.jspaths from~/.claude.json, never a.mcp.jsonthat a cloned repo or an agent could write.apache/comdevon GitHub, asgit remote get-url --allreports it afterinsteadOfrewrites, or that is not onmain, or whose fetch failed.fetchandmergewithcore.hooksPath=/dev/null, so no hook in the checkout runs.refresh=<commit>takes only the full 40-character commit the report printed and fast-forwards to exactly that commit.mainjust fetched, where the checkout is already past it, or where the working tree has local changes.npm installin each server's own directory, so a shared checkout ends on one commit and a later run retries a failed install.setup updateStep 6e and the paste-in prompt indocs/setup/secure-agent-setup.mdpoint at it, and the prompt dropsmcp/<server>/.Type of change
.claude/skills/<name>/): eval fixtures updated belowdocs/,README.md,CONTRIBUTING.md)Test plan
prek run --files <changed files>passes. Its only change was refreshing thesurface_hashinsetup-isolated-setup-update/SKILL.md.plugins/magpie-setup/skills/isolated-setup-update/tests/test_comdev_mcp.py, picked up bytools/dev/run-skill-script-tests.sh. It has 25 tests: 2 check the docs, 23 run the documented script under bash and zsh. One of them pipes it into an interactivezsh -f -i, as a real paste runs, with history expansion and no interactive comments.~/.claude.jsonand a real temporary checkout whose upstream is one commit ahead; the temp path contains a space.gitwrapper on PATH sends onlyfetchto the local upstream, so the origin check still sees the real GitHub URL.npmthat reads stdin;mainhas moved on since, and refuses a commit that is not on the fetchedmain, a checkout already past it, a checkout with modified or untracked files, and anything but a full commit hash (main,origin/main, a short or upper-case hash,-x);npm installis retried on the next run;reference-transaction,post-merge,post-checkout) never run;.mcp.json, relative paths and--require=…args are ignored;github.com,http://, local paths, aninsteadOfrewrite, a second origin URL;setup-isolated-setup-update: not run, because it needs model access. No existing fixture covers the comdev check.RFC-AI-0004 compliance
~/.claude.json. The script acts only on checkouts registered there, which a sandboxed agent cannot write, and runs none of their git hooks. Beyond hooks it trusts the checkout's own.git/config, as any git command run there does.Linked issues
None. Found while running
setup-upgradeandsetup-isolated-setup-updateon an ASF tracker: the printed( cd <comdev>/mcp/ponymail && npm install )failed whatever directory it was run from.Notes for reviewers (optional)
jq, which ships in/usr/binon macOS 15 and later. It says so whenjqis missing.( … )subshell, so a pastedexitcannot close the terminal. It carries no#comments and no!: interactive zsh does not treat#as a comment by default, and takes!for history expansion.npm installstill runs the packages' install scripts, as the documented manual refresh always has. The script narrows what it installs to a reviewed commit ofapache/comdevmain.🤖 Generated with Claude Code