Document Directories
Use a document source when the material is local Markdown: one file, several files or a documentation folder. Unlike a code repository, a document source is captured: Context takes a reproducible snapshot, and pages cite that snapshot rather than the live folder.
flowchart LR
reg["Register<br/>folder and chapters"] --> cap["Capture<br/>a snapshot"]
cap --> write["Plan and write<br/>cite the snapshot"]Ask the Agent
Say which documents to ingest, not just which folder you happen to be in:
Ingest ../docs/user-guide as product documentation. Only the getting-started
and billing chapters.Run instructions, handbooks, plans or lists of tasks you hand the Agent are treated as guidance for the task, not as sources, unless you explicitly ask to ingest them. If it is unclear which documents to capture, the Agent asks once instead of capturing your instructions.
What the Agent confirms
Registering reads no content yet. The Agent records the folder or files you named and, when you limit the scope, only the chapters or patterns you asked for — in the example above, getting-started and billing. It then sets the source up for capture and tells you what was registered.
Two choices shape the snapshot, so make them before pages cite the source:
- Keep folders. By default a document source keeps only file names. Ask the Agent to keep the folder structure when it matters — for example
guides/andreference/both have asetup.md— and the snapshot keeps the folders together with the images and small data files the documents link to. - Structured files as documents. Markdown is read by default. If pages should cite small JSON or YAML files as text, name those extensions and they are captured as documents too. Images are kept as assets, not as citations.
Changing either choice later moves paths in the snapshot, so pages citing the source then need the same treatment as a renamed file.
If the knowledge workspace already has custom source settings, the Agent makes a focused change to include the new folder and tells you what it changed. For the full set of registration options, see the CLI Commands reference.
Capture
Capture reads the documents, so it needs your permission in the current conversation. Asking to capture, ingest or read the named documents grants it; merely mentioning them or asking only to register them does not, so in that case expect a question first. The Agent then captures the documents, reports the outcome and continues until every document in the request is done.
A linked image that is missing, lies outside the source, collides with another file or is larger than 5 MB does not stop the capture: the link stays as written and the Agent reports it as an asset gap, so you can fix the original or accept the gap.
Capture creates the snapshot; it does not classify, summarize or approve anything. Context keeps the snapshot intact, and the Agent never edits it by hand.
Documentation sites
Capture reads plain Markdown by default. If the folder turns out to be a documentation site — MDX pages, sidebars or a site configuration — the Agent tells you and asks before changing how it reads the folder. Route metadata and static component text are kept as evidence.
If a page is only a shell that loads its content at runtime, the Agent says so and asks for the rendered site or its data source instead of inventing the body.
When the documents change
Pages keep citing the snapshot they were written from. When the folder changes, ask for an update: the Agent captures the new version and asks which pages need changes. See Updating Knowledge.
If the documents are published by another team as versions — a documentation repository or a released knowledge package — or the folder is about to be archived, see Published and Archived Collections.
文档目录
资料是本地 Markdown 时,就用文档来源:一个文件、几个文件或整个文档文件夹都可以。和代码仓库不同,文档来源需要先采集:Context 会生成一份可复现的快照,页面引用的是这份快照,而不是随时在变的文件夹。
flowchart LR
reg["登记<br/>文件夹和章节"] --> cap["采集<br/>生成快照"]
cap --> write["规划与写作<br/>引用快照"]告诉 Agent
说清楚要导入哪些文档,而不只是说当前所在的文件夹:
请把 ../docs/user-guide 作为产品文档导入,只需要 getting-started 和 billing 两个章节。你交给 Agent 的运行说明、手册、计划或任务清单,默认都当作任务指引,而不是来源;只有你明确要求导入时才会登记。如果不确定要采集哪些文档,Agent 会先问你一次,而不会把你的指引当成资料采集进去。
Agent 会确认什么
登记时还不会读取任何内容。Agent 会记下你指定的文件夹或文件;如果你限定了范围,就只记下你要的章节或匹配规则,比如上例中的 getting-started 和 billing。然后它为这个来源做好采集准备,并告诉你登记了哪些内容。
有两项设置会影响快照,要在页面开始引用这个来源之前定好:
- 保留文件夹结构:默认情况下,文档来源只保留文件名。如果文件夹本身有含义,比如
guides/和reference/下都有setup.md,就请 Agent 保留文件夹结构;快照会保留文件夹,以及文档链接到的图片和小型数据文件。 - 把结构化文件当作文档:默认只读取 Markdown。如果页面需要把小型 JSON 或 YAML 文件当作文本引用,请说明这些扩展名,它们也会作为文档采集。图片只作为资源保留,不作为引用对象。
之后再改这两项设置,快照里的路径会随之变化,引用这个来源的页面就要像处理文件改名一样跟着调整。
如果知识工作区已经自定义过来源设置,Agent 会只做必要的修改来加入新文件夹,并告诉你改了哪些地方。完整的登记选项见 CLI 命令参考。
采集
采集会读取文档内容,所以需要你在当前对话中授权。你要求采集、导入或读取指定文档,就算授权;只是提到这些文档,或只要求登记,都不算,这时 Agent 会先问你。授权后,Agent 会采集文档、报告结果,一直做到请求中的文档全部完成。
链接的图片缺失、位于来源之外、与其他文件冲突或超过 5 MB 时,采集不会中断:链接保持原样,Agent 会把它报告为资源缺口,你可以修正原文,也可以接受这个缺口。
采集只生成快照,不做分类、摘要或审批。Context 会保证快照完整,Agent 也不会手动修改快照。
文档站
采集默认读取普通 Markdown。如果这个文件夹其实是一个文档站(包含 MDX 页面、侧边栏或站点配置),Agent 会告诉你,并在改变读取方式之前先征得你的同意。路由元数据和静态组件里的文字会作为依据保留下来。
如果某个页面只是运行时才加载内容的空壳,Agent 会告诉你,并请你提供渲染后的站点或它的数据源,而不会凭空编造正文。
文档发生变化时
页面会继续引用写作时依据的那份快照。文件夹内容变了以后,请发起更新:Agent 会采集新版本,并和你确认哪些页面需要修改。参见更新知识。
如果这些文档由其他团队按版本发布(比如文档仓库或已发布的知识包),或者文件夹即将归档,参见按版本发布与即将归档的资料。