[Feature] Give kimi -p explicit permission modes and a documented structured exit-code contract

未关闭
#5,128 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript

调研方向

Start by tracing runV2Print, resolveNativeSession, forceAuto, and AgentPermissionPolicyService to see how print mode selects permissions and handles blocked tool calls. Then locate the scattered exit paths, including the session occupied code and goal codes in goal-prompt.ts. The issue is done when permission behavior and stable exit codes are implemented and documented, with structured stream-json errors and compatibility for goal codes 0, 3, and 6; the proposed code table and call sites are not included in the payload.

由索引模型根据 Issue 内容生成。

描述

What feature would you like to see?

Give kimi -p explicit permission controls and a documented, structured exit-code contract.

Permission side:

  • kimi -p --permission ask|yolo|auto (naming up to the team) so headless runs can choose the policy instead of always being forced into auto.
  • In a restricted mode, if a tool call would need approval, fail fast with a structured error instead of silently approving or hanging. Something like {"type":"error","code":"approval_required","tool":"Bash","reason":"..."} in --output-format stream-json, plus a stable exit code.
  • Optionally --deny "<pattern>" / --allow "<pattern>" to pass permission rules for one invocation.

Exit-code contract:

  • document every stable exit code in one place, covering at least: success, goal incomplete, blocked, paused, session occupied (currently 4), context overflow, compaction failure, approval required, output truncated, and print wait ceiling reached.
  • make --output-format stream-json emit one structured error object before exiting for each of those, mirrored by the exit code.
  • keep the existing goal codes (0 complete, 3 blocked, 6 paused) for compatibility and document them next to the new ones.
Additional information

Why this matters:

  • runV2Print currently forces auto for new and resumed sessions (resolveNativeSession, forceAuto), so kimi -p has no way to run with approvals on. That is convenient for trusted automation but makes it unsafe to run in an untrusted repository, and there is no signal when a run would have needed approval.
  • In non-interactive hosts, AgentPermissionPolicyService also skips the dangerous-command guard entirely (bootstrap.args.nonInteractive), so print-mode runs have neither prompts nor the guard. The missing guard entries themselves are reported in #5123, and the Bash sensitive-file gap in #5124; those are bugs, but the broader missing control is a feature.
  • Exit codes are currently scattered: 4 for session occupied, goal codes in goal-prompt.ts, and most other failures exit as a generic error. CI has no stable way to distinguish "provider said no", "context overflow", "the goal did not finish" (#5062), or "the print wait ceiling was reached" (#5122).
  • A documented contract would let scripts retry only the cases that are retryable and surface the rest.

I checked the tracker for print-mode permission flags and a documented exit-code table and found no existing request. I understand external feature PRs are not accepted; I am only proposing the feature and can provide the exact call sites and a proposed code table if useful.

主要语言
TypeScript
星标
8.3k
派生
1.4k
平均合并
12 小时 6 分钟
30 天内合并 PR
596

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MoonshotAI/kimi-code 的其他 Issue

查看 MoonshotAI/kimi-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。