feat(cli): detect all major AI-agent harnesses for the agent reporter - #455
Conversation
|
Warning Review limit reached
Next review available in: 54 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe CLI now detects recognized AI-agent harnesses through Gunshi agent profiles and supports ChangesAgent reporter detection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant ReporterResolver
participant Gunshi
participant Reporter
CLI->>ReporterResolver: resolve reporter
ReporterResolver->>Gunshi: getAgentProfile(process.env)
Gunshi-->>ReporterResolver: recognized harness profile
ReporterResolver-->>CLI: agent reporter selection
CLI->>Reporter: emit agent output
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/cli/test/reporter-resolve.test.ts (1)
20-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winName the test after its observable behavior.
Remove the Gunshi implementation details and E2E reference from the test name. Name the test for the false result from an injected harness variable.
Proposed change
- it('does not recognize harness-specific vars (e.g. CLAUDECODE) in an injected env — that detection is delegated to gunshi/agent, which only reads the real process.env; see scripts/cli-e2e.mjs for the end-to-end coverage', () => { + it('returns false for harness-specific variables in an injected environment', () => {As per coding guidelines, tests must be named after the behavior they verify, not the reasoning behind the implementation.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/test/reporter-resolve.test.ts` at line 20, Rename the test case around the observable outcome: an injected harness-specific environment variable does not trigger detection. Remove references to Gunshi, delegation, real process.env, and E2E coverage from the test name while preserving the test behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/cli-e2e.mjs`:
- Around line 53-76: Update cleanEnv() to construct the child environment from
an explicit allowlist of required OS variables instead of spreading process.env
and deleting AGENT_DETECTION_ENV_KEYS. Preserve applying the provided overrides
last, and remove the deny-list-based inheritance so newly introduced detection
signals cannot leak into the fallback environment.
---
Nitpick comments:
In `@packages/cli/test/reporter-resolve.test.ts`:
- Line 20: Rename the test case around the observable outcome: an injected
harness-specific environment variable does not trigger detection. Remove
references to Gunshi, delegation, real process.env, and E2E coverage from the
test name while preserving the test behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1cd1b8e4-4cdf-484c-9bab-f71f10d6e921
📒 Files selected for processing (12)
.changeset/agent-detection-via-gunshi.mddocs/src/content/docs/guides/(reporting)/reporters.mddocs/src/content/docs/guides/(setup)/cli.mddocs/src/content/docs/ja/guides/(reporting)/reporters.mddocs/src/content/docs/ja/guides/(setup)/cli.mdpackages/cli/docs/output.mdpackages/cli/src/docs/generated.tspackages/cli/src/reporter-resolve.tspackages/cli/test/pulse-animation.test.tspackages/cli/test/reporter-resolve.test.tspackages/cli/test/run.test.tsscripts/cli-e2e.mjs
…#448) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
33f8a75 to
ada0519
Compare
Follow-up to the gunshi migration (#448 plan): the agent reporter's auto-selection now recognizes the major AI-agent harnesses instead of a two-entry allow-list.
Before / after
The curated list detected exactly
CLAUDECODE(+ theSVELTE_VITALS_AGENTopt-in) — so Cursor, Codex, Replit, Gemini CLI, and every other harness got console output despite the help text promising "auto-selected under AI-agent envs". Detection now delegates togunshi/agent'sgetAgentProfile()(std-env, inlined in gunshi, zero new deps): Claude Code, Cursor (CURSOR_AGENT), Codex, Replit, Gemini, opencode, auggie, goose, devin, kiro, plus theAI_AGENTuniversal override — all env-var-based, no TTY heuristics (the design constraint holds; verified from the bundled detection source). The recognized list evolves with gunshi updates behind the exact pin.The testability mechanism (the subtle part)
std-env computes its profile once at gunshi's module load from the real
process.env— no in-process env stub can exercise it (verified empirically;vi.resetModulesdoesn't re-run an externalized dependency's init). Resolution:isAgentEnv(env)keeps its injectable signature — theSVELTE_VITALS_AGENTopt-in reads the PASSED env (fully testable), and the gunshi delegation fires only whenenvisprocess.envby reference, which is exactly the production default (opts.env ?? process.env) and never a test's literal object. Zero production call-site changes; the constraint is documented at the function. The delegation itself is tested for real inscripts/cli-e2e.mjs(now 10 checks): fresh child processes of the built CLI with ambient agent signals scrubbed, asserting clean-env→console,CLAUDECODE→agent, andCURSOR_AGENT→agent.Also fixed en route (root-caused): the e2e harness's
execFileSyncdiscarded stderr on zero-exit runs — the exact stream the auto-selection hint uses — switched tospawnSyncwith uniform stream capture.Precedence is unchanged and pinned: explicit
--reporter>SVELTE_VITALS_REPORTER> agent env > GitHub Actions > console. Docs (en/ja reporters + CLI guides, bundledoutputtopic) updated without hard-coding an agent-name list (anti-rot rule). Changeset:svelte-vitalsminor declaring the widened detection.Gates: full suite green, e2e 10/10, lint/typecheck clean.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
SVELTE_VITALS_AGENT=1.Documentation