Skip to content

fix: align detection and init behavior across implementations#5

Merged
danjdewhurst merged 2 commits into
mainfrom
claude/repo-review-2dcg3o
Jun 11, 2026
Merged

fix: align detection and init behavior across implementations#5
danjdewhurst merged 2 commits into
mainfrom
claude/repo-review-2dcg3o

Conversation

@danjdewhurst

Copy link
Copy Markdown
Contributor

Fixes from a full repo review. The headline items are cross-implementation consistency bugs: identical inputs could produce different results in the TypeScript, Python, and Rust implementations, contrary to the portable detection contract.

Cross-implementation fixes (each pinned by new shared fixtures)

  • Equal-confidence tie-break: Rust's max_by picked the last maximal match, while TS/Python picked the first. With CURSOR_AGENT=1 GEMINI_CLI=1, Rust reported gemini and TS/Python reported cursor. All implementations now prefer the earliest rule in the registry.
  • Duplicate signals: a variable matching both an exact rule and a prefix rule (e.g. CURSOR_AGENT) was reported twice in signals. Results are now deduplicated.
  • Prefix signal ordering: Rust sorted prefix-matched signal names; TS and Python emitted env insertion order. TS and Python now sort too.
  • agenthint init --json: TS/Python printed AI_AGENT=--json (exit 0) while Rust exited 2. All CLIs now reject option-like names with the usage message and exit 2, and Rust's --help/init argument handling matches TS/Python exactly.
  • Cowork explainability: when CLAUDE_CODE_IS_COWORK classifies the result as cowork, the classifier signal is now included in signals.

Cleanups

  • TS: one shared AI_AGENT normalizer (src/agent-names.ts) for detection and init; removed the dead isKnownAgent branch. Public exports unchanged.
  • Rust: use parent_id() instead of spawning ps to find the parent pid.
  • Python: cache the detection-rules JSON instead of re-parsing per call.
  • Node CLI test: compare stdoutContains fixtures literally (matching Rust/Python) instead of as regex.

Tooling and docs

  • Build and install linux-arm64 native binaries (ubuntu-24.04-arm matrix entry + install.sh detection).
  • Commit the up-to-date Cargo.lock, guard CI with cargo metadata --locked, and add the release-please cargo-workspace plugin so version bumps keep the lockfile in sync (worth eyeballing on the next release PR).
  • Pin Python in .mise.toml so npm run check works out of the box.
  • Document AGENTHINT_AGENT, the ordering/dedup/tie-break contract in SPEC, the REPL_ID false-positive caveat, and the Windows parent-process limitation.

Deliberately unchanged: REPL_ID still reports isAgent: true at 0.65 confidence — documented the threshold guidance instead of changing detection semantics.

https://claude.ai/code/session_01R7u5FuNixEbMNQiFGBBx3H


Generated by Claude Code

claude added 2 commits June 10, 2026 21:58
- Resolve equal-confidence ties to the earliest rule in all languages
  (Rust previously picked the last match)
- Deduplicate signals when a variable matches both an exact rule and a
  prefix rule
- Sort prefix-matched signal names in TypeScript and Python to match Rust
- Include env:CLAUDE_CODE_IS_COWORK in signals when it classifies cowork
- Reject option-like names in 'agenthint init' consistently (exit 2)
- Share one AI_AGENT normalizer between detection and init in TypeScript
- Use parent_id() instead of spawning ps to find the Rust parent pid
- Cache detection rules in the Python library
- Compare CLI fixture stdoutContains literally in the Node test
- Build and install linux-arm64 native binaries
- Guard CI against a stale Cargo.lock and update release-please to keep
  it in sync; pin Python in mise
- Document AGENTHINT_AGENT, ordering/tie rules, REPL_ID confidence, and
  the Windows parent-process limitation

https://claude.ai/code/session_01R7u5FuNixEbMNQiFGBBx3H
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@danjdewhurst, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 15 seconds. Learn how PR review limits work.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7fa45694-30e9-43d4-ab69-aed6e985460c

📥 Commits

Reviewing files that changed from the base of the PR and between 3beb9d5 and 169555e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • .github/release-please-config.json
  • .github/workflows/ci.yml
  • .github/workflows/native-binaries.yml
  • .mise.toml
  • README.md
  • SPEC.md
  • crates/agenthint/src/lib.rs
  • crates/agenthint/src/main.rs
  • docs/signals.md
  • fixtures/cli-cases.json
  • fixtures/detection-cases.json
  • install.sh
  • python/agenthint/__init__.py
  • python/agenthint/cli.py
  • src/agent-names.ts
  • src/cli.ts
  • src/index.ts
  • src/init.ts
  • test/cli.test.mjs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@danjdewhurst danjdewhurst merged commit 87fd407 into main Jun 11, 2026
1 of 2 checks passed
@danjdewhurst danjdewhurst deleted the claude/repo-review-2dcg3o branch June 11, 2026 06:32
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.

2 participants