Skip to content

AtomCode v5.2.3 新子系统深度分析 — 架构级重写:plexus 行级运行时 + harness 分层运行时 + 全新 TUI ​

基于 strings 结构体元数据 + 提示注入串 + 模块路径 + 运行时验证的还原分析 2026-10-14 前置报告:06-version-diff-v5.0.9-to-v5.2.3.md 姊妹报告:DEEP_ANALYSIS_53 系列(会话事件化 / 断流续接 / Provider / 安全授权)


1. 全景:从单体引擎到行级插件运行时 ​

v5.0.9 的架构是单体引擎:atomcode-kernel(agent 循环)+ atomcode-coding(编码运行时)+ atomcode-capabilities(能力)+ atomcode-tuix(TUI 渲染)。

v5.2.3 将其重构为三层运行时,且所有前端(终端 / 网页 / VS Code / ACP)共用同一个运行时:

┌─────────────────────────────────────────────────────────────┐
│  前端层  atomcode-tui(新全屏 TUI,默认)  atomcode-tuix(--classic)
│           WebUI SPA / VS Code 扩展 / ACP v2                    │
├─────────────────────────────────────────────────────────────┤
│  运行时层  atomcode-harness(agent loop + 42 个插件行)        │
│            atomcode-plexus(行级插件内核:realm/fiber/event)  │
├─────────────────────────────────────────────────────────────┤
│  能力层  atomcode-capabilities / atomcode-coding /             │
│          atomcode-config / atomcode-auth / atomcode-review     │
├─────────────────────────────────────────────────────────────┤
│  平台层  atomcode-daemon / atomcode-updater /                  │
│          atomcode-telemetry / atomcode-codingplan-crypto       │
└─────────────────────────────────────────────────────────────┘

2. atomcode-plexus:行级插件内核 ​

2.1 模块结构 ​

crates/atomcode-plexus/src/app.rs       ← 应用装配入口
crates/atomcode-plexus/src/context.rs   ← 行上下文(每行一个 context)
crates/atomcode-plexus/src/event.rs     ← 事件总线
crates/atomcode-plexus/src/fiber.rs     ← 执行单元(异步 fiber)
crates/atomcode-plexus/src/plugin.rs    ← 插件行 trait 与注册
crates/atomcode-plexus/src/realm.rs     ← 隔离域(权限/工具集边界)
crates/atomcode-plexus/src/service.rs   ← 服务槽(服务注册与解析)

2.2 核心抽象(从二进制证据还原) ​

Plugin Row(插件行):一切皆行的最小单位。

This agent is assembled at runtime from plugin rows on the plexus kernel.
There is no fixed feature set

Realm(隔离域):域 = 权限 + 工具集 + 服务视图的边界。

#in-process, isolated realm, tools: ...
run a child agent in an isolated realm, with a reduced tool set
cannot claim it (unload the incumbent or isolate a realm)
task runs a child in its own realm with a reduced tool set and hands back

Fiber(执行单元):异步任务。

fiber status poisoned / fiber ledger poisoned / fiber table poisoned
`root`realm tree poisoned

Service(服务槽):服务在域内注册、解析。

The service slots filled and visible from this agent's realm (...)

2.3 行装配机制 ​

struct RawEntry with 4 elements   ← 行条目(id / 类型 / 依赖 / 载荷)
struct RawPatch with 4 elements   ← 行补丁
struct RawRemove with 1 element   ← 行移除
mounting stalled with unsatisfied dependencies:
insertpatch / root fiber always exists

→ 行有依赖关系;装配时若依赖未满足会报告 mounting stalled。可在运行中替换或卸载单行。 树的变更原语 = RawEntry(插入)/ RawPatch(补丁)/ RawRemove(删除), 以 root fiber 为根,管理 fiber 表 + fiber ledger + realm 树。

2.4 "一切皆插件"系统提示自述(决定性证据) ​

