Skip to content

Updating Knowledge ​

Every approved page records which source version it was written from. When a repository moves on or a document is edited, an update compares the new version with the one the pages were written from, revises only the affected pages and then records the new version as processed. Unaffected pages are left alone.

mermaid
flowchart LR
  ask["You name the scope<br/>and target version"] --> acq["Agent fetches the<br/>new version"]
  acq --> match["Agent finds pages<br/>citing changed material"]
  match --> decide["Keep / revise / add"]
  decide --> rev["You review<br/>the changed pages"]
  rev --> build["Approved pages applied,<br/>outputs rebuilt"]

If you have already moved a repository's pin with context source add repo --ref <sha>, the Agent processes it with context update --pending, which needs no other input. Only pages whose cited text changed are asked about one by one; every other page that cites the repository can still be revised in the same decision when an addition affects it, and the new commit is recorded once that decision and its revisions are done. When the source checkout does not have that commit yet, it is fetched first; if it cannot be fetched, the update stops and asks for the commit to be checked out instead of treating every citation as missing. In a partial clone, the update also downloads the contents of cited files the clone does not have yet, in one request per source; if they cannot be downloaded, it stops and names the source, the number of files and the reason. Only --pending uses the network: an update with an explicit input file reads what the checkouts already have and says so when a commit or contents are missing. Checking status or verifying never fetches anything.

Ask for the update ​

Name the scope — a whole repository, some modules or specific documents — and, when it matters, the version:

text
billing-service has moved to the release-2.4 merge. Locate the affected knowledge
and update it. Only the invoicing and refunds modules.

For a single page whose text is wrong, a revision is the better tool. To have sources checked on a schedule instead of asking each time, set up routine updates. If other work is still unfinished in the knowledge workspace, the Agent tells you and asks whether to finish or roll it back before starting an independent update.

How the new version is chosen ​

Context does not watch platforms for changes; the Agent uses its own Git and document tools once, for the scope you named.

  • For a branch or merge request, it works out the target branch, whether the change is merged and the actual commit on that branch. An unmerged proposal is not the mainline, and a squash or rebase can produce a different commit than the feature branch.
  • Intervening commits that touch the registered modules are included; reverts are real changes.
  • A new commit that leaves the registered modules unchanged can conclude "no knowledge change".
  • If the old version is no longer available after a force push or history cleanup, the Agent says so and compares the current material with the approved knowledge instead.
  • For documents, a read failure, a deletion and a move are reported differently; none of them is a reason to retire a page.

Which pages change ​

The Agent first finds the pages whose cited text no longer matches at the new version; citations whose text only moved follow it automatically and are not asked about. For a repository citation it also gets the lines the source diff moved the old text to, which saves working out new line numbers. Changed files that no page cites are listed as well, grouped by directory, so new modules, interfaces or settings are not missed. That list is a starting point, not a list of pages that must change: the Agent reads the change and each page, keeps what is still right and revises what changed. A revised page is rewritten to describe the current state as one coherent article, rather than collecting "updated" notes; the change history belongs in the changelog. Lasting knowledge from those uncited changes goes into an existing page, or, for a genuinely new topic, into a proposed new page, shown to you for confirmation before it is written.

If you name no modules, the whole registered source is in scope.

Review and finishing ​

Changed pages appear in the review report with their changed blocks next to the previous text. Approve, comment or ask for changes as in Reading Review Reports. A revised page cannot keep a citation of the updated source that the new version no longer confirms, even in a paragraph the update did not rewrite; the Agent sees every such problem of a page at once, and the submission result lists the citations a section no longer carries.

The update is finished when every selected revision is approved, the approved pages are applied and the outputs rebuilt — or when the Agent concludes that nothing needs to change. Only then is the new version recorded as processed. It is not recorded when the new version is fetched or after the first approved page, so an interrupted update can resume without losing track of what remains.

On pages that were kept as they are, citations whose text merely moved in the new version are updated automatically, so verification no longer reports them. This also works in a fresh clone or on another machine: the cited text is read from the previously processed commit and is used only if it still matches. If cited text actually changed or can no longer be confirmed, the Agent lists those pages when the update finishes; their citations still point to the previous locations. Pages citing the project's own docs or Skills (same-repository content) are listed too when that text changed, even though their citations are updated to the current text — verification will not flag them later, so check them from the list. Correct each listed page that needs it with a revision. Finishing the update also leaves the knowledge structure current, so verification does not ask you to run Close again.

Only the sources the update needs ​

Unrelated repositories do not need to be checked out for an update. A note, a document-only change, a wording fix or a navigation change needs no code at all. When required code is missing, the Agent restores only that repository at its recorded commit; see Code Repositories.

更新知识 ​

每个已批准页面都会记录其写作时依据的来源版本。当仓库有了新提交或文档被编辑后,更新会将新版本与页面写作时依据的版本对比,只修订受影响的页面,然后把新版本记录为已处理。不受影响的页面保持不变。

