Skip to content

Knowledge Packages ​

A knowledge package is the Agent-facing output of a Context knowledge workspace: a folder under dist/ that turns approved knowledge into something another Agent can install and query. It carries the approved pages in reader-facing form, a query Skill that knows how to search them, and an inventory that maps every file back to its approved source. The same build can also produce a documentation website and LLM Docs.

This subsection, Outputs and Sites, covers everything that happens after pages are approved: the package (this page), Documentation Sites, LLM Docs, Customizing Pages and Themes, Multilingual Sites and Custom Output Templates.

mermaid
flowchart LR
  approved["Approved knowledge"] --> build["Build"]
  tpl["Package template"] --> build
  build --> kb["Knowledge package<br/>dist/name/"]
  build --> site["Website (optional)"]
  kb --> agent["Installed in<br/>other Agents"]

Choosing outputs ​

You pick outputs in the work-start report, as one multi-select list; later steps reuse your choice:

  • [x] Agent knowledge package — the default for a new knowledge workspace.
  • [x] Documentation website — the default together with the package, for local preview or later hosting.
  • [ ] LLM text — optional input for model context or retrieval; see LLM Docs.

You can also stop at approved Markdown, and no build runs. Selecting an output is all the permission it needs.

To change your choice later, just tell the Agent, for example:

Add a documentation website to this knowledge package, and leave out everything under internal/.

Some content belongs in the package but not on the website — detailed material only Agents need, or a collection you keep as written for one team. Ask for it:

Put the API field tables in the package only, and link them from the API overview page.

The Agent places those articles under a hidden group in the knowledge map: they stay in the package's navigation and in LLM Docs, count as placed, and are out of the website menus. Linked from an entry article, they remain reachable on the site; to leave them off the website entirely, the Agent also excludes their paths from the website package.

The Agent updates the workspace's package declaration for you; you never need to write it by hand. If you want to see the options it sets, such as which pages a package selects, how directory indexes fold and how images are shipped, they are listed in Project API and Package Templates.

What is inside ​

text
dist/<package-name>/
├── AGENTS.md
├── skills/
│   └── context-knowledge-query/
│       ├── SKILL.md
│       └── scripts/search.mjs
├── others/context/search-guide.md   # package-specific search hints
├── wikis/
│   ├── index.md          # package entry page
│   ├── codeindex/ ...
│   ├── business/ ...
│   └── product/ ...
├── guides/ ...           # architecture, sop, faq, decision, incident
├── rules/ ...            # standards, test
├── feats/ ...
├── others/assets/ ...    # bundled images and resources
└── context-build-inventory.json

The package name already names the folder, so roots inside are flat: wikis/, guides/, rules/, feats/. Each page lands under the root for its collection — sop pages under guides/sop/, codeindex pages under wikis/codeindex/ — as listed in Knowledge Collections. wikis/ is the structured entity-and-relationship layer; guides/ and rules/ explain, operationalize or constrain it.

Pages in the package are written for consumers: they keep their reader-facing front matter, drop internal markers, and end with a readable Sources section generated from the page's citations — repository links with file and line ranges, document links with their captured attribution. Exact section-level evidence stays in the knowledge workspace.

How Agents read it ​

The bundled context-knowledge-query Skill is a complete, generic query entry, identical in every Context package, so one installed copy serves every package the Agent can find: the surrounding package, a --root or --base folder, directories in CONTEXT_KNOWLEDGE_PACKAGES, or packages recorded by the host's package manager. It lists the available packages, reads each candidate package's others/context/search-guide.md first, and then works structure first:

  1. Start from the generated directory indexes in each root.
  2. Use the relationships recorded in the inventory for connections between pages.
  3. Read the most likely pages and cite their visible headings and passages.
  4. Report a gap when the package does not cover the fact asked for.

When the indexes do not narrow the scope, or a page is too large to read directly, a bundled search script ranks Markdown chunks by relevance. Search results are leads; page bodies and recorded relationships establish what the package says. When a page's text does not settle a question, the Skill follows the page's Sources entries: repository links at their recorded commit through the host's authorized tools, document links at the current document. Entries without links stay out of reach, and an Agent must not claim to have read a source it did not open.

Building and assets ​

The build uses only approved knowledge. A newly generated package template must be accepted or edited before the first build; see Custom Output Templates.

Images and resources referenced by approved pages are bundled into others/assets/ by default. Each packaged image is kept at or below 1 MiB and all images together at or below 40 MiB; oversized images are compressed into new WebP files inside dist/ only, never touching your sources or approved knowledge. Source audit files and capture reports are never shipped as reader assets.

What the build checks ​

  • Template honesty. Template prose that describes coverage, scope or known gaps must be backed by approved knowledge or the package's own structure data.
  • Index links. Every generated directory index is checked so relative links resolve inside the package.
  • Path collisions. A template file may not land on the same path as a selected page.
  • Relationship coverage. The inventory records whether code index pages carry current relationship data, so an empty list of dependencies means "none found", not "not checked".

When a check fails, the Agent fixes the template, the approved knowledge or the package declaration and rebuilds; it never patches dist/ as the fix. The exact rules live in Custom Output Templates.

Using the package ​

A package can be used where it was built or copied to any directory your Agent host can read. To point Claude Code, Codex or Cursor at a package and query it, see Using a Package in Your Agent.

知识包 ​

知识包是 Context 知识工作区面向 Agent 的产出:dist/ 下的一个文件夹,把已批准的知识变成其他 Agent 可以安装和查询的内容。它包含面向读者的已批准页面、一个懂得如何搜索这些页面的查询 Skill,以及一份把每个文件映射回其已批准来源的清单。同一次构建还可以生成文档站和 LLM Docs。

