完成第一个任务
第一个任务的目标不是观察模型输出得多漂亮,而是验证完整闭环:CodeN 读取工作区、模型提出工具调用、权限策略介入、工具返回结果,模型据此继续,并由你用测试或 diff 验证最终状态。默认启动的是连续输出 CLI;TUI 必须显式使用 --tui。
启动 CLI / TUI
Section titled “启动 CLI / TUI”三种界面模式
Section titled “三种界面模式”| 模式 | 触发方式 | 特点 |
|---|---|---|
| CLI/REPL | 默认;或 --cli |
连续输出;交互式多行输入;带启动横幅 |
| 全屏 TUI | 显式 --tui |
Ink 全屏界面;瞬时活动进入 transcript;单任务串行 |
-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只关闭颜色,不影响界面模式。
CLI 会话中的输入
Section titled “CLI 会话中的输入”- 首次输入为空时使用多行编辑器(支持时):Enter 提交;行尾单个
\插入换行。 Ctrl+D(空输入)退出;Ctrl+C取消当前任务而不是退出。- 启动横幅显示版本、工作区哈希、模型、审批模式、思考等级与会话 ID,随后进入
任务 >提示。
TUI 行为要点
Section titled “TUI 行为要点”- 输入区由两条贯穿全宽的水平线包围;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 TUIcoden --cli # explicit CLI/REPLcoden -p "Reply with exactly: coden-ok" # print single-turn outputcoden --tui "fix the failing tests in this project"完成第一个任务
Section titled “完成第一个任务”- Node.js 22+(或直接以 Bun 运行源码)。
- 已配置 Provider 凭据(见 配置第一个 Provider)。
- 进入目标项目目录;当前工作目录就是 CodeN 的工作区。
cd /path/to/projectcoden "run the test suite and fix the first failure"观察到的行为
Section titled “观察到的行为”| 阶段 | 行为 |
|---|---|
| 启动 | 读取配置、发现 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 modificationscoden -p --auto "run the test suite and fix the first failure" # single-turn plain-text outputcoden --tui "run the test suite and fix the first failure" # run in the full-screen TUIcoden --resume # list sessions for the current workspacecoden --resume <session-id> # resume a specific sessiongit status # inspect the change scopegit diff --stat # inspect the change sizecoden --resume # session list: title, message count, last activity边界与失败模式
Section titled “边界与失败模式”- 权限拒绝:返回
permission.denied: <tool> was not authorized(或permission.outside_workspace_denied),模型会收到错误并调整策略;--auto不改变PreToolUseHook 的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 用量;请为任务选择明确、可验证的范围。