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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/core-decomposition.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Rust 编译和链接面。
| `bitfun-agent-runtime` | Sessions、execution、coordination、agent system | target:crate 尚不存在,agent runtime 仍在 core |
| `bitfun-agent-tools` | 轻量 tool DTO / contract、portable tool context facts / provider、runtime restriction、host path normalization / runtime artifact URI / remote POSIX path pure contract、provider-neutral tool path resolution / absolute-path check / runtime artifact reference assembly、file guidance marker、file-read freshness comparison、oversized tool-result preview/rendering policy、tool execution result/error/invalid-call presentation policy、allowed-list / collapsed-tool execution gate policy、provider-neutral path policy root matching / denial message、pure manifest/exposure and GetToolSpec presentation/schema/static metadata/detail/result assembly / execution-plan contract、provider-backed tool catalog / GetToolSpec runtime facade、provider-backed GetToolSpec execution result helper / Tool-result vector adapter、generic contextual manifest resolver、generic catalog snapshot provider / GetToolSpec catalog provider、generic registry / static-provider / dynamic-provider / decorator-ref / snapshot-decorator adapter / runtime assembly container、generic readonly/enabled snapshot filter | partial:product registry snapshot access、`ToolUseContext` adapter、session file-read state storage、tool-result filesystem writes、`GetToolSpec` Tool impl 和 concrete tools 仍在 core,并由 core `tools/product_runtime.rs` 作为单一 product runtime owner 组装;core 当前从 `bitfun-tool-packs` provider plan 物化内置工具列表,static-provider 安装 assembly、decorator reference、generic snapshot decorator adapter、provider-backed catalog runtime facade、readonly/enabled 过滤规则、provider-neutral tool path resolution / runtime artifact reference assembly、file guidance/freshness policy、oversized result rendering、tool execution presentation 与 path policy 判定已委托给 `bitfun-agent-tools` |
| `bitfun-tool-packs` | 由 feature group 隔离的工具 provider plan | partial:提供 basic / git / mcp / browser-web / computer-use / image-analysis / miniapp / agent-control feature-group 元数据和 product provider group plan;不得声明 concrete tools 已迁移 |
| `bitfun-services-core` | Config、session、workspace、storage、filesystem、system services | partial:部分 pure helper 已迁出;config/workspace/filesystem runtime 多数仍在 core |
| `bitfun-services-core` | Config、session、workspace、storage、filesystem、system services | partial:部分 pure helper 已迁出;通用本地 filesystem operations/tree/search/listing/service facade 已迁入;config/workspace/runtime/persistence 以及 filesystem 的 remote overlay、product runtime binding 仍在 core |
| `bitfun-services-integrations` | Git、MCP、remote SSH、remote connect、file watch integrations | partial:MCP runtime 已迁入;remote SSH 仍只迁移低风险 contracts/helpers;remote-connect 已拥有 wire DTO、request builder、tracker state / registry lifecycle、tracker event reduction、dialog submission orchestration port/provider、file IO/path resolution helper、remote file command / response assembly、dialog/cancel/execution accepted response helper、workspace/session response assembly helper 与 image-context adapter contract;concrete scheduler/session restore/terminal adapter、workspace-root source、persistence/workspace service reads 与 product execution 仍在 core |
| `bitfun-product-domains` | Miniapp 和 function-agent 产品子域 | partial:pure decision、port、MiniApp create/update/draft/apply/import state transition、storage/builtin contract、imported meta timestamp policy、seed meta timestamp policy、runtime detection concrete owner、worker/host/export 纯决策已迁入;filesystem IO、worker process、host dispatch execution、built-in asset seeding、export skeleton 与 Git/AI service runtime 仍在 core |
| `terminal-core` | 已有 terminal package,移动到 workspace 顶层 `src/crates/terminal` 路径 | done:已在 workspace 顶层 |
Expand Down
5 changes: 3 additions & 2 deletions docs/plans/core-decomposition-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,10 @@ cargo check --workspace

**当前安全迁移状态(2026-05-11):**

