Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 14 additions & 16 deletions AGENTS-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@ BitFun 是一个由 Rust workspace 与 React 前端组成的项目。

## 分层模块索引

依赖关系按自上而下读取:某一行代码只能依赖更下方的层级。可复用行为放到能够拥有它的最低层;入口、协议外观和交付形态选择留在对应的最高入口层
依赖关系按自上而下读取:上层只能依赖下层,同层 crate 也应保持最小依赖

| # | 层级 | 路径 | 职责 | 模块 / 入口 | 层级文档 |
|---|---|---|---|---|---|
| 1 | 产品入口与协议入口层 | `src/apps/*`, `src/web-ui`, `src/mobile-web`, `BitFun-Installer`, `tests/e2e`, `src/crates/surfaces` | UI、命令、路由、交付形态、宿主集成、协议入口和跨形态测试 | desktop、CLI、server、relay、Web UI、mobile web、installer、E2E、`acp` | 最近的本地 `AGENTS.md`;[surfaces](src/crates/surfaces/AGENTS.md) |
| 2 | 门面与产品组装层 | `src/crates/facade` | 兼容导出、product-full 组装、交付形态接线和 provider 注册 | `core` | [AGENTS.md](src/crates/facade/AGENTS.md) |
| 3 | 具体适配实现层 | `src/crates/integrations` | 低层外部协议、provider、transport 和平台 adapter | `ai-adapters`, `api-layer`, `transport`, `webdriver` | [AGENTS.md](src/crates/integrations/AGENTS.md) |
| 4 | 可复用服务与服务适配层 | `src/crates/services` | 具体非 UI 服务实现,以及窄产品领域 port adapter | `services-core`, `services-integrations`, `terminal` | [AGENTS.md](src/crates/services/AGENTS.md) |
| 5 | 产品策略与能力层 | `src/crates/product` | 产品领域、feature facts、capability packs、非 UI 产品策略和窄领域 port | `product-domains`, `product-capabilities` | [AGENTS.md](src/crates/product/AGENTS.md) |
| 6 | 执行原语层 | `src/crates/execution` | provider-neutral 的 agent、tool、harness、stream 和 typed-service 构件 | `agent-runtime`, `agent-stream`, `agent-tools`, `harness`, `runtime-services`, `tool-packs`, `tool-runtime` | [AGENTS.md](src/crates/execution/AGENTS.md) |
| 7 | 稳定契约层 | `src/crates/contracts` | 跨层共享 DTO、事件形状和 port | `core-types`, `events`, `runtime-ports` | [AGENTS.md](src/crates/contracts/AGENTS.md) |
| 1 | 接口与入口层 | `src/apps/*`, `src/web-ui`, `src/mobile-web`, `BitFun-Installer`, `tests/e2e`, `src/crates/interfaces` | 产品宿主、命令、UI 入口、协议接口和跨形态测试 | desktop、CLI、server、relay、Web UI、mobile web、installer、E2E、`acp` | 最近的本地 `AGENTS.md`;[interfaces](src/crates/interfaces/AGENTS.md) |
| 2 | 产品组装层 | `src/crates/assembly` | 兼容导出、产品能力选择、product-full 接线和 adapter/service 注册 | `core`, `product-capabilities` | [AGENTS.md](src/crates/assembly/AGENTS.md) |
| 3 | 适配层 | `src/crates/adapters` | AI/API/transport/WebDriver 协议 adapter 和外部 provider 转换 | `ai-adapters`, `api-layer`, `transport`, `webdriver` | [AGENTS.md](src/crates/adapters/AGENTS.md) |
| 4 | 服务实现层 | `src/crates/services` | 可复用 OS、filesystem、terminal、MCP、remote、git、watch、process 和 network 实现 | `services-core`, `services-integrations`, `terminal` | [AGENTS.md](src/crates/services/AGENTS.md) |
| 5 | 执行原语层 | `src/crates/execution` | 可移植 agent、harness、stream、typed-service、tool-contract、tool-group 和 tool-execution 构件 | `agent-runtime`, `agent-stream`, `tool-contracts`, `harness`, `runtime-services`, `tool-provider-groups`, `tool-execution` | [AGENTS.md](src/crates/execution/AGENTS.md) |
| 6 | 稳定契约与产品领域层 | `src/crates/contracts` | 跨层共享 DTO、事件形状、runtime port、产品领域契约和策略 | `core-types`, `events`, `runtime-ports`, `product-domains` | [AGENTS.md](src/crates/contracts/AGENTS.md) |

