Repository navigation
fix(integrations): map Kimi Code JSON dispatch to --output-format stream-json - #5031
Open
RaycarlLei wants to merge 1 commit into
Open
RaycarlLei wants to merge 1 commit into
RaycarlLei wants to merge 1 commit into
Conversation
…eam-json KimiIntegration inherited SkillsIntegration.build_exec_args(), which appends --output-format json when output_json is true. Kimi Code CLI restricts --output-format to text and stream-json, so its option parser rejects the value and kimi exits 1 before the prompt runs. This is reachable through dispatch_command(stream=False) when output_json is left unset (it then resolves to True), and through direct build_exec_args() calls. Override build_exec_args() to request stream-json instead, keeping the base requires_cli guard and argument order (EXTRA_ARGS before --model). Assisted-by: Claude Code (model: Claude Opus 5.5, autonomous) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
KimiIntegrationdoes not overridebuild_exec_args(), so it inheritsSkillsIntegration.build_exec_args()(base.py#L1708-L1727), which appends--output-format jsonwhenoutput_jsonis true.Kimi Code CLI only accepts
textandstream-jsonfor that option. It is declared with Commander.choices(['text', 'stream-json'])(apps/kimi-code/src/cli/commands.ts#L70-L75) and documented indocs/en/reference/kimi-command.md#L22.472192cis the@moonshot-ai/kimi-code@2.2.0tag, the current npmlatest. Commander rejectsjsonwhile parsing options, before any prompt runs, so this reproduces without a Kimi account. WithKIMI_CODE_HOMEpointing at an empty directory (not logged in):The
stream-jsonrun gets past option parsing and only stops because that empty home has no model configured.The same failure through Spec Kit on
main(f68ffca), withkimi2.2.0 onPATH:Reachability. The built-in workflow steps do not hit this. The
commandstep either streams, whereoutput_jsonis left asNoneand resolves tonot stream, i.e.False(base.py#L463-L464), or captures with an explicitoutput_json=False(step/command/__init__.py#L313-L319). Thepromptstep passesoutput_json=False(step/prompt/__init__.py#L248-L253). It is reached through the publicdispatch_command(..., stream=False)whenoutput_jsonis left unset (it then resolves toTrue), through directbuild_exec_args()calls (defaultoutput_json=True), and by extensions or other callers of those APIs.Fix. Override
build_exec_args()inKimiIntegrationso structured output requests--output-format stream-json(JSONL events), the same approach Amp took with--stream-jsonin #4581. The rest matches the base implementation: therequires_cliguard,-p <prompt>,SPECKIT_INTEGRATION_KIMI_EXTRA_ARGSbefore--model, and--model, which Kimi accepts (-m, --model <model>,commands.ts#L58-L63). The override sits belowpost_process_skill_content(), clear of thebuild_command_invocation()removal in #4983.Part of #2416, which lists Kimi among the
SkillsIntegrationCLIs that inherit the-pargv without verification.Testing
Tested locally with
uv run specify --helpRan existing tests with
uv sync && uv run pytestTested with a sample project (if applicable): see the first bullet below
Sample project:
specify init --integration kimi, thendispatch_command('speckit.plan', ..., stream=False)againstkimi2.2.0, withKIMI_CODE_HOMEconfigured for a local OpenAI-compatible stub model because no Kimi account was available. Onmainit exits 1 with the Commander error above. On this branch it exits 0 and stdout holds three JSONL events (system.version, the assistant message,session.resume_hint).tests/integrations/test_integration_kimi.pygets four argv tests: text mode,stream-json,--model, andSPECKIT_INTEGRATION_KIMI_EXTRA_ARGS. Run againstmain, thestream-jsonand extra-args cases fail with'json' != 'stream-json'. All four pass on this branch..venv/bin/python -m pytest tests/integrations tests/workflows tests/test_agent_config_consistency.py -q: 3551 passed, 8 skipped.uvx ruff@0.15.0 check src tests: all checks passed.Full suite,
.venv/bin/python -m pytest tests -q(macOS, Python 3.14.3): 12417 passed, 376 skipped, 24 failed. All 24 are in 9 files this PR does not touch, and running those files on unmodifiedmainon the same machine fails the same 24 test IDs. 13 come from the checkout and temp directory sitting under a path with a space: path assertions intest_init_dir.py,test_timestamp_branches.pyandtests/specify_cli/workflows/step/test_command_add.py, plus the#!<sys.executable>shebang of the fakecurlintest_workflow_step_submission.py. The other 11 are composed-template cases intest_*_python_parity.py, whose bash variant runspython3fromPATH, and that interpreter has no PyYAML on this machine.AI Disclosure
AI disclosure: Claude Code opened this PR on behalf of @RaycarlLei. Claude Code (model: Claude Opus 5.5, reasoning effort xhigh, autonomous agent mode with tool approvals bypassed) reproduced the bug against
kimi2.2.0, read the Kimi Code source for the allowed--output-formatvalues, wrote the override and the four tests, ran the checks above, wrote this description, and pushed the branch. Read-only Claude Code subagents on the same model and effort cross-checked the description's claims and the diff before posting. @RaycarlLei reviewed the diff and a draft of this description and approved posting, but did not re-run the tests or edit the text. The commit carriesAssisted-by: Claude Code (model: Claude Opus 5.5, autonomous).🤖 Generated with Claude Code