跳转到内容

完成第一个任务

第一个任务的目标不是观察模型输出得多漂亮,而是验证完整闭环:CodeN 读取工作区、模型提出工具调用、权限策略介入、工具返回结果,模型据此继续,并由你用测试或 diff 验证最终状态。默认启动的是连续输出 CLI;TUI 必须显式使用 --tui。

模式 触发方式 特点
CLI/REPL 默认;或 --cli 连续输出;交互式多行输入;带启动横幅
全屏 TUI 显式 --tui Ink 全屏界面;瞬时活动进入 transcript;单任务串行
print -p / --print 纯文本、可管道化;单轮后退出
  • 不带任何界面选项时始终进入 CLI/REPL,无论是否为 TTY。
  • --tui 要求 stdin、stdout 都是 TTY、支持 raw mode 且 TERM != dumb;不满足时降级为 CLI 并输出警告,不报错。
  • -p/--print 必须同时提供 prompt;例如 coden -p --auto "实现功能并运行测试"。
  • --tui 与 --cli、--tui 与 --print 组合会在参数解析阶段报错;--cli 与 --print 组合不报错,以 print 优先。
  • NO_COLOR 只关闭颜色,不影响界面模式。
  • 首次输入为空时使用多行编辑器(支持时):Enter 提交;行尾单个 \ 插入换行。
  • Ctrl+D(空输入)退出;Ctrl+C 取消当前任务而不是退出。
  • 启动横幅显示版本、工作区哈希、模型、审批模式、思考等级与会话 ID,随后进入 任务 > 提示。
  • 输入区由两条贯穿全宽的水平线包围;Enter 提交,Shift+Enter 或行尾 \ 插入换行。
  • Ctrl+P/Ctrl+N 浏览输入历史;PageUp/PageDown 和滚轮浏览 transcript,End 回到最新内容。
  • 运行中 Ctrl+C 取消当前任务;空闲时 Ctrl+C 或空输入 Ctrl+D 退出。
  • 工具授权、工作区信任与插件确认以内联请求显示在 transcript 中,不弹窗;等待时输入区可见但禁用。
  • TUI 保持单任务串行,不会在运行中排队输入。
终端窗口
coden # CLI/REPL (default)
coden --tui # explicit full-screen TUI
coden --cli # explicit CLI/REPL
coden -p "Reply with exactly: coden-ok" # print single-turn output
coden --tui "fix the failing tests in this project"
  • Node.js 22+(或直接以 Bun 运行源码)。
  • 已配置 Provider 凭据(见 配置第一个 Provider)。
  • 进入目标项目目录;当前工作目录就是 CodeN 的工作区。
终端窗口
cd /path/to/project
coden "run the test suite and fix the first failure"
阶段 行为
启动 读取配置、发现 Skills、加载插件;打印启动横幅(版本、工作区哈希、模型、审批模式、思考等级)
等待授权 默认审批模式为 manual:read 自动允许;write/edit 显示输入摘要并请求确认
授权选项 y 允许一次;危险操作只提供 y/N;普通修改可输入 s 允许本会话(allow_session)
工具调用 bash 以工作区为当前目录执行;输出有界(默认 30000 字符)并截断
完成 模型不再调用工具时,单轮结束;CLI 中带 prompt 启动的任务在完成后退出

会话内提示符为 任务 > ;首条用户消息作为会话标题。工作区哈希与数据目录由工作区路径决定(workspaceHash)。

终端窗口
coden --auto "run the test suite and fix the first failure" # skip permission prompts (ordinary operations only)
coden --smart-approve "run the test suite and fix the first failure" # LLM review for ordinary modifications
coden -p --auto "run the test suite and fix the first failure" # single-turn plain-text output
coden --tui "run the test suite and fix the first failure" # run in the full-screen TUI
coden --resume # list sessions for the current workspace
coden --resume <session-id> # resume a specific session
终端窗口
git status # inspect the change scope
git diff --stat # inspect the change size
coden --resume # session list: title, message count, last activity
  • 权限拒绝:返回 permission.denied: <tool> was not authorized(或 permission.outside_workspace_denied),模型会收到错误并调整策略;--auto 不改变 PreToolUse Hook 的 deny/ask 语义。
  • 超出步数:默认 maxSteps 为 80,达到后抛出 runtime.step_limit(Maximum model steps (80) reached);模型先耗尽步骤再报错。
  • 工作区外访问:read/write/edit 按符号链接解析后的真实路径分类;外部路径默认作为修改请求人工确认,--auto 下直接拒绝。
  • 取消:CLI 中 Ctrl+C 取消当前任务;TUI 中运行中 Ctrl+C 取消、空闲时退出。被中断的工具调用在会话恢复时会以 runtime.interrupted 错误标记补齐。
  • 会话与费用:每次有效任务都会创建会话文件并计入 Provider 用量;请为任务选择明确、可验证的范围。