Core Agent Guide
June 8, 2026 · View on GitHub
中文 | English
Core Agent Guide
Scope
This file applies to src/crates/assembly/core. Use the top-level AGENTS.md for
repository-wide rules and the nearest narrower guide when one exists.
Role
bitfun-core is the shared product runtime facade. It still owns compatibility
paths and the product-full assembly boundary, but new decomposition work should
prefer the owner crates described in docs/architecture/core-decomposition.md
and docs/architecture/agent-runtime-services-design.md.
Main areas:
src/agentic/: agents, prompts, tools, sessions, execution, persistencesrc/service/: config, filesystem, terminal, git, LSP, MCP, remote connect, AI memorysrc/infrastructure/: AI clients, app paths, event system, storage, debug log serversrc/product_runtime/: product-full compatibility adapters and runtime service provider wiring
Agent runtime mental model:
SessionManager -> Session -> DialogTurn -> ModelRound
Boundary Rules
- Keep shared core platform-agnostic. Avoid host-specific APIs such as
tauri::AppHandle; use shared abstractions such asbitfun_events::EventEmitter. - Desktop-only host adapters belong in
src/apps/desktop, then flow through transport/API layers. - Do not add new cross-layer references from
servicetoagenticwithout a narrow port/interface boundary. - Do not move platform-specific logic, build-script behavior, product capability selection, or provider-specific AI serialization into shared core.
- When moving ownership out of core, preserve old import paths with facade or re-export code until downstream call sites are intentionally migrated.
Decomposition Rules
- Treat
bitfun-coreas a compatibility facade plus full product assembly point, not as the preferred home for new stable contracts. - Put stable DTOs, facts, ports, and pure decisions in the matching owner crate where a clear owner exists. Keep concrete managers, IO, platform adapters, and product execution in core until a reviewed port/adapter/service design and behavior equivalence tests exist.
- Tool changes must preserve expanded/collapsed exposure, prompt-visible
manifests,
GetToolSpec, permission behavior,ToolUseContextsemantics, and desktop/MCP/ACP catalog behavior. - Runtime-owner migrations must keep concrete lifecycle, IO, event delivery, permission orchestration, and remote/platform implementations in core until the target owner has a reviewed port/adapter/service design plus behavior-equivalence tests.
- Product-domain changes may move pure product-domain plans with equivalence coverage, but filesystem writes, worker/host side effects, Git/AI concrete calls, marker IO, and path-manager integration stay in core unless a reviewed owner design says otherwise.
- Remote/service changes must keep external protocol lifecycle, workspace projection, scheduler/session restore, terminal pre-warm, and product execution boundaries explicit.
- Feature work must keep
product-fullas the compatibility product assembly boundary unless a separate product matrix review changes default capability selection.
Owner References
Use these files for ownership details instead of expanding this guide:
docs/architecture/core-decomposition.mddocs/architecture/agent-runtime-services-design.mdsrc/crates/execution/agent-runtime/AGENTS.mdsrc/crates/execution/tool-contracts/AGENTS.mdsrc/crates/execution/harness/AGENTS.mdsrc/crates/contracts/product-domains/AGENTS.mdsrc/crates/contracts/runtime-ports/andsrc/crates/execution/runtime-services/source docssrc/crates/services/services-core/AGENTS.mdsrc/crates/services/services-integrations/AGENTS.mdsrc/crates/execution/tool-provider-groups/AGENTS.md
Narrower local guides already exist for some subtrees:
src/crates/adapters/ai-adapters/AGENTS.mdsrc/agentic/execution/AGENTS.mdsrc/agentic/deep_review/AGENTS.md
Verification
Use the smallest check that matches the touched behavior:
cargo check --workspace
cargo test -p bitfun-core <test_name> -- --nocapture
node scripts/check-core-boundaries.mjs
For documentation-only changes, run git diff --check.