fix(statusline): getPkgVersion() resolves main repo node_modules when CWD is a git worktree (#2742) - #2743
Closed
michaelaperez-byte wants to merge 1 commit into
Closed
Conversation
… CWD is a git worktree (ruvnet#2742)
Contributor
Author
|
Superseded by merged PR #2747 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2742
When Claude Code runs inside a git worktree (common multi-agent pattern), the worktree has no
node_modulesof its own.getPkgVersion()in the generated statusline (statusline.cjs) probedCWD/node_modules/...— which all missed — causing the statusline to show a stale baked-in version instead of the actually-installed one.Fix
Added a worktree probe to
getPkgVersion()that resolves the main reponode_moduleswhen CWD is a linked worktree. In a worktree,.gitis a plain file containinggitdir: /path/to/main/.git/worktrees/<name>. The probe:.gitentry.gitis a file (worktree indicator), reads thegitdir:linelastIndexOf('/.git/worktrees/')node_modules/ruflo/package.jsonandnode_modules/@claude-flow/cli/package.jsonto the candidate pathsPure
fsoperations — no process spawn (matches the template design constraint for the render path). Slots into the existing candidate list before the #2221 global-install probes, so the highest-version-wins selection applies unchanged.Changes
.claude/helpers/statusline.cjsgetPkgVersion())v3/@claude-flow/cli/.claude/helpers/statusline.cjsv3/@claude-flow/cli/__tests__/issue-2742-worktree-pkg-version.test.tsTotal: 3 files, +179 lines, 0 deletions (additive only).
Verification
Independent detached-HEAD worktree verification — all gates PASS:
RuFlo V3.6for global npm installs — statusline-generator version probe never checks the global node_modules (survives #2195) #2221 global probes. Pure fs, additive, both copies identical.node --checkexit 0 on both.cjscopies.diffof both copies = zero differences.statusline-cost-display(13/13),issue-2682-identity(2/2),issue-2694-cve-counter(8/8) all PASS — zero regressions..gitfile -> main repo root -> correct paths. Normal repo.gitdirectory -> correctly skipped.Context
Same function/lineage as #2195 and #2221 — this closes the remaining resolution gap for worktree environments. Reporter (Markus-Buchholz) provided the code snippet; this PR adapts it to the existing code style.
Generated by ruflo-loop (z-ai/glm-5.2, cheap tier).