“产出与站点”这一小节涵盖页面批准之后的所有环节:知识包(本页)、文档站、LLM Docs、页面与主题定制、多语言站点 和 定制输出模板。

mermaid
flowchart LR
  approved["已批准的知识"] --> build["构建"]
  tpl["知识包模板"] --> build
  build --> kb["知识包<br/>dist/name/"]
  build --> site["网站(可选)"]
  kb --> agent["安装到<br/>其他 Agent"]

选择产出 ​

你在 开工报告 中通过一个多选列表选择产出,后续步骤沿用你的选择:

  • [x] Agent 知识包:新知识工作区的默认选项。
  • [x] 文档网站:默认与知识包一起生成,用于本地预览或之后托管。
  • [ ] LLM 文本:可选,作为模型上下文或检索的输入;参见 LLM Docs。

你也可以只停留在已批准的 Markdown,此时不会运行任何构建。选中某个产出即是对它的全部授权。

之后想改变选择,直接告诉 Agent 即可,例如:

为这个知识包加上文档网站,并排除 internal/ 下的所有内容。

有些内容属于知识包,但不属于网站——只有 Agent 需要的详细材料,或为某个团队原样纳入的一组页面。直接提出即可:

把 API 字段表只放进知识包,并从 API 概览页链接过去。

Agent 会把这些文章放到知识地图中的隐藏分组下:它们留在知识包的导航和 LLM Docs 中,算作已放置,但不出现在网站菜单里。从入口文章链接后,它们在站点上仍可访问;若要让它们完全不出现在网站上,Agent 还会把它们的路径从网站包中排除。

Agent 会替你更新知识工作区的知识包声明,你无需手写。如果想了解它设置的选项,例如知识包选择哪些页面、目录索引如何折叠、图片如何交付,可参阅 Project API 和 包模板。

包里有什么 ​

text
dist/<package-name>/
├── AGENTS.md
├── skills/
│   └── context-knowledge-query/
│       ├── SKILL.md
│       └── scripts/search.mjs
├── others/context/search-guide.md   # 知识包专属的检索提示
├── wikis/
│   ├── index.md          # 知识包入口页
│   ├── codeindex/ ...
│   ├── business/ ...
│   └── product/ ...
├── guides/ ...           # 架构、操作流程、常见问题、决策、故障记录
├── rules/ ...            # 规范、测试
├── feats/ ...
├── others/assets/ ...    # 随包提供的图片和资源
└── context-build-inventory.json

知识包名称已经是文件夹名,所以内部的根目录是扁平的:wikis/、guides/、rules/、feats/。每个页面都放在其所属集合对应的根目录下,例如 sop 页面放在 guides/sop/,codeindex 页面放在 wikis/codeindex/,具体对应关系见 知识分类。wikis/ 是结构化的实体与关系层;guides/ 和 rules/ 则对其进行解释、落地为操作或加以约束。

知识包中的页面是写给使用者的:它们保留面向读者的 frontmatter,去掉内部标记,并在末尾附上一个根据页面引用生成的可读来源章节:仓库链接带有文件和行范围,文档链接带有采集时记录的来源归属。精确到章节的证据仍保留在知识工作区中。

Agent 如何读取知识包 ​

随包提供的 context-knowledge-query Skill 是一个完整、通用的查询入口,在每个 Context 知识包中都相同,因此安装一份即可服务 Agent 能找到的所有知识包:所在的知识包、通过 --root 或 --base 指定的文件夹、CONTEXT_KNOWLEDGE_PACKAGES 中列出的目录,或宿主包管理器记录的知识包。它会先列出可用的知识包,读取每个候选知识包的 others/context/search-guide.md,然后以结构优先的方式工作:

  1. 从每个根目录中生成的目录索引开始。
  2. 借助清单中记录的关系了解页面之间的关联。
  3. 阅读最可能相关的页面,并引用其中可见的标题和段落。
  4. 当知识包没有覆盖所问的事实时,报告这一缺口。

当索引无法缩小范围,或某个页面太大而无法直接阅读时,随包提供的搜索脚本会按相关度对 Markdown 片段排序。搜索结果只是线索;知识包说了什么,要以页面正文和记录的关系为准。当页面正文不足以回答问题时,Skill 会沿该页面的 Sources 条目继续查找:仓库链接通过宿主授权的工具按记录的提交读取,文档链接打开当前文档。没有链接的条目无法从知识包访问,Agent 不得声称读过自己没有打开的来源。

构建与资源 ​

构建只使用已批准的知识。新生成的知识包模板必须先被接受或修改,才能进行首次构建;参见 定制输出模板。

已批准页面引用的图片和资源默认打包到 others/assets/。每张打包的图片不超过 1 MiB,所有图片合计不超过 40 MiB;过大的图片只会在 dist/ 中被压缩为新的 WebP 文件,绝不会改动你的来源或已批准的知识。来源审计文件和采集报告永远不会作为读者资源交付。

构建会检查什么 ​

  • 模板如实。 描述覆盖范围、范围边界或已知缺口的模板文字,必须有已批准的知识或知识包自身的结构数据作为依据。
  • 索引链接。 每个生成的目录索引都会被检查,确保相对链接能在知识包内解析。
  • 路径冲突。 模板文件不能与选中的页面落在同一路径上。
  • 关系覆盖。 清单会记录代码索引页面是否带有当前的关系数据,因此空的依赖列表表示“未发现”,而不是“未检查”。

检查失败时,Agent 会修复模板、已批准的知识或知识包声明,然后重新构建;它不会把修补 dist/ 当作修复。具体规则见 定制输出模板。

使用知识包 ​

知识包可以在构建所在的位置使用,也可以复制到 Agent 宿主能读取的任意目录。要让 Claude Code、Codex 或 Cursor 指向某个知识包并查询它,参见 在 Agent 中使用知识包。