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
6 changes: 3 additions & 3 deletions AGENTS-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ Execution、Extension、Cross-platform Adapter 的边界以
| 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、session persistence primitives、network 和 MiniApp runtime IO 实现 | `services-core`, `services-integrations`, `terminal` | [AGENTS.md](src/crates/services/AGENTS.md) |
| 4 | 服务实现层 | `src/crates/services` | 可复用 OS、filesystem、terminal、MCP、remote、git、watch、process、LSP plugin registry、session persistence primitives、network 和 MiniApp runtime IO 实现 | `services-core`, `services-integrations`, `terminal` | [AGENTS.md](src/crates/services/AGENTS.md) |
| 5 | 执行原语层 | `src/crates/execution` | 可移植 agent、harness、stream、DeepReview policy/report、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) |
| 6 | 稳定契约与产品领域层 | `src/crates/contracts` | 跨层共享 DTO、事件形状、runtime port、LSP protocol/plugin DTO、产品领域契约和策略 | `core-types`, `events`, `runtime-ports`, `product-domains` | [AGENTS.md](src/crates/contracts/AGENTS.md) |

边界规则:

- 接口与入口层暴露选定产品行为;可复用行为应下移。
- 组装层只接线下层并选择产品能力事实,不实现具体 adapter、OS 或 service 细节。
- 产品特性只在内核能力之上组装用户侧命令、UI contribution、设置和默认策略;长程任务、scheduler、permission、session/workspace、memory、DFX、hook 和 event 事实属于 Agent Kernel owner。
- 适配层翻译协议和外部 provider 形状,不拥有产品能力选择或可复用 OS service 行为。
- 服务实现层负责可复用的 OS、process、terminal、MCP、remote、git、filesystem、session persistence primitives 和 MiniApp runtime IO 能力。
- 服务实现层负责可复用的 OS、process、terminal、MCP、remote、git、filesystem、LSP plugin registry、session persistence primitives 和 MiniApp runtime IO 能力。
- 外部系统是边界外资源,不是仓库内层级。只有已注册的 adapter、service 或 app-local provider 应调用它们;其他层消费 port 和稳定契约。
- 执行原语层只放可移植运行时构件,不拥有宿主或交付形态。
- 契约层保持轻行为,不得向上依赖。
Expand Down
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ Keep crate dependencies inside each layer to the smallest set needed.
| 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, session persistence primitives, MiniApp runtime IO, and network implementations | `services-core`, `services-integrations`, `terminal` | [AGENTS.md](src/crates/services/AGENTS.md) |
| 4 | Services | `src/crates/services` | Reusable OS, filesystem, terminal, MCP, remote, git, watch, process, LSP plugin registry, session persistence primitives, MiniApp runtime IO, 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, DeepReview policy/report, 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) |
| 6 | Stable contracts and product domains | `src/crates/contracts` | Shared DTOs, event shapes, runtime ports, LSP protocol/plugin DTOs, and product domain contracts/policies | `core-types`, `events`, `runtime-ports`, `product-domains` | [AGENTS.md](src/crates/contracts/AGENTS.md) |

Boundary rules:

- 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.
- Product features assemble user-facing commands, UI contributions, settings, and default policy on top of kernel capabilities; long-running task, scheduler, permission, session/workspace, memory, DFX, hook, and event facts stay in Agent Kernel owners.
- Adapters translate protocols and external-provider shapes; they should not own product capability selection or reusable OS service behavior.
- Services implement reusable concrete OS, process, terminal, MCP, remote, git, filesystem, and MiniApp runtime IO capabilities.
- Services implement reusable concrete OS, process, terminal, MCP, remote, git, filesystem, LSP plugin registry, and MiniApp runtime IO capabilities.
- External systems are boundary resources, not repository layers. Only registered adapters/services/app-local providers should call them; other layers consume ports and stable contracts.
- 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
4 changes: 2 additions & 2 deletions docs/plans/core-decomposition-completed.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
## 1. 基础边界