边界规则:

- 产品入口与协议入口只选择交付形态并调用 facade 或 adapter API;可复用行为应下移。
- facade 只负责兼容和产品组装接线,不实现 provider、protocol、OS 或 service 细节。
- 具体适配实现只翻译外部系统;依赖已组装产品行为的协议入口应放入 `surfaces`。
- 通用 service 不依赖产品 crate;feature-gated service adapter 只能实现窄 `product-domains` port。
- product 拥有产品策略和能力事实,不拥有 UI、protocol、host 或具体 service 实现。
- execution 只放可移植执行构件,不等同于完整产品 runtime 或宿主 runtime。
- contracts 只放轻行为契约,不得向上依赖。
- 接口与入口层暴露选定产品行为;可复用行为应下移。
- 组装层只接线下层并选择产品能力事实,不实现具体 adapter、OS 或 service 细节。
- 适配层翻译协议和外部系统,不拥有产品能力选择或可复用 OS service 行为。
- 服务实现层负责可复用的 OS、process、terminal、MCP、remote、git 和 filesystem 能力。
- 执行原语层只放可移植运行时构件,不拥有宿主或交付形态。
- 契约层保持轻行为,不得向上依赖。

## 常用命令

Expand Down Expand Up @@ -169,7 +167,7 @@ await api.invoke('your_command', { request: { ... } });
| `core`、`transport`、`api-layer` 或共享服务中的 Rust 逻辑 | `cargo check --workspace`;行为变化时再加最近的 focused `cargo test` |
| 桌面端集成、Tauri API、browser/computer-use 或桌面专属行为 | `cargo check -p bitfun-desktop`;行为变化时再加 focused desktop tests |
| 被桌面端 smoke/functional 流覆盖的行为 | 优先运行最近的 focused E2E/smoke check;除非改动影响构建,否则 broad build/test 交给 CI |
| `src/crates/integrations/ai-adapters` | 运行上面相关 Rust 检查;只有 stream contract 改动时再加 `cargo test -p bitfun-agent-stream` |
| `src/crates/adapters/ai-adapters` | 运行上面相关 Rust 检查;只有 stream contract 改动时再加 `cargo test -p bitfun-agent-stream` |
| 不涉及打包的安装器前端或 i18n runtime | `pnpm --dir BitFun-Installer run type-check` |
| 安装器 Tauri/Rust 改动 | `cargo check --manifest-path BitFun-Installer/src-tauri/Cargo.toml` |
| 安装器打包、payload、安装/卸载流程或 native bundling | `pnpm run installer:build` |
Expand Down
35 changes: 16 additions & 19 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,25 @@ Repository rule: **keep product logic platform-agnostic, then expose it through

## Layered Module Index

Dependencies flow top to bottom: code in a row may depend only on lower rows.
Put reusable behavior in the lowest layer that can own it; put entrypoint and
profile selection in the highest layer that owns the surface.
Dependencies flow top to bottom. A layer may depend on lower layers only; keep
crate dependencies inside each layer to the smallest set needed.

