Skip to content

Using a Package in Your Agent ​

A knowledge package is a plain folder of Markdown with a bundled query Skill, built from approved knowledge. It lets your Agent use the knowledge without the knowledge workspace that produced it — handy when you consume knowledge someone else maintains, or want answers in a project that has no workspace of its own.

This page is for people using a package. What a package contains and how it is built is in Knowledge Packages.

Giving your Agent a package ​

A package can be used where it was built, from a global installation, or from any folder your Agent host can read. There are two simple ways to make it available:

  • Point the Agent at the folder for the question at hand.
  • Install the package's query Skill into your host's Skills directory, so the Agent can reach the package in later tasks too.
text
Use the knowledge package in ./dist/billing-kb to answer questions in this
project. Install its query Skill for this host.

Every Context package ships the same context-knowledge-query Skill, so one installed copy serves all of them. It finds the packages it can reach: the package around it, a folder you name with --root or a collection with --base, directories listed in CONTEXT_KNOWLEDGE_PACKAGES, and packages recorded by your host's package manager when it supports them. After that, just ask your question — see Asking Questions. You do not need to move files around.

Before you share a package ​

If you build a package for others, tailor its search guide first: put your project's terminology, synonyms, common questions and preferred entry pages in others/context/search-guide.md, or explicitly accept the default when the package templates are reviewed. Leave the query Skill itself unchanged; Context keeps it identical across packages and replaces edited copies on build. See Custom Output Templates.

What your Agent does with it ​

The bundled query Skill makes the Agent navigate before it searches. It first lists the packages it can read and, unless you named one, picks those whose index and search guide match the question. It then works out what kind of question you asked — a lookup, an explanation, a procedure, a rule, a relationship, a detail or a coverage question — opens the matching index and follows links to the likely page. It reads only the sections it needs and cites the page and heading it answered from; titles and descriptions help it choose where to look but never support a claim on their own.

When the indexes do not narrow things down, it searches the packages for exact names, error strings or several terms at once. Search results are only leads: the Agent opens the page before answering. When the packages lack evidence, it says so and tells you what it checked.

Going back to the sources ​

Package pages keep their source citations. When a page's text does not settle a question, the query Skill follows its Sources entries itself: repository links at their recorded commit through the tools your host allows, document links at the current document. For code evidence read remotely, /c4a:context-inspect-search can follow those citations to the original documents and code at their recorded versions. See Asking Questions and Choose how Context reads code.

在 Agent 中使用知识包 ​

知识包是一个由 Markdown 组成的普通文件夹,附带一个查询 Skill,由已批准的知识构建而成。它让你的 Agent 无需生产它的知识工作区也能使用这些知识——当你使用别人维护的知识,或想在一个没有自己知识工作区的项目中获得回答时,这会很方便。

本页面向使用知识包的人。知识包包含什么以及如何构建,见 知识包。

把知识包交给你的 Agent ​

知识包可以在构建位置使用,也可以通过全局安装使用,或放在 Agent 宿主能读取的任意文件夹中。有两种简单的方式让它可用:

  • 让 Agent 指向该文件夹,用于当前的问题。
  • 把知识包的查询 Skill 安装到宿主的 Skills 目录,这样 Agent 在之后的任务中也能找到这个知识包。
text
使用 ./dist/billing-kb 中的知识包回答这个项目里的问题。
为当前宿主安装它的查询 Skill。

每个 Context 知识包都带有相同的 context-knowledge-query Skill,因此安装一份即可服务所有知识包。它会找到能访问的知识包:它所在的知识包、你用 --root 指定的文件夹或用 --base 指定的集合、CONTEXT_KNOWLEDGE_PACKAGES 中列出的目录,以及宿主包管理器(如果支持)记录的知识包。之后直接提问即可——参见 提问。你不需要移动文件。

分享知识包之前 ​

如果你为他人构建知识包,请先定制它的检索指南:把项目的术语、同义词、常见问题和首选入口页面写进 others/context/search-guide.md,或者在知识包模板审核时明确接受默认模板。查询 Skill 本身请保持不变;Context 会让它在各知识包中保持一致,并在构建时替换被修改的副本。参见 定制输出模板。

Agent 会如何使用它 ​

随包提供的查询 Skill 让 Agent 先浏览再搜索。它会先列出能读取的知识包,如果你没有指定,就挑选索引和检索指南与问题相符的那些。然后它会判断你提的是哪类问题——查找、解释、操作流程、规则、关系、细节还是覆盖范围——打开对应的索引,沿链接找到可能的页面。它只阅读需要的章节,并引用作答所依据的页面和标题;标题和描述帮助它决定去哪里找,但本身绝不能作为结论的依据。

当索引无法缩小范围时,它会在这些知识包中搜索精确的名称、错误字符串或同时搜索多个词。搜索结果只是线索:Agent 会先打开页面再作答。当这些知识包缺少证据时,它会如实说明,并告诉你它检查了哪些内容。

回到来源 ​

知识包页面保留了来源引用。当页面正文不足以回答问题时,查询 Skill 会自行沿其 Sources 条目查找:仓库链接通过宿主允许的工具按记录的提交读取,文档链接打开当前文档。需要远程读取代码证据时,/c4a:context-inspect-search 可以沿这些引用,追溯到记录版本下的原始文档和代码。请参阅 提问 和 选择 Context 读取代码的方式。