- 已建立 `product-full` 作为完整产品能力保护开关,产品入口显式启用完整能力。
- 已抽取 `bitfun-core-types`、`bitfun-events`、`bitfun-runtime-ports`、`bitfun-agent-stream` 等基础契约。
- 已抽取 `bitfun-core-types`、`bitfun-events`、`bitfun-runtime-ports`、`bitfun-agent-stream` 等基础契约;LSP protocol DTO 和 plugin manifest DTO 已进入 `bitfun-core-types`
- 已建立 `bitfun-services-core`、`bitfun-services-integrations`、`bitfun-agent-tools`、`tool-runtime`、`bitfun-tool-packs`、`bitfun-agent-runtime`、`bitfun-runtime-services`、`bitfun-harness`、`bitfun-product-domains`、`bitfun-product-capabilities` 等 owner crate。
- `src/crates` 已按 `interfaces / assembly / adapters / services / execution / contracts` 六层布局整理,DeepReview path classifier、boundary rules、Cargo workspace path 和根/层级 AGENTS 已同步。

## 2. 已迁移 owner

- `services-core` 已承接 session layout、metadata store CRUD / index rebuild、metadata pagination、metadata construction / mutation、lineage / branch shaping、JSON file store、filesystem primitives、managed runtime command resolution / PATH merge、diagnostic redaction、session usage/token usage 基础服务。
- `services-core` 已承接 session layout、metadata store CRUD / index rebuild、metadata pagination、metadata construction / mutation、lineage / branch shaping、JSON file store、filesystem primitives、managed runtime command resolution / PATH merge、LSP plugin registry / extension matching / command-target mapping、diagnostic redaction、session usage/token usage 基础服务。
- `services-core` 已承接 workspace-runtime legacy session-store merge、metadata 冲突选择、index rebuild 和 legacy path copy/move fallback;core workspace-runtime 只保留路径计算、runtime layout ensure 和错误兼容映射。
- `runtime-services` 已承接 typed runtime service assembly、capability availability、provider registry、capability validation、无副作用 capability marker ports 和 backend event delivery;core backend event system 只保留兼容 re-export。
- `bitfun-events` 已承接 backend event DTO、agentic event DTO 和 platform-neutral `EventEmitter` trait。
Expand Down
7 changes: 5 additions & 2 deletions docs/plans/core-decomposition-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,21 @@

### PR-D:Extension Host 与 OpenCode / ACP 适配收口

状态:本阶段收口 ACP external-agent tool bridge;Extension/OpenCode/plugin、UI extension、effect / permission mapping 和多形态 SDK 验证转入后续阶段
状态:本阶段收口已有消费路径中的 ACP external-agent tool bridge 与 LSP plugin contract / registry owner;OpenCode / UI extension / capability-effect 泛化 API 不提前稳定,等出现真实消费路径后单独接入

完成口径:

- ACP external-agent tool name、schema、validation、presentation 和 ToolResult shape 由 `bitfun-agent-tools` 承接。
- `bitfun-acp` 继续持有 ACP protocol、client lifecycle、remote probing、permission bridge 和配置加载;现有 `AcpClientInfo` API shape 不变。
- OpenCode/plugin concrete host、UI contribution、hook/workflow provider mapping 和 capability/effect policy 仍需在实际消费路径明确后单独接入,避免提前扩大稳定 API。
- LSP protocol DTO 和 plugin manifest DTO 由 `bitfun-core-types` 承接,`bitfun-core::service::lsp::types` 只保留兼容 re-export。
- LSP plugin registry、extension/language lookup、surface-facing supported-extension summary 和 manifest command placeholder 解析由 `bitfun-services-core` 承接;core 保留 plugin package IO、server path 检查和 process lifecycle。
- OpenCode concrete host、UI contribution、hook/workflow provider mapping 和 capability/effect policy 仍需在实际消费路径明确后单独接入,避免提前扩大稳定 API。

保护:

