Skip to content

feat: 增加重插件分层加载、能力开关与 AGENTS.md 自动上下文 - #117

Open
A-m-o-r-F-a-t-i wants to merge 2 commits into
uvwt:mainfrom
A-m-o-r-F-a-t-i:feat/heavy-plugins
Open

A-m-o-r-F-a-t-i wants to merge 2 commits into
uvwt:mainfrom
A-m-o-r-F-a-t-i:feat/heavy-plugins

Conversation

@A-m-o-r-F-a-t-i

Copy link
Copy Markdown

背景

随着已安装 Skill 和动态 MCP 数量增加,当前扁平能力索引会重复暴露同一领域的 Skill、MCP 服务及工具描述,模型需要自行拼接领域上下文,也缺少统一的功能开关。与此同时,AgentDock 尚未原生加载全局和工作区 AGENTS.md,项目规则需要由客户端额外注入。

本 PR 将两个已经完成并通过测试的能力一起提交:

  1. 原生加载全局与工作区 AGENTS.md
  2. 增加“重插件”分层能力模型和 Windows 图形化管理面板。

主要改动

1. 原生 AGENTS.md 自动上下文

  • Core 原生发现 ${AGENTDOCK_HOME}/AGENTS.md、工作区根目录及目标子目录链上的 AGENTS.md
  • agentdock_context 新增请求级 workdir,每次调用重新读取规则文件,不修改命令默认工作目录;
  • MCP 初始化 instructions 提供启动快照,规则变化后可通过 agentdock_context 刷新;
  • 使用 Git/worktree 边界、os.Root、文件身份校验、大小与层级预算限制读取范围;
  • 默认启用,可通过 AGENTDOCK_AGENTS_AUTOLOAD=false 关闭自动发现,显式 AGENTDOCK_INSTRUCTIONS_FILE 保持原语义;
  • Nexus 私有 context.local 保持既有协议结构,通过原有 rules 字段承载规则文本。

2. 重插件与两层渐进式加载

  • 新增逻辑插件注册表 ~/.agentdock/plugins/plugins.json,插件只记录名称、领域描述、成员归属和总开关;
  • 插件可以封装一个或多个文档 Skill 与动态 MCP 服务,不复制或改变原 Skill/MCP 配置;
  • agentdock_context 第一层仅暴露启用插件的名称、描述和成员数量;
  • 插件成员不会在顶层 skillsdynamic_mcp 中重复显示;
  • 新增 plugin_load,第二层按需返回插件包含的 Skill 入口、MCP 服务描述,并延迟执行 MCP 工具发现;
  • 无服务器限定的通用 mcp_tool_search 不扫描插件成员,显式选择插件或服务后再展开完整工具描述。

3. 插件、Skill 与 MCP 独立开关

有效可用性采用:

成员基础开关启用 AND(未归属插件 OR 所属插件启用)
  • 关闭插件只叠加屏蔽其成员,不改写成员自身开关;
  • 再次开启插件时,仍保持成员各自的启用/停用状态;
  • 在 Skill 资源解析、动态 MCP 搜索、检查和调用边界统一校验有效可用性;
  • 删除插件只删除分组定义,不卸载 Skill,也不删除 MCP 注册;
  • 同类型成员只能归属一个插件,避免重复所有权。

4. Windows 能力管理面板

新增“能力”页面:

  • 创建、编辑、启用、停用和删除插件;
  • 手动开关单个 Skill、MCP 服务及整个插件;
  • 插件成员在插件卡片内分组展示;
  • 顶层独立 Skill/MCP 列表自动排除已归属插件的成员;
  • 增加对应 Runtime API、数据模型、中英文资源和静态 UI 门禁。

兼容性

  • 缺少插件注册表时按空注册表处理,现有安装继续保持原有扁平行为;
  • 不修改 Skill 包格式、版本选择、环境变量存储、MCP transport 或凭据配置;
  • 插件总开关是独立覆盖层,不会破坏原 Skill/MCP 状态;
  • 本地 agentdock_context 只增加可选字段,现有空参数调用继续有效;
  • 共享 Nexus 协议未新增必需字段。

测试

已执行并通过:

  • go test ./...
  • 变更相关包 go test -count=1
  • ./scripts/test/check-scripts.sh(WSL POSIX 环境)
  • go test ./scripts/test -run TestScriptGovernance -count=1
  • go vet ./...
  • 生产 agentdock 二进制构建
  • Windows 控制面板 .NET 8 Release 构建:0 警告、0 错误

新增测试覆盖插件注册表迁移兼容、成员所有权冲突、开关持久化、顶层去重、plugin_load 延迟展开、MCP 工具发现失败降级、Runtime API、AGENTS.md 路径边界与 Windows 控制面板结构。

Make operator and project guidance available through MCP initialization and
agentdock_context without requiring separate file reads, ACP, or Recall.

Discover the explicit global instructions file or the default AGENTS.md,
then load workspace guidance from the applicable root to the selected
directory. Return ordered content with provenance, hashes, and explicit
load/skip/error states. Read fresh files on each context request.

Add an optional request-local workdir selector without changing command
working directories or sharing workspace selection across clients. Keep
empty-argument calls compatible and preserve the private Nexus context
shape through the existing rules field.

Bound discovery and content sizes, validate UTF-8, reject automatically
discovered symlinks and non-regular files, and deduplicate physical files.
Preserve explicit instructions-file behavior and provide an autoload
opt-out through AGENTDOCK_AGENTS_AUTOLOAD.

Cover discovery, refresh, scope boundaries, Windows path casing, file
validation, concurrent workspace isolation, schema compatibility, and MCP
initialization/live-context delivery with regression tests. Document the
loading contract, configuration, and startup-snapshot limitations.
- 用逻辑插件封装同领域 Skill 与动态 MCP,保留现有注册表兼容性
- 在 agentdock_context 中仅公开插件摘要,并由 plugin_load 延迟展开成员与 MCP 工具
- 为插件、Skill 和 MCP 增加独立开关及有效可用性校验
- 在 Windows 控制面板增加能力管理页、分组展示和中英文界面
- 补充 Runtime API、持久化、协议契约、集成测试与使用文档
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant