@armadra/agent 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. package/CHANGELOG.md +177 -294
  2. package/CHANGELOG.zh-CN.md +442 -0
  3. package/README.md +408 -364
  4. package/README.zh-CN.md +705 -0
  5. package/dist/agent/session-plan.js +2 -2
  6. package/dist/agent/session-state.d.ts +3 -0
  7. package/dist/agent/session-state.js +20 -0
  8. package/dist/agent/session-subagent.d.ts +15 -1
  9. package/dist/agent/session-subagent.js +26 -3
  10. package/dist/agent/session-telemetry.d.ts +16 -2
  11. package/dist/agent/session-telemetry.js +29 -7
  12. package/dist/agent/session-tools.js +5 -2
  13. package/dist/agent/session-trace-writer.d.ts +27 -0
  14. package/dist/agent/session-trace-writer.js +253 -0
  15. package/dist/agent/session.d.ts +2 -0
  16. package/dist/agent/session.js +12 -0
  17. package/dist/agent/subagent-direct.d.ts +20 -0
  18. package/dist/agent/subagent-direct.js +76 -0
  19. package/dist/agent/subagent-registry.d.ts +8 -1
  20. package/dist/agent/subagent-registry.js +28 -1
  21. package/dist/agent/system-prompt.d.ts +3 -1
  22. package/dist/agent/system-prompt.js +3 -0
  23. package/dist/agent/tool-runner.d.ts +2 -1
  24. package/dist/agent/tool-runner.js +5 -4
  25. package/dist/agent/types-w6.d.ts +39 -0
  26. package/dist/agent/types-w6.js +4 -0
  27. package/dist/agent/types.d.ts +5 -2
  28. package/dist/agents/external.js +1 -1
  29. package/dist/agents/task-record.d.ts +74 -1
  30. package/dist/agents/task-record.js +100 -0
  31. package/dist/ai/apis/cache-params.js +2 -1
  32. package/dist/ai/apis/chatgpt-backend.d.ts +52 -0
  33. package/dist/ai/apis/chatgpt-backend.js +224 -0
  34. package/dist/ai/apis/chatgpt-rate-limits.d.ts +26 -0
  35. package/dist/ai/apis/chatgpt-rate-limits.js +91 -0
  36. package/dist/ai/apis/openai-responses-request.d.ts +2 -1
  37. package/dist/ai/apis/openai-responses-request.js +8 -2
  38. package/dist/ai/apis/openai-responses.d.ts +2 -0
  39. package/dist/ai/apis/openai-responses.js +51 -16
  40. package/dist/ai/overflow.d.ts +1 -1
  41. package/dist/ai/overflow.js +10 -7
  42. package/dist/ai/providers/auth.d.ts +15 -2
  43. package/dist/ai/providers/auth.js +69 -2
  44. package/dist/ai/providers/builtin.js +27 -0
  45. package/dist/ai/providers/catalog-data.js +1 -0
  46. package/dist/ai/providers/enrich.js +2 -7
  47. package/dist/ai/providers/models-dev-cache.js +15 -19
  48. package/dist/ai/providers/models-dev-snapshot.js +8 -7
  49. package/dist/ai/providers/models-dev.js +5 -15
  50. package/dist/ai/providers/suggest.js +2 -16
  51. package/dist/ai/types.d.ts +27 -1
  52. package/dist/auth/chatgpt/backend-client.d.ts +26 -0
  53. package/dist/auth/chatgpt/backend-client.js +74 -0
  54. package/dist/auth/chatgpt/claims.d.ts +17 -0
  55. package/dist/auth/chatgpt/claims.js +46 -0
  56. package/dist/auth/chatgpt/cli.d.ts +33 -0
  57. package/dist/auth/chatgpt/cli.js +252 -0
  58. package/dist/auth/chatgpt/doctor.d.ts +17 -0
  59. package/dist/auth/chatgpt/doctor.js +36 -0
  60. package/dist/auth/chatgpt/host-id.d.ts +7 -0
  61. package/dist/auth/chatgpt/host-id.js +26 -0
  62. package/dist/auth/chatgpt/login.d.ts +30 -0
  63. package/dist/auth/chatgpt/login.js +130 -0
  64. package/dist/auth/chatgpt/presets.d.ts +66 -0
  65. package/dist/auth/chatgpt/presets.js +120 -0
  66. package/dist/auth/chatgpt/quota-text.d.ts +13 -0
  67. package/dist/auth/chatgpt/quota-text.js +36 -0
  68. package/dist/auth/oauth/browser.d.ts +12 -0
  69. package/dist/auth/oauth/browser.js +27 -0
  70. package/dist/auth/oauth/callback-server.d.ts +47 -0
  71. package/dist/auth/oauth/callback-server.js +147 -0
  72. package/dist/auth/oauth/flows.d.ts +62 -0
  73. package/dist/auth/oauth/flows.js +113 -0
  74. package/dist/auth/oauth/jwt.d.ts +24 -0
  75. package/dist/auth/oauth/jwt.js +81 -0
  76. package/dist/auth/oauth/live.d.ts +21 -0
  77. package/dist/auth/oauth/live.js +25 -0
  78. package/dist/auth/oauth/oidc.d.ts +26 -0
  79. package/dist/auth/oauth/oidc.js +72 -0
  80. package/dist/auth/oauth/pkce.d.ts +15 -0
  81. package/dist/auth/oauth/pkce.js +20 -0
  82. package/dist/auth/oauth/refresh.d.ts +35 -0
  83. package/dist/auth/oauth/refresh.js +129 -0
  84. package/dist/auth/oauth/token-client.d.ts +33 -0
  85. package/dist/auth/oauth/token-client.js +121 -0
  86. package/dist/auth/oauth/token-store.d.ts +23 -0
  87. package/dist/auth/oauth/token-store.js +125 -0
  88. package/dist/auth/testing/fake-oauth.d.ts +73 -0
  89. package/dist/auth/testing/fake-oauth.js +271 -0
  90. package/dist/auth/testing/refresh-child.d.ts +5 -0
  91. package/dist/auth/testing/refresh-child.js +16 -0
  92. package/dist/bundle/ama.cjs +28307 -13241
  93. package/dist/checkpoints/backend.js +6 -5
  94. package/dist/checkpoints/restore.js +3 -2
  95. package/dist/checkpoints/settings.js +2 -1
  96. package/dist/checkpoints/shadow-git.js +7 -6
  97. package/dist/checkpoints/shadow-restore.js +3 -2
  98. package/dist/checkpoints/tracker.js +4 -3
  99. package/dist/cli/args.d.ts +9 -2
  100. package/dist/cli/args.js +74 -27
  101. package/dist/cli/bootstrap.js +53 -31
  102. package/dist/cli/choice-prompt.d.ts +58 -0
  103. package/dist/cli/choice-prompt.js +142 -0
  104. package/dist/cli/codemode-notice.js +2 -2
  105. package/dist/cli/compose-agents.js +2 -1
  106. package/dist/cli/compose-extensions.js +2 -0
  107. package/dist/cli/compose-memory.d.ts +53 -0
  108. package/dist/cli/compose-memory.js +127 -0
  109. package/dist/cli/compose-providers.d.ts +5 -0
  110. package/dist/cli/compose-providers.js +32 -2
  111. package/dist/cli/compose-session.d.ts +5 -0
  112. package/dist/cli/compose-session.js +27 -13
  113. package/dist/cli/compose-store.d.ts +2 -0
  114. package/dist/cli/compose-store.js +9 -5
  115. package/dist/cli/compose.d.ts +2 -0
  116. package/dist/cli/compose.js +13 -5
  117. package/dist/cli/default-model.d.ts +0 -2
  118. package/dist/cli/default-model.js +5 -8
  119. package/dist/cli/deps.d.ts +5 -1
  120. package/dist/cli/exit-codes.d.ts +1 -1
  121. package/dist/cli/exit-codes.js +7 -16
  122. package/dist/cli/from-prompt.js +3 -2
  123. package/dist/cli/help-text.d.ts +2 -1
  124. package/dist/cli/help-text.js +5 -99
  125. package/dist/cli/main.d.ts +5 -0
  126. package/dist/cli/main.js +21 -2
  127. package/dist/cli/proxy.js +14 -9
  128. package/dist/cli/runtime.d.ts +5 -0
  129. package/dist/cli/startup-screen.js +20 -27
  130. package/dist/cli/startup-steps.js +6 -8
  131. package/dist/cli/subcommands/auth.d.ts +6 -3
  132. package/dist/cli/subcommands/auth.js +52 -22
  133. package/dist/cli/subcommands/config-set.d.ts +21 -0
  134. package/dist/cli/subcommands/config-set.js +137 -0
  135. package/dist/cli/subcommands/config.d.ts +2 -1
  136. package/dist/cli/subcommands/config.js +51 -37
  137. package/dist/cli/subcommands/doctor.d.ts +2 -1
  138. package/dist/cli/subcommands/doctor.js +97 -58
  139. package/dist/cli/subcommands/init.d.ts +1 -1
  140. package/dist/cli/subcommands/init.js +8 -7
  141. package/dist/cli/subcommands/memory.d.ts +18 -0
  142. package/dist/cli/subcommands/memory.js +189 -0
  143. package/dist/cli/subcommands/model-meta.js +11 -9
  144. package/dist/cli/subcommands/models-cache-probe.d.ts +1 -1
  145. package/dist/cli/subcommands/models-cache-probe.js +26 -32
  146. package/dist/cli/subcommands/models-discover.d.ts +3 -0
  147. package/dist/cli/subcommands/models-discover.js +44 -21
  148. package/dist/cli/subcommands/models.d.ts +1 -1
  149. package/dist/cli/subcommands/models.js +29 -22
  150. package/dist/cli/subcommands/probe-runner.js +8 -7
  151. package/dist/cli/subcommands/providers-list.js +32 -21
  152. package/dist/cli/subcommands/providers-plan.js +24 -25
  153. package/dist/cli/subcommands/providers-probe.js +5 -6
  154. package/dist/cli/subcommands/providers.d.ts +2 -2
  155. package/dist/cli/subcommands/providers.js +48 -59
  156. package/dist/cli/subcommands/sessions-export.d.ts +1 -1
  157. package/dist/cli/subcommands/sessions-export.js +10 -9
  158. package/dist/cli/subcommands/sessions-search.d.ts +1 -1
  159. package/dist/cli/subcommands/sessions-search.js +11 -10
  160. package/dist/cli/subcommands/sessions-trace.d.ts +30 -0
  161. package/dist/cli/subcommands/sessions-trace.js +156 -0
  162. package/dist/cli/subcommands/sessions.d.ts +4 -3
  163. package/dist/cli/subcommands/sessions.js +40 -37
  164. package/dist/cli/subcommands/stats.d.ts +1 -1
  165. package/dist/cli/subcommands/stats.js +49 -30
  166. package/dist/cli/system-prompt-arg.js +3 -2
  167. package/dist/codemode/capability.js +3 -2
  168. package/dist/compaction/post-compact.d.ts +1 -0
  169. package/dist/compaction/post-compact.js +15 -1
  170. package/dist/compaction/prune-tier.d.ts +1 -1
  171. package/dist/compaction/prune-tier.js +3 -3
  172. package/dist/compaction/serialize.js +2 -1
  173. package/dist/config/auth-file.d.ts +12 -2
  174. package/dist/config/auth-file.js +32 -10
  175. package/dist/config/checker.js +12 -11
  176. package/dist/config/context-files.js +3 -2
  177. package/dist/config/edit.d.ts +106 -0
  178. package/dist/config/edit.js +350 -0
  179. package/dist/config/init.d.ts +4 -3
  180. package/dist/config/init.js +10 -18
  181. package/dist/config/json-schema.d.ts +2 -1
  182. package/dist/config/json-schema.js +101 -68
  183. package/dist/config/key-docs.d.ts +18 -7
  184. package/dist/config/key-docs.js +43 -128
  185. package/dist/config/load.js +7 -6
  186. package/dist/config/merge.d.ts +4 -1
  187. package/dist/config/merge.js +42 -22
  188. package/dist/config/paths.js +6 -5
  189. package/dist/config/profile.d.ts +5 -1
  190. package/dist/config/profile.js +7 -2
  191. package/dist/config/schema-w5.js +3 -2
  192. package/dist/config/schema-w6.d.ts +19 -0
  193. package/dist/config/schema-w6.js +115 -0
  194. package/dist/config/schema.js +34 -20
  195. package/dist/config/settings-registry.d.ts +78 -0
  196. package/dist/config/settings-registry.js +184 -0
  197. package/dist/config/types-w6.d.ts +109 -0
  198. package/dist/config/types-w6.js +19 -0
  199. package/dist/config/types.d.ts +11 -8
  200. package/dist/config/types.js +1 -0
  201. package/dist/drivers/acp/client.js +1 -1
  202. package/dist/drivers/acp/driver.js +13 -8
  203. package/dist/drivers/agents.js +4 -3
  204. package/dist/drivers/base.js +3 -2
  205. package/dist/drivers/host-runners.js +2 -1
  206. package/dist/drivers/native/claude-stream.js +12 -11
  207. package/dist/drivers/native/codex-app-server.js +17 -12
  208. package/dist/drivers/native/oneshot.js +8 -7
  209. package/dist/drivers/pool.js +1 -1
  210. package/dist/drivers/runner.d.ts +3 -1
  211. package/dist/drivers/runner.js +68 -20
  212. package/dist/drivers/turn.js +1 -1
  213. package/dist/hooks/config.js +3 -2
  214. package/dist/hooks/protocol.js +18 -12
  215. package/dist/host/api-impl.js +11 -10
  216. package/dist/host/loader.js +9 -8
  217. package/dist/host/types.d.ts +3 -0
  218. package/dist/i18n/catalog.d.ts +2169 -0
  219. package/dist/i18n/catalog.js +72 -0
  220. package/dist/i18n/format.d.ts +21 -0
  221. package/dist/i18n/format.js +58 -0
  222. package/dist/i18n/index.d.ts +58 -0
  223. package/dist/i18n/index.js +72 -0
  224. package/dist/i18n/messages/agents.d.ts +84 -0
  225. package/dist/i18n/messages/agents.js +85 -0
  226. package/dist/i18n/messages/approval.d.ts +99 -0
  227. package/dist/i18n/messages/approval.js +100 -0
  228. package/dist/i18n/messages/auth.d.ts +187 -0
  229. package/dist/i18n/messages/auth.js +189 -0
  230. package/dist/i18n/messages/cli-args.d.ts +46 -0
  231. package/dist/i18n/messages/cli-args.js +46 -0
  232. package/dist/i18n/messages/cli-help.d.ts +12 -0
  233. package/dist/i18n/messages/cli-help.js +244 -0
  234. package/dist/i18n/messages/cli.d.ts +336 -0
  235. package/dist/i18n/messages/cli.js +311 -0
  236. package/dist/i18n/messages/config-keys.d.ts +289 -0
  237. package/dist/i18n/messages/config-keys.js +292 -0
  238. package/dist/i18n/messages/config.d.ts +502 -0
  239. package/dist/i18n/messages/config.js +239 -0
  240. package/dist/i18n/messages/drivers.d.ts +123 -0
  241. package/dist/i18n/messages/drivers.js +124 -0
  242. package/dist/i18n/messages/errors.d.ts +83 -0
  243. package/dist/i18n/messages/errors.js +171 -0
  244. package/dist/i18n/messages/interactive-line.d.ts +61 -0
  245. package/dist/i18n/messages/interactive-line.js +69 -0
  246. package/dist/i18n/messages/interactive-startup.d.ts +103 -0
  247. package/dist/i18n/messages/interactive-startup.js +104 -0
  248. package/dist/i18n/messages/interactive-view.d.ts +140 -0
  249. package/dist/i18n/messages/interactive-view.js +141 -0
  250. package/dist/i18n/messages/interactive.d.ts +493 -0
  251. package/dist/i18n/messages/interactive.js +248 -0
  252. package/dist/i18n/messages/memory.d.ts +123 -0
  253. package/dist/i18n/messages/memory.js +128 -0
  254. package/dist/i18n/messages/panels.d.ts +190 -0
  255. package/dist/i18n/messages/panels.js +189 -0
  256. package/dist/i18n/messages/permissions.d.ts +126 -0
  257. package/dist/i18n/messages/permissions.js +151 -0
  258. package/dist/i18n/messages/plan.d.ts +123 -0
  259. package/dist/i18n/messages/plan.js +124 -0
  260. package/dist/i18n/messages/print.d.ts +86 -0
  261. package/dist/i18n/messages/print.js +91 -0
  262. package/dist/i18n/messages/report.d.ts +391 -0
  263. package/dist/i18n/messages/report.js +490 -0
  264. package/dist/i18n/messages/rewind.d.ts +198 -0
  265. package/dist/i18n/messages/rewind.js +217 -0
  266. package/dist/i18n/messages/session.d.ts +230 -0
  267. package/dist/i18n/messages/session.js +258 -0
  268. package/dist/i18n/messages/settings.d.ts +348 -0
  269. package/dist/i18n/messages/settings.js +336 -0
  270. package/dist/i18n/messages/subcommands-config.d.ts +111 -0
  271. package/dist/i18n/messages/subcommands-config.js +127 -0
  272. package/dist/i18n/messages/subcommands.d.ts +548 -0
  273. package/dist/i18n/messages/subcommands.js +474 -0
  274. package/dist/i18n/messages/trace.d.ts +243 -0
  275. package/dist/i18n/messages/trace.js +238 -0
  276. package/dist/i18n/types.d.ts +15 -0
  277. package/dist/i18n/types.js +7 -0
  278. package/dist/index.d.ts +6 -0
  279. package/dist/index.js +2 -0
  280. package/dist/memory/edit.d.ts +24 -0
  281. package/dist/memory/edit.js +63 -0
  282. package/dist/memory/frontmatter.d.ts +37 -0
  283. package/dist/memory/frontmatter.js +79 -0
  284. package/dist/memory/index.d.ts +28 -0
  285. package/dist/memory/index.js +126 -0
  286. package/dist/memory/lock.d.ts +17 -0
  287. package/dist/memory/lock.js +62 -0
  288. package/dist/memory/paths.d.ts +57 -0
  289. package/dist/memory/paths.js +175 -0
  290. package/dist/memory/report.d.ts +36 -0
  291. package/dist/memory/report.js +86 -0
  292. package/dist/memory/runtime.d.ts +42 -0
  293. package/dist/memory/runtime.js +36 -0
  294. package/dist/memory/secrets.d.ts +8 -0
  295. package/dist/memory/secrets.js +27 -0
  296. package/dist/memory/section.d.ts +28 -0
  297. package/dist/memory/section.js +59 -0
  298. package/dist/memory/store.d.ts +70 -0
  299. package/dist/memory/store.js +284 -0
  300. package/dist/memory/tool.d.ts +31 -0
  301. package/dist/memory/tool.js +94 -0
  302. package/dist/modes/acp/acp-events.js +2 -1
  303. package/dist/modes/acp/acp-server.js +13 -12
  304. package/dist/modes/commands-core.d.ts +17 -0
  305. package/dist/modes/commands-core.js +101 -61
  306. package/dist/modes/image-input.js +20 -6
  307. package/dist/modes/interactive/agent-bar.d.ts +95 -0
  308. package/dist/modes/interactive/agent-bar.js +248 -0
  309. package/dist/modes/interactive/agent-panels.js +27 -26
  310. package/dist/modes/interactive/agent-transcript.d.ts +47 -0
  311. package/dist/modes/interactive/agent-transcript.js +191 -0
  312. package/dist/modes/interactive/agent-ui.d.ts +36 -1
  313. package/dist/modes/interactive/agent-ui.js +180 -14
  314. package/dist/modes/interactive/agent-view.d.ts +72 -0
  315. package/dist/modes/interactive/agent-view.js +281 -0
  316. package/dist/modes/interactive/approval-dialog.js +46 -34
  317. package/dist/modes/interactive/clipboard-paste.d.ts +2 -2
  318. package/dist/modes/interactive/clipboard-paste.js +9 -4
  319. package/dist/modes/interactive/commands.d.ts +22 -1
  320. package/dist/modes/interactive/commands.js +93 -38
  321. package/dist/modes/interactive/completion.js +2 -1
  322. package/dist/modes/interactive/config-panel.d.ts +70 -0
  323. package/dist/modes/interactive/config-panel.js +319 -0
  324. package/dist/modes/interactive/config-ui.d.ts +96 -0
  325. package/dist/modes/interactive/config-ui.js +397 -0
  326. package/dist/modes/interactive/confirm-dialog.d.ts +49 -0
  327. package/dist/modes/interactive/confirm-dialog.js +120 -0
  328. package/dist/modes/interactive/event-notices.js +11 -9
  329. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  330. package/dist/modes/interactive/interactive-mode.js +25 -22
  331. package/dist/modes/interactive/key-dispatch.d.ts +18 -0
  332. package/dist/modes/interactive/key-dispatch.js +39 -13
  333. package/dist/modes/interactive/line/line-editor.js +2 -1
  334. package/dist/modes/interactive/line/line-mode.d.ts +2 -0
  335. package/dist/modes/interactive/line/line-mode.js +24 -4
  336. package/dist/modes/interactive/line/line-render.js +25 -24
  337. package/dist/modes/interactive/memory-panel.d.ts +64 -0
  338. package/dist/modes/interactive/memory-panel.js +221 -0
  339. package/dist/modes/interactive/message-view.d.ts +4 -2
  340. package/dist/modes/interactive/message-view.js +42 -33
  341. package/dist/modes/interactive/panels.js +39 -31
  342. package/dist/modes/interactive/pickers.d.ts +2 -1
  343. package/dist/modes/interactive/pickers.js +10 -6
  344. package/dist/modes/interactive/plan-command.d.ts +1 -1
  345. package/dist/modes/interactive/plan-command.js +24 -27
  346. package/dist/modes/interactive/plan-dialog.js +18 -17
  347. package/dist/modes/interactive/plan-flow.js +6 -5
  348. package/dist/modes/interactive/rewind-command.d.ts +1 -1
  349. package/dist/modes/interactive/rewind-command.js +18 -16
  350. package/dist/modes/interactive/rewind-flow.d.ts +0 -1
  351. package/dist/modes/interactive/rewind-flow.js +13 -14
  352. package/dist/modes/interactive/rewind-list.js +7 -6
  353. package/dist/modes/interactive/rewind-panel.js +40 -40
  354. package/dist/modes/interactive/rewind-text.d.ts +5 -3
  355. package/dist/modes/interactive/rewind-text.js +48 -38
  356. package/dist/modes/interactive/run-indicator.js +15 -12
  357. package/dist/modes/interactive/session-events.js +3 -2
  358. package/dist/modes/interactive/startup-header.js +22 -23
  359. package/dist/modes/interactive/startup-ui.js +41 -29
  360. package/dist/modes/interactive/status-area.d.ts +2 -0
  361. package/dist/modes/interactive/status-area.js +8 -2
  362. package/dist/modes/interactive/status-bar.js +4 -3
  363. package/dist/modes/interactive/subagent-view.js +9 -7
  364. package/dist/modes/interactive/tasks-report.d.ts +6 -0
  365. package/dist/modes/interactive/tasks-report.js +28 -31
  366. package/dist/modes/interactive/terminal-setup.d.ts +9 -0
  367. package/dist/modes/interactive/terminal-setup.js +23 -0
  368. package/dist/modes/interactive/tool-summary.js +19 -17
  369. package/dist/modes/interactive/tool-view.js +7 -4
  370. package/dist/modes/interactive/trace-view.d.ts +89 -0
  371. package/dist/modes/interactive/trace-view.js +332 -0
  372. package/dist/modes/print/print-mode.js +14 -15
  373. package/dist/modes/rpc/commands.js +7 -3
  374. package/dist/modes/rpc/rpc-mode.js +9 -3
  375. package/dist/modes/session-report.d.ts +2 -0
  376. package/dist/modes/session-report.js +101 -105
  377. package/dist/modes/startup-ui-text.js +11 -6
  378. package/dist/permissions/bypass.d.ts +30 -0
  379. package/dist/permissions/bypass.js +45 -0
  380. package/dist/permissions/memory-class.d.ts +23 -0
  381. package/dist/permissions/memory-class.js +54 -0
  382. package/dist/permissions/modes.d.ts +3 -3
  383. package/dist/permissions/modes.js +21 -16
  384. package/dist/permissions/pipeline.d.ts +1 -1
  385. package/dist/permissions/pipeline.js +9 -2
  386. package/dist/permissions/preview.js +49 -42
  387. package/dist/permissions/rules.js +5 -2
  388. package/dist/permissions/types.d.ts +4 -0
  389. package/dist/plan/store.js +2 -1
  390. package/dist/rpc.d.ts +39 -1
  391. package/dist/rpc.js +3 -0
  392. package/dist/sandbox/bash.js +11 -8
  393. package/dist/sandbox/detect.js +14 -11
  394. package/dist/sdk.d.ts +17 -1
  395. package/dist/sdk.js +29 -7
  396. package/dist/session/export.js +31 -30
  397. package/dist/session/manager.d.ts +1 -1
  398. package/dist/session/manager.js +5 -3
  399. package/dist/session/reuse.js +5 -4
  400. package/dist/session/scan.js +3 -2
  401. package/dist/session/stats-aggregate.d.ts +3 -1
  402. package/dist/session/stats-aggregate.js +5 -1
  403. package/dist/session/stats-index.js +2 -1
  404. package/dist/session/stats-scan.d.ts +4 -1
  405. package/dist/session/stats-scan.js +6 -2
  406. package/dist/session/store.d.ts +11 -0
  407. package/dist/session/store.js +48 -1
  408. package/dist/session/types.d.ts +2 -0
  409. package/dist/skills/builtin.js +2 -1
  410. package/dist/tools/image-file.d.ts +26 -1
  411. package/dist/tools/image-file.js +55 -13
  412. package/dist/tools/presets.d.ts +14 -1
  413. package/dist/tools/presets.js +3 -3
  414. package/dist/tools/registry.js +1 -1
  415. package/dist/tools/truncate.d.ts +1 -1
  416. package/dist/tools/truncate.js +2 -2
  417. package/dist/tools/types.d.ts +17 -1
  418. package/dist/trace/build-index.d.ts +91 -0
  419. package/dist/trace/build-index.js +127 -0
  420. package/dist/trace/build-nodes.d.ts +24 -0
  421. package/dist/trace/build-nodes.js +279 -0
  422. package/dist/trace/build-util.d.ts +43 -0
  423. package/dist/trace/build-util.js +120 -0
  424. package/dist/trace/build.d.ts +82 -0
  425. package/dist/trace/build.js +382 -0
  426. package/dist/trace/detail.d.ts +35 -0
  427. package/dist/trace/detail.js +205 -0
  428. package/dist/trace/flatten.d.ts +69 -0
  429. package/dist/trace/flatten.js +173 -0
  430. package/dist/trace/format.d.ts +47 -0
  431. package/dist/trace/format.js +329 -0
  432. package/dist/trace/html-template.d.ts +19 -0
  433. package/dist/trace/html-template.js +150 -0
  434. package/dist/trace/html.d.ts +104 -0
  435. package/dist/trace/html.js +292 -0
  436. package/dist/trace/preview.d.ts +29 -0
  437. package/dist/trace/preview.js +59 -0
  438. package/dist/trace/query-session.d.ts +14 -0
  439. package/dist/trace/query-session.js +38 -0
  440. package/dist/trace/query.d.ts +55 -0
  441. package/dist/trace/query.js +188 -0
  442. package/dist/trace/session.d.ts +40 -0
  443. package/dist/trace/session.js +168 -0
  444. package/dist/trace/types.d.ts +243 -0
  445. package/dist/trace/types.js +13 -0
  446. package/dist/tui/components/editor-paste.d.ts +2 -0
  447. package/dist/tui/components/editor-paste.js +6 -3
  448. package/dist/tui/components/editor.js +2 -2
  449. package/dist/tui/components/loader.d.ts +3 -0
  450. package/dist/tui/components/loader.js +14 -0
  451. package/dist/tui/components/settings-list.d.ts +61 -0
  452. package/dist/tui/components/settings-list.js +135 -0
  453. package/dist/tui/keybindings.d.ts +6 -1
  454. package/dist/tui/keybindings.js +18 -6
  455. package/dist/tui.d.ts +1 -0
  456. package/dist/tui.js +2 -0
  457. package/docs/en/host-api.md +167 -0
  458. package/docs/en/permissions.md +214 -0
  459. package/docs/en/providers.md +625 -0
  460. package/docs/en/rpc.md +361 -0
  461. package/docs/en/sessions.md +219 -0
  462. package/docs/en/tui.md +527 -0
  463. package/docs/host-api.md +18 -17
  464. package/docs/memory.md +172 -0
  465. package/docs/permissions.md +3 -2
  466. package/docs/providers.md +67 -1
  467. package/docs/rpc.md +31 -3
  468. package/docs/session-format.md +8 -2
  469. package/docs/sessions.md +29 -1
  470. package/docs/tui.md +189 -21
  471. package/package.json +8 -3
