attention-manifest-protocol 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +13 -12
  2. package/CHANGELOG.zh-CN.md +13 -12
  3. package/README.md +18 -16
  4. package/README.zh-CN.md +22 -18
  5. package/lib/context/workspaceService.d.ts +9 -0
  6. package/lib/context/workspaceService.js +9 -0
  7. package/lib/discover/kinds.d.ts +1 -1
  8. package/lib/discover/kinds.js +1 -1
  9. package/lib/discover/tree.js +143 -85
  10. package/lib/discover/types.d.ts +14 -1
  11. package/lib/file/path.js +15 -45
  12. package/lib/file/service.d.ts +1 -8
  13. package/lib/file/service.js +23 -122
  14. package/lib/global/service.d.ts +6 -0
  15. package/lib/global/service.js +3 -0
  16. package/lib/index.d.ts +4 -0
  17. package/lib/index.js +3 -0
  18. package/lib/knowledge/index.d.ts +2 -0
  19. package/lib/knowledge/index.js +1 -0
  20. package/lib/knowledge/registry.d.ts +19 -0
  21. package/lib/knowledge/registry.js +39 -0
  22. package/lib/module/mcp/filesystemServer.d.ts +0 -1
  23. package/lib/module/mcp/filesystemServer.js +1 -14
  24. package/lib/module/tool/filesystemExecutor.d.ts +1 -1
  25. package/lib/module/tool/filesystemExecutor.js +1 -1
  26. package/lib/naming/aliases.js +0 -10
  27. package/lib/naming/ids.d.ts +10 -10
  28. package/lib/naming/ids.js +10 -10
  29. package/lib/protocol/filesystem.js +12 -12
  30. package/lib/protocol/index.d.ts +1 -0
  31. package/lib/protocol/index.js +1 -0
  32. package/lib/protocol/registry.d.ts +20 -0
  33. package/lib/protocol/registry.js +46 -0
  34. package/lib/protocol/workspace.js +1 -1
  35. package/lib/registry/index.d.ts +2 -0
  36. package/lib/registry/index.js +1 -0
  37. package/lib/registry/memory.d.ts +17 -0
  38. package/lib/registry/memory.js +33 -0
  39. package/lib/skill/index.d.ts +2 -0
  40. package/lib/skill/index.js +1 -0
  41. package/lib/skill/registry.d.ts +20 -0
  42. package/lib/skill/registry.js +37 -0
  43. package/package.json +72 -72
package/CHANGELOG.md CHANGED
@@ -5,21 +5,22 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this
6
6
  project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased]
9
-
10
- ## [0.4.5] - 2026-10-31
8
+ ## [0.4.6] - 2026-11-02
11
9
 
12
- ### Fixed
10
+ ### Added
13
11
 
14
- - Bound discovery tree construction and subtree lookahead under small output limits, deep or cyclic input, and exhausted traversal budgets; extensionless file filters now work consistently.
15
- - Enforced filesystem session read/write/create permissions across MCP tools, sanitized classified failures, and kept stdio sessions alive after malformed or escaping requests.
16
- - Checked excluded paths against case-folded Windows paths and resolved symlink targets; preserved selected-root routing for multi-root outlines and dependency graphs.
17
- - Applied session and service read/tree/graph budgets consistently and report truncation instead of returning incomplete results as complete.
12
+ - Host-owned `SkillRegistry`, `KnowledgeRegistry` and `ProtocolRegistry` with validated registration, duplicate rejection, defensive copies and deterministic listing.
13
+ - Metadata-only `skills`, `knowledge` and `protocols` discovery scopes, with registry injection through workspace and global agent services. Disabled skills and protocols are excluded from discovery.
18
14
 
19
15
  ### Changed
20
16
 
21
- - Standardized TypeScript tool filenames on lowerCamelCase and updated repository documentation and references.
22
- - Advanced the npm package version to 0.4.5.
17
+ - Share in-memory registry storage and query mechanics through `InMemoryRegistry` while keeping validation and list policies in each domain.
18
+
19
+ ### Fixed
20
+
21
+ - Reserve discovery node capacity for ancestors before visiting descendants so tight limits preserve tree structure and accurate summary counts.
22
+
23
+ ## [Unreleased]
23
24
 
24
25
  ### Added
25
26
 
@@ -33,8 +34,8 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
33
34
  - Agent workspace: a `File`/`Directory` tree, paged reads, CAS atomic writes, strategy-based outlines, import/export/dependency graphs and Office parsing (DOCX/XLSX/PPTX, with best-effort DOC/XLS/PPT/PUB/ACCDB).
