Skip to content

Commit 948aa51

Browse files
committed
refactor: move MiniApp host plans and developer tooling
Move MiniApp host call planning into product-domain decisions while keeping runtime execution and permission-sensitive IO in core. Streamline root contributor guidance, move DeepReview-specific rules to local AGENTS files, and guard desktop DevTools shortcuts behind backend availability.
1 parent 8cbbec3 commit 948aa51

21 files changed

Lines changed: 1043 additions & 367 deletions

File tree

AGENTS-CN.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -164,40 +164,6 @@ await api.invoke('your_command', { request: { ... } });
164164
- 产品表面可以有差异;共享稳定 facts 或 ports,不共享 UI、protocol、lifecycle 或平台实现。
165165
- 迁移 runtime owner 必须有评审过的 port/provider 设计、旧路径兼容、行为等价测试;如果可能改变行为边界,还需要先确认。
166166

167-
### DeepReview 护栏
168-
169-
Deep Review / 代码审核团队横跨 core runtime 与 Web UI。target resolution 与
170-
manifest construction 保持在前端;policy validation、queue/retry state 和
171-
report enrichment 保持在 shared core。
172-
173-
### 后端链路
174-
175-
大多数功能建议按这个顺序追踪:
176-
177-
1. `src/web-ui` 或应用入口
178-
2. `src/apps/desktop/src/api/*` 或 server routes
179-
3. `src/crates/api-layer`
180-
4. `src/crates/transport`
181-
5. `src/crates/core`
182-
183-
### `bitfun-core`
184-
185-
`src/crates/core` 是代码库中心。
186-
187-
主要区域:
188-
189-
- `agentic/`:agents、prompts、tools、sessions、execution、persistence
190-
- `service/`:config、filesystem、terminal、git、LSP、MCP、remote connect、project context、AI memory
191-
- `infrastructure/`:AI clients、app paths、event system、storage、debug log server
192-
193-
Agent 运行时心智模型:
194-
195-
```text
196-
SessionManager → Session → DialogTurn → ModelRound
197-
```
198-
199-
会话数据保存在 `.bitfun/sessions/{session_id}/`
200-
201167
## 验证
202168

203169
按触及文件选择最小本地预检。完整构建和大范围测试默认由 CI 保护;只有改动直接影响构建、
@@ -210,7 +176,6 @@ SessionManager → Session → DialogTurn → ModelRound
210176
| Locale contract 或 shared terms | `pnpm run i18n:generate && pnpm run i18n:contract:test && pnpm run i18n:audit` |
211177
| Web UI i18n runtime、namespace loading 或直接 `i18nService.t(...)` 调用 | `pnpm run i18n:contract:test && pnpm run type-check:web && pnpm --dir src/web-ui run test:run src/infrastructure/i18n/core/I18nService.test.ts` |
212178
| Mobile web UI、状态、配对、断开或重连行为 | `pnpm --dir src/mobile-web run type-check`;行为变化还需要在 PR 中说明手动配对 / 重连验证 |
213-
| Deep Review / 代码审核团队行为 | 运行最近的 Web UI 检查,再运行 `cargo test -p bitfun-core deep_review -- --nocapture`;如果触及后端或 Tauri API,还需要运行对应 Rust / 桌面端检查 |
214179
| `core``transport``api-layer` 或共享服务中的 Rust 逻辑 | `cargo check --workspace`;行为变化时再加最近的 focused `cargo test` |
215180
| 桌面端集成、Tauri API、browser/computer-use 或桌面专属行为 | `cargo check -p bitfun-desktop`;行为变化时再加 focused desktop tests |
216181
| 被桌面端 smoke/functional 流覆盖的行为 | 优先运行最近的 focused E2E/smoke check;除非改动影响构建,否则 broad build/test 交给 CI |
@@ -219,20 +184,6 @@ SessionManager → Session → DialogTurn → ModelRound
219184
| 安装器 Tauri/Rust 改动 | `cargo check --manifest-path BitFun-Installer/src-tauri/Cargo.toml` |
220185
| 安装器打包、payload、安装/卸载流程或 native bundling | `pnpm run installer:build` |
221186

