@a2f0/agent-tool 0.1.63 → 0.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/update-dependencies/SKILL.md +13 -6
- package/src/bun/execute.ts +11 -6
- package/src/permissions/install.ts +86 -39
- package/src/skills/bundled.ts +1 -1
- package/src/skills/install.ts +80 -48
- package/src/system/files.ts +34 -1
- package/src/system/manifestVersion.ts +29 -0
- package/src/workflows/pushGate.ts +9 -7
package/package.json
CHANGED
|
@@ -47,12 +47,19 @@ executable may capture it with `agent-tool --repo <checkout> run --label setup -
|
|
|
47
47
|
assume a sibling workspace exists. Verify the installed version afterward; if it
|
|
48
48
|
still differs, report the mismatch rather than deleting arbitrary dependencies.
|
|
49
49
|
|
|
50
|
-
After upgrading agent-tool, run the repository's skill/permission sync commands
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
After upgrading agent-tool, run the repository's skill/permission sync commands.
|
|
51
|
+
For each ownership manifest they do not refresh, run its installer directly:
|
|
52
|
+
`agent-tool skills install --harness <existing-scope> --apply` for
|
|
53
|
+
`.agent-tool-skills.json`, and
|
|
54
|
+
`agent-tool permissions install --harness <existing-scope> --apply` for
|
|
55
|
+
`.agent-tool-permissions.json`. Preserve each harness scope, and commit the
|
|
56
|
+
ownership manifests with any generated files.
|
|
57
|
+
The manifests record the agent-tool version, so every upgrade changes them, even
|
|
58
|
+
when no skill or rule changed, and `skills check` and `permissions check` fail
|
|
59
|
+
until the sync records the new version. Hermes reads the shared `.agents/skills`
|
|
60
|
+
in a trusted project; the installer does not grant trust. If discovery is
|
|
61
|
+
unavailable, read those files directly rather than silently using a stale global
|
|
62
|
+
copy.
|
|
56
63
|
|
|
57
64
|
## Nonblocking execution
|
|
58
65
|
|
package/src/bun/execute.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { accessSync, constants as files, existsSync,
|
|
2
|
+
import { accessSync, constants as files, existsSync, lstatSync, realpathSync, statSync } from "node:fs";
|
|
3
3
|
import { constants } from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { runCommand } from "../commands/run";
|
|
6
6
|
import { assert, flag, option } from "../workflows/core";
|
|
7
7
|
import { CLASSES } from "../permissions/catalog";
|
|
8
|
-
import {
|
|
8
|
+
import { checkRecordedPermissions, PERMISSIONS_MANIFEST } from "../permissions/install";
|
|
9
9
|
import { projectCommands } from "../permissions/project";
|
|
10
10
|
import { pinnedBun } from "./toolchain";
|
|
11
11
|
import { workspacePackage } from "../system/workspace";
|
|
@@ -21,13 +21,18 @@ const EXECUTABLE = /^[\w.+-][\w.+-]*$/;
|
|
|
21
21
|
* they are regenerated.
|
|
22
22
|
*/
|
|
23
23
|
function assertCurrentRules(root: string, command: string): void {
|
|
24
|
-
|
|
24
|
+
// Only a missing manifest means no rules; a link, even a dangling one, is refused by the check below.
|
|
25
|
+
try { lstatSync(path.join(root, PERMISSIONS_MANIFEST)); }
|
|
26
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") return; throw error; }
|
|
25
27
|
// Only a current allow class matches whatever rules exist; a removed or asking class relies on fresh ones.
|
|
26
28
|
const entry = projectCommands(root).find(item => item.command === command);
|
|
27
29
|
if (entry && CLASSES[entry.class].decision === "allow") return;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
30
|
+
// Check the harnesses the manifest records. Rule content decides: a manifest from another
|
|
31
|
+
// agent-tool release, or with no usable version, over current rules allows nothing extra.
|
|
32
|
+
const recorded = checkRecordedPermissions(root);
|
|
33
|
+
// The manifest was there a moment ago; fail closed rather than treat its absence as current rules.
|
|
34
|
+
assert(recorded, `${PERMISSIONS_MANIFEST} disappeared while checking the rules for '${command}'; rerun the command.`);
|
|
35
|
+
const stale = recorded.filter(item => item.status !== "unchanged" && item.path !== PERMISSIONS_MANIFEST);
|
|
31
36
|
assert(!stale.length, `Permission rules predate the current class of '${command}'; regenerate them with approval (agent-tool permissions install --apply) before running it.`);
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { chmodSync, existsSync, lstatSync, mkdirSync,
|
|
2
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { readRegularFile } from "../system/files";
|
|
5
|
+
import { AGENT_TOOL_VERSION, manifestVersionCheck, validVersion, type CheckStatus } from "../system/manifestVersion";
|
|
4
6
|
import { claudePermissions, codexRules, type CatalogEntry, type ClaudePermissions } from "./catalog";
|
|
5
7
|
import { projectCommands } from "./project";
|
|
6
8
|
|
|
7
|
-
const
|
|
9
|
+
export const PERMISSIONS_MANIFEST = ".agent-tool-permissions.json";
|
|
8
10
|
const CLAUDE_SETTINGS = ".claude/settings.json";
|
|
9
11
|
const CODEX_RULES = ".codex/rules/agent-tool.rules";
|
|
10
12
|
const HARNESSES = ["claude", "codex"] as const;
|
|
11
13
|
type Harness = typeof HARNESSES[number];
|
|
12
14
|
const hash = (source: string) => createHash("sha256").update(source).digest("hex");
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* What an install owns and the agent-tool version that wrote it. Manifests from releases before
|
|
18
|
+
* the version field lack it and stay readable; the field is additive, so `schemaVersion` stays 1.
|
|
19
|
+
*/
|
|
20
|
+
interface Manifest { schemaVersion: 1; agentToolVersion?: string; claude?: ClaudePermissions; codex?: { file: string; sha256: string } }
|
|
21
|
+
/** One reading of the manifest: its bytes, none without one, and its parsed contents. */
|
|
22
|
+
interface Recorded { raw?: string; manifest: Manifest }
|
|
15
23
|
export interface PermissionChange { path: string; status: "create" | "update" | "unchanged" }
|
|
16
|
-
|
|
24
|
+
/** One entry per generated file, then the manifest's own entry with its recorded and running versions. */
|
|
25
|
+
export interface PermissionCheck { path: string; status: CheckStatus; recordedVersion?: string | null; currentVersion?: string }
|
|
17
26
|
|
|
18
27
|
export function harnesses(target: string): Harness[] {
|
|
19
28
|
if (target === "all") return [...HARNESSES];
|
|
@@ -40,19 +49,28 @@ function atomicWrite(file: string, contents: string): void {
|
|
|
40
49
|
finally { try { unlinkSync(temporary); } catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; } }
|
|
41
50
|
}
|
|
42
51
|
|
|
43
|
-
function readManifest(root: string):
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
function readManifest(root: string): Recorded {
|
|
53
|
+
// One descriptor, refusing links, FIFOs, and devices, so a hook or CI can be neither redirected nor stalled.
|
|
54
|
+
const read = readRegularFile(destination(root, PERMISSIONS_MANIFEST));
|
|
55
|
+
if (read.status === "missing") return { manifest: { schemaVersion: 1 } };
|
|
56
|
+
if (read.status === "irregular") throw new Error(`Managed permissions manifest is not a regular file: ${PERMISSIONS_MANIFEST}`);
|
|
57
|
+
const raw = read.contents;
|
|
58
|
+
const parsed: unknown = JSON.parse(raw);
|
|
59
|
+
const object = (item: unknown): item is Record<string, unknown> => !!item && typeof item === "object" && !Array.isArray(item);
|
|
47
60
|
const strings = (items: unknown) => Array.isArray(items) && items.every(item => typeof item === "string");
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
// Present ownership entries must be well formed; a falsy one must not drop its harness from the check.
|
|
62
|
+
if (!object(parsed) || parsed.schemaVersion !== 1
|
|
63
|
+
|| (parsed.claude !== undefined && !(object(parsed.claude) && strings(parsed.claude.allow) && strings(parsed.claude.ask)))
|
|
64
|
+
|| (parsed.codex !== undefined && !(object(parsed.codex) && typeof parsed.codex.file === "string" && typeof parsed.codex.sha256 === "string" && /^[a-f0-9]{64}$/.test(parsed.codex.sha256)))) throw new Error("Invalid managed permissions manifest.");
|
|
65
|
+
const { agentToolVersion, ...value } = parsed as unknown as Manifest;
|
|
66
|
+
// The version is provenance, not ownership: an unusable one counts as none, which the check reports and the install replaces.
|
|
67
|
+
return { raw, manifest: { ...value, ...(validVersion(agentToolVersion) ? { agentToolVersion } : {}) } };
|
|
50
68
|
}
|
|
51
69
|
|
|
52
70
|
type Settings = Record<string, unknown> & { permissions?: Record<string, unknown> };
|
|
53
|
-
function
|
|
54
|
-
if (
|
|
55
|
-
const value = JSON.parse(
|
|
71
|
+
function parseSettings(source: string | undefined): Settings {
|
|
72
|
+
if (source === undefined) return {};
|
|
73
|
+
const value = JSON.parse(source) as unknown;
|
|
56
74
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${CLAUDE_SETTINGS} is not a JSON object.`);
|
|
57
75
|
const permissions = (value as Settings).permissions;
|
|
58
76
|
if (permissions !== undefined && (typeof permissions !== "object" || Array.isArray(permissions))) throw new Error(`${CLAUDE_SETTINGS} has an invalid permissions object.`);
|
|
@@ -82,11 +100,12 @@ function pending(root: string, targets: Harness[], manifest: Manifest, project:
|
|
|
82
100
|
return targets.map(harness => {
|
|
83
101
|
const relative = harness === "claude" ? CLAUDE_SETTINGS : CODEX_RULES;
|
|
84
102
|
const file = destination(root, relative);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
// One read of each destination serves both the merge and the comparison.
|
|
104
|
+
const read = readRegularFile(file);
|
|
105
|
+
if (read.status === "irregular") throw new Error(`Permissions destination is not a regular file: ${relative}`);
|
|
106
|
+
const current = read.status === "file" ? read.contents : undefined;
|
|
88
107
|
let contents: string;
|
|
89
|
-
if (harness === "claude") contents = `${JSON.stringify(mergedSettings(
|
|
108
|
+
if (harness === "claude") contents = `${JSON.stringify(mergedSettings(parseSettings(current), manifest.claude, claudePermissions(project)), null, 2)}\n`;
|
|
90
109
|
else {
|
|
91
110
|
contents = codexRules(project);
|
|
92
111
|
if (current !== undefined && current !== contents && hash(current) !== manifest.codex?.sha256) throw new Error(`Locally edited or unmanaged rules: ${relative}. Preserve them before installing.`);
|
|
@@ -95,43 +114,71 @@ function pending(root: string, targets: Harness[], manifest: Manifest, project:
|
|
|
95
114
|
});
|
|
96
115
|
}
|
|
97
116
|
|
|
117
|
+
/** Each generated file's change, then the manifest's, which every new agent-tool release updates. */
|
|
98
118
|
export function installPermissions(rootDir: string, target: string, apply = false): PermissionChange[] {
|
|
99
119
|
const root = realpathSync(rootDir);
|
|
100
|
-
const manifest = readManifest(root);
|
|
120
|
+
const { raw: recorded, manifest } = readManifest(root);
|
|
101
121
|
const project = projectCommands(root);
|
|
102
122
|
const changes = pending(root, harnesses(target), manifest, project);
|
|
123
|
+
// Recording the version makes every upgrade change the manifest, so a committed sync is visible.
|
|
124
|
+
const { schemaVersion: _schema, agentToolVersion: _version, ...owned } = manifest;
|
|
125
|
+
const next: Manifest = { schemaVersion: 1, agentToolVersion: AGENT_TOOL_VERSION, ...owned };
|
|
126
|
+
for (const change of changes) {
|
|
127
|
+
if (change.harness === "claude") next.claude = claudePermissions(project);
|
|
128
|
+
else next.codex = { file: change.relative, sha256: hash(change.contents) };
|
|
129
|
+
}
|
|
130
|
+
const manifestFile = destination(root, PERMISSIONS_MANIFEST), contents = `${JSON.stringify(next, null, 2)}\n`;
|
|
131
|
+
const manifestStatus: PermissionChange["status"] = recorded === contents ? "unchanged" : recorded === undefined ? "create" : "update";
|
|
103
132
|
// Every destination is validated before any file is written.
|
|
104
133
|
if (apply) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
if (change.status !== "unchanged") atomicWrite(change.file, change.contents);
|
|
108
|
-
if (change.harness === "claude") next.claude = claudePermissions(project);
|
|
109
|
-
else next.codex = { file: change.relative, sha256: hash(change.contents) };
|
|
110
|
-
}
|
|
111
|
-
atomicWrite(destination(root, MANIFEST), `${JSON.stringify(next, null, 2)}\n`);
|
|
134
|
+
for (const change of changes) if (change.status !== "unchanged") atomicWrite(change.file, change.contents);
|
|
135
|
+
if (manifestStatus !== "unchanged") atomicWrite(manifestFile, contents);
|
|
112
136
|
}
|
|
113
|
-
return changes.map(({ relative, status }) => ({ path: relative, status }));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** The `--harness` a repository's rules were installed for, from its manifest, or null when it has none. */
|
|
117
|
-
export function installedPermissionHarness(rootDir: string): string | null {
|
|
118
|
-
const root = realpathSync(rootDir);
|
|
119
|
-
if (!existsSync(destination(root, MANIFEST))) return null;
|
|
120
|
-
const manifest = readManifest(root);
|
|
121
|
-
return manifest.claude && !manifest.codex ? "claude" : manifest.codex && !manifest.claude ? "codex" : "all";
|
|
137
|
+
return [...changes.map(({ relative, status }) => ({ path: relative, status })), { path: PERMISSIONS_MANIFEST, status: manifestStatus }];
|
|
122
138
|
}
|
|
123
139
|
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
const root = realpathSync(rootDir);
|
|
127
|
-
const manifest = readManifest(root);
|
|
140
|
+
/** Each generated file, then the manifest's own entry, against one reading of the manifest. */
|
|
141
|
+
function checks(root: string, targets: Harness[], { raw, manifest }: Recorded): PermissionCheck[] {
|
|
128
142
|
const project = projectCommands(root);
|
|
129
|
-
|
|
143
|
+
const files = pending(root, targets, manifest, project).map((change): PermissionCheck => {
|
|
130
144
|
if (change.status === "create") return { path: change.relative, status: "missing" };
|
|
131
145
|
if (change.status === "update") return { path: change.relative, status: "outdated" };
|
|
132
146
|
const managed = change.harness === "claude" ? JSON.stringify(manifest.claude) === JSON.stringify(claudePermissions(project)) : manifest.codex?.sha256 === hash(change.contents);
|
|
133
147
|
return { path: change.relative, status: managed ? "unchanged" : "unmanaged" };
|
|
134
148
|
});
|
|
149
|
+
return [...files, manifestVersionCheck(PERMISSIONS_MANIFEST, raw !== undefined, manifest.agentToolVersion)];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Read-only CI gate: generated rules are current, recorded as managed, and by the running version. */
|
|
153
|
+
export function checkPermissions(rootDir: string, target: string): PermissionCheck[] {
|
|
154
|
+
const root = realpathSync(rootDir);
|
|
155
|
+
return checks(root, harnesses(target), readManifest(root));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The push gate's check, or null without a manifest: the `--harness` the rules were installed
|
|
160
|
+
* for, from the manifest, and its check, from one reading of the manifest.
|
|
161
|
+
*/
|
|
162
|
+
export function checkInstalledPermissions(rootDir: string): { harness: string; changes: PermissionCheck[] } | null {
|
|
163
|
+
const root = realpathSync(rootDir);
|
|
164
|
+
const recorded = readManifest(root);
|
|
165
|
+
if (recorded.raw === undefined) return null;
|
|
166
|
+
const { claude, codex } = recorded.manifest;
|
|
167
|
+
const harness = claude && !codex ? "claude" : codex && !claude ? "codex" : "all";
|
|
168
|
+
return { harness, changes: checks(root, harnesses(harness), recorded) };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* `bun x`'s check, or null without a manifest: only the harnesses whose rules the manifest
|
|
173
|
+
* records, none when it records none, then the manifest's own entry, from one reading of it.
|
|
174
|
+
* Rules no manifest records are the user's by the installer's ownership contract (an install
|
|
175
|
+
* keeps them), so they are not judged here, as before the version field.
|
|
176
|
+
*/
|
|
177
|
+
export function checkRecordedPermissions(rootDir: string): PermissionCheck[] | null {
|
|
178
|
+
const root = realpathSync(rootDir);
|
|
179
|
+
const recorded = readManifest(root);
|
|
180
|
+
if (recorded.raw === undefined) return null;
|
|
181
|
+
return checks(root, HARNESSES.filter(harness => recorded.manifest[harness] !== undefined), recorded);
|
|
135
182
|
}
|
|
136
183
|
|
|
137
184
|
export function showPermissions(rootDir: string, target: string): string {
|
package/src/skills/bundled.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const BUNDLED_SKILLS: Readonly<Record<string, string>> = {
|
|
|
7
7
|
"reset": "---\nname: reset\ndescription: Return a clean checkout to its updated default branch after confirmed shipping or an explicit checkout cleanup request.\n---\n\n# Reset\n\nThis is checkout cleanup, not a destructive Git reset. Read repository guidance\nfor setup and hooks. Determine the default branch through the repository's\nremote metadata rather than assuming main.\n\nFor post-merge cleanup, preview with\n`agent-tool repo cleanup <PR-number> <shipped-head>`, then run it with `--apply`\nwithin the authorized cleanup scope. It requires a confirmed MERGED PR, refuses\nthe default and `branch.exempt` branches, preserves local edits, checks exact\nlocal/remote feature commits, verifies the merge is on the default branch, and\nfast-forwards that branch. By default it prunes the\nshipped local feature branch and deletes the matching remote branch if present.\nLocal pruning also applies after a squash merge or when GitHub already deleted\nthe remote branch; a missing remote is not evidence that local cleanup is done.\nPass `--keep-branch` when the user asked to preserve both feature refs.\nRead the receipt's completed steps if a later operation fails; do not claim full\ncleanup from a partial result. Verify the final branch and clean worktree, and\ncheck that `git branch --list <feature-branch>` is empty unless keeping the branch.\nIf the feature branch is checked out in another worktree, shared cleanup reports\na partial failure after updating the default branch and leaves both feature refs\nin place; preserve that worktree and report the remaining cleanup.\n\nRemote branch deletion uses GitHub REST after checking the live ref to avoid\npre-push hooks. The API has no atomic expected-OID delete guard; the check and\ndeletion retain a small concurrent-update window. Fork PRs require manual remote\nhandling and are refused by the shared cleanup command.\nUse a repository's stronger cleanup procedure when required, including atomic\nremote deletion or additional local verification; do not weaken it to use the\nshared command. The same local pruning and keep-branch outcomes still apply.\n\nFor an explicit checkout cleanup without a merged PR, preserve all feature refs:\ncheck worktree/index, resolve the default branch with `repo context`, fetch it,\nswitch, and update by fast-forward only. Never discard or automatically stash\nedits, force a diverged default branch, or infer shipping from Git ancestry after\na squash merge.\n\nRun `agent-tool teardown` and stop what the finished work left running\n(`teardown --apply` for recorded processes); report anything that remains.\nRun the repository's documented dependency/hook setup if required. When copied\nhooks are configured, use `agent-tool hooks check` and `hooks install --apply`;\ninspect unmanaged hooks before an explicit `--adopt`, which backs them up.\nDo not assume a package manager. Report final branch, commit, whether the shipped\nlocal branch was pruned or preserved, and unfinished cleanup or setup.\n",
|
|
8
8
|
"ship-pr": "---\nname: ship-pr\ndescription: Complete an authorized commit, independent review, repair, PR, CI, and squash-merge workflow for a GitHub repository.\n---\n\n# Ship PR\n\nUse the installed `agent-tool`. Read repository guidance and policy first;\nvalidation, versioning, package management, and hook bodies remain project\nconcerns. Use shared branch, hook, check, cleanup, and release commands where\nconfigured; keep application-specific commands in repository guidance. Shipping authorizes this workflow within the user's stated scope.\nPreserve unrelated edits and honor requested stopping points such as open-PR\nonly, report-only review, or keeping the feature branch.\n\nUse `agent-tool run --label <check> -- <command> [args...]` for noisy setup,\nvalidation, builds, and hook-running Git commands. It preserves exit status and\ncomplete private logs, prints one success receipt, and shows a bounded failure\ntail. Inspect more with `agent-tool logs <log> --max-bytes 8192 --tail-lines 80`\nor a targeted search; never dump an entire suite log or pipe checks into `tail`.\nThe receipt proves process completion, not absence of warnings: inspect required\nwarning, coverage, timing, or artifact evidence before accepting a check. Keep\nmachine-readable receipts and review findings visible by running `versions\nprepare`, `review`, `repo base-health`, and other commands whose output drives a\ndecision directly. Prefer documented compact test reporters when they preserve\nrequired evidence; do not reduce test scope, skip checks, silence warnings, or\nmask failures. Start servers, watchers, and other long-running processes with\n`agent-tool proc start --label <name> -- <command>`, never a backgrounded shell\ncommand, so they can be found and stopped.\n\n1. Start from the base branch's health: `agent-tool repo base-health` (with\n `--branch <base-branch>` for another base). `green`, `pending`, and `no-ci`\n need nothing more; report `no-ci` as missing CI on pushes. When it is\n `red`, read the failing jobs' logs (`gh run view <run-id> --log-failed`\n through `agent-tool run`) and relate them to the merges in\n `breakingRange`. Broken logic from combined merges: fix it and add the test\n that would have caught the combination. A flaky or timing-dependent test:\n remove the race, ordering dependence, or shared state. Infrastructure or an\n outside service: record it; rerun only when the log shows the cause was\n external. Never retry until green, skip, or loosen an assertion. When\n `openRepairs` lists a PR, do not duplicate it. Otherwise ship the repair\n through this workflow as its own PR, naming the failing run in its body,\n ahead of the requested change; when the change touches the same code, make\n the repair a separate commit in that PR and say so in its description. A\n red base does not block an unrelated change; stop only when the change\n cannot be validated without the repair. A PR failure with the same job and\n error as on the base is repaired on the base. Reverting the breaking merge\n is allowed when the fix is not small and the break blocks a deploy or\n publish; the revert names the merge and the follow-up that restores it.\n2. Finish the requested change on a feature branch. Use\n `agent-tool branch create <branch> --base <base-branch> --remote <remote>`\n from a clean checkout; it fetches and pins the base, checks naming policy and\n collisions, and creates without a local upstream. Use `branch check` with\n explicit destination names in CI or hooks. Before pushing, validate with the\n repository's push gate and the tests that target the changed code, not the\n full suite: CI runs everything and is the authority. Commit only the\n intended files.\n3. Use `agent-tool repo context --fetch` to resolve the PR's base repository\n and branch, or the default branch when no PR exists, and fetch its exact base.\n Record the returned base/head identities. Integrate the fetched base\n using the repository's normal workflow, resolving conflicts without losing\n user work. If project policy versions packages, prepare versions against the\n pinned base after every integration or repair and before each review, using\n the project's commands or `agent-tool versions prepare <base-oid>`, which\n commits bumped manifests and the refreshed lockfile.\n `agent-tool versions resolve-conflicts` resolves conflicts confined to\n version fields. Review the resulting committed HEAD with an independent\n reviewer using the bundled cross-agent-review skill. Repair blocking findings\n and review every changed HEAD again. Review failure blocks shipping. One\n change keeps a review: after a clean review, a new HEAD that only integrated\n the base and prepared versions (as when another PR took the same version\n first). When `agent-tool review carry <reviewed-head> <new-head>` exits 0\n with `ok: true`, the earlier clean review stands, and the new HEAD is the\n reviewed head from then on; report the review as carried, giving the\n reviewed head and the command's JSON output. Every other changed HEAD,\n including one the command rejects, gets an independent review, and CI\n still runs on the new HEAD.\n4. Run `agent-tool branch push <reviewed-head> --remote <remote>` through\n normal hooks; it verifies local and remote identity afterward. If a hook\n changed content or HEAD, review that result.\n Open the PR using the open-pr skill, or update the existing PR as needed.\n5. Allow configured review bots time to respond, then use\n `agent-tool pr threads list` to fetch review threads and all comments. Follow repository policy for feedback: fix valid findings,\n reply with `pr threads reply <comment-id>` (body file or stdin), and use\n `pr threads resolve <thread-id>` only for fully addressed findings.\n Validate, commit, push, and independently review every feedback or CI repair.\n Wait with `agent-tool pr checks --wait --head <reviewed-head>`, whose limit\n defaults to `agent-tool.json` `merge.checksTimeoutSeconds`. When a job\n fails, read its log with `agent-tool pr logs --head <reviewed-head>`, fix it\n in a new commit, review it, push, and wait on the new head. A base that\n moved (`behind: true`) needs no integration unless GitHub reports a\n conflict, `versions check` fails against the live base, or the repository\n sets `merge.requireStrictBaseFreshness`; under that policy the wait stops\n early, so cancel the stale head's CI with\n `agent-tool pr cancel-runs --head <reviewed-head>`, then integrate,\n validate, review (or carry the review, as in step 3), push, and wait again.\n Then run\n `agent-tool pr preflight <reviewed-head> <base-branch> <reviewed-base>` to\n recheck CI, conflicts, the live base, PR identity, local state, and explicit\n version policy. When versions are managed,\n `agent-tool versions check <live-base-oid>` must pass. Use the squash-merge\n skill to merge the exact reviewed HEAD.\n6. After confirmed MERGED, follow the reset skill: run\n `agent-tool repo cleanup <PR-number> <reviewed-head> --apply` to return to the\n updated default branch and prune the shipped feature branch, honoring\n stronger repository cleanup rules. Never prune with raw `git branch -D` or\n `git push --delete`: the cleanup command checks the merge and both refs\n first, and harness command guards prompt for raw force deletes. If the user requested keep-branch, preserve\n both feature refs. Check the cleanup receipt and verify the local feature ref\n is absent unless preserved; report incomplete cleanup explicitly. Apply\n documented dependency/hook setup.\n7. When the project publishes npm packages, use `agent-tool release verify\n <package> <version> <merge-oid> --workflow <publish-workflow>` to verify the\n exact workflow and tarball, allowing registry propagation time. When the\n project deploys the merged branch, verify that deployment and documented\n live checks. Report deployment failures\n separately from a successful merge; follow project policy for repairs. A\n release that fails because another merge published the same version needs\n a follow-up version bump through this workflow.\n8. Run `agent-tool repo base-health` again until it is no longer `pending` and\n the merge commit, or a newer tip, has runs (`tip.hasRuns`). When no run\n starts within about ten minutes, as with path filters or PR-only CI, or the\n status is `no-ci`, report that and stop waiting. A failure there belongs to\n this session: fix it forward through this workflow before reporting the\n work done.\n\nBefore the final report, run `agent-tool teardown` in each repository this work\ntouched. Stop what the work started (`teardown --apply`, `proc stop`), stop any\nuntracked process it started, and remove worktrees it added. Report what\nremains and why; the work is not done while teardown fails for anything it\nstarted.\n\nNever infer a clean review from process success alone, or carry a review to a\nHEAD that `review carry` does not accept. Do not weaken configured CI policy to\nget a merge through. If a step fails, preserve useful intermediate work and report the concrete\nremaining issue. Report PR link, merged commit, review verdict, validation, final\ncheckout state, the base's health at the start and end and anything repaired or\nhardened, the teardown result, and whether the shipped local branch was pruned\nor preserved.\n",
|
|
9
9
|
"squash-merge": "---\nname: squash-merge\ndescription: Squash-merge a reviewed GitHub pull request while binding the mutation to the reviewed commit and checking CI.\n---\n\n# Squash Merge\n\nUse the installed `agent-tool` and repository merge policy. Merge only within\nthe user's authorized scope. Have the exact reviewed HEAD, base commit, and base\nbranch available, and read the verdict and unresolved findings. BLOCKER or MAJOR\nfindings require repair and a new review before merging.\nFollow the repository's review-bot policy and require all actionable blocking\nreview feedback to be addressed before merging.\n\nWait with `agent-tool pr checks --wait --head <reviewed-head>`, which waits for\nchecks to appear and for every workflow/job/event entry to finish, and reports\n`behind: true` when the live base has moved past the head. A moved base alone\nneeds no integration: integrate, validate, review, and push again only when\nGitHub reports a conflict, when `versions check` fails against the live base,\nor when the repository sets `merge.requireStrictBaseFreshness`. Under that\npolicy the wait stops early at `behind: true`; cancel that head's runs with\n`agent-tool pr cancel-runs --head <reviewed-head>` first. Run\n`agent-tool pr preflight <reviewed-head> <base-branch> <reviewed-base>` immediately\nbefore merging. It checks local and PR identity, that the head contains the\nreviewed base, conflicts and merge readiness, explicit version policy against\nthe live base, configured strict rulesets, and passing checks; under the strict\npolicy the live base must also equal the reviewed one. If an identity changed,\nrefresh, integrate, validate, and review again; a new HEAD that\n`agent-tool review carry <reviewed-head> <new-head>` accepts keeps the earlier\nclean review. Read unresolved feedback with `pr threads list` and follow\nproject review policy.\n\nUse a title that satisfies `agent-tool.json` and pass both reviewed HEAD and\nbase branch:\n\n```sh\nagent-tool pr merge 'feat: describe the change' <reviewed-head-oid> <base-branch>\n```\n\nThe helper enforces HEAD atomically through GitHub's `expectedHeadOid`, checks\nCI, rejects queued or automatic merges, and creates a subject-only squash with\nthe PR reference. GitHub has no atomic expected-base argument in this mutation,\nso a base can move between preflight and merge; without the strict policy that\nis accepted, and a break the combination causes is repaired on the base. With\n`merge.requireStrictBaseFreshness`, the helper refuses to merge unless an\nactive strict status ruleset that the actor cannot bypass protects the base. Do\nnot retarget the PR concurrently with merging.\n\nConfirm GitHub reports MERGED before any cleanup. A failed or uncertain mutation\nis not evidence of a merge. Preserve the branch on failure. After a confirmed\nmerge, perform checkout cleanup only when requested or as part of an authorized\nshipping workflow, with `agent-tool repo cleanup <PR-number> <reviewed-head>\n--apply` rather than raw `git branch -D`. Report the PR and merge result.\n",
|
|
10
|
-
"update-dependencies": "---\nname: update-dependencies\ndescription: Update dependencies or update everything in a repository, including runtimes, tools, and CI pins, with compatibility checks and safe previews; ship through review, CI, merge, and release verification unless a narrower scope is requested.\n---\n\n# Update Dependencies\n\nUse the repository's package managers and installed `agent-tool`. Read `AGENTS.md`,\nREADME, existing dependency-maintenance notes, linked setup/release documents,\nand repository-owned upgrade skills before editing. Follow their hooks, version\npolicy, checks, and requested stopping point.\nUpdate applicable dependencies throughout the repository, including workspaces\nand examples. When asked to perform dependency updates, invoke the installed\n[`ship-pr`](../ship-pr/SKILL.md) to complete review, PR, CI, and merge, then verify\nthe repository's normal merge-triggered publication or deployment. An explicit\nnarrower scope, such as inventory-only, local changes, or open-PR-only, takes\nprecedence. This default does not authorize standalone infrastructure applies,\ndeployments, or global tool changes. Default dependency-update merge subject:\n`chore: update dependencies`, subject to repository title policy and any explicit\nuser subject.\n\nRun noisy installs, checks, tests, and builds with\n`agent-tool run --label <check> -- <command> [args...]` to retain full private\nlogs and return the original status with compact output. Inspect bounded excerpts\nusing `agent-tool logs <log>` and targeted searches for warnings and evidence;\na successful receipt does not establish a warning-free upgrade. Keep structured\naudit/plan results, deployment previews, and review findings directly visible\nwhen they drive a safety decision. Do not dump full suite logs into context,\nsilence warnings at their source, or change check scope to reduce output.\n\n## Checkout setup\n\nThis shared workflow also handles natural-language requests to \"update everything\".\nIf the repository owns an `update-everything` wrapper, read and follow its extra\nrequirements; do not create an alias or overwrite that skill. The workflow works\nfrom a standalone checkout with no workspace coordinator.\n\nAfter a fetch, branch integration, or dependency pin change, check that the local\n`agent-tool --version` matches the repository's declared pin before trusting its\ncommands or generated skills. A stale CLI can reject newer configuration keys.\nAfter screening install scripts and hooks as below, run the documented frozen\ninstall with the repository's pinned runtime. For Bun projects, an already working\nCLI can run `agent-tool bun install`; if it is missing or cannot parse the new\nconfig, run the documented package-manager install directly. A known working\nexecutable may capture it with `agent-tool --repo <checkout> run --label setup --\n<install-command> [args...]`. Do not fetch an unpinned CLI, alter global tools, or\nassume a sibling workspace exists. Verify the installed version afterward; if it\nstill differs, report the mismatch rather than deleting arbitrary dependencies.\n\nAfter upgrading agent-tool, run the repository's skill/permission sync commands\n(or `agent-tool skills install --harness <existing-scope> --apply`), preserve its\nharness scope, and commit ownership manifests with generated files. Hermes reads\nthe shared `.agents/skills` in a trusted project; the installer does not grant\ntrust. If discovery is unavailable, read those files directly rather than silently\nusing a stale global copy.\n\n## Nonblocking execution\n\nUse the harness's managed background execution for long finite checks, reviews,\npush hooks, CI waits, and release verification; request completion notification\nwhen available and retain its process handle plus agent-tool's log/receipt path.\nRun `run-group` and reviews directly so their reports remain visible. A started\nprocess is not a passed check: read its final status and required evidence before\nshipping, and do not repeatedly poll when completion events are available.\nWithout harness background support, `proc start --label <name> -- agent-tool run\n--label <check> -- <command> [args...]` records the outer process and captures\nits output; inspect `proc list` and `logs` plus the inner run receipt to establish\ncompletion and exit status. An exited process record alone does not prove success.\nUse `proc stop`/`teardown` for owned leftovers; never stop another session's work.\nThese commands need no matrix workspace or global configuration change.\n\nKeep independent compatibility groups moving while a producer release or an\nexternal gate is pending. Only final adoption of that exact published release\nmust wait. Bound CPU/process-heavy concurrency to the machine's available budget;\na failed full suite needs diagnosis and a full-scope rerun, not larger timeouts,\nfewer assertions, or a focused retry presented as suite recovery. Background\nexecution never bypasses an approval, a deployment preview, or exact-head review.\n\n## Safety before execution\n\n**Always dry-run before any infrastructure apply or deployment. Never destroy,\nreplace, or recreate a resource during an upgrade.** This includes Terraform,\nOpenTofu, Wrangler, Ansible, other infrastructure tools, and effects triggered by\ninstallation, tests, hooks, Git push, opening a PR, CI, or merging. Greenfield\nprojects and approval to ship do not waive this rule.\n\nBefore running project commands or pushing, trace their scripts, hooks, workflow\ntriggers, reusable workflows, and deployment commands. A dry-run flag alone is\ninsufficient: inspect tasks, provisioners, plugins, external programs, and actions\nthat can mutate despite preview mode. Avoid such a preview unless its effects\nare proven read-only. Do not run destroy/delete, taint/replace, state removal,\nbackend migration, forced database reset, or an automatic \"repair\" that bypasses\nthe rule. Do not hide destruction with targeting, disabled refresh, ignored\nchanges, new resource identities, or weakened policy.\n\nPreview with the proposed versions and complete configuration for each affected\nenvironment, using its real backend/workspace/account, variables, inventory, and\nresource identities. An empty local state, mocked credentials, validate-only run,\nor bundle build cannot establish safety for production. Check the current baseline\nas well when needed to distinguish existing drift from the upgrade. Keep state,\nbinary plans, JSON plans, and secret-bearing diffs out of Git and public reports.\n\nIf a preview proposes deletion or replacement, fails, is incomplete, omits\naffected resources, or cannot establish safety, skip that dependency and its\ncoupled migrations. Restore only this task's edits to the affected compatibility\ngroup, retain independent safe upgrades, and record the reason and affected\nresources. Never apply to find out. A preview is not deployment authorization.\n\nBefore an authorized apply/deploy, verify the exact validated commit, toolchain,\nconfiguration, environment, and current state still match the preview. Re-preview\nafter relevant changes or drift. CI must enforce the same order and stop on an\nunsafe preview before mutation; a successful local preview does not excuse an\nunguarded push- or merge-triggered deployment. Establish a narrowly scoped guard\nwhen authorized and reviewable, or hold the affected upgrade before triggering\nthat workflow. Do not disable protections to ship. A plan must be inspected before\nthe operation; inspecting deployment logs afterward is too late.\nAn unsafe workflow triggered on every branch push also blocks pushing otherwise\nindependent upgrades until that trigger has a proven safe guard.\n\n### Terraform and OpenTofu\n\nRead core, provider, and module upgrade guides, including intermediate major\nmigrations. Regenerate provider locks with the pinned CLI, preserving supported\nplatform hashes. Backend initialization/migration is also subject to the safety\ngate. Inspect external data programs and provisioners before planning.\n\nUse a full refreshed saved plan with locking and the real variables, for example\n`terraform plan -input=false -out=<private-plan>`; if using `-detailed-exitcode`,\n0 and 2 are success, 1 is failure. Inspect `terraform show -json <private-plan>`.\nRun `agent-tool dependencies check-terraform-plan <private-plan.json>` to check\nsupported JSON resource actions. It fails for every action containing `delete`,\nincluding both replacement orders, unknown actions, incomplete/deferred plans,\nfailed checks, or opaque provider action invocations. It prints actions and\ndiagnostics without resource attribute values; it does not prove that a plan is\nfresh, comprehensive, authentic, or that provider code has no hidden effects.\nOlder/unsupported plan formats that cannot establish completeness are skipped.\nOpenTofu currently omits `complete` in its JSON format and is rejected by this\nhelper; report that limitation rather than adding a synthetic completeness flag.\nAlso inspect resource identity, drift, warnings, provider semantics, and any\neffects outside resource actions. For an authorized apply, consume the exact\napproved saved plan, not an uninspected newly generated plan.\n\nSource: [Terraform JSON plan format](https://developer.hashicorp.com/terraform/internals/json-format).\n\n### Wrangler and other deployment tools\n\nUse the proposed pinned Wrangler for `wrangler deploy --dry-run` with the same\nbuild/configuration/environment used by deployment. This checks bundling, not a\ncomplete remote resource plan. Separately verify account, worker name, routes,\nbindings and resource IDs against the existing deployment and read migration\nsemantics. Review Durable Object deleted/renamed classes, D1 schema/data\nmigrations, storage resources, queues, containers, and deployment integrations.\nNever infer \"no destruction\" from a successful bundle. Resource removals,\nreplacement, or unprovable remote effects skip the affected group. Apply the\nequivalent preview and identity checks to other tools rather than assuming they\nshare Terraform's guarantees.\n\nDo not assume `wrangler d1 migrations list --remote` is read-only. The\nimplementation inspected for this skill initializes migration tracking with\n`CREATE TABLE IF NOT EXISTS`; verify the pinned Wrangler version before using\nthe command. Verify database identity and compare migration files with the\ndatabase's configured migration tracking table through audited read-only\nqueries. A missing table, pending migration, or unverifiable schema/data\neffects hold the affected upgrade/deployment group. Never initialize schema\nmerely to establish preview safety.\n\nWrangler runs a custom `build.command` again during deployment. Use supported\nconfiguration referencing the same validated artifacts for both preview and\ndeployment, preventing another unvalidated build before upload. Bind the\nartifacts, configuration, and pinned tool to the authorized commit, and recheck\ntheir identities before upload and after relevant changes. Hold the affected\ngroup if the pinned Wrangler cannot upload the validated output without\nrebuilding it, or if the upload cannot be proven to match the preview.\n\nSources: [Wrangler command documentation](https://developers.cloudflare.com/workers/wrangler/commands/),\n[D1 migration listing implementation](https://github.com/cloudflare/workers-sdk/blob/e3d186776fcc2e4b5cc4cfd7155591778a375957/packages/wrangler/src/d1/migrations/list.ts),\n[migration table initialization](https://github.com/cloudflare/workers-sdk/blob/e3d186776fcc2e4b5cc4cfd7155591778a375957/packages/wrangler/src/d1/migrations/helpers.ts),\nand [Wrangler custom builds](https://developers.cloudflare.com/workers/wrangler/custom-builds/).\n\n### Ansible\n\nCheck controller Python, ansible-core, collections/roles, and target Python support\ntogether; read porting guides. Inspect all tasks and invoked scripts before\n`ansible-playbook --check --diff` with the real inventory and variables.\n`check_mode: false` forces mutation even with `--check`; unsupported modules and\nconditions based on registered results can omit effects. Inspect deletion,\nrecreation, service/data reset, and package removal semantics beyond the diff.\nSkipped or opaque tasks are a safety gap, not a clean preview. Redact diffs.\n\nSource: [Ansible check mode limits](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_checkmode.html).\n\n## Inventory and choose compatible targets\n\nRecord each dependency source, current resolved version, latest stable candidate,\nselected target, compatibility constraints, upstream migration links, and checks\nin the run ledger described under Report.\nQuery authoritative registries, official releases, support matrices, and migration\nguides at execution time; do not treat remembered versions or prereleases as\nlatest stable. Inspect runtime requirements, peer dependencies, ABI/API changes,\nplatform availability, maintained release lines, and changed defaults, including\nsecurity, privacy/telemetry, data retention, and postinstall/native behavior.\nCheck transitive dependencies' peer/runtime constraints as well as direct ones. Unsupported\nor unpublished targets stay pinned with an explanation.\n\nInventory manifests, locks, tool configuration, CI/reusable actions, containers,\nscripts, deployment files, and executable documentation. Search duplicate version\npins and aliases, not just filenames; exclude vendored/generated snapshots unless\nthe repository owns their update process. Examples of sources to inspect:\n\n| Ecosystem | Sources and compatibility group |\n| --- | --- |\n| JavaScript/TypeScript | All package.json dependency fields, overrides/resolutions, workspace catalogs, packageManager/engines, npm/Bun/pnpm/Yarn locks, Node/Bun pins, compiler and lint/build/test plugins |\n| Toolchains | mise.toml/.mise.toml, mise.lock, .tool-versions, runtime version files, tool URLs/checksums, CI pins and container images; include every tool declared by mise, not just mise itself |\n| Python/Ansible | pyproject/requirements, uv/Poetry/pip locks, Python pins, ansible-core, collection/role requirements, lint plugins and managed host constraints |\n| Ruby/iOS | .ruby-version, Gemfile/lock, Bundler, CocoaPods, Podfile/lock, podspecs, Swift packages and Xcode/iOS deployment requirements |\n| Infrastructure | Terraform/OpenTofu CLI constraints, provider locks/constraints, module versions/Git refs, Wrangler and Cloudflare integration dependencies |\n| CI/system/native | Actions/reusable workflow refs, Docker tags/digests, OS images/packages, Rust/Cargo toolchain and locks, Go modules, Gradle/AGP/Kotlin/JDK and other repository-specific manifests |\n\nBuild connected compatibility groups before editing. Select the newest supported\ncombination, which can be older than an individual package's latest. Upgrade the\nframework first or keep its compatible toolchain pinned; do not force peer\nresolution, drop compatibility checks, or add blanket overrides to make installs\npass. Preserve source pin policy (exact version, digest, full Git SHA) and resolve\nimmutable pins from verified upstream releases. Preserve intentional runtime\nminimums unless migration requires changing the support contract.\n\nFor React Native, use its version-specific upgrade guide/template diffs and\nrepository upgrade skills. Couple React and its renderer, native modules,\nMetro/Babel, CLI, codegen, Hermes/New Architecture, CocoaPods/Bundler/Ruby,\nXcode/iOS deployment targets, and Android Gradle/AGP/Kotlin/JDK/SDK/NDK. For Expo,\nuse the chosen SDK's supported React Native/dependency matrix and its dependency\nchecks. Do not independently update framework-managed pods or generated native\nfiles; use the framework's regeneration workflow and prove iOS/Android builds.\nPermissive peer ranges alone do not prove native renderer or toolchain compatibility;\ncheck the framework's actual supported versions and native implementation.\nAn unavailable native toolchain is a reported validation limit; do not claim the\ngroup verified. See [React Native upgrading](https://reactnative.dev/docs/upgrading).\n\nCheck developer tools' own dependencies too: a compiler release without its old\nprogrammatic API may break test/lint runners that import it even when `tsc` passes.\nAction runtime upgrades can require newer self-hosted runners; preserve workflow\npermissions, action inputs/outputs, caching, artifact semantics, and job names.\n\nCheck current advisories with read-only ecosystem audits against the baseline and\nproposed lockfiles, using the repository's configured registry/advisory sources.\nDo not send private dependency metadata to an unconfigured or unauthorized service;\nreport the resulting coverage limit. Cover direct and resolved transitive dependencies,\nincluding native/platform-specific binaries. Latest direct packages can still\npin vulnerable transitive versions. Trace each finding to its owning dependency,\nverify affected versions, runtime conditions, and remediation in the maintainer's\nadvisory and fixed release. When the owner's range permits a fixed version, use a\ntargeted refresh with the lockfile's owning manager and preserve unrelated\nresolutions; otherwise prefer a supported owner upgrade.\nIf the owner still pins a vulnerable version, a narrowly scoped security patch\noverride may be used only with API/ABI/runtime compatibility evidence and focused\nregression checks of the actual affected integration. Document its rationale and\nremoval condition; a passing install or bundle alone is insufficient. Do not run\nblind audit fixes or use blanket overrides to bypass compatibility constraints.\nReport unresolved advisories and unavailable audit coverage accurately; current\ndirect pins or a partial clean audit do not\nestablish that the whole dependency graph is safe.\n\n## Migrate and validate\n\nCapture relevant baseline checks and warnings first, after screening their side\neffects. Update one compatibility group at a time. Read the upstream instructions\nfor every breaking step; implement required source/config/schema migrations and\nremoved API replacements. Use the manager that owns each lockfile, on the selected\nruntime, and inspect the resulting diff. For Bun lockfiles, change declared\nversions with `agent-tool bun update <name[@version]>` and drop packages with\n`agent-tool bun remove <name>`; both use the pinned Bun and refuse to add a\npackage. A new dependency goes through `agent-tool bun add <name@version>`, which\nasks for approval; never introduce one by editing `package.json` and\nreinstalling. For existing Bun catalog entries use\n`agent-tool bun update --catalog default <name@version>...` (or the existing named\ncatalog). Name an explicit exact/ranged registry spec; keep `catalog:` references,\nworkspace membership, other entries, and peer compatibility contracts intact.\nThe helper refuses intake and ambiguous layouts and uses the owning manager to\nrefresh the lock; do not replace catalog references with direct versions.\n\nFor an already-resolved transitive registry package with an eligible owner range,\nuse `agent-tool bun update --resolved <name>...` with the owning Bun 1.4.4 or newer.\nIt selects every locked copy of those names, never a requested version or glob,\nand accepts only a result with identical manifests and unchanged non-target lock\nentries/metadata. It preserves release-age, overrides and patches. If an older\nmanager is pinned, or a required new child prevents a target-only result, this\npath is unsupported: prefer an owning-dependency upgrade through the normal\nhelper, or obtain approval for an explicitly reviewed manager workflow. Do not\nsilently substitute a broad refresh or add a transitive package directly. Inspect\nthe receipt/logs and re-audit; a no-op or warning can leave an advisory unresolved.\nNever hand-edit integrity hashes or lock entries.\nReview intentional patches, overrides, and pins before removal; retain them until\nupstream fixes and regression checks demonstrate they are unnecessary.\nAvoid unrelated global installations or environment changes. Use task-local or\nrepository-scoped tools for testing changed runtime pins.\nFor published packages, also validate tarballs and consumer installs with their\ndocumented supported package managers, including manifest/override syntax and\nruntime requirements. A successful owning-manager install does not prove that\npublished metadata works for those consumers.\n\nRun the repository's setup/hooks, frozen installs, lint, typechecks, tests, builds,\npackage/platform smoke checks, and relevant safe integration previews. Resolve\nupgrade-related deprecation warnings at their source. Do not suppress warnings,\nweaken tests, or disable checks; report remaining upstream/pre-existing warnings\nwith evidence and keep a target pinned when migration cannot be completed.\nAdd focused regression coverage when a migration changes behavior; avoid tests\nthat merely assert version strings. Re-run checks after repairs. Report checks\nblocked by missing credentials, platforms, or external services accurately.\nRe-audit the final resolved graph after migrations and repairs.\n\nConfirm every inventory row is upgraded, already current, intentionally constrained,\nor skipped with a concrete reason. Do not present an unresolved group as complete.\nWhen upgrading agent-tool itself, install its managed skills with the same harness\nscope and commit the ownership manifest; never edit generated managed skill copies.\n\nWhen changes depend on another repository's release, ship the producer first and\nconfirm publishing and registry availability before pinning the consumer; include\nits exact version/commit and API migration notes. Independent groups may proceed.\nComplete the installed `ship-pr` workflow within the requested scope, including\nindependent review of every changed HEAD, required CI and review feedback, merge,\nand verification of the merge's normal publication or deployment. Do not stop at\nan open PR unless the user requested that stopping point or a concrete blocker\nprevents continuing. Check deployment safety again before push/open/merge;\nshipping defaults do not waive the preview gates above.\n\n## Report\n\nKeep run-specific evidence in the upgrade PR body or a linked PR comment: the\ninventory and old/selected versions, completed migrations, validation and warnings,\nbaseline/final audits and coverage limits, preview environment/commit/tool versions\nand safe action summary, and skipped/constrained dependencies with reasons. Include\nsecurity overrides, their rationale and removal condition, and unresolved advisories.\nIf the user requested a scope that stops before a PR, provide this ledger in the\ntask report and honor that limit. For a sweep, keep one entry per repository,\nincluding unready and unchanged checkouts, and use an existing tracking issue only\nwhen explicitly requested. Never create an issue merely to store upgrade evidence.\n\nKeep durable repository guidance focused on what the next upgrade needs: current\ncompatibility constraints, intentional pins/overrides, unresolved advisories, and\nreusable repository-specific procedures. Prefer the existing maintenance document;\notherwise create `docs/dependency-upgrades.md` (or the repository's equivalent)\nonly when there is substantive guidance to preserve. For each constraint, record\nits rationale, upstream advisory/migration/issue link or originating PR, and the\ncondition and check for removing or revisiting it. Do not copy version inventories,\naudit output, validation/preview receipts, or dated run journals into that document.\n\nOn every upgrade, reconcile the existing maintenance document against the final\ndependency graph and checks: update constraints in place, remove resolved entries,\nand link the PR for historical evidence. Keep the root README focused on purpose,\nsetup, supported requirements, and normal usage, with a concise maintenance link\nwhen needed. Keep dependency-maintenance guidance in `AGENTS.md` to a short\nrouting rule and link; do not accumulate upgrade reports in either entrypoint\nor duplicate the maintenance document.\n\nFor shipping, report the branch, reviewed commit/verdict, PR, merge, publish/deploy\nresult, and final checkout state. Keep full logs private; never publish credentials,\nstate, or plan contents in any of these locations.\n"
|
|
10
|
+
"update-dependencies": "---\nname: update-dependencies\ndescription: Update dependencies or update everything in a repository, including runtimes, tools, and CI pins, with compatibility checks and safe previews; ship through review, CI, merge, and release verification unless a narrower scope is requested.\n---\n\n# Update Dependencies\n\nUse the repository's package managers and installed `agent-tool`. Read `AGENTS.md`,\nREADME, existing dependency-maintenance notes, linked setup/release documents,\nand repository-owned upgrade skills before editing. Follow their hooks, version\npolicy, checks, and requested stopping point.\nUpdate applicable dependencies throughout the repository, including workspaces\nand examples. When asked to perform dependency updates, invoke the installed\n[`ship-pr`](../ship-pr/SKILL.md) to complete review, PR, CI, and merge, then verify\nthe repository's normal merge-triggered publication or deployment. An explicit\nnarrower scope, such as inventory-only, local changes, or open-PR-only, takes\nprecedence. This default does not authorize standalone infrastructure applies,\ndeployments, or global tool changes. Default dependency-update merge subject:\n`chore: update dependencies`, subject to repository title policy and any explicit\nuser subject.\n\nRun noisy installs, checks, tests, and builds with\n`agent-tool run --label <check> -- <command> [args...]` to retain full private\nlogs and return the original status with compact output. Inspect bounded excerpts\nusing `agent-tool logs <log>` and targeted searches for warnings and evidence;\na successful receipt does not establish a warning-free upgrade. Keep structured\naudit/plan results, deployment previews, and review findings directly visible\nwhen they drive a safety decision. Do not dump full suite logs into context,\nsilence warnings at their source, or change check scope to reduce output.\n\n## Checkout setup\n\nThis shared workflow also handles natural-language requests to \"update everything\".\nIf the repository owns an `update-everything` wrapper, read and follow its extra\nrequirements; do not create an alias or overwrite that skill. The workflow works\nfrom a standalone checkout with no workspace coordinator.\n\nAfter a fetch, branch integration, or dependency pin change, check that the local\n`agent-tool --version` matches the repository's declared pin before trusting its\ncommands or generated skills. A stale CLI can reject newer configuration keys.\nAfter screening install scripts and hooks as below, run the documented frozen\ninstall with the repository's pinned runtime. For Bun projects, an already working\nCLI can run `agent-tool bun install`; if it is missing or cannot parse the new\nconfig, run the documented package-manager install directly. A known working\nexecutable may capture it with `agent-tool --repo <checkout> run --label setup --\n<install-command> [args...]`. Do not fetch an unpinned CLI, alter global tools, or\nassume a sibling workspace exists. Verify the installed version afterward; if it\nstill differs, report the mismatch rather than deleting arbitrary dependencies.\n\nAfter upgrading agent-tool, run the repository's skill/permission sync commands.\nFor each ownership manifest they do not refresh, run its installer directly:\n`agent-tool skills install --harness <existing-scope> --apply` for\n`.agent-tool-skills.json`, and\n`agent-tool permissions install --harness <existing-scope> --apply` for\n`.agent-tool-permissions.json`. Preserve each harness scope, and commit the\nownership manifests with any generated files.\nThe manifests record the agent-tool version, so every upgrade changes them, even\nwhen no skill or rule changed, and `skills check` and `permissions check` fail\nuntil the sync records the new version. Hermes reads the shared `.agents/skills`\nin a trusted project; the installer does not grant trust. If discovery is\nunavailable, read those files directly rather than silently using a stale global\ncopy.\n\n## Nonblocking execution\n\nUse the harness's managed background execution for long finite checks, reviews,\npush hooks, CI waits, and release verification; request completion notification\nwhen available and retain its process handle plus agent-tool's log/receipt path.\nRun `run-group` and reviews directly so their reports remain visible. A started\nprocess is not a passed check: read its final status and required evidence before\nshipping, and do not repeatedly poll when completion events are available.\nWithout harness background support, `proc start --label <name> -- agent-tool run\n--label <check> -- <command> [args...]` records the outer process and captures\nits output; inspect `proc list` and `logs` plus the inner run receipt to establish\ncompletion and exit status. An exited process record alone does not prove success.\nUse `proc stop`/`teardown` for owned leftovers; never stop another session's work.\nThese commands need no matrix workspace or global configuration change.\n\nKeep independent compatibility groups moving while a producer release or an\nexternal gate is pending. Only final adoption of that exact published release\nmust wait. Bound CPU/process-heavy concurrency to the machine's available budget;\na failed full suite needs diagnosis and a full-scope rerun, not larger timeouts,\nfewer assertions, or a focused retry presented as suite recovery. Background\nexecution never bypasses an approval, a deployment preview, or exact-head review.\n\n## Safety before execution\n\n**Always dry-run before any infrastructure apply or deployment. Never destroy,\nreplace, or recreate a resource during an upgrade.** This includes Terraform,\nOpenTofu, Wrangler, Ansible, other infrastructure tools, and effects triggered by\ninstallation, tests, hooks, Git push, opening a PR, CI, or merging. Greenfield\nprojects and approval to ship do not waive this rule.\n\nBefore running project commands or pushing, trace their scripts, hooks, workflow\ntriggers, reusable workflows, and deployment commands. A dry-run flag alone is\ninsufficient: inspect tasks, provisioners, plugins, external programs, and actions\nthat can mutate despite preview mode. Avoid such a preview unless its effects\nare proven read-only. Do not run destroy/delete, taint/replace, state removal,\nbackend migration, forced database reset, or an automatic \"repair\" that bypasses\nthe rule. Do not hide destruction with targeting, disabled refresh, ignored\nchanges, new resource identities, or weakened policy.\n\nPreview with the proposed versions and complete configuration for each affected\nenvironment, using its real backend/workspace/account, variables, inventory, and\nresource identities. An empty local state, mocked credentials, validate-only run,\nor bundle build cannot establish safety for production. Check the current baseline\nas well when needed to distinguish existing drift from the upgrade. Keep state,\nbinary plans, JSON plans, and secret-bearing diffs out of Git and public reports.\n\nIf a preview proposes deletion or replacement, fails, is incomplete, omits\naffected resources, or cannot establish safety, skip that dependency and its\ncoupled migrations. Restore only this task's edits to the affected compatibility\ngroup, retain independent safe upgrades, and record the reason and affected\nresources. Never apply to find out. A preview is not deployment authorization.\n\nBefore an authorized apply/deploy, verify the exact validated commit, toolchain,\nconfiguration, environment, and current state still match the preview. Re-preview\nafter relevant changes or drift. CI must enforce the same order and stop on an\nunsafe preview before mutation; a successful local preview does not excuse an\nunguarded push- or merge-triggered deployment. Establish a narrowly scoped guard\nwhen authorized and reviewable, or hold the affected upgrade before triggering\nthat workflow. Do not disable protections to ship. A plan must be inspected before\nthe operation; inspecting deployment logs afterward is too late.\nAn unsafe workflow triggered on every branch push also blocks pushing otherwise\nindependent upgrades until that trigger has a proven safe guard.\n\n### Terraform and OpenTofu\n\nRead core, provider, and module upgrade guides, including intermediate major\nmigrations. Regenerate provider locks with the pinned CLI, preserving supported\nplatform hashes. Backend initialization/migration is also subject to the safety\ngate. Inspect external data programs and provisioners before planning.\n\nUse a full refreshed saved plan with locking and the real variables, for example\n`terraform plan -input=false -out=<private-plan>`; if using `-detailed-exitcode`,\n0 and 2 are success, 1 is failure. Inspect `terraform show -json <private-plan>`.\nRun `agent-tool dependencies check-terraform-plan <private-plan.json>` to check\nsupported JSON resource actions. It fails for every action containing `delete`,\nincluding both replacement orders, unknown actions, incomplete/deferred plans,\nfailed checks, or opaque provider action invocations. It prints actions and\ndiagnostics without resource attribute values; it does not prove that a plan is\nfresh, comprehensive, authentic, or that provider code has no hidden effects.\nOlder/unsupported plan formats that cannot establish completeness are skipped.\nOpenTofu currently omits `complete` in its JSON format and is rejected by this\nhelper; report that limitation rather than adding a synthetic completeness flag.\nAlso inspect resource identity, drift, warnings, provider semantics, and any\neffects outside resource actions. For an authorized apply, consume the exact\napproved saved plan, not an uninspected newly generated plan.\n\nSource: [Terraform JSON plan format](https://developer.hashicorp.com/terraform/internals/json-format).\n\n### Wrangler and other deployment tools\n\nUse the proposed pinned Wrangler for `wrangler deploy --dry-run` with the same\nbuild/configuration/environment used by deployment. This checks bundling, not a\ncomplete remote resource plan. Separately verify account, worker name, routes,\nbindings and resource IDs against the existing deployment and read migration\nsemantics. Review Durable Object deleted/renamed classes, D1 schema/data\nmigrations, storage resources, queues, containers, and deployment integrations.\nNever infer \"no destruction\" from a successful bundle. Resource removals,\nreplacement, or unprovable remote effects skip the affected group. Apply the\nequivalent preview and identity checks to other tools rather than assuming they\nshare Terraform's guarantees.\n\nDo not assume `wrangler d1 migrations list --remote` is read-only. The\nimplementation inspected for this skill initializes migration tracking with\n`CREATE TABLE IF NOT EXISTS`; verify the pinned Wrangler version before using\nthe command. Verify database identity and compare migration files with the\ndatabase's configured migration tracking table through audited read-only\nqueries. A missing table, pending migration, or unverifiable schema/data\neffects hold the affected upgrade/deployment group. Never initialize schema\nmerely to establish preview safety.\n\nWrangler runs a custom `build.command` again during deployment. Use supported\nconfiguration referencing the same validated artifacts for both preview and\ndeployment, preventing another unvalidated build before upload. Bind the\nartifacts, configuration, and pinned tool to the authorized commit, and recheck\ntheir identities before upload and after relevant changes. Hold the affected\ngroup if the pinned Wrangler cannot upload the validated output without\nrebuilding it, or if the upload cannot be proven to match the preview.\n\nSources: [Wrangler command documentation](https://developers.cloudflare.com/workers/wrangler/commands/),\n[D1 migration listing implementation](https://github.com/cloudflare/workers-sdk/blob/e3d186776fcc2e4b5cc4cfd7155591778a375957/packages/wrangler/src/d1/migrations/list.ts),\n[migration table initialization](https://github.com/cloudflare/workers-sdk/blob/e3d186776fcc2e4b5cc4cfd7155591778a375957/packages/wrangler/src/d1/migrations/helpers.ts),\nand [Wrangler custom builds](https://developers.cloudflare.com/workers/wrangler/custom-builds/).\n\n### Ansible\n\nCheck controller Python, ansible-core, collections/roles, and target Python support\ntogether; read porting guides. Inspect all tasks and invoked scripts before\n`ansible-playbook --check --diff` with the real inventory and variables.\n`check_mode: false` forces mutation even with `--check`; unsupported modules and\nconditions based on registered results can omit effects. Inspect deletion,\nrecreation, service/data reset, and package removal semantics beyond the diff.\nSkipped or opaque tasks are a safety gap, not a clean preview. Redact diffs.\n\nSource: [Ansible check mode limits](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_checkmode.html).\n\n## Inventory and choose compatible targets\n\nRecord each dependency source, current resolved version, latest stable candidate,\nselected target, compatibility constraints, upstream migration links, and checks\nin the run ledger described under Report.\nQuery authoritative registries, official releases, support matrices, and migration\nguides at execution time; do not treat remembered versions or prereleases as\nlatest stable. Inspect runtime requirements, peer dependencies, ABI/API changes,\nplatform availability, maintained release lines, and changed defaults, including\nsecurity, privacy/telemetry, data retention, and postinstall/native behavior.\nCheck transitive dependencies' peer/runtime constraints as well as direct ones. Unsupported\nor unpublished targets stay pinned with an explanation.\n\nInventory manifests, locks, tool configuration, CI/reusable actions, containers,\nscripts, deployment files, and executable documentation. Search duplicate version\npins and aliases, not just filenames; exclude vendored/generated snapshots unless\nthe repository owns their update process. Examples of sources to inspect:\n\n| Ecosystem | Sources and compatibility group |\n| --- | --- |\n| JavaScript/TypeScript | All package.json dependency fields, overrides/resolutions, workspace catalogs, packageManager/engines, npm/Bun/pnpm/Yarn locks, Node/Bun pins, compiler and lint/build/test plugins |\n| Toolchains | mise.toml/.mise.toml, mise.lock, .tool-versions, runtime version files, tool URLs/checksums, CI pins and container images; include every tool declared by mise, not just mise itself |\n| Python/Ansible | pyproject/requirements, uv/Poetry/pip locks, Python pins, ansible-core, collection/role requirements, lint plugins and managed host constraints |\n| Ruby/iOS | .ruby-version, Gemfile/lock, Bundler, CocoaPods, Podfile/lock, podspecs, Swift packages and Xcode/iOS deployment requirements |\n| Infrastructure | Terraform/OpenTofu CLI constraints, provider locks/constraints, module versions/Git refs, Wrangler and Cloudflare integration dependencies |\n| CI/system/native | Actions/reusable workflow refs, Docker tags/digests, OS images/packages, Rust/Cargo toolchain and locks, Go modules, Gradle/AGP/Kotlin/JDK and other repository-specific manifests |\n\nBuild connected compatibility groups before editing. Select the newest supported\ncombination, which can be older than an individual package's latest. Upgrade the\nframework first or keep its compatible toolchain pinned; do not force peer\nresolution, drop compatibility checks, or add blanket overrides to make installs\npass. Preserve source pin policy (exact version, digest, full Git SHA) and resolve\nimmutable pins from verified upstream releases. Preserve intentional runtime\nminimums unless migration requires changing the support contract.\n\nFor React Native, use its version-specific upgrade guide/template diffs and\nrepository upgrade skills. Couple React and its renderer, native modules,\nMetro/Babel, CLI, codegen, Hermes/New Architecture, CocoaPods/Bundler/Ruby,\nXcode/iOS deployment targets, and Android Gradle/AGP/Kotlin/JDK/SDK/NDK. For Expo,\nuse the chosen SDK's supported React Native/dependency matrix and its dependency\nchecks. Do not independently update framework-managed pods or generated native\nfiles; use the framework's regeneration workflow and prove iOS/Android builds.\nPermissive peer ranges alone do not prove native renderer or toolchain compatibility;\ncheck the framework's actual supported versions and native implementation.\nAn unavailable native toolchain is a reported validation limit; do not claim the\ngroup verified. See [React Native upgrading](https://reactnative.dev/docs/upgrading).\n\nCheck developer tools' own dependencies too: a compiler release without its old\nprogrammatic API may break test/lint runners that import it even when `tsc` passes.\nAction runtime upgrades can require newer self-hosted runners; preserve workflow\npermissions, action inputs/outputs, caching, artifact semantics, and job names.\n\nCheck current advisories with read-only ecosystem audits against the baseline and\nproposed lockfiles, using the repository's configured registry/advisory sources.\nDo not send private dependency metadata to an unconfigured or unauthorized service;\nreport the resulting coverage limit. Cover direct and resolved transitive dependencies,\nincluding native/platform-specific binaries. Latest direct packages can still\npin vulnerable transitive versions. Trace each finding to its owning dependency,\nverify affected versions, runtime conditions, and remediation in the maintainer's\nadvisory and fixed release. When the owner's range permits a fixed version, use a\ntargeted refresh with the lockfile's owning manager and preserve unrelated\nresolutions; otherwise prefer a supported owner upgrade.\nIf the owner still pins a vulnerable version, a narrowly scoped security patch\noverride may be used only with API/ABI/runtime compatibility evidence and focused\nregression checks of the actual affected integration. Document its rationale and\nremoval condition; a passing install or bundle alone is insufficient. Do not run\nblind audit fixes or use blanket overrides to bypass compatibility constraints.\nReport unresolved advisories and unavailable audit coverage accurately; current\ndirect pins or a partial clean audit do not\nestablish that the whole dependency graph is safe.\n\n## Migrate and validate\n\nCapture relevant baseline checks and warnings first, after screening their side\neffects. Update one compatibility group at a time. Read the upstream instructions\nfor every breaking step; implement required source/config/schema migrations and\nremoved API replacements. Use the manager that owns each lockfile, on the selected\nruntime, and inspect the resulting diff. For Bun lockfiles, change declared\nversions with `agent-tool bun update <name[@version]>` and drop packages with\n`agent-tool bun remove <name>`; both use the pinned Bun and refuse to add a\npackage. A new dependency goes through `agent-tool bun add <name@version>`, which\nasks for approval; never introduce one by editing `package.json` and\nreinstalling. For existing Bun catalog entries use\n`agent-tool bun update --catalog default <name@version>...` (or the existing named\ncatalog). Name an explicit exact/ranged registry spec; keep `catalog:` references,\nworkspace membership, other entries, and peer compatibility contracts intact.\nThe helper refuses intake and ambiguous layouts and uses the owning manager to\nrefresh the lock; do not replace catalog references with direct versions.\n\nFor an already-resolved transitive registry package with an eligible owner range,\nuse `agent-tool bun update --resolved <name>...` with the owning Bun 1.4.4 or newer.\nIt selects every locked copy of those names, never a requested version or glob,\nand accepts only a result with identical manifests and unchanged non-target lock\nentries/metadata. It preserves release-age, overrides and patches. If an older\nmanager is pinned, or a required new child prevents a target-only result, this\npath is unsupported: prefer an owning-dependency upgrade through the normal\nhelper, or obtain approval for an explicitly reviewed manager workflow. Do not\nsilently substitute a broad refresh or add a transitive package directly. Inspect\nthe receipt/logs and re-audit; a no-op or warning can leave an advisory unresolved.\nNever hand-edit integrity hashes or lock entries.\nReview intentional patches, overrides, and pins before removal; retain them until\nupstream fixes and regression checks demonstrate they are unnecessary.\nAvoid unrelated global installations or environment changes. Use task-local or\nrepository-scoped tools for testing changed runtime pins.\nFor published packages, also validate tarballs and consumer installs with their\ndocumented supported package managers, including manifest/override syntax and\nruntime requirements. A successful owning-manager install does not prove that\npublished metadata works for those consumers.\n\nRun the repository's setup/hooks, frozen installs, lint, typechecks, tests, builds,\npackage/platform smoke checks, and relevant safe integration previews. Resolve\nupgrade-related deprecation warnings at their source. Do not suppress warnings,\nweaken tests, or disable checks; report remaining upstream/pre-existing warnings\nwith evidence and keep a target pinned when migration cannot be completed.\nAdd focused regression coverage when a migration changes behavior; avoid tests\nthat merely assert version strings. Re-run checks after repairs. Report checks\nblocked by missing credentials, platforms, or external services accurately.\nRe-audit the final resolved graph after migrations and repairs.\n\nConfirm every inventory row is upgraded, already current, intentionally constrained,\nor skipped with a concrete reason. Do not present an unresolved group as complete.\nWhen upgrading agent-tool itself, install its managed skills with the same harness\nscope and commit the ownership manifest; never edit generated managed skill copies.\n\nWhen changes depend on another repository's release, ship the producer first and\nconfirm publishing and registry availability before pinning the consumer; include\nits exact version/commit and API migration notes. Independent groups may proceed.\nComplete the installed `ship-pr` workflow within the requested scope, including\nindependent review of every changed HEAD, required CI and review feedback, merge,\nand verification of the merge's normal publication or deployment. Do not stop at\nan open PR unless the user requested that stopping point or a concrete blocker\nprevents continuing. Check deployment safety again before push/open/merge;\nshipping defaults do not waive the preview gates above.\n\n## Report\n\nKeep run-specific evidence in the upgrade PR body or a linked PR comment: the\ninventory and old/selected versions, completed migrations, validation and warnings,\nbaseline/final audits and coverage limits, preview environment/commit/tool versions\nand safe action summary, and skipped/constrained dependencies with reasons. Include\nsecurity overrides, their rationale and removal condition, and unresolved advisories.\nIf the user requested a scope that stops before a PR, provide this ledger in the\ntask report and honor that limit. For a sweep, keep one entry per repository,\nincluding unready and unchanged checkouts, and use an existing tracking issue only\nwhen explicitly requested. Never create an issue merely to store upgrade evidence.\n\nKeep durable repository guidance focused on what the next upgrade needs: current\ncompatibility constraints, intentional pins/overrides, unresolved advisories, and\nreusable repository-specific procedures. Prefer the existing maintenance document;\notherwise create `docs/dependency-upgrades.md` (or the repository's equivalent)\nonly when there is substantive guidance to preserve. For each constraint, record\nits rationale, upstream advisory/migration/issue link or originating PR, and the\ncondition and check for removing or revisiting it. Do not copy version inventories,\naudit output, validation/preview receipts, or dated run journals into that document.\n\nOn every upgrade, reconcile the existing maintenance document against the final\ndependency graph and checks: update constraints in place, remove resolved entries,\nand link the PR for historical evidence. Keep the root README focused on purpose,\nsetup, supported requirements, and normal usage, with a concise maintenance link\nwhen needed. Keep dependency-maintenance guidance in `AGENTS.md` to a short\nrouting rule and link; do not accumulate upgrade reports in either entrypoint\nor duplicate the maintenance document.\n\nFor shipping, report the branch, reviewed commit/verdict, PR, merge, publish/deploy\nresult, and final checkout state. Keep full logs private; never publish credentials,\nstate, or plan contents in any of these locations.\n"
|
|
11
11
|
};
|
|
12
12
|
/** Markdown files a skill ships beside its SKILL.md, by skill and then by path within the skill directory. */
|
|
13
13
|
export const BUNDLED_SKILL_REFERENCES: Readonly<Record<string, Readonly<Record<string, string>>>> = {
|
package/src/skills/install.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import {
|
|
2
|
+
import { lstatSync, mkdirSync, realpathSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { harnessNamed } from "../harnesses";
|
|
5
|
+
import { readRegularFile } from "../system/files";
|
|
6
|
+
import { AGENT_TOOL_VERSION, manifestVersionCheck, validVersion, type CheckStatus } from "../system/manifestVersion";
|
|
5
7
|
import { BUNDLED_SKILL_REFERENCES, BUNDLED_SKILLS } from "./bundled";
|
|
6
8
|
|
|
7
|
-
const
|
|
9
|
+
export const SKILLS_MANIFEST = ".agent-tool-skills.json";
|
|
8
10
|
const hash = (source: string) => createHash("sha256").update(source).digest("hex");
|
|
9
11
|
|
|
10
12
|
/** Refuse symlinks at every existing component, including dangling links. */
|
|
@@ -40,76 +42,106 @@ export function bundledSkillFiles(): [name: string, files: [relative: string, so
|
|
|
40
42
|
return Object.entries(BUNDLED_SKILLS).map(([name, source]) => [name, [["SKILL.md", source], ...Object.entries(BUNDLED_SKILL_REFERENCES[name] ?? {})]]);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
/**
|
|
46
|
+
* One reading of the ownership manifest: its bytes (none without a manifest), each managed
|
|
47
|
+
* file's hash, and the agent-tool version whose install wrote it. Manifests from releases
|
|
48
|
+
* before the version field lack it and stay readable; the field is additive, so
|
|
49
|
+
* `schemaVersion` stays 1 and older releases still read newer manifests.
|
|
50
|
+
*/
|
|
51
|
+
interface SkillManifest { raw?: string; agentToolVersion?: string; files: Record<string, string> }
|
|
52
|
+
|
|
53
|
+
function readManifest(root: string): SkillManifest {
|
|
54
|
+
// One descriptor, refusing links, FIFOs, and devices, so a hook or CI can be neither redirected nor stalled.
|
|
55
|
+
const read = readRegularFile(safeDestination(root, SKILLS_MANIFEST));
|
|
56
|
+
if (read.status === "missing") return { files: {} };
|
|
57
|
+
if (read.status === "irregular") throw new Error(`Managed skill manifest is not a regular file: ${SKILLS_MANIFEST}`);
|
|
58
|
+
const raw = read.contents;
|
|
59
|
+
const value = JSON.parse(raw);
|
|
60
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || value.schemaVersion !== 1 || !value.files || typeof value.files !== "object" || Array.isArray(value.files) || Object.values(value.files).some(item => typeof item !== "string" || !/^[a-f0-9]{64}$/.test(item))) throw new Error("Invalid managed skill manifest.");
|
|
61
|
+
// The version is provenance, not ownership: an unusable one counts as none, which the check reports and the install replaces.
|
|
62
|
+
return { raw, ...(validVersion(value.agentToolVersion) ? { agentToolVersion: value.agentToolVersion } : {}), files: value.files };
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
interface PlannedFile { file: string; relative: string; source: string; current?: string; change: SkillChange }
|
|
66
|
+
interface Plan { files: PlannedFile[]; manifestFile: string; manifest: string; manifestChange: SkillChange }
|
|
67
|
+
|
|
68
|
+
/** What installing one target would write, from one reading of the manifest; refuses before any write. */
|
|
69
|
+
function plan(root: string, target: string, recorded: SkillManifest): Plan {
|
|
53
70
|
// Hermes consumes shared skills, not the review adapter registry. OpenCode
|
|
54
71
|
// discovers both default directories too; avoid additional duplicate bundles.
|
|
55
72
|
const directories = target === "all" ? [".agents/skills", ".claude/skills"]
|
|
56
73
|
: [target === "hermes" ? ".agents/skills" : harnessNamed(target).skillDirectory];
|
|
57
|
-
const manifestFile = safeDestination(root,
|
|
58
|
-
const
|
|
59
|
-
const pending: { file: string; relative: string; source: string; change: SkillChange }[] = [];
|
|
74
|
+
const manifestFile = safeDestination(root, SKILLS_MANIFEST);
|
|
75
|
+
const planned: PlannedFile[] = [];
|
|
60
76
|
for (const directory of directories) {
|
|
61
77
|
for (const [name, sources] of bundledSkillFiles()) {
|
|
62
78
|
for (const [inside, source] of sources) {
|
|
63
79
|
const relative = `${directory}/${name}/${inside}`;
|
|
64
80
|
const file = safeDestination(root, relative);
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
pending.push({ file, relative, source, change: { path: relative, status: current === source ? "unchanged" : current === undefined ? "create" : "update" } });
|
|
81
|
+
const read = readRegularFile(file);
|
|
82
|
+
if (read.status === "irregular") throw new Error(`Skill destination is not a regular file: ${relative}`);
|
|
83
|
+
const current = read.status === "file" ? read.contents : undefined;
|
|
84
|
+
if (current !== undefined && current !== source && hash(current) !== recorded.files[relative]) throw new Error(`Locally edited or unmanaged skill: ${relative}. Preserve it before installing.`);
|
|
85
|
+
planned.push({ file, relative, source, current, change: { path: relative, status: current === source ? "unchanged" : current === undefined ? "create" : "update" } });
|
|
72
86
|
}
|
|
73
87
|
}
|
|
74
88
|
}
|
|
89
|
+
const files = { ...recorded.files };
|
|
90
|
+
for (const item of planned) files[item.relative] = hash(item.source);
|
|
91
|
+
// Recording the version makes every upgrade change the manifest, so a committed sync is visible.
|
|
92
|
+
const manifest = `${JSON.stringify({ schemaVersion: 1, agentToolVersion: AGENT_TOOL_VERSION, files }, null, 2)}\n`;
|
|
93
|
+
const status = recorded.raw === manifest ? "unchanged" : recorded.raw === undefined ? "create" : "update";
|
|
94
|
+
return { files: planned, manifestFile, manifest, manifestChange: { path: SKILLS_MANIFEST, status } };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Each managed file's change, then the manifest's, which every new agent-tool release updates. */
|
|
98
|
+
export function installSkills(rootDir: string, target: string, apply = false): SkillChange[] {
|
|
99
|
+
const root = realpathSync(rootDir);
|
|
100
|
+
const planned = plan(root, target, readManifest(root));
|
|
75
101
|
// Preflight every destination before writing any files.
|
|
76
102
|
if (apply) {
|
|
77
|
-
const files
|
|
78
|
-
|
|
79
|
-
if (item.change.status !== "unchanged") atomicWrite(item.file, item.source);
|
|
80
|
-
files[item.relative] = hash(item.source);
|
|
81
|
-
}
|
|
82
|
-
atomicWrite(manifestFile, `${JSON.stringify({ schemaVersion: 1, files }, null, 2)}\n`);
|
|
103
|
+
for (const item of planned.files) if (item.change.status !== "unchanged") atomicWrite(item.file, item.source);
|
|
104
|
+
if (planned.manifestChange.status !== "unchanged") atomicWrite(planned.manifestFile, planned.manifest);
|
|
83
105
|
}
|
|
84
|
-
return
|
|
106
|
+
return [...planned.files.map(item => item.change), planned.manifestChange];
|
|
85
107
|
}
|
|
86
108
|
|
|
87
109
|
const DIRECTORY_HARNESSES: Record<string, string> = { ".claude/skills": "claude", ".agents/skills": "codex", ".opencode/skills": "opencode" };
|
|
88
110
|
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
/** One entry per managed file, then the manifest's own entry with its recorded and running versions. */
|
|
112
|
+
export interface SkillCheck { path: string; status: CheckStatus; recordedVersion?: string | null; currentVersion?: string }
|
|
113
|
+
|
|
114
|
+
/** Each managed file of one target against the same reading of the manifest. */
|
|
115
|
+
function fileChecks(root: string, target: string, recorded: SkillManifest): SkillCheck[] {
|
|
116
|
+
return plan(root, target, recorded).files.map(({ relative, current, change }): SkillCheck => {
|
|
117
|
+
if (change.status === "create") return { path: relative, status: "missing" };
|
|
118
|
+
if (change.status === "update") return { path: relative, status: "outdated" };
|
|
119
|
+
if (!recorded.files[relative]) return { path: relative, status: "unmanaged" };
|
|
120
|
+
if (recorded.files[relative] !== hash(current!)) return { path: relative, status: "outdated" };
|
|
121
|
+
return { path: relative, status: "unchanged" };
|
|
122
|
+
});
|
|
99
123
|
}
|
|
100
124
|
|
|
101
|
-
|
|
125
|
+
const versionCheck = (recorded: SkillManifest): SkillCheck => manifestVersionCheck(SKILLS_MANIFEST, recorded.raw !== undefined, recorded.agentToolVersion);
|
|
102
126
|
|
|
103
|
-
/** Read-only CI gate: require current bundled bytes
|
|
127
|
+
/** Read-only CI gate: require current bundled bytes, their ownership records, and the installing version. */
|
|
104
128
|
export function checkSkills(rootDir: string, target: string): SkillCheck[] {
|
|
105
129
|
const root = realpathSync(rootDir);
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
const recorded = readManifest(root);
|
|
131
|
+
return [...fileChecks(root, target, recorded), versionCheck(recorded)];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The push gate's check, or null without a manifest: every `--harness` whose directory the
|
|
136
|
+
* manifest records, so it covers every installed directory, OpenCode's included (an
|
|
137
|
+
* unrecognized directory adds `all`), then the manifest's own entry once, even when it records
|
|
138
|
+
* no harness. One reading of the manifest serves them all.
|
|
139
|
+
*/
|
|
140
|
+
export function checkInstalledSkills(rootDir: string): { harnesses: string[]; changes: SkillCheck[] } | null {
|
|
141
|
+
const root = realpathSync(rootDir);
|
|
142
|
+
const recorded = readManifest(root);
|
|
143
|
+
if (recorded.raw === undefined) return null;
|
|
144
|
+
const directories = new Set(Object.keys(recorded.files).map(file => file.split("/", 2).join("/")));
|
|
145
|
+
const harnesses = [...new Set([...directories].map(directory => DIRECTORY_HARNESSES[directory] ?? "all"))].sort();
|
|
146
|
+
return { harnesses, changes: [...harnesses.flatMap(harness => fileChecks(root, harness, recorded)), versionCheck(recorded)] };
|
|
115
147
|
}
|
package/src/system/files.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { closeSync, constants, fstatSync, ftruncateSync, lstatSync, openSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { closeSync, constants, fstatSync, ftruncateSync, lstatSync, openSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
/** Refuses symbolic links below the base, so a committed link cannot redirect a write outside it. */
|
|
@@ -13,6 +13,39 @@ export function assertNoLinks(base: string, destination: string): void {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/** What `readRegularFile` found: nothing, something other than a regular file, or a file's text. */
|
|
17
|
+
export type RegularFile = { status: "missing" } | { status: "irregular" } | { status: "file"; contents: string };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reads a regular file. It refuses anything else before opening it, then opens one descriptor
|
|
21
|
+
* without following a final symbolic link and without blocking and checks that descriptor, so a
|
|
22
|
+
* path replaced after the first check can neither redirect the read nor stall it on a FIFO.
|
|
23
|
+
* Callers refuse links in parent directories with a component walk first. Node has no `openat`,
|
|
24
|
+
* so a parent swapped between that walk and the open is outside this guard; only a concurrent
|
|
25
|
+
* writer of the checkout could do it, and that writer already controls its hooks and packages.
|
|
26
|
+
*/
|
|
27
|
+
export function readRegularFile(file: string, afterCheck: () => void = () => {}): RegularFile {
|
|
28
|
+
// Never open an existing special file: opening a device can block or act even without reading.
|
|
29
|
+
try { if (!lstatSync(file).isFile()) return { status: "irregular" }; }
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (["ENOENT", "ENOTDIR"].includes((error as NodeJS.ErrnoException).code ?? "")) return { status: "missing" };
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
// Tests replace the file here, where only the descriptor's flags and check still guard the read.
|
|
35
|
+
afterCheck();
|
|
36
|
+
let descriptor: number;
|
|
37
|
+
try { descriptor = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK); }
|
|
38
|
+
catch (error) {
|
|
39
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
40
|
+
if (code === "ENOENT" || code === "ENOTDIR") return { status: "missing" };
|
|
41
|
+
// O_NOFOLLOW reports a final symbolic link as ELOOP (EMLINK on some BSDs).
|
|
42
|
+
if (code === "ELOOP" || code === "EMLINK") return { status: "irregular" };
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
try { return fstatSync(descriptor).isFile() ? { status: "file", contents: readFileSync(descriptor, "utf8") } : { status: "irregular" }; }
|
|
46
|
+
finally { closeSync(descriptor); }
|
|
47
|
+
}
|
|
48
|
+
|
|
16
49
|
/**
|
|
17
50
|
* Replaces a file atomically through an unpredictable, exclusively created
|
|
18
51
|
* temporary name, so no committed link can stand in for it. Sandboxed build
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import metadata from "../../package.json";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The release whose installs wrote a repository's managed files. The skills and permissions
|
|
5
|
+
* manifests record it, so every upgrade changes them and a committed sync shows in the diff.
|
|
6
|
+
*/
|
|
7
|
+
export const AGENT_TOOL_VERSION: string = metadata.version;
|
|
8
|
+
|
|
9
|
+
export type CheckStatus = "missing" | "outdated" | "unmanaged" | "unchanged";
|
|
10
|
+
export interface ManifestVersionCheck { path: string; status: CheckStatus; recordedVersion: string | null; currentVersion: string }
|
|
11
|
+
|
|
12
|
+
// semver.org's grammar: numeric identifiers, prerelease ones included, have no leading zeros.
|
|
13
|
+
const IDENTIFIER = "(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)";
|
|
14
|
+
const SEMVER = new RegExp(`^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-${IDENTIFIER}(?:\\.${IDENTIFIER})*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$`);
|
|
15
|
+
|
|
16
|
+
/** A recorded version in the package's release format: semantic versioning, such as `0.1.64` or `1.0.0-rc.1`. */
|
|
17
|
+
export function validVersion(value: unknown): value is string {
|
|
18
|
+
return typeof value === "string" && SEMVER.test(value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A manifest's own check entry: `missing` without a manifest, and `outdated` when it records
|
|
23
|
+
* no version (it predates the field) or another release than the running one, so an upgrade
|
|
24
|
+
* fails the check until the install runs, even when no managed file changed.
|
|
25
|
+
*/
|
|
26
|
+
export function manifestVersionCheck(path: string, exists: boolean, recorded: string | undefined): ManifestVersionCheck {
|
|
27
|
+
const status = !exists ? "missing" : recorded === AGENT_TOOL_VERSION ? "unchanged" : "outdated";
|
|
28
|
+
return { path, status, recordedVersion: recorded ?? null, currentVersion: AGENT_TOOL_VERSION };
|
|
29
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync, writeSync } from "node:fs";
|
|
2
|
+
import { existsSync, lstatSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync, writeSync } from "node:fs";
|
|
3
3
|
import { isatty } from "node:tty";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { executeGroup, reraiseGroupSignal, type GroupRecord } from "../commands/group";
|
|
7
7
|
import { loadConfig, PUSH_GATE_BUDGET_SECONDS, type AgentToolConfig } from "../config";
|
|
8
8
|
import { gitEnvironment } from "../git/environment";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { checkInstalledPermissions, PERMISSIONS_MANIFEST } from "../permissions/install";
|
|
10
|
+
import { checkInstalledSkills, SKILLS_MANIFEST } from "../skills/install";
|
|
11
11
|
import { branchErrors, parsePrePushInput, pushedBranches, zeroOid, type PushTuple } from "./branch";
|
|
12
12
|
import { binariesAddedByCommits, commitFindings, rejectedBinaries } from "./checks";
|
|
13
13
|
import { assert, checkoutRoot, git, output } from "./core";
|
|
@@ -160,10 +160,12 @@ function guard(guards: Guard[], name: string, ref: string | undefined, check: ()
|
|
|
160
160
|
function runGuards(root: string, config: AgentToolConfig, tuples: PushTuple[], destination: ReturnType<typeof listDestination>): { guards: Guard[]; refs: PushedRef[] } {
|
|
161
161
|
const guards: Guard[] = [];
|
|
162
162
|
guard(guards, "hooks", undefined, () => { const result = checkHooks(); return { ok: result.ok, details: { changes: result.changes.filter(change => change.status !== "unchanged"), blockers: result.blockers, configure: result.configure } }; });
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
// A manifest that exists in any form gets its guard, which reports one it cannot read instead of ending the gate.
|
|
164
|
+
const present = (file: string) => { try { lstatSync(path.join(root, file)); return true; } catch (error) { return !["ENOENT", "ENOTDIR"].includes((error as NodeJS.ErrnoException).code ?? ""); } };
|
|
165
|
+
// A manifest that vanishes after the presence check fails its guard rather than passing unchecked.
|
|
166
|
+
const vanished = (file: string) => { throw new Error(`${file} disappeared during the check.`); };
|
|
167
|
+
if (present(SKILLS_MANIFEST)) guard(guards, "skills", undefined, () => { const { harnesses, changes } = checkInstalledSkills(root) ?? vanished(SKILLS_MANIFEST); const drift = changes.filter(change => change.status !== "unchanged"); return { ok: !drift.length, details: { harnesses, changes: drift } }; });
|
|
168
|
+
if (present(PERMISSIONS_MANIFEST)) guard(guards, "permissions", undefined, () => { const { harness, changes } = checkInstalledPermissions(root) ?? vanished(PERMISSIONS_MANIFEST); const drift = changes.filter(change => change.status !== "unchanged"); return { ok: !drift.length, details: { harness, changes: drift } }; });
|
|
167
169
|
guard(guards, "branch", undefined, () => { const branches = pushedBranches(tuples).map(name => ({ name, errors: branchErrors(name, config) })).filter(branch => branch.errors.length); return { ok: !branches.length, details: { branches } }; });
|
|
168
170
|
let refs: PushedRef[] = [];
|
|
169
171
|
guard(guards, "ranges", undefined, () => { refs = pushedRefs(tuples, destination); return { ok: true }; });
|