34
35
  - Session module: `ses_` identity, one-time bearer token, TTL, suspend/revoke/rotate, fork, per-session context isolation and quotas; SQLite adapters `SqliteWorkspaceSessionStore` / `SqliteWorkspaceSessionContextStore`.
35
36
  - `src/hook`: `useRead`, `useWrite`, `useDiff`, `useParse`, `useDependency`, `useExportation`, `useImportation`, `useOutline`, `useCode`, `useProject`. Every hook is read-only except `useWrite`, and runs are recorded in `hook_runs`.
36
- - `amp_tool_file_*` (ten tools), the `amp_tool_globalfs_*` global naming adapter, and `amp_service_filesystem` / `amp_protocol_filesystem`.
37
- - Lossless read-only syntax trees: `amp_tool_file_ast`, `useAst`, `src/syntax/syntaxTree.ts` and `src/syntax/syntaxRegistry.ts`; languages, token kinds and node kinds are registry data, every token keeps UTF-8 byte and line ranges, and the target file is never executed.
37
+ - `amp_tool_filesystem_*` (ten tools), the `amp_tool_globalfs_*` global naming adapter, and `amp_service_filesystem` / `amp_protocol_filesystem`.
38
+ - Lossless read-only syntax trees: `amp_tool_filesystem_ast`, `useAst`, `src/syntax/syntaxTree.ts` and `src/syntax/syntaxRegistry.ts`; languages, token kinds and node kinds are registry data, every token keeps UTF-8 byte and line ranges, and the target file is never executed.
38
39
  - SQLite tables: `workspace_sessions`, `session_roots`, `session_context`, `file_nodes`, `file_annotations`, `file_writes`, `file_outlines`, `file_imports`, `file_exports`, `file_dependencies`, `hook_runs`.
39
40
  - Data structures: `Trie`, `ByteLineIndex` (segment-tree prefix sums) and `OutlineIndex` (AST + Trie + SegmentTree).