This agent is assembled at runtime from plugin rows on the plexus kernel. There is no
  fixed feature set ... only the rows the running tree happens to have mounted, which is
  why you cannot know what you are made of from anything you were trained on.

composition HOW THIS SYSTEM IS PUT TOGETHER. Every capability is a *row* in a config
  tree ... model adapter, each tool group, memory, recall, approval policy, the UI.
  A row names a plugin from the build's catalog; the tree says which rows run.

2.5 Service 槽模型(槽=地址,插件=值) ​

The service slots filled and visible from this agent's realm (... of them). A slot is
  an address; the plugin behind it is a value the config picked, so the presence of
  `llm` says a model adapter is mounted, not which one.

` is provided but nothing injects it / ` is injected by / % but no registered plugin provides it
k` is registered twice; each plugin name is registered once and mounted on as many rows
  as the layers insert

→ 服务槽是"地址";同一插件名注册一次、可挂载多行。

2.6 运行中的控制面(live runtime control plane) ​

banner / exit / quit / rows / dump / audit / stop / agents / seams / title / patch

  /agents        live agents
  /seams         filled service slots
  /rows          config rows, and which are enabled
  /patch `FILE`  apply a patch layer to the RUNNING tree
  /dump          the running tree in full
  /audit         check the running composition

JSON-RPC 控制方法(agent_loop 插件暴露):

agent/create  agent/list  agent/send  agent/inject  agent/cancel
session/transcript  session/events
harness/seams  harness/rows  harness/patch  harness/audit
user/answer

行级 TOML 层:[[insert]] id = "ui" name = "ui-tui2"(挂载新行)、 [[remove]] id = "persona-coding"(卸载行)、[[patch]] id = "ui" config = {...}(打补丁)。 App::patch 只重挂载自身 entry 已改变的行。

2.7 诊断注入(运行时验证 --tui --audit) ​

· `tui-brand` is provided but nothing injects it
· `tui-mcp-phase` is provided but nothing injects it
· `tui-rasters` is provided but nothing injects it
· `tui-repaint` is provided but nothing injects it
· `tui-team-roster` is provided but nothing injects it
no defects; 5 note(s) above

→ TUI 的 5 个组件(brand / mcp-phase / rasters / repaint / team-roster)通过注入器注册。 校验语义:composition is consistent: every declared role matches the running tree。


3. atomcode-harness:分层运行时(42 个插件行) ​

3.1 结构 ​

crates/atomcode-harness/src/agent.rs        ← Agent 主体
crates/atomcode-harness/src/commands.rs     ← 命令处理器
crates/atomcode-harness/src/diagnostics.rs  ← 诊断
crates/atomcode-harness/src/exec.rs         ← 执行
crates/atomcode-harness/src/feed.rs         ← 事件馈送
crates/atomcode-harness/src/model_source.rs ← 模型源解析
crates/atomcode-harness/src/seams.rs        ← 接缝(可替换点)
crates/atomcode-harness/src/session.rs      ← 会话

3.2 42 个插件行全清单(plugins/ 子模块) ​

agent_loop / agents / ask / capabilities / compaction / findings / handle /
image_budget / llm / loop_policy / opener / persona / policy_rows / policy /
product_dirs / reasoning_effort / recall / recovery / registries /
self_knowledge / session / session_title / subagent / team / todo_reminder /
tool_exec / tools / trace / truncation / ui_jsonrpc / ui / ui_web / world /
world_tools

3.3 插件默认配置(二进制内嵌 [[insert]] 行) ​

name = "agent-loop"          config = { max_rounds = 100 }
name = "compaction-overflow" config = { max_attempts = 3 }
name = "compaction-tail"     config = { threshold = 0.75, keep_turns = 2 }
name = "image-budget"        config = { max_bytes = 8388608 }
name = "loop-policy"         config = { nudge_at = 3, stop_at = 6 }
name = "tool-exec-parallel"  config = { max_parallel = 4 }
name = "truncation-recovery" config = { max_continuations = 4 }
name = "llm-stream-recovery" config = { max_recoveries = 1 }
name = "llm-request-timeout" config = { request_secs = 600 }
name = "llm-rate-limit"      config = { max_waits = 5, max_wait_secs = 120, fallback_secs = 5 }
name = "persona-atomcode"    config = { model = ..., product = ..., provider = ... }
name = "todo-reminder"       ← tell the agent when the task list has stopped describing what it is doing

多级压缩:multi-level compaction on overflow (mechanical plus an LLM summary) and cache-friendly history compaction。

3.4 插件行标识符与语义(从提示注入串还原) ​

行 ID二进制证据(提示注入串)职责
self-knowledge"This agent is assembled at runtime from plugin rows on the plexus kernel. There is no fixed feature set"自我认知:告诉模型它由行装配而来
ui-handle"drive this harness through the AgentHandle protocol the shipped UIs speak"以 AgentHandle 协议驱动 harness
user-questions"user-questionstool-driver"用户提问工具
llm-atomcode-config"the model AtomCode is already configured to use (config.toml in the user tree)"默认模型来源
llm-stream-recovery"keep what a broken stream produced and continue from it"断流恢复
llm-request-timeout"bound one model request so a turn cannot hang forever"请求超时上限
llm-retry / llm-replay"…"重试 / 重放
llm-rate-limit"…"限流
image-budget"how many image bytes one model request carries; the oldest are left out first"图片字节预算
compaction-overflow / compaction-tail"…"上下文压缩策略(溢出 / 尾部)
tool-exec-parallel"overlap the tool calls that declare themselves safe to overlap"安全工具并行
token-budget"send a turn once it has spent enough prompt tokens"token 预算
tool-fs-world"read/write/edit/list, routed through the fs seam"世界工具(fs seam 路由)
tool-bash-world"shell execution, routed through the shell seam"世界工具(shell seam 路由)
tool-search-world"grep and glob, routed through the fs seam"世界工具
surface-headless"paint into memory and keep every frame; no tty"无头表面
surface-terminal"the terminal, full screen, restored on the way out"终端表面
delegation-bounds"declarative allow/deny rules over tool calls"委派边界
tool-open-file-workspace"an open_file target inside the workspace needs no approval"工作区内 open_file 免审批
session-persistence"resume = true continues that session by replaying the events session-persistence stored for it before the first turn. There is no separate snapshot format for this: the stored events are the snapshot"会话持久化(事件即快照)
world / world_tools"Every answer is generated from the running system, so none of it can be out of date; it is read-only and cheap"世界问答(实时只读)
subagent-in-process"run a child agent in an isolated realm, with a reduced tool set"进程内子代理

3.4 装配链收敛(v5.0.9 → v5.2.3) ​

移除:

  • ATOMCODE_ENGINE 引擎选择开关(二进制中已无此字符串,grep -c = 0)
  • 手写中间件链
  • crates/atomcode-kernel/src/agent.rs(旧内核 agent)

保留唯一装配路径:parts::prepare → runtime::mount(行清单装配)。


4. atomcode-tui:全新全屏终端界面 ​

4.1 自研布局引擎模块 ​

crates/atomcode-tui/src/layout.rs    ← flex 布局
crates/atomcode-tui/src/surface.rs   ← 绘制表面
crates/atomcode-tui/src/raster.rs    ← 栅格渲染
crates/atomcode-tui/src/frame.rs     ← 帧缓冲
crates/atomcode-tui/src/el.rs        ← 元素
crates/atomcode-tui/src/block.rs     ← 区块
crates/atomcode-tui/src/theme.rs     ← 主题
crates/atomcode-tui/src/scrollbar.rs ← 滚动条(v5.2.3 新交互)
crates/atomcode-tui/src/keymap.rs    ← 键盘/鼠标映射
crates/atomcode-tui/src/markdown/    ← markdown 渲染(含表格 table.rs)
crates/atomcode-tui/src/overlay.rs   ← 覆盖层
crates/atomcode-tui/src/moment.rs    ← 瞬态 UI
crates/atomcode-tui/src/secret.rs    ← 秘密输入
crates/atomcode-tui/src/qr.rs        ← QR 码(手机配对)
crates/atomcode-tui/src/modules/     ← 12 个面板模块(ask/bg/chrome/input/plugins/providers/settings/sheet/status/todo/transcript)

4.2 完全自研(无第三方 TUI 框架) ​

二进制中搜不到 ratatui / tui-rs / crossterm——全新界面完全自研。证据:

  • surface 双模式:surface-headless("paint into memory and keep every frame; no tty") 与 surface-terminal("the terminal, full screen, restored on the way out")
  • 面板布局:host.rs 的 host::composer / host::TAIL 控制
    • Between the conversation and the field, because it belongs to the composer: its place is written in host::composer
    • The bottom sheet: the list /agents, /cd, /diff and /view put up ... at the foot of the screen
  • 服务槽绘制字段:paint screen= rows=footer menu= body= buf_w= emit= botrule_row= botrule_dashes=
  • 帧模型内部状态:moment poisoned / last frame poisoned / overlays poisoned / row index poisoned / room poisoned / pin gate poisoned / stream.prompt / stream conversation-scrollbar / context-menu / history-search / jump-to-bottom
  • 终端能力探测:--probe-terminal asks the terminal itself、(answered by the terminal)、 the terminal did not answer ... (falling back to xterm's values)、 [?1002l 256 truecolor 24bit ATOMCODE_MOUSE xterm xterm-color xterm-256color(鼠标跟踪转义)
  • 行级结构体:struct Row / struct SizeRow / struct SurfaceRow / struct BrandRowConfig / struct MemorySection

4.3 界面组成(运行时验证 --tui --demo) ​

第 1 行:  ❯ fix the build                    ← 输入框(提示文字)
第 3 行:  ⚑ rate limited; waiting 30s (1/5)  ← 限流状态
第 5 行:  ● scout 汇报回来了  点击展开        ← 子代理行(可点击)
第 7 行:  ● Fixed it. 中文也要能画 🙂          ← 消息
第 9 行:  ✻ Done · 0ms · 1 轮 · 2 工具 · 880 tokens · 本轮缓存 33%   ← 回合结束条
第 13 行: ● 看看那个目录                       ← 用户消息
第 15 行: ● $ cd /Users/我的项目/前端…          ← 工具调用(bash)
第 17 行: ● write_file 我的笔记/notes.md → 允许一次  ← 审批收成一行
第 18 行: ● Allow `bash` to run? → 拒绝       ← 审批
第 19 行: ● Add a [telemetry] section, or leave it off? → 拒绝  ← 配置提问
第 22 行: ❯ 再帮我看看 crates/ 的结构          ← 输入框
第 24 行: replay │ AtomCodeReverseEngineering │ 1.2K tok │ 缓存 33%  ← 状态栏

关键 UI 元素:

  • 审批可视化:● write_file … → 允许一次、● Allow bash to run? → 拒绝
  • 回合结束条:✻ Done · 耗时 · 轮数 · 工具数 · tokens · 缓存%
  • 状态栏:会话名 │ 项目名 │ token 用量 │ 缓存%
  • 限流提示:⚑ rate limited; waiting 30s (1/5)
  • 中文/emoji 渲染:Fixed it. 中文也要能画 🙂

4.3 CLI 切换机制 ​

--tui       Open the full-screen UI assembled from plugin rows for this launch,
            whatever `[ui] screen` says. It is also what opens without a flag
--classic   Open the classic screen for this launch, whatever `[ui] screen` says —
            the escape hatch. `[ui] screen = "classic"` makes it the one that opens without the flag
配置效果
[ui] screen 缺省新 TUI(默认)
[ui] screen = "classic"旧 tuix 界面
--tui强制新界面
--classic强制旧界面(escape hatch)

4.4 新 CLI 诊断选项 ​

--probe-terminal   Print what the terminal says its colours are and what every colour role
                   of the row-assembled screen resolves to on it, then exit
--no-mouse         On the row-assembled screen: leave the mouse to the terminal
--audit            With --tui: check that the screen's composition is sound, and exit
--demo             With --tui: print one composed frame of the screen, and exit
--print-frame      With --tui: print one composed frame of the screen(demo 别名)
--mascot           On the row-assembled screen: show the mascot
--theme `THEME`    auto|dark|light

4.5 终端兼容回退 ​

This console cannot draw the new screen (no escape-sequence support); opening the classic
  screen. Windows Terminal runs the new one.
w is only on the classic screen for now: quit and run `atomcode --classic` (same sessions).
  It is coming to this screen.

→ 无转义序列支持的终端自动回退到经典界面并明示原因;新旧界面共享同一会话。

4.6 i18n 多语言 ​

zh-CN / en-US / zh_CN / i18n / UI language / --lang `LANG`
chat.* / perm.* / skills.* / providers.* 等 i18n 键体系

5. 新旧界面共存 ​

atomcode-tuix(旧界面)保留,但模块大幅扩展:

crates/atomcode-tuix/src/event_loop/{bg_runtime,commands,mod,monitor,oauth_poll,
  openrouter_connect,pointer_select,usage_monitor}.rs
crates/atomcode-tuix/src/modals/{config_panel,dir_picker,file_viewer,language_picker,
  model_picker,mod,onboarding_wizard,password,plugin_manager,provider_panel,qr,rewind,
  session_picker,usage_render,usage}.rs
crates/atomcode-tuix/src/render/{cell,diff,plain,qr,retained,screen,worker}.rs

→ 旧界面也同步获得 /bg、OpenRouter 接入、指针选择、用量监控等能力。


6. 与旧架构的对应关系 ​

v5.0.9 模块v5.2.3 替代说明
atomcode-kernel/src/agent.rsharness/src/plugins/agent_loop.rsagent 循环插件化
coding/src/execution_policy.rsharness/src/plugins/policy.rs策略插件化
coding/src/skill_first.rsharness/src/plugins/registries.rs技能注册插件化
coding/src/team/runner.rsharness/src/plugins/team.rs团队插件化
coding/src/session_title.rsharness/src/plugins/session_title.rs会话标题插件化
coding/src/plan_mode.rsharness/src/plugins/*拆分为多行
capabilities/src/tools/approval.rscapabilities/src/tools/permission_rules.rs审批规则重构
capabilities/src/tools/task.rsharness/src/plugins/subagent.rs子代理插件化
capabilities/src/session/transcript.rscapabilities/src/session/events.rs会话事件化
tuix(渲染引擎)tui(新渲染引擎)+ tuix(--classic)双界面并存

7. 运行时验证记录 ​

7.1 --tui --audit(屏幕组成检查) ​

· `tui-brand` is provided but nothing injects it
· `tui-mcp-phase` is provided but nothing injects it
· `tui-rasters` is provided but nothing injects it
· `tui-repaint` is provided but nothing injects it
· `tui-team-roster` is provided but nothing injects it
no defects; 5 note(s) above

7.2 --tui --demo(界面帧渲染) ​

渲染出一帧完整界面:输入框 / 限流状态 / 子代理行 / 消息 / 回合结束条 / 审批行 / 状态栏

7.3 --probe-terminal(终端能力探测) ​

--probe-terminal asks the terminal itself, so its output cannot be redirected.
Run it in the terminal and copy what it prints.

→ 终端能力探测需要真实终端会话,无法在重定向下运行。

基于 VitePress 构建 · AtomCode v5.2.3 逆向工程分析文档