Skip to content

Commit 9e44f4a

Browse files
committed
refactor(product-domains): externalize guarded domain helpers
Move MiniApp and function-agent pure contracts/helpers into bitfun-product-domains while keeping core as the runtime owner and compatibility facade. Add core-owned adapter equivalence tests and update decomposition guardrails for the remaining runtime migration boundaries.
1 parent 0b51233 commit 9e44f4a

44 files changed

Lines changed: 2736 additions & 1103 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS-CN.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ BitFun 是一个由 Rust workspace 与共享 React 前端组成的项目。
1818
|---|---|---|
1919
| Core(产品逻辑) | `src/crates/core` | [AGENTS.md](src/crates/core/AGENTS.md) |
2020
| 已拆出的 core 支撑 crate | `src/crates/{core-types,agent-stream,runtime-ports,terminal,tool-runtime}` | (使用 core 指南) |
21-
| Core owner crate | `src/crates/{services-core,services-integrations,agent-tools,tool-packs,product-domains}` | (使用 core 指南 + 拆解护栏) |
21+
| Core owner crate | `src/crates/{services-core,services-integrations,agent-tools,tool-packs}` | (使用 core 指南 + 拆解护栏) |
22+
| 产品领域 crate | `src/crates/product-domains` | [AGENTS.md](src/crates/product-domains/AGENTS.md) |
2223
| Transport 适配层 | `src/crates/transport` | (使用 core 指南) |
2324
| API layer | `src/crates/api-layer` | (使用 core 指南) |
2425
| AI adapters | `src/crates/ai-adapters` | [AGENTS.md](src/crates/ai-adapters/AGENTS.md) |
@@ -118,8 +119,9 @@ await api.invoke('your_command', { request: { ... } });
118119
### Tool 归属护栏
119120