| # | Layer | Path | Owns | Modules / entries | Layer doc |
|---|---|---|---|---|---|
| 1 | Product surfaces and protocol surfaces | `src/apps/*`, `src/web-ui`, `src/mobile-web`, `BitFun-Installer`, `tests/e2e`, `src/crates/surfaces` | UI, commands, routes, delivery profiles, host integration, protocol entrypoints, and cross-surface tests | desktop, CLI, server, relay, Web UI, mobile web, installer, E2E, `acp` | nearest local `AGENTS.md`; [surfaces](src/crates/surfaces/AGENTS.md) |
| 2 | Facade and product assembly | `src/crates/facade` | Compatibility exports, product-full assembly, delivery-profile wiring, and provider registration | `core` | [AGENTS.md](src/crates/facade/AGENTS.md) |
| 3 | Concrete provider adapters | `src/crates/integrations` | Low-level external protocol, provider, transport, and platform adapters | `ai-adapters`, `api-layer`, `transport`, `webdriver` | [AGENTS.md](src/crates/integrations/AGENTS.md) |
| 4 | Reusable services and service adapters | `src/crates/services` | Concrete non-UI services and narrow product-domain port adapters | `services-core`, `services-integrations`, `terminal` | [AGENTS.md](src/crates/services/AGENTS.md) |
| 5 | Product policy and capabilities | `src/crates/product` | Product domains, feature facts, capability packs, product-owned non-UI policy, and narrow domain ports | `product-domains`, `product-capabilities` | [AGENTS.md](src/crates/product/AGENTS.md) |
| 6 | Execution primitives | `src/crates/execution` | Provider-neutral agent, tool, harness, stream, and typed-service building blocks | `agent-runtime`, `agent-stream`, `agent-tools`, `harness`, `runtime-services`, `tool-packs`, `tool-runtime` | [AGENTS.md](src/crates/execution/AGENTS.md) |
| 7 | Stable contracts | `src/crates/contracts` | Shared DTOs, event shapes, and ports | `core-types`, `events`, `runtime-ports` | [AGENTS.md](src/crates/contracts/AGENTS.md) |
| 1 | Interfaces and entrypoints | `src/apps/*`, `src/web-ui`, `src/mobile-web`, `BitFun-Installer`, `tests/e2e`, `src/crates/interfaces` | Product hosts, commands, UI entrypoints, protocol interfaces, and cross-surface tests | desktop, CLI, server, relay, Web UI, mobile web, installer, E2E, `acp` | nearest local `AGENTS.md`; [interfaces](src/crates/interfaces/AGENTS.md) |
| 2 | Product assembly | `src/crates/assembly` | Compatibility exports, product capability selection, product-full wiring, and adapter/service registration | `core`, `product-capabilities` | [AGENTS.md](src/crates/assembly/AGENTS.md) |
| 3 | Adapters | `src/crates/adapters` | AI/API/transport/WebDriver protocol adapters and external-provider translation | `ai-adapters`, `api-layer`, `transport`, `webdriver` | [AGENTS.md](src/crates/adapters/AGENTS.md) |
| 4 | Services | `src/crates/services` | Reusable OS, filesystem, terminal, MCP, remote, git, watch, process, and network implementations | `services-core`, `services-integrations`, `terminal` | [AGENTS.md](src/crates/services/AGENTS.md) |
| 5 | Execution primitives | `src/crates/execution` | Portable agent, harness, stream, typed-service, tool-contract, tool-group, and tool-execution building blocks | `agent-runtime`, `agent-stream`, `tool-contracts`, `harness`, `runtime-services`, `tool-provider-groups`, `tool-execution` | [AGENTS.md](src/crates/execution/AGENTS.md) |
| 6 | Stable contracts and product domains | `src/crates/contracts` | Shared DTOs, event shapes, runtime ports, and product domain contracts/policies | `core-types`, `events`, `runtime-ports`, `product-domains` | [AGENTS.md](src/crates/contracts/AGENTS.md) |

Boundary rules:

- Surfaces and protocol surfaces choose delivery profiles and call facade or adapter APIs; reusable behavior moves down.
- Facade wires lower layers for compatibility and product assembly; it must not implement provider, protocol, OS, or service details.
- Concrete provider adapters translate external systems; product-facing protocol entrypoints that depend on assembled product behavior belong in `surfaces`.
- Generic services stay product-independent; feature-gated service adapters may implement narrow `product-domains` ports.
- Product owns product policy and capability facts, not UI, protocol, host, or concrete service implementations.
- Execution primitives are portable building blocks, not the full product runtime or host-specific runtime.
- Interfaces and app entrypoints expose selected product behavior; reusable behavior moves down.
- Assembly wires lower layers and selects product capability facts; it must not implement concrete adapter, OS, or service details.
- Adapters translate protocols and external systems; they should not own product capability selection or reusable OS service behavior.
- Services implement reusable concrete OS, process, terminal, MCP, remote, git, and filesystem capabilities.
- Execution crates are portable runtime building blocks, not host-specific or delivery-profile owners.
- Contracts stay behavior-light and must not depend upward.


