Published and Archived Collections
Some material you want to cite is not a folder you maintain. Another team publishes it as versions — a documentation repository, a released knowledge package — or a team wiki is about to be archived. Context handles both with a document source:
- Follow a published version. You install one exact version as files, Context records where it came from and which version it is, and pages cite it like any local document. When a newer version comes out, you move the source to it and update the pages it affects.
- Absorb once. You capture the collection's files, write the author's own judgments as notes and produce articles; when the original is archived, the source is frozen and stays citable.
Register material as a source only when pages cite it. Content readers only need to find stays an external entrance.
Following a published version
Ask the Agent with the exact version:
Register the payments team's API docs repository at commit 4f2a9c1 as a source.
Keep its folders; pages will cite the reference/ and guides/ chapters.Context never downloads the content itself. The Agent installs that version as real files — not links — into sources/<kind>/<name>@<version>/ in the knowledge workspace, using the origin's own tool outside the workspace so no lock files or tool settings land in it, and then registers the source with its origin:
context source add file api-docs --layout tree \
--local sources/git/api-docs@4f2a9c1 \
--origin-kind git --origin-id https://example.com/payments/api-docs.git \
--origin-version 4f2a9c1Registration adds sources/<kind>/ to .gitignore: only the registration and the captured snapshot are committed, not the installed files. For a Git repository the registration also returns the exact install command and a command that lists the latest version. The snapshot records the origin and version, and the website's source list links each cited file to that version.
--layout tree keeps the folders and the images documents link to; add --document-ext .json --document-ext .yaml when pages should cite small structured files as text. Choose the layout before pages cite the source, because switching it later moves paths in the snapshot. See Document Directories for capture and asset gaps.
Moving to a newer version
When you ask for an update — or a routine update runs — the Agent compares the latest available version with the registered one. If it is the same, nothing happens. If it is newer, the Agent installs it into a new <name>@<new version> directory, moves the registration to it and captures again. The snapshot shows which files changed, so only the pages citing them are revised, as for any document change. The old version directory is deleted afterwards.
In a fresh clone
The installed files are not in Git, so a new clone of the knowledge workspace does not have them. Capture then reports a deferred gap whose next step is the install command for the registered version. The Agent installs exactly that version, not the latest, so the knowledge is rebuilt from what it was written from.
Absorbing a collection before it is archived
To bring a collection in once instead of following it, the Agent registers its folder with --layout tree, captures it, saves the author's own judgments — decisions, procedures, comparisons that exist nowhere else — as notes, and produces articles. When the original is archived, the source is frozen:
context source add file team-wiki --freezeA frozen source keeps its snapshot citable and is never captured again, so the archived folder can disappear. --unfreeze allows capturing again. Which collections to follow and which to absorb is part of planning; see Migrating an Existing Knowledge Base.
按版本发布与即将归档的资料
有些要引用的资料并不在你维护的文件夹里:可能是其他团队按版本发布的文档仓库或知识包,也可能是即将归档的团队 wiki。这两种情况都用文档来源处理:
- 跟进已发布的版本:把某个确切版本安装成文件,Context 记下它的出处和版本,页面像引用本地文档一样引用它。有新版本时,把来源切换过去,再更新受影响的页面。
- 一次性吸收:采集资料集里的文件,把作者自己的判断整理成笔记,再据此写出文章。原资料归档后冻结这个来源,已有的引用照样有效。
只有页面需要引用的资料才登记为来源。读者只需要知道去哪里找的内容,作为外部入口登记就够了。
跟进已发布的版本
告诉 Agent 要登记哪个确切版本,例如:
把支付团队 API 文档仓库的 4f2a9c1 提交登记为来源。
保留它的文件夹,页面会引用 reference/ 和 guides/ 两部分。Context 本身不下载这些内容。Agent 用来源自己的工具在工作区外完成安装,因此锁文件和工具配置都不会混进工作区。装好后,Agent 把这个版本以真实文件(而不是链接)的形式放到知识工作区的 sources/<kind>/<name>@<version>/,再连同出处一起登记:
context source add file api-docs --layout tree \
--local sources/git/api-docs@4f2a9c1 \
--origin-kind git --origin-id https://example.com/payments/api-docs.git \
--origin-version 4f2a9c1登记时会把 sources/<kind>/ 加进 .gitignore:提交到仓库的只有登记信息和采集快照,安装的文件不会提交。如果来源是 Git 仓库,登记结果还会给出准确的安装命令,以及查看最新版本的命令。快照会记下出处和版本,网站的来源列表也会把每个被引用的文件链接到对应版本。
--layout tree 会保留文件夹,以及文档里链接到的图片。如果页面要把小型结构化文件当作文本引用,再加上 --document-ext .json --document-ext .yaml。布局要在页面开始引用这个来源之前定好,之后再改会使快照里的路径发生变化。采集方式和资源缺口见文档目录。
切换到新版本
你要求更新时,或例行更新运行时,Agent 会拿最新可用版本和已登记的版本比较。版本没变就什么也不做;有新版本时,Agent 把它装到新的 <name>@<new version> 目录,把登记切换过去并重新采集。快照会标出哪些文件有变化,所以只需修订引用了这些文件的页面,做法和处理其他文档变化一样。最后删掉旧版本的目录。
在新克隆的工作区里
安装的文件不进 Git,所以新克隆的知识工作区里没有它们。这时采集会报告一个待补的缺口,给出的下一步就是安装已登记版本的命令。Agent 安装的是登记的那个版本,而不是最新版,这样重建出来的知识与当初写作时依据的内容一致。
归档前一次性吸收资料集
如果只想一次性接入某个资料集、不打算持续跟进,Agent 会用 --layout tree 登记它的文件夹并采集,把作者自己的判断(别处找不到的决定、流程和对比)保存为笔记,然后写出文章。原资料归档后,冻结这个来源:
context source add file team-wiki --freeze冻结的来源会保留快照供引用,以后也不再采集,所以原来的文件夹删掉也没关系。需要恢复采集时,使用 --unfreeze。哪些资料集持续跟进、哪些一次性吸收,在规划阶段决定,参见迁移已有知识库。