Skip to content

Commit b244c30

Browse files
authored
Merge pull request #3857 from bobleer/bob/docs-agent-guide-accuracy
docs: slim the root agent guide and correct stale ownership docs
2 parents 16a3438 + 2f0dd22 commit b244c30

13 files changed

Lines changed: 405 additions & 617 deletions

File tree

‎AGENTS-CN.md‎

Lines changed: 132 additions & 234 deletions
Large diffs are not rendered by default.

‎AGENTS.md‎

Lines changed: 135 additions & 326 deletions
Large diffs are not rendered by default.

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ in end-user `release` builds.
9696

9797
## Code Standards and Architecture Constraints
9898

99-
Use [`AGENTS.md`](AGENTS.md) as the canonical source for architecture-sensitive
100-
rules, module boundaries, and the verification matrix. In contributor-facing
101-
terms:
99+
Use [`AGENTS.md`](AGENTS.md) as the canonical source for repository-wide rules,
100+
layer boundaries, and how to choose verification. In contributor-facing terms:
102101

103102
- Logs are English-only and should stay useful, not noisy.
104103
- User-visible copy should use the project i18n flow; do not share Web UI
@@ -109,7 +108,8 @@ terms:
109108
- Tauri commands use `snake_case` command names and structured `request`
110109
payloads.
111110
- Product architecture, feature-boundary, dependency-boundary, and build-speed
112-
work must follow `docs/architecture/product-architecture.md`.
111+
work must follow `docs/architecture/product-architecture.md` and
112+
`docs/architecture/rust-build-dependency-boundaries.md`.
113113
- Feature-specific rules belong in the nearest module `AGENTS.md`.
114114

115115
## Key Contribution Focus Areas
@@ -190,7 +190,8 @@ Common local checks:
190190
| Mobile web | `pnpm --dir src/mobile-web run type-check` |
191191
| Rust shared runtime or services | Follow the nearest module `AGENTS.md`: one package/test target and the minimum required features |
192192
| Desktop/Tauri integration | `cargo check -p openbitfun-desktop` |
193-
| i18n resources or contract | use the matching i18n row in `AGENTS.md` |
193+
| i18n resources | `pnpm run i18n:audit` |
194+
| i18n contract or shared terms | `pnpm run i18n:generate && pnpm run i18n:contract:test && pnpm run i18n:audit` |
194195

195196
For UI changes, include screenshots or a short recording when helpful. If you
196197
cannot run a relevant check, explain why in the PR and provide a lower-risk

‎CONTRIBUTING_CN.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pnpm run e2e:test
8080
`.openbitfun/desktop-dev/` 下。显式设置的数据目录环境变量仍优先生效;
8181
`--shared-data` 保留为默认模式的兼容写法。
8282

83-
> 完整脚本列表见 [`package.json`](package.json)。agent 专用命令、验证与架构规则见 [`AGENTS.md`](AGENTS.md)。
83+
> 完整脚本列表见 [`package.json`](package.json)。agent 专用命令、验证与架构规则见 [`AGENTS-CN.md`](AGENTS-CN.md)。
8484
8585
### 桌面端调试工具
8686