- 插件、OpenCode、ACP、external skills 不能直接写 kernel 权威状态、permission decision、audit event 或 UI implementation。
- 未声明能力默认受限;UI contribution descriptor 可 round-trip,并在不支持形态返回 unsupported/unavailable。
- LSP manifest 序列化默认值、registry 查找/卸载/错误文案、supported-extension summary 和跨平台 command placeholder 解析必须有 focused contract tests。

### PR-E:Cross-platform Adapter 与多形态 SDK 验证

Expand Down
40 changes: 40 additions & 0 deletions scripts/core-boundaries/rules/source/forbidden-rules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,46 @@ export const forbiddenContentRules = [
},
],
},
{
path: 'src/crates/assembly/core/src/service/lsp/types.rs',
patterns: [
{
regex: /\bpub struct LspPlugin\b/,
message:
'LSP plugin manifest DTO belongs in bitfun-core-types; keep core LSP types as a compatibility facade',
},
{
regex: /\bpub enum JsonRpcMessage\b/,
message:
'LSP JSON-RPC DTOs belong in bitfun-core-types; keep core LSP types as a compatibility facade',
},
{
regex: /\buse serde::\{Deserialize,\s*Serialize\}/,
message:
'core LSP types should not own serialization DTOs after migration to bitfun-core-types',
},
],
},
{
path: 'src/crates/assembly/core/src/service/lsp/registry.rs',
patterns: [
{
regex: /\bpub struct PluginRegistry\b/,
message:
'LSP plugin registry belongs in bitfun-services-core; keep core registry as a compatibility facade',
},
{
regex: /\bHashMap<String,\s*LspPlugin>\b/,
message:
'core LSP registry must not own plugin index maps after migration to bitfun-services-core',
},
{
regex: /\bPathBuf::from\(file_path\)/,
message:
'LSP file-extension lookup belongs in bitfun-services-core registry rules',
},
],
},
{
path: 'src/crates/assembly/core/src/product_assembly.rs',
patterns: [
Expand Down
119 changes: 119 additions & 0 deletions scripts/core-boundaries/rules/source/required-rules.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,125 @@
// Boundary rules for source ownership, facades, and required owner content.

export const requiredContentRules = [
{
path: 'src/crates/contracts/core-types/src/lsp.rs',
reason:
'core-types must own shared LSP protocol DTOs and plugin manifest wire contracts',
patterns: [
{
regex: /\bpub struct LspPlugin\b/,
message: 'missing LSP plugin manifest contract owner',
},
{
regex: /\bpub struct ServerConfig\b/,
message: 'missing LSP plugin server config contract',
},
{
regex: /\bpub enum JsonRpcMessage\b/,
message: 'missing LSP JSON-RPC wire DTO contract',
},
{
regex: /\bpub enum PluginSource\b/,
message: 'missing LSP plugin source contract',
},
],
},
{
path: 'src/crates/services/services-core/src/lsp.rs',
reason:
'services-core must own pure LSP plugin registry and command-target mapping rules',
patterns: [
{
regex: /\bpub struct PluginRegistry\b/,
message: 'missing services-owned LSP plugin registry',
},
{
regex: /\bpub struct LspSupportedExtensions\b/,
message: 'missing supported extension summary owner',
},
{
regex: /\bpub struct LspPluginRuntimeTarget\b/,
message: 'missing LSP plugin runtime target contract',
},
{
regex: /\bpub fn resolve_plugin_command_for_target\b/,
message: 'missing pure LSP plugin command placeholder resolver',
},
{
regex: /\bpub fn resolve_plugin_command_for_current_target\b/,
message: 'missing current-target LSP plugin command resolver',
},
],
},
{
path: 'src/crates/assembly/core/src/service/lsp/types.rs',
reason:
'core LSP types path must remain a compatibility facade over core-types',
patterns: [
{
regex: /\bpub use bitfun_core_types::lsp::\*/,
message: 'core LSP types must re-export bitfun-core-types contracts',
},
],
},
{
path: 'src/crates/assembly/core/src/service/lsp/registry.rs',
reason:
'core LSP registry path must remain a compatibility facade over services-core',
patterns: [
{
regex: /\bpub use bitfun_services_core::lsp::\{/,
message: 'core LSP registry must re-export services-core registry',
},
],
},
{
path: 'src/crates/contracts/core-types/tests/lsp_contracts.rs',
reason:
'core-types must keep LSP manifest serialization and default-value regressions',
patterns: [
{
regex: /\blsp_plugin_manifest_defaults_preserve_legacy_shape\b/,
message: 'missing LSP manifest default regression',
},
{
regex: /\blsp_capability_config_missing_fields_default_to_false\b/,
message: 'missing LSP capability default regression',
},
],
},
{
path: 'src/crates/services/services-core/tests/lsp_plugin_registry_contracts.rs',
reason:
'services-core must keep behavior-equivalence contracts for LSP plugin registry and command mapping',
patterns: [
{
regex: /\bregistry_preserves_language_extension_and_file_path_lookup\b/,
message: 'missing LSP registry lookup regression',
},
{
regex: /\bregistry_unregister_removes_plugin_indexes\b/,
message: 'missing LSP registry unregister regression',
},
{
regex: /\bregistry_unregister_preserves_indexes_owned_by_newer_plugin\b/,
message:
'missing LSP registry overlapping-plugin unregister regression',
},
{
regex: /\bregistry_duplicate_and_missing_errors_keep_legacy_messages\b/,
message: 'missing LSP registry error-message regression',
},
{
regex: /\bregistry_supported_extensions_matches_desktop_api_shape\b/,
message: 'missing LSP supported extension summary regression',
},
{
regex: /\bplugin_command_placeholder_resolution_is_target_driven\b/,
message: 'missing LSP plugin command placeholder regression',
},
],
},
{
path: 'src/crates/execution/runtime-services/src/lib.rs',
reason:
Expand Down
24 changes: 3 additions & 21 deletions src/apps/desktop/src/api/lsp_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,32 +393,14 @@ pub struct SupportedExtensionsResponse {

#[tauri::command]
pub async fn lsp_get_supported_extensions() -> Result<SupportedExtensionsResponse, String> {
use std::collections::HashMap;

let manager = get_global_lsp_manager().map_err(|e| format!("LSP not initialized: {}", e))?;

let guard = manager.read().await;
let plugins = guard.list_plugins().await;

let mut extension_to_language: HashMap<String, String> = HashMap::new();
let mut supported_languages: std::collections::HashSet<String> =
std::collections::HashSet::new();

for plugin in plugins {
for lang in &plugin.languages {
supported_languages.insert(lang.clone());
}

for ext in &plugin.file_extensions {
if !plugin.languages.is_empty() {
extension_to_language.insert(ext.clone(), plugin.languages[0].clone());
}
}
}
let summary = guard.supported_extensions().await;

Ok(SupportedExtensionsResponse {
extension_to_language,
supported_languages: supported_languages.into_iter().collect(),
extension_to_language: summary.extension_to_language,
supported_languages: summary.supported_languages,
})
}

Expand Down
8 changes: 7 additions & 1 deletion src/crates/assembly/core/src/service/lsp/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::plugin_loader::PluginLoader;
use super::process::{
CrashCallback, DiagnosticsCallback, LspServerProcess, ProgressCallback, TokenCreateCallback,
};
use super::registry::PluginRegistry;
use super::registry::{LspSupportedExtensions, PluginRegistry};
use super::types::{CompletionItem, LspPlugin};

/// LSP protocol-layer manager (stateless, pure protocol implementation).
Expand Down Expand Up @@ -250,6 +250,12 @@ impl LspManager {
registry.find_by_file_path(file_path).cloned()
}

/// Returns surface-facing supported extension facts.
pub async fn supported_extensions(&self) -> LspSupportedExtensions {
let registry = self.registry.read().await;
registry.supported_extensions()
}

/// Shuts down all servers.
pub async fn shutdown(&self) -> Result<()> {
info!("Shutting down all LSP servers");
Expand Down
Loading
Loading