- 已迁移到 `bitfun-services-core`:`service::system`、`service::diff`、`util::process_manager`、`service::session::types`、`service::session_usage::{types,classifier,redaction,render}`、`service::token_usage::types`。
- 已迁移到 `bitfun-services-core`:`service::system`、`service::diff`、`util::process_manager`、`service::session::types`、`service::session_usage::{types,classifier,redaction,render}`、`service::token_usage::types`、通用本地 `infrastructure::filesystem` operations/tree/search/listing 和 `service::filesystem` service facade
- `SessionKind` 已移动到 `bitfun-core-types`,core 的 `agentic::core::SessionKind` 与 `service::session::SessionKind` 继续通过 re-export 兼容。
- 最新主干新增的 Deep Review `deep_review_run_manifest` / `deep_review_cache` 字段已随 `service::session::types` 一起迁移,并保留原有序列化别名与 round-trip 测试;这不是新的 P2 行为变更。
- `service::config`、`workspace`、`workspace_runtime`、`filesystem`、`runtime`、`i18n`、`bootstrap`、`project_context` 仍保留在 core;继续迁移前需要先确认 `BitFunError``PathManager`、workspace/provider ports 的边界方案
- `service::config`、`workspace`、`workspace_runtime`、`runtime`、`i18n`、`bootstrap`、`project_context` 仍保留在 core;filesystem 侧的 remote workspace overlay、`BitFunError` 映射、MiniApp filesystem IO、tool-result persistence、PathManager 绑定和产品 runtime 接线仍保留在 core。继续迁移前需要先确认 `PathManager`、workspace/provider ports 和产品持久化边界方案

**验证:**

Expand Down Expand Up @@ -1314,6 +1314,7 @@ product-full = ["miniapp", "function-agents"]
- 2026-05-21 function-agent response-policy update: Git commit-message and Startchat prompt templates, AI response JSON extraction, JSON repair, JSON-string parsers, and domain error mapping now live in `bitfun-product-domains::function_agents`; core still owns AI service calls, Git service adapters, provider acquisition, AI transport errors, and runtime analysis orchestration.
- 2026-05-25 HR-B update: MiniApp create/update/draft prepare/draft sync/permission update/draft apply/import 的纯 manager state transitions 已移入 `bitfun-product-domains::miniapp::lifecycle` / `MiniAppRuntimeFacade`,imported meta 的 id/timestamp 规则也已归入 product-domain helper;内置 MiniApp seed meta 的 id/timestamp/preserved-created-at 规则已移入 `bitfun-product-domains::miniapp::builtin`。
- 2026-05-26 HR-B expansion: MiniApp concrete runtime detector owner 已移入 `bitfun-product-domains::miniapp::runtime`,包含 PATH lookup、version-manager directory scan 与 `--version` process check;core `miniapp::runtime_detect` 只保留兼容 facade。core 仍负责 compile 调度、source/storage/path/marker filesystem IO、customization metadata IO、worker process、host dispatch、built-in asset include/seeding/recompile,以及 function-agent Git/AI concrete service 调用。
- 2026-05-26 filesystem owner update: 通用本地 filesystem operations、tree/search、directory listing、统一 `FileSystemError` 和 service facade 已迁入 `bitfun-services-core::filesystem`;core `infrastructure::filesystem` / `service::filesystem::{types,listing}` 只保留 re-export,core `service::filesystem::FileSystemService` 只保留 remote workspace overlay、legacy `BitFunError` 映射和旧 API 兼容。MiniApp filesystem IO、tool-result persistence、workspace `PathManager` 绑定、remote SSH runtime 和产品持久化接线仍显式 core-owned。
- boundary check 已补充 product-domain owner anchor:`MiniAppStoragePort` / `MiniAppRuntimePort` 的 core adapter、MiniApp host/customization/builtin 纯 contract、MiniApp manager preflight tests、function-agent Git adapter、prompt/response policy helper 必须存在,防止把 port contract 或 response policy 误读成 storage IO、worker process、host dispatch、customization draft runtime、builtin asset seeding runtime 或 Git/AI service runtime 已完成迁移。
- miniapp runtime/storage/manager/host dispatch/exporter/builtin 与 function-agent 运行逻辑继续迁移前,需要先确认 agent/tool/provider port 和 Git/AI service 边界。

Expand Down
91 changes: 91 additions & 0 deletions scripts/check-core-boundaries.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,21 @@ const ownerCrateFeatureAssemblyRules = [
];

const facadeOnlyFiles = [
{
path: 'src/crates/core/src/infrastructure/filesystem/mod.rs',
importPrefix: 'bitfun_services_core::filesystem',
reason: 'core filesystem infrastructure facade must only re-export the services-core owner crate',
},
{
path: 'src/crates/core/src/service/filesystem/listing.rs',
importPrefix: 'bitfun_services_core::filesystem',
reason: 'core filesystem listing facade must only re-export the services-core owner crate',
},
{
path: 'src/crates/core/src/service/filesystem/types.rs',
importPrefix: 'bitfun_services_core::filesystem',
reason: 'core filesystem DTO facade must only re-export the services-core owner crate',
},
{
path: 'src/crates/core/src/service/git/git_service.rs',
importPrefix: 'bitfun_services_integrations::git',
Expand Down Expand Up @@ -511,6 +526,36 @@ const facadeOnlyFiles = [
];

const forbiddenContentRules = [
{
path: 'src/crates/core/src/service/filesystem/service.rs',
patterns: [
{
regex: /\btokio::fs::/,
message:
'core filesystem service must not own async local filesystem IO; use bitfun-services-core filesystem primitives',
},
{
regex: /\bstd::fs::/,
message:
'core filesystem service must not own sync local filesystem IO; use bitfun-services-core filesystem primitives',
},
{
regex: /\bignore::WalkBuilder\b/,
message:
'core filesystem service must not own local file walking/search implementation; use bitfun-services-core filesystem primitives',
},
{
regex: /\bsha2::/,
message:
'core filesystem service must not own editor-sync hashing implementation; use bitfun-services-core filesystem primitives',
},
{
regex: /\bbase64::/,
message:
'core filesystem service must not own binary file encoding implementation; use bitfun-services-core filesystem primitives',
},
],
},
{
path: 'src/crates/core/src/miniapp/runtime_detect.rs',
patterns: [
Expand Down Expand Up @@ -1752,6 +1797,52 @@ const forbiddenContentUnderRules = [
];

const requiredContentRules = [
{
path: 'src/crates/services-core/src/filesystem/mod.rs',
reason:
'services-core filesystem owner must expose local filesystem primitives behind a single module boundary',
patterns: [
{
regex: /mod error;/,
message: 'filesystem owner must expose its error boundary',
},
{
regex: /mod operations;/,
message: 'filesystem owner must expose local file operation primitives',
},
{
regex: /mod tree;/,
message: 'filesystem owner must expose local file tree/search primitives',
},
{
regex: /pub use error::\{FileSystemError, FileSystemResult\};/,
message: 'filesystem owner must re-export the unified filesystem error type',
},
{
regex: /pub use service::FileSystemService;/,
message: 'filesystem owner must keep the consolidated service facade',
},
],
},
{
path: 'src/crates/core/src/service/filesystem/service.rs',
reason:
'core filesystem service may keep remote-workspace overlay and BitFunError compatibility, but local filesystem owner must remain services-core',
patterns: [
{
regex: /lookup_remote_connection_with_hint/,
message: 'core filesystem wrapper must preserve remote workspace connection disambiguation',
},
{
regex: /get_remote_workspace_manager/,
message: 'core filesystem wrapper must preserve existing remote file service lookup',
},
{
regex: /map_filesystem_error/,
message: 'core filesystem wrapper must map services-core errors at the compatibility boundary',
},
],
},
{
path: 'src/crates/core/Cargo.toml',
reason:
Expand Down
5 changes: 5 additions & 0 deletions src/crates/core/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ SessionManager → Session → DialogTurn → ModelRound
- Keep concrete remote SSH runtime code behind `ssh-remote`. No-default builds
may keep workspace identity helpers and explicit unsupported stubs, but must
not compile russh-backed SSH/SFTP/terminal/search runtime modules.
- Generic local filesystem operations, tree/search, listing, and filesystem DTOs
live in `bitfun-services-core::filesystem`. Core may keep compatibility
re-exports, remote workspace overlay, `BitFunError` mapping, MiniApp
filesystem IO, tool-result persistence, `PathManager` binding, and product
runtime wiring.
- Keep no-default `bitfun-core` as a runtime-surface-light facade, not a
claimed dependency-light build. Full product runtime modules such as agentic,
MiniApp/function-agent, Git/MCP, remote-connect, review-platform, snapshot,
Expand Down
4 changes: 2 additions & 2 deletions src/crates/core/src/agentic/tools/implementations/ls_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ Usage:
}

// Local: original implementation
let entries =
list_directory_entries(&resolved.resolved_path, limit).map_err(BitFunError::tool)?;
let entries = list_directory_entries(&resolved.resolved_path, limit)
.map_err(|error| BitFunError::tool(error.to_string()))?;

let entries_json = entries
.iter()
Expand Down
19 changes: 6 additions & 13 deletions src/crates/core/src/infrastructure/filesystem/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
//! Filesystem infrastructure
//!
//! File operations and file tree building.
//! Filesystem infrastructure compatibility facade.

pub mod file_operations;
pub mod file_tree;

pub use file_operations::{
normalize_text_for_editor_disk_sync, FileInfo, FileOperationOptions, FileOperationService,
FileReadResult, FileWriteResult,
};
pub use file_tree::{
BatchedFileSearchProgressSink, FileContentSearchOptions, FileNameSearchOptions,
pub use bitfun_services_core::filesystem::{
normalize_text_for_editor_disk_sync, BatchedFileSearchProgressSink, FileContentSearchOptions,
FileInfo, FileNameSearchOptions, FileOperationOptions, FileOperationService, FileReadResult,
FileSearchOutcome, FileSearchProgressSink, FileSearchResult, FileSearchResultGroup,
FileTreeNode, FileTreeOptions, FileTreeService, FileTreeStatistics, SearchMatchType,
FileTreeNode, FileTreeOptions, FileTreeService, FileTreeStatistics, FileWriteResult,
SearchMatchType,
};
Loading
Loading