deeparche-platform 0.50.4__py3-none-any.whl
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.
- deeparche/ARCHITECTURE.md +1700 -0
- deeparche/CHANGELOG.md +5298 -0
- deeparche/CONSISTENCY_CHECK.md +138 -0
- deeparche/CONTRACT.md +603 -0
- deeparche/README.md +183 -0
- deeparche/__init__.py +299 -0
- deeparche/builtin/__init__.py +0 -0
- deeparche/builtin/command_surface.py +650 -0
- deeparche/builtin/file_io.py +399 -0
- deeparche/builtin/file_tools.py +1294 -0
- deeparche/builtin/ignore_rules.py +190 -0
- deeparche/builtin/limits.py +145 -0
- deeparche/builtin/mcp.py +1866 -0
- deeparche/builtin/minimal_subagent.py +140 -0
- deeparche/builtin/model_info_tool.py +121 -0
- deeparche/builtin/output_store.py +147 -0
- deeparche/builtin/paging.py +96 -0
- deeparche/builtin/persistent_tool.py +358 -0
- deeparche/builtin/process_tool.py +304 -0
- deeparche/builtin/recall_tool.py +146 -0
- deeparche/builtin/registry.py +326 -0
- deeparche/builtin/repo_map.py +754 -0
- deeparche/builtin/shell_manual.py +98 -0
- deeparche/builtin/shell_tool.py +370 -0
- deeparche/builtin/skills.py +995 -0
- deeparche/builtin/subagent_tool.py +755 -0
- deeparche/builtin/todo_tool.py +327 -0
- deeparche/builtin/webfetch_tool.py +793 -0
- deeparche/builtin/websearch_tool.py +267 -0
- deeparche/core/__init__.py +118 -0
- deeparche/core/approval.py +89 -0
- deeparche/core/atomic.py +81 -0
- deeparche/core/background.py +544 -0
- deeparche/core/call_grant.py +175 -0
- deeparche/core/call_lease.py +289 -0
- deeparche/core/command_grammar.py +455 -0
- deeparche/core/command_surface.py +135 -0
- deeparche/core/compaction.py +1272 -0
- deeparche/core/context.py +3075 -0
- deeparche/core/environment.py +108 -0
- deeparche/core/errors.py +86 -0
- deeparche/core/event_window.py +454 -0
- deeparche/core/filters.py +111 -0
- deeparche/core/hooks.py +230 -0
- deeparche/core/inject_texts.py +81 -0
- deeparche/core/invariants.py +57 -0
- deeparche/core/loop.py +2209 -0
- deeparche/core/media.py +181 -0
- deeparche/core/permission.py +421 -0
- deeparche/core/process.py +1487 -0
- deeparche/core/provider_error.py +79 -0
- deeparche/core/request_cleanup.py +650 -0
- deeparche/core/sandbox.py +1108 -0
- deeparche/core/session_state.py +55 -0
- deeparche/core/state.py +89 -0
- deeparche/core/subagent_result.py +171 -0
- deeparche/core/token_estimate.py +219 -0
- deeparche/core/tool_attempt.py +65 -0
- deeparche/core/tool_host.py +260 -0
- deeparche/core/tool_ipc.py +79 -0
- deeparche/core/tool_worker.py +70 -0
- deeparche/core/tools.py +1613 -0
- deeparche/core/turn_token.py +83 -0
- deeparche/core/turn_transaction.py +81 -0
- deeparche/core/types.py +746 -0
- deeparche/docs/extending.md +1195 -0
- deeparche/docs/feature_tree.html +528 -0
- deeparche/docs/integration.md +208 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/01_compatible_/321/211/320/255/320/256/321/206/342/225/241/320/221/321/205/342/225/235/320/237.md +99 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/02_compatible_/321/206/342/225/241/320/221/321/205/342/225/235/320/237.md +75 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/03_responses_/321/211/320/255/320/256/321/206/342/225/241/320/221/321/205/342/225/235/320/237.md +105 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/04_responses_/321/206/342/225/241/320/221/321/205/342/225/235/320/237.md +73 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/05_claude_/321/211/320/255/320/256/321/206/342/225/241/320/221/321/205/342/225/235/320/237.md +119 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/06_claude_/321/206/342/225/241/320/221/321/205/342/225/235/320/237.md +84 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/07_mcp.md +86 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/08_agent_skills.md +74 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/09_function_calling.md +54 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/10_structured_outputs.md +52 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/11_prompt_caching.md +250 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/12_/321/207/320/244/320/270/321/206/320/230/342/225/226/321/205/342/225/226/320/265/321/205/320/225/342/225/226/321/206/320/231/320/271/321/205/342/226/222/320/245/321/210/320/267/320/224/321/210/320/234/320/223.md +364 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/13_/321/205/320/275/320/240/321/204/342/225/227/320/263/321/207/320/240/320/226/321/206/320/231/320/267/321/210/320/261/320/234/321/205/320/251/320/270/321/205/320/235/320/237/321/210/320/276/320/276.md +163 -0
- deeparche/docs//321/205/320/235/320/237/321/210/320/276/320/276/321/210/320/267/320/224/321/210/320/234/320/223/README.md +29 -0
- deeparche/examples/README.md +88 -0
- deeparche/examples/__init__.py +1 -0
- deeparche/examples/config/HISTORY.md +506 -0
- deeparche/examples/config/agent.example.toml +160 -0
- deeparche/examples/config/channel.example.toml +26 -0
- deeparche/examples/config/deeparche.example.toml +1417 -0
- deeparche/examples/config/permissions.example.toml +83 -0
- deeparche/examples/config/tool.example.toml +55 -0
- deeparche/examples/dev/platform/quickstart_core_kb.py +210 -0
- deeparche/examples/dev/platform/quickstart_kernel.py +422 -0
- deeparche/examples/dev/platform/quickstart_orchestrator.py +313 -0
- deeparche/examples/dev/platform/quickstart_tool_simple.py +60 -0
- deeparche/examples/dev/product/agents/reviewer/agent.toml +15 -0
- deeparche/examples/dev/product/agents/reviewer/system.md +12 -0
- deeparche/examples/dev/product/quickstart_agent.py +79 -0
- deeparche/examples/dev/product/quickstart_api.py +253 -0
- deeparche/examples/dev/product/quickstart_headless.py +123 -0
- deeparche/examples/dev/product/quickstart_resume.py +124 -0
- deeparche/examples/dev/product/quickstart_subagent.py +210 -0
- deeparche/examples/dev/product/quickstart_tool_product.py +60 -0
- deeparche/llm/__init__.py +0 -0
- deeparche/llm/adapter.py +571 -0
- deeparche/llm/client.py +301 -0
- deeparche/llm/constants.py +16 -0
- deeparche/llm/fallback.py +161 -0
- deeparche/llm/media.py +197 -0
- deeparche/llm/pricing.py +1801 -0
- deeparche/llm/protocols/__init__.py +29 -0
- deeparche/llm/protocols/claude.py +376 -0
- deeparche/llm/protocols/common.py +180 -0
- deeparche/llm/protocols/compatible.py +206 -0
- deeparche/llm/protocols/responses.py +294 -0
- deeparche/llm/stream_parser.py +130 -0
- deeparche/orch/__init__.py +58 -0
- deeparche/orch/approval.py +468 -0
- deeparche/orch/bootstrap.py +884 -0
- deeparche/orch/event_journal.py +1162 -0
- deeparche/orch/log.py +161 -0
- deeparche/orch/messages.py +92 -0
- deeparche/orch/model_config.py +393 -0
- deeparche/orch/model_descriptor.py +156 -0
- deeparche/orch/persist.py +72 -0
- deeparche/orch/providers.py +1312 -0
- deeparche/orch/resume.py +152 -0
- deeparche/orch/runtime.py +425 -0
- deeparche/orch/scope.py +131 -0
- deeparche/orch/service/__init__.py +53 -0
- deeparche/orch/service/contract.py +67 -0
- deeparche/orch/service/events.py +85 -0
- deeparche/orch/service/media.py +92 -0
- deeparche/orch/service/stream.py +374 -0
- deeparche/orch/session.py +2028 -0
- deeparche/orch/session_assembler.py +59 -0
- deeparche/orch/session_journal.py +94 -0
- deeparche/orch/session_lock.py +348 -0
- deeparche/orch/stream.py +143 -0
- deeparche/orch/subagent.py +2114 -0
- deeparche/orch/subagent_approval.py +334 -0
- deeparche/orch/subagent_background.py +836 -0
- deeparche/orch/subagent_config.py +301 -0
- deeparche/orch/subagent_models.py +464 -0
- deeparche/orch/subagent_sessions.py +559 -0
- deeparche/orch/supervisor.py +399 -0
- deeparche/orch/title.py +56 -0
- deeparche/orch/tool_families.py +21 -0
- deeparche/orch/transcript.py +865 -0
- deeparche/orch/turn.py +484 -0
- deeparche/orch/watcher.py +114 -0
- deeparche/protocols/__init__.py +39 -0
- deeparche/protocols/decision/__init__.py +17 -0
- deeparche/protocols/decision/client.py +145 -0
- deeparche/protocols/vector/__init__.py +19 -0
- deeparche/protocols/vector/client.py +115 -0
- deeparche_platform-0.50.4.dist-info/METADATA +156 -0
- deeparche_platform-0.50.4.dist-info/RECORD +158 -0
- deeparche_platform-0.50.4.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,1700 @@
|
|
|
1
|
+
# DeepArche Architecture
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
DeepArche is organized into a layered modular architecture with strict dependency rules to ensure maintainability and prevent circular dependencies.
|
|
6
|
+
|
|
7
|
+
**核心理论(2026-08-16 文档化——理解本项目只需这几行)**:
|
|
8
|
+
|
|
9
|
+
- `Harness = Context Manager + Tool Registry + Agent Loop`;`Agent = Harness + LLM`——
|
|
10
|
+
控制层与推理层分离,框架不绑定任何特定 LLM
|
|
11
|
+
- 三模块硬边界:上下文管理 / 工具接入 / 循环控制——职责不混
|
|
12
|
+
- 缓存红线:发给模型的开头部分(system)字节稳定;动态内容只经 user 消息注入
|
|
13
|
+
- 8 段式提示词组装:每轮 LLM 看到的上下文由 ContextManager 精细控制
|
|
14
|
+
- 平台/产品边界(S3 2026-09-12):平台(core/llm/orch/builtin)零约定、
|
|
15
|
+
不依赖产品;产品(product/*)读取约定并组合平台能力——依赖单向
|
|
16
|
+
(core → llm → orch/builtin → product),守卫全绿(白名单为空)
|
|
17
|
+
|
|
18
|
+
**分层(2026-09-12 平台/产品定版)**:
|
|
19
|
+
|
|
20
|
+
> 2026-08-16:TUI 已归档至 `code/archived/tui/`(冻结单独重设计——交互
|
|
21
|
+
> 未达生产水平;发行包不含)。当前唯一受支持展示层为 CLI(product/cli)。
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
平台(零约定): core(引擎) → llm(协议) → orch(通用编排) + builtin(通用工具)
|
|
25
|
+
产品(吃约定): product(产品编排 assembly/config/agents/actions/approval/
|
|
26
|
+
checkpoint/revert/instructions → api 服务契约 → cli 展示 + tools 接线)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Layer Structure(机器生成区——2026-08-16 起由 gen_feature_tree.py 维护)
|
|
30
|
+
|
|
31
|
+
> 本节全部内容由 `python scripts/gen_feature_tree.py --write` 生成:
|
|
32
|
+
> 分层模块树(模块 docstring 首行 = 功能一句话)+ 接入点总览(命令/
|
|
33
|
+
> 工具/CLI 参数/配置键/公开 API/测试套件)+ Mermaid 图(依赖图与
|
|
34
|
+
> 模块树——纯可选输出,由同一脚本渲染)。
|
|
35
|
+
> 漂移检测:`python scripts/check_feature_tree.py`(挂全量回归——
|
|
36
|
+
> 手工修改本节或代码新增模块未同步 → 立即红,提示运行 --write)。
|
|
37
|
+
|
|
38
|
+
<!-- FEATURE-TREE:START -->
|
|
39
|
+
|
|
40
|
+
### 分层模块树
|
|
41
|
+
|
|
42
|
+
*由 gen_feature_tree.py 生成(235 个模块)——模块 docstring 首行 = 功能一句话;每层折叠块,点击展开*
|
|
43
|
+
|
|
44
|
+
<details open><summary>🧠 <b>core/</b> —— 内核(引擎——零外部依赖)(35 模块)</summary>
|
|
45
|
+
|
|
46
|
+
| 模块 | 功能 |
|
|
47
|
+
|------|------|
|
|
48
|
+
| approval.py | 审批端口(M1.2c 2026-10-24)。 |
|
|
49
|
+
| atomic.py | 原子替换的**有界重试**(Windows 瞬时占用——**单源**)。 |
|
|
50
|
+
| background.py | 后台任务执行底座——工具异步执行的内核能力。 |
|
|
51
|
+
| call_grant.py | 运行期工具调用授权(M1.3a 2026-10-23)。 |
|
|
52
|
+
| call_lease.py | 工具调用资源租约(M1.3b 2026-10-25)。 |
|
|
53
|
+
| command_grammar.py | slash 命令语法:纯数据 + lexer/parser(**core 纯净**)。 |
|
|
54
|
+
| command_surface.py | 命令面数据契约(core——不依赖任何 parser/第三方库)。 |
|
|
55
|
+
| compaction.py | 上下文压缩模块,支持基于 LLM 的摘要 |
|
|
56
|
+
| context.py | 上下文管理模块(缓存友好的对话历史 + 消息序列化) |
|
|
57
|
+
| environment.py | Shell 环境探测与执行参数(单源)——供环境快照与工具执行共用。 |
|
|
58
|
+
| errors.py | 结构化工具错误码(2026-08-14——dsh 借鉴项 ①:错误码集中单源)。 |
|
|
59
|
+
| event_window.py | 有界事件窗口的纯契约(Phase 0)。 |
|
|
60
|
+
| filters.py | Agent 输出的流式过滤器模块 |
|
|
61
|
+
| hooks.py | 钩子系统,用于可观测性和控制 |
|
|
62
|
+
| inject_texts.py | 用户通道**注入文案**单源(D2 2026-10-16——提示词可达性收编)。 |
|
|
63
|
+
| invariants.py | 运行时不变量 helper(2026-08-14——dsh 借鉴项 ③:不变量文化)。 |
|
|
64
|
+
| loop.py | Agent 主循环模块:思考 → 行动 → 观察 |
|
|
65
|
+
| media.py | 媒体基础常量与格式判定(core 层——通用文件格式知识,零依赖)。 |
|
|
66
|
+
| permission.py | 权限决策最小内核(2026-08-26——最终精简——用户定稿)。 |
|
|
67
|
+
| process.py | 进程生命周期单源(2026-10-21——shell 挂起根治)。 |
|
|
68
|
+
| provider_error.py | ProviderError —— LLM 传输/认证/配额错误的 durable 分类(0.45.6 Phase 2)。 |
|
|
69
|
+
| request_cleanup.py | 请求投影历史清理(请求体预算 / 历史媒体 / 历史工具结果)。 |
|
|
70
|
+
| sandbox.py | 沙箱执行——工具执行隔离后端(执行后端定位,非内核六件事)。 |
|
|
71
|
+
| session_state.py | SessionState —— 从 EventLog 重建的 durable 会话状态(0.45.6 Phase 3)。 |
|
|
72
|
+
| state.py | 状态存储**协议**(内核——纯抽象:零约定、零 I/O)。 |
|
|
73
|
+
| subagent_result.py | 子代理结构化结果单源(0.8.0 审计 B5——消除双实现)。 |
|
|
74
|
+
| token_estimate.py | Token 估算单源(路线 B 2026-09-13——**回退口径;不参与行为决策**)。 |
|
|
75
|
+
| tool_attempt.py | ToolAttempt —— 从 EventLog 派生的工具尝试状态(0.45.6 Phase 1)。 |
|
|
76
|
+
| tool_host.py | P6.1 ToolHost:独立 worker process + 一行 JSON IPC。 |
|
|
77
|
+
| tool_ipc.py | ToolHost 进程协议 codec:UTF-8 JSON Lines 字节流。 |
|
|
78
|
+
| tool_worker.py | P6.1 process worker:module:func + UTF-8 JSON Lines 字节协议。 |
|
|
79
|
+
| tools.py | 工具注册与执行模块 |
|
|
80
|
+
| turn_token.py | TurnToken —— 回合取消的一等凭据(0.45.6 Phase 1)。 |
|
|
81
|
+
| turn_transaction.py | TurnTransaction —— 回合终态的显式所有者(0.45.6 Phase 1b)。 |
|
|
82
|
+
| types.py | DeepArche 框架核心数据类型定义 |
|
|
83
|
+
|
|
84
|
+
</details>
|
|
85
|
+
|
|
86
|
+
<details open><summary>🔌 <b>llm/</b> —— 协议(LLM 适配——只依赖 core)(11 模块)</summary>
|
|
87
|
+
|
|
88
|
+
| 模块 | 功能 |
|
|
89
|
+
|------|------|
|
|
90
|
+
| adapter.py | 协议适配器——三协议翻译 + 官方 SDK 委托(非必要不自己做轮子)。 |
|
|
91
|
+
| client.py | LLM 客户端——流式事件归一化(SDK 委托后的薄壳)。 |
|
|
92
|
+
| constants.py | LLM 连接层默认值单源(2026-09-13——工具默认与信息可见性批次·子项 22)。 |
|
|
93
|
+
| fallback.py | FallbackLLM——多 LLM 客户端自动故障转移。 |
|
|
94
|
+
| media.py | 媒体协议层——多模态内容到各协议 wire 块的转换与能力门控(llm 层)。 |
|
|
95
|
+
| pricing.py | 模型定价和成本跟踪模块 |
|
|
96
|
+
| stream_parser.py | SSE 解析公共 helper 模块 |
|
|
97
|
+
| protocols/claude.py | claude 协议策略(Phase 2 2026-10-21)。 |
|
|
98
|
+
| protocols/common.py | 协议公共转换(Phase 2 2026-10-21)。 |
|
|
99
|
+
| protocols/compatible.py | compatible 协议策略(Phase 2 2026-10-21)。 |
|
|
100
|
+
| protocols/responses.py | responses 协议策略(Phase 2 2026-10-21)。 |
|
|
101
|
+
|
|
102
|
+
</details>
|
|
103
|
+
|
|
104
|
+
<details open><summary>🎛️ <b>orch/</b> —— 平台·通用编排(装配/会话/子代理/服务契约——依赖 core+llm,零约定)(33 模块)</summary>
|
|
105
|
+
|
|
106
|
+
| 模块 | 功能 |
|
|
107
|
+
|------|------|
|
|
108
|
+
| approval.py | 审批编排层(2026-08-26——最终精简——规则 + 策略 + 接线;S3 2026-09-12 路径显式化)。 |
|
|
109
|
+
| bootstrap.py | Agent 装配(Bootstrap)——编排层的总装工厂 |
|
|
110
|
+
| event_journal.py | EventJournal——会话事件日志的唯一磁盘写者(阶段 A,2026-10-22)。 |
|
|
111
|
+
| log.py | 会话消息日志(2026-08-05——/revert /sessions resume /save /checkpoint 的数据源; |
|
|
112
|
+
| messages.py | 消息 ↔ Turn 重建(平台·纯函数——S3 2026-09-12 自 product/orch/checkpoint 上收)。 |
|
|
113
|
+
| model_config.py | 模型配置解析(纯函数——平台零约定:S3 2026-09-12)。 |
|
|
114
|
+
| model_descriptor.py | 模型语义描述(平台语义层——展示面的唯一模型编码)。 |
|
|
115
|
+
| persist.py | 回合落盘核心(2026-08-19 #5 步骤2——主/子代理共用单源)。 |
|
|
116
|
+
| providers.py | 多供应商注册与运行时切换(对齐 Kilo provider 机制)。 |
|
|
117
|
+
| resume.py | 会话恢复核心原语(2026-08-19 阶段2——主/子代理共用单源)。 |
|
|
118
|
+
| runtime.py | 编排运行时(A′4 2026-09-12——底座卓越核心)。 |
|
|
119
|
+
| scope.py | 会话级所有权边界(M1.1 2026-10-23)。 |
|
|
120
|
+
| session.py | 会话管理模块,支持缓存友好设计 |
|
|
121
|
+
| session_assembler.py | SessionAssembler 通用协议(orch 层;零产品依赖)。 |
|
|
122
|
+
| session_journal.py | 会话级 EventJournal 生命周期(orch 单一 helper)。 |
|
|
123
|
+
| session_lock.py | 跨进程会话写租约(RES-089——同一 session 单 writable owner)。 |
|
|
124
|
+
| stream.py | 流式消费业务逻辑(2026-08-26——自 api/stream.py 迁入——编排层单源)。 |
|
|
125
|
+
| subagent.py | 子代理(Subagent)编排模块——多 Agent 调度的编排层归属。 |
|
|
126
|
+
| subagent_approval.py | 子代理审批:树级 ApprovalBroker + manager 侧单视图适配。 |
|
|
127
|
+
| subagent_background.py | subagent_background —— subagent.py 拆分(批 A,纯搬运)。 |
|
|
128
|
+
| subagent_config.py | subagent_config —— subagent.py 拆分(批 A,纯搬运):类型/结果/解析。 |
|
|
129
|
+
| subagent_models.py | subagent_models —— subagent.py 拆分(批 A,纯搬运)。 |
|
|
130
|
+
| subagent_sessions.py | subagent_sessions —— subagent.py 拆分(批 A,纯搬运)。 |
|
|
131
|
+
| supervisor.py | P6.2 local Supervisor v1:单机 child 托管 + 心跳 + 预算重启。 |
|
|
132
|
+
| title.py | 会话标题生成(orch 层——2026-08-19 阶段1 合并:主/子代理共用)。 |
|
|
133
|
+
| tool_families.py | 工具族名单(视图元数据——2026-09-10 自 core/tools.py 外迁)。 |
|
|
134
|
+
| transcript.py | UI/审计转录与展示投影(Phase B 2026-10-23;T3 2026-10-31 重写投影)。 |
|
|
135
|
+
| turn.py | 回合服务(2026-08-05——api 层创建;2026-08-26 迁入 orch 层并收敛 run_turn)。 |
|
|
136
|
+
| watcher.py | 文件变更监视器(平台通用——S3 2026-09-12 自 product.orch.instructions 上收)。 |
|
|
137
|
+
| service/contract.py | 渲染安全契约(2026-08-05——api 层:展示层的不可信内容处理规则)。 |
|
|
138
|
+
| service/events.py | 展示事件协议(2026-08-05——api 层:展示无关的"展示就绪事件")。 |
|
|
139
|
+
| service/media.py | 媒体附件构建(2026-08-05 P4——api 展示服务:CLI/TUI 共用的附件解析)。 |
|
|
140
|
+
| service/stream.py | 统一流式消费器(2026-08-05——api 层:core.run_stream 原始事件 → 展示就绪事件; |
|
|
141
|
+
|
|
142
|
+
</details>
|
|
143
|
+
|
|
144
|
+
<details open><summary>🧰 <b>builtin/</b> —— 平台·通用工具(只依赖 core.tools——约定工具归 product/tools)(22 模块)</summary>
|
|
145
|
+
|
|
146
|
+
| 模块 | 功能 |
|
|
147
|
+
|------|------|
|
|
148
|
+
| command_surface.py | 命令面平台 parser(tree-sitter Bash/PowerShell;best-effort,不是完整 shell)。 |
|
|
149
|
+
| file_io.py | 文件读写**保真层**(2026-10-03——file_tools 根本修复的底座)。 |
|
|
150
|
+
| file_tools.py | DeepArche 内置文件工具模块 |
|
|
151
|
+
| ignore_rules.py | ignore 规则单源(gitignore 语义——`file_grep` / `file_glob` 共用)。 |
|
|
152
|
+
| limits.py | 内置工具默认值单源(2026-09-13——工具默认与信息可见性批次·子任务 A/B)。 |
|
|
153
|
+
| mcp.py | MCP(Model Context Protocol)客户端——官方 SDK v2(mcp 2.0.0) |
|
|
154
|
+
| minimal_subagent.py | 极简子代理执行器(通道一——只依赖内核,前台同步执行)。 |
|
|
155
|
+
| model_info_tool.py | model_info 工具注册——模型目录查询(builtin 薄封装——2026-08-19 P3')。 |
|
|
156
|
+
| output_store.py | 工具输出落盘(统一能力——2026-09-13 工具默认与信息可见性批次·子任务 B)。 |
|
|
157
|
+
| paging.py | 分页渲染小助手(builtin 共享单源——2026-09-15)。 |
|
|
158
|
+
| persistent_tool.py | persistent 管理工具族(2026-08-24——模型侧——agent 级——权限链审批) |
|
|
159
|
+
| process_tool.py | 常驻进程能力(Phase 2——2026-10-21)。 |
|
|
160
|
+
| recall_tool.py | recall 工具——记忆目录显式检索(对齐 opencode recall / kilo recall 语义)。 |
|
|
161
|
+
| registry.py | 通用内置工具全集注册(2026-08-04——单一事实源,防工具漂移)。 |
|
|
162
|
+
| repo_map.py | Repo Map — 多语言代码符号图 + PageRank 重要性排序(builtin 内置工具)。 |
|
|
163
|
+
| shell_manual.py | Shell 操作手册工具(按需阅读,零常驻上下文)。 |
|
|
164
|
+
| shell_tool.py | DeepArche 内置 Shell 工具模块 |
|
|
165
|
+
| skills.py | 技能管理器与工具族(builtin 独立工具域——2026-08-24 方案 C 定稿) |
|
|
166
|
+
| subagent_tool.py | subagent 工具注册——模型可见的子代理调用接口(builtin 薄封装)。 |
|
|
167
|
+
| todo_tool.py | todo 工具——任务清单跟踪(对齐 kilo todo.ts:任务分解/状态跟踪)。 |
|
|
168
|
+
| webfetch_tool.py | webfetch 工具——URL 抓取(对齐 kilo webfetch.ts:简单文本提取)。 |
|
|
169
|
+
| websearch_tool.py | web_search 工具(0.44.0)。 |
|
|
170
|
+
|
|
171
|
+
</details>
|
|
172
|
+
|
|
173
|
+
<details open><summary>📦 <b>product/</b> —— 产品层(产品编排/服务契约/展示——第一个产品:harness/CLI)(95 模块)</summary>
|
|
174
|
+
|
|
175
|
+
| 模块 | 功能 |
|
|
176
|
+
|------|------|
|
|
177
|
+
| agent.py | DeepArche Agent 门面(生产级同构调用层——教学/嵌入入口)。 |
|
|
178
|
+
| api/commands.py | 命令注册表(2026-08-05——api 层:业务命令装配;2026-08-26 薄壳化)。 |
|
|
179
|
+
| api/config.py | 前端配置组合适配(API 稳定面薄包装——2026-11-17 OUT-000308)。 |
|
|
180
|
+
| api/display.py | API 展示面值对象与错误(不依赖具体 Display/Channel)。 |
|
|
181
|
+
| api/owner.py | RuntimeOwner:展示层的唯一 ProductRuntime 创建/关闭入口。 |
|
|
182
|
+
| api/runtime.py | 产品运行时(B3 2026-09-12——对外服务面:任意前端)。 |
|
|
183
|
+
| assets/example_assets.py | 示例资产定位器(**单源**——T8 2026-10-06)。 |
|
|
184
|
+
| channels/builtin.py | 内置渠道声明(仅 CLI;不启动运行时)。 |
|
|
185
|
+
| channels/contract.py | 渠道契约(扩展层;不依赖 product.orch 业务)。 |
|
|
186
|
+
| channels/launcher.py | 薄渠道 Launcher:只做发现后的工厂激活与 Display 生命周期。 |
|
|
187
|
+
| channels/registry.py | 渠道注册/发现(只登记声明;不 import entry、不启动 transport)。 |
|
|
188
|
+
| cli/__main__.py | DeepArche CLI 统一入口(2026-08-16——pip 发行版落地:python -m deeparche.product.cli)。 |
|
|
189
|
+
| cli/approval_ui.py | CLI 审批与确认对话框(B3 2026-09-12——自 cli/main.py 拆出)。 |
|
|
190
|
+
| cli/auth.py | auth 快速配置向导(2026-08-15 配置层级 v2——R11-b)。 |
|
|
191
|
+
| cli/banner.py | CLI 信任展示与历史渲染(B3 2026-09-12——自 cli/main.py 拆出)。 |
|
|
192
|
+
| cli/colors.py | CLI ANSI 颜色常量(单源——2026-08-14 P3 边角清理)。 |
|
|
193
|
+
| cli/commands.py | CLI 命令处理器模块 |
|
|
194
|
+
| cli/consume.py | CLI 反馈与流式消费(B3 2026-09-12——自 cli/main.py 拆出)。 |
|
|
195
|
+
| cli/display_state.py | CLI 显示模式状态(B3 2026-09-12——跨模块单源)。 |
|
|
196
|
+
| cli/history.py | 输出历史(product/cli——Phase 4 2026-10-21 由 core.display 迁入)。 |
|
|
197
|
+
| cli/input_stack.py | CLI 输入栈(B3 2026-09-12——自 cli/main.py 拆出)。 |
|
|
198
|
+
| cli/main.py | DeepArche CLI 入口点模块 |
|
|
199
|
+
| cli/media.py | CLI 媒体与剪贴板输入(B3 2026-09-12——自 cli/main.py 拆出)。 |
|
|
200
|
+
| cli/picker.py | 可复用交互式选择器 |
|
|
201
|
+
| cli/queue_wiring.py | CLI 输入队列接线(批5 2026-09-22——四类 handler 全部指向既有 CLI 路径)。 |
|
|
202
|
+
| cli/renderer.py | CLI 输出显示渲染器模块 |
|
|
203
|
+
| cli/repl.py | CLI 交互循环(B3 2026-09-12——自 cli/main.py 拆出)。 |
|
|
204
|
+
| cli/startup.py | 启动台统一渲染(2026-10-20 · item 2)。 |
|
|
205
|
+
| cli/supervise.py | P6.2 CLI adapter:`--supervise` 包装现有 --task / `/sessions resume` 路径。 |
|
|
206
|
+
| cli/tasks.py | CLI 任务模式(B3 2026-09-12——自 cli/main.py 拆出)。 |
|
|
207
|
+
| host/lifecycle.py | 渠道宿主生命周期与终端中断适配(组合根内部状态机)。 |
|
|
208
|
+
| host/options.py | 渠道宿主启动选项(中性值对象——不依赖 argparse/CLI 命名空间)。 |
|
|
209
|
+
| host/runtime_host.py | 渠道宿主运行时组合根:`launch_host(options, registry=...)`。 |
|
|
210
|
+
| manifest/discover.py | 清单包发现(批 C2 2026-09-22)。 |
|
|
211
|
+
| manifest/loader.py | 统一清单包加载器(Manifest Pack——批 C1 2026-09-22)。 |
|
|
212
|
+
| orch/agent_config.py | 智能体配置字段注册表与合并状态机(0.50.0 PLAN-000351 Phase 2)。 |
|
|
213
|
+
| orch/agents.py | 智能体预设(Agent Preset)编排模块——用户快速设计/编排/分享智能体。 |
|
|
214
|
+
| orch/app.py | 产品应用装配层(B3 2026-09-12——自 cli/main.py 下沉)。 |
|
|
215
|
+
| orch/approval.py | 产品审批接线(S3 2026-09-12——平台闭包评估 + 产品路径约定)。 |
|
|
216
|
+
| orch/approval_api.py | approval_api —— 审批的**统一契约 / 注册点 / 跨进程总线**(T3-P1,产品层)。 |
|
|
217
|
+
| orch/approval_command.py | approval_command —— 审批的**命令式展示面**与总线同步桥(T3-P1 第 2 批)。 |
|
|
218
|
+
| orch/approval_modes.py | 审批模式单源(2026-09-29——`/approval` 命令 + 三端接线)。 |
|
|
219
|
+
| orch/approval_pending.py | scope-owned approval service(M1.2c 2026-10-24)。 |
|
|
220
|
+
| orch/approval_presenters.py | approval_presenters —— 审批**展示方**的选择单源(P2.5,产品层)。 |
|
|
221
|
+
| orch/approval_relay.py | approval_relay —— 跨 agent / 跨会话的审批转交与作答(T3-P2,产品层)。 |
|
|
222
|
+
| orch/assembly.py | 会话装配服务(2026-08-04——编排服务化:统一编排层)。 |
|
|
223
|
+
| orch/auto_title.py | 会话自动命名(S2 2026-09-23——通道 C `title` Spec;2026-10-13 接线根治)。 |
|
|
224
|
+
| orch/cache_keeper.py | Prompt Cache 保活(2026-10-21 AUDIT-CACHE-TTL-002)。 |
|
|
225
|
+
| orch/capabilities.py | 能力快照与变更通知(A5——2026-09-15 用户定稿)。 |
|
|
226
|
+
| orch/channel.py | 渠道契约(Phase 4 2026-10-21)。 |
|
|
227
|
+
| orch/checkpoint.py | 检查点与代码回滚——git 快照仓库方案(对齐 Kilo Snapshot 服务,零用户 git 冲突)。 |
|
|
228
|
+
| orch/command_args.py | 命令参数候选解析(S3 2026-09-26)——**唯一候选源**。 |
|
|
229
|
+
| orch/command_audit.py | 命令审计落盘(**单源**——CLI 与服务面共用,2026-10-17)。 |
|
|
230
|
+
| orch/command_completion.py | slash 命令补全 resolver(CLI/API **同一入口**)。 |
|
|
231
|
+
| orch/command_visibility.py | 命令展示可见性策略(产品展示投影——2026-12-01 OUT-000566)。 |
|
|
232
|
+
| orch/completion_view.py | 只读补全数据视图(**不读盘/不改状态**)。 |
|
|
233
|
+
| orch/config.py | 产品配置管理——两级来源(2026-10-03 配置来源统一;S3 2026-09-12 自 orch/config.py 迁入产品层)。 |
|
|
234
|
+
| orch/config_compose.py | 配置字段组合语义(产品层单点——2026-11-17 OUT-000308)。 |
|
|
235
|
+
| orch/config_manager.py | 统一配置管理器(2026-09-30 新建 —— 目标 ③ 内核切片)。 |
|
|
236
|
+
| orch/config_write.py | 配置写回(2026-09-30 新建)——**唯一的 TOML 写入口**(路径单一)。 |
|
|
237
|
+
| orch/console.py | 终端控制台卫生(产品级共享——终端入口单源:CLI 主入口 / 桌面/服务型入口)。 |
|
|
238
|
+
| orch/continuation.py | 会话内「回合间续跑」的**统一入口**(2026-10-11 用户裁定)。 |
|
|
239
|
+
| orch/cost_view.py | 父成本只读派生视图(M1.1b 2026-10-23)。 |
|
|
240
|
+
| orch/env.py | 产品环境变量加载(A′5 2026-09-12——自 cli/main.py 抽出,CLI 与 Agent 门面共用)。 |
|
|
241
|
+
| orch/goal.py | goal —— **会话级目标状态机**(P3,产品层)。 |
|
|
242
|
+
| orch/goal_lifecycle.py | goal 生命周期单一入口(F1,2026-11-23)。 |
|
|
243
|
+
| orch/goal_projection.py | goal 状态投影(**唯一 writer**:goal.json → user 前缀块)。 |
|
|
244
|
+
| orch/hooks_loader.py | Hook 配置级加载器(2026-08-16——A2:配置级 hook 注册通道)。 |
|
|
245
|
+
| orch/hot_reload.py | 热重载管理器(2026-08-24 建;2026-11-30 P2b 改为 always-on 配置)。 |
|
|
246
|
+
| orch/input_queue.py | 单会话输入队列(批4 2026-09-22——产品/服务面;不进 core 六件事)。 |
|
|
247
|
+
| orch/instructions.py | 指令加载与文件监视——Kilo SystemContext 同构实现(更省 token 版本)。 |
|
|
248
|
+
| orch/internal_events.py | 内部事件通道(**用户可见、模型不可见**——2026-10-17)。 |
|
|
249
|
+
| orch/model_presentation.py | 模型展示投影(产品展示层——只消费 ModelDescriptor)。 |
|
|
250
|
+
| orch/model_state.py | 模型派生状态的**单点解析与应用**(2026-10-20 装配链审计 · S1)。 |
|
|
251
|
+
| orch/paths.py | 产品路径约定(单源——平台零约定:S3 2026-09-12)。 |
|
|
252
|
+
| orch/reload.py | 工作区切换(重装配 + 新会话)——序列单源(2026-10-15)。 |
|
|
253
|
+
| orch/restore.py | 会话恢复单源(2026-09-14——"产品级单入口")。 |
|
|
254
|
+
| orch/revert.py | 回滚/撤销引擎——**event_id / seq 单坐标**(0.44.4 T4)。 |
|
|
255
|
+
| orch/reviewer.py | 审批 reviewer 决策器(产品——**通道 C `reviewer` Spec**;批 S1 迁移 2026-09-23)。 |
|
|
256
|
+
| orch/roles.py | 存储 role 词表(**产品自持**——2026-10-17)。 |
|
|
257
|
+
| orch/sandbox_policy.py | 沙箱失败策略(产品层单点——2026-09-18 批 A 硬化)。 |
|
|
258
|
+
| orch/session_store.py | 会话存储装配(**构造单源**)+ 会话旁路产物名册(**生命周期单源**)。 |
|
|
259
|
+
| orch/system_notice.py | 系统通知标记(**单源**——2026-10-14 用户裁定)。 |
|
|
260
|
+
| orch/template.py | 统一模板占位符(H1 2026-09-25)——**唯一 render 入口**。 |
|
|
261
|
+
| orch/tool_risk.py | 工具风险行(单源)——ToolDef 元数据 → 人可读风险描述。 |
|
|
262
|
+
| orch/tools_loader.py | 用户工具配置级加载器(2026-08-18 v2——tool.toml 目录包方案)。 |
|
|
263
|
+
| orch/transcript_view.py | 中性 transcript → 展示消息(Phase B 2026-10-23)。 |
|
|
264
|
+
| orch/turn_boundary.py | 回合边界刷新(`detach` 语义配套)——**单源**(2026-10-13)。 |
|
|
265
|
+
| orch/workspaces.py | 工作区信任清单(`deeparche.toml` `[workspace]` 键控条目——**配置即声明**)。 |
|
|
266
|
+
| tools/_state.py | 工具状态存储策略(**工具自持** —— 完整落盘策略,供同层工具共享)。 |
|
|
267
|
+
| tools/capability_set.py | scoped registry 构建(0.50.0 Phase 3——DEC-000099 D19/D20a/D26)。 |
|
|
268
|
+
| tools/hot_reload_tool.py | 热重载工具(product:hot_reload pack)与 `/reload` 全局命令(2026-12-02 P4)。 |
|
|
269
|
+
| tools/namespace.py | 工具命名空间与注册计划(0.44.0 D)。 |
|
|
270
|
+
| tools/policy.py | 工具面策略(0.50.0——`[tools.policy]` 六字段的唯一实现)。 |
|
|
271
|
+
| tools/registry.py | 产品工具管理器/注册器(S3 2026-09-12——平台零约定 + 产品默认接线)。 |
|
|
272
|
+
|
|
273
|
+
</details>
|
|
274
|
+
|
|
275
|
+
<details open><summary>🛠️ <b>scripts/</b> —— 工具脚本(检查器/生成器/基准——零运行路径)(39 模块)</summary>
|
|
276
|
+
|
|
277
|
+
| 模块 | 功能 |
|
|
278
|
+
|------|------|
|
|
279
|
+
| bench_session_io.py | — |
|
|
280
|
+
| benchmark.py | 微基准(B2 2026-09-12——底座性能回归基线)。 |
|
|
281
|
+
| build_dists.py | — |
|
|
282
|
+
| capability_surface.py | — |
|
|
283
|
+
| check_cache_epoch.py | — |
|
|
284
|
+
| check_capability_matrix.py | — |
|
|
285
|
+
| check_command_completion.py | 命令补全体系 —— **端到端检查**(P0-1,2026-10-12)。 |
|
|
286
|
+
| check_dependencies.py | — |
|
|
287
|
+
| check_dist_manifest.py | — |
|
|
288
|
+
| check_doc_drift.py | — |
|
|
289
|
+
| check_face_residue.py | — |
|
|
290
|
+
| check_feature_tree.py | — |
|
|
291
|
+
| check_lint.py | — |
|
|
292
|
+
| check_model_state_single_source.py | — |
|
|
293
|
+
| check_python_syntax.py | check_python_syntax —— 解释器契约 + 全量语法闸门(2026-10-09)。 |
|
|
294
|
+
| check_retired_symbols.py | — |
|
|
295
|
+
| check_scratch_isolation.py | — |
|
|
296
|
+
| check_single_source.py | — |
|
|
297
|
+
| check_spawn_no_window.py | — |
|
|
298
|
+
| check_temp_dir_source.py | — |
|
|
299
|
+
| check_terminology.py | 术语/语义一致性检查——防止双名称与**语义漂移**导致维护性崩塌。 |
|
|
300
|
+
| check_test_ownership.py | — |
|
|
301
|
+
| check_tests_hermetic.py | — |
|
|
302
|
+
| check_transcript_paths.py | — |
|
|
303
|
+
| check_workdir_source.py | — |
|
|
304
|
+
| cli_interactive_check.py | — |
|
|
305
|
+
| contracts_snapshot_lib.py | 公共 API 契约快照构建(Phase 0 2026-10-21)。 |
|
|
306
|
+
| eval_basic.py | — |
|
|
307
|
+
| gen_contracts_snapshot.py | — |
|
|
308
|
+
| gen_feature_tree.py | — |
|
|
309
|
+
| manual_session_lock_check.py | — |
|
|
310
|
+
| probe_multimodal.py | — |
|
|
311
|
+
| public_snapshot_check.py | — |
|
|
312
|
+
| run_all_tests.py | — |
|
|
313
|
+
| scratch.py | — |
|
|
314
|
+
| scratch_run.py | — |
|
|
315
|
+
| smoke_api.py | — |
|
|
316
|
+
| stress_session.py | — |
|
|
317
|
+
| tool_conflicts.py | — |
|
|
318
|
+
|
|
319
|
+
</details>
|
|
320
|
+
|
|
321
|
+
### 接入点总览
|
|
322
|
+
|
|
323
|
+
#### 业务命令(api CommandRegistry——31 个)
|
|
324
|
+
|
|
325
|
+
| 命令 | 说明 |
|
|
326
|
+
|------|------|
|
|
327
|
+
| `/agent` | 切换智能体预设 |
|
|
328
|
+
| `/approval` | 审批两轴:status \| mode <full\|reviewer\|manual\|status\|reset>(谁判)\| presenter <auto\|local\|bus\|status\|reset>(怎么问) |
|
|
329
|
+
| `/auth` | API 密钥快速配置指引:guide\|status\|reauth <id>\|reconfigure <id>\|help(只读;真实写入用 deeparche config auth) |
|
|
330
|
+
| `/cancel` | 中断当前回合(与 Ctrl+C 同源) |
|
|
331
|
+
| `/cd` | /cd <路径>:切换工作目录(未登记目录需先 /workspace add) |
|
|
332
|
+
| `/checkpoint` | 记录代码检查点(git 快照仓库) |
|
|
333
|
+
| `/checkpoints` | 列出全部检查点 |
|
|
334
|
+
| `/cleanup` | 上下文清理:status [--ids] \| preview <media\|tool_results\|all> <before_current\|older_than:N(示例 older_than:12)> \| apply ... \| restore <op-id>(只改模型请求投影,不改 EventLog 原文) |
|
|
335
|
+
| `/compact` | 立即压缩上下文 |
|
|
336
|
+
| `/config` | 显示当前配置(list/show/set/unset/backups [--ids]/restore;flag:--file deeparche\|permissions;list packages = 包目录/来源/状态;restore 备份不存在 = 用户错误) |
|
|
337
|
+
| `/cost` | 显示成本统计 |
|
|
338
|
+
| `/cost-display` | 成本显示开关:/cost-display [on\|off\|status](无参 = 切换) |
|
|
339
|
+
| `/decide` | 审批作答:/decide <id> allow\|deny\|remember [--as <agent-id>] |
|
|
340
|
+
| `/diff` | 查看最近变更 diff(git unified diff) |
|
|
341
|
+
| `/fork` | 从当前会话分叉出新会话 |
|
|
342
|
+
| `/help` | 列出全部命令(注册表单源);/help <命令> 看单条详情与参数候选 |
|
|
343
|
+
| `/max-turns` | 设置本会话最大轮次 <N>(0 = 不限制;常用 0/10/20/50/100) |
|
|
344
|
+
| `/model` | 切换模型 |
|
|
345
|
+
| `/name` | 给当前会话命名:/name <名称>(指定会话用 /sessions rename;名称可任意,含空格请加引号) |
|
|
346
|
+
| `/new` | 开始新对话(原会话保留,上下文重置) |
|
|
347
|
+
| `/pending` | 列出待批审批(跨进程总线);/pending [<id> \| --ids] |
|
|
348
|
+
| `/provider` | 切换供应商 |
|
|
349
|
+
| `/pwd` | 显示生效工作目录 + 命中的工作区 |
|
|
350
|
+
| `/reload` | 触发一次工具面热重载(/reload [tools\|mcp];全局 always-on,不随 product:hot_reload 策略消失) |
|
|
351
|
+
| `/revert` | 回退分层:status(只读栈/用法)\| both [n\|检查点](文件+上下文,默认 1)\| context [n\|检查点](仅上下文,文件保持现状)\| files [n\|检查点](仅文件,上下文保持现状)\| undo [n](按栈条目 scope 撤销,默认 1);根 /revert 无参只显示状态/用法 |
|
|
352
|
+
| `/sandbox` | 沙箱:status(状态)\| mode <auto\|docker\|subprocess\|passthrough\|capability_guard>(切换并写回 [sandbox].mode) |
|
|
353
|
+
| `/save` | 保存会话 |
|
|
354
|
+
| `/sessions` | 会话:list [main\|subagent\|all] [--limit N] [--tree\|--flat] [--ids] \| resume <main\|subagent\|all> [<完整id>] [--detach\|--promote] \| show <完整id> [--limit N] \| rename <完整id> <名称> \| copy [<完整id>] --to <工作区> [--move] \| delete <完整id> |
|
|
355
|
+
| `/thinking` | 切换思考深度(无参循环/带参指定) |
|
|
356
|
+
| `/verbose` | 明细显示开关:/verbose [on\|off\|status](无参 = 切换) |
|
|
357
|
+
| `/workspace` | 工作区登记(tree/list [--ids]/add [路径]/remove/use/rename;add 缺省 = 当前工作目录) |
|
|
358
|
+
|
|
359
|
+
#### 模型可见工具(builtin 注册面——30 个)
|
|
360
|
+
|
|
361
|
+
> subagent 工具族(subagent/subagent_wait/subagent_status/subagent_cancel/subagent_session/subagent_list/subagent_cancel_all——2026-08-19 管理工具集完备)经展示层回调注入;MCP 工具(mcp__{name}__{tool})随配置动态。
|
|
362
|
+
|
|
363
|
+
| 工具 | 说明 |
|
|
364
|
+
|------|------|
|
|
365
|
+
| `code_index` | 语义检索工作区代码:index 建立/更新向量索引,query 按语义相似度返回相关代码位置(path:行区间 + score),status 查看索引状态,reset 删除本工具索引。需在 deeparche.toml 配置 [tools.code_index](embedding 接口与模型)。 |
|
|
366
|
+
| `config_info` | DeepArche 配置说明书。只读参考:不读取用户当前配置,不写文件。何时使用:用户问某功能“怎么配置”、某节/键是什么意思、需要唯一示例源中的可粘贴 TOML 片段、查看包目录(topic=packages)或 /tools 包状态(topic=tools),或需要扩展契约(topic=extend)。何时不要使用:查询当前生效值用 /config show\|list;修改配置用 /conf… |
|
|
367
|
+
| `feishu_send` | 经飞书应用机器人或自定义机器人发送出站通知:文本/Markdown/post/卡片、命名 target、reply/thread/mentions。 |
|
|
368
|
+
| `feishu_send_media` | 经飞书发送本地图片/文件/音频/视频(视频原生 media 消息;可选 cover_path 作为视频封面);路径只能是 work_dir 内本地文件,不接受 URL。若提供 text,会先单独发送一条文本,再发送媒体;每个媒体条目各发一条消息(消息数 = (text?1:0) + 媒体条目数)。 |
|
|
369
|
+
| `feishu_targets` | 列出飞书 enabled 命名目标(name/kind/label/tags/default)。 |
|
|
370
|
+
| `file_edit` | 编辑文件。用 new_string 替换 old_string(精确匹配,且必须唯一);匹配按 LF 语义(CRLF 文件同样可用),写回**保持原文件的编码与换行风格**。未命中时返回最相近的行与相似度(**仅提示**,不会自动改动文件);多匹配时回出现行号;成功后附带变更行摘要(无需再读一遍确认)。 |
|
|
371
|
+
| `file_glob` | 文件名模式匹配(内置 glob)。支持 **/*.py、src/**/*.ts 等模式;返回匹配文件路径(**稳定排序**),默认上限 2000 条(max_results;0=不限)。默认遵守工作区 ignore 文件并跳过 .git/node_modules 等目录;需要连同被忽略的文件一起找时传 no_ignore=true(同时不跳过隐藏项;skip_dirs 仍由配置决定)。 |
|
|
372
|
+
| `file_grep` | 内容搜索(内置正则,任何环境可用)。递归搜索目录内文件,支持 include/exclude 过滤(如 *.py、*.{ts,tsx})。命中行格式 文件:行号:内容,上下文行格式 文件-行号-内容,块间以 -- 分隔;结果按路径与行号**稳定排序**。multiline=true 跨行匹配(如整块标签/结构);literal=true 按字面量搜索(免手工转义)。需要看命中附近代码时直接用 b… |
|
|
373
|
+
| `file_read` | 读取文件或目录。文件:支持 offset/limit 分页(默认 500 行;limit<=0 = 全部行),每行带**行号前缀**(line_numbers 默认 true;行号仅供定位,**不要**写进 file_edit 的 old_string);页脚给出总行数、续读 offset 与编码/换行/大小事实。文本按**原文件编码**解码(UTF-8 家族;其它编码需在 [tools.fil… |
|
|
374
|
+
| `file_write` | 写入文件(覆盖已有内容)。覆盖时**保持原文件的编码与换行风格**(原文件编码无法识别 ⇒ 拒绝覆盖,不损坏原文);新建文件为 UTF-8 + LF。 |
|
|
375
|
+
| `goal_done` | **结项**本会话目标(此后不再有「待唤醒」语义;可再建新目标)。**目标被用户锁定时**:不结项,而是**降级为暂停**(把决定权交回用户)。 |
|
|
376
|
+
| `goal_pause` | **暂停**本会话目标(此后不记回合;继续需唤醒)。 |
|
|
377
|
+
| `goal_resume` | **唤醒**本会话目标(仅对暂停态有效)。因轮次/成本越界自动暂停的目标**需用户加预算**(`/goal resume --rounds +N/--cost +M`)——本工具不接受预算,避免模型自行放宽上限。 |
|
|
378
|
+
| `goal_set` | 建立**本会话的目标**(状态机;同一时刻仅 1 个活跃目标)。预算可选:**只能传收紧值**(≤ 配置 `[tools.goal]` 上限;超过即拒绝;配置为 0 时该键**无上限**,可传任意值)——放宽预算请由用户 `/goal set --rounds/--cost`。状态属**本会话**(随会话保存:`/sessions resume` 恢复、`/fork` 复制;`/new` 开新会… |
|
|
379
|
+
| `goal_status` | 查看**本会话目标**当前状态(状态/预算/已用轮次与成本/连续无进展/最近唤醒记录;越界时给出续跑指引)。 |
|
|
380
|
+
| `goal_update` | **修改**本会话目标正文(实现过程微调)。**锁定态 ⇒ 拒绝**(用户 `/goal lock` 之后,模型不得修改/变更/关闭目标;**暂停与继续推进不受限**)。只能改正文——**预算属用户**(本工具不接受预算参数)。 |
|
|
381
|
+
| `hot_reload` | 触发一次**工具面热重载**(源:tools = 用户工具 / 当前智能体工具 / 渠道工具根;mcp = 全局 + 当前智能体 MCP)——重新读取磁盘并应用,**无需重启进程**。无源时明确返回 no sources。源集合由 `[tools] hot_reload_sources_mode`(extend\|replace)与 `hot_reload_sources`(tools\|mcp)决… |
|
|
382
|
+
| `process_output` | 读取常驻进程日志尾部(默认 200 行,最多 2000 行;只返回尾部以避免输出撑爆上下文)。 |
|
|
383
|
+
| `process_start` | 启动常驻进程(开发服务器、监听端口、watch、长任务)。返回 id/pid/log 路径;用 process_status / process_output / process_stop 管理。**不要**用 shell_execute 的 Start-Process / nohup / & 启动常驻进程——前台命令结束会清理后代。 |
|
|
384
|
+
| `process_status` | 查询常驻进程状态;省略 id 列出当前工作区全部进程。active>0 表示直接进程已退出但仍有后代存活,可用 process_stop 清理。 |
|
|
385
|
+
| `process_stop` | 停止常驻进程及其后代(Job Object / 进程组;有界回收)。已退出的进程也可调用,用于清理残留后代。 |
|
|
386
|
+
| `recall` | 检索长期记忆目录中的历史记录——关键词匹配返回命中片段(默认上限 50 条;max_hits=0 不限;含总数页脚);用于跨会话回顾决策/约定/教训 |
|
|
387
|
+
| `repo_map` | Scan the project and return a multi-language code symbol map (Python/JavaScript/TypeScript/Go/Rust/Java/C/C++/C#/Ruby/PHP; classes, functions, methods, types ranked by importance) to understand proje… |
|
|
388
|
+
| `shell_execute` | 执行 shell 命令(平台 shell),返回 stdout + stderr。文件读写/搜索优先用专用工具(file_read/file_write/file_edit、repo_map),内容搜索用 rg(三端互通)勿用 grep;目录树用 Get-ChildItem -Recurse 勿用 tree;不确定命令用法或推荐命令时先调用 shell_manual 阅读手册。 |
|
|
389
|
+
| `shell_manual` | Shell 操作手册(按需阅读):三端互通命令优先(rg/fd/jq),PowerShell/cmd/Unix 语法要点与命令对照表。不确定命令用法或想确认推荐命令时调用。 |
|
|
390
|
+
| `todo` | 任务清单跟踪:add 添加 / update 更新状态 / edit 改描述 / delete 删除 / list 列出(可过滤)——状态 pending/in_progress/completed/cancelled;用于多步骤任务分解与进度跟踪 |
|
|
391
|
+
| `tools_audit` | **harness 工具审计**:列出当前 工具面/命令面 与各工具声明的能力(只读/写本地/网络/执行、作用域、风险等级),供用户核对「引入了什么、能做什么、风险多高」。只读;top/offset 分页。 |
|
|
392
|
+
| `webfetch` | 只读抓取 URL(http/https;仅 GET/HEAD)。支持 headers/API-key header;format=text\|markdown\|raw;返回状态码/最终 URL/content-type/charset/title。超预算自动落盘(返回预览+路径)。 |
|
|
393
|
+
| `webfetch_mutate` | 对 URL 执行有副作用的 HTTP 方法(POST/PUT/PATCH/DELETE)。高风险、需审批;支持 headers/body/API-key header;不跟随重定向、不自动重试;不托管 cookie/session/OAuth。 |
|
|
394
|
+
| `workspace_scaffold` | 创建新的 DeepArche 项目/Agent 工作区骨架。仅在用户明确要求新建工作区,或已批准创建计划后调用。模式:library(可运行的最小项目)、vendor(复制运行时代码,深度定制)、docs_only(只生成说明)。不要用于:配置问答、修改已有项目、添加单个工具/Skill、只是讨论架构或方案。副作用:写入 path/name 目录(path 缺省=装配期 work_dir;相对… |
|
|
395
|
+
|
|
396
|
+
#### CLI 参数(--xxx——16 个)
|
|
397
|
+
|
|
398
|
+
| 参数 | 说明 |
|
|
399
|
+
|------|------|
|
|
400
|
+
| `--version` | 显示版本并退出 |
|
|
401
|
+
| `--task` | 执行任务步骤后退出(可重复——与 --exec 按 argv 顺序全部执行) |
|
|
402
|
+
| `--exec` | 启动即执行命令(可重复——按 argv 顺序执行;与交互输入 /xxx 同一命令注册表、同 handler;可与 --task 混排按序执行;示例 --exec "/sessions resume all <id>"、--exec "/c… |
|
|
403
|
+
| `--session` | 启动前恢复精确会话 ID,再进入 REPL/--task/--exec |
|
|
404
|
+
| `--supervise` | P6.2 本地 supervisor:托管 --task 或 --exec "/sessions resume <main\|subagent\|all> <id>" 子进程,崩溃/挂起后按预算重启(不自动重放任务;调参见 [supervis… |
|
|
405
|
+
| `--work-dir` | 工作目录(缺省 = 当前目录)。与运行时 /cd 同源(resolve_work_dir 单源,见 product/orch/config.py) |
|
|
406
|
+
| `--allow-workdir` | 显式授权未登记的启动工作目录(本次启动生效——记入审计日志)。语义:'我确认允许 harness 操作该目录';路径须与实际工作目录一致(防复制粘贴误授权其他目录) |
|
|
407
|
+
| `--image` | 图片附件(可多次;本地文件自动 base64,URL 直传) |
|
|
408
|
+
| `--audio` | 音频附件(可多次;本地文件自动 base64,URL 直传) |
|
|
409
|
+
| `--video` | 视频附件(可多次;本地文件自动 base64,URL 直传) |
|
|
410
|
+
| `--channel` | 启动渠道(缺省 cli;可选值由当前工作区 enabled 渠道动态给出) |
|
|
411
|
+
| `--allow-shadow` | 仅与 config init --target local 搭配:非交互确认创建 local 并遮蔽 user(交互模式优先询问 y/N) |
|
|
412
|
+
| `--provider` | 指定 provider id(配合 --reauth/--reconfigure) |
|
|
413
|
+
| `--reauth` | 只轮换 .env 凭证,不改 TOML 定义 |
|
|
414
|
+
| `--reconfigure` | 显式修改 provider 定义并写 .env |
|
|
415
|
+
| `--target` | config init/auth 的写入层:local=.deeparche / user=~/.deeparche;auth 要求所选层已存在(先 config init);init --target local 可在 user 唯一来… |
|
|
416
|
+
|
|
417
|
+
#### 配置键(deeparche.example.toml——权威基准;来源唯一:本地级 > 用户级)
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
[agent]
|
|
421
|
+
provider = mimo
|
|
422
|
+
[models]
|
|
423
|
+
[models.*]
|
|
424
|
+
thinking = True
|
|
425
|
+
thinking_effort = high
|
|
426
|
+
thinking_efforts = [...](5 项)
|
|
427
|
+
max_output_tokens = 131072
|
|
428
|
+
context_window = 1048576
|
|
429
|
+
[models.mimo-v2.6-pro]
|
|
430
|
+
thinking_effort = high
|
|
431
|
+
thinking_efforts = [...](3 项)
|
|
432
|
+
modalities = [...](4 项)
|
|
433
|
+
video_fps = 2.0
|
|
434
|
+
video_resolution = default
|
|
435
|
+
context_window = 1048576
|
|
436
|
+
max_output_tokens = 131072
|
|
437
|
+
[models.mimo-v2.6-flash]
|
|
438
|
+
thinking_effort = medium
|
|
439
|
+
thinking_efforts = [...](3 项)
|
|
440
|
+
modalities = [...](4 项)
|
|
441
|
+
video_fps = 2.0
|
|
442
|
+
video_resolution = default
|
|
443
|
+
context_window = 1048576
|
|
444
|
+
max_output_tokens = 131072
|
|
445
|
+
[models.mimo-v2.6-pro-ultraspeed]
|
|
446
|
+
thinking_effort = high
|
|
447
|
+
thinking_efforts = [...](3 项)
|
|
448
|
+
modalities = [...](4 项)
|
|
449
|
+
video_fps = 2.0
|
|
450
|
+
video_resolution = default
|
|
451
|
+
context_window = 1048576
|
|
452
|
+
max_output_tokens = 131072
|
|
453
|
+
[models.deepseek-v4-pro]
|
|
454
|
+
thinking_effort = max
|
|
455
|
+
thinking_efforts = [...](4 项)
|
|
456
|
+
max_output_tokens = 393216
|
|
457
|
+
context_window = 1048576
|
|
458
|
+
[models.deepseek-flash]
|
|
459
|
+
thinking_effort = low
|
|
460
|
+
thinking_efforts = [...](4 项)
|
|
461
|
+
max_output_tokens = 393216
|
|
462
|
+
context_window = 1048576
|
|
463
|
+
modalities = [...](2 项)
|
|
464
|
+
[models.deepseek-v4.1-flash]
|
|
465
|
+
thinking_effort = low
|
|
466
|
+
thinking_efforts = [...](4 项)
|
|
467
|
+
max_output_tokens = 393216
|
|
468
|
+
context_window = 1048576
|
|
469
|
+
modalities = [...](2 项)
|
|
470
|
+
[models.opendesign/mimo-v2.6-pro]
|
|
471
|
+
inherits = mimo-v2.6-pro
|
|
472
|
+
modalities = [...](3 项)
|
|
473
|
+
[models.opendesign/mimo-v2.6-flash]
|
|
474
|
+
inherits = mimo-v2.6-flash
|
|
475
|
+
modalities = [...](3 项)
|
|
476
|
+
[models.deepseek-v4.1-flash-eco]
|
|
477
|
+
inherits = deepseek-v4.1-flash
|
|
478
|
+
[providers]
|
|
479
|
+
[providers.mimo]
|
|
480
|
+
name = MiMo
|
|
481
|
+
base_url = https://api.xiaomimimo.com
|
|
482
|
+
api_key = ${MIMO_API_KEY}
|
|
483
|
+
protocol = compatible
|
|
484
|
+
[providers.mimo.pricing]
|
|
485
|
+
mimo-v2.6-pro = mimo-pro
|
|
486
|
+
mimo-v2.6-flash = mimo-flash
|
|
487
|
+
mimo-v2.6-pro-ultraspeed = mimo-ultraspeed
|
|
488
|
+
models = [...](3 项)
|
|
489
|
+
default_model = mimo-v2.6-flash
|
|
490
|
+
[providers.deepseek]
|
|
491
|
+
name = DeepSeek
|
|
492
|
+
base_url = https://api.deepseek.com
|
|
493
|
+
api_key = ${DEEPSEEK_API_KEY}
|
|
494
|
+
protocol = compatible
|
|
495
|
+
[providers.deepseek.pricing]
|
|
496
|
+
deepseek-v4-pro = deepseek-pro
|
|
497
|
+
deepseek-flash = deepseek-flash
|
|
498
|
+
models = [...](2 项)
|
|
499
|
+
default_model = deepseek-flash
|
|
500
|
+
[providers.opencode-go]
|
|
501
|
+
name = OpenCode-Go
|
|
502
|
+
base_url = https://opencode.ai/zen/go
|
|
503
|
+
api_key = ${OPENCODE_GO_API_KEY}
|
|
504
|
+
protocol = compatible
|
|
505
|
+
[providers.opencode-go.pricing]
|
|
506
|
+
deepseek-v4-pro = deepseek-pro
|
|
507
|
+
deepseek-v4.1-flash = deepseek-flash
|
|
508
|
+
mimo-v2.6-pro = mimo-pro
|
|
509
|
+
mimo-v2.6-flash = mimo-flash
|
|
510
|
+
models = [...](4 项)
|
|
511
|
+
default_model = mimo-v2.6-flash
|
|
512
|
+
[providers.opencode-go.headers]
|
|
513
|
+
x-opencode-session = ${MY_SESSION_TOKEN}-{affinity_key}
|
|
514
|
+
[providers.commandcode-gota]
|
|
515
|
+
name = CommandCode-Gota
|
|
516
|
+
base_url = https://api.commandcode.ai/provider
|
|
517
|
+
api_key = ${COMMANDCODE_GOTA_API_KEY}
|
|
518
|
+
protocol = compatible
|
|
519
|
+
[providers.commandcode-gota.pricing]
|
|
520
|
+
deepseek/deepseek-v4-pro = deepseek-pro
|
|
521
|
+
deepseek/deepseek-v4.1-flash = deepseek-flash
|
|
522
|
+
xiaomi/mimo-v2.6-pro = mimo-pro
|
|
523
|
+
xiaomi/mimo-v2.6-flash = mimo-flash
|
|
524
|
+
models = [...](4 项)
|
|
525
|
+
default_model = deepseek/deepseek-v4.1-flash
|
|
526
|
+
[providers.opendesign-go]
|
|
527
|
+
name = OpenDesign-Go
|
|
528
|
+
base_url = https://amr-link.open-design.ai/v1
|
|
529
|
+
api_key = ${OPENDESIGN_GO_API_KEY}
|
|
530
|
+
protocol = compatible
|
|
531
|
+
[providers.opendesign-go.pricing]
|
|
532
|
+
deepseek-v4-pro = deepseek-pro
|
|
533
|
+
deepseek-v4.1-flash = deepseek-flash-0_5
|
|
534
|
+
deepseek-v4.1-flash-eco = deepseek-flash-0_25
|
|
535
|
+
mimo-v2.6-pro = mimo-pro
|
|
536
|
+
mimo-v2.6-flash = mimo-flash
|
|
537
|
+
models = [...](5 项)
|
|
538
|
+
default_model = deepseek-v4.1-flash
|
|
539
|
+
[providers.opendesign-go.model_map]
|
|
540
|
+
mimo-v2.6-pro = opendesign/mimo-v2.6-pro
|
|
541
|
+
mimo-v2.6-flash = opendesign/mimo-v2.6-flash
|
|
542
|
+
[context]
|
|
543
|
+
[context.cleanup]
|
|
544
|
+
[compaction]
|
|
545
|
+
[snapshot]
|
|
546
|
+
[cost]
|
|
547
|
+
[cost.presets]
|
|
548
|
+
[cost.presets.mimo-pro]
|
|
549
|
+
input_price = 3.0
|
|
550
|
+
cache_read_price = 0.025
|
|
551
|
+
output_price = 6.0
|
|
552
|
+
reasoning_price = 6.0
|
|
553
|
+
symbol = ¥
|
|
554
|
+
[cost.presets.mimo-flash]
|
|
555
|
+
input_price = 1.0
|
|
556
|
+
cache_read_price = 0.02
|
|
557
|
+
output_price = 2.0
|
|
558
|
+
reasoning_price = 2.0
|
|
559
|
+
symbol = ¥
|
|
560
|
+
[cost.presets.mimo-ultraspeed]
|
|
561
|
+
input_price = 30.0
|
|
562
|
+
cache_read_price = 0.25
|
|
563
|
+
output_price = 60.0
|
|
564
|
+
reasoning_price = 60.0
|
|
565
|
+
symbol = ¥
|
|
566
|
+
[cost.presets.mimo-batch-pro]
|
|
567
|
+
input_price = 1.5
|
|
568
|
+
cache_read_price = 0.0125
|
|
569
|
+
output_price = 3.0
|
|
570
|
+
reasoning_price = 3.0
|
|
571
|
+
symbol = ¥
|
|
572
|
+
[cost.presets.mimo-batch-flash]
|
|
573
|
+
input_price = 0.5
|
|
574
|
+
cache_read_price = 0.01
|
|
575
|
+
output_price = 1.0
|
|
576
|
+
reasoning_price = 1.0
|
|
577
|
+
symbol = ¥
|
|
578
|
+
[cost.presets.deepseek-pro]
|
|
579
|
+
input_price = 4.5
|
|
580
|
+
cache_read_price = 0.15
|
|
581
|
+
output_price = 13.5
|
|
582
|
+
reasoning_price = 13.5
|
|
583
|
+
symbol = ¥
|
|
584
|
+
offset = +08:00
|
|
585
|
+
overrides = [...](2 项)
|
|
586
|
+
[cost.presets.deepseek-flash]
|
|
587
|
+
input_price = 1.0
|
|
588
|
+
cache_read_price = 0.02
|
|
589
|
+
output_price = 4.0
|
|
590
|
+
reasoning_price = 4.0
|
|
591
|
+
symbol = ¥
|
|
592
|
+
offset = +08:00
|
|
593
|
+
overrides = [...](2 项)
|
|
594
|
+
[cost.presets.deepseek-flash-0_5]
|
|
595
|
+
input_price = 1.0
|
|
596
|
+
cache_read_price = 0.02
|
|
597
|
+
output_price = 4.0
|
|
598
|
+
reasoning_price = 4.0
|
|
599
|
+
symbol = ¥
|
|
600
|
+
offset = +08:00
|
|
601
|
+
[cost.presets.deepseek-flash-0_25]
|
|
602
|
+
input_price = 0.5
|
|
603
|
+
cache_read_price = 0.01
|
|
604
|
+
output_price = 2.0
|
|
605
|
+
reasoning_price = 2.0
|
|
606
|
+
symbol = ¥
|
|
607
|
+
offset = +08:00
|
|
608
|
+
[cost.presets.free]
|
|
609
|
+
input_price = 0
|
|
610
|
+
cache_read_price = 0
|
|
611
|
+
output_price = 0
|
|
612
|
+
reasoning_price = 0
|
|
613
|
+
symbol = ¥
|
|
614
|
+
[display]
|
|
615
|
+
verbose = False
|
|
616
|
+
event_page_size = 100
|
|
617
|
+
event_page_cache_pages = 3
|
|
618
|
+
[display.commands]
|
|
619
|
+
[cache]
|
|
620
|
+
[tools]
|
|
621
|
+
paths = [...](0 项)
|
|
622
|
+
[tools.policy]
|
|
623
|
+
[tools.file]
|
|
624
|
+
skip_dirs = [...](0 项)
|
|
625
|
+
skip_files = [...](0 项)
|
|
626
|
+
readonly_paths = [...](0 项)
|
|
627
|
+
ignore_files = [...](2 项)
|
|
628
|
+
[tools.media]
|
|
629
|
+
media_exts = [...](0 项)
|
|
630
|
+
[tools.goal]
|
|
631
|
+
[tools.webfetch]
|
|
632
|
+
[tools.websearch]
|
|
633
|
+
[tools.repo_map]
|
|
634
|
+
[tools.shell]
|
|
635
|
+
[tools.recall]
|
|
636
|
+
[tools.model_info]
|
|
637
|
+
[tools.todo]
|
|
638
|
+
[tools.persistent]
|
|
639
|
+
[tools.skill]
|
|
640
|
+
[tools.subagent]
|
|
641
|
+
[tools.mcp]
|
|
642
|
+
[prompts]
|
|
643
|
+
[hooks]
|
|
644
|
+
[sandbox]
|
|
645
|
+
mode = auto
|
|
646
|
+
[model_calls]
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
#### 环境变量(DACH_*——派生定制)
|
|
650
|
+
|
|
651
|
+
| 变量 | 说明 | 定义处 |
|
|
652
|
+
|------|------|--------|
|
|
653
|
+
| `DACH_CONFIG_FILE` | 两级 toml 文件名覆盖(默认 deeparche.toml;须为系统环境变量) | product/orch/config.py |
|
|
654
|
+
| `DACH_LOCAL_DIR` | 本地级配置目录名覆盖(默认 .deeparche;须为系统环境变量) | product/orch/config.py |
|
|
655
|
+
| `DACH_STRICT_INVARIANTS` | 不变量双态开关(=1 时 fail-fast 抛错;默认 warn) | core/invariants.py |
|
|
656
|
+
|
|
657
|
+
#### 公开 API(deeparche/__init__.py 显式导出——87 个符号)
|
|
658
|
+
|
|
659
|
+
| 符号 | 来源模块 |
|
|
660
|
+
|--------|----------|
|
|
661
|
+
| `Agent` | product.agent |
|
|
662
|
+
| `AgentComponents` | orch.bootstrap |
|
|
663
|
+
| `AgentHook` | core.hooks |
|
|
664
|
+
| `AgentLoop` | core.loop |
|
|
665
|
+
| `AssemblyConfig` | product.orch.assembly |
|
|
666
|
+
| `BuildConfig` | orch.bootstrap |
|
|
667
|
+
| `CapabilitySandboxRunner` | core.sandbox |
|
|
668
|
+
| `CommandContext` | product.api.commands |
|
|
669
|
+
| `CommandDef` | core.tools |
|
|
670
|
+
| `CompactionPolicy` | core.compaction |
|
|
671
|
+
| `ContextManager` | core.context |
|
|
672
|
+
| `CostTracker` | llm.pricing |
|
|
673
|
+
| `DEFAULT_RESULT_TRUNCATE_CHARS` | core.tools |
|
|
674
|
+
| `DisplayEvent` | orch.service |
|
|
675
|
+
| `EnvDetailsFilter` | core.filters |
|
|
676
|
+
| `EnvironmentSnapshot` | orch.session |
|
|
677
|
+
| `FallbackLLM` | llm.fallback |
|
|
678
|
+
| `FileSessionStore` | orch.session |
|
|
679
|
+
| `HookContext` | core.hooks |
|
|
680
|
+
| `LLMClient` | llm.client |
|
|
681
|
+
| `LLMSummarizer` | core.compaction |
|
|
682
|
+
| `MCPManager` | builtin.mcp |
|
|
683
|
+
| `MCPServerConfig` | builtin.mcp |
|
|
684
|
+
| `ModelPricing` | llm.pricing |
|
|
685
|
+
| `OutputHistory` | product.cli.history |
|
|
686
|
+
| `Part` | core.types |
|
|
687
|
+
| `ProductRuntime` | product.api.runtime |
|
|
688
|
+
| `ProtocolAdapter` | llm.adapter |
|
|
689
|
+
| `Resource` | core.permission |
|
|
690
|
+
| `Rule` | core.permission |
|
|
691
|
+
| `RuntimeConfig` | product.orch.config |
|
|
692
|
+
| `SESSIONS_DIR` | product.orch.paths |
|
|
693
|
+
| `SandboxRequest` | core.sandbox |
|
|
694
|
+
| `SandboxResult` | core.sandbox |
|
|
695
|
+
| `SandboxRunner` | core.sandbox |
|
|
696
|
+
| `Session` | orch.session |
|
|
697
|
+
| `SessionConfig` | product.orch.config |
|
|
698
|
+
| `SessionLog` | orch.log |
|
|
699
|
+
| `SessionOverrides` | product.orch.config |
|
|
700
|
+
| `SessionRuntime` | orch.runtime |
|
|
701
|
+
| `SessionStore` | orch.session |
|
|
702
|
+
| `SkillInfo` | builtin.skills |
|
|
703
|
+
| `SkillManager` | builtin.skills |
|
|
704
|
+
| `StreamEvent` | core.types |
|
|
705
|
+
| `StreamSession` | orch.service |
|
|
706
|
+
| `SubprocessSandbox` | core.sandbox |
|
|
707
|
+
| `TRUNCATE_SUFFIX` | core.tools |
|
|
708
|
+
| `TYPE_COMPACTION` | orch.service |
|
|
709
|
+
| `TYPE_CONFIRM_REQUEST` | orch.service |
|
|
710
|
+
| `TYPE_DONE` | orch.service |
|
|
711
|
+
| `TYPE_ERROR` | orch.service |
|
|
712
|
+
| `TYPE_REASONING` | orch.service |
|
|
713
|
+
| `TYPE_REASONING_END` | orch.service |
|
|
714
|
+
| `TYPE_TEXT` | orch.service |
|
|
715
|
+
| `TYPE_TOOL_CALL` | orch.service |
|
|
716
|
+
| `TYPE_TOOL_RESULT` | orch.service |
|
|
717
|
+
| `TYPE_WARN` | orch.service |
|
|
718
|
+
| `ThinkingConfig` | llm.adapter |
|
|
719
|
+
| `ToolDef` | core.tools |
|
|
720
|
+
| `ToolRegistry` | core.tools |
|
|
721
|
+
| `Turn` | core.types |
|
|
722
|
+
| `Usage` | core.types |
|
|
723
|
+
| `apply_preset` | product.orch.agents |
|
|
724
|
+
| `assemble_session` | product.orch.assembly |
|
|
725
|
+
| `build_agent` | orch.bootstrap |
|
|
726
|
+
| `build_media_parts` | orch.service |
|
|
727
|
+
| `build_repo_map_for_project` | builtin.repo_map |
|
|
728
|
+
| `create_sandbox` | core.sandbox |
|
|
729
|
+
| `default_consume` | orch.runtime |
|
|
730
|
+
| `default_safety_checker` | product.orch.approval |
|
|
731
|
+
| `discover_presets` | product.orch.agents |
|
|
732
|
+
| `escape_markup` | orch.service |
|
|
733
|
+
| `finalize_turn` | orch.turn |
|
|
734
|
+
| `get_nested` | llm.stream_parser |
|
|
735
|
+
| `infer_schema` | core.tools |
|
|
736
|
+
| `load_config` | product.orch.config |
|
|
737
|
+
| `media_capabilities` | orch.service |
|
|
738
|
+
| `parse_compatible_usage` | llm.stream_parser |
|
|
739
|
+
| `parse_frontmatter` | builtin.skills |
|
|
740
|
+
| `prepare_turn` | orch.turn |
|
|
741
|
+
| `register_commands` | product.api.commands |
|
|
742
|
+
| `register_product_tools` | product.tools.registry |
|
|
743
|
+
| `register_repo_map_tool` | builtin.repo_map |
|
|
744
|
+
| `resolve_session_config` | product.orch.config |
|
|
745
|
+
| `run_agent_once` | orch.runtime |
|
|
746
|
+
| `truncate` | orch.service |
|
|
747
|
+
| `truncate_result` | core.tools |
|
|
748
|
+
|
|
749
|
+
#### 测试套件(193 个——run_all_tests.ps1 一键全量)
|
|
750
|
+
|
|
751
|
+
- test_adapter_protocol.py
|
|
752
|
+
- test_agent_config_merge.py
|
|
753
|
+
- test_agent_facade.py
|
|
754
|
+
- test_agent_loop.py
|
|
755
|
+
- test_agents.py
|
|
756
|
+
- test_api.py
|
|
757
|
+
- test_api_contract.py
|
|
758
|
+
- test_approval.py
|
|
759
|
+
- test_approval_api.py
|
|
760
|
+
- test_approval_audit_gaps.py
|
|
761
|
+
- test_approval_cli_bus.py
|
|
762
|
+
- test_approval_command_confirm.py
|
|
763
|
+
- test_approval_modes.py
|
|
764
|
+
- test_approval_persist.py
|
|
765
|
+
- test_approval_presenter.py
|
|
766
|
+
- test_approval_relay.py
|
|
767
|
+
- test_approval_reviewer.py
|
|
768
|
+
- test_approval_reviewer_inherit.py
|
|
769
|
+
- test_approval_same_source.py
|
|
770
|
+
- test_assembly.py
|
|
771
|
+
- test_assembly_registry_complete.py
|
|
772
|
+
- test_auto_title.py
|
|
773
|
+
- test_background.py
|
|
774
|
+
- test_background_cancel.py
|
|
775
|
+
- test_call_lease.py
|
|
776
|
+
- test_capabilities.py
|
|
777
|
+
- test_capability_surface_manifest.py
|
|
778
|
+
- test_channels.py
|
|
779
|
+
- test_checkpoint_perf.py
|
|
780
|
+
- test_cli_channel.py
|
|
781
|
+
- test_cli_config_workspace.py
|
|
782
|
+
- test_cli_confirm_bus.py
|
|
783
|
+
- test_cli_integration.py
|
|
784
|
+
- test_cli_process.py
|
|
785
|
+
- test_cli_queue_wiring.py
|
|
786
|
+
- test_code_index_pack.py
|
|
787
|
+
- test_command_args.py
|
|
788
|
+
- test_command_contract.py
|
|
789
|
+
- test_command_visibility.py
|
|
790
|
+
- test_commands_side_effects.py
|
|
791
|
+
- test_compaction.py
|
|
792
|
+
- test_compaction_long_session.py
|
|
793
|
+
- test_completer.py
|
|
794
|
+
- test_config_authority.py
|
|
795
|
+
- test_config_command_dispatch.py
|
|
796
|
+
- test_config_info.py
|
|
797
|
+
- test_config_info_hints.py
|
|
798
|
+
- test_config_info_pack.py
|
|
799
|
+
- test_config_layers.py
|
|
800
|
+
- test_config_manager.py
|
|
801
|
+
- test_config_sync.py
|
|
802
|
+
- test_config_write.py
|
|
803
|
+
- test_context_cache_p0.py
|
|
804
|
+
- test_context_cleanup.py
|
|
805
|
+
- test_context_window_contract.py
|
|
806
|
+
- test_custom_tool_registration.py
|
|
807
|
+
- test_cwd_command.py
|
|
808
|
+
- test_discriminator.py
|
|
809
|
+
- test_display_page_contract.py
|
|
810
|
+
- test_dist_manifest_guard.py
|
|
811
|
+
- test_doc_drift_guard.py
|
|
812
|
+
- test_event_journal_recovery.py
|
|
813
|
+
- test_event_page_contract.py
|
|
814
|
+
- test_event_page_index_incremental.py
|
|
815
|
+
- test_example_config_hygiene.py
|
|
816
|
+
- test_examples_smoke.py
|
|
817
|
+
- test_extend_contract_doc.py
|
|
818
|
+
- test_external_access.py
|
|
819
|
+
- test_face_residue_guard.py
|
|
820
|
+
- test_fallback.py
|
|
821
|
+
- test_feature_tree.py
|
|
822
|
+
- test_features_extra.py
|
|
823
|
+
- test_feishu_client.py
|
|
824
|
+
- test_feishu_notify_pack.py
|
|
825
|
+
- test_feishu_pairing.py
|
|
826
|
+
- test_file_atomic.py
|
|
827
|
+
- test_file_fidelity.py
|
|
828
|
+
- test_file_tools.py
|
|
829
|
+
- test_file_tools_enhanced.py
|
|
830
|
+
- test_functionality.py
|
|
831
|
+
- test_goal_pack.py
|
|
832
|
+
- test_goal_state.py
|
|
833
|
+
- test_golden_trace.py
|
|
834
|
+
- test_history_page_api.py
|
|
835
|
+
- test_hooks_loader.py
|
|
836
|
+
- test_hot_reload.py
|
|
837
|
+
- test_ignore_rules.py
|
|
838
|
+
- test_import_isolation.py
|
|
839
|
+
- test_imports.py
|
|
840
|
+
- test_inheritance_live.py
|
|
841
|
+
- test_input_queue.py
|
|
842
|
+
- test_instruction_lifecycle.py
|
|
843
|
+
- test_instructions.py
|
|
844
|
+
- test_invariants.py
|
|
845
|
+
- test_limits_single_source.py
|
|
846
|
+
- test_llm_errors.py
|
|
847
|
+
- test_llm_sampling.py
|
|
848
|
+
- test_loop_unit.py
|
|
849
|
+
- test_manifest.py
|
|
850
|
+
- test_manifest_discover.py
|
|
851
|
+
- test_mcp.py
|
|
852
|
+
- test_media.py
|
|
853
|
+
- test_media_gating.py
|
|
854
|
+
- test_message_assembly.py
|
|
855
|
+
- test_message_roles.py
|
|
856
|
+
- test_minimal_subagent.py
|
|
857
|
+
- test_model_calls.py
|
|
858
|
+
- test_model_calls_follow_switch.py
|
|
859
|
+
- test_model_descriptor.py
|
|
860
|
+
- test_model_presentation.py
|
|
861
|
+
- test_model_state_matrix.py
|
|
862
|
+
- test_model_variants.py
|
|
863
|
+
- test_output_store.py
|
|
864
|
+
- test_ownership_guard.py
|
|
865
|
+
- test_pathutil.py
|
|
866
|
+
- test_perf_smoke.py
|
|
867
|
+
- test_permission.py
|
|
868
|
+
- test_permission_guard.py
|
|
869
|
+
- test_plan_writer.py
|
|
870
|
+
- test_platform_purity.py
|
|
871
|
+
- test_pricing.py
|
|
872
|
+
- test_process_supervisor.py
|
|
873
|
+
- test_process_tools.py
|
|
874
|
+
- test_product_api.py
|
|
875
|
+
- test_product_hardening.py
|
|
876
|
+
- test_product_tools_capability_guard.py
|
|
877
|
+
- test_protocols_decision.py
|
|
878
|
+
- test_protocols_vector.py
|
|
879
|
+
- test_provider_resolve.py
|
|
880
|
+
- test_providers.py
|
|
881
|
+
- test_public_snapshot_check.py
|
|
882
|
+
- test_rebind_wiring.py
|
|
883
|
+
- test_recycle.py
|
|
884
|
+
- test_register_contract.py
|
|
885
|
+
- test_reload_chain_complete.py
|
|
886
|
+
- test_request_cleanup_413.py
|
|
887
|
+
- test_restore_plan.py
|
|
888
|
+
- test_resume_window.py
|
|
889
|
+
- test_revert.py
|
|
890
|
+
- test_revert_from_archive.py
|
|
891
|
+
- test_run_stream_anchor.py
|
|
892
|
+
- test_runtime.py
|
|
893
|
+
- test_runtime_commands.py
|
|
894
|
+
- test_sandbox.py
|
|
895
|
+
- test_scoped_registry_p3.py
|
|
896
|
+
- test_service_face_wiring.py
|
|
897
|
+
- test_session_config.py
|
|
898
|
+
- test_session_events_store.py
|
|
899
|
+
- test_session_lease.py
|
|
900
|
+
- test_session_sidecars.py
|
|
901
|
+
- test_session_state.py
|
|
902
|
+
- test_sessions_copy.py
|
|
903
|
+
- test_shell_dump.py
|
|
904
|
+
- test_shell_manual.py
|
|
905
|
+
- test_skills_resume.py
|
|
906
|
+
- test_startup_report.py
|
|
907
|
+
- test_subagent.py
|
|
908
|
+
- test_subagent_assembly.py
|
|
909
|
+
- test_subagent_cancel_flush.py
|
|
910
|
+
- test_subagent_child_tools.py
|
|
911
|
+
- test_subagent_depends_on.py
|
|
912
|
+
- test_subagent_grant.py
|
|
913
|
+
- test_subagent_inherit_guard.py
|
|
914
|
+
- test_subagent_model_scope.py
|
|
915
|
+
- test_subagent_persistence.py
|
|
916
|
+
- test_subagent_progress.py
|
|
917
|
+
- test_subagent_r3r4_corrections.py
|
|
918
|
+
- test_subagent_result_structured.py
|
|
919
|
+
- test_subagent_steer.py
|
|
920
|
+
- test_summarize.py
|
|
921
|
+
- test_supervisor.py
|
|
922
|
+
- test_task_session_shared_log.py
|
|
923
|
+
- test_template.py
|
|
924
|
+
- test_terminology_guard.py
|
|
925
|
+
- test_thinking_effort.py
|
|
926
|
+
- test_tool_cancel.py
|
|
927
|
+
- test_tool_error_codes.py
|
|
928
|
+
- test_tool_host.py
|
|
929
|
+
- test_tools_loader.py
|
|
930
|
+
- test_tools_registry.py
|
|
931
|
+
- test_transcript_contract.py
|
|
932
|
+
- test_trust_gate.py
|
|
933
|
+
- test_usage_parsing.py
|
|
934
|
+
- test_w02_agent_fields.py
|
|
935
|
+
- test_w03_child_workspace.py
|
|
936
|
+
- test_webfetch_recall.py
|
|
937
|
+
- test_webui_archive.py
|
|
938
|
+
- test_workdir_rebind.py
|
|
939
|
+
- test_workdir_resolve.py
|
|
940
|
+
- test_workdir_source_guard.py
|
|
941
|
+
- test_workspace_command.py
|
|
942
|
+
- test_workspace_scaffold.py
|
|
943
|
+
- test_workspace_use_rename.py
|
|
944
|
+
|
|
945
|
+
### Mermaid(脚本渲染——手工勿改)
|
|
946
|
+
|
|
947
|
+
**依赖图(每层一色)**:
|
|
948
|
+
|
|
949
|
+
```mermaid
|
|
950
|
+
graph LR
|
|
951
|
+
%% 层配色(classDef——每层一色,一眼区分层身份)
|
|
952
|
+
classDef c_core fill:#3b82f6,stroke:#3b82f6,color:#fff,stroke-width:1px
|
|
953
|
+
classDef c_llm fill:#06b6d4,stroke:#06b6d4,color:#fff,stroke-width:1px
|
|
954
|
+
classDef c_orch fill:#22c55e,stroke:#22c55e,color:#fff,stroke-width:1px
|
|
955
|
+
classDef c_builtin fill:#78716c,stroke:#78716c,color:#fff,stroke-width:1px
|
|
956
|
+
classDef c_product fill:#e11d48,stroke:#e11d48,color:#fff,stroke-width:1px
|
|
957
|
+
classDef c_scripts fill:#94a3b8,stroke:#94a3b8,color:#fff,stroke-width:1px
|
|
958
|
+
n_core["🧠 core 内核"]:::c_core --> n_llm["🔌 llm 协议"]:::c_llm
|
|
959
|
+
n_llm --> n_orch["🎛️ orch 编排"]:::c_orch
|
|
960
|
+
n_orch --> n_api["🖥️ api 展示服务"]:::c_api
|
|
961
|
+
n_api --> n_cli["⌨️ cli 命令行"]:::c_cli
|
|
962
|
+
n_core -. 回调注入 .-> n_builtin["🧰 builtin 内置工具"]:::c_builtin
|
|
963
|
+
n_cli -. 同步维护 .-> n_scripts["🛠️ scripts 检查/生成"]:::c_scripts
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
**模块树 mindmap(层→模块两级辐射布局)**:
|
|
967
|
+
|
|
968
|
+
```mermaid
|
|
969
|
+
mindmap
|
|
970
|
+
root((DeepArche 功能实现树))
|
|
971
|
+
core 内核(引擎——零外部依赖)
|
|
972
|
+
approval.py
|
|
973
|
+
atomic.py
|
|
974
|
+
background.py
|
|
975
|
+
call_grant.py
|
|
976
|
+
call_lease.py
|
|
977
|
+
command_grammar.py
|
|
978
|
+
command_surface.py
|
|
979
|
+
compaction.py
|
|
980
|
+
context.py
|
|
981
|
+
environment.py
|
|
982
|
+
errors.py
|
|
983
|
+
event_window.py
|
|
984
|
+
filters.py
|
|
985
|
+
hooks.py
|
|
986
|
+
inject_texts.py
|
|
987
|
+
invariants.py
|
|
988
|
+
loop.py
|
|
989
|
+
media.py
|
|
990
|
+
permission.py
|
|
991
|
+
process.py
|
|
992
|
+
provider_error.py
|
|
993
|
+
request_cleanup.py
|
|
994
|
+
sandbox.py
|
|
995
|
+
session_state.py
|
|
996
|
+
state.py
|
|
997
|
+
subagent_result.py
|
|
998
|
+
token_estimate.py
|
|
999
|
+
tool_attempt.py
|
|
1000
|
+
tool_host.py
|
|
1001
|
+
tool_ipc.py
|
|
1002
|
+
tool_worker.py
|
|
1003
|
+
tools.py
|
|
1004
|
+
turn_token.py
|
|
1005
|
+
turn_transaction.py
|
|
1006
|
+
types.py
|
|
1007
|
+
llm 协议(LLM 适配——只依赖 core)
|
|
1008
|
+
adapter.py
|
|
1009
|
+
client.py
|
|
1010
|
+
constants.py
|
|
1011
|
+
fallback.py
|
|
1012
|
+
media.py
|
|
1013
|
+
pricing.py
|
|
1014
|
+
stream_parser.py
|
|
1015
|
+
protocols/claude.py
|
|
1016
|
+
protocols/common.py
|
|
1017
|
+
protocols/compatible.py
|
|
1018
|
+
protocols/responses.py
|
|
1019
|
+
orch 平台·通用编排(装配/会话/子代理/服务契约——依赖 core+llm,零约定)
|
|
1020
|
+
approval.py
|
|
1021
|
+
bootstrap.py
|
|
1022
|
+
event_journal.py
|
|
1023
|
+
log.py
|
|
1024
|
+
messages.py
|
|
1025
|
+
model_config.py
|
|
1026
|
+
model_descriptor.py
|
|
1027
|
+
persist.py
|
|
1028
|
+
providers.py
|
|
1029
|
+
resume.py
|
|
1030
|
+
runtime.py
|
|
1031
|
+
scope.py
|
|
1032
|
+
session.py
|
|
1033
|
+
session_assembler.py
|
|
1034
|
+
session_journal.py
|
|
1035
|
+
session_lock.py
|
|
1036
|
+
stream.py
|
|
1037
|
+
subagent.py
|
|
1038
|
+
subagent_approval.py
|
|
1039
|
+
subagent_background.py
|
|
1040
|
+
subagent_config.py
|
|
1041
|
+
subagent_models.py
|
|
1042
|
+
subagent_sessions.py
|
|
1043
|
+
supervisor.py
|
|
1044
|
+
title.py
|
|
1045
|
+
tool_families.py
|
|
1046
|
+
transcript.py
|
|
1047
|
+
turn.py
|
|
1048
|
+
watcher.py
|
|
1049
|
+
service/contract.py
|
|
1050
|
+
service/events.py
|
|
1051
|
+
service/media.py
|
|
1052
|
+
service/stream.py
|
|
1053
|
+
builtin 平台·通用工具(只依赖 core.tools——约定工具归 product/tools)
|
|
1054
|
+
command_surface.py
|
|
1055
|
+
file_io.py
|
|
1056
|
+
file_tools.py
|
|
1057
|
+
ignore_rules.py
|
|
1058
|
+
limits.py
|
|
1059
|
+
mcp.py
|
|
1060
|
+
minimal_subagent.py
|
|
1061
|
+
model_info_tool.py
|
|
1062
|
+
output_store.py
|
|
1063
|
+
paging.py
|
|
1064
|
+
persistent_tool.py
|
|
1065
|
+
process_tool.py
|
|
1066
|
+
recall_tool.py
|
|
1067
|
+
registry.py
|
|
1068
|
+
repo_map.py
|
|
1069
|
+
shell_manual.py
|
|
1070
|
+
shell_tool.py
|
|
1071
|
+
skills.py
|
|
1072
|
+
subagent_tool.py
|
|
1073
|
+
todo_tool.py
|
|
1074
|
+
webfetch_tool.py
|
|
1075
|
+
websearch_tool.py
|
|
1076
|
+
product 产品层(产品编排/服务契约/展示——第一个产品:harness/CLI)
|
|
1077
|
+
agent.py
|
|
1078
|
+
api/commands.py
|
|
1079
|
+
api/config.py
|
|
1080
|
+
api/display.py
|
|
1081
|
+
api/owner.py
|
|
1082
|
+
api/runtime.py
|
|
1083
|
+
assets/example_assets.py
|
|
1084
|
+
channels/builtin.py
|
|
1085
|
+
channels/contract.py
|
|
1086
|
+
channels/launcher.py
|
|
1087
|
+
channels/registry.py
|
|
1088
|
+
cli/__main__.py
|
|
1089
|
+
cli/approval_ui.py
|
|
1090
|
+
cli/auth.py
|
|
1091
|
+
cli/banner.py
|
|
1092
|
+
cli/colors.py
|
|
1093
|
+
cli/commands.py
|
|
1094
|
+
cli/consume.py
|
|
1095
|
+
cli/display_state.py
|
|
1096
|
+
cli/history.py
|
|
1097
|
+
cli/input_stack.py
|
|
1098
|
+
cli/main.py
|
|
1099
|
+
cli/media.py
|
|
1100
|
+
cli/picker.py
|
|
1101
|
+
cli/queue_wiring.py
|
|
1102
|
+
cli/renderer.py
|
|
1103
|
+
cli/repl.py
|
|
1104
|
+
cli/startup.py
|
|
1105
|
+
cli/supervise.py
|
|
1106
|
+
cli/tasks.py
|
|
1107
|
+
host/lifecycle.py
|
|
1108
|
+
host/options.py
|
|
1109
|
+
host/runtime_host.py
|
|
1110
|
+
manifest/discover.py
|
|
1111
|
+
manifest/loader.py
|
|
1112
|
+
orch/agent_config.py
|
|
1113
|
+
orch/agents.py
|
|
1114
|
+
orch/app.py
|
|
1115
|
+
orch/approval.py
|
|
1116
|
+
orch/approval_api.py
|
|
1117
|
+
orch/approval_command.py
|
|
1118
|
+
orch/approval_modes.py
|
|
1119
|
+
orch/approval_pending.py
|
|
1120
|
+
orch/approval_presenters.py
|
|
1121
|
+
orch/approval_relay.py
|
|
1122
|
+
orch/assembly.py
|
|
1123
|
+
orch/auto_title.py
|
|
1124
|
+
orch/cache_keeper.py
|
|
1125
|
+
orch/capabilities.py
|
|
1126
|
+
orch/channel.py
|
|
1127
|
+
orch/checkpoint.py
|
|
1128
|
+
orch/command_args.py
|
|
1129
|
+
orch/command_audit.py
|
|
1130
|
+
orch/command_completion.py
|
|
1131
|
+
orch/command_visibility.py
|
|
1132
|
+
orch/completion_view.py
|
|
1133
|
+
orch/config.py
|
|
1134
|
+
orch/config_compose.py
|
|
1135
|
+
orch/config_manager.py
|
|
1136
|
+
orch/config_write.py
|
|
1137
|
+
orch/console.py
|
|
1138
|
+
orch/continuation.py
|
|
1139
|
+
orch/cost_view.py
|
|
1140
|
+
orch/env.py
|
|
1141
|
+
orch/goal.py
|
|
1142
|
+
orch/goal_lifecycle.py
|
|
1143
|
+
orch/goal_projection.py
|
|
1144
|
+
orch/hooks_loader.py
|
|
1145
|
+
orch/hot_reload.py
|
|
1146
|
+
orch/input_queue.py
|
|
1147
|
+
orch/instructions.py
|
|
1148
|
+
orch/internal_events.py
|
|
1149
|
+
orch/model_presentation.py
|
|
1150
|
+
orch/model_state.py
|
|
1151
|
+
orch/paths.py
|
|
1152
|
+
orch/reload.py
|
|
1153
|
+
orch/restore.py
|
|
1154
|
+
orch/revert.py
|
|
1155
|
+
orch/reviewer.py
|
|
1156
|
+
orch/roles.py
|
|
1157
|
+
orch/sandbox_policy.py
|
|
1158
|
+
orch/session_store.py
|
|
1159
|
+
orch/system_notice.py
|
|
1160
|
+
orch/template.py
|
|
1161
|
+
orch/tool_risk.py
|
|
1162
|
+
orch/tools_loader.py
|
|
1163
|
+
orch/transcript_view.py
|
|
1164
|
+
orch/turn_boundary.py
|
|
1165
|
+
orch/workspaces.py
|
|
1166
|
+
tools/_state.py
|
|
1167
|
+
tools/capability_set.py
|
|
1168
|
+
tools/hot_reload_tool.py
|
|
1169
|
+
tools/namespace.py
|
|
1170
|
+
tools/policy.py
|
|
1171
|
+
tools/registry.py
|
|
1172
|
+
scripts 工具脚本(检查器/生成器/基准——零运行路径)
|
|
1173
|
+
bench_session_io.py
|
|
1174
|
+
benchmark.py
|
|
1175
|
+
build_dists.py
|
|
1176
|
+
capability_surface.py
|
|
1177
|
+
check_cache_epoch.py
|
|
1178
|
+
check_capability_matrix.py
|
|
1179
|
+
check_command_completion.py
|
|
1180
|
+
check_dependencies.py
|
|
1181
|
+
check_dist_manifest.py
|
|
1182
|
+
check_doc_drift.py
|
|
1183
|
+
check_face_residue.py
|
|
1184
|
+
check_feature_tree.py
|
|
1185
|
+
check_lint.py
|
|
1186
|
+
check_model_state_single_source.py
|
|
1187
|
+
check_python_syntax.py
|
|
1188
|
+
check_retired_symbols.py
|
|
1189
|
+
check_scratch_isolation.py
|
|
1190
|
+
check_single_source.py
|
|
1191
|
+
check_spawn_no_window.py
|
|
1192
|
+
check_temp_dir_source.py
|
|
1193
|
+
check_terminology.py
|
|
1194
|
+
check_test_ownership.py
|
|
1195
|
+
check_tests_hermetic.py
|
|
1196
|
+
check_transcript_paths.py
|
|
1197
|
+
check_workdir_source.py
|
|
1198
|
+
cli_interactive_check.py
|
|
1199
|
+
contracts_snapshot_lib.py
|
|
1200
|
+
eval_basic.py
|
|
1201
|
+
gen_contracts_snapshot.py
|
|
1202
|
+
gen_feature_tree.py
|
|
1203
|
+
manual_session_lock_check.py
|
|
1204
|
+
probe_multimodal.py
|
|
1205
|
+
public_snapshot_check.py
|
|
1206
|
+
run_all_tests.py
|
|
1207
|
+
scratch.py
|
|
1208
|
+
scratch_run.py
|
|
1209
|
+
smoke_api.py
|
|
1210
|
+
stress_session.py
|
|
1211
|
+
tool_conflicts.py
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
<!-- FEATURE-TREE:END -->
|
|
1215
|
+
|
|
1216
|
+
## Dependency Rules
|
|
1217
|
+
|
|
1218
|
+
- **Core Layer**: Only depends on Python standard library. Same-layer internal imports allowed.
|
|
1219
|
+
- **LLM Layer**: Only depends on Core layer.
|
|
1220
|
+
- **Orch Layer**: Only depends on Core + LLM layers(工具注册经回调注入——零依赖 builtin)。
|
|
1221
|
+
- **API Layer**: Only depends on Core + LLM + Orch layers(展示服务层——不依赖 cli/tui/builtin;
|
|
1222
|
+
展示注入经 CommandContext 回调——反向依赖禁止)。
|
|
1223
|
+
- **CLI Layer**: Can depend on all other layers(含 api——业务命令/事件/收尾共用)。
|
|
1224
|
+
- **Builtin Tools**: Only depends on Core layer's ToolRegistry.
|
|
1225
|
+
|
|
1226
|
+
> 2026-08-16:TUI 归档(`code/archived/tui/`)——依赖规则中 tui 层移除;
|
|
1227
|
+
> 重做时按 cli 同规则加回。
|
|
1228
|
+
|
|
1229
|
+
依赖检查:`python scripts/check_dependencies.py`(层规则见脚本 LAYER_RULES)。
|
|
1230
|
+
|
|
1231
|
+
## 配置层级与派生定制(2026-10-03——两级来源·来源唯一)
|
|
1232
|
+
|
|
1233
|
+
两级来源(全部锚定、无向上扫描——所见即所得):
|
|
1234
|
+
|
|
1235
|
+
| 层 | 位置 | 用途 |
|
|
1236
|
+
|----|------|------|
|
|
1237
|
+
| 本地级 | `./.deeparche/deeparche.toml` | 个人覆盖(不入库) |
|
|
1238
|
+
| 用户级 | `~/.deeparche/deeparche.toml`(旧路径 %APPDATA%/~/.config 仅读取兼容) | 全局兜底 |
|
|
1239
|
+
|
|
1240
|
+
- **来源唯一**:两级中**首个“有配置”的层即工作区**(判据 = 该层存在任一配置文件
|
|
1241
|
+
——`deeparche.toml` / `permissions.toml` / `.env`);命中后**读与写都只指向它**
|
|
1242
|
+
——不合并、不覆盖,低层键不渗入(两处都放配置 ⇒ 用户级不生效,启动可见提示)
|
|
1243
|
+
- `.env` 只读**来源层**的那一个(与 toml 同层);其已配置的键优先于系统环境变量
|
|
1244
|
+
(精确 > 模糊),未覆盖的键才回落系统环境。密钥只进 .env
|
|
1245
|
+
- 项目仓库级(`./deeparche.toml` + `./.env`)旧设计不存在;不探测、不读取、不提示。
|
|
1246
|
+
- 派生定制(二次开发零改代码):`DACH_CONFIG_FILE`(toml 文件名覆盖)、
|
|
1247
|
+
`DACH_LOCAL_DIR`(本地级目录名覆盖)——必须设为系统环境变量
|
|
1248
|
+
- auth 向导:`deeparche config auth [--target local|user]`(默认写入本地级——安全默认)
|
|
1249
|
+
|
|
1250
|
+
## 新增能力面(2026-08-14~16 维护期——债务清偿)
|
|
1251
|
+
|
|
1252
|
+
| 能力 | 入口 | 归属 |
|
|
1253
|
+
|------|------|------|
|
|
1254
|
+
| 提示词配置面(A1) | toml [prompts] title_prompt / subagent_system_template 等(键 = prompts_cfg 读取面) | orch/agents.py + api |
|
|
1255
|
+
| hook 配置级注册(A2) | toml [hooks] paths;agent.toml [hooks].paths(相对预设目录) | orch/hooks_loader.py |
|
|
1256
|
+
| 采样参数面(A3) | toml [models."*"] temperature/top_p/stop/penalty + extra_body/extra_kwargs 透传 | llm/adapter.py SamplingConfig |
|
|
1257
|
+
| 有状态单轮 | CLI --exec "/sessions resume all <id>" --task "…" | cli/tasks.py `_run_task(env, ...)`(共享 env/context/loop/journal) |
|
|
1258
|
+
| 有状态子代理 | subagent 工具 subagent_id/persistent 参数;预设 [agent].persistent 类型声明 | orch/subagent.py |
|
|
1259
|
+
| 结构化工具错误码 | 六码 TOOL_TIMEOUT/PERMISSION_DENIED/SANDBOX_BLOCKED/TOOL_CRASH/TOOL_CANCELLED/TOOL_INVALID_ARGS + ToolError 哨兵 | core/errors.py |
|
|
1260
|
+
| 运行时不变量 | 默认 warn / DACH_STRICT_INVARIANTS 抛错 | core/invariants.py |
|
|
1261
|
+
| 发现机制明确化 | 锚定+声明(agents/skills/AGENTS.md 无隐含扫描;技能加载含基准目录说明) | orch/agents.py + skills.py + instructions.py |
|
|
1262
|
+
|
|
1263
|
+
## Import Rules
|
|
1264
|
+
|
|
1265
|
+
**✅ Correct - Absolute imports:**
|
|
1266
|
+
```python
|
|
1267
|
+
from deeparche.core.types import Part, Turn
|
|
1268
|
+
from deeparche.llm.adapter import ProtocolAdapter
|
|
1269
|
+
from deeparche.orch.session import Session
|
|
1270
|
+
from deeparche.product.api import ProductRuntime
|
|
1271
|
+
```
|
|
1272
|
+
|
|
1273
|
+
**❌ Incorrect - Relative imports:**
|
|
1274
|
+
```python
|
|
1275
|
+
from .types import Part
|
|
1276
|
+
from ..llm import adapter
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1279
|
+
## Module Responsibilities
|
|
1280
|
+
|
|
1281
|
+
### Core Layer
|
|
1282
|
+
|
|
1283
|
+
- **types.py**: Basic data structures used across all layers
|
|
1284
|
+
- **context.py**: Conversation history and context budget management
|
|
1285
|
+
- **tools.py**: Tool registration and execution management
|
|
1286
|
+
- **loop.py**: Agent main loop (think → act → observe)
|
|
1287
|
+
- **permission.py**: 权限最小内核(Resource/Rule 契约 + evaluate 纯匹配 + build_resources;规则集与策略在 orch/approval.py)
|
|
1288
|
+
- **hooks.py**: Hook system for lifecycle events
|
|
1289
|
+
- **compaction.py**: Context compression with LLM summarization
|
|
1290
|
+
- **filters.py**: Stream filtering for environment details
|
|
1291
|
+
- **display.py 已删除(2026-10-21)**:输出历史迁至 `product/cli/history.py`(显示契约 = AgentLoop 的 StreamEvent 事件流;DisplayBackend 已于 2026-09-10 删除)
|
|
1292
|
+
- **media.py**: 媒体基础常量与格式判定(MIME 白名单/扩展名映射/模态判定——通用文件格式知识,零依赖)
|
|
1293
|
+
- **environment.py**: 环境信息收集(OS/shell/工作区——环境块数据源)
|
|
1294
|
+
- **background.py**: 后台任务容器(BackgroundRunner——wait_all/wait_one/drain_results/tick)
|
|
1295
|
+
- **sandbox.py**: 沙箱执行器(Docker/Subprocess 回落;安全隔离)
|
|
1296
|
+
- **errors.py**: 结构化工具错误码单源(六码 TOOL_TIMEOUT/PERMISSION_DENIED/SANDBOX_BLOCKED/TOOL_CRASH/TOOL_CANCELLED/TOOL_INVALID_ARGS;ToolError 哨兵经 execute_parallel 异常映射产出结构化字典结果——机器路由旁路不进模型字节)
|
|
1297
|
+
- **invariants.py**: 运行时不变量双态 helper(默认 warn / DACH_STRICT_INVARIANTS 抛错)
|
|
1298
|
+
|
|
1299
|
+
### LLM Layer
|
|
1300
|
+
|
|
1301
|
+
- **adapter.py**: Protocol adapter for different LLM APIs (OpenAI Compatible, Responses, Claude)
|
|
1302
|
+
- **client.py**: Unified LLM client with retry logic
|
|
1303
|
+
- **media.py**: 协议媒体块构造与能力门控(PROTOCOL_MODALITIES/media_block/placeholder/官方 Token 估算)
|
|
1304
|
+
- **pricing.py**: Model pricing and cost tracking
|
|
1305
|
+
- **stream_parser.py**: SSE stream parsing for different protocols
|
|
1306
|
+
- **fallback.py**: 供应商回落(主供应商失败 → 备选供应商)
|
|
1307
|
+
|
|
1308
|
+
### Orch Layer
|
|
1309
|
+
|
|
1310
|
+
> **2026-10-21 B4 标注**:本节至 CLI Layer 为 S3 分层迁移前的手写说明。
|
|
1311
|
+
> 当前实际位置以顶部生成树为准:通用编排在 `orch/`,产品编排在
|
|
1312
|
+
> `product/orch/`,服务契约在 `product/api/`,展示在 `product/cli/`;
|
|
1313
|
+
> 飞书通知工具在 `product/tools/packs/feishu_notify/`(入站渠道已归档)。
|
|
1314
|
+
> 下方旧路径仅作历史参考,不得作为接入依据。
|
|
1315
|
+
|
|
1316
|
+
- **session.py**: Session management with cache-friendly design
|
|
1317
|
+
- **config.py**: 配置加载——两级来源(2026-10-03:本地级 ./.deeparche/ + 用户级
|
|
1318
|
+
~/.deeparche/——首个“有配置”的层即工作区(来源唯一)、无向上扫描)
|
|
1319
|
+
+ 模型能力表 + 运行时配置
|
|
1320
|
+
- **providers.py**: 供应商管理(load_providers / resolve_api_key / select_model / rebuild_llm)
|
|
1321
|
+
- **hooks_loader.py**: 配置级 hook 加载器(2026-08-16 A2——toml [hooks] paths
|
|
1322
|
+
与 agent.toml [agent] hooks 的 importlib 加载;失败显式报错)
|
|
1323
|
+
- **assembly.py**: 装配服务——`assemble_session(AssemblyConfig) → AssemblyResult`
|
|
1324
|
+
(CLI/TUI 同一入口;tools_description 装配期一次——缓存安全;subagent 工具
|
|
1325
|
+
注册经 `subagent_tool_register` 回调注入——orch 零依赖 builtin)
|
|
1326
|
+
- **actions.py**: 动作服务——业务命令实现(`cmd_*`,CommandContext 权威定义)
|
|
1327
|
+
+ `rebuild_context_for_resume`(/sessions resume 核心逻辑——CLI/TUI 共用)
|
|
1328
|
+
- **agents.py**: 智能体预设——发现/加载/`AgentCatalog`(命令边界 refresh/resolve)/
|
|
1329
|
+
`apply_preset`;identity 固定 system;workspace context 走 user 通道;
|
|
1330
|
+
内置 `product/agents/builder`(创建 Agent/Tool/Channel);提示词单源
|
|
1331
|
+
(`FRAMEWORK_PROMPT` / `TOOLS_DESCRIPTION`)
|
|
1332
|
+
- **subagent.py**: 子代理调度——配置解析/配额/审批 pending 通道/生命周期工具
|
|
1333
|
+
(`subagent_wait/status/cancel/session/list/cancel_all`——
|
|
1334
|
+
管理工具集 7 件——2026-08-19)/`parse_subagent_policy`(wait_timeout 配置化)
|
|
1335
|
+
- **revert.py**: 回滚——文件快照逐轮恢复/`revert_stack` 软回退/`record_turn_snapshot`
|
|
1336
|
+
- **checkpoint.py**: git 快照仓库(`SnapshotRepo`——基线/检查点/变更文件提取)
|
|
1337
|
+
- ~~mcp.py / skills.py~~:**2026-08-24 已迁 builtin/**(builtin 独立工具域——方案 C 定稿)——本节不再包含;见 Builtin Tools 节
|
|
1338
|
+
- **instructions.py**: 指令加载与文件监视(Kilo SystemContext 同构)——AGENTS.md
|
|
1339
|
+
新会话注入 system(baseline);变更检测 → 轻量提醒追加对话流(内容不注入、
|
|
1340
|
+
不修改 system);记忆文件(md)同样监视。模型用现有文件工具读写记忆文件
|
|
1341
|
+
(人类可读、跨会话持久,对齐 MiMo-Code data/memory)
|
|
1342
|
+
- **bootstrap.py**: Agent composition root — `build_agent()` assembles LLM/tools/session/
|
|
1343
|
+
context/loop/MCP/skills/cost into a runnable `AgentComponents`. CLI 及其他入口
|
|
1344
|
+
复用此装配,不重复组装。内置工具注册通过 `register_tools` 回调注入
|
|
1345
|
+
(orch 不依赖 builtin 层,保持分层规则)。默认审批决策见 `default_safety_checker()`
|
|
1346
|
+
(策略闭包在 orch/approval.py)。
|
|
1347
|
+
|
|
1348
|
+
### API Layer(展示服务——2026-08-05 四层架构落地)
|
|
1349
|
+
|
|
1350
|
+
- **events.py**: 展示事件协议——`DisplayEvent`(reasoning/text/tool_call/tool_result/
|
|
1351
|
+
confirm_request/done/error + reasoning_end 标记)——展示层唯一消费契约
|
|
1352
|
+
- **stream.py**: 统一流式消费器——`StreamSession(loop, input)` 迭代产出 DisplayEvent
|
|
1353
|
+
(EnvDetailsFilter 过滤/工具计时/消息收集/结束提醒——CLI/TUI 共用(子代理成本独立记账——2026-08-19),
|
|
1354
|
+
消除双展示各自实现的事件消费逻辑)
|
|
1355
|
+
- **orch/log.py**(2026-10-21 由 core 迁入): 会话消息日志——`SessionLog`(统一 reasoning_content 字段——
|
|
1356
|
+
/revert /sessions resume /save /checkpoint 数据源)
|
|
1357
|
+
- **commands.py**: 业务命令注册表——`CommandRegistry`/`CommandContext`(业务
|
|
1358
|
+
命令动作集中:/agent /revert /sessions(list|resume|show|rename|copy|delete) /save /provider /model
|
|
1359
|
+
/thinking /checkpoint /fork 等;**命令数权威口径 = register_commands 注册数**
|
|
1360
|
+
——`check_doc_drift.py` 机械校验,此处不写死数字);`emit(text, level)` 语义级反馈——展示层着色;
|
|
1361
|
+
confirm/select/render_history 经回调注入(api 零依赖展示层)
|
|
1362
|
+
- **approval.py → 已迁 orch/approval.py**(2026-08-26 权限最终精简——规则集
|
|
1363
|
+
构建 + make_checker 策略闭包 + 审计编排归编排层;api 层不再含审批业务)
|
|
1364
|
+
- **media.py**: 媒体附件(media_capabilities / build_media_parts——CLI --image/--audio/--video)
|
|
1365
|
+
- **turn.py**: 回合收尾服务——`prepare_turn`(软回退永久化)/`finalize_turn`
|
|
1366
|
+
(消息入库/轮次快照/自动标题/会话保存;取消轮次仅入 user)
|
|
1367
|
+
- **contract.py**: 渲染安全契约——事件内容一律视为不可信:CLI ANSI 原样安全;
|
|
1368
|
+
TUI markup 拼接前 `escape_markup()`(MarkupError 防护);`truncate` 资源防护
|
|
1369
|
+
|
|
1370
|
+
### CLI Layer
|
|
1371
|
+
|
|
1372
|
+
- **main.py**: CLI entry and REPL loop(命令分发经 api 注册表——业务命令;
|
|
1373
|
+
本地命令 /clear /display /exit /q /quit /t(/N 为 /t N 快捷)保留;
|
|
1374
|
+
/help /verbose /cost-display 已收编到注册表;
|
|
1375
|
+
detach 等待策略——主回合结束、后台子代理继续)
|
|
1376
|
+
- **renderer.py**: Display rendering for real-time and history(直接消费 StreamEvent
|
|
1377
|
+
事件流——2026-09-10 起不再继承已删除的 DisplayBackend;reasoning 全文 dim + thought (N chars) 摘要)
|
|
1378
|
+
- **commands.py**: 本地命令(print_help——由 LOCAL_COMMANDS 表 + 注册表派生 / handle_transcript)
|
|
1379
|
+
- **colors.py**: ANSI 颜色常量单源(2026-08-14 P3 边角——DIM/BOLD/CYAN/GREEN/
|
|
1380
|
+
YELLOW/RED/RESET 此前在 commands/renderer/main/picker 四文件重复;其余
|
|
1381
|
+
文件 re-export 保持既有导入路径兼容)
|
|
1382
|
+
- **picker.py**: 交互选择器(interactive_select——/provider /model /agent 无参弹出;`/sessions resume <view>` 无 id 时在视图内选择)
|
|
1383
|
+
- **auth.py**: API 密钥快速配置向导(2026-08-15——`config auth [--target local|user]`
|
|
1384
|
+
两级写入;密钥零回显、幂等;非 tty 降级 input 不阻塞)
|
|
1385
|
+
- **prompts.py**: 命令清单单源说明(注册表 command_names() + cli/commands.LOCAL_COMMANDS
|
|
1386
|
+
——补全/帮助派生自同一来源)
|
|
1387
|
+
|
|
1388
|
+
### TUI Layer(2026-08-16 归档 code/archived/tui/——冻结重设计,发行包不含)
|
|
1389
|
+
|
|
1390
|
+
重做时取回:与 CLI 共用装配/命令/回合收尾(api 层),textual 依赖随重做加回。
|
|
1391
|
+
|
|
1392
|
+
### Builtin Tools
|
|
1393
|
+
|
|
1394
|
+
- **file_tools.py**: File operations (read, write, edit, grep, glob——媒体编码单源 core.media)
|
|
1395
|
+
- **shell_tool.py**: Shell command execution with safety checks(沙箱可插拔——
|
|
1396
|
+
沙箱版/直连版单一注册语义)
|
|
1397
|
+
- **subagent_tool.py**: subagent 工具族(7 件——2026-08-19 管理工具集;结果格式化
|
|
1398
|
+
单源委托 orch.SubAgentManager.format_result)
|
|
1399
|
+
- **minimal_subagent.py**: 极简子代理执行器(通道一——仅依赖内核;嵌套能力恒存在
|
|
1400
|
+
(无 allow_nested)+ max_total 每节点一份;2026-09-10 / S2 2026-11-30)
|
|
1401
|
+
- **mcp.py / skills.py**: MCP 客户端管理 / Skill 发现与工具(2026-08-24 自 orch 迁入)
|
|
1402
|
+
- **model_info_tool.py**: 模型目录查询(供应商/模型/档位/成本/能力——[subagent] allow_model_change 相关)
|
|
1403
|
+
- **persistent_tool.py**: 持久化注入管理(persistent_list/add/set/show/remove)
|
|
1404
|
+
- **repo_map.py**: 项目代码符号地图(AST + PageRank——2026-09-10 自 core 迁入);
|
|
1405
|
+
工作区目录遍历复用 `file_tools.WorkspaceScanPolicy`(与 code_index 同源)
|
|
1406
|
+
- **shell_manual.py / recall_tool.py / todo_tool.py / webfetch_tool.py**: 操作手册/记忆检索/任务清单/URL 抓取
|
|
1407
|
+
- **registry.py**: 内置工具全集注册(CLI/TUI 单一事实源)
|
|
1408
|
+
|
|
1409
|
+
## 术语约束(Terminology Contract)
|
|
1410
|
+
|
|
1411
|
+
统一推理内容相关术语,防止"双名称"导致的维护性崩塌(历史教训:
|
|
1412
|
+
`reasoning`/`thinking` 混用曾造成流式推理事件在链路中静默丢失)。
|
|
1413
|
+
|
|
1414
|
+
### 依据(参考项目官方表述)
|
|
1415
|
+
|
|
1416
|
+
| 参考项目 | 协议层(供应商字段) | 内部数据模型 |
|
|
1417
|
+
|---|---|---|
|
|
1418
|
+
| DeepSeek-Reasonix | `reasoning_content`(API 字段) | `ReasoningContent`(Go 结构体字段) |
|
|
1419
|
+
| kilocode | `reasoning_content` / `reasoning_text`(协议) | `type: "reasoning"`(内部消息模型) |
|
|
1420
|
+
| MiMo-Code | `reasoning_content`(round-trip 必需字段) | — |
|
|
1421
|
+
| Anthropic(协议特有) | `thinking`(blocks / thinking_delta / thinking 参数) | — |
|
|
1422
|
+
|
|
1423
|
+
**结论**:`reasoning` 是统一术语;`thinking` 是 Anthropic 协议特有命名。
|
|
1424
|
+
|
|
1425
|
+
### 约束规则
|
|
1426
|
+
|
|
1427
|
+
| 层 | 规则 | 示例 |
|
|
1428
|
+
|---|---|---|
|
|
1429
|
+
| **统一事件契约** | 事件类型一律 `"reasoning"` | `StreamEvent(type="reasoning", delta=...)`;`loop` 对外只产 `"reasoning"` |
|
|
1430
|
+
| **数据层** | Turn part type 一律 `"reasoning"` | `Part(type="reasoning", text=...)` |
|
|
1431
|
+
| **协议层(源字段)** | 供应商字段名原样保留,不出现在统一契约 | `reasoning_content`(兼容协议)、`thinking` / `thinking_delta`(Anthropic) |
|
|
1432
|
+
| **协议配置类** | `ThinkingConfig` 保留(对应协议 `thinking` 参数) | 仅 llm 层使用 |
|
|
1433
|
+
| **兼容输入** | 第三方 LLM 若产 `"thinking"` 事件,loop 接受并归一为 `"reasoning"` | `event.type in ("reasoning", "thinking")` |
|
|
1434
|
+
| **展示层** | 渲染方法命名 `reasoning_*` / `on_reasoning` | `renderer.reasoning_delta()` |
|
|
1435
|
+
| **内部变量** | 非契约的局部变量可自由命名(`thinking_buf` 等) | 不参与契约 |
|
|
1436
|
+
|
|
1437
|
+
### 检查方式
|
|
1438
|
+
|
|
1439
|
+
```bash
|
|
1440
|
+
# 契约点不应出现 "thinking"(协议源字段与兼容层除外):
|
|
1441
|
+
# event.type == "thinking" / type="thinking" / on_thinking / thinking_delta 等
|
|
1442
|
+
python scripts/check_terminology.py # 如启用
|
|
1443
|
+
```
|
|
1444
|
+
|
|
1445
|
+
## 提示词可配置性(Prompt Configurability)
|
|
1446
|
+
|
|
1447
|
+
内置提示词全部可传入/可覆盖,分层职责:
|
|
1448
|
+
|
|
1449
|
+
| 层 | 覆盖方式 | 可覆盖项 |
|
|
1450
|
+
|---|---|---|
|
|
1451
|
+
| 内核(core) | 构造参数 | `CompactionPolicy(summary_prompt=)`(摘要提示词)、`AgentLoop(messages=)`(压缩/doom loop/max_turns 反馈消息,见 `DEFAULT_LOOP_MESSAGES`) |
|
|
1452
|
+
| 编排(orch) | `BuildConfig` | `summary_prompt` / `loop_messages` / `env_block`(环境块模板,见 `DEFAULT_ENV_BLOCK`)/ `memory_note_template` / `instructions_template` / `reminder_templates`——build_agent 透传给内核 |
|
|
1453
|
+
| 展示(cli/tui) | `deeparche.toml [prompts]` 节 | `framework_prompt` / `tools_description`(覆盖内置默认——`FRAMEWORK_PROMPT` / `TOOLS_DESCRIPTION` 单源在 `orch/agents.py`,CLI/TUI 共用基座)及以上全部项 |
|
|
1454
|
+
|
|
1455
|
+
规则:所有提示词为**装配期静态**(会话内 system 字节不变)——不破坏前缀缓存;`None` = 使用各层默认值(默认值与历史行为一致)。
|
|
1456
|
+
|
|
1457
|
+
## 后台任务等待语义(wait_policy)
|
|
1458
|
+
|
|
1459
|
+
| 策略 | 语义 | 使用方 |
|
|
1460
|
+
|---|---|---|
|
|
1461
|
+
| `wait_all`(引擎默认) | done 前等待全部后台任务完成并注入结果(主回合不空悬) | API 使用方显式选择 |
|
|
1462
|
+
| `detach`(展示默认) | done 直接返回——后台任务继续运行;结果由上层 drain(CLI 输入前 / TUI 每秒刷新)收集——打印 + `context.inject`(一次性——下轮模型可感知) | CLI/TUI("主等待、子继续") |
|
|
1463
|
+
|
|
1464
|
+
## 审批事件通道(confirm_request——2026-08-26 最终精简)
|
|
1465
|
+
|
|
1466
|
+
- 主代理工具审批:`confirm_request` 事件 → 展示层弹窗(CLI prompt_toolkit /
|
|
1467
|
+
TUI 内联面板)→ 决策经 `loop.resolve_confirm` 三值回传(approve / deny /
|
|
1468
|
+
remember——remember = 会话内同类放行——loop 持有缓存)
|
|
1469
|
+
- 子代理审批(2026-08-19 恒上浮——用户定稿):pending 队列阻塞(子代理
|
|
1470
|
+
线程)→ 父线程 tick 弹窗 → 决策经 `resolve_approval` 回传
|
|
1471
|
+
- 最小语义(2026-08-26 用户定稿):**审批开关缺省关**——直接调用内核
|
|
1472
|
+
(evaluate——无 checker)工具全部放行——开发者需要审批时显式开启
|
|
1473
|
+
(permissions.toml `[approval] enabled = true`)并注入 checker
|
|
1474
|
+
- 职责分离(最终形态):
|
|
1475
|
+
- 内核(core/permission.py):Resource/Rule 数据契约 + evaluate 纯匹配
|
|
1476
|
+
(规则参数化 → allow/deny/None——未命中不落策略)——审批原语在 loop
|
|
1477
|
+
(yield confirm_request → resolve_confirm)
|
|
1478
|
+
- 编排(orch/approval.py):规则集构建(来源层 permissions.toml + 默认
|
|
1479
|
+
资源 pack)+ make_checker 策略闭包(资源级匹配 + 越界检查 + 未命中策略)
|
|
1480
|
+
+ 审计——注入 loop.safety_checker(loop 零权限知识——只有 ask 协议)
|
|
1481
|
+
- 决策来源透明:内核不管同意/拒绝来自配置规则还是用户审批
|
|
1482
|
+
- 旧机制(状态机 request/pending/reply、request_permissions 工具、on-request
|
|
1483
|
+
模式、多审批人、运行时写盘)已删除——不复活
|
|
1484
|
+
|
|
1485
|
+
### 工作区根与资源规则(当前)
|
|
1486
|
+
|
|
1487
|
+
```toml
|
|
1488
|
+
[workspace."D:/projects/app"] # 信任工作区(键控登记;路径按绝对路径解析)
|
|
1489
|
+
name = "app"
|
|
1490
|
+
[permissions]
|
|
1491
|
+
rules_mode = "extend" # extend(默认 pack + rules)| replace(仅 rules)
|
|
1492
|
+
rules = [
|
|
1493
|
+
{ action = "file_*", resource = "fs:**", effect = "allow" },
|
|
1494
|
+
{ action = "*", resource = "cmd:mkfs*", effect = "deny" },
|
|
1495
|
+
]
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
- **cmd 是前缀语义(非 glob)**:`cmd:foo` ≡ `cmd:foo*`;任意命令写 `cmd:*`;
|
|
1499
|
+
`cmd:**` 永不命中——加载期点名告警。
|
|
1500
|
+
- **资源级裁决**:每个 Resource 独立匹配;同资源 deny > allow;跨资源
|
|
1501
|
+
deny > ask > allow;规则顺序不是安全优先级。`Rule.effect` 只有 allow/deny。
|
|
1502
|
+
- **默认 pack**:action=`*` 的明确危险设备 fs 规则;安全目标不生成 deny。
|
|
1503
|
+
- **工作区 fs 编译**:`fs:**` 在 build_rules 编译期展开为每个信任根的
|
|
1504
|
+
`fs:<root>/**`——根内命中、根外未命中;越界判定走同一 roots 集合。
|
|
1505
|
+
- **路径归一化**:生成 fs 资源前做 `//`、`.`、`..` 词法归一;相对路径必须
|
|
1506
|
+
有 work_dir;不解析 symlink、不改变执行文本。
|
|
1507
|
+
|
|
1508
|
+
## 工具契约(Tool Contract)
|
|
1509
|
+
|
|
1510
|
+
- 工具执行函数必须返回字符串
|
|
1511
|
+
- **返回字符串以 `Error:` 开头 = 工具失败**(AgentLoop 据此判定 `tool_status="error"`)
|
|
1512
|
+
- 工具参数类型自动转换(字符串 → 整数/浮点数),见 `core/tools.py`
|
|
1513
|
+
|
|
1514
|
+
## 能力双通道注册规范(2026-08-25 定稿——分离注册重建)
|
|
1515
|
+
|
|
1516
|
+
**核心**:给模型的(工具)与给用户的(命令)是**两个独立数据结构、两条原生
|
|
1517
|
+
视图**——注册函数合一产出两者——可见性由注册位置显式决定——无派生无过滤。
|
|
1518
|
+
|
|
1519
|
+
```python
|
|
1520
|
+
# core/tools.py——ToolDef(模型通道)与 CommandDef(用户通道)并列独立类
|
|
1521
|
+
registry.add(ToolDef(name="file_read", ...)) # → 模型视图(list_schemas)
|
|
1522
|
+
registry.add_command(CommandDef("/tools", "列表", h)) # → 用户视图(REPL /xxx——免审批)
|
|
1523
|
+
```
|
|
1524
|
+
|
|
1525
|
+
| 通道 | 数据结构 | 入口 | 调用者 | 权限 |
|
|
1526
|
+
|------|---------|------|--------|------|
|
|
1527
|
+
| model | `ToolDef` | `list_schemas()` → tools 参数 | 模型 | 工具调用面;`risk_level`/`permission` 是风险/审查元数据(reviewer 参考),**不是**审批执行开关 |
|
|
1528
|
+
| command | `CommandDef` | `find_command()` → REPL /xxx | 用户 | **免审批**(用户明确调用) |
|
|
1529
|
+
|
|
1530
|
+
**CommandDef 字段**:`name`(含 / 前缀)/ `help`(/help 展示)/ `handler(ctx, arg_str)`
|
|
1531
|
+
(ctx duck typing——不 import 上层——builtin 零依赖 api)/ `aliases`(并入查找表)。
|
|
1532
|
+
|
|
1533
|
+
**ToolRegistry 命令方法**:`add_command`(**幂等替换**——同名覆盖不抛错——
|
|
1534
|
+
防重复装配/热重载)/ `find_command`(split 首词 + 小写 + 别名解析)/
|
|
1535
|
+
`list_commands`(按 name 去重排序)/ `command_names`(含别名——Tab 补全单源)。
|
|
1536
|
+
|
|
1537
|
+
**ToolRegistry scope 替换**:`replace_scope(scope, register)`(2026-12-01)——
|
|
1538
|
+
`snapshot -> unregister_scope(scope) -> register(self) -> 失败 restore`。只替换
|
|
1539
|
+
该 scope 的**工具**;命令/别名归包注册(`RegistrationPlan`)管理。用于 MCP
|
|
1540
|
+
`mcp__<server>` 整组注册/重绑定:预期刷新不触发同名覆盖 warning,真正跨源
|
|
1541
|
+
同名仍由 `_insert` 可见;不得用它绕过包 registrar 的 commands/aliases 替换。
|
|
1542
|
+
|
|
1543
|
+
**双视图洁净(硬契约)**:
|
|
1544
|
+
- 模型视图 = `_tools`(list_schemas 纯三字段 name/description/parameters——
|
|
1545
|
+
**零命令零 meta**——缓存红线)
|
|
1546
|
+
- 用户视图 = `_commands`——命令独立存在(可无对应工具——如 /tools——
|
|
1547
|
+
纯用户入口;工具可无对应命令——如 file_read——纯模型能力)
|
|
1548
|
+
- `clone` **零命令**(视图构建原语);智能体/子代理消费端由
|
|
1549
|
+
`CapabilitySetBuilder` 在该工具视图上注入命令层(always-on + 包命令),
|
|
1550
|
+
不依赖 clone 复制命令
|
|
1551
|
+
- 共享函数是**显式选择**(命令 handler 闭包调工具 fn)——不是机制耦合
|
|
1552
|
+
|
|
1553
|
+
**注册归属(同一注册表——builtin 10 + api 31 = 41;命令数权威口径 =
|
|
1554
|
+
register_commands 注册数,check_doc_drift.py 机械校验)**:
|
|
1555
|
+
- builtin 能力命令(10):/tools(registry——独立实现)/notices(通知投影)/
|
|
1556
|
+
code_index(代码索引)/todo(todo 清单)/skills(skills——薄封装 skill_list)/
|
|
1557
|
+
persistent(persistent_tool——含 set/show/remove——handler 原在 api 迁入)/
|
|
1558
|
+
mcp(mcp——薄封装 _cmd_dispatch)/subagent-cancel(subagent_tool——handler
|
|
1559
|
+
原在 api 迁入)/goal(goal pack)/feishu(feishu_notify pack)——随工具
|
|
1560
|
+
注册函数合一产出;/tools /notices 为 builtin 全局命令;hot_reload 工具由
|
|
1561
|
+
product:hot_reload pack 提供,/reload 为 api 全局 always-on 命令。
|
|
1562
|
+
- api 业务命令(31):`register_commands(scoped)`——always-on 层随每个
|
|
1563
|
+
scoped registry 构建注入(0.50.0 Phase 3;不再装配后补注册 master);
|
|
1564
|
+
子代理 scoped registry 同样注入(工具级 invocation 不清命令);子实例
|
|
1565
|
+
全局 + 类型级 MCP 由 `agent_instance_loader` 以独立 manager 启停
|
|
1566
|
+
(builder 不物化 MCP——无双启)
|
|
1567
|
+
- 展示本地命令(cli):/clear /display /exit /q /quit /t(/N 为 /t N 快捷)
|
|
1568
|
+
|
|
1569
|
+
**消费路径**:REPL 分发 = 当前 scoped `find_command`(单源——无 scan 兜底);
|
|
1570
|
+
completer 补全 = 当前 scoped `command_names()`;`/tools` 显示当前 scoped
|
|
1571
|
+
(handler 经 ctx.tools——切换后反映当前能力集)。
|
|
1572
|
+
|
|
1573
|
+
**判定标准(新增能力时的注册位置)**:
|
|
1574
|
+
- 模型执行任务需要 → 注册**工具**(参数化 schema;审批由 permissions.toml 规则决定)
|
|
1575
|
+
- 用户手动操作需要 → 注册**命令**(字符串参数——免审批)
|
|
1576
|
+
- 两者都需要 → 同一注册函数内分别注册(共享底层函数——显式选择)
|
|
1577
|
+
- 都不要 → 不注册
|
|
1578
|
+
|
|
1579
|
+
**废弃机制(不复活)**:ToolDef.meta 字段、api/command_sources.py
|
|
1580
|
+
(scan/merge/make_execute)、"command-only 工具"概念——一律不再使用。
|
|
1581
|
+
|
|
1582
|
+
## 智能体能力管理(2026-08-25 定稿——tools 管理器统一)
|
|
1583
|
+
|
|
1584
|
+
**核心**:智能体的能力面(哪些工具可见)由**声明式工具过滤 + 智能体级能力**
|
|
1585
|
+
表达——`AgentPreset.read_only`(2026-08-24 的"只读视图原语")**已移除**
|
|
1586
|
+
(粗粒度按工具性质一刀切——plan 智能体连计划文件都写不了——设计缺陷)。
|
|
1587
|
+
`ToolDef.read_only` 保留(工具性质标注——非权限字段)。
|
|
1588
|
+
|
|
1589
|
+
**智能体级能力面(agent.toml)**:
|
|
1590
|
+
|
|
1591
|
+
```toml
|
|
1592
|
+
[agent]
|
|
1593
|
+
name = "plan"
|
|
1594
|
+
tools = ["tools/plan_writer/tool.toml"] # 智能体级专用工具(仅此智能体可见)
|
|
1595
|
+
|
|
1596
|
+
[tools.policy] # 工具面策略(六字段——工具级过滤)
|
|
1597
|
+
only_tools = ["file_read", "file_grep"] # 缺省=全部;[]=空集
|
|
1598
|
+
exclude_tools = ["file_write", "shell_execute"]
|
|
1599
|
+
```
|
|
1600
|
+
|
|
1601
|
+
- **工具面策略**:global / agent / 子代理同构 `[tools.policy]` 六字段;先合并为
|
|
1602
|
+
单一 effective policy(only 交集 / exclude 并集 / exclude 胜出)。资源/包级
|
|
1603
|
+
在注册前整包跳过(命令随包);工具级视图构建 = `CapabilitySetBuilder`
|
|
1604
|
+
(`agent_tools_view` 为兼容包装——内部同一构建器;只有 only/exclude,无自动保留)。
|
|
1605
|
+
- **智能体级能力(0.50.0 Phase 3)**:`[agent] skills/tools/mcp`(相对
|
|
1606
|
+
agent.toml)先作为**定义**进入定义池;每个 agent 状态由
|
|
1607
|
+
`CapabilitySetBuilder(effective policy)` 构建**一份 scoped registry**——
|
|
1608
|
+
包拒绝 -> 整包工具/命令不注册、MCP 不连接;准入 -> 完整能力。
|
|
1609
|
+
scoped registry 是唯一消费源(REPL/API/动作/`/tools` 均读它);master
|
|
1610
|
+
只作定义池/诊断,不承载运行期 MCP/技能/子代理注册。
|
|
1611
|
+
- **注册/卸载顺序**:切换时先卸载上一预设的智能体级定义/技能目录,再构建
|
|
1612
|
+
当前 scoped registry(旧工具不得进入新能力集)。
|
|
1613
|
+
- **热重载事务(2026-12-01)**:源仍只有 `tools` / `mcp`。`tools` 源刷新在
|
|
1614
|
+
work clone 上经 `RegistrationPlan` 按包原子替换 tools+commands+aliases,
|
|
1615
|
+
包删除/改名由 catalog 退役;`mcp` 源把 `MCPManager` rebind 到 work clone 再
|
|
1616
|
+
aggregate(start/stop/restart/sync 全部作用于 work),成功提交后 manager
|
|
1617
|
+
指回原表;失败不提交 work,但清理原表受影响的 `mcp__<server>` scope,
|
|
1618
|
+
保证 registry/session 一致、无 stale 工具。global 与当前 agent 同名 server
|
|
1619
|
+
按 agent 覆盖 global(global 同名项让位、旧 owner 清理)并 warning;
|
|
1620
|
+
agent→agent 同名切换则在当前 agent sync 前先停旧 agent owner/session,
|
|
1621
|
+
由当前 agent 接管,不产生 "already running"。
|
|
1622
|
+
|
|
1623
|
+
**plan 智能体范式(2026-08-25 重建)**:计划制定 = 纯构建——`exclude_tools`
|
|
1624
|
+
写工具黑名单(不碰工作区)+ 智能体级 `plan_writer` 专用工具(唯一写通道——
|
|
1625
|
+
路径硬约束 `.deeparche/plans/`——realpath 前缀校验)——批准后**提醒用户自行
|
|
1626
|
+
切换执行智能体**(不自动切换——切换决策权归用户)——计划文件是交接资产。
|
|
1627
|
+
|
|
1628
|
+
## 工作区边界与回滚(Workspace & Checkpoint)
|
|
1629
|
+
|
|
1630
|
+
### 工作区边界(默认只允许工作区内)
|
|
1631
|
+
|
|
1632
|
+
- `file_tools` 路径守卫:resolve + 前缀检查——**工作区外访问默认拒绝**(安全默认)
|
|
1633
|
+
- **工作区外访问需申请**:配置 `SafetyPolicy` confirm 规则放行特定路径
|
|
1634
|
+
(`deeparche.toml [safety]` + `PermissionRule(level="confirm")` → 工具调用需用户确认,见 confirm_request 事件)
|
|
1635
|
+
|
|
1636
|
+
### 代码回滚(git 快照仓库,对齐 Kilo Snapshot 服务)
|
|
1637
|
+
|
|
1638
|
+
- **原理**:独立快照仓库(`--git-dir .deeparche/snapshot/` + `--work-tree {work_dir}`)——
|
|
1639
|
+
用户 `.git`(index/HEAD/stash)**零操作**;用户项目无需是 git 仓库
|
|
1640
|
+
- **基线**:会话开始记录工作区状态(`SnapshotRepo.baseline()`)
|
|
1641
|
+
- **检查点**:`/checkpoint` 命令记录(`SnapshotRepo.checkpoint()`)
|
|
1642
|
+
- **回滚**:`/revert both|context|files [n|检查点]` 恢复代码/上下文
|
|
1643
|
+
(`status` 只读、`undo` 按栈条目 scope 撤销)——**优先用逐轮快照 git diff 恢复
|
|
1644
|
+
该轮改过的文件**(`record_turn_snapshot` 记录每轮变更,含 file_write/file_edit/
|
|
1645
|
+
shell 删除等——`orch/revert.py`);消息中提取 path 仅是 fallback
|
|
1646
|
+
(2026-08-05 审计:文档修正——代码比文档更先进),用户自己的修改不受影响
|
|
1647
|
+
- **非 git 环境**:检查点/回滚不可用(提示),会话持久化不受影响
|
|
1648
|
+
- 归属:`orch/revert.py` + `orch/checkpoint.py`(编排层);内核零改动
|
|
1649
|
+
|
|
1650
|
+
### 多模态媒体能力(2026-08-01 定版,真实端点实测)
|
|
1651
|
+
|
|
1652
|
+
- **配置**:`[models."<模型名>"] modalities = ["text", "image", "audio", "video"]`(模型级能力;
|
|
1653
|
+
解析链:CLI > 具体模型 > 通配 > 内置 `MODEL_MODALITIES` 能力表 > 保守纯文本);
|
|
1654
|
+
视频参数 `video_fps` / `video_resolution`(MiMo 官方:fps 默认 2 范围 [0.1,10])
|
|
1655
|
+
- **双层门控**:模型模态 ∩ 协议模态(`llm/media.py` `PROTOCOL_MODALITIES` 实测表)→
|
|
1656
|
+
支持则真媒体块,否则占位文本——非法块永不达 API,上下文永不损坏
|
|
1657
|
+
- **实测能力矩阵**(2026-08-01 三轮 30 用例真实 MiMo 端点):
|
|
1658
|
+
| 模态 | compatible(/v1) | responses | claude(/anthropic) |
|
|
1659
|
+
|------|----------------|-----------|--------------------|
|
|
1660
|
+
| 图片 | ✓ image_url | ✓ 仅标准 input_image | ✓ 仅标准 image 块 |
|
|
1661
|
+
| 音频 | ✓ input_audio(data 承载 URL/dataURL) | ✗ 400 拒绝 | ✗ 静默忽略(必须门控) |
|
|
1662
|
+
| 视频 | ✓ video_url(fps/media_resolution) | ✗ 400 拒绝 | ✗ 静默忽略(必须门控) |
|
|
1663
|
+
**等协议/模型厂商扩展支持后**:更新 `PROTOCOL_MODALITIES` 表与对应 wire 构造即可启用
|
|
1664
|
+
- **媒体传入**:CLI `--image/--audio/--video <路径|URL>`(本地文件自动 base64 编码,
|
|
1665
|
+
官方限制 base64 ≤50MB;公网 URL 直传);输入框路径粘贴检测仅提示不自动注入
|
|
1666
|
+
- **持久化与切换**:Part 存完整媒体(media_url/media_base64/media_path/mime_type)→
|
|
1667
|
+
模型切换后序列化时按新模型重新门控(自动恢复/再次占位);回滚/快照无损
|
|
1668
|
+
- **压缩安全**:媒体 base64 不进入摘要请求(`[Attached <mime>: <name>]` 留痕);
|
|
1669
|
+
媒体 token 计入压缩预算(base64 长度保守估算,core 零依赖)
|
|
1670
|
+
- **缓存安全**:媒体在 user 消息(不在 system 前缀);同模型同会话序列化确定性;
|
|
1671
|
+
模态声明绝不注入 system(防止切换模型破坏前缀缓存);实测媒体请求缓存命中正常
|
|
1672
|
+
- **职责**:`core/media.py`(MIME/格式知识,零依赖)→ `llm/media.py`(协议块/门控/估算)
|
|
1673
|
+
→ `adapter.py`(三协议接入)→ `context.py`(组装)→ `cli/main.py`(入口)
|
|
1674
|
+
|
|
1675
|
+
## Verification
|
|
1676
|
+
|
|
1677
|
+
Run dependency checks:
|
|
1678
|
+
```bash
|
|
1679
|
+
python code/deeparche/scripts/check_dependencies.py # 层依赖规则(含 api/tui)
|
|
1680
|
+
python code/deeparche/scripts/check_terminology.py # 术语一致性(reasoning 统一)
|
|
1681
|
+
python code/deeparche/scripts/check_feature_tree.py # 功能实现树漂移检测(生成区与代码一致)
|
|
1682
|
+
```
|
|
1683
|
+
|
|
1684
|
+
Test suites(tests/ 目录——**193 个测试套件 + 21 个检查脚本 = 214 项**全量回归,`run_all_tests.py` / `run_all_tests.ps1` 一键;数字以 `run_all_tests.py` 实测为准——2026-12-02 校准):
|
|
1685
|
+
```bash
|
|
1686
|
+
python code/deeparche/tests/test_api.py # api 层(展示服务)
|
|
1687
|
+
python code/deeparche/tests/test_subagent.py # 子代理
|
|
1688
|
+
python code/deeparche/tests/test_subagent_persistence.py # 有状态子代理(9 项)
|
|
1689
|
+
python code/deeparche/tests/test_loop_unit.py # 内核循环
|
|
1690
|
+
# ... 其余套件(imports/functionality/approval/background/agents 等)
|
|
1691
|
+
```
|
|
1692
|
+
|
|
1693
|
+
Import tests:
|
|
1694
|
+
```python
|
|
1695
|
+
import deeparche.core.types
|
|
1696
|
+
import deeparche.llm.adapter
|
|
1697
|
+
import deeparche.orch.session
|
|
1698
|
+
import deeparche.product.api
|
|
1699
|
+
import deeparche.product.cli.main
|
|
1700
|
+
```
|