40
41
  - Outline strategies cover code (TS/JS/Python/Java/C/C++/C#/Go/Rust), Vue, project manifests (npm/Maven/Gradle/CMake/Cargo/Go/pyproject/Make), prose (Markdown/TeX/plain text), HTML/CSS/SCSS/Sass/XML/OPML and Office; `outlineCoverageCheck` verifies 74 cases.
@@ -5,29 +5,30 @@
5
5
  格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循
6
6
  [语义化版本](https://semver.org/lang/zh-CN/)。
7
7
 
8
- ## [未发布]
9
-
10
- ## [0.4.5] - 2026-10-31
8
+ ## [0.4.6] - 2026-11-02
11
9
 
12
- ### 修复
10
+ ### 新增
13
11
 
14
- - 对小输出限额、深层或循环输入以及遍历预算耗尽场景限制 discovery 树构建和子树探测;无扩展名文件过滤现在保持一致。
15
- - 在 MCP 工具中落实 filesystem session 的读取、写入和创建权限,统一错误分类并隐藏主机路径;畸形或越界请求后 stdio 会话仍可继续处理。
16
- - 路径排除检查覆盖 Windows 大小写折叠及符号链接真实目标;多根 workspace 的大纲和依赖查询保持所选根目录。
17
- - 一致执行 session 与 service 的读取、目录树和依赖图预算;结果截断时明确标记,不再伪报完整。
12
+ - 宿主维护的 `SkillRegistry`、`KnowledgeRegistry` 与 `ProtocolRegistry`,支持登记校验、重复 ID 拒绝、防御性副本与稳定列表。
13
+ - 只返回元数据的 `skills`、`knowledge`、`protocols` 发现范围,并贯通 workspace/global agent 服务的注册中心注入;发现时排除禁用的 skill 与 protocol。
18
14
 
19
15
  ### 变更
20
16
 
21
- - TypeScript 工具文件名统一为小写开头的 camelCase,并更新仓库内路径引用和文档。
22
- - npm 包版本升至 0.4.5。
17
+ - 通过 `InMemoryRegistry` 复用内存存储与查询机制,各领域保留独立校验和列表策略。
18
+
19
+ ### 修复
20
+
21
+ - 发现树先为祖先预留节点容量,紧凑预算下仍保留树结构并准确统计节点。
22
+
23
+ ## [未发布]
23
24
 
24
25
  ### 新增
25
26
 
26
27
  - Agent 工作区:`File`/`Directory` 树、分页读、CAS 原子写、策略化大纲、import/export/dependency 图与 Office(DOCX/XLSX/PPTX,DOC/XLS/PPT/PUB/ACCDB best-effort)解析。
27
28
  - Session 模块:`ses_` 身份、一次性 bearer 令牌、TTL、暂停/撤销/rotate、fork、每会话上下文隔离与配额;SQLite 适配器 `SqliteWorkspaceSessionStore` / `SqliteWorkspaceSessionContextStore`。
28
29
  - `src/hook` 组合层:`useRead`、`useWrite`、`useDiff`、`useParse`、`useDependency`、`useExportation`、`useImportation`、`useOutline`、`useCode`、`useProject`;除 `useWrite` 外只读,并记录 `hook_runs`。
29
- - `amp_tool_file_*` 十个工具与 `amp_tool_globalfs_*` 全局命名适配器;`amp_service_filesystem` / `amp_protocol_filesystem`。
30
- - 无损只读语法树:`amp_tool_file_ast`、`useAst`、`src/syntax/syntaxTree.ts` 与 `src/syntax/syntaxRegistry.ts`;语言/Token/节点类别由注册中心管理,全部 token 保留 UTF-8 字节与行范围,不执行目标文件。`syntaxTreeCheck` 8 例,完整 verify 135/135。
30
+ - `amp_tool_filesystem_*` 十个工具与 `amp_tool_globalfs_*` 全局命名适配器;`amp_service_filesystem` / `amp_protocol_filesystem`。
31
+ - 无损只读语法树:`amp_tool_filesystem_ast`、`useAst`、`src/syntax/syntaxTree.ts` 与 `src/syntax/syntaxRegistry.ts`;语言/Token/节点类别由注册中心管理,全部 token 保留 UTF-8 字节与行范围,不执行目标文件。`syntaxTreeCheck` 8 例,完整 verify 135/135。
31
32
  - SQLite 表:`workspace_sessions`、`session_roots`、`session_context`、`file_nodes`、`file_annotations`、`file_writes`、`file_outlines`、`file_imports`、`file_exports`、`file_dependencies`、`hook_runs`。
32
33
  - 数据结构:`Trie`、`ByteLineIndex`(SegmentTree 前缀和)、`OutlineIndex`(AST + Trie + SegmentTree)。
33
34
  - 大纲策略覆盖代码(TS/JS/Python/Java/C/C++/C#/Go/Rust)、Vue、项目清单(npm/Maven/Gradle/CMake/Cargo/Go/pyproject/Make)、文章(Markdown/TeX/plain text)、HTML/CSS/SCSS/Sass/XML/OPML 与 Office;`outlineCoverageCheck` 74 例逐项验证。
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **English** · [简体中文](README.zh-CN.md) · [Changelog](CHANGELOG.md)
4
4
 
5
- AMP is a metacognitive protocol for agents: declare knowledge and obligations, allocate finite attention, obtain evidence, and record costs and outcomes. The reference implementation is version `0.4.5`, requires **Node.js 24 or later**, and uses Apache-2.0.
5
+ AMP is a metacognitive protocol for agents: declare knowledge and obligations, allocate finite attention, obtain evidence, and record costs and outcomes. The reference implementation is version `0.4.2`, requires **Node.js 24 or later**, and uses Apache-2.0.
6
6
 
7
7
  ## Architecture
8
8
 
@@ -53,7 +53,9 @@ Offline parsers live in `tools/support/`. The runtime stays database-free and us
53
53
 
54
54
  ### Discovery
55
55
 
56
- `amp_tool_workspace_discover` returns one structural tree over the authorized projects. File nodes carry a module kind (`service`, `tool`, `controller`, `route`, `repository`, `model`, `config`, `test`, `middleware`, `component`, `util`), an extension and bounded content matches. Hosts register project descriptions, purposes, summaries, plugins, services and tools through `HostCatalog`; project metadata is attached to project nodes, and an unregistered project falls back to its workspace summary. Discovery is read-only, never widens `projectIds`, and returns snippets as discovery evidence rather than as a Frame-allocated detail read.
56
+ `amp_tool_workspace_discover` returns one structural tree over authorized projects, host components, skills, knowledge and protocols. File nodes carry a module kind (`service`, `tool`, `controller`, `route`, `repository`, `model`, `config`, `test`, `middleware`, `component`, `util`), an extension and bounded content matches. Hosts register projects and components through `HostCatalog`, reusable instructions through `SkillRegistry`, source-aware entries through `KnowledgeRegistry`, and protocol metadata through `ProtocolRegistry`. Discovery exposes skill/knowledge/protocol metadata only; full entries are fetched from their registries by ID. Discovery is read-only, never widens `projectIds`, and returns snippets as discovery evidence rather than as a Frame-allocated detail read.
57
+
58
+ These registries are domain-owned catalogs, not a mandate to duplicate every concept as a generic registry. Existing runtime state and policies for ability, cognition, progress and behavior should stay in their domain models; add a read-only catalog/discovery projection only when enumeration is needed. Agents should not write directly to active registries by default. A future contribution flow should create a sourced, versioned proposal and require host authorization, review and audit before activation.
57
59
 
58
60
  ## Quick start
59
61
 
@@ -85,7 +87,7 @@ import { ToolIds, parseId } from "attention-manifest-protocol/naming";
85
87
 
86
88
  `npm run build:lib` rebuilds `lib/` and `prepublishOnly` runs it before publishing. The build compiles only the library; the Vite demo entry (`src/main.ts`) is not part of it.
87
89
 
88
- Focused checks can be run directly with the corresponding camelCase tools, such as `node tools/workspaceAgentCheck.ts`, `node tools/workspaceProjectCheck.ts`, `node tools/workspaceDiffCheck.ts`, `node tools/workspaceReactiveDiffCheck.ts`, `node tools/discoverCheck.ts` and `node tools/discoverAgentCheck.ts`. `verify` runs the full chain and both type checks. Evaluation inputs/reports remain in [docs/eval](docs/eval/) and [docs/probes](docs/probes/) as JSON; fixture and recorded-probe results are not independent human studies or production-quality evidence.
90
+ Focused checks: `npm run workspace-agent-check`, `workspace-project-check`, `workspace-diff-check`, `workspace-reactive-diff-check` and the `workspace-*-boundary-check` suites, `workspace-context-check`, `document-context-check`, `tex-context-check`, `governance-check`, `assignment-check`, `interaction-binding-check`, `discover-check`, `discover-agent-check`, `typecheck` and `typecheck:tools`. `verify` runs the full chain and both type checks. Evaluation inputs/reports remain in [docs/eval](docs/eval/) and [docs/probes](docs/probes/) as JSON; fixture and recorded-probe results are not independent human studies or production-quality evidence.
89
91
 
90
92
  ## Agent tools
91
93
 
@@ -116,20 +118,20 @@ The `amp_protocol_workspace` v1 response contains `protocol`, `version`, `revisi
116
118
 
117
119
  ### Filesystem tools
118
120
 
119
- `amp_tool_file_*` is bound to one authenticated Session; the bearer token never appears in a tool argument. Every tool except `write` is read-only.
121
+ `amp_tool_filesystem_*` is bound to one authenticated Session; the bearer token never appears in a tool argument. Every tool except `write` is read-only.
120
122
 
121
123
  | Tool | Purpose |
122
124
  | --- | --- |
123
- | `amp_tool_file_session` | Current identity, roots, permissions, remaining TTL and quotas |
124
- | `amp_tool_file_file` | One File/Directory node; `depth`/`offset`/`limit` bound the subtree |
125
- | `amp_tool_file_directory` | Flat listing of direct children |
126
- | `amp_tool_file_read` | 1-based line page with fingerprint, charset and the next line |
127
- | `amp_tool_file_write` | Atomic write; create/overwrite/upsert/append, CAS, dry-run |
128
- | `amp_tool_file_outline` | Structural outline with `query`/`startLine`/`endLine` filters |
129
- | `amp_tool_file_import` | Outgoing, incoming or two-way imports |
130
- | `amp_tool_file_export` | Exported symbols, signatures and re-export edges |
131
- | `amp_tool_file_dependency` | Cycles, topological order and bounded closures |
132
- | `amp_tool_file_ast` | Lossless syntax tree: every non-whitespace token, declaration/markup hierarchy, UTF-8/line ranges; read-only, never executes |
125
+ | `amp_tool_filesystem_session` | Current identity, roots, permissions, remaining TTL and quotas |
126
+ | `amp_tool_filesystem_file` | One File/Directory node; `depth`/`offset`/`limit` bound the subtree |
127
+ | `amp_tool_filesystem_directory` | Flat listing of direct children |
128
+ | `amp_tool_filesystem_read` | 1-based line page with fingerprint, charset and the next line |
129
+ | `amp_tool_filesystem_write` | Atomic write; create/overwrite/upsert/append, CAS, dry-run |
130
+ | `amp_tool_filesystem_outline` | Structural outline with `query`/`startLine`/`endLine` filters |
131
+ | `amp_tool_filesystem_import` | Outgoing, incoming or two-way imports |
132
+ | `amp_tool_filesystem_export` | Exported symbols, signatures and re-export edges |
133
+ | `amp_tool_filesystem_dependency` | Cycles, topological order and bounded closures |
134
+ | `amp_tool_filesystem_ast` | Lossless syntax tree: every non-whitespace token, declaration/markup hierarchy, UTF-8/line ranges; read-only, never executes |
133
135
 
134
136
  The global variant is `amp_tool_globalfs_*`, a naming adapter in [src/global/filesystem.ts](src/global/filesystem.ts) that grants no new root or permission. Outline nodes carry `isFile`/`isDirectory`/`file?`/`directory?`/`path` (for example `add.py#add`) and `range` (UTF-8 bytes plus 1-based lines as bigint; decimal strings on the wire). Strategies cover code, Vue, project manifests, Markdown/TeX/plain text, CSS/SCSS/Sass, HTML, XML/OPML and Office; Office parsing covers DOCX/XLSX/PPTX and treats DOC/XLS/PPT/PUB/ACCDB as best-effort CFB.
135
137
 
@@ -153,8 +155,8 @@ await diff.run({ path: "src/new.ts", before: "" });
153
155
  ### MCP stdio
154
156
 
155
157
  ```sh
156
- node tools/workspaceAgentDemo.ts
157
- node tools/workspaceAgentServer.ts --config .cache/workspace-agent.local
158
+ npm run workspace-agent-demo
159
+ npm run workspace-agent -- --config .cache/workspace-agent.local
158
160
  ```
159
161
 
160
162
  For an MCP client, start Node directly to keep package-manager banners out of stdout. Replace absolute paths with your checkout location:
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.md) · **简体中文** · [更新日志](CHANGELOG.zh-CN.md)
4
4
 
5
- AMP 是供 agent 使用的元认知协议:声明知识和义务,分配有限注意力,获取证据,记录成本与结果。当前参考实现为 `0.4.5`,要求 **Node.js 24 或以上**,使用 Apache-2.0 许可证。
5
+ AMP 是供 agent 使用的元认知协议:声明知识和义务,分配有限注意力,获取证据,记录成本与结果。当前参考实现为 `0.4.2`,要求 **Node.js 24 或以上**,使用 Apache-2.0 许可证。
6
6
 
7
7
  ## 架构
8
8
 
@@ -38,7 +38,7 @@ Context 使用结构树和类型化关系图。项目依赖、导入、调用与
38
38
  - MCP 执行、参数 Schema 校验、摘要固定与旧式握手回退,以及 A2A 发现与消息绑定。
39
39
  - 项目树、项目依赖图、TS/JS 的部分静态导入/调用/引用图,以及知识库词法检索。
40
40
  - Agent 工作区:`File`/`Directory` 树(指纹、字符集、bigint 行数/字节数、时间、描述/摘要/用途);分页读、CAS 原子写、按策略提取的大纲(代码/项目/文章/Office);import/export/dependency 图(Tarjan SCC、拓扑序、有界闭包);Session 身份与上下文隔离;`src/hook` 组合层;SQLite 实体与仓储。
41
- - 宿主发现:以一棵结构树返回获准项目、内部模块(service/tool/controller/route/repository/model/config/test/...)、文件名、有界内容匹配,以及宿主注册的插件、服务与工具。项目节点带描述、用途与简介。
41
+ - 宿主发现:以一棵结构树返回获准项目、内部模块(service/tool/controller/route/repository/model/config/test/...)、文件名、有界内容匹配,以及宿主注册的插件、服务、工具、skills 和 knowledge。项目节点带描述、用途与简介;skill/knowledge 节点只暴露元数据,详情由注册中心按 ID 查询。
42
42
  - Markdown、TXT、DOCX、XLSX、PPTX、TeX/LaTeX/BibTeX 的结构提取、原生定位与摘要/详情分层。
43
43
  - `amp_protocol_workspace` v1 服务、8 个 agent 工具、本地运行时接入与 MCP stdio 服务端。
44
44
  - 带显式策略的指纹:值使用 RFC 8785 规范化 JSON,文件按字节哈希,目录树使用域分隔的 Merkle 根,`verify` 比较算法、`kind` 与策略,而不是只比对裸十六进制字符串。未配对代理项与 `-0` 被拒绝,而不是被静默改写。
@@ -53,7 +53,9 @@ Context 使用结构树和类型化关系图。项目依赖、导入、调用与
53
53
 
54
54
  ### 发现
55
55
 
56
- `amp_tool_workspace_discover` 以一棵结构树返回获准项目。文件节点带模块分类(`service`、`tool`、`controller`、`route`、`repository`、`model`、`config`、`test`、`middleware`、`component`、`util`)、扩展名与有界内容匹配。宿主通过 `HostCatalog` 登记项目的描述、用途、简介,以及插件、服务和工具;项目元数据附在项目节点上,未登记的项目回退到 workspace 摘要。发现是只读的,不会扩大 `projectIds`;内容匹配只是发现证据,不能替代 Frame 分配后的详情读取。
56
+ `amp_tool_workspace_discover` 以一棵结构树返回获准项目、宿主组件、skill、knowledge 与 protocol。文件节点带模块分类(`service`、`tool`、`controller`、`route`、`repository`、`model`、`config`、`test`、`middleware`、`component`、`util`)、扩展名与有界内容匹配。宿主通过 `HostCatalog` 登记项目与插件/服务/工具,通过 `SkillRegistry`、`KnowledgeRegistry`、`ProtocolRegistry` 登记可复用指令、知识条目与协议元数据。发现只暴露 skill/knowledge/protocol 元数据,不返回指令或正文;注册中心按 ID 提供完整条目。发现是只读的,不会扩大 `projectIds`;内容匹配只是发现证据,不能替代 Frame 分配后的详情读取。
57
+
58
+ 这些 registry 是各自领域的宿主目录,不要求每个概念都复制成同构 registry。Ability、cognition、progress 等若已有运行时状态、策略或事件模型,应由现有领域模块维护;需要统一枚举时增加只读 catalog/discovery 投影即可。Agent 默认只读正式目录;可选的登记工作流应先创建带来源、版本和提案状态的候选项,再经宿主权限校验、人工审核与审计后发布,不授予模型直接改写已生效条目的能力。
57
59
 
58
60
  ## 快速开始
59
61
 
@@ -85,7 +87,7 @@ import { ToolIds, parseId } from "attention-manifest-protocol/naming";
85
87
 
86
88
  `npm run build:lib` 重新构建 `lib/`,发布前由 `prepublishOnly` 自动执行。该构建只编译库代码,Vite 演示入口(`src/main.ts`)不在其中。
87
89
 
88
- 专项检查可直接运行对应的 camelCase 工具,例如 `node tools/workspaceAgentCheck.ts`、`node tools/workspaceProjectCheck.ts`、`node tools/workspaceDiffCheck.ts`、`node tools/workspaceReactiveDiffCheck.ts`、`node tools/discoverCheck.ts` 与 `node tools/discoverAgentCheck.ts`。`verify` 执行完整验证链和两份类型检查。评测输入/结果以 JSON 保存在 [docs/eval](docs/eval/) 与 [docs/probes](docs/probes/),夹具与录制探针不等同于独立的人类研究或生产质量证明。
90
+ 专项检查为 `npm run workspace-agent-check`、`workspace-project-check`、`workspace-diff-check`、`workspace-reactive-diff-check` 与 `workspace-*-boundary-check` 系列、`workspace-context-check`、`document-context-check`、`tex-context-check`、`governance-check`、`assignment-check`、`interaction-binding-check`、`discover-check`、`discover-agent-check`、`typecheck` 与 `typecheck:tools`。`verify` 执行完整验证链和两份类型检查。评测输入/结果以 JSON 保存在 [docs/eval](docs/eval/) 与 [docs/probes](docs/probes/),夹具与录制探针不等同于独立的人类研究或生产质量证明。
89
91
 
90
92
  ## Agent 工具
91
93
 
@@ -116,20 +118,20 @@ import { ToolIds, parseId } from "attention-manifest-protocol/naming";
116
118
 
117
119
  ### 文件系统工具
118
120
 
119
- `amp_tool_file_*` 绑定一个已认证 Session;令牌不出现在工具参数里。除 `write` 外全部只读。
121
+ `amp_tool_filesystem_*` 绑定一个已认证 Session;令牌不出现在工具参数里。除 `write` 外全部只读。
120
122
 
121
123
  | 工具 | 用途 |
122
124
  | --- | --- |
123
- | `amp_tool_file_session` | 当前身份、根、权限、剩余 TTL 与配额 |
124
- | `amp_tool_file_file` | 返回一个 File/Directory 节点;`depth`/`offset`/`limit` 控制子树与分页 |
125
- | `amp_tool_file_directory` | 平铺列出一级子节点 |
126
- | `amp_tool_file_read` | 按 1-based 行号读取文本页;返回指纹、字符集与下一页行号 |
127
- | `amp_tool_file_write` | 原子写入;create/overwrite/upsert/append、CAS、dry-run |
128
- | `amp_tool_file_outline` | 结构化大纲;支持 `query`/`startLine`/`endLine` 过滤 |
129
- | `amp_tool_file_import` | 出边/入边/两向导入关系 |
130
- | `amp_tool_file_export` | 导出符号、签名与 re-export 边 |
131
- | `amp_tool_file_dependency` | 环、拓扑序、依赖/被依赖闭包 |
132
- | `amp_tool_file_ast` | 无损语法树:每个非空白 token、声明/块/标签层级、UTF-8 字节与行范围;只读,不执行 |
125
+ | `amp_tool_filesystem_session` | 当前身份、根、权限、剩余 TTL 与配额 |
126
+ | `amp_tool_filesystem_file` | 返回一个 File/Directory 节点;`depth`/`offset`/`limit` 控制子树与分页 |
127
+ | `amp_tool_filesystem_directory` | 平铺列出一级子节点 |
128
+ | `amp_tool_filesystem_read` | 按 1-based 行号读取文本页;返回指纹、字符集与下一页行号 |
129
+ | `amp_tool_filesystem_write` | 原子写入;create/overwrite/upsert/append、CAS、dry-run |
130
+ | `amp_tool_filesystem_outline` | 结构化大纲;支持 `query`/`startLine`/`endLine` 过滤 |
131
+ | `amp_tool_filesystem_import` | 出边/入边/两向导入关系 |
132
+ | `amp_tool_filesystem_export` | 导出符号、签名与 re-export 边 |
133
+ | `amp_tool_filesystem_dependency` | 环、拓扑序、依赖/被依赖闭包 |
134
+ | `amp_tool_filesystem_ast` | 无损语法树:每个非空白 token、声明/块/标签层级、UTF-8 字节与行范围;只读,不执行 |
133
135
 
134
136
  全局变体为 `amp_tool_globalfs_*`,由 [src/global/filesystem.ts](src/global/filesystem.ts) 做命名适配;它不扩大任何根或权限。
135
137
  大纲节点带 `isFile`/`isDirectory`/`file?`/`directory?`/`path`(如 `add.py#add`)与 `range`(UTF-8 字节 + 1-based 行,bigint;JSON 中为十进制字符串)。策略覆盖代码、Vue、项目清单、Markdown/TeX/纯文本、CSS/SCSS/Sass、HTML、XML/OPML 与 Office;Office 文件由 `office.ts` 解析 DOCX/XLSX/PPTX,DOC/XLS/PPT/PUB/ACCDB 为 CFB best-effort。
@@ -154,8 +156,8 @@ await diff.run({ path: "src/new.ts", before: "" });
154
156
  ### MCP stdio 接入
155
157
 
156
158
  ```sh
157
- node tools/workspaceAgentDemo.ts
158
- node tools/workspaceAgentServer.ts --config .cache/workspace-agent.local
159
+ npm run workspace-agent-demo
160
+ npm run workspace-agent -- --config .cache/workspace-agent.local
159
161
  ```
160
162
 
161
163
  真实 MCP 客户端应直接启动 Node,避免包管理器提示混入协议 stdout。将以下绝对路径替换为实际项目目录:
@@ -220,11 +222,13 @@ Frame、快照、ContentStore 与后备执行器由宿主提供;将 `tools` /
220
222
  | [src/naming](src/naming/) | 冻结的 ID 表、ID 文法、兼容别名与 catalog 摘要 |
221
223
  | [src/context](src/context/) | Context 生命周期、树/图投影、CAS、工作区事实、上下文装配与 agent 服务 |
222
224
  | [src/session](src/session/) | 身份、令牌、TTL、上下文隔离、fork/revoke/rotate |
225
+ | [src/skill](src/skill/) | 可复用 agent skill 注册、校验、查询与隔离副本 |
226
+ | [src/knowledge](src/knowledge/) | 带来源元数据的 knowledge 注册、校验、查询与隔离副本 |
227
+ | [src/protocol](src/protocol/) | 线上协议契约、通道,以及宿主维护的协议元数据注册中心 |
223
228
  | [src/file](src/file/) | File/Directory 树、元数据、分页读、原子写、会话运行时/服务、模块图与 ZIP/CFB 容器 |
224
229
  | [src/syntax](src/syntax/) | 字符集检测/编解码、字节/行索引、语法注册表与无损只读语法树 |
225
230
  | [src/outline](src/outline/) | 代码/文档大纲、范围与标签索引、关键字/策略注册表、React/Shell/SQL/Visual Basic 策略与 Office 解析 |
226
231
  | [src/hook](src/hook/) | 面向 agent 的组合 hooks 与运行记录 |
227
- | [src/protocol](src/protocol/) | 线上契约:信封、A2A、通道与 `amp_protocol_workspace` 接口 |
228
232
  | [src/module](src/module/) | 模型/工具端口、MCP 适配器与执行策略 |
229
233
  | [src/runtime](src/runtime/) | agent 回合、工具循环与治理接入 |
230
234
  | [src/governance](src/governance/) | 清单、凭据、预算、工作流、签名与审计 |
@@ -1,5 +1,8 @@
1
1
  import type { Frame } from "../frame/frame.js";
2
2
  import { HostCatalog } from "../discover/host.js";
3
+ import type { KnowledgeRegistry } from "../knowledge/registry.js";
4
+ import type { ProtocolRegistry } from "../protocol/registry.js";
5
+ import type { SkillRegistry } from "../skill/registry.js";
3
6
  import type { ToolCatalog } from "../naming/index.js";
4
7
  import type { WorkspaceErrorCode, WorkspaceProjectAction, WorkspaceResponse, WorkspaceToolDefinition } from "../protocol/workspace.js";
5
8
  import type { Receipt } from "../receipt/receipt.js";
@@ -116,6 +119,9 @@ export interface WorkspaceServiceOptions {
116
119
  * components are filtered against `projectIds` before discovery sees them.
117
120
  */
118
121
  host?: HostCatalog;
122
+ skills?: SkillRegistry;
123
+ knowledge?: KnowledgeRegistry;
124
+ protocols?: ProtocolRegistry;
119
125
  }
120
126
  export declare class WorkspaceAgentService {
121
127
  private readonly agentId;
@@ -127,6 +133,9 @@ export declare class WorkspaceAgentService {
127
133
  private readonly roots;
128
134
  private readonly definitions;
129
135
  private readonly host;
136
+ private readonly skills?;
137
+ private readonly knowledge?;
138
+ private readonly protocols?;
130
139
  private readonly projectIds;
131
140
  private readonly store;
132
141
  private readonly writer?;
@@ -468,6 +468,9 @@ export class WorkspaceAgentService {
468
468
  roots;
469
469
  definitions = workspaceToolDefinitions();
470
470
  host;
471
+ skills;
472
+ knowledge;
473
+ protocols;
471
474
  projectIds;
472
475
  store;
473
476
  writer;
@@ -493,6 +496,9 @@ export class WorkspaceAgentService {
493
496
  }
494
497
  this.agentId = options.agentId;
495
498
  this.host = options.host ?? new HostCatalog();
499
+ this.skills = options.skills;
500
+ this.knowledge = options.knowledge;
501
+ this.protocols = options.protocols;
496
502
  this.projectIds = new Set(options.projectIds);
497
503
  this.writer = options.writer;
498
504
  this.runner = options.runner;
@@ -824,6 +830,9 @@ export class WorkspaceAgentService {
824
830
  projects,
825
831
  components,
826
832
  builtIn: this.builtInComponents(),
833
+ ...(this.skills === (void 0) ? {} : { skills: this.skills }),
834
+ ...(this.knowledge === (void 0) ? {} : { knowledge: this.knowledge }),
835
+ ...(this.protocols === (void 0) ? {} : { protocols: this.protocols }),
827
836
  query,
828
837
  contentOf: (entity) => {
829
838
  if (entity.detailRef === (void 0)) {
@@ -8,7 +8,7 @@ export declare const ModuleKinds: readonly ["service", "tool", "controller", "ro
8
8
  export type ModuleKind = (typeof ModuleKinds)[number];
9
9
  export declare const ComponentKinds: readonly ["plugin", "service", "tool", "module"];
10
10
  export type ComponentKind = (typeof ComponentKinds)[number];
11
- export declare const DiscoveryScopes: readonly ["all", "projects", "host"];
11
+ export declare const DiscoveryScopes: readonly ["all", "projects", "host", "skills", "knowledge", "protocols"];
12
12
  export type DiscoveryScope = (typeof DiscoveryScopes)[number];
13
13
  export declare const ComponentStatuses: readonly ["active", "disabled", "deprecated"];
14
14
  export type ComponentStatus = (typeof ComponentStatuses)[number];
@@ -19,5 +19,5 @@ export const ModuleKinds = [
19
19
  "unknown",
20
20
  ];
21
21
  export const ComponentKinds = ["plugin", "service", "tool", "module"];
22
- export const DiscoveryScopes = ["all", "projects", "host"];
22
+ export const DiscoveryScopes = ["all", "projects", "host", "skills", "knowledge", "protocols"];
23
23
  export const ComponentStatuses = ["active", "disabled", "deprecated"];