Skip to content

feat(dev-tooling)!: port worktree targeting from upstream - #2

Merged
ROBJkE merged 2 commits into
mainfrom
cursor/cursor-native-upstream-sync-e5a2
Sep 22, 2026
Merged

ROBJkE merged 2 commits into
mainfrom
cursor/cursor-native-upstream-sync-e5a2

Conversation

@cursor

@cursor cursor Bot commented Sep 19, 2026

Copy link
Copy Markdown

Summary

Merges upstream df8444d (feat(dev-tooling)!: target linked git worktrees in every environment) into the Cursor-only main line and keeps Cursor packaging intact.

The three MCP servers captured their project root once at launch, so a session working in a linked git worktree ran PHPStan, PHPUnit, ESLint and the builds against the main checkout. Every tool now takes an optional project_root. set_project_root sticks a default per server process and cwd reports the resolution state. Targeting works under native, docker, docker-compose, vagrant and ddev. A worktree whose .git file carries an absolute gitdir pointer is refused; relink with git -c worktree.useRelativePaths=true worktree repair (git 2.48+). worktree_prepare installs composer or npm dependencies in the target tree. The vendored protocol handler moves to bash-mcp-sdk v5.1.0.

Cursor adaptations

  • Kept .cursor-plugin/ metadata, mcp.json with ${CURSOR_PLUGIN_ROOT}, and camelCase hook events. Did not restore .claude-plugin/, .lsp.json, or PascalCase hooks.
  • worktree-directives.sh fires on git worktree add / git worktree remove (beforeShellExecution and postToolUse) and emits additional_context instead of Claude's hookSpecificOutput envelope.
  • dev-tooling-runner still documents the worktree_prepare / set_project_root exclusions in the agent body. No Claude tools / disallowedTools / model / color frontmatter.
  • Skill frontmatter stays name / version / description only.

Version bumps

Plugin From To Why
dev-tooling 4.0.0 5.0.0 Breaking worktree + response-banner + undeclared-parameter refusal
shopware-env 2.0.0 2.1.0 Shared environment / docker-compose mapping used by worktree targeting
test-writing 6.0.0 6.0.1 Vendored bash-mcp-sdk v5.1.0

Breaking change

Most tool results begin with Project root: <path> (launch|sticky|call). A call carrying a parameter the tool does not declare is refused. The handler requires bash 4.1 and jq 1.7.

Validation

  • .github/scripts/validate-cursor-plugins.sh
  • .github/scripts/validate-versions.sh
  • .github/scripts/validate-issue-templates.sh
  • .github/scripts/vendor-mcp-sdk.sh --check
  • template-sync pairs from .github/workflows/validate.yml
  • BATS: worktree suites, mcp-shared, MCP tool suites, hook enforcement, shopware-env, test-writing
Open in Web View Automation 

SpiGAndromeda and others added 2 commits September 16, 2026 23:46
…hopwareLabs#186)

The three MCP servers captured their project root once at launch, so a session working in a linked git worktree ran PHPStan, PHPUnit, ESLint and the builds against the main checkout while editing the worktree. The results parsed as valid and described the wrong tree. Every tool now takes an optional `project_root`. `set_project_root` sticks a default per server process and `cwd` reports the resolution state. Precedence is per-call argument, then sticky value, then launch root, and most results begin with a `Project root: <path> (launch|sticky|call)` banner so the tree a result describes is visible in the transcript.

Targeting works under `native`, `docker`, `docker-compose`, `vagrant` and `ddev`. The environment layer maps a host root onto the environment-side path: the configured workdir plus the worktree's position below the launch root, under `docker-compose` a configured workdir or the destination of the longest matching bind mount, with both sides of every containment and mapping comparison canonicalized so a symlinked spelling cannot refuse a reachable root. Under the container environments the worktree has to sit inside the launch root, the only tree the container mounts. The `.git` file has to carry a relative `gitdir` pointer in every environment (an absolute pointer names a host path no container holds), and the refusal quotes the repair command (`git -c worktree.useRelativePaths=true worktree repair`, git 2.48+). A back-pointer written relative resolves against the per-worktree directory that holds it. An environment name outside the known set is refused rather than run as native, with the container set in one `_env_is_container_environment` predicate read by containment, charset and probe alike. Roots the wrappers cannot embed are refused per environment, an existence probe through the call's own wrapper confirms the environment reaches the mapped path (cached per environment, root and mapped path), a worktree's own config is re-derived per call while the launch binding stays inert until restart, `docker compose` invocations stay anchored to the launch root because compose discovers its project from the working directory, and `ddev` names the resolved workdir with `exec -d` for worktree targets.

`worktree_prepare` on each server provisions what a fresh worktree lacks: `composer install --no-interaction` on `php-tooling` at the effective root (the directory the dependency gate checks, so scope deliberately does not redirect it) and `npm ci` in the scope-aware package directory on the JS servers, run through the environment wrappers so a container install happens inside the container at the mapped path. The dependency refusals name it as the remedy, a successful install returns a short summary instead of the per-package output, and the `dev-tooling-runner` agent's `disallowedTools` blocks it so a check-only dispatch cannot be steered into a `node_modules`-rewriting install. Symlinking `vendor/` from the launch tree is ruled out in the descriptions because composer's autoloaders resolve `__DIR__` through the symlink and load the launch tree's classes. A `PostToolUse` hook on `EnterWorktree`/`ExitWorktree` reminds the session to repoint all three servers, names the repair command up front when the created worktree carries an absolute pointer, and warns that a native worktree branches from the default remote branch unless `worktree.baseRef` is `head`.

Fixes riding along: six tools declared a `scope` parameter and never resolved it; `console_run` resolved a relative `output_file` against `$PWD` instead of the project root; a relative path carrying `..` reached a worktree-targeted call while its absolute spelling was refused; `docker-compose` workdir resolution accepts an ancestor bind mount via longest-prefix matching instead of demanding an exact source; jest's `install_if_missing` measured an environment-side path with a host `[[ -d ]]` and paid a full `npm ci` on every scoped container run; and the native wrappers no longer embed a `cd` in the command text because `exec_command`/`exec_npm_command` enter the working directory themselves, which also fixes the unscoped native branch that ran in the server process's own directory.

The vendored protocol handler moves to bash-mcp-sdk v5.1.0, which re-runs the `EXIT` trap its own signal handling displaces. Temp files no longer survive a signalled shutdown, and the servers drop the subshell isolation that worked around it. The three server entry points share `shared/server_run.sh`, `config.sh`'s cleanup is the documented `config_cleanup`, and `get_environment_info` is removed (no callers).

test-writing's rule catalog is corrected alongside: remediations Shopware's static gates reject are rescoped or removed (CONV-007 and MIGRATION-007 fall to mechanically enforced php-cs-fixer and phpstan-phpunit rules), and a remediation invariant lands in the reviewing skills and team-review prompts. A suggested fix never changes what an existing assertion pins.

BREAKING CHANGE: most tool results begin with the `Project root:` banner line ahead of the tool's own output, which changes the shape consumers parse (`set_project_root` and `cwd` carry no banner). A call carrying a parameter the tool does not declare is refused instead of ignored. A worktree whose `.git` file carries an absolute `gitdir` pointer is refused in every environment; relink with `git -c worktree.useRelativePaths=true worktree repair <worktree-path>` (git 2.48+) or create worktrees with `--relative-paths`, and `git config worktree.useRelativePaths true` makes every later worktree relative-linked from the start. The vendored handler enforces a startup floor of bash 4.1 and jq 1.7.

Co-Authored-By: Claude <noreply@anthropic.com>
Merge origin/upstream (df8444d) into the Cursor-only main line. The three MCP servers now take an optional project_root, stick a default with set_project_root, and report resolution state via cwd. Targeting works under native, docker, docker-compose, vagrant, and ddev. A worktree with an absolute gitdir pointer is refused in every environment; relink with git -c worktree.useRelativePaths=true worktree repair (git 2.48+). worktree_prepare installs composer or npm dependencies in the target tree. The vendored protocol handler moves to bash-mcp-sdk v5.1.0.

Cursor adaptations: keep .cursor-plugin packaging and camelCase hooks; fire worktree-directives on git worktree add/remove and emit additional_context; document the runner's worktree_prepare and set_project_root exclusions in the agent body rather than Claude frontmatter. shopware-env 2.1.0 and test-writing 6.0.1 pick up the shared environment and SDK updates.

BREAKING CHANGE: most tool results begin with a Project root banner. A call carrying an undeclared parameter is refused. The handler requires bash 4.1 and jq 1.7.

Co-authored-by: ROBJkE <ROBJkE@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

@ROBJkE
ROBJkE marked this pull request as ready for review September 22, 2026 07:19
@ROBJkE
ROBJkE merged commit a86e272 into main Sep 22, 2026
12 checks passed
@ROBJkE
ROBJkE deleted the cursor/cursor-native-upstream-sync-e5a2 branch September 22, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants