Skip to content

fix(integrations): cursor-agent honors executable/extra-args env overrides#3265

Open
jawwad-ali wants to merge 2 commits into
github:mainfrom
jawwad-ali:fix/cursor-agent-executable-override
Open

fix(integrations): cursor-agent honors executable/extra-args env overrides#3265
jawwad-ali wants to merge 2 commits into
github:mainfrom
jawwad-ali:fix/cursor-agent-executable-override

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

Description

Spec Kit exposes two documented per-integration env hooks on every CLI-dispatch integration:

codex and devin both route through these helpers:

args = [self._resolve_executable(), "exec", prompt]
self._apply_extra_args_env_var(args)

But CursorAgentIntegration.build_exec_args() hardcoded self.key as argv[0] and never called _apply_extra_args_env_var():

args = [self.key, "-p", "--trust", "--approve-mcps", "--force", prompt]

So SPECKIT_INTEGRATION_CURSOR_AGENT_EXECUTABLE and SPECKIT_INTEGRATION_CURSOR_AGENT_EXTRA_ARGS were silently ignored for cursor-agent — the lone CLI-dispatch outlier.

Fix

Route argv[0] through self._resolve_executable() and apply the extra-args hook immediately after the mandatory headless flags (before the --model/--output-format extends), mirroring codex/devin. The mandatory -p --trust --approve-mcps --force flags are unchanged.

Testing

  • New test_build_exec_args_honors_executable_override and test_build_exec_args_honors_extra_args_override: fail before (argv[0]==cursor-agent, no --foo), pass after (verified by stashing the source — both fail). The mandatory-flags assertion still holds under the override.
  • The 39 existing tests pin argv[0]==cursor-agent only in the default no-env case (where _resolve_executable() falls back to self.key), so they stay green. TestCursorAgentCliDispatch passes (12); uvx ruff check clean.

AI Disclosure

  • I did use AI assistance (describe below)

Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI flagged the codex/devin-vs-cursor-agent parity gap; I confirmed the dropped overrides, proved fail-before via source-stash, and reviewed the diff before submitting.

…rrides

cursor-agent's build_exec_args() hardcoded self.key as argv[0] and never
called _apply_extra_args_env_var(), so the documented
SPECKIT_INTEGRATION_CURSOR_AGENT_EXECUTABLE (issue github#2596) and
SPECKIT_INTEGRATION_CURSOR_AGENT_EXTRA_ARGS (issue github#2595) hooks were
silently dropped — unlike every other CLI-dispatch integration (codex,
devin). Route argv[0] through _resolve_executable() and apply the
extra-args hook after the mandatory headless flags, mirroring the twins.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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.

Pull request overview

This PR fixes parity for the cursor-agent integration by ensuring it honors the same documented per-integration environment-variable hooks as other CLI-dispatch integrations (notably executable override and extra CLI args injection).

Changes:

  • Route CursorAgentIntegration argv[0] through self._resolve_executable() so SPECKIT_INTEGRATION_CURSOR_AGENT_EXECUTABLE is honored.
  • Invoke self._apply_extra_args_env_var(args) in CursorAgentIntegration.build_exec_args() so SPECKIT_INTEGRATION_CURSOR_AGENT_EXTRA_ARGS is applied.
  • Add targeted tests validating both overrides for cursor-agent.
Show a summary per file
File Description
src/specify_cli/integrations/cursor_agent/init.py Uses _resolve_executable() and _apply_extra_args_env_var() to honor executable and extra-args env overrides in cursor-agent CLI dispatch.
tests/integrations/test_integration_cursor_agent.py Adds tests for executable override and extra args injection for cursor-agent build_exec_args().

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines +155 to +158
i = get_integration("cursor-agent")
args = i.build_exec_args("/speckit-plan", output_json=False)
assert "--foo" in args
assert "bar" in args

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — fixed in aa20825. The test now exercises build_exec_args with both a model and JSON output and asserts the extra args land before --model and --output-format (args.index('--foo') < args.index('--model') / < args.index('--output-format')), plus that the canonical flags stay intact and paired. I verified it fails if _apply_extra_args_env_var is moved after the flag extends, so an insertion-order regression is now caught. (AI-assisted: Claude Code under my review.)

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address Copilot feedback

Per Copilot feedback: the extra-args override test only asserted the
injected tokens were present, not that they land before Spec Kit's
canonical --model / --output-format flags. Exercise build_exec_args with
both a model and JSON output and assert the extra args are inserted
before --model / --output-format (and the canonical flags stay intact and
paired). Verified this fails if the _apply_extra_args_env_var call is
moved after the flag extends.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jawwad-ali

Copy link
Copy Markdown
Contributor Author

Thanks @mnriem — addressed the Copilot feedback in aa20825: the extra-args test now pins insertion order (extra args before the canonical --model/--output-format, canonical flags intact), and I confirmed it fails if the hook is reordered after the flag extends. TestCursorAgentCliDispatch green (12), ruff clean. (AI-assisted: Claude Code under my direction and review.)

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Low

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.

3 participants