Fix agents version stderr parsing#547
Conversation
Greptile SummaryThis PR fixes a stdout/stderr fallback bug in
Confidence Score: 5/5Safe to merge — the change is a narrow, well-tested fix to a stdout/stderr fallback expression, accompanied by validator cleanup that removes duplicate code without altering observable behaviour. The core change is a single-line expression swap with clear semantics, backed by a dedicated regression test. Duplicate function removals in the target packages consolidate identical or overlapping logic with no missing call sites. All existing tests continue to pass and new ones specifically cover the fixed path. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[probeAgent called] --> B[spawnSync binary --version]
B --> C{result.error OR\nstatus !== 0?}
C -- Yes --> D[Return installed: false]
C -- No --> E{stdout.trim\ntruthful?}
E -- Yes --> F[raw = stdout.trim]
E -- No --> G{stderr.trim\ntruthful?}
G -- Yes --> H[raw = stderr.trim]
G -- No --> I[raw = '']
F --> J[regex match semver]
H --> J
I --> J
J --> K{match found?}
K -- Yes --> L[version = captured group]
K -- No --> M[version = first line of raw]
L --> N[Return installed: true, version]
M --> N
Reviews (3): Last reviewed commit: "Reset agents spawn mock between tests" | Re-trigger Greptile |
|
Update: the failing test workflow was the same repo-wide package-target duplicate validator issue already affecting other PRs, not the agents change. I folded in the package-validator cleanup so this PR can run the full suite independently.\n\nVerification after the update:\n- npx --yes pnpm@9.12.0 exec vitest run packages/cli/src/commands/agents.test.ts packages/targets/pkg-flatpak/src/index.test.ts packages/targets/pkg-winget/src/index.test.ts packages/targets/pkg-snap/src/index.test.ts -> 26 passed\n- npx --yes pnpm@9.12.0 --filter @profullstack/sh1pt --filter @profullstack/sh1pt-target-pkg-flatpak --filter @profullstack/sh1pt-target-pkg-winget --filter @profullstack/sh1pt-target-pkg-snap typecheck -> passed |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
61545ab to
397b6a4
Compare
|
Follow-up update: I rebased this branch onto current master and addressed Greptile's test-isolation note by resetting the mocked spawnSync in beforeEach before applying the default mock return value.\n\nFresh verification after the rebase:\n- npx --yes pnpm@9.12.0 exec vitest run packages/cli/src/commands/agents.test.ts packages/targets/pkg-flatpak/src/index.test.ts packages/targets/pkg-winget/src/index.test.ts packages/targets/pkg-snap/src/index.test.ts -> 4 files / 26 tests passed\n- npx --yes pnpm@9.12.0 --filter @profullstack/sh1pt --filter @profullstack/sh1pt-target-pkg-flatpak --filter @profullstack/sh1pt-target-pkg-winget --filter @profullstack/sh1pt-target-pkg-snap typecheck -> passed |
Fixes #546.
What changed
agents listnow falls back to stderr when stdout is empty for successful<binary> --versionprobes.claude 1.2.3to stderr.Why
Some CLIs print version information on stderr. The previous
result.stdout ?? result.stderrexpression ignored stderr whenever stdout was an empty string, so JSON output reported installed agents withversion: "".Verification
npx --yes pnpm@9.12.0 exec vitest run packages/cli/src/commands/agents.test.ts-> 4 passednpx --yes pnpm@9.12.0 --filter @profullstack/sh1pt typecheck-> passed