Skip to content

Release: v2.0.3 - #172

Merged
Minitour merged 4 commits into
mainfrom
develop
Aug 5, 2026
Merged

Release: v2.0.3#172
Minitour merged 4 commits into
mainfrom
develop

Conversation

@Minitour

@Minitour Minitour commented Aug 5, 2026

Copy link
Copy Markdown
Member

This pull request refactors how the CLI determines when to perform version checks and display update notices. It introduces utility functions to more accurately detect the current subcommand and skip version checks for specific commands, and adds tests to ensure this logic is robust.

CLI Version Check Logic Improvements:

  • Added cliSubcommandFromArgv and shouldSkipVersionCheck utilities to reliably identify the invoked subcommand and decide if the version check should be skipped (for upgrade and activity-ingest commands). [1] [2]
  • Updated src/cli/index.ts to use these utilities, ensuring version checks are only performed when appropriate and update notices are not shown for commands that must produce machine-readable output. [1] [2]

Testing Enhancements:

  • Added comprehensive tests for the new CLI subcommand detection and version check skipping logic in cli-subcommand.test.ts.

Minitour and others added 3 commits August 5, 2026 09:58
Skip the post-command upgrade notice for activity-ingest so provider gate
hooks receive parseable permission/continue JSON instead of JSON plus banner text.

Co-authored-by: Cursor <cursoragent@cursor.com>
Parse the first non-option argv token for version-check suppression so
`capa --no-color activity-ingest` keeps stdout JSON-only for gate hooks.

Co-authored-by: Cursor <cursoragent@cursor.com>
fix(cli): keep activity-ingest stdout JSON-only for Cursor gate hooks
Copilot AI lite review requested due to automatic review settings August 5, 2026 07:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix CLI version-check gating for JSON-only subcommands

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Detect the invoked subcommand even when global flags come first.
• Skip background version checks and post-command update banners for JSON-only commands.
• Add unit tests covering argv parsing and skip rules.
Diagram

graph TD
  A["src/cli/index.ts"] --> B["cliSubcommandFromArgv(argv)"] --> C{"Skip version check?"} -->|"no"| D["checkForUpdates()"] --> E{"Has update?"} -->|"yes"| F["Print update notice"]
  C -->|"yes"| G["Run command only (stdout JSON-safe)"]
  E -->|"no"| G
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use Commander parsing to resolve the subcommand
  • ➕ Leverages the CLI framework’s understanding of commands/args (less bespoke argv logic).
  • ➕ Potentially more robust if global options or subcommands evolve.
  • ➖ Harder to do early because update-check is started before full command parsing/dispatch.
  • ➖ May require refactoring command registration/execution order.
2. Always emit update notices to stderr (never stdout)
  • ➕ Guarantees machine-readable stdout for all commands without per-command allowlists.
  • ➕ Simplifies gating logic (version check can still run).
  • ➖ Behavior change for users/scripts expecting notices on stdout.
  • ➖ Some environments may not surface stderr by default (reduced visibility).
3. Config-driven suppression (env var / config file) for hook contexts
  • ➕ Decouples behavior from subcommand names; hooks can opt-out explicitly.
  • ➕ Avoids maintaining a growing list of special-case commands.
  • ➖ Requires external coordination/documentation and changes in hook invocations.
  • ➖ Still needs a default policy for typical users.

Recommendation: The PR’s approach (early argv-based subcommand detection + explicit skip list) is a pragmatic fix because it runs before command execution and directly protects JSON-only stdout for known hook subcommands. If more machine-readable commands appear, consider moving notices to stderr to avoid accumulating skip rules.

Files changed (3) +60 / -3

Bug fix (1) +11 / -3
index.tsGate update checks/notices based on parsed subcommand +11/-3

Gate update checks/notices based on parsed subcommand

• Replaces a hard-coded 'process.argv[2] === 'upgrade'' check with utilities that derive the first non-flag token as the subcommand. Skips starting 'checkForUpdates()' and suppresses the post-command update banner when the subcommand is 'upgrade' or 'activity-ingest' to keep stdout strictly machine-readable.

src/cli/index.ts

Refactor (1) +13 / -0
cli-subcommand.tsIntroduce CLI subcommand and version-check gating utilities +13/-0

Introduce CLI subcommand and version-check gating utilities

• Adds 'cliSubcommandFromArgv()' to find the first non-option token after the runtime/script args. Adds 'shouldSkipVersionCheck()' to centralize the allowlist of subcommands that must not append human-readable output after execution.

src/cli/utils/cli-subcommand.ts

Tests (1) +36 / -0
cli-subcommand.test.tsAdd tests for argv subcommand detection and skip rules +36/-0

Add tests for argv subcommand detection and skip rules

• Introduces Bun tests validating that the subcommand resolver ignores leading global options and that version-check skipping applies only to 'upgrade' and 'activity-ingest'. Covers undefined/other subcommand cases to prevent regressions.

src/cli/utils/tests/cli-subcommand.test.ts

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Skip wrap process-table scans when a project has no workspace markers,
raise the Windows job test timeout to 20s, and retry temp dir cleanup
after SQLite close on EBUSY/EPERM.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings August 5, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Minitour
Minitour merged commit 7ab8e48 into main Aug 5, 2026
14 checks passed
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