repo-kit-update
Use to update the .agents/ folder of your local clone of a repository to the current version of its repository kit, on a new branch, without committing.
- License 许可
- MIT
- 最近更新
- 2026-10-30
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- repo-kit-update
- description
- Use to update the .agents/ folder of your local clone of a repository to the current version of its repository kit, on a new branch, without committing.
03 SKILL.md 正文
Update a repository kit
This skill writes into the clone repos/<name>, never into the workspace. In the clone it writes only under .agents/. It never reads .env files, .local/env or secret values, never prints tokens, and never commits or pushes.
Words used below
<ws>: the workspace root, an absolute path (the output ofpwdin step 1).<name>: the repository name inrepos.json.<clone>:<ws>/repos/<name>.<kind>:kit.kindof the entry.<kitdir>:<ws>/.agents/repo-kits/<kind>.<version>:versionin<kitdir>/kit.json. This is the workspace version of the kit; the workspace's own.agents/kit.jsonis a different file.<branch>:repo-kit-<kind>-<version>, for examplerepo-kit-example-0.2.0.<default>:default_branchof the entry.<out>: a temporary folder for the rendered kit, outside the clone and the workspace: the literal output ofmktemp -din step 5, written into every later command.<base>: the folder the clone's kit files are read from. An update always has<clone>/.agents, so<base>is<clone>/.agents. The kit path.agents/<p>is the clone file<base>/<p>.<stamp version>:versionin<clone>/.agents/kit.json.- States of a path:
absent,same,replaceable,edited,obsolete,removed-edited,foreign(see## Recipe: statusin.agents/skills/repo-kit-install/SKILL.md). Decisions for aneditedorremoved-editedpath:kit,local,raise, exactly these words.
Stops
Every stop prints its message and ends the skill. Every check of this table runs before step 13, so before a stop in this table the skill has written nothing into the clone, created no branch and switched no branch. When <out> already exists, run rm -rf <out> before stopping. Only step 15 can stop after the clone changed; it prints the commands that discard the attempt.
| Stop | Message |
|---|---|
| U1 no digest tool | Stop: python3, shasum and sha256sum are all missing, so file digests cannot be computed. Nothing was changed. |
| U2 unknown repository | Stop: repository <name> is not in repos.json. Nothing was changed. |
| U3 invalid kit | Stop: the kit of repository <name> in repos.json is invalid: <reason>. Fix the entry or the kit through a workspace merge request, then run repo-kit-update again. Nothing was changed. |
| U4 render failed | Stop: rendering kit <kind> for repository <name> failed: <reason>. Nothing was changed. |
| U5 clone missing | Stop: clone repos/<name> is missing. Clone it with the repos-sync skill, then run repo-kit-update again. Nothing was changed. |
| U6 dirty clone | Stop: clone repos/<name> has uncommitted changes. Commit or stash them yourself, then run repo-kit-update again. Nothing was changed. |
| U7 not on the default branch | Stop: clone repos/<name> is on branch <current>, not <default>. Switch it to <default> and pull it yourself, then run repo-kit-update again. Nothing was changed. |
| U8 both folders | Stop: repos/<name> has both .agent/ and .agents/. Which one should stay? Merge them by hand in a separate merge request, then run repo-kit-update again. Nothing was changed. |
| U9 invalid stamp | Stop: repos/<name>/.agents/kit.json is not a stamp with kind, version and params. Ask the maintainer to repair it. Nothing was changed. |
| U10 other kind | Stop: repos/<name>/.agents/kit.json has kind <stamp kind>, but repos.json names kind <kind>. Changing the kind of a repository is the owner's decision. Nothing was changed. |
| U11 workspace behind | Stop: repos/<name>/.agents/kit.json has version <stamp version>, newer than version <version> of kit <kind> in this workspace. The workspace is behind: update it from its default branch, then run the skill again. Nothing was changed. |
| U12 branch exists | Stop: branch <branch> already exists in repos/<name>. Finish or delete it, then run repo-kit-update again. Nothing was changed. |
| U13 value the recipe cannot render | Stop: parameter <NAME> of repository <name> has the value <value>, which the recipe without python3 cannot render. Run repo-kit-update where python3 is available. Nothing was changed. |
| U14 raise | Stop: <path> got the decision raise. Change kit <kind> in .agents/repo-kits/<kind>/ through a workspace merge request. Raise the kit version in the same merge request, because the update compares versions, then run repo-kit-update again. Nothing was changed. |
U8 also asks the maintainer the question in its message and waits for the answer; the skill does not merge the folders.
Steps
- Go to the workspace root: the nearest directory, walking up from where you are, where
test -f .agents/kit.jsonsucceeds. Runpwd; its output is<ws>. Start every command below withcd <ws> &&orcd <clone> &&as shown. - Find the tools. When
command -v python3prints a path, Python is present. Otherwise, when neithercommand -v shasumnorcommand -v sha256sumprints a path, stop with U1. Without Python, follow## Without Pythonin every step that names a recipe. - Ask the person for
<name>when they did not give it. Read<ws>/repos.jsonand find the entry ofrepositorieswhosenameis<name>. With no such entry, stop with U2. - Check the entry's
kit:- When the entry has no
kit, stop with U3 and the reasonthe entry has no kit. - When
test -d <kitdir>fails, stop with U3 and the reasonkit kind <kind> is not a folder under .agents/repo-kits/. - Read
<kitdir>/kit.json.kit.paramsof the entry must have exactly the names inparamsofkit.json, and every value must match the wholepatternof its parameter. Check a pattern withPATTERN='<pattern>' VALUE='<value>' python3 -c 'import os, re, sys; sys.exit(0 if re.fullmatch(os.environ["PATTERN"], os.environ["VALUE"]) else 1)'; exit code 0 means it matches. Without Python runprintf '%s\n' '<value>' | grep -Ex -e '<pattern>'; exit code 0 means the whole value matches. In both commands write each'inside the quotes as'\''.grep -Esyntax covers the patterns kits use: character classes,.,*,+,?,{m,n},|and groups. When a pattern uses syntaxgrep -Edoes not support, such as\d,\w,\s,(?or a lazy*?, compare by reading instead. A value with a line break never matches. On a missing name, an extra name or a value that does not match, stop with U3 and name the parameter in the reason. - Remember
<version>fromversionin<kitdir>/kit.jsonand<default>from the entry.
- When the entry has no
- Render the kit. Run
mktemp -d; its output is<out>. Write that path itself into every later command; do not keep it in a shell variable, because a later command may run in a new shell.- With Python:
cd <ws> && python3 tools/repo_kit.py render <name> <out>. When it exits 2, stop with U4 and use its error line as the reason. - Without Python: apply
## Recipe: renderas## Without Pythonsays.<out>/.agents/now holds every kit file with the placeholders replaced.
- With Python:
- Check the clone:
- When
test -d <clone>/.gitfails, stop with U5. - When
cd <clone> && git status --porcelainprints anything, stop with U6. - When
cd <clone> && git rev-parse --abbrev-ref HEADprints something other than<default>, stop with U7 with that output as<current>. Do not switch or pull; the person does that. - When both
test -d <clone>/.agentandtest -d <clone>/.agentssucceed, stop with U8.
- When
- Check the stamp.
- When
test -f <clone>/.agents/kit.jsonfails, there is no stamp: runrm -rf <out>, tell the personrepos/<name> has no kit stamp; continuing as repo-kit-install., and continue with.agents/skills/repo-kit-install/SKILL.mdfor the same<name>from its first step. Do not run the rest of this skill. - Read
kind,versionandparamsfrom the stamp withgrep -m 1 '^ "kind": ' <clone>/.agents/kit.json,grep -m 1 '^ "version": ' <clone>/.agents/kit.jsonandgrep -m 1 '^ "params": ' <clone>/.agents/kit.json. When one of them prints nothing, stop with U9. The parameter values are the"<NAME>": "<value>"lines thatsed -n '/^ "params": {$/,/^ },$/p' <clone>/.agents/kit.jsonprints; the line"params": {},means the stamp has no parameters. - When
kindis not<kind>, stop with U10. - Compare
<stamp version>with<version>as three numbers, MAJOR first, then MINOR, then PATCH:1.10.0is newer than1.9.0. When the stamp version is newer, stop with U11. For example, stamp1.2.0and workspace kit1.1.0stop here, and the clone is unchanged. - When
<stamp version>equals<version>and the stampparamshave the same names with the same values askit.paramsof the entry (order does not matter), runrm -rf <out>, tell the personrepos/<name> is up to date with kit <kind> <version>; nothing to do.and end the skill.
- When
- When
cd <clone> && git rev-parse --verify --quiet refs/heads/<branch>orcd <clone> && git rev-parse --verify --quiet refs/remotes/origin/<branch>prints anything, stop with U12. - Compare the clone with the kit.
- With Python:
cd <ws> && python3 tools/repo_kit.py status <name> repos/<name>. When it exits 2, stop with U4 and use its error line as the reason. - Without Python: apply
## Recipe: statusas## Without Pythonsays. Each output line is<state> <path>; for the path.agents/<p>the clone file is<base>/<p>. Write the list down. The states mean: same: the clone file equals the kit file; nothing to do.absent: the kit has the file and the clone does not; it will be copied.replaceable: the kit changed the file and the clone file is untouched since the stamp; it will be replaced.obsolete: the kit no longer has the file and the clone file is untouched; it will be deleted.edited: the clone file was changed in the repository and differs from the kit; it needs a decision.removed-edited: the kit no longer has the file and the clone file was changed in the repository; it needs a decision.foreign: a repository file inside.agents/that the kit never had; it is not touched.
- With Python:
- Collect decisions before writing anything. Show the person every
editedandremoved-editedpath. For each.agents/<p>, one at a time:- For
edited, show the difference withdiff <base>/<p> <out>/.agents/<p>. Forremoved-edited, tell the person the kit no longer has this file and show it withcat <base>/<p>. - Ask for one decision:
kit: foreditedthe kit file replaces the clone file; forremoved-editedthe file is deleted. The clone text is lost.local: the clone text moves to.agents/local/<p>; foreditedthe kit file then takes its place. Whentest -e <base>/local/<p>succeeds, that place is taken: tell the person and ask again forkitorraise.raise: the kit itself must change first.
- Write the decisions down as
<decision> <path>. When the person gives any other word, ask again. When there is no such path, there is nothing to ask.
- For
- When any path got
raise, runrm -rf <out>and stop with U14, naming that path. The clone has no new branch and no changed file. - List every
foreignpath from step 9 for the report. Do not move or change them. - Create the branch:
cd <clone> && git switch -c <branch>. From here on the clone changes. - Write the kit files, in this order, for each path
.agents/<p>:- Each
replaceablepath:cd <clone> && cp <out>/.agents/<p> .agents/<p>. - Each
absentpath:cd <clone> && mkdir -p "$(dirname .agents/<p>)" && cp <out>/.agents/<p> .agents/<p>. - Each
obsoletepath:cd <clone> && rm .agents/<p>. - Each decision:
kitonedited:cd <clone> && cp <out>/.agents/<p> .agents/<p>.kitonremoved-edited:cd <clone> && rm .agents/<p>.localonedited:cd <clone> && mkdir -p "$(dirname .agents/local/<p>)" && mv .agents/<p> .agents/local/<p> && cp <out>/.agents/<p> .agents/<p>.localonremoved-edited:cd <clone> && mkdir -p "$(dirname .agents/local/<p>)" && mv .agents/<p> .agents/local/<p>. Leavesamepaths as they are and do not touchforeignpaths.
- Each
- Write the new stamp.
- With Python:
cd <ws> && python3 tools/repo_kit.py stamp <name> repos/<name>. - Without Python: apply
## Recipe: stampas## Without Pythonsays. Then run step 9 again. Every kit path must now besame;foreignpaths stay. When another state is left, stop: runrm -rf <out>, tell the person every line whose state is neithersamenorforeign, and print these commands for the person to discard the attempt. Do not run them yourself:
The first line removes every uncommitted change of this attempt, staged or untracked. The second returns the clone tocd <clone> && git reset --hard && git clean -fd cd <clone> && git switch <default> && git branch -d <branch><default>and deletes<branch>. Step 6 made sure the clone had no uncommitted or untracked files before, so nothing else is lost. - With Python:
- Run
rm -rf <out>. Print these commands for the person and do not run them. The repository's forge isforgeof the entry, not the forge of this workspace:
Then, bycd <clone> git add -A .agents git commit -m "chore(agents): update kit <kind> to <version>"forge:gitlab:git push -u origin <branch> -o merge_request.create -o merge_request.title="Update kit <kind> to <version>";github:git push -u origin <branch>, thengh pr create --fill;git:git push -u origin <branch>, then open the merge request by hand. Tell the person to adjust the commit message to the repository's own commit rules when it has them.
- Report to the person:
<branch>and the version change<stamp version>to<version>; the replaced, copied and deleted paths; the decisions; eachforeignpath with the proposalgit mv .agents/<p> .agents/local/<p>as a later change of their own; the printed commands. Never commit or push yourself.
Example
Workspace entry payments-worker with forge gitlab, default branch main and "kit": {"kind": "example", "params": {"SERVICE": "payments-worker"}}. The clone repos/payments-worker is clean on main and has kit example version 0.1.0. The team changed files/rules/example.md and files/skills/example/SKILL.md and raised the kit to 0.2.0. In the clone a maintainer had changed step 1 of .agents/skills/example/SKILL.md.
Stamp repos/payments-worker/.agents/kit.json before:
{
"kind": "example",
"version": "0.1.0",
"params": {
"SERVICE": "payments-worker"
},
"files": {
".agents/AGENTS.md": "27ff1ccb6beb7cb7b873f3d9c173ff18e74fbb30572c299987bb09055b1d77b4",
".agents/rules/example.md": "e31c19605d14f680052c8bb7550bd2132105a0eacda42e9db2a11809743af543",
".agents/skills/example/SKILL.md": "777eb69778449f5ffa502dafaf1fee70914792262e0448e43a312adce57bd70b"
}
}
- Step 5:
mktemp -dprints/tmp/tmp.Q7r2m, so<out>is/tmp/tmp.Q7r2m. - Step 7: the stamp version
0.1.0is older than0.2.0, so the update goes on. Step 8 finds no branchrepo-kit-example-0.2.0. - Step 9 prints:
The clonesame .agents/AGENTS.md replaceable .agents/rules/example.md edited .agents/skills/example/SKILL.mdrules/example.mdstill has the stamp digeste31c1960..., so it isreplaceable. The cloneSKILL.mdhas digest6b9e2f06..., which is neither the stamp digest nor the digest of the kit file, so it isedited. - Step 10: the person decides
local .agents/skills/example/SKILL.md. - Steps 13 to 15 run, with
<ws>the workspace root:cd <ws>/repos/payments-worker && git switch -c repo-kit-example-0.2.0 cd <ws>/repos/payments-worker && cp /tmp/tmp.Q7r2m/.agents/rules/example.md .agents/rules/example.md cd <ws>/repos/payments-worker && mkdir -p "$(dirname .agents/local/skills/example/SKILL.md)" && mv .agents/skills/example/SKILL.md .agents/local/skills/example/SKILL.md && cp /tmp/tmp.Q7r2m/.agents/skills/example/SKILL.md .agents/skills/example/SKILL.md cd <ws> && python3 tools/repo_kit.py stamp payments-worker repos/payments-worker - Stamp after:
{ "kind": "example", "version": "0.2.0", "params": { "SERVICE": "payments-worker" }, "files": { ".agents/AGENTS.md": "27ff1ccb6beb7cb7b873f3d9c173ff18e74fbb30572c299987bb09055b1d77b4", ".agents/rules/example.md": "0e96d5109adecd0063c090858b2b121986c1fde4f2cfa3b2acd1299f35cc181b", ".agents/skills/example/SKILL.md": "d863c733393931e28bb36078a2255078b9f500dd3ec4124a060d51d81d64d686" } } - Step 9 again prints
samefor all three paths. The maintainer's text is in.agents/local/skills/example/SKILL.md. - Step 16 runs
rm -rf /tmp/tmp.Q7r2mand printsgit add -A .agents,git commit -m "chore(agents): update kit example to 0.2.0"andgit push -u origin repo-kit-example-0.2.0 -o merge_request.create -o merge_request.title="Update kit example to 0.2.0".
Without Python
The recipes live in .agents/skills/repo-kit-install/SKILL.md; follow them there and do not copy them here. They use the words of that skill, which mean here:
<ws>,<name>,<clone>=<ws>/repos/<name>,<kind>,<kitdir>=<ws>/.agents/repo-kits/<kind>and<version>: as in## Words used below.<out>: the literalmktemp -doutput of step 5.<base>:<clone>/.agents.- Their stop S4 is U4 here, and their stop S12 is U13 here, with the messages of
## Stopsof this skill.
- Step 2: without
python3, one ofshasumorsha256summust exist; with neither, stop with U1. - Step 4: check each value against its
patternwith thegrep -Excommand of step 4, or by reading when the pattern uses syntaxgrep -Edoes not support; the whole value must match, not only a part of it. - Step 5: apply
## Recipe: renderinstead oftools/repo_kit.py render. When a value contains a character that recipe cannot render, stop with U13. When a kit file uses an undeclared placeholder, stop with U4 and the reasonkit <kind>: files/<file> uses undeclared placeholder <NAME>. - Steps 9 and 15: apply
## Recipe: statusinstead oftools/repo_kit.py status, with digests fromshasum -a 256orsha256sum. - Step 15: apply
## Recipe: stampinstead oftools/repo_kit.py stamp. - The skill changes no workspace file, so there is no workspace check to run.
04 同仓库更多 Skills
verify
Use when a change in __SERVICE__ must be checked before review
work-record
Use when you finished work on a tracker task and it must be recorded in the workspace through a merge request.
task-new
Use to create one story in a stream from the stream profile's story template, link it from its scope screens and open a merge request.
task-decompose
Use to split a stream at the decomposition stage into stories - list scope screens without a story, create the accepted stories and close the stage through a merge request.
task-context
Use to gather the context of a story key or a tracker id - its story, stream stage, scope screens, repositories, decisions, mockups and work records.
repos-sync
Use to update clones of your repositories under repos/ and see their branch, lag and uncommitted changes.