feat(cli): 新增 --headless 非交互模式,支持执行完自动退出#207
Open
JiGuangWorker wants to merge 1 commit into
Open
Conversation
Add --headless option that allows deepcode to run a prompt and exit automatically without entering the interactive TUI. This enables: - CI/CD pipeline integration - Shell scripting / automation - Batch processing Changes: - cli-args.ts: add --headless boolean flag and validation (requires --prompt) - cli.tsx: add runHeadless() function that creates SessionManager, submits prompt, streams output to stdout, and exits cleanly. In headless mode, permissions are forced to allowAll since there is no user to ask for approval. Closes lessweb#139
686ec08 to
722dd04
Compare
Author
|
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.
概述
新增
--headless参数,允许 deepcode 在非交互模式下执行 prompt 后自动退出,不再停留 TUI 界面。Close #139
使用场景
--headless主要面向以下场景:deepcode --headless -p "..." | tee result.txt)设计决策
权限策略
headless 模式没有用户可交互,因此:
runHeadless()中,getResolvedSettings将permissions强制设为{ defaultMode: "allowAll" },忽略用户在 settings.json 中的askAll配置--headless是一个显式参数,使用者需明确指定;默认执行路径(无--headless)不受任何影响架构实现
核心改动是绕过 Ink/React TUI 渲染流程,直接调用
SessionManager:改动文件
packages/cli/src/cli-args.ts:新增--headless布尔参数 + 校验packages/cli/src/cli.tsx:新增runHeadless()函数使用方式