120121
- `src/crates/agent-tools` 拥有轻量 tool contract,以及 generic registry / dynamic-provider container。
121-
- `src/crates/core/src/agentic/tools/registry.rs` 只负责产品工具组装`dyn Tool` 适配和 snapshot decoration。
122+
- `src/crates/core/src/agentic/tools` 当前负责产品工具组装`dyn Tool` 适配、snapshot decoration、tool exposure / manifest resolution,以及按需工具说明发现(`GetToolSpec`
122123
- `ToolUseContext` 与具体工具实现继续留在 core,直到有已评审的 port/provider 设计和等价测试。
124+
- Tool 迁移必须保持 expanded/collapsed exposure、prompt 可见 manifest、`ToolUseContext.unlocked_collapsed_tools`,以及 desktop/MCP/ACP tool catalog 行为等价。
123125

124126
### DeepReview 护栏
125127

AGENTS.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Repository rule: **keep product logic platform-agnostic, then expose it through
1818
|---|---|---|
1919
| Core (product logic) | `src/crates/core` | [AGENTS.md](src/crates/core/AGENTS.md) |
2020
| Extracted core support | `src/crates/{core-types,agent-stream,runtime-ports,terminal,tool-runtime}` | (use core guide) |
21-
| Core owner crates | `src/crates/{services-core,services-integrations,agent-tools,tool-packs,product-domains}` | (use core guide + decomposition guardrails) |
21+
| Core owner crates | `src/crates/{services-core,services-integrations,agent-tools,tool-packs}` | (use core guide + decomposition guardrails) |
22+
| Product domains | `src/crates/product-domains` | [AGENTS.md](src/crates/product-domains/AGENTS.md) |
2223
| Transport adapters | `src/crates/transport` | (use core guide) |
2324
| API layer | `src/crates/api-layer` | (use core guide) |
2425
| AI adapters | `src/crates/ai-adapters` | [AGENTS.md](src/crates/ai-adapters/AGENTS.md) |
@@ -121,10 +122,14 @@ and milestone verification gates.
121122

122123
- `src/crates/agent-tools` owns lightweight tool contracts and the generic
123124
registry / dynamic-provider container.
124-
- `src/crates/core/src/agentic/tools/registry.rs` owns product tool assembly,
125-
`dyn Tool` adaptation, and snapshot decoration only.
125+
- `src/crates/core/src/agentic/tools` owns product tool assembly, `dyn Tool`
126+
adaptation, snapshot decoration, tool exposure / manifest resolution, and
127+
on-demand tool spec discovery (`GetToolSpec`) for now.
126128
- Keep `ToolUseContext` and concrete tool implementations in core until a
127129
reviewed port/provider design and equivalence tests exist.
130+
- Tool migrations must preserve expanded/collapsed exposure, prompt-visible
131+
manifests, `ToolUseContext.unlocked_collapsed_tools`, and desktop/MCP/ACP
132+
tool catalog behavior.
128133

129134
### DeepReview guardrails
130135

docs/architecture/core-decomposition.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Rust 编译和链接面。
6666
| `bitfun-agent-stream` | Stream 聚合和 stream-focused 测试 |
6767
| `bitfun-runtime-ports` | 面向 service/agent 边界的轻量跨层 DTO 和 trait |
6868
| `bitfun-agent-runtime` | Sessions、execution、coordination、agent system |
69-
| `bitfun-agent-tools` | Tool trait、context、registryprovider contract |
69+
| `bitfun-agent-tools` | 轻量 tool DTO / contract、runtime restriction、generic registry / provider container |
7070
| `bitfun-tool-packs` | 由 feature group 隔离的具体工具实现 |
7171
| `bitfun-services-core` | Config、session、workspace、storage、filesystem、system services |
7272
| `bitfun-services-integrations` | Git、MCP、remote SSH、remote connect、file watch integrations |
@@ -113,6 +113,11 @@ owner 边界,否则不要把一个 feature group 继续拆成更小的 crate
113113
- 最新主干已把 subagent 可见性做成 mode-scoped registry 行为。迁移 agent registry 或
114114
subagent definitions 前,必须先保留 mode visibility、hidden/custom/review 分组和 desktop
115115
subagent API 等价测试;在此之前它们仍属于 `bitfun-core` product runtime assembly。
116+
- 最新主干新增 on-demand tool spec discovery。`ToolExposure``GetToolSpec`
117+
`manifest_resolver`、collapsed-tool catalog、context-aware tool schema/description
118+
`ToolUseContext.unlocked_collapsed_tools` 暂时属于 `bitfun-core` product tool runtime;
119+
迁移前必须证明 prompt-visible manifest、expanded/collapsed exposure、unlock state 与
120+
desktop/MCP/ACP tool catalog 等价。
116121
- 最新 CLI 重构新增大量 TUI、theme、selector、dialog 和 chat-state 代码,但仍位于
117122
`src/apps/cli`。后续 core decomposition 只能通过产品 check 验证 CLI 仍可组装,不应把
118123
CLI presentation 依赖迁入 core-types、runtime-ports 或 agent-tools。
@@ -123,22 +128,30 @@ owner 边界,否则不要把一个 feature group 继续拆成更小的 crate
123128
contract 搬迁、旧路径 re-export、序列化 round-trip 测试、未启用的新 feature group 声明。
124129
- 中风险:在 owner crate 内为纯模块补 feature group、把 core 中的重依赖改为 optional 但
125130
仍由 `product-full` 启用、把只依赖 port 的 helper 迁入 owner crate。
126-
- 高风险:`ToolUseContext`、tool registry / MCP registry owner 化、remote-connect、remote SSH
127-
runtime、miniapp / function-agent runtime、agent registry、`bitfun-core default = []`
131+
- 当前 `product-domains` 可继续承载 MiniApp runtime search plan、worker install 命令选择、
132+
package.json storage-shape helper、lifecycle / revision helper、host routing string helper 等纯决策 /
133+
解析逻辑;实际 runtime detection、worker pool、storage IO、PathManager、进程执行、
134+
host dispatch 执行与 builtin asset seeding 仍留在 core product runtime。
135+
- `product-domains` 可以先定义 MiniApp runtime/storage 与 function-agent Git/AI 的 port
136+
contract;core-owned adapter 只能在不改变执行路径的前提下委托现有 service,并先补等价
137+
测试。IO/进程/AI/Git 执行 owner 迁移仍属于后续高风险步骤。
138+
- 高风险:`ToolUseContext`、product tool registry / manifest / exposure / `GetToolSpec` owner 化、
139+
MCP concrete tool integration、remote-connect、remote SSH runtime、miniapp / function-agent runtime、
140+
agent registry、`bitfun-core default = []`
128141
或任何产品 crate feature set 调整。
129142
- 高风险项不能作为 P2/P3 普通收尾任务顺带执行,必须先有等价性测试、port/provider 设计、
130143
旧路径兼容策略和用户确认。
131144
- 为减少 PR 次数,后续 runtime 迁移沿用 5 个主题 PR 的队列约束,每个 PR 仍必须保持单一
132145
owner 主题:`services-integrations` runtime 收口、MCP runtime/dynamic tools、
133146
remote-connect runtime、agent tools + `tool-packs` owner 化、`product-domains`
134147
runtime + core facade finalization。PR 2 的 MCP runtime/dynamic tools 已完成;后续不得把
135-
remote-connect、tool registry owner 化或 product-domain runtime 顺带混入已完成的 MCP PR。
148+
remote-connect、product tool manifest/exposure owner 化或 product-domain runtime 顺带混入已完成的 MCP PR。
136149
`bitfun-core default = []` 和 per-product feature matrix 仍是上述 runtime 队列之后的独立评估。
137150
- PR 2 的 MCP 迁移已覆盖 config service orchestration、server process / local-remote
138151
transport lifecycle、resource/prompt adapter、catalog cache、list-changed / reconnect policy、
139152
dynamic tool descriptor、dynamic tool provider 与 result rendering。`bitfun-core` 保留
140153
core `ConfigService` store adapter、OAuth data-dir 注入、`BitFunError` 映射、旧路径 facade
141-
和全局 tool registry 组装;tool registry owner 化仍归后续 tool/provider PR。
154+
和全局 tool registry / manifest 组装;product tool manifest/exposure owner 化仍归后续 tool/provider PR。
142155

143156
## 产品表面边界(Product Surface Boundary)
144157

@@ -187,7 +200,8 @@ BitFun 的重构目标不是把 Desktop、CLI、Remote、Server 和 ACP 强行
187200
- 如果变更影响 feature assembly、产品 crate manifest、desktop integration、CLI、
188201
server 或 transport path,则必须保留完整产品检查。
189202
- 对功能逻辑偏移风险较高的迁移,必须先补“迁移前快照”测试或脚本输出,例如 tool registry
190-
工具清单、dynamic provider metadata、snapshot wrapping 覆盖、remote-connect 消息字段、
203+
工具清单、expanded/collapsed manifest、`GetToolSpec` 插入与 unlock state、
204+
dynamic provider metadata、snapshot wrapping 覆盖、remote-connect 消息字段、
191205
MCP tool/resource/prompt wire shape、miniapp permission policy、function-agent 输入输出契约。
192206
- boundary check 只能证明依赖方向,不能替代产品等价性验证。任何会移动 runtime owner 的 PR
193207
都必须同时说明旧路径兼容方式、产品能力不变证据和失败时的回滚边界。

0 commit comments

Comments
 (0)