package/README.md CHANGED
@@ -4,67 +4,74 @@
4
4
  [![npm](https://img.shields.io/npm/v/@armadra/agent)](https://www.npmjs.com/package/@armadra/agent)
5
5
  [![license](https://img.shields.io/npm/l/@armadra/agent)](LICENSE)
6
6
 
7
- 一个在终端里写代码的 Agent,也可以嵌进 [Armadra](https://github.com/yovinchen/Armadra) 画布当协调者。用 TypeScript 写成,运行时零依赖,也提供单文件发行版。
7
+ English · [简体中文](README.zh-CN.md)
8
+
9
+ A coding agent for the terminal that can also be embedded in the [Armadra](https://github.com/yovinchen/Armadra) canvas as a coordinator. Written in TypeScript with zero runtime dependencies, and also shipped as a single-file build.
8
10
 
9
11
  ```sh
10
12
  npm i -g @armadra/agent
11
- export ANTHROPIC_API_KEY=sk-... # 任一家的 key 即可
13
+ export ANTHROPIC_API_KEY=sk-... # a key from any supported provider works
12
14
  ama
13
15
  ```
14
16
 
15
- ## 目录
16
-
17
- - [为什么做 ama](#为什么做-ama)
18
- - [特性一览](#特性一览)
19
- - [安装](#安装)
20
- - [快速开始](#快速开始)
21
- - [配置](#配置)
22
- - [接入中转站](#接入中转站)
23
- - [工具与预设](#工具与预设)
24
- - [缓存](#缓存)
25
- - [安全](#安全)
26
- - [沙箱](#沙箱)
17
+ ## Contents
18
+
19
+ - [Why ama](#why-ama)
20
+ - [Features](#features)
21
+ - [Install](#install)
22
+ - [Quick start](#quick-start)
23
+ - [Configuration](#configuration)
24
+ - [Relays and gateways](#relays-and-gateways)
25
+ - [ChatGPT login](#chatgpt-login)
26
+ - [Tools and presets](#tools-and-presets)
27
+ - [Caching](#caching)
28
+ - [Safety](#safety)
29
+ - [Sandbox](#sandbox)
27
30
  - [Plan](#plan)
28
- - [子 Agent](#子-agent)
29
- - [外部 Agent](#外部-agent)
30
- - [回滚](#回滚)
31
- - [界面与入口](#界面与入口)
32
- - [嵌入 Armadra](#嵌入-armadra)
33
- - [文档](#文档)
34
- - [已知限制](#已知限制)
35
- - [开发](#开发)
36
-
37
- ## 为什么做 ama
38
-
39
- - **调用型 Agent**:ama 被别的程序调用的时候和被人使用的时候一样多——`-p` 一次性运行、`--mode rpc`、SDK、宿主适配器都是一等入口,退出码与 JSON 形状是契约。
40
- - **分层清楚**:参考 Pi 的分层,协议实现与供应商数据分开。四条协议线(Anthropic Messages、OpenAI Chat Completions、OpenAI Responses、Google Generative AI)只写一次,供应商只是「baseUrl + key + 模型表 + compat 开关」。
41
- - **配置精简**:设一个环境变量就能用;常用配置只有五个键,其余都有缺省。只用 API Key(官方或中转站),只做 Skill 与内置工具,不接 MCP。
42
- - **缓存优先**:长任务的大部分用量是缓存读取。ama 保证请求前缀逐字节稳定,按各家写法打缓存断点,并把缓存是否生效、为什么没命中显示出来。
43
- - **两种用法**:独立用就是一个终端编码 Agent;嵌入 Armadra 时作为画布上的协调者,驱动 Claude Code、Codex、OpenCode 等 CLI Agent 分工、汇报与汇总。
44
-
45
- ## 特性一览
46
-
47
- | 方面 | 内容 |
48
- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
49
- | 多协议与供应商 | 4 条协议线、17 家内置供应商(Anthropic、OpenAI、Google、DeepSeek、Moonshot、智谱、通义、OpenRouter、Groq、xAI、Mistral、MiniMax、阶跃、火山方舟、腾讯、Ollama、LM Studio)、内置渠道(Messages / Responses 优先、Chat 回落)、自定义供应商、模型级协议 |
50
- | 零配置与中转站 | 有 key 就选第一个可用的供应商(中转站按价格规则挑缺省模型);识别 `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL`;`ama providers add` 只给 baseUrl 与 key 一键接入:列模型、探测渠道、写回配置 |
51
- | 模型元数据 | 上下文、输出上限、图像输入、推理、价格来自随包的 models.dev 内置快照(启动与运行都不联网,`ama models refresh` 显式刷新);一个供应商可挂多个渠道(Chat / Responses / Messages),`provider/model@渠道` |
52
- | 图像输入 | `-p --image`、界面里 `@图片路径`、`Ctrl+V` / `/paste` 粘贴剪贴板图片;按端点分档的单图上限、超限自动缩放;模型不收图片时直接拒绝并提示换模型 |
53
- | 工具与预设 | read / edit / write / bash / grep / glob,另有 ls、todo、task / task_ctl(子 Agent)、codemode;四个预设 `default` / `minimal` / `codemode-only` / `coordinator` |
54
- | Plan 与子 Agent | Plan 模式只读调研、出计划后审批执行;`task` 委派子 Agent(内置 general / explore / plan,可自定义类型,前台 / 后台 / 续聊 / worktree 隔离) |
55
- | 外部 Agent | `task(agent="claude" \| "codex" \| "acp:<程序>")` 以各 CLI 自己的登录驱动外部编码 Agent,审批只交给人;`ama --mode acp` 把 ama 暴露为 ACP Agent |
56
- | 回滚与沙箱 | 每回合检查点,`/rewind` / 双击 Esc 回到任一条消息之前(代码、对话或两者);macOS / Linux 的操作系统沙箱隔离 codemode 与(可选)bash |
57
- | codemode | 模型写一段 JS,在受 Node 权限模型约束的子进程里编排多次工具调用,只有输出回到模型 |
58
- | Skill | `SKILL.md` 目录,模型按索引自行读取,用户用 `/skill:<名字>` 调用;另有提示模板 |
59
- | 两层 Hook | 命令式 Hook(`hooks.json`,11 个事件,用户策略)与进程内宿主适配器 HostApi(嵌入方) |
60
- | 权限 | 四种模式、allow / deny 规则、危险命令识别(穿透 `sh -c` / `eval` / `xargs` / `find -exec`)、项目信任、审批时的执行前预览 |
61
- | 缓存 | 前缀稳定、缓存字段与兼容开关、未命中归因、「报 / 不报缓存」三态、长工具运行时保温、压缩摘要按会话前缀续写 |
62
- | 会话 | JSONL 条目树,分叉与 `/tree` 回溯;两档压缩(裁剪大工具结果 → 摘要)与熔断;预算上限(`--max-turns` / `--max-cost`)、重复调用检测、模型回退 |
63
- | 入口 | 差分渲染终端界面、`--no-tui` 行式、`-p`(text / json / stream-json)、`--mode rpc`、`--mode acp`、SDK |
64
-
65
- ## 安装
66
-
67
- 需要 **Node ≥ 22**。
31
+ - [Sub-agents](#sub-agents)
32
+ - [External agents](#external-agents)
33
+ - [Rewind](#rewind)
34
+ - [Memory](#memory)
35
+ - [Traces](#traces)
36
+ - [Interfaces and entry points](#interfaces-and-entry-points)
37
+ - [Embedding in Armadra](#embedding-in-armadra)
38
+ - [Documentation](#documentation)
39
+ - [Known limitations](#known-limitations)
40
+ - [Development](#development)
41
+
42
+ ## Why ama
43
+
44
+ - **An agent built to be called**: ama is driven by other programs as often as by people. One-shot `-p` runs, `--mode rpc`, the SDK and host adapters are all first-class entry points; exit codes and JSON shapes are contracts.
45
+ - **Clean layering**: following Pi's layering, protocol implementations are separate from provider data. Four protocol lines (Anthropic Messages, OpenAI Chat Completions, OpenAI Responses, Google Generative AI) are written once; a provider is just "baseUrl + key + model table + compat switches".
46
+ - **Minimal configuration**: one environment variable is enough to start; the common settings are five keys and everything else has a default. API keys only (official or relay), Skills and built-in tools only, no MCP.
47
+ - **Cache first**: most of the usage in long tasks is cache reads. ama keeps the request prefix byte-stable, places cache breakpoints the way each provider expects, and shows whether the cache works and why it missed.
48
+ - **Two ways to use it**: standalone it is a terminal coding agent; embedded in Armadra it is the coordinator on the canvas, dispatching work to CLI agents such as Claude Code, Codex and OpenCode, collecting their reports and summarizing.
49
+
50
+ ## Features
51
+
52
+ | Area | What you get |
53
+ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
+ | Protocols and providers | 4 protocol lines, 18 built-in providers (Anthropic, OpenAI, Google, DeepSeek, Moonshot, Zhipu, Qwen, OpenRouter, Groq, xAI, Mistral, MiniMax, StepFun, Volcengine Ark, Tencent, ChatGPT plan login, Ollama, LM Studio), built-in channels (Messages / Responses preferred, Chat as fallback), custom providers, per-model protocols |
55
+ | Zero config and relays | With a key present, the first available provider is picked (relays pick a default model by price rules); `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL` are recognized; `ama providers add` connects a relay from just a baseUrl and key: lists models, probes channels and writes the config back |
56
+ | Model metadata | Context window, output limit, image input, reasoning and prices come from a bundled models.dev snapshot (no network at startup or runtime; `ama models refresh` updates explicitly); one provider can mount several channels (Chat / Responses / Messages), `provider/model@channel` |
57
+ | Image input | `-p --image`, `@image-path` in the interface, `Ctrl+V` / `/paste` for clipboard images; per-endpoint size tiers with automatic resizing; models without image input refuse up front and suggest switching |
58
+ | Tools and presets | read / edit / write / bash / grep / glob, plus ls, todo, task / task_ctl (sub-agents) and codemode; four presets `default` / `minimal` / `codemode-only` / `coordinator` |
59
+ | Plan and sub-agents | Plan mode researches read-only, proposes a plan and executes after approval; `task` delegates to sub-agents (built-in general / explore / plan, custom types, foreground / background / follow-up / worktree isolation); an agent bar and a live sub-agent view you can talk to directly |
60
+ | External agents | `task(agent="claude" \| "codex" \| "acp:<program>")` drives external coding agents with each CLI's own login, and approvals go to a human only; `ama --mode acp` exposes ama as an ACP agent |
61
+ | Rewind and sandbox | A checkpoint per turn; `/rewind` / double Esc returns to before any message (code, conversation or both); an OS sandbox on macOS / Linux isolates codemode and (optionally) bash |
62
+ | codemode | The model writes a piece of JS that orchestrates many tool calls in a child process constrained by the Node permission model; only the output goes back to the model |
63
+ | Skills | `SKILL.md` directories; the model reads them from an index, users invoke them with `/skill:<name>`; prompt templates too |
64
+ | Two hook layers | Command hooks (`hooks.json`, 11 events, user policy) and the in-process host adapter HostApi (for embedders) |
65
+ | Permissions | Four modes, allow / deny rules, dangerous-command detection (sees through `sh -c` / `eval` / `xargs` / `find -exec`), project trust, a pre-execution preview in approvals |
66
+ | Caching | A stable prefix, cache fields and compat switches, miss attribution, a three-state "reports / does not report cache" model, warming during long tool runs, compaction summaries that continue the session prefix |
67
+ | Sessions | A JSONL entry tree with forks and `/tree` navigation; two-tier compaction (prune large tool results → summarize) with a circuit breaker; budgets (`--max-turns` / `--max-cost`), repeated-call detection, model fallback |
68
+ | Memory and traces | Opt-in cross-session memory (Markdown files, an index in the system prompt); a trace of every turn, request and tool with TTFT / decode / tool timing, in the TUI (`/trace`), as a single-file HTML page or over RPC |
69
+ | Settings and language | `/config` settings panel and `ama config get / set`; Chinese and English interface (`--lang`, `ui.language`, `AMA_LANG`) |
70
+ | Entry points | A differential-rendering terminal UI, `--no-tui` line mode, `-p` (text / json / stream-json), `--mode rpc`, `--mode acp`, the SDK |
71
+
72
+ ## Install
73
+
74
+ Requires **Node ≥ 22**.
68
75
 
69
76
  ### npm
70
77
 
@@ -73,88 +80,86 @@ npm i -g @armadra/agent
73
80
  ama --version
74
81
  ```
75
82
 
76
- ### Release 单文件
83
+ ### Single-file release
77
84
 
78
- [Releases](https://github.com/Owlbay/armadra-agent/releases) 附带 `ama.cjs`、`ama-sandbox.cjs`、`package.tgz` 与 `SHA256SUMS`。`ama.cjs` 是全部内联的单文件,`ama-sandbox.cjs` 是 codemode 的沙箱子进程入口,两者放在**同一目录**:
85
+ [Releases](https://github.com/Owlbay/armadra-agent/releases) ship `ama.cjs`, `ama-sandbox.cjs`, `package.tgz` and `SHA256SUMS`. `ama.cjs` is a fully inlined single file and `ama-sandbox.cjs` is the codemode sandbox child-process entry; keep both in the **same directory**:
79
86
 
80
87
  ```sh
81
- sha256sum -c --ignore-missing SHA256SUMS # macOS:shasum -a 256 -c --ignore-missing SHA256SUMS
88
+ sha256sum -c --ignore-missing SHA256SUMS # macOS: shasum -a 256 -c --ignore-missing SHA256SUMS
82
89
  node ama.cjs --version
83
90
  alias ama="node /path/to/ama.cjs"
84
91
  ```
85
92
 
86
- `package.tgz` 与 npm 上的包内容相同,可以离线安装:`npm i -g ./package.tgz`。
93
+ `package.tgz` has the same content as the npm package and can be installed offline: `npm i -g ./package.tgz`.
87
94
 
88
- ### 从源码构建
95
+ ### Build from source
89
96
 
90
97
  ```sh
91
98
  git clone https://github.com/Owlbay/armadra-agent.git && cd armadra-agent
92
99
  corepack enable && pnpm install
93
- pnpm build # 产出 dist/ 与 dist/bundle/ama.cjs、dist/bundle/ama-sandbox.cjs
100
+ pnpm build # produces dist/ and dist/bundle/ama.cjs, dist/bundle/ama-sandbox.cjs
94
101
  node dist/bundle/ama.cjs --version
95
102
  ```
96
103
 
97
- ### Node 版本、codemode 与沙箱
104
+ ### Node version, codemode and sandbox
98
105
 
99
- | Node / 平台 | codemode | bash 沙箱(`sandbox.bash: "auto"`) |
100
- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
101
- | ≥ 25 | 文件系统与网络都隔离;`codemode` 按只读类工具处理,`default` 权限模式下免审批;`default` 预设**缺省开启** codemode | 取决于平台(下两行) |
102
- | 22 / 24 + 操作系统沙箱(macOS、多数 Linux) | 子进程经 `sandbox-exec` / bubblewrap 启动,网络由内核拒绝;与 Node ≥ 25 相同:只读类、`default` 预设缺省开启 | macOS `sandbox-exec`、Linux bubblewrap 可用(`unshare` 不算) |
103
- | 22 / 24,没有操作系统沙箱(如 Windows) | 隔离文件系统,**不隔离网络**;`codemode` 按执行类处理,每次都要审批(状态栏显示红色 `net!`);`default` 预设缺省**不开** codemode,启动时提示一次(每个配置目录一次) | 不可用,bash 照常审批 |
106
+ | Node / platform | codemode | bash sandbox (`sandbox.bash: "auto"`) |
107
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
108
+ | ≥ 25 | File system and network both isolated; `codemode` counts as a read-only tool and needs no approval in `default` permission mode; the `default` preset **enables** codemode by default | Depends on the platform (next two rows) |
109
+ | 22 / 24 + OS sandbox (macOS, most Linux) | The child process starts through `sandbox-exec` / bubblewrap and the kernel denies network; same as Node ≥ 25: read-only class, enabled by default in the `default` preset | Available with macOS `sandbox-exec` or Linux bubblewrap (`unshare` does not count) |
110
+ | 22 / 24 without an OS sandbox (e.g. Windows) | File system isolated, **network not isolated**; `codemode` counts as an execute-class tool and needs approval every time (red `net!` in the status bar); the `default` preset does **not** enable codemode, with a one-time notice per config directory | Not available; bash asks for approval as usual |
104
111
 
105
- 其余功能在 Node 22 起都一样。`ama doctor` 显示本机的操作系统沙箱能力([docs/sandbox.md](docs/sandbox.md));`sandbox.enabled: "off"` 或 `AMA_SANDBOX=off` 关闭它。网络未隔离时想用 codemode 就显式开:`--codemode on` 或 config 写 `"codemode": { "mode": "on" }`。`codemode.requireStrict: true` 可以在网络未隔离时直接禁用 codemode。
112
+ Everything else works the same from Node 22 on. `ama doctor` shows the OS sandbox capabilities of the machine ([docs/sandbox.md](docs/sandbox.md), Chinese); `sandbox.enabled: "off"` or `AMA_SANDBOX=off` turns it off. To use codemode without network isolation, enable it explicitly: `--codemode on` or `"codemode": { "mode": "on" }` in the config. `codemode.requireStrict: true` disables codemode outright when the network is not isolated.
106
113
 
107
- ## 快速开始
114
+ ## Quick start
108
115
 
109
- **零配置**:设好任一家的标准环境变量就能用,ama 按内置顺序选第一个有 key 的供应商和它的缺省模型(`ama config show` 说明选了谁、为什么)。没有任何 key 时启动会提示怎么配,不会落到测试用的 `fake` 供应商上。
116
+ **Zero config**: set the standard environment variable of any provider and go. ama picks the first provider with a key in built-in order, and that provider's default model (`ama config show` explains which and why). Without any key, startup tells you how to configure one instead of silently using the test `fake` provider.
110
117
 
111
118
  ```sh
112
- export ANTHROPIC_API_KEY=sk-... # 或 OPENAI_API_KEY、GEMINI_API_KEY、DEEPSEEK_API_KEY、MOONSHOT_API_KEY ……
119
+ export ANTHROPIC_API_KEY=sk-... # or OPENAI_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY, MOONSHOT_API_KEY …
113
120
  cd your-project
114
- ama # 终端界面
121
+ ama # terminal UI
115
122
  ```
116
123
 
117
- **把 key 存起来**:不想放在环境变量里,就存进 `~/.config/ama/auth.json`(0600)。key 从 stdin 读取,不经命令行参数、不进 shell 历史:
124
+ **Store a key**: if you prefer not to keep it in the environment, store it in `~/.config/ama/auth.json` (0600). The key is read from stdin, never from command-line arguments, so it stays out of shell history:
118
125
 
119
126
  ```sh
120
- ama auth set deepseek # 终端里输入(不回显)
121
- ama auth list # 只列供应商与 key 形态,不显示 key
127
+ ama auth set deepseek # type it in the terminal (not echoed)
128
+ ama auth list # lists providers and key shapes only, never the key
122
129
  ama auth remove deepseek
123
130
  ```
124
131
 
125
- **一次性运行**:`-p` 执行完就退出,适合脚本与管道。
132
+ **One-shot runs**: `-p` exits when done, for scripts and pipes.
126
133
 
127
134
  ```sh
128
- ama -p "解释一下 src/index.ts"
129
- git diff | ama -p "审阅这段改动" # 提示也可以来自 stdin
130
- ama -p "列出 TODO" --model deepseek/deepseek-v4-pro --output-format json
135
+ ama -p "explain src/index.ts"
136
+ git diff | ama -p "review this change" # the prompt can come from stdin too
137
+ ama -p "list the TODOs" --model deepseek/deepseek-v4-pro --output-format json
131
138
  ```
132
139
 
133
- **常用参数**:
140
+ **Common flags**:
134
141
 
135
- | 参数 | 作用 |
136
- | ------------------------------------------------------- | ------------------------------------------------------------ |
137
- | `--model provider/id` | 选模型(配置、命令行、`/model`、SDK 写法一致) |
138
- | `--thinking off\|minimal\|low\|medium\|high\|xhigh` | 思考级别(缺省 `medium`) |
139
- | `--permission-mode plan\|default\|auto-edit\|full-auto` | 权限模式(缺省 `default`) |
140
- | `-c` / `-r [id]` | 继续本目录最近的会话 / 选择会话恢复 |
141
- | `--tools-preset <名>` | 工具预设(见下文) |
142
- | `--allow <规则>` / `--deny <规则>` | 追加权限规则,可重复 |
143
- | `--max-turns N` / `--max-cost USD` | 一次运行的轮数 / 美元上限(`-p` 到限退出 8) |
144
- | `--agent-dir <目录>` | 追加子 Agent 定义目录,可重复 |
145
- | `--mode rpc` / `--mode acp` | stdio 上说 RPC(JSONL)/ ACP(JSON-RPC),供宿主与编辑器驱动 |
142
+ | Flag | Effect |
143
+ | ------------------------------------------------------- | --------------------------------------------------------------------------- |
144
+ | `--model provider/id` | Pick a model (same syntax in config, command line, `/model` and the SDK) |
145
+ | `--thinking off\|minimal\|low\|medium\|high\|xhigh` | Thinking level (default `medium`) |
146
+ | `--permission-mode plan\|default\|auto-edit\|full-auto` | Permission mode (default `default`) |
147
+ | `-c` / `-r [id]` | Continue the latest session in this directory / pick a session to resume |
148
+ | `--tools-preset <name>` | Tool preset (see below) |
149
+ | `--allow <rule>` / `--deny <rule>` | Add permission rules; repeatable |
150
+ | `--max-turns N` / `--max-cost USD` | Turn / USD limit per run (`-p` exits with 8 when reached) |
151
+ | `--agent-dir <dir>` | Extra sub-agent definition directory; repeatable |
152
+ | `--lang zh\|en` | Interface language (also `AMA_LANG` and `ui.language`) |
153
+ | `--memory` / `--no-memory` | Turn memory on / off for this launch |
154
+ | `--mode rpc` / `--mode acp` | Speak RPC (JSONL) / ACP (JSON-RPC) on stdio, for hosts and editors to drive |
146
155
 
147
- **内置供应商**(17 家):Anthropic、OpenAI、Google、DeepSeek、Moonshot(Kimi)、智谱、通义(DashScope)、OpenRouter、Groq、xAI、Mistral、MiniMax、阶跃、火山方舟、腾讯 TokenHub、Ollama、LM Studio。多协议的供应商带内置渠道,缺省协议 Messages / Responses 优先、Chat 回落:OpenAI、xAI、火山方舟走 Responses,通义、MiniMax、阶跃、腾讯走 Messages,DeepSeek、智谱、Kimi 暂走 Chat(`@messages` 可选),`provider/model@渠道` 指定渠道。完整表见 [docs/providers.md](docs/providers.md)「内置供应商」。
156
+ **Built-in providers** (18): Anthropic, OpenAI, Google, DeepSeek, Moonshot (Kimi), Zhipu, Qwen (DashScope), OpenRouter, Groq, xAI, Mistral, MiniMax, StepFun, Volcengine Ark, Tencent TokenHub, ChatGPT (sign in with your plan, see "ChatGPT login"), Ollama, LM Studio. Multi-protocol providers ship built-in channels with Messages / Responses preferred and Chat as fallback: OpenAI, xAI and Volcengine Ark use Responses; Qwen, MiniMax, StepFun and Tencent use Messages; DeepSeek, Zhipu and Kimi use Chat for now (`@messages` is optional). `provider/model@channel` picks a channel. The full table is in [docs/en/providers.md](docs/en/providers.md) "Built-in providers".
148
157
 
149
- 本地 Ollama / LM Studio 不需要 key:`ama --model ollama/<模型名>`。`ama --help` 列出全部参数与子命令;测试或排查时可用不花钱的 `--model fake/echo`(回显最后一条用户消息;模型选择器、`models list`、`doctor` 缺省不列这个测试供应商,`AMA_SHOW_FAKE=1` 时列出)。
158
+ Local Ollama / LM Studio need no key: `ama --model ollama/<model>`. `ama --help` lists every flag and subcommand; for tests and troubleshooting use the free `--model fake/echo` (echoes the last user message; the model picker, `models list` and `doctor` hide this test provider unless `AMA_SHOW_FAKE=1`).
150
159
 
151
- ## 配置
160
+ ## Configuration
152
161
 
153
- 一个文件 `~/.config/ama/config.json`。第一次进入对话(交互、`-p`、RPC)或 `ama providers add` 时自动建好目录(0700)、
154
- 最小的 `config.json` 与给编辑器用的 `config.schema.json`;`config show`、`doctor`、`models list` 等只读命令不写配置目录。
155
- 也可以 `ama init` 手动建(已有文件不覆盖)。生成的 `config.json` 只有 `$schema`、`version` 与空 `providers`,不写死缺省值——以后
156
- 缺省值调整时老配置同样跟着变。`ama config path` 打印各文件位置,`ama config edit` 用 `$VISUAL` / `$EDITOR` 打开,
157
- `config.schema.json` 给每个键带了说明与缺省值,编辑器悬停可见。常用的只有五个键:
162
+ One file: `~/.config/ama/config.json`. The first time you enter a conversation (interactive, `-p`, RPC) or run `ama providers add`, ama creates the directory (0700), a minimal `config.json` and a `config.schema.json` for editors; read-only commands such as `config show`, `doctor` and `models list` never write the config directory. You can also run `ama init` by hand (existing files are not overwritten). The generated `config.json` holds only `$schema`, `version` and empty `providers`, with no hard-coded defaults, so old configs follow when defaults change later. `ama config path` prints where each file lives, `ama config edit` opens it with `$VISUAL` / `$EDITOR`, and `config.schema.json` carries a description and default for every key, visible on hover in editors. The common settings are just five keys:
158
163
 
159
164
  ```json
160
165
  {
@@ -168,54 +173,64 @@ ama -p "列出 TODO" --model deepseek/deepseek-v4-pro --output-format json
168
173
  }
169
174
  ```
170
175
 
171
- 其余(`compaction`、`retry`、`codemode`、`hooks`、`ui`、`skills`、`cache`、`request`)都有缺省,`ama config show` 列出每一项的生效值与来源(default / user / profile / project / cli),也接受 `--tools-preset` / `--codemode` 看覆盖后的效果。
176
+ Everything else (`compaction`, `retry`, `codemode`, `hooks`, `ui`, `skills`, `cache`, `request`) has defaults. `ama config show` lists the effective value and source (default / user / profile / project / cli) of every key, and also accepts `--tools-preset` / `--codemode` to preview overrides.
177
+
178
+ **Request timeout**: model requests have an idle timeout, 300 s by default. Waiting longer than that for response headers, or between two chunks of the stream, counts as stuck and is retried with `retry` backoff as a retryable error (any byte received resets the timer, so long answers are unaffected). Adjust with `request.idleTimeoutMs` (user level only) or the `AMA_IDLE_TIMEOUT_MS` environment variable; 0 disables it.
179
+
180
+ **Interface language**: choose it with `ui.language` (`auto` / `zh` / `en`, default `auto`), `--lang zh|en` or the `AMA_LANG` environment variable. `auto` decides from `LC_ALL` / `LC_MESSAGES` / `LANG`: `zh*` is Chinese, anything else English (to keep Chinese regardless: `ama config set ui.language zh`). It affects the interface and config descriptions only (`config.schema.json` is written in the current language; run `ama init` again after switching to rewrite it); text sent to the model is always English. To have the model reply in a given language, set `ui.replyLanguage`. See [docs/i18n.md](docs/i18n.md) (Chinese).
172
181
 
173
- **请求超时**:模型请求有空闲超时,缺省 300 s——等响应头、以及流里两块数据之间超过这个时间就判定卡住,按可重试错误
174
- 走 `retry` 的退避重试(收到任何字节即重新计时,长回答不受影响)。用 `request.idleTimeoutMs`(只认用户级)或环境变量
175
- `AMA_IDLE_TIMEOUT_MS` 调整,0 关闭。
182
+ **Proxy**: when `HTTPS_PROXY` / `HTTP_PROXY` is set (`NO_PROXY` excludes), ama enables Node's built-in environment proxy at startup (equivalent to `NODE_USE_ENV_PROXY=1`, zero dependencies). It works directly on Node 24+; on Node 22 only 22.21+ with `NODE_USE_ENV_PROXY=1` works, older versions print a one-time notice and connect directly. The "Proxy" section of `ama doctor` shows the current state (credentials in the proxy URL are masked).
176
183
 
177
- **代理**:设了 `HTTPS_PROXY` / `HTTP_PROXY`(`NO_PROXY` 排除)时,ama 启动时调用 Node 内置的环境变量代理(等价于
178
- `NODE_USE_ENV_PROXY=1`,零依赖)。Node 24+ 直接可用;Node 22 只有 22.21+ 设 `NODE_USE_ENV_PROXY=1` 才行,更早的版本会提示一次
179
- 并直连。`ama doctor` 的「代理」一节显示当前状态(代理地址里的账号密码打码)。
184
+ ### File locations and layers
180
185
 
181
- ### 文件位置与层级
186
+ | Location | Contents |
187
+ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
188
+ | `~/.config/ama/` | User level: `config.json`, `config.schema.json` (generated by ama), `auth.json` (0600), `hooks.json`, `keybindings.json`, `trust.json`, `AGENTS.md`, `skills/` |
189
+ | `~/.local/share/ama/` | Data: `sessions/` (session JSONL), `plans/` (plan files), `file-history/` (checkpoint backups), `memory/` (memories, when enabled), `models-dev.json` (override from `ama models refresh`), input history |
190
+ | `<project>/.ama/` | Project level: `config.json` (can only tighten), `hooks.json` / `skills/` / `prompts/` (require trust) |
191
+ | `<project>/AGENTS.md` | Project conventions, looked up from cwd upwards and added to the system prompt automatically |
192
+ | `--profile <file>` | Host profile (for embedders, see "Embedding in Armadra") |
182
193
 
183
- | 位置 | 内容 |
184
- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
185
- | `~/.config/ama/` | 用户级:`config.json`、`config.schema.json`(ama 生成)、`auth.json`(0600)、`hooks.json`、`keybindings.json`、`trust.json`、`AGENTS.md`、`skills/` |
186
- | `~/.local/share/ama/` | 数据:`sessions/`(会话 JSONL)、`plans/`(计划文件)、`file-history/`(检查点备份)、`models-dev.json`(`ama models refresh` 的覆盖)、输入历史 |
187
- | `<项目>/.ama/` | 项目级:`config.json`(只能收紧)、`hooks.json` / `skills/` / `prompts/`(需信任) |
188
- | `<项目>/AGENTS.md` | 项目约定,从 cwd 向上查找,自动进系统提示 |
189
- | `--profile <文件>` | 宿主 profile(嵌入方用,见「嵌入 Armadra」) |
194
+ `AMA_CONFIG_DIR` / `AMA_DATA_DIR` change the two directories; `XDG_CONFIG_HOME` / `XDG_DATA_HOME` are honored too, and on Windows they are `%APPDATA%\ama` and `%LOCALAPPDATA%\ama`.
190
195
 
191
- `AMA_CONFIG_DIR` / `AMA_DATA_DIR` 可改两个目录;也遵循 `XDG_CONFIG_HOME` / `XDG_DATA_HOME`,Windows 下是 `%APPDATA%\ama` 与 `%LOCALAPPDATA%\ama`。
196
+ Layers merge as **built-in defaults ← user ← profile ← project**, but the project level can only tighten: it can add deny rules, make the permission mode stricter, narrow the tool preset and turn codemode off. Loosening items such as `allow` rules, laxer modes, `cache` and `tools.default` are ignored with a warning. Cloning an unfamiliar repository therefore never widens permissions through its config.
192
197
 
193
- 合并顺序是 **内置缺省 ← 用户级 ← profile ← 项目级**,但项目级只能收紧:可以追加 deny、把权限模式改严、把工具预设改窄、关掉 codemode;`allow` 规则、放宽模式、`cache`、`tools.default` 等放宽项被忽略并给出 warning。这样克隆一个陌生仓库不会因为它的配置而放开权限。
198
+ ### `/config` and `ama config`
194
199
 
195
- ### 检查
200
+ `/config` in the terminal UI opens a settings panel: scalar settings by group with their effective value, source and when a change takes effect; ↑↓ Enter / Space change a value, `/` searches, Tab switches between user and project level (project level may only tighten). Changes are written at once (one key only, `.bak` kept); `/config key=value` sets one key without the panel. From the shell:
196
201
 
197
202
  ```sh
198
- ama config show # 每一项的生效值与来源、供应商、将使用的模型、工具
203
+ ama config get ui.language
204
+ ama config set ui.language en # --project writes .ama/config.json (tighten-only)
205
+ ama config set tools.disabled '["bash"]' --json-value
206
+ ama config unset ui.language
207
+ ama config list ui # value, source, when it applies
208
+ ```
209
+
210
+ Unknown keys, invalid values and loosening at project level exit with 3 and leave the file alone. See [docs/en/tui.md](docs/en/tui.md) "The `/config` settings panel and `ama config`".
211
+
212
+ ### Checking
213
+
214
+ ```sh
215
+ ama config show # effective value and source of every key, providers, the model to be used, tools
199
216
  ama config show --json
200
- ama doctor # 配置层级、项目信任、key 来源、Hook、终端能力
217
+ ama doctor # config layers, project trust, key sources, hooks, terminal capabilities
201
218
  ```
202
219
 
203
- ## 接入中转站
220
+ ## Relays and gateways
204
221
 
205
- **一键接入**:只给 baseUrl 与 key。
222
+ **One-step setup**: give just a baseUrl and a key.
206
223
 
207
224
  ```sh
208
225
  export PACKY_API_KEY=sk-...
209
226
  ama providers add packy --base-url https://proxy.example/v1 --key-env PACKY_API_KEY --probe --limit 8 --yes
210
- ama -p "hi" --model packy/kimi-k2.5 # 首选渠道
211
- ama -p "hi" --model packy/kimi-k2.5@messages # 指定渠道(Anthropic Messages)
212
- ama -p "图里有什么颜色" --image shot.png --model packy/kimi-k2.5
213
- ama providers list # 供应商 → 渠道 → 模型数、key 来源
227
+ ama -p "hi" --model packy/kimi-k2.5 # preferred channel
228
+ ama -p "hi" --model packy/kimi-k2.5@messages # a specific channel (Anthropic Messages)
229
+ ama -p "what colors are in this picture" --image shot.png --model packy/kimi-k2.5
230
+ ama providers list # provider → channels → model count, key source
214
231
  ```
215
232
 
216
- `add` 列出 `GET {baseUrl}/models` 的模型,从 baseUrl 推出 chat / responses / messages 三个候选渠道,`--probe` 逐渠道发最小
217
- 请求,把能用的渠道写进每个模型的 `channels`;上下文、输出上限、图像、推理与价格不写进配置,运行时从内置的 models.dev
218
- 快照补(`ama models list` 标出每个字段的来源)。不给 `--key-env` 时 key 从 stdin 读(不回显)存进 `auth.json`。写入后的配置:
233
+ `add` lists the models from `GET {baseUrl}/models`, derives three candidate channels (chat / responses / messages) from the baseUrl, and with `--probe` sends a minimal request per channel and writes the working channels into each model's `channels`. Context window, output limit, images, reasoning and prices are not written to the config; at runtime they come from the bundled models.dev snapshot (`ama models list` marks where each field comes from). Without `--key-env` the key is read from stdin (not echoed) and stored in `auth.json`. The resulting config:
219
234
 
220
235
  ```json
221
236
  {
@@ -237,14 +252,14 @@ ama providers list # 供应商 → 渠道 →
237
252
  }
238
253
  ```
239
254
 
240
- **零配置**:内置的 `openai` / `anthropic` 识别 `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL`。baseUrl 不在官方主机时接受目录外的 model id,缓存相关字段按保守缺省。
255
+ **Zero config**: the built-in `openai` / `anthropic` providers recognize `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL`. When the baseUrl is not an official host, model ids outside the catalog are accepted and cache-related fields use conservative defaults.
241
256
 
242
257
  ```sh
243
258
  OPENAI_BASE_URL=https://proxy.example/v1 OPENAI_API_KEY=$PACKY_API_KEY \
244
259
  ama -p "hi" --model openai/qwen3.8-flash
245
260
  ```
246
261
 
247
- **一个供应商 + 模型级协议**:同一个中转站下,不同模型支持的协议常常不同。不必为每种协议建一个供应商,把 `api` 写在模型上即可:
262
+ **One provider, per-model protocols**: under one relay, different models often support different protocols. Instead of a provider per protocol, put `api` on the model:
248
263
 
249
264
  ```json
250
265
  {
@@ -263,258 +278,279 @@ OPENAI_BASE_URL=https://proxy.example/v1 OPENAI_API_KEY=$PACKY_API_KEY \
263
278
  }
264
279
  ```
265
280
 
266
- - `api` 缺省 `openai-completions`;可选 `openai-responses`、`anthropic-messages`、`google-generative-ai`。
267
- - `apiKey` 支持 `$ENV` / `${ENV}`(读环境变量)与 `!command`(执行命令取值),不要把 key 明文写进配置。
268
- - 自定义模型的元数据缺省从随包的 models.dev 快照补(启动不联网;`ama models refresh` 显式联网刷新到数据目录,`refresh-catalog`
269
- 是旧名);匹配不到时不猜 `contextWindow`,自动压缩关闭,需要时在模型条目里补上或写 `"modelsDev": "provider/model"` 指定条目。
281
+ - `api` defaults to `openai-completions`; also `openai-responses`, `anthropic-messages`, `google-generative-ai`.
282
+ - `apiKey` supports `$ENV` / `${ENV}` (read an environment variable) and `!command` (run a command for the value); never put a key in the config in plain text.
283
+ - Custom model metadata defaults to the bundled models.dev snapshot (no network at startup; `ama models refresh` refreshes explicitly into the data directory, `refresh-catalog` is the old name). Without a match `contextWindow` is not guessed and automatic compaction is off; add it to the model entry when needed, or point to an entry with `"modelsDev": "provider/model"`.
284
+
285
+ **Don't want to write the model table by hand**: let ama ask the relay.
286
+
287
+ ```sh
288
+ ama models discover packy # list GET {baseUrl}/models
289
+ ama models discover packy --probe --write --limit 8 # probe each model's protocols and write back to the config
290
+ ama models check packy/grok-4.7 # one minimal request to confirm connectivity
291
+ ama models cache-probe packy/grok-4.7 # does this endpoint report cache usage
292
+ ```
293
+
294
+ `--probe` tries a few protocols per model and records the first that works; `--write` merges into the user-level `config.json` (the original is backed up as `config.json.bak`, existing entries are not overwritten). Both `--probe` and `cache-probe` send real requests: they print an estimate first and stop on 401 / 403 / 429; `cache-probe` needs `--yes` when not interactive. Details in [docs/en/providers.md](docs/en/providers.md).
295
+
296
+ ## ChatGPT login
270
297
 
271
- **不想手写模型表**:让 ama 去问中转站。
298
+ Use your own ChatGPT Plus / Pro plan instead of an API key (built-in provider `chatgpt`; for your own personal use only):
272
299
 
273
300
  ```sh
274
- ama models discover packy # 列出 GET {baseUrl}/models
275
- ama models discover packy --probe --write --limit 8 # 逐个探测可用协议并写回配置
276
- ama models check packy/grok-4.7 # 一次最小请求确认连通
277
- ama models cache-probe packy/grok-4.7 # 这个端点报不报缓存
301
+ ama auth login chatgpt # official Sign in with ChatGPT in the browser; --paste over SSH
302
+ ama auth status # flavor, plan, masked email, token lifetime
303
+ ama models discover chatgpt # models available to the account
304
+ ama --model chatgpt/<model>
305
+ ama auth logout chatgpt
278
306
  ```
279
307
 
280
- `--probe` 对每个模型依次试几种协议,记第一个成功的;`--write` 合并进用户级 `config.json`(原文件备份为 `config.json.bak`,已有条目不覆盖)。`--probe` 与 `cache-probe` 都会发真实请求:执行前打印预估,401 / 403 / 429 即停,`cache-probe` 在非交互环境需要 `--yes`。细节见 [docs/providers.md](docs/providers.md)。
308
+ Credentials are an OAuth entry in `auth.json` (0600), refreshed automatically and serialized across processes; tokens never reach logs, sessions or events. Plan requests cost 0 and show as "subscription" in `/session` and `ama stats`; an exhausted quota reports `quota_exceeded`, an expired login `auth_expired`. `--flavor codex` is an opt-in fallback path. See [docs/en/providers.md](docs/en/providers.md) "ChatGPT login".
281
309
 
282
- ## 工具与预设
310
+ ## Tools and presets
283
311
 
284
- | 预设 | 模型直接看到的工具 | 适合 |
285
- | --------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
286
- | `default` | read、edit、write、bash、grep、glob;网络隔离时另加 `codemode` | 缺省(要 todo 就 `tools.default: ["+todo"]`) |
287
- | `minimal` | read、edit、write、bash | 小模型、小上下文;`full-auto` |
288
- | `codemode-only` | 只有 `codemode` | 长流程、工具调用密集的任务 |
289
- | `coordinator` | read 与宿主注册的画布工具 | 嵌入 Armadra 的协调者:不写文件、不跑 bash;codemode 缺省关,显式开了脚本里也只能调这些工具 |
312
+ | Preset | Tools the model sees directly | Good for |
313
+ | --------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
314
+ | `default` | read, edit, write, bash, grep, glob; plus `codemode` with network isolation | The default (for todo, set `tools.default: ["+todo"]`) |
315
+ | `minimal` | read, edit, write, bash | Small models, small contexts; `full-auto` |
316
+ | `codemode-only` | only `codemode` | Long workflows heavy on tool calls |
317
+ | `coordinator` | read and the canvas tools registered by the host | The coordinator embedded in Armadra: writes no files, runs no bash; codemode is off by default, and when enabled explicitly scripts can call only these tools |
290
318
 
291
- - `--tools-preset <名>` 或 `tools.preset` 选预设。`codemode` 是 `codemode-only` 的旧名(0.3.0),配置、命令行、RPC、SDK 都还认,`ama config show` 显示规范名并提示。
292
- - `tools.default` 在预设上微调:`["+task", "+todo", "-glob"]`;不带前缀的名字整组替换。`task` 与 `task_ctl` 同进退(`+task` 一起加)。
293
- - 另有 `--tools a,b,c`(只启用这些)、`--exclude-tools a,b`、交互模式的 `/tools`。
319
+ - Pick a preset with `--tools-preset <name>` or `tools.preset`. `codemode` is the old name of `codemode-only` (0.3.0); config, command line, RPC and SDK still accept it, and `ama config show` shows the canonical name with a hint.
320
+ - `tools.default` tweaks the preset: `["+task", "+todo", "-glob"]`; bare names replace the whole set. `task` and `task_ctl` go together (`+task` adds both).
321
+ - There are also `--tools a,b,c` (enable only these), `--exclude-tools a,b` and `/tools` in interactive mode.
294
322
 
295
- **codemode** 让模型写一段 JavaScript,用 `tools.<name>(args)` 编排多次工具调用(可以 `Promise.all` 并发),只有脚本输出回到模型。脚本跑在 `node --permission` 子进程的 vm 里:没有 `require` / `import` / `process` / `fetch`,每次内层调用仍逐个经过 Hook、权限与审批。
323
+ **codemode** lets the model write a piece of JavaScript that orchestrates many tool calls with `tools.<name>(args)` (concurrently with `Promise.all`); only the script's output goes back to the model. The script runs in a vm inside a `node --permission` child process: no `require` / `import` / `process` / `fetch`, and every inner call still goes through hooks, permissions and approval one by one.
296
324
 
297
- **缺省开放**:`codemode.mode` 不写时跟随预设——`default` → `on`(六个工具 + codemode,只在网络隔离的沙箱里:Node ≥ 25,或 Node 22 / 24 + 操作系统沙箱;否则 `off`),`codemode-only` → `only`,`minimal` / `coordinator` → `off`。显式的 `--codemode off|on|only` 或 `codemode.mode` 优先,项目级只能写 `off`。`on` 模式下 codemode 的描述只用一行列出可在脚本里调用的直接工具(参数相同)与仅脚本可调的工具名,不重复声明,前缀只多约 400 token([三预设基准](https://github.com/Owlbay/armadra-agent/blob/main/docs/benchmarks/presets-2026-10-02.md)测的是去重前的 codemode 预设:小任务输入多约 45%、轮数不减)。只读检索多、调用次数多的长流程可以用 `codemode-only`。
325
+ **Default exposure**: when `codemode.mode` is unset it follows the preset: `default` → `on` (six tools + codemode, only inside a network-isolating sandbox: Node ≥ 25, or Node 22 / 24 + an OS sandbox; otherwise `off`), `codemode-only` → `only`, `minimal` / `coordinator` → `off`. An explicit `--codemode off|on|only` or `codemode.mode` wins; the project level can only write `off`. In `on` mode the codemode description lists, in one line, the direct tools callable from scripts (same parameters) and the script-only tool names, without re-declaring them, adding only about 400 tokens to the prefix (the [three-preset benchmark](https://github.com/Owlbay/armadra-agent/blob/main/docs/benchmarks/presets-2026-10-02.md) measured the codemode preset before deduplication: about 45% more input on small tasks, no fewer turns). Long workflows with many read-only lookups and many calls can use `codemode-only`.
298
326
 
299
- ## 缓存
327
+ ## Caching
300
328
 
301
- 长任务的主要用量是缓存读取:前缀一旦变化,此后每次请求都按全价重读。ama 分三层处理:
329
+ Most usage in long tasks is cache reads: once the prefix changes, every later request re-reads it at full price. ama handles this in three layers:
302
330
 
303
- - **协议层**:系统提示节顺序固定、不含时间戳,工具按名排序,中途变化只追加在末尾;按各家写法打缓存断点(Anthropic `cache_control`、OpenAI `prompt_cache_key` 等),端点 400 拒收某个缓存字段时自动去掉重发。
304
- - **会话层**:每次请求记前缀指纹,检测未命中并归因(空闲超时、子任务、切换模型、系统提示 / 工具表变化、服务端淘汰),判定端点报不报缓存,长工具运行期间保温。
305
- - **展示层**:状态栏、`/session`、`/cache`、RPC 统计与 `ama models cache-probe`。
331
+ - **Protocol layer**: the system prompt sections have a fixed order and no timestamps, tools are sorted by name, and mid-session changes are only appended at the end; cache breakpoints follow each provider's style (Anthropic `cache_control`, OpenAI `prompt_cache_key`, …), and when an endpoint rejects a cache field with 400 it is dropped and the request resent.
332
+ - **Session layer**: every request records a prefix fingerprint to detect and attribute misses (idle timeout, sub-task, model switch, system prompt / tool table change, server eviction), decides whether the endpoint reports cache usage, and warms the cache during long tool runs.
333
+ - **Display layer**: the status bar, `/session`, `/cache`, RPC stats and `ama models cache-probe`.
306
334
 
307
- ### 读状态栏
335
+ ### Reading the status bar
308
336
 
309
- 独立终端缺省两行(`Ctrl+G` / `/statusline` 切换成一行,嵌入宿主缺省一行):
337
+ A standalone terminal shows two lines by default (`Ctrl+G` / `/statusline` switches to one; embedding hosts default to one):
310
338
 
311
339
  ```
312
340
  tps: 100 tok/s • 546 tok / 5.5s (avg 100 · ttft 1.4s) ↑412k ↓8.1k · cache 83% ♨ · rebill $0.11 · [-]
313
341
  Accept edits claude-opus-5-5 medium | Ctx 34.0% | proj ⎇ main 5ae9e54 (+12,-3) | $0.84 | 2h24m
314
342
  ```
315
343
 
316
- 上行是速率与用量,下行是权限模式、模型与思考级别、上下文、目录与 git 分支(含工作区增删行)、费用、会话时长。缓存相关的项:
344
+ The top line is throughput and usage; the bottom line is permission mode, model and thinking level, context, directory and git branch (with working-tree line changes), cost and session duration. The cache-related items:
317
345
 
318
- | 项 | 怎么读 |
319
- | -------------- | -------------------------------------------------------------------------- |
320
- | `cache 83%` | **最近一次**请求的命中率;会话累计在 `/session` |
321
- | `cache —` | 端点还没报过缓存(还没有足够长的可比请求) |
322
- | `cache 未报告` | 端点不报缓存(连续 3 次读写都是 0);这类请求不算进命中率,而不是显示成 0% |
323
- | `♨` | 保温计时中 |
324
- | `rebill $0.11` | 本会话因缓存未命中多付的钱(无价格的模型显示 token);为 0 不显示 |
325
- | `Ctx 34.0%` | 上下文占用;≥ 70% 黄、≥ 90% 红,跨过时消息区提示「约剩 N 回合」 |
346
+ | Item | How to read it |
347
+ | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
348
+ | `cache 83%` | Hit rate of the **latest** request; the session total is in `/session` |
349
+ | `cache —` | The endpoint has not reported cache usage yet (no long enough comparable request so far) |
350
+ | `cache` "not reported" | The endpoint does not report cache usage (reads and writes were 0 three times in a row); such requests are left out of the hit rate rather than shown as 0% |
351
+ | `♨` | Warming timer running |
352
+ | `rebill $0.11` | Extra spend in this session caused by cache misses (tokens for models without prices); hidden when 0 |
353
+ | `Ctx 34.0%` | Context usage; yellow at ≥ 70%, red at ≥ 90%, with an "about N turns left" note in the message area when crossed |
326
354
 
327
- 一次未命中重计费 ≥ 20k token 或 ≥ $0.10 时,消息区写一行原因。`/cache` 看缓存统计,`/cache fingerprint` 查前缀指纹(两次之间哈希变了,就是系统提示或工具表被改了)。
355
+ When one miss re-bills ≥ 20k tokens or ≥ $0.10, the message area gets one line with the reason. `/cache` shows cache stats and `/cache fingerprint` the prefix fingerprint (if the hash changed between two requests, the system prompt or tool table was modified).
328
356
 
329
- ### 三态、保温与摘要续写
357
+ ### Three states, warming and summary continuation
330
358
 
331
- - **三态**:每个端点(供应商 + 主机 + 模型)在 `unknown` / `reported` / `silent` 之间判定。只有 `reported` 才显示命中率、检测未命中、保温;不报缓存的中转不会被误报成 0%。中转上已知不报的模型可以设 `compat.cacheReporting: "silent"`。
332
- - **保温**:工具长时间运行(长测试、`task` 子任务、codemode 脚本)时,在缓存 TTL 到期前重放一次上一个请求(`maxTokens: 1`),只付读价把缓存续上。`cache.warming` 取 `off` / `streaming`(缺省,只在运行中)/ `idle`(空闲也保温,适合贵模型),`/cache warm …` 本会话切换;期望节省低于 `cache.minSavingsUsd`(缺省 $0.05)不发。
333
- - **摘要续写**:上下文压缩的摘要请求接在与上一次真实请求逐字节相同的前缀后面,整段历史按读价计费;失败时回落为独立摘要请求。
359
+ - **Three states**: each endpoint (provider + host + model) is classified as `unknown` / `reported` / `silent`. Only `reported` shows a hit rate, detects misses and warms; relays that do not report cache usage are never misreported as 0%. For models known not to report on a relay, set `compat.cacheReporting: "silent"`.
360
+ - **Warming**: while a tool runs for a long time (long tests, `task` sub-tasks, codemode scripts), the previous request is replayed once before the cache TTL expires (`maxTokens: 1`), paying only the read price to keep the cache alive. `cache.warming` is `off` / `streaming` (default, only while running) / `idle` (also while idle, for expensive models); `/cache warm …` switches it for the session; nothing is sent when the expected saving is below `cache.minSavingsUsd` (default $0.05).
361
+ - **Summary continuation**: the compaction summary request follows a prefix byte-identical to the last real request, so the whole history is billed at the read price; on failure it falls back to a standalone summary request.
334
362
 
335
- ### 实测
363
+ ### Measurements
336
364
 
337
- [缓存验收实验](https://github.com/Owlbay/armadra-agent/blob/main/docs/benchmarks/cache-2026-10-02.md)(2026-10-02,经一家测试中转站):
365
+ [Cache acceptance experiment](https://github.com/Owlbay/armadra-agent/blob/main/docs/benchmarks/cache-2026-10-02.md) (2026-10-02, through one test relay):
338
366
 
339
- | 场景 | 结果 |
340
- | --------------------------- | ---------------------------------------------------------------------------------------------- |
341
- | Kimi 摘要续写 | 摘要请求读缓存 20.2k / 20.5k,**命中 98.8%**(修复前 0%:发 `tool_choice` 时前缀在工具段断开) |
342
- | DeepSeek 按 2048 粒度报缓存 | 假未命中 3 次 → **0 次**(自动推断端点缓存粒度) |
343
- | 基线命中率(5 轮编码任务) | Kimi 累计 86%、MiniMax 75%,均 0 次未命中 |
367
+ | Scenario | Result |
368
+ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
369
+ | Kimi summary continuation | The summary request read 20.2k / 20.5k from cache, **98.8% hit** (0% before the fix: sending `tool_choice` broke the prefix at the tools section) |
370
+ | DeepSeek reporting cache in 2048 units | False misses 3 → **0** (cache granularity inferred per endpoint) |
371
+ | Baseline hit rate (5-turn coding task) | Kimi 86% cumulative, MiniMax 75%, 0 misses each |
344
372
 
345
- 缓存相关的全部配置与各协议字段见 [docs/providers.md](docs/providers.md)「缓存」。
373
+ All cache settings and the fields for each protocol are in [docs/en/providers.md](docs/en/providers.md) "Caching".
346
374
 
347
- ## 安全
375
+ ## Safety
348
376
 
349
- **权限模式**(`--permission-mode`、配置 `permission.mode`、`/permission` 选择器、交互模式 `Shift+Tab` 循环):
377
+ **Permission modes** (`--permission-mode`, config `permission.mode`, the `/permission` picker, and in interactive mode `Shift+Tab`, or `Tab` on an empty input, to cycle):
350
378
 
351
- | 模式 | 显示名 | 读 | 写 | 执行(bash 等) |
352
- | ----------- | ------------------ | --- | ------------------------------------------------------ | ------------------------------ |
353
- | `default` | Manual | ✓ | 询问 | 询问 |
354
- | `auto-edit` | Accept edits | ✓ | ✓ | 询问 |
355
- | `plan` | Plan | ✓ | 拒绝 | 拒绝 |
356
- | `auto` | Auto | ✓ | ✓ ¹ | 安全的自动放行,有风险的才问 ² |
357
- | `full-auto` | Bypass permissions | ✓ | ✓ | ✓ |
358
- | `allowlist` | Allowlist only | ✓ | 只放行 allow 规则命中的,其余拒绝,从不询问(适合 CI) | 同左 |
379
+ | Mode | Display name | Read | Write | Execute (bash etc.) |
380
+ | ----------- | ------------------ | ---- | --------------------------------------------------------------------------------------- | ----------------------------------- |
381
+ | `default` | Manual | ✓ | ask | ask |
382
+ | `auto-edit` | Accept edits | ✓ | ✓ | ask |
383
+ | `plan` | Plan | ✓ | deny | deny |
384
+ | `auto` | Auto | ✓ | ✓ ¹ | safe ones allowed, risky ones ask ² |
385
+ | `full-auto` | Bypass permissions | ✓ | ✓ | ✓ |
386
+ | `allowlist` | Allowlist only | ✓ | only calls matching allow rules pass, everything else is denied without asking (for CI) | same |
359
387
 
360
- ¹ 机密文件(`.env`、私钥、`.ssh/` 等)、`.git/` 与 `.ama/`、项目目录外的写入仍然询问。
361
- ² 三层判定:规则层(危险命令、网络、删除类、受保护路径 → 询问)→ 静态判定(安全名单:`ls`、`cat`、`grep`、`git status/diff/log`、`npm test`、`tsc --noEmit`、`cargo test` 等 → 放行)→ 都没决定时问一次模型分类器(独立请求,不影响主会话缓存;`permission.autoModel` 可指定便宜模型)。详见 [docs/permissions.md](docs/permissions.md)。
388
+ ¹ Secret files (`.env`, private keys, `.ssh/` …), `.git/` and `.ama/`, and writes outside the project directory still ask.
389
+ ² Three tiers: the rule tier (dangerous commands, network, deletion, protected paths → ask) → static judgement (a safe list: `ls`, `cat`, `grep`, `git status/diff/log`, `npm test`, `tsc --noEmit`, `cargo test` … → allow) → when neither decides, one question to a model classifier (a separate request that leaves the main session cache untouched; `permission.autoModel` can name a cheap model). Details in [docs/en/permissions.md](docs/en/permissions.md).
362
390
 
363
- **判定顺序**:deny 规则(含 Hook deny)→ 危险命令 →(auto 的规则层)→ 模式 / 静态判定 → allow 规则把「询问」变「允许」→(auto 的分类器)。前面的结论后面不能放宽。无人值守(`-p`、RPC 未接审批)时「询问」一律按拒绝。项目级配置只能收紧模式,且不能设 `auto` / `full-auto`。
391
+ **Decision order**: deny rules (including hook deny) → dangerous commands → (auto's rule tier) → mode / static judgement → allow rules turn "ask" into "allow" → (auto's classifier). A later step can never loosen an earlier decision. When unattended (`-p`, RPC without approvals) "ask" always means deny. Project config can only make the mode stricter and cannot set `auto` / `full-auto`.
364
392
 
365
- - **规则**:`bash(git push*)`、`write(src/**)`、`read(**)`、`canvas_*`;`--allow` / `--deny` 可重复。内置 deny:写 `.git/**`、读写 `.ssh/**`。
366
- - **危险命令**:`rm -rf /`、`sudo`、`git push --force`、`git reset --hard`、`git clean -f`、`curl … | sh`、`chmod -R 777`、`npm publish`、`shutdown` 等,即使有 allow 规则也要询问。识别会穿透 `sh -c '…'`、`eval`、`xargs`、`find -exec` 与 git 全局选项。
367
- - **bash 沙箱**(缺省关闭):见下文「沙箱」。
368
- - **项目信任**:`.ama/hooks.json`、`.ama/skills/`、`.ama/prompts/` 会执行或注入项目里的内容,需要先信任目录(交互模式问一次,可记住;`--trust` / `--no-trust`;非交互缺省不信任)。`AGENTS.md` 与 `.ama/config.json` 不需要信任,因为后者只能收紧。
369
- - **执行前预览**:审批对话框除了输入摘要,还列出这一步会碰到什么——bash 里 `rm` / `mv` / `git clean` / `git reset --hard` / 重定向的目标路径是否存在、大小、目录里有多少文件;write 显示路径与行数,edit 显示每处修改的 −/+ 摘要。`y` 允许、`n` 拒绝、`a` 本会话同类不再问、`v` 看完整输入。
370
- - **Hook**:`hooks.json` 在 `PreToolUse`、`PostToolUse`、`UserPromptSubmit`、`Stop`、`PostCompact`、`PostRewind` 等 11 个事件运行 shell 命令,可以否决工具调用、改写输入、追加上下文、让运行再跑一轮。见 [docs/hooks.md](docs/hooks.md)。
371
- - **审批来源**:子 Agent 与外部 Agent 发起的审批在对话框标题标出来源(`[task:explore]`、`[claude · 会话 abc12345]`、「首次运行外部 Agent」),见 [docs/permissions.md](docs/permissions.md)「审批对话框的来源标注」。
393
+ - **Rules**: `bash(git push*)`, `write(src/**)`, `read(**)`, `canvas_*`; `--allow` / `--deny` are repeatable. Built-in deny: writes to `.git/**`, reads and writes to `.ssh/**`.
394
+ - **Dangerous commands**: `rm -rf /`, `sudo`, `git push --force`, `git reset --hard`, `git clean -f`, `curl … | sh`, `chmod -R 777`, `npm publish`, `shutdown` and so on ask even with an allow rule. Detection sees through `sh -c '…'`, `eval`, `xargs`, `find -exec` and git global options.
395
+ - **bash sandbox** (off by default): see "Sandbox" below.
396
+ - **Project trust**: `.ama/hooks.json`, `.ama/skills/` and `.ama/prompts/` execute or inject content from the project, so the directory must be trusted first (asked once in interactive mode, can be remembered; `--trust` / `--no-trust`; untrusted by default when non-interactive). `AGENTS.md` and `.ama/config.json` need no trust, since the latter can only tighten.
397
+ - **Pre-execution preview**: besides an input summary, the approval dialog lists what the step will touch: for `rm` / `mv` / `git clean` / `git reset --hard` / redirections in bash, whether the target paths exist, their size and how many files a directory holds; for write, the path and line count; for edit, a −/+ summary per change. `y` allows, `n` denies, `a` stops asking for the same kind this session, `v` shows the full input.
398
+ - **Hooks**: `hooks.json` runs shell commands on 11 events such as `PreToolUse`, `PostToolUse`, `UserPromptSubmit`, `Stop`, `PostCompact` and `PostRewind`; hooks can veto tool calls, rewrite input, add context or make the run go another round. See [docs/hooks.md](docs/hooks.md) (Chinese).
399
+ - **Approval origin**: approvals raised by sub-agents and external agents show their origin in the dialog title (`[task:explore]`, `[claude · session abc12345]`, "first run of an external agent"); see [docs/en/permissions.md](docs/en/permissions.md) "Origin labels in the approval dialog".
372
400
 
373
- ## 沙箱
401
+ ## Sandbox
374
402
 
375
- macOS 用 `sandbox-exec`,Linux 用 bubblewrap(退而 `unshare -r -n`,只隔离网络),启动时用目标配置跑一次最小探针确认真能用(嵌套沙箱、没有用户命名空间时降级),`ama doctor` 显示结果。Windows 没有操作系统沙箱。
403
+ macOS uses `sandbox-exec` and Linux uses bubblewrap (falling back to `unshare -r -n`, which isolates the network only). At startup a minimal probe runs with the target profile to confirm it really works (degrading for nested sandboxes or missing user namespaces), and `ama doctor` shows the result. Windows has no OS sandbox.
376
404
 
377
- - **codemode**:子进程经沙箱启动,内核拒绝网络与一切写入;有沙箱时 Node 22 / 24 与 Node ≥ 25 一样按只读类处理、`default` 预设缺省开启(见上文「Node 版本、codemode 与沙箱」)。
378
- - **bash**(缺省关闭):`"sandbox": { "bash": "auto" }` 后 bash(含后台 bash)在沙箱里跑——只能写工作区、系统临时目录与 `sandbox.writable` 追加的目录,工作区的 `.ama/`、`.git/hooks`、`.git/config` 只读,读不到 `~/.ssh` 等凭据,缺省不能联网(`sandbox.network: "allow"` 放开)。`default` / `auto-edit` 下沙箱内的命令免审批(危险命令、deny 规则、Hook ask 照旧);被沙箱拒绝时模型可以请求 `sandbox: false` 不经沙箱重跑,这一步照常审批、无人值守拒绝。状态栏多一个 `沙箱` 标记。
379
- - `sandbox.*` 只认用户级 / profile,项目级只能写收紧的 `network: "deny"`;`sandbox.enabled: "off"` 或 `AMA_SANDBOX=off` 整体关闭。
405
+ - **codemode**: the child process starts inside the sandbox and the kernel denies network and all writes; with a sandbox, Node 22 / 24 behaves like Node ≥ 25: read-only class and enabled by default in the `default` preset (see "Node version, codemode and sandbox" above).
406
+ - **bash** (off by default): with `"sandbox": { "bash": "auto" }`, bash (including background bash) runs in the sandbox. It can only write the workspace, the system temp directory and directories added via `sandbox.writable`; the workspace's `.ama/`, `.git/hooks` and `.git/config` are read-only; credentials such as `~/.ssh` cannot be read; and there is no network by default (`sandbox.network: "allow"` opens it). In `default` / `auto-edit`, sandboxed commands need no approval (dangerous commands, deny rules and hook asks still apply); when the sandbox blocks something the model may ask to rerun with `sandbox: false` outside it, which is approved as usual and denied when unattended. The status bar shows an extra sandbox marker.
407
+ - `sandbox.*` is user level / profile only; the project level can only write the tightening `network: "deny"`. `sandbox.enabled: "off"` or `AMA_SANDBOX=off` turns it all off.
380
408
 
381
- 细节、各平台策略与已知绕过见 [docs/sandbox.md](docs/sandbox.md)。
409
+ Details, per-platform policies and known bypasses are in [docs/sandbox.md](docs/sandbox.md) (Chinese).
382
410
 
383
411
  ## Plan
384
412
 
385
- Plan 模式(`Shift+Tab`、`/permission plan`、`/plan <目标>`、`--permission-mode plan`)下模型只读调研——只放行读工具、只读命令(`ls`、`rg`、`git log / diff` 等)与只读子 Agent——最后输出 `<proposed_plan>` 计划块。ama 提取步骤、把计划落到 `<数据目录>/plans/`,弹出审批框:
413
+ In Plan mode (`Shift+Tab`, `/permission plan`, `/plan <goal>`, `--permission-mode plan`) the model researches read-only: only read tools, read-only commands (`ls`, `rg`, `git log / diff` …) and read-only sub-agents are allowed. It ends with a `<proposed_plan>` block. ama extracts the steps, saves the plan under `<data dir>/plans/` and opens an approval dialog:
414
+
415
+ - **Approve and execute** / **Approve, execute in a fresh context** (a new session that opens with the full plan), then pick the execution mode (back to the previous mode / Accept edits / Auto); steps become todos and are worked through one by one (with `todo update` when the todo tool exists, otherwise the model writes a `[DONE:S1]` line per finished step);
416
+ - **Keep revising** (feedback goes to the model to rewrite the plan) / **Discard and leave Plan**; `e` edits the plan in an external editor, Esc discards but stays in Plan.
417
+
418
+ Line mode uses `/plan approve [mode|fresh]` / `/plan reject`; RPC clients approve after declaring the `plans` capability; the SDK uses `createAgentSession({ plan: { onProposed } })`. **ama never approves on a person's behalf**: `-p` stops at "plan awaiting approval" and exits with 9 by default; only the user-level config `"plan": { "unattended": "approve" }` approves and executes automatically when unattended. `plan.model` lets planning and execution use different models. See [docs/plan.md](docs/plan.md) (Chinese).
419
+
420
+ ## Sub-agents
386
421
 
387
- - **批准并执行** / **批准,在新上下文执行**(新建会话,以计划全文开场),接着选执行模式(回到进入前的模式 / Accept edits / Auto);步骤变成待办,逐步推进(有 todo 工具时用 `todo update`,没有时模型每完成一步写一行 `[DONE:S1]`);
388
- - **继续修改**(意见发给模型重写计划)/ **放弃并退出 Plan**;`e` 在外部编辑器里改计划,Esc 放弃但留在 Plan。
422
+ The `task` tool hands a sub-task to a sub-agent with a fresh context (same process, its own session file, depth 1); the result returns to the parent session as a tool result. Under the `default` preset `task` is only available inside codemode scripts; expose it directly with `--tools …,task` or `tools.default: ["+task"]`.
389
423
 
390
- line 模式用 `/plan approve [模式|fresh]` / `/plan reject`;RPC 声明 `plans` 能力后由客户端审批;SDK 用 `createAgentSession({ plan: { onProposed } })`。**ama 不替人批准**:`-p` 缺省停在「计划待审批」并退出 9,用户级配置 `"plan": { "unattended": "approve" }` 才在无人值守时自动批准执行。`plan.model` 可让规划与执行用不同模型。见 [docs/plan.md](docs/plan.md)。
424
+ - Built-in types `general` (default), `explore` and `plan` (the last two are forced read-only and never prompt for approval); define your own types (tool allowlist, model, permissions, turns, worktree isolation) in `~/.config/ama/agents/*.md`, `.ama/agents/*.md` (requires trust) or `--agent-dir`.
425
+ - Several tasks in one reply run in parallel (`subagents.maxConcurrent`, default 4); `background: true` returns a `taskId` immediately and the parent session receives a `<task-notification>` when done; `task{taskId}` continues the conversation; `task_ctl` lists / waits / stops / reads output; `isolation: "worktree"` runs in a separate git worktree.
426
+ - The sub-session's tool table is byte-identical to the parent's, so its first request reuses the parent's cache prefix. In the interface the task tool line folds and shows progress; `/agents` lists the available types.
427
+ - **Agent bar and sub-agent view**: running tasks are listed above the status line; with an empty input press `Ctrl+B` (or `↓`, e.g. in tmux) to focus the bar, ↑↓ to pick and Enter to open a full-screen live view of that sub-agent, where your input goes straight to it (Esc goes back without interrupting). `/tasks` focuses the bar, `/tasks <id>` opens a view, `/tasks stop <id>` stops a task. See [docs/en/tui.md](docs/en/tui.md) "Agent bar".
391
428
 
392
- ## 子 Agent
429
+ See [docs/agents.md](docs/agents.md) (Chinese) "Sub-agents".
393
430
 
394
- `task` 工具把子任务交给一个全新上下文的子 Agent(同进程、独立会话文件,深度 1),结果作为工具结果回到父会话。`default` 预设下 `task` 只在 codemode 脚本里可用,直接暴露用 `--tools …,task` 或 `tools.default: ["+task"]`。
431
+ ## External agents
395
432
 
396
- - 内置类型 `general`(缺省)、`explore`、`plan`(后两者强制只读、不弹审批);`~/.config/ama/agents/*.md`、`.ama/agents/*.md`(需信任)或 `--agent-dir` 定义自己的类型(工具白名单、模型、权限、轮数、worktree 隔离)。
397
- - 同一回复里的多个 task 并行(`subagents.maxConcurrent`,缺省 4);`background: true` 立即返回 `taskId`,完成后父会话收到 `<task-notification>`;`task{taskId}` 续聊;`task_ctl` 列出 / 等待 / 停止 / 读输出;`isolation: "worktree"` 在独立 git worktree 里跑。
398
- - 子会话工具表与父逐字节相同,首个请求复用父的缓存前缀。界面里 task 工具行折叠显示进度,`/tasks` 看输出或停止,`/agents` 列出可用类型。
433
+ `task(agent="claude")`, `"codex"` or `"acp:<program>"` (any ACP agent: Gemini CLI, OpenCode, Kimi, ama itself …) drives an external coding agent with your **existing login** in that CLI. Foreground / background / follow-up / `task_ctl` work as with ama's own sub-agents, and results are treated as reference material.
399
434
 
400
- 见 [docs/agents.md](docs/agents.md)「子 Agent」。
435
+ - **Approvals go to a human only**: operations the external agent wants confirmed go to the interface / host; neither the auto classifier nor the model takes part, and unattended runs always deny. The first run of a given external agent in each session is confirmed once (the allow rule `task(claude)` or `full-auto` lets it through).
436
+ - An external agent's mode is never wider than ama's current mode (read-only under plan / allowlist). By default the child process is stripped of provider keys, `*_BASE_URL` and `AMA_*`, so subscriptions are never switched to API billing; it only starts in trusted directories; there is a concurrency pool, a USD budget and a watchdog.
437
+ - When embedded in a host, ama does not start external CLIs itself; it only uses runners injected by the host through `HostApi.runners`.
438
+ - **ama as an ACP agent**: `ama --mode acp` can be driven by Zed, JetBrains and Armadra's ACP nodes; `@armadra/agent/acp` exports a client, a driver and a fake agent.
401
439
 
402
- ## 外部 Agent
440
+ See [docs/agents.md](docs/agents.md) "External agents" and [docs/acp.md](docs/acp.md) (both Chinese).
403
441
 
404
- `task(agent="claude")`、`"codex"` 或 `"acp:<程序>"`(Gemini CLI、OpenCode、Kimi、ama 自己等任意 ACP Agent)用你在该 CLI 里的**现有登录**驱动外部编码 Agent,前台 / 后台 / 续聊 / `task_ctl` 与 ama 子 Agent 一致;结果按资料处理。
442
+ ## Rewind
405
443
 
406
- - **审批只交给人**:外部 Agent 要确认的操作走界面 / 宿主,auto 分类器与模型都不参与;无人值守一律拒绝。每个会话首次以某个外部 Agent 运行时确认一次(allow 规则 `task(claude)` 或 `full-auto` 放行)。
407
- - 外部 Agent 的模式不比 ama 当前模式宽(plan / allowlist 下只读);子进程缺省剥离供应商 key、`*_BASE_URL`、`AMA_*`,不把订阅切成 API 计费;只在已信任目录里启动;有并发池、美元预算与看门狗。
408
- - 嵌入宿主时 ama 不自己启动外部 CLI,只用宿主经 `HostApi.runners` 注入的 runner。
409
- - **ama 作为 ACP Agent**:`ama --mode acp` 供 Zed、JetBrains、Armadra 的 ACP 节点驱动;`@armadra/agent/acp` 导出客户端、驱动与假 Agent。
444
+ Every user message that starts a new turn is a rewind point: edit / write back up a file before writing it the first time, and each new turn re-snapshots tracked files (with `checkpoints.mode: "shadow-git"` the whole working directory goes into a shadow repository, so bash changes can be rolled back too).
410
445
 
411
- 见 [docs/agents.md](docs/agents.md)「外部 Agent」与 [docs/acp.md](docs/acp.md)。
446
+ - `/rewind`, or double Esc while idle, opens the list; the confirmation panel offers: restore code and conversation / restore conversation / restore code / summarize from here / summarize up to here, each with a preview. Files changed by hand outside the turn are listed as conflicts and skipped by default, with an option to overwrite; if git HEAD moved, ama only suggests commands and never touches git.
447
+ - When Esc interrupts a run before this turn produced any output, the message is withdrawn and put back into the input box (`ui.restoreOnCancel`).
448
+ - Line mode `/rewind <n> [both|conversation|code] [overwrite]`; RPC `get_rewind_points` / `rewind`; SDK `session.rewind()`; hook `PostRewind`.
412
449
 
413
- ## 回滚
450
+ See [docs/en/tui.md](docs/en/tui.md) "Rewind", [docs/rewind-plan.md](docs/rewind-plan.md) (Chinese) and [docs/en/sessions.md](docs/en/sessions.md).
414
451
 
415
- 每条开启新回合的用户消息都是回滚点:edit / write 第一次写文件前备份,每个新回合重拍已跟踪文件(`checkpoints.mode: "shadow-git"` 时整个工作目录进影子仓库,bash 的改动也能回滚)。
452
+ ## Memory
416
453
 
417
- - `/rewind` 或空闲时双击 Esc 打开列表,确认面板给出:恢复代码和对话 / 恢复对话 / 恢复代码 / 从这里摘要 / 摘要到这里,每项带预览;回合外被手动改过的文件按冲突列出、缺省跳过,可选择覆盖;git HEAD 变了只提示命令,不动 git。
418
- - 运行中 Esc 中断且本回合还没有输出时自动撤回这条消息并回填(`ui.restoreOnCancel`)。
419
- - line 模式 `/rewind <n> [both|conversation|code] [overwrite]`;RPC `get_rewind_points` / `rewind`;SDK `session.rewind()`;Hook `PostRewind`。
454
+ Cross-session personal notes, **off by default**. Turn it on with `ama memory enable` (or `--memory` / `AMA_MEMORY=1` for one launch); then saying "remember …" lets the model write a Markdown entry with the `memory` tool. Entries live under `<data dir>/memory/` in a user scope and a per-project scope (trusted projects only); an index goes into the system prompt at session start and bodies are read on demand. Writes ask in `default` mode, content that looks like a credential is refused, and sub-agents are read-only. Manage entries with `/memory` or `ama memory list | show | edit | rm | path | enable | disable`. When disabled, requests are byte-for-byte unchanged. See [docs/memory.md](docs/memory.md) (Chinese).
455
+
456
+ ## Traces
457
+
458
+ Every model request records timing (time to first token, decode, tools, retries, compaction) in the session file, without content. `/trace` opens a tree of turns → requests → tools → sub-agents with timing bars, tokens and cache hits; `/trace <task id>` shows one task. To share or inspect outside the terminal:
459
+
460
+ ```sh
461
+ ama sessions trace 3f9a1c2e --html trace.html # self-contained single file, redacted, no external loads
462
+ ama sessions trace 3f9a1c2e --json # same shape as RPC get_trace
463
+ ```
420
464
 
421
- 见 [docs/tui.md](docs/tui.md)「回滚」、[docs/rewind-plan.md](docs/rewind-plan.md) 与 [docs/sessions.md](docs/sessions.md)。
465
+ RPC clients use `get_trace` (tail-first paging, increments after `entry_appended`) and the SDK `session.trace()`. See [docs/en/tui.md](docs/en/tui.md) "Traces", [docs/en/sessions.md](docs/en/sessions.md) and [docs/en/rpc.md](docs/en/rpc.md).
422
466
 
423
- ## 界面与入口
467
+ ## Interfaces and entry points
424
468
 
425
- ### 终端界面
469
+ ### Terminal UI
426
470
 
427
- 直接运行 `ama`(stdin / stdout 都是 TTY)进入交互模式。界面只用主屏,对话历史留在终端回滚里,tmux `capture-pane` 能读到完整对话。
471
+ Running `ama` (with stdin / stdout both TTYs) enters interactive mode. The interface uses the main screen only; the conversation history stays in the terminal scrollback, so tmux `capture-pane` can read the whole conversation.
428
472
 
429
- | 按键 | 作用 |
430
- | -------------------- | -------------------------------------------------------------- |
431
- | Enter | 发送;运行中插话(steer) |
432
- | Alt+Enter | 运行中排到本轮之后(followUp) |
433
- | Shift+Enter / Ctrl+J | 换行 |
434
- | Esc | 中断当前运行 |
435
- | Esc Esc(空闲) | 输入框为空:打开回滚列表(同 `/rewind`);有字:清空并存进历史 |
436
- | Shift+Tab | 循环权限模式 |
437
- | Ctrl+O | 展开 / 折叠工具输出 |
438
- | Ctrl+L / Ctrl+T | 选择模型 / 思考级别 |
439
- | Ctrl+G | 底部信息行 两行 ↔ 一行(同 `/statusline`) |
440
- | Ctrl+V | 粘贴剪贴板里的图片,插入 `@<路径>`(同 `/paste`) |
441
- | Ctrl+C | 清空输入;输入为空时 1.5 秒内再按一次退出 |
442
- | Tab | 补全:`/` 命令、模板与 Skill,`@` 文件路径 |
473
+ | Key | Effect |
474
+ | ------------------------ | --------------------------------------------------------------------------------------- |
475
+ | Enter | Send; while running, steer |
476
+ | Alt+Enter | While running, queue after this turn (followUp) |
477
+ | Shift+Enter / Ctrl+J | New line |
478
+ | Esc | Interrupt the current run |
479
+ | Esc Esc (idle) | Empty input: open the rewind list (same as `/rewind`); with text: clear it into history |
480
+ | Shift+Tab / Tab | Cycle permission modes (Tab only on an empty input; entering Bypass asks to confirm) |
481
+ | Ctrl+O | Expand / collapse tool output |
482
+ | Ctrl+L / Ctrl+T | Pick model / thinking level |
483
+ | Ctrl+G | Bottom info line, two lines ↔ one (same as `/statusline`) |
484
+ | Ctrl+V | Paste an image from the clipboard and insert `@<path>` (same as `/paste`) |
485
+ | Ctrl+B / ↓ (empty input) | Focus the agent bar when there are sub-agent tasks (↓ in tmux) |
486
+ | Ctrl+C | Clear the input; on an empty input, press again within 1.5 s to quit |
487
+ | Tab | Complete: `/` commands, templates and Skills, `@` file paths |
443
488
 
444
- 常用命令:`/model`、`/thinking`、`/permission`、`/tools`、`/compact`、`/tree`(回到某条消息之前重新分支)、`/fork`、`/resume`、`/new`、`/session`、`/cache`、`/hooks`、`/skill:<名字>`、`/help`;第五波新增 `/plan`(计划面板与审批,`/plan <目标>` 进入 Plan)、`/tasks`(子 Agent 任务)、`/agents`(可用类型与外部 Agent)、`/paste`(剪贴板图片)、`/rewind`(回滚)、`/statusline [full|compact]`。输入里的 `@图片路径`(或粘贴 / 拖入的图片路径)作为图片附件发给模型;`/model` 按「供应商 · 渠道」分组,标出上下文与 `img`。按键可在 `~/.config/ama/keybindings.json` 覆盖。见 [docs/tui.md](docs/tui.md)。
489
+ Common commands: `/model`, `/thinking`, `/permission`, `/tools`, `/compact`, `/tree` (branch again from before a message), `/fork`, `/resume`, `/new`, `/session`, `/cache`, `/hooks`, `/skill:<name>`, `/help`; wave 5 added `/plan` (plan panel and approval; `/plan <goal>` enters Plan), `/tasks` (sub-agent tasks), `/agents` (available types and external agents), `/paste` (clipboard image), `/rewind` and `/statusline [full|compact]`; wave 6 added `/config` (settings panel), `/trace` (trace), `/memory` (memories), and `/tasks` now focuses the agent bar (`/tasks <id>` opens the sub-agent view). An `@image-path` in the input (or a pasted / dropped image path) is sent to the model as an image attachment; `/model` groups models by "provider · channel" and marks context size and `img`. Key bindings can be overridden in `~/.config/ama/keybindings.json`. See [docs/en/tui.md](docs/en/tui.md).
445
490
 
446
- `--no-tui`(或 stdin / stdout 不是 TTY、`TERM=dumb`)进入行式界面:readline + 括号粘贴,命令相同。
491
+ `--no-tui` (or when stdin / stdout is not a TTY, or `TERM=dumb`) enters line mode: readline with bracketed paste and the same commands.
447
492
 
448
- ### `-p` 一次性运行
493
+ ### One-shot `-p`
449
494
 
450
- | `--output-format` | stdout |
451
- | ----------------- | ----------------------------------------------------------------------------- |
452
- | `text`(缺省) | 最后一条回答的文本 |
453
- | `json` | 一个 `result` 对象:会话 id、模型、`stopReason`、`text`、用量、费用、缓存统计 |
454
- | `stream-json` | 每行一个事件,与 RPC 事件同形状 |
495
+ | `--output-format` | stdout |
496
+ | ----------------- | -------------------------------------------------------------------------------------- |
497
+ | `text` (default) | The text of the final answer |
498
+ | `json` | One `result` object: session id, model, `stopReason`, `text`, usage, cost, cache stats |
499
+ | `stream-json` | One event per line, same shapes as RPC events |
455
500
 
456
- **stdin**:管道内容拼在提示后面(`git diff | ama -p "审阅"`);没有提示参数时管道内容就是提示。有提示参数时只等管道的
457
- 首字节 2 秒(`AMA_STDIN_WAIT_MS` 可调,0 = 不等):一个字节都没收到就忽略 stdin、继续运行,并在 stderr 提示一行——父进程
458
- 留着不关的管道不会让 `-p` 挂起;收到首字节后读到 EOF。上游命令要先跑很久才输出时,在末尾加 `-` 一直等到 EOF
459
- (`npm test 2>&1 | ama -p "找出失败原因" -`);`--no-stdin` 完全不读。`< 文件` 重定向总会读取。
501
+ **stdin**: piped content is appended after the prompt (`git diff | ama -p "review"`); without a prompt argument the piped content is the prompt. With a prompt argument ama waits only 2 seconds for the pipe's first byte (`AMA_STDIN_WAIT_MS` adjusts it, 0 = don't wait): if not a single byte arrives, stdin is ignored, the run continues and stderr gets one line, so a pipe a parent process leaves open never hangs `-p`; once the first byte arrives it reads to EOF. When the upstream command runs a long time before printing, add a trailing `-` to wait for EOF (`npm test 2>&1 | ama -p "find why it fails" -`); `--no-stdin` never reads. A `< file` redirect is always read.
460
502
 
461
- `--image <文件>` 可重复,随提示发送图片(PNG / JPEG / GIF / WebP,单张上限按端点分档、base64 后计:官方 Anthropic 10 MB、Gemini / OpenAI 20 MB、中转 5 MB,超限时尝试用 sips / ImageMagick 缩放);提示里的 `@图片路径` 同样作为附件。当前
462
- 模型不收图片时直接退出 2,不发请求。
503
+ `--image <file>` is repeatable and sends images with the prompt (PNG / JPEG / GIF / WebP; the per-image limit is tiered by endpoint and measured after base64: official Anthropic 10 MB, Gemini / OpenAI 20 MB, relays 5 MB; oversized images are resized with sips / ImageMagick when possible); `@image-path` in the prompt is attached too. When the current model does not accept images, ama exits with 2 without sending a request.
463
504
 
464
- `--max-turns N` 限制一次运行最多 N 轮(一次模型请求加它的工具执行算一轮),`--max-cost USD` 限制一次运行的美元用量(配置
465
- `limits.maxTurns / maxCostUsd` 同义),到上限时提前结束(事件 `limit_reached`),**退出码 8**(0.4.x 的 `--max-turns` 是 1),
466
- `json` 结果带 `limitReached{kind, value, limit}`(轮数到限另有 `maxTurnsReached: true`)。Plan 模式下计划待审批时退出 9(见上文「Plan」)。
505
+ `--max-turns N` caps a run at N turns (one model request plus its tool executions is one turn), and `--max-cost USD` caps a run's USD spend (config `limits.maxTurns / maxCostUsd` mean the same). When a limit is reached the run ends early (event `limit_reached`) with **exit code 8** (`--max-turns` exited with 1 in 0.4.x), and the `json` result carries `limitReached{kind, value, limit}` (plus `maxTurnsReached: true` for the turn limit). In Plan mode a plan awaiting approval exits with 9 (see "Plan" above).
467
506
 
468
- `--system-prompt <文本|@文件>` 补充系统提示(任何模式都可用):缺省作为最后一条规则追加,preamble 与工具表这段最长的
469
- 缓存前缀不变;`--system-prompt-mode replace` 改为替换开头的角色说明,工具表、规则与 AGENTS.md 仍然保留。
507
+ `--system-prompt <text|@file>` adds to the system prompt (in every mode): by default it is appended as the last rule, keeping the preamble and tool table, the longest cache prefix, unchanged; `--system-prompt-mode replace` replaces the opening role description instead, while the tool table, rules and AGENTS.md stay.
470
508
 
471
- `--no-session` 让会话只留在内存里、不写会话文件(适合 CI 与一次性调用;之后无法 `--resume`),交互模式里 `/new` 切出的
472
- 新会话同样不落盘。
509
+ `--no-session` keeps the session in memory only and writes no session file (for CI and one-off calls; `--resume` is impossible afterwards); new sessions started with `/new` in interactive mode are not saved either.
473
510
 
474
- **无人值守**:`-p` 没有人审批,缺省权限模式下需要询问的调用(写文件、跑命令)一律拒绝。被拒时 stderr 一行汇总被拒的
475
- 工具与原因,`json` 结果带 `deniedTools`,`stream-json` 的 `tool_execution_end` 带 `denied: true`,退出码 7。需要放行时用
476
- `--permission-mode auto-edit`(放行写入)/ `auto`(ama 判断每一步),或 `--allow "bash(npm test*)"` 按规则放行。
511
+ **Unattended**: `-p` has nobody to approve, so calls that would ask under the default permission mode (writing files, running commands) are always denied. When something is denied, stderr summarizes the denied tools and reasons in one line, the `json` result carries `deniedTools`, `stream-json`'s `tool_execution_end` carries `denied: true`, and the exit code is 7. To allow them use `--permission-mode auto-edit` (allows writes) / `auto` (ama judges each step), or allow by rule with `--allow "bash(npm test*)"`.
477
512
 
478
- | 退出码 | 含义 |
479
- | ------ | ------------------------------------------------------------ |
480
- | 0 | 正常 |
481
- | 1 | 运行期错误(模型最终失败等) |
482
- | 2 | 用法错误;当前模型不收图片 |
483
- | 3 | 配置 / profile / 路径错误 |
484
- | 4 | 无可用模型或 key |
485
- | 5 | 会话不存在 / 损坏 |
486
- | 6 | 宿主 / Hook 启动失败 |
487
- | 7 | `-p` 有工具调用被拒(无人审批、deny 规则、plan 等) |
488
- | 8 | `-p` 到达预算上限(`--max-turns` / `--max-cost` / `limits`) |
489
- | 9 | `-p` 产出的计划已落盘、待审批(`plan.unattended: stop`) |
490
- | 78 | 宿主 API 版本不匹配 |
491
- | 130 | SIGINT;143 = SIGTERM |
513
+ | Exit code | Meaning |
514
+ | --------- | --------------------------------------------------------------------------------- |
515
+ | 0 | Success |
516
+ | 1 | Runtime error (the model ultimately failed, etc.) |
517
+ | 2 | Usage error; the current model does not accept images |
518
+ | 3 | Config / profile / path error; `ama config set` rejected a key or value |
519
+ | 4 | No usable model or key |
520
+ | 5 | Session missing / corrupted |
521
+ | 6 | Host / hook startup failure |
522
+ | 7 | `-p` had tool calls denied (no approver, deny rules, plan, …) |
523
+ | 8 | `-p` reached a budget limit (`--max-turns` / `--max-cost` / `limits`) |
524
+ | 9 | `-p` produced a plan that was saved and awaits approval (`plan.unattended: stop`) |
525
+ | 78 | Host API version mismatch |
526
+ | 130 | SIGINT; 143 = SIGTERM |
492
527
 
493
- ### 会话统计、检索与复用
528
+ ### Session stats, search and reuse
494
529
 
495
- 会话是 `<数据目录>/sessions` 下的 JSONL,下面这些命令只读不写(缺省看当前目录的会话,`--all` 看全部):
530
+ Sessions are JSONL files under `<data dir>/sessions`. These commands only read (by default they look at sessions of the current directory; `--all` looks at all):
496
531
 
497
532
  ```sh
498
- ama stats --since 7d --by model # 请求、token、缓存命中率、费用、工具调用 Top N(--json 可用)
499
- ama sessions search "parser" --role user # 跨会话全文检索,/正则/ 也行
500
- ama sessions show 3f9a1c2e # 末尾列出用户消息编号
501
- ama -p --from 3f9a1c2e#2 --model packy/kimi-k2.5 # 用那条消息(含图片)换个模型再问
502
- ama sessions export 3f9a1c2e --format md --output s.md # md / json / jsonl,导出前脱敏
533
+ ama stats --since 7d --by model # requests, tokens, cache hit rate, cost, top N tool calls (--json available)
534
+ ama sessions search "parser" --role user # full-text search across sessions; /regex/ works too
535
+ ama sessions show 3f9a1c2e # lists user message numbers at the end
536
+ ama -p --from 3f9a1c2e#2 --model packy/kimi-k2.5 # ask that message (images included) again with another model
537
+ ama sessions export 3f9a1c2e --format md --output s.md # md / json / jsonl, redacted before export
538
+ ama sessions trace 3f9a1c2e --html t.html # trace as a single HTML file (see "Traces")
503
539
  ```
504
540
 
505
- 统计口径(命中率只算报告缓存的端点、费用只加有价请求等)与导出格式见 [docs/sessions.md](docs/sessions.md)。
541
+ How the numbers are computed (hit rate only over endpoints that report cache usage, cost only over priced requests, …) and the export formats are in [docs/en/sessions.md](docs/en/sessions.md).
506
542
 
507
543
  ### RPC
508
544
 
509
- `ama --mode rpc` 在 stdin / stdout 上说 JSONL:先发 `hello` 与 `session_start`,之后收 `prompt`、`steer`、`abort`、`set_model`、`get_session_stats`、`fork` 等命令,推送流事件与审批请求。
545
+ `ama --mode rpc` speaks JSONL on stdin / stdout: it first sends `hello` and `session_start`, then accepts commands such as `prompt`, `steer`, `abort`, `set_model`, `get_session_stats` and `fork`, and pushes stream events and approval requests.
510
546
 
511
547
  ```sh
512
548
  printf '{"id":"1","type":"prompt","message":"hi"}\n' | ama --mode rpc --model fake/echo
513
549
  ```
514
550
 
515
- `hello.capabilities` 列出服务端能力(`approvals`、`images`、`hooks`、`plans`),客户端用 `set_client_capabilities` 声明要接管的审批与计划审批。第五波新增计划(`plan_response` / `get_plan` / `get_todos`)、任务(`get_tasks` / `get_agents`)、回滚(`get_rewind_points` / `rewind` / `summarize_*`)命令与 `subagent_*`、`plan_*`、`limit_reached`、`telemetry_tick` 等事件。协议见 [docs/rpc.md](docs/rpc.md),类型从 `@armadra/agent/rpc` 导入。
551
+ `hello.capabilities` lists server capabilities (`approvals`, `images`, `hooks`, `plans`); clients declare with `set_client_capabilities` which approvals and plan approvals they take over. Wave 5 added plan (`plan_response` / `get_plan` / `get_todos`), task (`get_tasks` / `get_agents`) and rewind (`get_rewind_points` / `rewind` / `summarize_*`) commands, plus events such as `subagent_*`, `plan_*`, `limit_reached` and `telemetry_tick`; wave 6 added `get_trace` and the `quota_update` event. Decide by `code`, never by the human-readable `error` text, which follows the interface language. The protocol is in [docs/en/rpc.md](docs/en/rpc.md); import the types from `@armadra/agent/rpc`.
516
552
 
517
- `ama --mode acp` 说 ACP(JSON-RPC over NDJSON),见 [docs/acp.md](docs/acp.md)。
553
+ `ama --mode acp` speaks ACP (JSON-RPC over NDJSON); see [docs/acp.md](docs/acp.md) (Chinese).
518
554
 
519
555
  ### SDK
520
556
 
@@ -527,7 +563,7 @@ import { createAgentSession } from "@armadra/agent";
527
563
 
528
564
  const session = await createAgentSession({
529
565
  cwd: process.cwd(),
530
- model: "anthropic/<model-id>", // 试跑可用 "fake/echo"
566
+ model: "anthropic/<model-id>", // "fake/echo" for a dry run
531
567
  auth: { kind: "env" },
532
568
  permission: {
533
569
  mode: "default",
@@ -537,103 +573,111 @@ const session = await createAgentSession({
537
573
  session.subscribe((event) => {
538
574
  if (event.type === "tool_execution_start") console.error(`→ ${event.toolName}`);
539
575
  });
540
- await session.prompt("列出 src 下的入口文件");
576
+ await session.prompt("list the entry files under src");
541
577
  console.log(session.getLastAssistantText());
542
578
  console.log(session.getStats().cache?.hitRate);
543
579
  await session.dispose();
544
580
  ```
545
581
 
546
- - `createAgentSession` 不读文件系统配置:内存会话、指定工具、回调审批,适合嵌在别的程序里。
547
- - 回滚:`session.rewindPoints()` 列出活动路径上开启新回合的用户消息;`session.rewind({ entryId, mode: "both" | "conversation" | "code", dryRun?, onConflict? })` 回到该消息之前(返回原消息草稿与代码恢复结果,内存会话只能仅对话);`session.summarizeFrom(entryId, instructions?)` / `session.summarizeUpTo(entryId, instructions?)` 对应「从这里摘要」「摘要到这里」。设计见 [docs/rewind-plan.md](docs/rewind-plan.md)。
548
- - 计划:`createAgentSession({ plan: { onProposed } })` 在计划提出后回调审批(返回 `{ decision: "approve" | "approve_fresh" | "revise" | "reject", mode?, feedback? }`),或之后用 `session.plan.respond()`;`session.plan.current()` / `todos()` 读当前计划与待办。类型 `SessionPlanOptions`、`PlanDecision` 等从包入口导出,见 [docs/plan.md](docs/plan.md)「接口」。
549
- - `createRuntime({ argv })` 走与 `ama` 命令行相同的启动序列(读配置、AGENTS.md、Skill、hooks.json、auth.json)。
550
- - 子路径:`@armadra/agent/host`(宿主适配器类型)、`@armadra/agent/rpc`(RPC 类型)、`@armadra/agent/tui`(终端组件库)、`@armadra/agent/acp`(ACP 类型、客户端、驱动与假 Agent)、`@armadra/agent/bundle`(单文件 `ama.cjs`,`require.resolve` 可取路径交给 `node` 或 `ELECTRON_RUN_AS_NODE=1` 启动)。
551
-
552
- 完整示例见 [examples/sdk-demo.ts](https://github.com/Owlbay/armadra-agent/blob/main/examples/sdk-demo.ts)(自定义工具、流式输出、用量统计)。
553
-
554
- ## 嵌入 Armadra
555
-
556
- Armadra 以 `ama --profile <path>` 启动 ama。profile 是一个 JSON 文件,指定宿主适配器(`host`)、指令(`instructions`)、Skill 与提示模板目录、Hook 文件、key 文件(`authFile`,可配 `authEnv: false` 不读环境变量)、会话目录与 `trustProject`。
557
-
558
- 宿主适配器是一个本地 JS 模块,导出 `hostApi` 与 `create(api)`,经 `HostApi` 注册画布工具(`canvas_*` / `context_*`)、追加系统提示、接管审批、注入消息、显示状态。同一个 profile 在画布外运行时适配器不激活,ama 退化为普通独立模式。配合 `coordinator` 预设,协调者只读文件、调用画布工具,不自己改代码。
559
-
560
- - ama 一侧的接口:[docs/host-api.md](docs/host-api.md)
561
- - 协调者的设计与契约:Armadra 仓库 [docs/design/coordinator-agent.md](https://github.com/yovinchen/Armadra/blob/main/docs/design/coordinator-agent.md)
562
-
563
- ## 文档
564
-
565
- | 文档 | 内容 |
566
- | ----------------------------------------------------- | --------------------------------------------------------------------------------------- |
567
- | [docs/providers.md](docs/providers.md) | 内置供应商与渠道、API Key、自定义供应商与中转站、模型元数据快照、图像输入、compat、缓存 |
568
- | [docs/tui.md](docs/tui.md) | 终端界面:布局、状态栏、按键、命令、回滚、审批、Plan 审批、子 Agent、剪贴板图片、组件库 |
569
- | [docs/permissions.md](docs/permissions.md) | 权限模式、plan 只读命令、判定顺序、沙箱内免审批、auto 三层判定、审批来源标注 |
570
- | [docs/plan.md](docs/plan.md) | Plan 模式:流程、计划格式、审批、分模型、配置与持久化 |
571
- | [docs/agents.md](docs/agents.md) | 子 Agent(类型、定义文件、后台、续聊、worktree)与外部 Agent(驱动、权限、环境、预算) |
572
- | [docs/acp.md](docs/acp.md) | ACP:`ama --mode acp` 与 ama 作为 ACP 客户端 |
573
- | [docs/sandbox.md](docs/sandbox.md) | 操作系统沙箱:codemode 与 bash、各平台实现、配置与已知绕过 |
574
- | [docs/codemode.md](docs/codemode.md) | codemode 脚本、沙箱与权限 |
575
- | [docs/hooks.md](docs/hooks.md) | 命令式 Hook(hooks.json) |
576
- | [docs/host-api.md](docs/host-api.md) | 宿主适配器 API |
577
- | [docs/rpc.md](docs/rpc.md) | RPC 协议(stdio JSONL) |
578
- | [docs/session-format.md](docs/session-format.md) | 会话文件格式 |
579
- | [docs/sessions.md](docs/sessions.md) | 会话统计、检索、`--from` 复用、导出、检查点与影子 git |
580
- | [docs/rewind-plan.md](docs/rewind-plan.md) | 检查点与回滚的设计 |
581
- | [docs/tui-design.md](docs/tui-design.md) | 终端界面视觉规格与逐屏样稿 |
582
- | [docs/design.md][design] | 总体设计与决策记录(第五波增补指引在 §0 之后) |
583
- | [docs/extensions.md][extensions] | 本地扩展(设计草案,未实现) |
584
- | [docs/benchmarks/][benchmarks] | 预设基准、D20 todo 复测与缓存验收实验(报告与原始数据) |
585
- | [docs/wave5-plan.md][wave5] | 第五波设计:状态行、模型元数据、渠道、图像、外部 Agent、Plan、子 Agent、压缩与 harness |
586
- | [docs/implementation-plan.md][impl]、[wave3-plan][w3] | 早期实施计划(追溯用) |
587
- | [docs/research/][research] | 第五波调研报告(追溯用) |
588
-
589
- npm 包里带上表前十五份(用户文档);其余是设计与追溯材料,链接指向 GitHub。
582
+ - `createAgentSession` does not read file-system config: an in-memory session, explicit tools and callback approvals, suited for embedding in other programs.
583
+ - Rewind: `session.rewindPoints()` lists the user messages on the active path that start new turns; `session.rewind({ entryId, mode: "both" | "conversation" | "code", dryRun?, onConflict? })` returns to before that message (returning the original message as a draft and the code restore result; in-memory sessions support conversation only); `session.summarizeFrom(entryId, instructions?)` / `session.summarizeUpTo(entryId, instructions?)` correspond to "summarize from here" / "summarize up to here". Design in [docs/rewind-plan.md](docs/rewind-plan.md) (Chinese).
584
+ - Plans: `createAgentSession({ plan: { onProposed } })` calls back for approval once a plan is proposed (return `{ decision: "approve" | "approve_fresh" | "revise" | "reject", mode?, feedback? }`), or use `session.plan.respond()` later; `session.plan.current()` / `todos()` read the current plan and todos. Types such as `SessionPlanOptions` and `PlanDecision` are exported from the package entry; see [docs/plan.md](docs/plan.md) (Chinese) "Interfaces".
585
+ - `createRuntime({ argv })` runs the same startup sequence as the `ama` command line (config, AGENTS.md, Skills, hooks.json, auth.json).
586
+ - Subpaths: `@armadra/agent/host` (host adapter types), `@armadra/agent/rpc` (RPC types), `@armadra/agent/tui` (terminal component library), `@armadra/agent/acp` (ACP types, client, driver and fake agent), `@armadra/agent/bundle` (the single-file `ama.cjs`; `require.resolve` gives its path to start with `node` or `ELECTRON_RUN_AS_NODE=1`).
587
+
588
+ A complete example is [examples/sdk-demo.ts](https://github.com/Owlbay/armadra-agent/blob/main/examples/sdk-demo.ts) (custom tools, streaming output, usage stats).
589
+
590
+ ## Embedding in Armadra
591
+
592
+ Armadra starts ama with `ama --profile <path>`. The profile is a JSON file naming the host adapter (`host`), instructions (`instructions`), Skill and prompt template directories, the hook file, the key file (`authFile`; `authEnv: false` skips environment variables), the session directory and `trustProject`.
593
+
594
+ The host adapter is a local JS module exporting `hostApi` and `create(api)`; through `HostApi` it registers canvas tools (`canvas_*` / `context_*`), appends to the system prompt, takes over approvals, injects messages and shows status. When the same profile runs outside the canvas the adapter stays inactive and ama falls back to plain standalone mode. With the `coordinator` preset the coordinator only reads files and calls canvas tools, never changing code itself.
595
+
596
+ - ama's side of the interface: [docs/en/host-api.md](docs/en/host-api.md)
597
+ - Coordinator design and contract: [docs/design/coordinator-agent.md](https://github.com/yovinchen/Armadra/blob/main/docs/design/coordinator-agent.md) in the Armadra repository
598
+
599
+ ## Documentation
600
+
601
+ English versions exist for six user docs; the rest are in Chinese.
602
+
603
+ | Document | Contents |
604
+ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
605
+ | [docs/en/providers.md](docs/en/providers.md) ([中文](docs/providers.md)) | Built-in providers and channels, API keys, ChatGPT login, custom providers and relays, model metadata snapshot, image input, compat, caching |
606
+ | [docs/en/tui.md](docs/en/tui.md) ([中文](docs/tui.md)) | Terminal UI: layout, status bar, keys, commands, rewind, approvals, Plan approval, sub-agents and the agent bar, traces, memory, `/config`, component library |
607
+ | [docs/en/permissions.md](docs/en/permissions.md) ([中文](docs/permissions.md)) | Permission modes, read-only commands in plan, decision order, approval-free sandboxed commands, auto's three tiers, approval origin labels |
608
+ | [docs/en/host-api.md](docs/en/host-api.md) ([中文](docs/host-api.md)) | Host adapter API |
609
+ | [docs/en/rpc.md](docs/en/rpc.md) ([中文](docs/rpc.md)) | RPC protocol (stdio JSONL) |
610
+ | [docs/en/sessions.md](docs/en/sessions.md) ([中文](docs/sessions.md)) | Session stats, search, `--from` reuse, export, traces, checkpoints and shadow git |
611
+ | [docs/memory.md](docs/memory.md) | Memory: enabling, storage, the `memory` tool and permissions, system prompt and cache, commands (Chinese) |
612
+ | [docs/plan.md](docs/plan.md) | Plan mode: flow, plan format, approval, separate models, config and persistence (Chinese) |
613
+ | [docs/agents.md](docs/agents.md) | Sub-agents (types, definition files, background, follow-up, worktree) and external agents (drivers, permissions, environment, budget) (Chinese) |
614
+ | [docs/acp.md](docs/acp.md) | ACP: `ama --mode acp` and ama as an ACP client (Chinese) |
615
+ | [docs/sandbox.md](docs/sandbox.md) | OS sandbox: codemode and bash, per-platform implementation, config and known bypasses (Chinese) |
616
+ | [docs/codemode.md](docs/codemode.md) | codemode scripts, sandbox and permissions (Chinese) |
617
+ | [docs/hooks.md](docs/hooks.md) | Command hooks (hooks.json) (Chinese) |
618
+ | [docs/session-format.md](docs/session-format.md) | Session file format (Chinese) |
619
+ | [docs/rewind-plan.md](docs/rewind-plan.md) | Checkpoint and rewind design (Chinese) |
620
+ | [docs/tui-design.md](docs/tui-design.md) | Terminal UI visual spec and screen-by-screen mockups (Chinese) |
621
+ | [docs/design.md][design] | Overall design and decision log (Chinese) |
622
+ | [docs/extensions.md][extensions] | Local extensions (draft design, not implemented) (Chinese) |
623
+ | [docs/benchmarks/][benchmarks] | Preset benchmarks, the D20 todo retest and the cache acceptance experiment (reports and raw data) |
624
+ | [docs/wave6-plan.md][wave6] | Wave 6 design: agent bar and sub-agent view, traces, memory, ChatGPT login, bilingual UI, `/config` (Chinese) |
625
+ | [docs/i18n.md][i18n] | Bilingual development conventions: language selection, message catalogs and key naming, model-side isolation, check script (Chinese) |
626
+ | [docs/wave5-plan.md][wave5] | Wave 5 design (Chinese) |
627
+ | [docs/implementation-plan.md][impl], [wave3-plan][w3] | Early implementation plans (for history) (Chinese) |
628
+ | [docs/research/][research] | Wave 5 and wave 6 research reports (for history) (Chinese) |
629
+
630
+ The npm package includes the first sixteen user docs above (both languages where available); the rest are design and history material linked on GitHub.
590
631
 
591
632
  [design]: https://github.com/Owlbay/armadra-agent/blob/main/docs/design.md
592
633
  [extensions]: https://github.com/Owlbay/armadra-agent/blob/main/docs/extensions.md
593
634
  [benchmarks]: https://github.com/Owlbay/armadra-agent/tree/main/docs/benchmarks
635
+ [wave6]: https://github.com/Owlbay/armadra-agent/blob/main/docs/wave6-plan.md
636
+ [i18n]: https://github.com/Owlbay/armadra-agent/blob/main/docs/i18n.md
594
637
  [wave5]: https://github.com/Owlbay/armadra-agent/blob/main/docs/wave5-plan.md
595
638
  [impl]: https://github.com/Owlbay/armadra-agent/blob/main/docs/implementation-plan.md
596
639
  [w3]: https://github.com/Owlbay/armadra-agent/blob/main/docs/wave3-plan.md
597
640
  [research]: https://github.com/Owlbay/armadra-agent/tree/main/docs/research
598
641
 
599
- ## 已知限制
642
+ ## Known limitations
600
643
 
601
- - **Linux 沙箱未在真机上验证**:bubblewrap 的策略只经单元测试与 Ubuntu CI 验证,没有在 Linux 桌面 / 服务器真机上跑过;没有 bwrap 时退到 `unshare -r -n`(只隔离网络,不能用于 bash 沙箱),都没有则按无沙箱处理(codemode 回到执行类、每次审批)。
602
- - **外部 Agent 的真实 CLI 测试只在本地跑**:CI 只跑录制回放与 ama 驱动 ama;接 `claude` / `codex` 的端到端需要本机已登录,`AMA_E2E_AGENTS=1` 时运行(会用你的订阅额度),见 [docs/agents.md](docs/agents.md)「本地验证真实 CLI」。
603
- - **DeepSeek、智谱、Kimi 缺省仍走 Chat**:它们的 Messages 渠道(`@messages`)只在中转上测过,等官方直连过了实测门(`scripts/channel-probe.mjs`)再切缺省。
604
- - **models.dev 刷新 PR 不自动触发 CI**:仓库 secret `MODELS_DEV_PR_TOKEN` 没配时,每周的 workflow 用缺省 token 开 PR(先在 workflow 里自跑 `pnpm run ci` 并把结果写进描述)。
605
- - 子 Agent 深度 1,不读 `.claude/agents`,不支持继承父对话的 fork 模式;Windows 没有操作系统沙箱。
644
+ - **The Linux sandbox is not verified on real machines**: the bubblewrap policies are only verified by unit tests and Ubuntu CI, never on a Linux desktop / server; without bwrap ama falls back to `unshare -r -n` (network isolation only, unusable for the bash sandbox), and with neither it behaves as if there were no sandbox (codemode back to the execute class, approval every time).
645
+ - **Real-CLI tests for external agents only run locally**: CI runs only recorded replays and ama driving ama; end-to-end tests against `claude` / `codex` need a logged-in machine and run with `AMA_E2E_AGENTS=1` (using your subscription quota); see [docs/agents.md](docs/agents.md) (Chinese).
646
+ - **DeepSeek, Zhipu and Kimi still default to Chat**: their Messages channels (`@messages`) have only been tested through relays; the default switches once direct official endpoints pass the measurement gate (`scripts/channel-probe.mjs`).
647
+ - **models.dev refresh PRs do not trigger CI automatically**: without the repository secret `MODELS_DEV_PR_TOKEN`, the weekly workflow opens the PR with the default token (after running `pnpm run ci` itself and putting the result in the description).
648
+ - **ChatGPT login is not yet verified with a real account**: both flavors are tested against a local mock only. Still to be confirmed with a real Plus / Pro account: the tool `namespace` shape on the official (siwc) path (`toolsInNamespace` stays off), whether the codex device code needs enabling in ChatGPT security settings, and the fields of the codex `wham/usage` quota response. Real-account checks run locally with `AMA_E2E_CHATGPT=1` (see [docs/en/providers.md](docs/en/providers.md)).
649
+ - Sub-agents have depth 1, do not read `.claude/agents` and have no fork mode that inherits the parent conversation; Windows has no OS sandbox.
606
650
 
607
- ## 开发
651
+ ## Development
608
652
 
609
- 需要 Node ≥ 22 与 pnpm(版本见 `package.json` 的 `packageManager`,`corepack enable` 即可)。
653
+ Requires Node ≥ 22 and pnpm (version in `packageManager` of `package.json`; `corepack enable` is enough).
610
654
 
611
655
  ```sh
612
656
  pnpm install
613
- pnpm run ci # typecheck、fmt:check、check:deps、release:check、test、build,再跑 bundle --version
614
- AMA_E2E=1 pnpm test:e2e # bundle 级端到端:print / rpc / acp / plan / 子 Agent / 回滚 / codemode / cache / host(fake 供应商,不花钱)
657
+ pnpm run ci # typecheck, fmt:check, check:deps, check:i18n, release:check, test, build, then bundle --version
658
+ AMA_E2E=1 pnpm test:e2e # bundle-level end-to-end: print / rpc / acp / plan / sub-agents / rewind / codemode / cache / host / auth / config / memory / trace / i18n (fake provider, free)
615
659
  ```
616
660
 
617
- pnpm 10 起 `pnpm ci` 是内置的「清理后安装」,跑检查要写 `pnpm run ci`。常用单项:`pnpm test`、`pnpm typecheck`、`pnpm fmt`、`pnpm build`。测试一律用 fake 供应商:`AMA_FAKE_SCRIPT=<脚本.json>` 让它按脚本产出文本、工具调用、429、断流等,示例在 `test/fixtures/scripts/`。
661
+ Since pnpm 10, `pnpm ci` is the built-in "clean install", so run the checks with `pnpm run ci`. Common single steps: `pnpm test`, `pnpm typecheck`, `pnpm fmt`, `pnpm build`. Tests always use the fake provider: `AMA_FAKE_SCRIPT=<script.json>` makes it produce text, tool calls, 429s, dropped streams and so on from a script; examples are in `test/fixtures/scripts/`.
618
662
 
619
- **真实模型脚本**(本地跑,CI 不跑;先 `pnpm build`):
663
+ **Real-model scripts** (run locally, not in CI; `pnpm build` first):
620
664
 
621
- | 脚本 | 用途 |
622
- | --------------------------------------------------------- | ------------------------------------- |
623
- | `node scripts/bench-presets.mjs`(`pnpm bench:presets`) | 预设基准(`--tasks long` 多步长任务) |
624
- | `node scripts/cache-experiment.mjs`(`pnpm bench:cache`) | 缓存验收实验 E1–E5 |
625
- | `node scripts/record-sse.mjs` | 录制各协议的 SSE 样本作为测试 fixture |
665
+ | Script | Purpose |
666
+ | -------------------------------------------------------- | ----------------------------------------------------------- |
667
+ | `node scripts/bench-presets.mjs` (`pnpm bench:presets`) | Preset benchmark (`--tasks long` for long multi-step tasks) |
668
+ | `node scripts/cache-experiment.mjs` (`pnpm bench:cache`) | Cache acceptance experiments E1–E5 |
669
+ | `node scripts/record-sse.mjs` | Record SSE samples of each protocol as test fixtures |
626
670
 
627
- 前两个共用预算控制:`--config` / `AMA_REAL_CONFIG`(含 key 引用的 config.json)、`--models` / `AMA_REAL_MODELS`、`--max-requests` / `AMA_REAL_MAX_REQUESTS`(缺省 60)、`--budget-usd` / `AMA_REAL_BUDGET_USD`(缺省 3)。超过请求数或预算立即停止并输出已有数据;配置与数据目录指向临时目录,不碰你的用户配置。
671
+ The first two share budget controls: `--config` / `AMA_REAL_CONFIG` (a config.json with key references), `--models` / `AMA_REAL_MODELS`, `--max-requests` / `AMA_REAL_MAX_REQUESTS` (default 60), `--budget-usd` / `AMA_REAL_BUDGET_USD` (default 3). They stop as soon as the request count or budget is exceeded and output the data collected so far; config and data directories point to temp directories, never your user config.
628
672
 
629
- **约束**:运行时依赖必须为零,`src/` 只允许 `node:` 内置模块与相对路径(`pnpm check:deps` 守住)。`src/` 按层分目录(`ai` 模型接入、`agent` 循环、`session` 会话树、`tools`、`codemode`、`permissions`、`hooks`、`host` 宿主契约、`tui` 组件库、`modes` 各入口、`cli` 启动),各目录的 `types.ts` 是模块之间的契约。
673
+ **Constraints**: runtime dependencies must be zero; `src/` may only use `node:` built-ins and relative paths (guarded by `pnpm check:deps`). `src/` is organized by layer (`ai` model access, `agent` loop, `session` session tree, `tools`, `codemode`, `permissions`, `hooks`, `host` host contract, `tui` component library, `modes` entry points, `cli` startup), and each directory's `types.ts` is the contract between modules.
630
674
 
631
- **发布**:改 `package.json` 版本与 [CHANGELOG.md](CHANGELOG.md),合入 main 后打 `v<版本>` tag。CI 全绿后 release job 生成 GitHub Release(`ama.cjs`、`ama-sandbox.cjs`、`package.tgz`、`SHA256SUMS`),再以 provenance 发布到 npm:优先用 OIDC 可信发布(trusted publishing,npm ≥ 11.5.1,job 内自动升级),在 npmjs.com 的 `@armadra/agent` 包设置 → Trusted Publisher 添加 GitHub Actions(组织 `Owlbay`、仓库 `armadra-agent`、工作流 `ci.yml`、环境留空)即可,不需要长期 token;仓库 secret `NPM_TOKEN` 保留为回退,两者都没有时 job 失败并提示。`pnpm release:check` 检查 tag 与版本一致,协议常量变化要求破坏性版本升级。
675
+ **Releasing**: bump the version in `package.json`, update both changelogs (English [CHANGELOG.md](CHANGELOG.md) and Chinese [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md), turning "Unreleased" into the version), merge into main and push a `v<version>` tag. Once CI is green the release job creates a GitHub Release (`ama.cjs`, `ama-sandbox.cjs`, `package.tgz`, `SHA256SUMS`) and publishes to npm with provenance. It prefers OIDC trusted publishing (npm ≥ 11.5.1, upgraded inside the job): add a GitHub Actions trusted publisher in the `@armadra/agent` package settings on npmjs.com (organization `Owlbay`, repository `armadra-agent`, workflow `ci.yml`, environment empty) and no long-lived token is needed; the repository secret `NPM_TOKEN` stays as a fallback, and the job fails with a hint when neither exists. `pnpm release:check` checks that the tag matches the version, requires a breaking version bump when protocol constants change, and checks that both READMEs / changelogs and `docs/en/` exist and link to each other and that both changelogs have a section for the current version (English from 0.6.0 on).
632
676
 
633
- ## 更新记录
677
+ ## Changelog
634
678
 
635
- 见 [CHANGELOG.md](CHANGELOG.md)。
679
+ See [CHANGELOG.md](CHANGELOG.md) (English, from 0.6.0) and [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md) (Chinese, complete history since 0.1).
636
680
 
637
- ## 许可证
681
+ ## License
638
682
 
639
683
  [MIT](LICENSE)