Expand Down Expand Up @@ -135,7 +132,7 @@ await api.invoke('your_command', { request: { ... } });
### Platform boundaries

- Do not call Tauri APIs directly from UI components; go through the adapter/infrastructure layer.
- Desktop-only integrations belong in `src/apps/desktop`, then flow back through transport/API layers.
- Desktop-only host adapters belong in `src/apps/desktop`, then flow back through transport/API layers.
- In shared core, avoid host-specific APIs such as `tauri::AppHandle`; use shared abstractions such as `bitfun_events::EventEmitter`.

### Remote compatibility
Expand Down Expand Up @@ -180,10 +177,10 @@ change directly affects build, packaging, or CI cannot protect the path.
| Locale contract or shared terms | `pnpm run i18n:generate && pnpm run i18n:contract:test && pnpm run i18n:audit` |
| 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` |
| 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 |
| Shared Rust logic in `core`, `transport`, `api-layer`, or services | `cargo check --workspace`, plus the nearest focused `cargo test` when behavior changed |
| Shared Rust logic in `core`, `transport`, `api-layer`, adapters, or services | `cargo check --workspace`, plus the nearest focused `cargo test` when behavior changed |
| Desktop integration, Tauri APIs, browser/computer-use, or desktop-only behavior | `cargo check -p bitfun-desktop`, plus focused desktop tests when behavior changed |
| 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 |
| `src/crates/integrations/ai-adapters` | Relevant Rust checks above; add `cargo test -p bitfun-agent-stream` only when stream contracts changed |
| `src/crates/adapters/ai-adapters` | Relevant Rust checks above; add `cargo test -p bitfun-agent-stream` only when stream contracts changed |
| Installer frontend or i18n runtime without packaging changes | `pnpm --dir BitFun-Installer run type-check` |
| Installer Tauri/Rust changes | `cargo check --manifest-path BitFun-Installer/src-tauri/Cargo.toml` |
| Installer packaging, payload, install/uninstall flow, or native bundling | `pnpm run installer:build` |
Expand Down
2 changes: 1 addition & 1 deletion BitFun-Installer/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ reqwest = { version = "0.12", default-features = false, features = ["json", "rus
urlencoding = "2"
futures = "0.3"
eventsource-stream = "0.2"
bitfun-ai-adapters = { path = "../../src/crates/integrations/ai-adapters" }
bitfun-ai-adapters = { path = "../../src/crates/adapters/ai-adapters" }

[target.'cfg(windows)'.dependencies]
winreg = "0.52"
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ We welcome contributions beyond standard feature or bug-fix PRs. Examples includ

| Contribution area | Location / files | Example |
| --- | --- | --- |
| Prompts | `src/crates/facade/core/src/agentic/agents/prompts/` | Add or refine prompts, and update related logic as needed |
| Tools | `src/crates/facade/core/src/agentic/tools/implementations/`, `src/crates/facade/core/src/agentic/tools/registry.rs` | Add tool implementations and register them in the tool registry |
| Subagents | `src/crates/facade/core/src/agentic/agents/custom_subagents/`, `src/crates/facade/core/src/agentic/agents/registry.rs` | Add subagent implementations and register them in the subagent registry |
| Mode contributions | `src/crates/facade/core/src/agentic/agents/*_mode.rs`, `src/crates/facade/core/src/agentic/agents/prompts/*_mode.md`, `src/web-ui/src/locales/*/settings/modes.json` | Add/improve agent modes (e.g. Plan/Debug/Agentic or custom modes) and keep prompts + UI copy in sync |
| Prompts | `src/crates/assembly/core/src/agentic/agents/prompts/` | Add or refine prompts, and update related logic as needed |
| Tools | `src/crates/assembly/core/src/agentic/tools/implementations/`, `src/crates/assembly/core/src/agentic/tools/registry.rs` | Add tool implementations and register them in the tool registry |
| Subagents | `src/crates/assembly/core/src/agentic/agents/custom_subagents/`, `src/crates/assembly/core/src/agentic/agents/registry.rs` | Add subagent implementations and register them in the subagent registry |
| Mode contributions | `src/crates/assembly/core/src/agentic/agents/*_mode.rs`, `src/crates/assembly/core/src/agentic/agents/prompts/*_mode.md`, `src/web-ui/src/locales/*/settings/modes.json` | Add/improve agent modes (e.g. Plan/Debug/Agentic or custom modes) and keep prompts + UI copy in sync |
| Scenario guides for Code Agent and AIIde | `website/src/docs/` | Add workflows, playbooks, and real-world scenario docs (or link them from `README.md`) |

### Before you start
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ DevTools;`Cmd/Ctrl + Shift + I` 切换 BitFun 元素检查器,`Cmd/Ctrl + Sh