mermaid
flowchart LR
  ask["你指定范围<br/>和目标版本"] --> acq["Agent 获取<br/>新版本"]
  acq --> match["Agent 找到引用了<br/>变更材料的页面"]
  match --> decide["保留 / 修订 / 新增"]
  decide --> rev["你审核<br/>变更的页面"]
  rev --> build["应用已批准的页面,<br/>重新构建产物"]

如果你已经用 context source add repo --ref <sha> 移动了仓库的固定版本,Agent 会用 context update --pending 处理它,无需其他输入。只有引用文字发生变化的页面会被逐个询问;其他引用该仓库的页面,在新增内容影响到它们时也能在同一次决定中修订。这次决定及其修订完成后,新的 commit 才会被记录。来源检出还没有这个 commit 时会先拉取;无法拉取时,更新会停下并要求检出该 commit,而不是把所有引用都当作缺失。在部分克隆中,更新还会下载克隆里还没有的被引用文件内容,每个来源一次请求;下载不了时会停下,并说明来源、文件数和原因。只有 --pending 会访问网络:带显式输入文件的更新只读取检出中已有的内容,缺少 commit 或文件内容时会直接说明。查看状态和校验从不拉取任何内容。

发起更新 ​

指定范围——整个仓库、部分模块或特定文档——必要时再说明版本:

text
billing-service 已合入 release-2.4,请帮我找到受影响的知识并更新。
这次只处理 invoicing 和 refunds 两个模块。

如果只是单个页面的文本有误,更适合用 修订。如果希望按计划定时检查来源,而不是每次都提出请求,请设置例行更新。如果知识工作区中还有其他未完成的工作,Agent 会告诉你,并在开始一次独立的更新之前询问是先完成还是回滚。

如何选定新版本 ​

Context 不会监视平台上的变化;Agent 只会针对你指定的范围,使用它自己的 Git 和文档工具获取一次。

  • 对于分支或合并请求,Agent 会确认目标分支、变更是否已合并,以及该分支上的实际提交。未合并的提议不属于主线,而 squash 或 rebase 可能产生与特性分支不同的提交。
  • 中间涉及已登记模块的提交都会纳入;revert 也是真实的变更。
  • 如果新提交没有改变已登记的模块,可以得出“知识无需变更”的结论。
  • 如果在 force push 或历史清理之后旧版本已不可用,Agent 会说明这一点,并改为将当前材料与已批准的知识进行对比。
  • 对于文档,读取失败、删除和移动会分别报告;这些都不能作为下线页面的理由。

哪些页面会变化 ​

Agent 首先找出引用文字在新版本中已对不上的页面;文字只是移动了位置的引用会自动跟随,不会被问到。对于仓库引用,Agent 还会拿到来源 diff 把旧文字移到了哪几行,省去自己推算新行号。没有任何页面引用的变更文件也会按目录分组列出,以免漏掉新的模块、接口或设置。这份列表是起点,而不是必须修改的页面清单:Agent 会阅读变更和每个页面,保留仍然正确的内容,修订发生变化的部分。修订后的页面会整体改写为描述当前状态的连贯文章,而不是堆积“已更新”之类的说明;变更历史属于 changelog。这些未引用变更中的长期知识会写进已有页面;真正的新主题则成为提议的新页面,在写作之前先交给你确认。

如果你没有指定模块,整个已登记的来源都在范围内。

审核与完成 ​

变更的页面会出现在审核报告中,变更的区块与之前的文本并排展示。按 阅读审核报告 中的方式批准、评论或要求修改。修订后的页面不能保留新版本已无法确认的该来源引用,即使是在这次更新没有改写的段落里;Agent 会一次看到页面的所有此类问题,提交结果也会列出章节不再携带的引用。

当每个选中的修订都已批准、已批准的页面已应用且产物已重新构建——或 Agent 得出无需变更的结论时,更新才算完成。只有到这时,新版本才会被记录为已处理。获取新版本时或第一个页面获批后都不会记录,因此中断的更新可以恢复执行,而不会丢失剩余工作的进度。

在保持不变的页面中,仅在新版本里移动了位置的引用会被自动更新,验证不再报告它们。在全新克隆或另一台机器上也是如此:被引用的文本会从上一次处理的提交中读取,只有在仍然一致时才会使用。如果被引用的文本确实发生了变化或已无法确认,Agent 会在更新完成时列出这些页面;它们的引用仍指向之前的位置。引用项目自身文档或 Skill(同仓库内容)的页面,在该文本变化时也会被列出,尽管它们的引用会更新到当前文本——之后验证不会再标记它们,所以请根据这份列表检查。对列出的页面中需要处理的,用 修订 逐一修正。完成更新后,知识结构也保持最新,验证不会再要求你重新运行 Close。

只需要更新所用的来源 ​

更新时无需检出不相关的仓库。笔记、仅涉及文档的变更、措辞修正或导航变更完全不需要代码。当所需代码缺失时,Agent 只会在记录的提交上恢复那一个仓库;参见 代码仓库。