222-
## 先看哪里
223-
224-
| 功能 | 关键路径 |
225-
|---|---|
226-
| Agent mode | `src/crates/core/src/agentic/agents/``src/crates/core/src/agentic/agents/prompts/``src/web-ui/src/locales/*/scenes/agents.json` |
227-
| Deep Review / 代码审核团队 | `src/crates/core/src/agentic/deep_review/``src/crates/core/src/agentic/deep_review_policy.rs``src/crates/core/src/agentic/agents/definitions/hidden/deep_review.rs``src/crates/core/src/agentic/tools/implementations/{task_tool.rs,code_review_tool.rs}``src/web-ui/src/shared/services/review-team/``src/web-ui/src/flow_chat/deep-review/``src/web-ui/src/app/scenes/agents/components/ReviewTeamPage.tsx` |
228-
| Mobile web 配对 / 远程控制 | `src/mobile-web/src/pages/PairingPage.tsx``src/mobile-web/src/pages/SessionListPage.tsx``src/mobile-web/src/pages/ChatPage.tsx``src/mobile-web/src/services/RemoteSessionManager.ts``src/mobile-web/src/services/RelayHttpClient.ts``src/mobile-web/src/services/store.ts` |
229-
| 会话用量报告(`/usage`| `src/crates/core/src/service/session_usage/``src/web-ui/src/flow_chat/components/usage/``src/web-ui/src/locales/*/flow-chat.json` |
230-
| Tool | `src/crates/core/src/agentic/tools/implementations/``src/crates/core/src/agentic/tools/registry.rs` |
231-
| MCP / LSP / remote | `src/crates/core/src/service/mcp/``src/crates/core/src/service/lsp/``src/crates/core/src/service/remote_connect/``src/crates/core/src/service/remote_ssh/` |
232-
| 桌面端 API | `src/apps/desktop/src/api/``src/crates/api-layer/src/``src/crates/transport/src/adapters/tauri.rs` |
233-
| 中继服务器 | `src/apps/relay-server/` |
234-
| Web/server 通信 | `src/web-ui/src/infrastructure/api/``src/crates/transport/src/adapters/websocket.rs``src/apps/server/src/routes/``src/apps/server/src/main.rs` |
235-
236187
## Agent 文档优先级
237188

238189
进入具体目录后,优先遵循离目标文件最近的 `AGENTS.md` / `AGENTS-CN.md`。如果局部文档与本文件冲突,以更具体、更近的文档为准。

AGENTS.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -174,40 +174,6 @@ Repository-level decomposition rules:
174174
compatibility, behavior equivalence tests, and explicit confirmation when a
175175
behavior boundary could change.
176176

177-
### DeepReview guardrails
178-
179-
Deep Review / Code Review Team work spans the core runtime and web UI. Keep
180-
target resolution and manifest construction on the frontend; keep policy
181-
validation, queue/retry state, and report enrichment in shared core.
182-
183-
### Backend flow
184-
185-
Trace most features in this order:
186-
187-
1. `src/web-ui` or app entrypoint
188-
2. `src/apps/desktop/src/api/*` or server routes
189-
3. `src/crates/api-layer`
190-
4. `src/crates/transport`
191-
5. `src/crates/core`
192-
193-
### `bitfun-core`
194-
195-
`src/crates/core` is the center of the codebase.
196-
197-
Important areas:
198-
199-
- `agentic/`: agents, prompts, tools, sessions, execution, persistence
200-
- `service/`: config, filesystem, terminal, git, LSP, MCP, remote connect, project context, AI memory
201-
- `infrastructure/`: AI clients, app paths, event system, storage, debug log server
202-
203-
Agent runtime mental model:
204-
205-
```text
206-
SessionManager → Session → DialogTurn → ModelRound
207-
```
208-
209-
Session data is stored under `.bitfun/sessions/{session_id}/`.
210-
211177
## Verification
212178

213179
Run the smallest local precheck that matches the touched files. CI is expected to
@@ -221,7 +187,6 @@ change directly affects build, packaging, or CI cannot protect the path.
221187
| Locale contract or shared terms | `pnpm run i18n:generate && pnpm run i18n:contract:test && pnpm run i18n:audit` |
222188
| Web UI i18n runtime, namespace loading, or direct `i18nService.t(...)` usage | `pnpm run i18n:contract:test && pnpm run type-check:web && pnpm --dir src/web-ui run test:run src/infrastructure/i18n/core/I18nService.test.ts` |
223189
| Mobile web UI, state, pairing, disconnect, or reconnect behavior | `pnpm --dir src/mobile-web run type-check`; include manual pairing / reconnect notes when behavior changes |
224-
| Deep Review / Code Review Team behavior | Nearest Web UI check above, plus `cargo test -p bitfun-core deep_review -- --nocapture`; also run Rust / desktop checks when backend or Tauri APIs are touched |
225190
| Shared Rust logic in `core`, `transport`, `api-layer`, or services | `cargo check --workspace`, plus the nearest focused `cargo test` when behavior changed |
226191
| Desktop integration, Tauri APIs, browser/computer-use, or desktop-only behavior | `cargo check -p bitfun-desktop`, plus focused desktop tests when behavior changed |
227192
| Behavior covered by desktop smoke/functional flows | Prefer the nearest focused E2E/smoke check; rely on CI for broad build/test coverage unless build behavior changed |
@@ -230,20 +195,6 @@ change directly affects build, packaging, or CI cannot protect the path.
230195
| Installer Tauri/Rust changes | `cargo check --manifest-path BitFun-Installer/src-tauri/Cargo.toml` |
231196
| Installer packaging, payload, install/uninstall flow, or native bundling | `pnpm run installer:build` |
232197

233-
## Where to look first
234-
235-
| Feature | Key paths |
236-
|---|---|
237-
| Agent modes | `src/crates/core/src/agentic/agents/`, `src/crates/core/src/agentic/agents/prompts/`, `src/web-ui/src/locales/*/scenes/agents.json` |
238-
| Deep Review / Code Review Team | `src/crates/core/src/agentic/deep_review/`, `src/crates/core/src/agentic/deep_review_policy.rs`, `src/crates/core/src/agentic/agents/definitions/hidden/deep_review.rs`, `src/crates/core/src/agentic/tools/implementations/{task_tool.rs,code_review_tool.rs}`, `src/web-ui/src/shared/services/review-team/`, `src/web-ui/src/flow_chat/deep-review/`, `src/web-ui/src/app/scenes/agents/components/ReviewTeamPage.tsx` |
239-
| Mobile web pairing / remote control | `src/mobile-web/src/pages/PairingPage.tsx`, `src/mobile-web/src/pages/SessionListPage.tsx`, `src/mobile-web/src/pages/ChatPage.tsx`, `src/mobile-web/src/services/RemoteSessionManager.ts`, `src/mobile-web/src/services/RelayHttpClient.ts`, `src/mobile-web/src/services/store.ts` |
240-
| Session usage report (`/usage`) | `src/crates/core/src/service/session_usage/`, `src/web-ui/src/flow_chat/components/usage/`, `src/web-ui/src/locales/*/flow-chat.json` |
241-
| Tools | `src/crates/core/src/agentic/tools/implementations/`, `src/crates/core/src/agentic/tools/registry.rs` |
242-
| MCP / LSP / remote | `src/crates/core/src/service/mcp/`, `src/crates/core/src/service/lsp/`, `src/crates/core/src/service/remote_connect/`, `src/crates/core/src/service/remote_ssh/` |
243-
| Desktop APIs | `src/apps/desktop/src/api/`, `src/crates/api-layer/src/`, `src/crates/transport/src/adapters/tauri.rs` |
244-
| Relay server | `src/apps/relay-server/` |
245-
| Web/server communication | `src/web-ui/src/infrastructure/api/`, `src/crates/transport/src/adapters/websocket.rs`, `src/apps/server/src/routes/`, `src/apps/server/src/main.rs` |
246-
247198
## Agent-doc priority
248199

249200
Prefer the nearest matching `AGENTS.md` / `AGENTS-CN.md` for the directory you are changing. If local guidance conflicts with this file, follow the more specific, nearer document.

CONTRIBUTING.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ Be respectful, kind, and constructive. We welcome contributors of all background
1919

2020
#### Windows: OpenSSL Setup
2121

22-
The desktop app includes SSH remote support, which pulls in OpenSSL. On Windows the workspace **does not use vendored OpenSSL**; link against **pre-built** binaries (no Perl/NASM/OpenSSL source build).
22+
Most Windows contributors do not need to configure OpenSSL manually. Use
23+
`pnpm run desktop:dev` or the normal `desktop:build*` scripts; they bootstrap a
24+
pre-built OpenSSL package when needed.
2325

24-
- **Default**: `pnpm run desktop:dev` calls `ensure-openssl-windows.mjs` on Windows. `pnpm run desktop:preview:debug` does the same whenever it needs to fast-rebuild `bitfun-desktop` before preview. Every `desktop:build*` script runs via `scripts/desktop-tauri-build.mjs`, which does the same before invoking Cargo.
25-
- **Manual / CI**: Download the [FireDaemon OpenSSL 3.5.5 LTS ZIP](https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-3.5.5.zip), extract, set `OPENSSL_DIR` to the `x64` folder, `OPENSSL_STATIC=1`, or run `scripts/ci/setup-openssl-windows.ps1`.
26-
- **Opt out of auto-download**: `BITFUN_SKIP_OPENSSL_BOOTSTRAP=1` and configure `OPENSSL_DIR` yourself.
27-
- **`desktop:dev:raw`** skips the dev script (no OpenSSL bootstrap); set `OPENSSL_DIR` yourself, run `scripts/ci/setup-openssl-windows.ps1`, or `node scripts/ensure-openssl-windows.mjs` (warms `.bitfun/cache/` and prints PowerShell `OPENSSL_*` lines to paste).
26+
Only handle OpenSSL yourself when the bootstrap fails, you are preparing CI, or
27+
you intentionally use `pnpm run desktop:dev:raw`. In that case, run
28+
`scripts/ci/setup-openssl-windows.ps1`, or set `OPENSSL_DIR` to a pre-built x64
29+
OpenSSL directory and set `OPENSSL_STATIC=1`.
2830

2931
### Install dependencies
3032

@@ -54,9 +56,10 @@ pnpm run e2e:test
5456
5557
### Desktop debugging tools
5658

57-
Desktop dev builds enable the `devtools` Cargo feature. Use
58-
`Cmd/Ctrl + Shift + I` for the element inspector and `Cmd/Ctrl + Shift + J` for
59-
native webview DevTools. These tools are disabled in end-user `release` builds.
59+
Desktop dev builds enable the `devtools` Cargo feature. Use `F12` for native
60+
webview DevTools. `Cmd/Ctrl + Shift + I` toggles the BitFun element inspector,
61+
and `Cmd/Ctrl + Shift + J` also opens native DevTools. These tools are disabled
62+
in end-user `release` builds.
6063

6164
## Code Standards and Architecture Constraints
6265

@@ -73,8 +76,7 @@ terms:
7376
payloads.
7477
- Core decomposition, feature-boundary, dependency-boundary, and build-speed
7578
work must follow `docs/architecture/core-decomposition.md`.
76-
- Deep Review / Code Review Team changes must keep the core and Web UI guidance
77-
aligned with the implementation.
79+
- Feature-specific rules belong in the nearest module `AGENTS.md`.
7880

7981
## Key Contribution Focus Areas
8082

CONTRIBUTING_CN.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
#### Windows:OpenSSL 配置
2121

22-
桌面端包含 SSH 远程功能,会链接 OpenSSL。Windows 上**不使用 OpenSSL 源码编译(vendored)**,需使用**预编译**库。
22+
大多数 Windows 贡献者不需要手动配置 OpenSSL。使用 `pnpm run desktop:dev`
23+
或常规 `desktop:build*` 脚本即可;脚本会在需要时自动引导预编译的 OpenSSL 包。
2324

24-
- **默认**:Windows 下 `pnpm run desktop:dev` 会调用 `ensure-openssl-windows.mjs``pnpm run desktop:preview:debug` 在需要为预览执行快速本地 `cargo build -p bitfun-desktop` 时,也会做同样的 OpenSSL 引导。所有 `desktop:build*` 均通过 `scripts/desktop-tauri-build.mjs` 执行,在 `tauri build` 前做相同引导(首次下载到 `.bitfun/cache/`,之后走缓存)。
25-
- **手动 / CI**:下载 [FireDaemon ZIP](https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-3.5.5.zip),解压后将 `OPENSSL_DIR` 指向 `x64`,并设 `OPENSSL_STATIC=1`,或运行 `scripts/ci/setup-openssl-windows.ps1`
26-
- **关闭自动下载**:设置 `BITFUN_SKIP_OPENSSL_BOOTSTRAP=1` 并自行配置 `OPENSSL_DIR`
27-
- **`desktop:dev:raw`** 不经过 `dev.cjs`(无 OpenSSL 引导);请自行设置 `OPENSSL_DIR`、运行 `scripts/ci/setup-openssl-windows.ps1`,或执行 `node scripts/ensure-openssl-windows.mjs`(会预热 `.bitfun/cache/` 并打印可在 PowerShell 中粘贴的 `OPENSSL_*` 命令)。
25+
只有在自动引导失败、准备 CI 环境,或你明确使用 `pnpm run desktop:dev:raw`
26+
时才需要手动处理。此时运行 `scripts/ci/setup-openssl-windows.ps1`,或将
27+
`OPENSSL_DIR` 指向预编译的 x64 OpenSSL 目录,并设置 `OPENSSL_STATIC=1`
2828

2929
### 安装依赖
3030

@@ -54,8 +54,9 @@ pnpm run e2e:test
5454
5555
### 桌面端调试工具
5656

57-
桌面端 dev 构建会启用 `devtools` Cargo feature。`Cmd/Ctrl + Shift + I` 打开元素检查器,
58-
`Cmd/Ctrl + Shift + J` 打开原生 webview DevTools;面向最终用户的 `release` 构建不会启用这些工具。
57+
桌面端 dev 构建会启用 `devtools` Cargo feature。`F12` 打开原生 webview
58+
DevTools;`Cmd/Ctrl + Shift + I` 切换 BitFun 元素检查器,`Cmd/Ctrl + Shift + J`
59+
也可以打开原生 DevTools。面向最终用户的 `release` 构建不会启用这些工具。
5960

6061
## 代码规范与架构约束
6162

@@ -67,7 +68,7 @@ pnpm run e2e:test
6768
- Tauri command 使用 `snake_case` 命令名和结构化 `request` 参数。
6869
- core 拆解、feature 边界、依赖边界和构建提速重构必须遵循
6970
`docs/architecture/core-decomposition.md`
70-
- Deep Review / 代码审核团队改动需要保持 core 与 Web UI 指南和实现一致
71+
- 功能级规则应放在离代码最近的模块 `AGENTS.md`
7172

7273
## 重点关注的贡献方向
7374

docs/plans/core-decomposition-completed.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@
6464
### 1.5 Product Domain 与 function-agent / MiniApp 边界
6565

6666
- `product-domains` 已承接 MiniApp 的纯状态、runtime detection policy、worker capacity / idle / LRU policy、
67-
host method / fs access / shell token / env 等纯决策,以及 function-agent prompt / parser / response policy / ports。
67+
host method、`fs.*` / `shell.exec` host call plan、fs access / shell token / cwd / timeout / env 等纯决策,
68+
以及 function-agent prompt / parser / response policy / ports。
6869
- 内置 MiniApp bundle identity、版本和 embedded source assets 已归入 `product-domains`
6970
- function-agent Git concrete snapshot、no-HEAD diff fallback、非 Git workspace fallback、ahead/behind/last-commit
7071
fallback 和 project context lookup 已迁入 `services-integrations::function_agents`
71-
- function-agent AI provider acquisition、AI transport error mapping、MiniApp worker process、host dispatch、
72-
PathManager integration、marker IO 和 seed 写盘仍留在 core concrete path。
72+
- function-agent AI provider acquisition、AI transport error mapping、MiniApp worker process、host side-effect dispatch、
73+
`net.fetch` / `os.info` runtime execution、PathManager integration、marker IO 和 seed 写盘仍留在 core concrete path。
7374

7475
## 2. 已建立的保护
7576

docs/plans/core-decomposition-plan.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,15 @@ prompt-visible manifest、GetToolSpec、readonly/enabled filtering、expanded/co
120120

121121
目标:让 Harness / Product Domains 不再停留在 descriptor 或 pure policy 层,而是接管符合设计边界的工作流和 domain owner。
122122

123-
- 为 Deep Review、DeepResearch、MiniApp、function-agent 明确哪些属于 Harness workflow、哪些属于 Product Domain policy、
124-
哪些属于 Concrete Integration provider。
125-
- 迁移 MiniApp worker/host/seed/marker IO 中可被 Runtime Services / provider port 保护的主体。
126-
- 为 function-agent AI provider acquisition 抽稳定 AI runtime/provider port,避免 integration crate 依赖回 core 或复制 AI client runtime。
127-
- Harness provider 从 legacy route plan 逐步转向可执行 workflow owner;无法迁移的 concrete 副作用必须明确保留在 Product Assembly adapter。
123+
- MiniApp host primitive 的 `fs.*` / `shell.exec` 纯调用计划、参数默认值、错误契约和权限检查计划归入
124+
Product Domain;core 仅消费计划并继续负责权限 policy resolution、路径规范化、文件 IO、进程执行和输出映射。
125+
- `net.fetch` / `os.info` 不迁入 Product Domain:前者依赖 `reqwest::Url` 与 HTTP client 语义,后者依赖平台 runtime facts,
126+
保留在 core concrete path 更符合最小依赖原则。
127+
- MiniApp seed / marker 的 bundle、hash、marker wire format 与 seed decision 已由 Product Domain 持有;core 仍负责磁盘读写、
128+
customization metadata、PathManager integration 和 recompile。
129+
- function-agent 已通过 Product Domain facade 与 core adapter 隔离 Git/AI 端口;AI provider acquisition 和 transport error mapping
130+
仍留在 core,除非后续单独评审稳定 AI runtime/provider 边界。
131+
- Harness provider 继续保持 legacy route plan / descriptor owner;Deep Review / DeepResearch concrete execution 不混入本阶段。
128132

129133
**不混入:** 改变 MiniApp storage layout、worker 生命周期、host primitive 权限、Deep Review report 语义、function-agent prompt/response policy。
130134

@@ -155,7 +159,7 @@ prompt-visible manifest、GetToolSpec、readonly/enabled filtering、expanded/co
155159

156160
## 5. 执行节奏
157161

158-
后续按 M2 -> M3 -> M4 -> M5 推进。每个里程碑原则上对应一个大 PR;如果发现风险超过单 PR 可控范围,只允许按 owner 边界拆分,
162+
后续按 M4 收尾 -> M5 推进。每个里程碑原则上对应一个大 PR;如果发现风险超过单 PR 可控范围,只允许按 owner 边界拆分,
159163
不允许拆成 facade / guard / helper 小 PR。
160164

161165
每个里程碑固定流程:

0 commit comments

Comments
 (0)