| 贡献方向 | 位置/文件 | 示例说明 |
| --- | --- | --- |
| Prompts | `src/crates/facade/core/src/agentic/agents/prompts/` | 新增或优化提示词,并按需更新相关逻辑 |
| Tools | `src/crates/facade/core/src/agentic/tools/implementations/`、`src/crates/facade/core/src/agentic/tools/registry.rs` | 新增工具实现,并在工具注册表中注册 |
| Subagents | `src/crates/facade/core/src/agentic/agents/custom_subagents/`、`src/crates/facade/core/src/agentic/agents/registry.rs` | 新增子代理实现,并在子代理注册表中注册 |
| 模式贡献 | `src/crates/facade/core/src/agentic/agents/*_mode.rs`、`src/crates/facade/core/src/agentic/agents/prompts/*_mode.md`、`src/web-ui/src/locales/*/settings/modes.json` | 新增/优化 Agent 模式(例如 Plan/Debug/Agentic 或自定义模式)的逻辑与提示词,并同步前端模式文案 |
| Prompts | `src/crates/assembly/core/src/agentic/agents/prompts/` | 新增或优化提示词,并按需更新相关逻辑 |
| Tools | `src/crates/assembly/core/src/agentic/tools/implementations/`、`src/crates/assembly/core/src/agentic/tools/registry.rs` | 新增工具实现,并在工具注册表中注册 |
| Subagents | `src/crates/assembly/core/src/agentic/agents/custom_subagents/`、`src/crates/assembly/core/src/agentic/agents/registry.rs` | 新增子代理实现,并在子代理注册表中注册 |
| 模式贡献 | `src/crates/assembly/core/src/agentic/agents/*_mode.rs`、`src/crates/assembly/core/src/agentic/agents/prompts/*_mode.md`、`src/web-ui/src/locales/*/settings/modes.json` | 新增/优化 Agent 模式(例如 Plan/Debug/Agentic 或自定义模式)的逻辑与提示词,并同步前端模式文案 |
| Code Agent 与 AIIde 场景指南 | `website/src/docs/` | 补充流程、playbook 与真实场景说明(或从 `README.md` 链接) |

### 开始前
Expand Down
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ members = [
"src/apps/desktop",
"src/apps/server",
"src/apps/relay-server",
"src/crates/surfaces/acp",
"src/crates/facade/core",
"src/crates/integrations/ai-adapters",
"src/crates/integrations/webdriver",
"src/crates/integrations/api-layer",
"src/crates/integrations/transport",
"src/crates/interfaces/acp",
"src/crates/assembly/core",
"src/crates/adapters/ai-adapters",
"src/crates/adapters/webdriver",
"src/crates/adapters/api-layer",
"src/crates/adapters/transport",
"src/crates/services/services-core",
"src/crates/services/services-integrations",
"src/crates/services/terminal",
"src/crates/product/product-capabilities",
"src/crates/product/product-domains",
"src/crates/assembly/product-capabilities",
"src/crates/contracts/product-domains",
"src/crates/execution/agent-runtime",
"src/crates/execution/agent-stream",
"src/crates/execution/agent-tools",
"src/crates/execution/tool-contracts",
"src/crates/execution/harness",
"src/crates/execution/runtime-services",
"src/crates/execution/tool-packs",
"src/crates/execution/tool-runtime",
"src/crates/execution/tool-provider-groups",
"src/crates/execution/tool-execution",
"src/crates/contracts/core-types",
"src/crates/contracts/events",
"src/crates/contracts/runtime-ports",
Expand Down
Loading
Loading