Bug Description
When dispatching workflow commands via the opencode integration, OpencodeIntegration inherits build_exec_args() from MarkdownIntegration, which generates ["opencode", "-p", "/speckit.specify ..."]. The opencode CLI does not support the -p short flag — it uses --prompt (long form only) for prompt input, and the intended headless dispatch mode is opencode run [message..].
When opencode receives the unrecognized -p flag, it prints its full help text and exits — the workflow step sees exit code 0 but no actual output, causing the step to fail silently.
Steps to Reproduce
- Initialize a project with opencode:
specify init --ai opencode
- Run a workflow:
specify workflow run speckit --input spec="build a login page" --input integration=opencode
- Observe: opencode prints its CLI help text instead of executing the
/speckit.specify command
- The workflow step fails with empty stdout/stderr and
exit_code: 0 (help exits successfully)
Expected Behavior
The workflow should dispatch opencode run "/speckit.specify build a login page" which:
- Uses the
run subcommand (headless/batch mode, not interactive TUI)
- Processes the slash-command from
.opencode/command/speckit.specify.md
- Runs to completion and exits with the appropriate exit code
Actual Behavior
The inherited build_exec_args() generates ["opencode", "-p", "/speckit.specify build a login page"]. Since -p is not a valid opencode flag, opencode prints its help text and exits — no command is executed.
Environment
- Specify CLI Version: 0.8.3.dev0
- AI Agent: opencode
- Operating System: Linux x86_64
- Python: 3.12.3
Error Output
$ specify workflow run speckit \
--input spec="$(cat ./01_chat_mvp.md)" \
--input integration=opencode
Running workflow: Full SDD Cycle (speckit)
Version: 1.0.0
▸ speckit.specify …
[opencode prints full CLI help text — same output as `opencode --help`]
Root Cause
Code location: src/specify_cli/integrations/opencode/__init__.py (21 lines)
OpencodeIntegration does NOT override build_exec_args(). It inherits from MarkdownIntegration which hardcodes -p:
# src/specify_cli/integrations/base.py, lines 833-847
class MarkdownIntegration(IntegrationBase):
def build_exec_args(self, prompt, *, model=None, output_json=True):
if not self.config or not self.config.get("requires_cli"):
return None
args = [self.key, "-p", prompt] # ← "-p" invalid for opencode
if model:
args.extend(["--model", model]) # ← opencode uses "-m"
if output_json:
args.extend(["--output-format", "json"]) # ← not supported
return args
Other integrations with non-standard CLI dispatch DO override build_exec_args() — e.g., CopilotIntegration (copilot/__init__.py line 127). OpencodeIntegration should do the same.
Proposed Fix
Override build_exec_args() in OpencodeIntegration:
def build_exec_args(self, prompt, *, model=None, output_json=True):
"""Build CLI args for opencode headless dispatch via ``run`` subcommand."""
args = [self.key, "run", prompt]
if model:
args.extend(["-m", model])
return args
Key changes:
- Replace
-p flag with run subcommand (opencode headless/batch mode)
- Use
-m instead of --model (matches opencode actual flag)
- Drop
--output-format json (not supported by opencode)
Additional Context
The "auto" integration resolution (which reads .specify/integration.json) works correctly — when a project is initialized with --ai opencode, the engine correctly resolves the integration key to "opencode". The bug is solely in the CLI argument construction.
A full forensic analysis with evidence chain is documented in the repo.
Bug Description
When dispatching workflow commands via the opencode integration,
OpencodeIntegrationinheritsbuild_exec_args()fromMarkdownIntegration, which generates["opencode", "-p", "/speckit.specify ..."]. The opencode CLI does not support the-pshort flag — it uses--prompt(long form only) for prompt input, and the intended headless dispatch mode isopencode run [message..].When opencode receives the unrecognized
-pflag, it prints its full help text and exits — the workflow step sees exit code 0 but no actual output, causing the step to fail silently.Steps to Reproduce
specify init --ai opencodespecify workflow run speckit --input spec="build a login page" --input integration=opencode/speckit.specifycommandexit_code: 0(help exits successfully)Expected Behavior
The workflow should dispatch
opencode run "/speckit.specify build a login page"which:runsubcommand (headless/batch mode, not interactive TUI).opencode/command/speckit.specify.mdActual Behavior
The inherited
build_exec_args()generates["opencode", "-p", "/speckit.specify build a login page"]. Since-pis not a valid opencode flag, opencode prints its help text and exits — no command is executed.Environment
Error Output
Root Cause
Code location:
src/specify_cli/integrations/opencode/__init__.py(21 lines)OpencodeIntegrationdoes NOT overridebuild_exec_args(). It inherits fromMarkdownIntegrationwhich hardcodes-p:Other integrations with non-standard CLI dispatch DO override
build_exec_args()— e.g.,CopilotIntegration(copilot/__init__.pyline 127).OpencodeIntegrationshould do the same.Proposed Fix
Override
build_exec_args()inOpencodeIntegration:Key changes:
-pflag withrunsubcommand (opencode headless/batch mode)-minstead of--model(matches opencode actual flag)--output-format json(not supported by opencode)Additional Context
The
"auto"integration resolution (which reads.specify/integration.json) works correctly — when a project is initialized with--ai opencode, the engine correctly resolves the integration key to"opencode". The bug is solely in the CLI argument construction.A full forensic analysis with evidence chain is documented in the repo.