SuperAPI AI Directory

sync-context

General & other

View repository

Updated 10-15 20:09

About this skill

sync-context

In cooking, spec.md is handled by explore / to-spec / archive; do not change it here. No verbosity and no pretentious profundity.

See impact-files.mdfor the "Affected Files" format. See context-template.md。

Pre-checks

Run node .agents/scripts/precheck.mjs: if FAIL, stop and, per the output, prompt the user to run setup(when only script-type missing items are present, use setup update mode); do not run it on their behalf. PASS output carries the project category; read docs as needed per the root AGENTS.md. For when to change CODE-MAP, see code-map-update.md。

Unified tool definition

  • 交互式提问: a type of tool built into most Agents, a tool by which the Agent asks the user questions and provides options and custom input; its name differs across Agents and it may be called AskUserQuestion or AskQuestion , etc.

Input

  • When the user invokes it explicitly, the arguments may be files or directories (globs are first expanded by the shell into actual files before being passed in); if no arguments are given, take the current workspace changes.
  • When triggered by the review dispatcher after the review passes, the caller passes in the file paths of this change.
  • After files are changed directly in conversation without going through review, the current agent passes in the paths changed in this round.

Determine the changed files:

  1. The user gave paths: process only those paths.
  2. Otherwise use git to get the changed files in the working tree and staging area, for example the paths in git status --porcelain , plus the union of git diff --name-only and git diff --cached --name-only ; deduplicate.
  3. Ignore .agents/cooking/。
  4. When there are no changes in either the working tree or the staging area: use the 交互式提问 tool to ask the user which commit or which files to sync, and do not automatically take the most recent commit.

Query

The script is copied by setup from setup/scripts/ to .agents/scripts/. Always call the latter.

query Scan on the spot the "Affected Files" of archived entries under .agents/docs/CONTEXT/ (matching only additions and modifications).

node .agents/scripts/spec-files.mjs query <文件1> <文件2>...
# 或从 git 输出传入:
git diff --name-only | node .agents/scripts/spec-files.mjs query --stdin
  • If an entry cannot be parsed: stop, fix its "Affected Files" first, and do not skip it.
  • Output NO_MATCH: see "No match" below.
  • If there are matches: open only the matched entries; do not read multiple unmatched entries at once, and even more so do not load the entire CONTEXT/。

If matched, update

Compare againstcurrent file, and update terminology / domain / affected files. Do not compare against acceptance criteria (there are none in CONTEXT).

  1. Change only the sentences overturned by this change; do not rewrite the whole text and do not expand the scope. If an old entry still contains acceptance criteria, non-goals, or user stories: convert it to the context template and drop those sections.
  2. If the "Affected Files" have changed, update them per impact-files.md , and use parse to confirm it passes. Queries follow only additions and modifications.
  3. In ## 更新记录 , append:- <日期>: <一句话>;涉及:<文件路径>. Do not make up for old omissions.
  4. If unsure whether an entry is still valid or should be merged/deprecated: use the 交互式提问 tool to ask the user; do not guess.
  5. Sync multiple entries one by one; do not cross-contaminate.
  6. If the title or one-sentence summary has changed, sync the corresponding line in <模块>/index.md (do not paste the body text).

If obsolete, delete it

Changes delete or entirely overturn the capability described by an entry (major refactor, breaking change, removal of a feature / component): delete the entire entry. The context is dynamically loaded memory; outdated entries left behind are just noise and will mislead decisions.

  1. Delete the entry file, and delete the corresponding line in <模块>/index.md ; when the module no longer has any entries, also delete the <模块>/ directory and the module line in CONTEXT/index.md .
  2. Replaced by a new capability: create a new entry according to the template, then delete the old one; if it is only a rename or a change of ownership: modify the content and rename the entry file, and sync the two-level index links.
  3. Unsure whether to deprecate the entire entry: use the 交互式提问 tool to ask the user; do not guess.

No match

  • Trivial change(formatting, typo): end.
  • Constitutes a new capability: create a new entry according to the context template. Module: for code, search by CODE-MAP path prefix; for non-code, use CONTEXT/index.md existing module names. If it does not match, ask. Do not leave completed changes without context.
  • When unsure, ask; do not guess.

Prohibited

Do not write business code, do not modify cooking, do not act on behalf of setup to update ARCHITECTURE.md. When an architectural-level change is found, stop and have the user run setup update mode.

Code type: when the path or responsibility has been overturned by the code, follow code-map-update.md to update CODE-MAP.md(only change the relevant lines). For non-code, do not open CODE-MAP.

End

Report: number of files scanned, entries matched and updated, entries deleted, entries created, whetherCODE-MAP.md was updated, whether setup。