Skip to content

Using Packages in Agents ​

context build turns approved knowledge into a knowledge package under dist/<name>/: a plain folder of Markdown that any Agent can read, with a bundled Skill that teaches it how. The package is what you hand to Agents that should use the knowledge without the Context knowledge workspace that produced it.

What is inside ​

text
dist/<package>/
├── AGENTS.md                       # how to use this package
├── skills/knowledge-query/         # bundled query Skill and search script
├── wikis/index.md                  # entities and relationships
├── guides/                         # architecture, procedures, FAQs, decisions
├── rules/                          # standards, constraints, test scenarios
├── context-build-inventory.json    # package coverage
├── context-site-map.json           # page → website URL
└── others/assets/                  # images and files the pages use

Approved collections map to roots: codeindex, business and product go to wikis/; architecture, sop, faq, decision and incident go to guides/; standards and test go to rules/. A root that was not selected is simply absent.

How the query Skill reads it ​

The bundled knowledge-query Skill makes the Agent navigate before it searches:

  1. Classify the request: lookup, explanation, procedure, rule, relationship, detail or coverage.
  2. Open the matching root index and follow links to a likely page.
  3. Read only the needed sections; titles and descriptions select scope but do not support claims.
  4. Answer from visible section content and cite the page and heading.
  5. When the package lacks evidence, report the gap and what was checked.

When indexes do not narrow the scope, it searches: rg for an exact name or error string, and for several terms or non-English phrases the bundled BM25 script:

bash
node <knowledge-query Skill directory>/scripts/search.mjs --query '<terms>' --limit 8

Hits are leads; the Agent opens the page before answering.

Making it available ​

A package can be used where it was built, from a global installation, or from any directory your Agent host can read. Point the Agent at the folder, or install skills/knowledge-query into the host's skills directory; if the Skill ends up outside the package tree, the search script takes --root <package directory>, or --base <package collection> to find the package by its inventory name.

Before publishing a package, replace or edit the generic query Skill template with your project's terminology, common intents and preferred entry pages — or explicitly accept the default during package-template review.

Going back to the sources ​

Package pages carry exported source attributions. When the package is not enough, /c4a:context-inspect-search can trace those attributions to the original documents and code at their recorded versions. See Asking Questions and Reading Code Evidence Remotely.

在 Agent 中使用知识包 ​

context build 会把已批准的知识转换为 dist/<name>/ 下的知识包:一个由 Markdown 组成的普通文件夹,任何 Agent 都能读取,并附带一个教 Agent 如何读取的内置 Skill。如果某些 Agent 只需要使用这些知识,而不需要生产它的 Context 知识工作区,你交给它们的就是这个知识包。

包里有什么 ​

text
dist/<package>/
├── AGENTS.md                       # how to use this package
├── skills/knowledge-query/         # bundled query Skill and search script
├── wikis/index.md                  # entities and relationships
├── guides/                         # architecture, procedures, FAQs, decisions
├── rules/                          # standards, constraints, test scenarios
├── context-build-inventory.json    # package coverage
├── context-site-map.json           # page → website URL
└── others/assets/                  # images and files the pages use

已批准的集合会映射到不同的根目录:codeindex、business 和 product 放入 wikis/;architecture、sop、faq、decision 和 incident 放入 guides/;standards 和 test 放入 rules/。未选中的根目录不会出现。

查询 Skill 如何读取知识包 ​

内置的 knowledge-query Skill 要求 Agent 先浏览再搜索:

  1. 对请求分类:查找、解释、操作流程、规则、关系、细节或覆盖范围。
  2. 打开对应的根索引,沿链接找到可能的页面。
  3. 只阅读需要的章节;标题和描述用于选定范围,但不能作为结论的依据。
  4. 根据可见的章节内容作答,并引用页面和标题。
  5. 当知识包缺少证据时,报告这一缺口以及已经检查过的内容。

当索引无法缩小范围时,它才会搜索:精确的名称或错误字符串用 rg;多个词或非英文短语则使用内置的 BM25 脚本:

bash
node <knowledge-query Skill directory>/scripts/search.mjs --query '<terms>' --limit 8

命中结果只是线索;Agent 会先打开页面再作答。

让知识包可用 ​

知识包可以在构建位置使用,也可以通过全局安装使用,或放在 Agent 宿主能读取的任意目录中。你可以让 Agent 指向该文件夹,或者把 skills/knowledge-query 安装到宿主的技能目录;如果 Skill 最终位于知识包目录树之外,搜索脚本可以通过 --root <package directory> 指定知识包目录,或通过 --base <package collection> 按清单名称查找知识包。

发布知识包之前,请用项目的术语、常见意图和首选入口页面替换或修改通用的查询 Skill 模板,或者在知识包模板审核时明确接受默认模板。

回到来源 ​

知识包页面带有导出的来源归属信息。当知识包不够用时,/c4a:context-inspect-search 可以依据这些归属信息,追溯到记录版本下的原始文档和代码。请参阅提问和远程读取代码证据。