Skip to content

Quick Start ​

This walkthrough turns one code module and one local documentation folder into a reviewed knowledge package with a browsable site. You give instructions in plain language; the Agent runs the commands the workflow returns. The commands shown below are what the Agent runs on your behalf, so you can recognize them in its progress messages.

Make sure Installation is done and you have restarted the Agent session so the plugin is loaded.

1. Create the knowledge workspace ​

Tell the Agent where the Context knowledge workspace should live and what it is for:

text
/c4a:context Create a Context knowledge workspace in ./context for our component library
and its product docs. Readers are frontend developers new to the library.

The Agent initializes the directory and installs its dependencies:

bash
context init ./context
cd ./context
bun install
context status --format json

You get this layout:

text
context/
├── AGENTS.md       # guidance for the Agent
├── src/            # source, phase and package declarations
├── sources/        # registered sources and captured evidence
├── knowledge/      # approved knowledge (empty for now)
├── dist/           # built packages (ignored by Git)
└── .tmp/           # runtime state and reports (ignored by Git)

2. Point it at your sources ​

Name the material and anything the Agent should skip:

text
Use ../component-lib for code and ../docs for product documents.
Skip the deprecated v1 folder.

The Agent registers each boundary. Registration records what is in scope; it does not decide what to write.

bash
context source add repo 20260901 --module component-lib --local ../component-lib --configure
context source add file 20260901 --module product-docs --local ../docs --configure

For a monorepo, pick the package or service your readers need. Unneeded material costs reading time and tokens, but do not exclude something just because its filename looks old.

3. Confirm the work-start report ​

The Agent reads representative material, asks about anything that would change the scope, records the reader purpose in src/indexers.yaml, and presents a work-start report with:

  • the confirmed sources and scope;
  • the Indexer skills it will use;
  • the first pages you should expect and where they will sit in the site.

Nothing is written until you approve the report. If the plan is off, say what to change — for example "merge the two API pages" or "add a troubleshooting page" — and the Agent revises it.

4. Let it write, then review ​

After approval, the Agent writes each page with references to exact source lines and submits them for checks on coverage and stale inputs.

When writing finishes, you receive a review report showing each page's title, path, summary and content. Approve it, reject pages, or ask for revisions. Approved pages land in knowledge/ as Markdown; rejected or revised pages go back to writing.

mermaid
flowchart LR
  write["Agent writes pages"] --> review["You review"]
  review -->|revise| write
  review -->|approve| kn["knowledge/"]
  kn --> build["context build"]
  build --> kb["dist/component-kb/"]
  build --> site["dist/component-site/"]

5. Build the package and site ​

For a new knowledge workspace, the Agent proposes a knowledge package plus a website by default. The package declaration in src/index.ts looks like this:

ts
kbPackage({
  name: "component-kb",
  template: "src/package-templates/kb",
  site: { title: "Component knowledge", lang: "en-US", base: "/" },
});

context build then produces dist/component-kb/ for Agents and dist/component-site/ — a static site with article pages and local search — for people. Commit the knowledge workspace to Git so the result can be inspected, versioned and refreshed later.

Next steps ​

  • Ask a question against the new package with /c4a:context-inspect-search.
  • When the code or docs change, tell /c4a:context what changed; it reopens only the affected pages.
  • For larger scopes, read Large Projects.
  • See every entry you can invoke, and the Skills that run on their own, in Commands and Skills.

快速开始 ​

本教程把一个代码模块和一个本地文档目录整理成经过审核的知识包,并附带可浏览的站点。你用自然语言下达指令,Agent 执行工作流返回的命令。下文列出的命令都是 Agent 代你执行的,方便你在它的进度消息中认出它们。

请先完成安装,并重启 Agent 会话以加载插件。

1. 创建知识工作区 ​

告诉 Agent Context 知识工作区放在哪里、用来做什么:

text
/c4a:context Create a Context knowledge workspace in ./context for our component library
and its product docs. Readers are frontend developers new to the library.

Agent 会初始化目录并安装依赖:

bash
context init ./context
cd ./context
bun install
context status --format json

得到的目录结构如下:

text
context/
├── AGENTS.md       # guidance for the Agent
├── src/            # source, phase and package declarations
├── sources/        # registered sources and captured evidence
├── knowledge/      # approved knowledge (empty for now)
├── dist/           # built packages (ignored by Git)
└── .tmp/           # runtime state and reports (ignored by Git)

2. 指定来源 ​

说明要用哪些材料,以及 Agent 应该跳过什么:

text
Use ../component-lib for code and ../docs for product documents.
Skip the deprecated v1 folder.

Agent 会逐一登记每个边界。登记只记录范围内有哪些内容,并不决定要写什么。

bash
context source add repo 20260901 --module component-lib --local ../component-lib --configure
context source add file 20260901 --module product-docs --local ../docs --configure

对于 monorepo,挑出读者真正需要的包或服务即可。无关材料会浪费阅读时间和 token,但也不要仅因为文件名看起来旧就把它排除。

3. 确认开工报告 ​

Agent 会阅读有代表性的材料,就可能改变范围的问题向你确认,把读者目标记录到 src/indexers.yaml,然后给出一份开工报告,包括:

  • 已确认的来源和范围;
  • 将使用的 Indexer 技能;
  • 预计产出的第一批页面,以及它们在站点中的位置。

在你批准报告之前,不会写入任何内容。如果计划不对,直接说要改什么——例如“合并两个 API 页面”或“增加一个故障排查页面”——Agent 会据此修订。

4. 让它写作,然后审核 ​

批准后,Agent 逐页写作,引用精确到来源行,并提交检查覆盖度和过期输入。

写作完成后,你会收到一份审核报告,列出每个页面的标题、路径、摘要和内容。你可以批准、拒绝部分页面,或要求修订。批准的页面以 Markdown 形式落入 knowledge/;被拒绝或要求修订的页面回到写作环节。

mermaid
flowchart LR
  write["Agent 写作页面"] --> review["你来审核"]
  review -->|"修订"| write
  review -->|"批准"| kn["knowledge/"]
  kn --> build["context build"]
  build --> kb["dist/component-kb/"]
  build --> site["dist/component-site/"]

5. 构建知识包和站点 ​

对于新的知识工作区,Agent 默认会建议构建一个知识包加一个网站。src/index.ts 中的知识包声明如下:

ts
kbPackage({
  name: "component-kb",
  template: "src/package-templates/kb",
  site: { title: "Component knowledge", lang: "en-US", base: "/" },
});

随后 context build 会产出供 Agent 使用的 dist/component-kb/,以及供人阅读的 dist/component-site/——一个包含文章页面和本地搜索的静态站点。把知识工作区提交到 Git,以便之后检查、做版本管理和刷新。

下一步 ​

  • 用 /c4a:context-inspect-search 基于新知识包提问。
  • 代码或文档变化时,告诉 /c4a:context 改了什么;它只会重新打开受影响的页面。
  • 范围更大时,请阅读复杂任务。
  • 所有可调用的入口,以及会自行运行的 Skill,见命令与技能。