Skip to content

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

Open
jawwad-ali wants to merge 1 commit 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 1 commit 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

@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

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