@@ -90,14 +90,15 @@ DevTools;`Cmd/Ctrl + Shift + I` 切换 OpenBitFun 元素检查器,`Cmd/Ctrl
9090

9191
## 代码规范与架构约束
9292

93-
架构敏感规则、模块边界和验证矩阵以 [`AGENTS.md`](AGENTS.md) 为准。面向贡献者只需把握:
93+
仓库级规则、分层边界和验证选择方式以 [`AGENTS-CN.md`](AGENTS-CN.md) 为准。面向贡献者只需把握:
9494

9595
- 日志只使用英文,并保持必要、可读。
9696
- 用户可见文案走项目 i18n 流程;不要把 Web UI locale catalog 共享给较小产品形态。
9797
- shared core 必须保持平台无关;Desktop/Tauri 细节属于 app adapter,并通过类型化能力接口回流;需要事件投递时使用已有生产 transport adapter。
9898
- Tauri command 使用 `snake_case` 命令名和结构化 `request` 参数。
9999
- core 拆解、feature 边界、依赖边界和构建提速重构必须遵循
100-
`docs/architecture/product-architecture.md`。
100+
`docs/architecture/product-architecture.md` 和
101+
`docs/architecture/rust-build-dependency-boundaries.md`。
101102
- 功能级规则应放在离代码最近的模块 `AGENTS.md` 中。
102103

103104
## 重点关注的贡献方向
@@ -174,7 +175,8 @@ Repository Object Sizes 检查会拒绝超过 5 MiB 的 Git 文件对象,包
174175
| Mobile web | `pnpm --dir src/mobile-web run type-check` |
175176
| Rust 共享 runtime 或 services | 遵循最近模块的 `AGENTS.md`,选择单个包/测试目标和最小所需 feature |
176177
| Desktop/Tauri 集成 | `cargo check -p openbitfun-desktop` |
177-
| i18n 资源或契约 | 使用 `AGENTS.md` 中匹配的 i18n 验证行 |
178+
| i18n 资源 | `pnpm run i18n:audit` |
179+
| i18n 契约或共享术语 | `pnpm run i18n:generate && pnpm run i18n:contract:test && pnpm run i18n:audit` |
178180

179181
UI 改动在有帮助时附截图或短录屏。无法运行相关检查时,在 PR 中说明原因,并提供风险更低的手动验证路径。
180182

‎docs/architecture/computer-use-control.md‎

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,35 @@ background input.
156156

157157
## Ownership and execution
158158

159-
Portable DTOs and `AppInputAction` live in `tool-contracts`; the host port lives in
160-
Core. Desktop owns native resources and platform adapters. Assembly must not own
161-
OS APIs, native focus workarounds or concrete capture implementations.
162-
163-
The shared action catalog and structural target validation live in
164-
`tool-contracts`. Desktop's `control_session/admission.rs` is a deterministic
165-
owner/mode/lease state machine; its facade alone performs native cleanup and
166-
carries tokens across workers. `desktop_host/observation.rs` coordinates native
167-
reads, while `observation_cache.rs` stores bounded references without owning input
168-
permission. `computer_use_geometry` adapts the independent `computer-use-rust`
169-
project's image/content/surface mapping for all three platforms. The reference
170-
project's macOS-only capture/input and standalone MCP/session shell are not a
171-
replacement for the existing Windows, Linux or product runtime providers.
159+
This section details the split stated in
160+
[Native provider ownership](#native-provider-ownership). Core does not depend on
161+
`services/computer-use`; it reaches the provider only through the injected port.
162+
163+
| Owner | Owns | Must not |
164+
|---|---|---|
165+
| `tool-contracts` (`computer_use*` modules) | Portable DTOs, `AppInputAction` and its structural target validation, the shared action catalog (`ControlActionPolicy`), control and permission facts, `CaptureGeometry`, the settle decision and the `ComputerUseHost` port | Hold OS handles or make permission decisions |
166+
| `services/computer-use` | Native resources and platform adapters for Windows, macOS and Linux: capture, AX/UIA/AT-SPI, input, OS permission probes and requests, remembered grants, the control session and `NativeComputerUseHost`; `host_runtime` holds CLI graphical-session admission and the macOS main run loop | Import Core, Tauri or the CLI, or discover Core config |
167+
| Core (Assembly) | The ComputerUse tool and its permission policy, the `computer_use_program` executor, the `ai.computer_use_enabled`, missing-provider and remote-workspace gates, and release of a turn's control through the port; its `computer_use_host` module only re-exports that port | Own OS APIs, native focus workarounds or concrete capture implementations |
168+
| Desktop | Provider injection and its diagnostic directory, the Tauri status, permission, sharing and preview commands, and the devtools-only full Tool fixtures | Reintroduce a native implementation |
169+
| CLI | Provider injection and its diagnostic directory for chat/exec inside a graphical login session, the main-thread run-loop adapter and the `computer-use` command | Reintroduce a native implementation, or infer a provider for Dispatch, ACP or the stdio server |
170+
171+
Service paths below are relative to
172+
`src/crates/services/computer-use/src/computer_use/`.
173+
`control_session/admission.rs` is a deterministic owner/mode/lease state machine
174+
with no OS handles; its facade `control_session.rs` alone performs native
175+
cleanup and carries tokens across workers. `desktop_host/` implements the port
176+
for `NativeComputerUseHost`. The directory kept its name when it moved out of
177+
the Desktop app; Desktop and CLI share it. `desktop_host/observation.rs`
178+
coordinates native reads, while `observation_cache.rs` stores bounded references
179+
without owning input permission. The
180+
[Native Computer Use guide](../../src/crates/services/computer-use/AGENTS.md)
181+
has the full module map.
182+
183+
`tool-contracts::computer_use_geometry` adapts the independent
184+
`computer-use-rust` project's image/content/surface mapping for all three
185+
platforms. The reference project's macOS-only capture/input and standalone
186+
MCP/session shell are not a replacement for the existing Windows, Linux or
187+
product runtime providers.
172188

173189
### Reference implementation migration
174190

@@ -178,8 +194,8 @@ runtime, build, test or filesystem dependency of OpenBitFun.
178194

179195
| Area | Reference source | OpenBitFun owner and adaptation |
180196
|---|---|---|
181-
| Permission query/request | `src/native/permissions.rs`, native permission probes | `computer_use_permissions` contracts, Desktop `permissions.rs`, `ComputerUsePermissions.tsx`; four separate read-only probes and explicit request receipts; Windows capability/UIPI facts and Linux AT-SPI/session consent replace macOS-specific assumptions |
182-
| App sharing and control grants | `src/sharing.rs`, `src/grants.rs`, sharing controls in `src/gui.rs` | Admission state machine plus Desktop `sharing.rs`, `shared_preview.rs`, `process_identity.rs`, `grants.rs`, `share_grants.rs`; user-selected native window, observe first, separate revocable grant, executable-bound remembered preference, manual preview gestures |
197+
| Permission query/request | `src/native/permissions.rs`, native permission probes | `computer_use_permissions` contracts, native service `permissions.rs`, Web `ComputerUsePermissions.tsx`; four separate read-only probes and explicit request receipts; Windows capability/UIPI facts and Linux AT-SPI/session consent replace macOS-specific assumptions |
198+
| App sharing and control grants | `src/sharing.rs`, `src/grants.rs`, sharing controls in `src/gui.rs` | Admission state machine plus native service `sharing.rs`, `shared_preview.rs`, `process_identity.rs`, `grants.rs`, `share_grants.rs`; user-selected native window, observe first, separate revocable grant, executable-bound remembered preference, manual preview gestures |
183199
| Coordinate conversion | `CoordinateMap` in `src/sharing.rs` | Portable `CaptureGeometry` and Web `previewGeometry.ts`; image/content/global/preview round trips, aspect fit, negative origins, independent X/Y scales, strict padding rejection and immutable screenshot identity |
184200
| Virtual mouse | `src/cursor.rs`, GUI cursor rendering | Web `VirtualCursor.ts` ports the deterministic physical model, rendered by `PreviewCursor.tsx`; 63 Rust-generated reference samples cover movement, retargeting, immediate placement, resize and visibility. Existing passive native overlays remain platform adapters |
185201
| Background control | Native directed/semantic input and desktop-state comparison | Existing AX/UIA/AT-SPI and directed-input providers plus `background_guard.rs`; diagnostic focus/pointer/window-order evidence, explicit unsupported routes, no restore or replay. Concurrent human input does not revoke Agent control. The reference's implicit Command modifier is not copied because it changes the requested click |
@@ -407,15 +423,16 @@ until the next information boundary and reuses the returned observation. It does
407423
not reduce the user's selected reasoning effort or impose step/retry-count caps.
408424

409425
`get_app_state`, `app_batch` and single app-input aliases accept optional
410-
`include_image` (default `true`). With `false`, Desktop reads AX and refreshes
411-
observation/node identities without retrieving or encoding a model screenshot.
412-
This is suitable for sufficient semantic state or known keyboard flows. Canvas,
413-
visual verification and selecting image coordinates still need an image-bearing
414-
observation. Target preparation, control leases, cancellation and native consent
415-
remain unchanged; AX-only is not a different input route. Legacy port providers
416-
can retain their old capture path and omit the image from its result. Existing
417-
callers/persisted tool calls omit the field and retain their previous behavior.
418-
The option is local tool presentation, not a new remote GUI capability.
426+
`include_image` (default `true`). With `false`, the native provider reads AX and
427+
refreshes observation/node identities without retrieving or encoding a model
428+
screenshot. This is suitable for sufficient semantic state or known keyboard
429+
flows. Canvas, visual verification and selecting image coordinates still need an
430+
image-bearing observation. Target preparation, control leases, cancellation and
431+
native consent remain unchanged; AX-only is not a different input route. Legacy
432+
port providers can retain their old capture path and omit the image from its
433+
result. Existing callers/persisted tool calls omit the field and retain their
434+
previous behavior. The option is local tool presentation, not a new remote GUI
435+
capability.
419436

420437
Program receipts include `observation_elapsed_ms` alongside per-step and total
421438
elapsed time. These measure host execution, not model reasoning or end-to-end

0 commit comments

Comments
 (0)