@a2f0/agent-tool 0.1.57 → 0.1.58
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/README.md +3 -2
- package/package.json +1 -1
- package/skills/ship-pr/SKILL.md +58 -25
- package/skills/squash-merge/SKILL.md +16 -10
- package/src/cli.ts +6 -0
- package/src/commands/group.ts +25 -12
- package/src/config.ts +34 -0
- package/src/permissions/catalog.ts +2 -2
- package/src/permissions/install.ts +8 -0
- package/src/skills/bundled.ts +2 -2
- package/src/skills/install.ts +14 -0
- package/src/workflows/baseHealth.ts +165 -0
- package/src/workflows/branch.ts +19 -5
- package/src/workflows/checks.ts +36 -5
- package/src/workflows/hooks.ts +27 -6
- package/src/workflows/pr.ts +72 -15
- package/src/workflows/prFreshness.ts +2 -1
- package/src/workflows/pushGate.ts +303 -0
- package/src/workflows/pushGateSteps.ts +386 -0
- package/src/workflows/repository.ts +2 -0
package/README.md
CHANGED
|
@@ -78,8 +78,9 @@ validation suite, and release procedures.
|
|
|
78
78
|
## Documentation
|
|
79
79
|
|
|
80
80
|
- [Shared workflows](docs/workflows.md): branches, commit trust, copied hooks,
|
|
81
|
-
PR checks/threads,
|
|
82
|
-
validation receipts, and
|
|
81
|
+
declared push gates, PR checks/threads, default-branch health, cleanup, CI
|
|
82
|
+
aggregate gates, release verification, durable validation receipts, and
|
|
83
|
+
toolchain/protection diagnostics.
|
|
83
84
|
- [CLI reference](docs/reference.md): existing review, version, skill installation,
|
|
84
85
|
command capture, import-graph checks, configuration, and distribution contracts.
|
|
85
86
|
- [Development](docs/development.md): setup, source layout, validation, and release
|
package/package.json
CHANGED
package/skills/ship-pr/SKILL.md
CHANGED
|
@@ -20,21 +20,41 @@ or a targeted search; never dump an entire suite log or pipe checks into `tail`.
|
|
|
20
20
|
The receipt proves process completion, not absence of warnings: inspect required
|
|
21
21
|
warning, coverage, timing, or artifact evidence before accepting a check. Keep
|
|
22
22
|
machine-readable receipts and review findings visible by running `versions
|
|
23
|
-
prepare`, `review`, and other commands whose output drives a
|
|
24
|
-
Prefer documented compact test reporters when they preserve
|
|
25
|
-
do not reduce test scope, skip checks, silence warnings, or
|
|
26
|
-
Start servers, watchers, and other long-running processes with
|
|
23
|
+
prepare`, `review`, `repo base-health`, and other commands whose output drives a
|
|
24
|
+
decision directly. Prefer documented compact test reporters when they preserve
|
|
25
|
+
required evidence; do not reduce test scope, skip checks, silence warnings, or
|
|
26
|
+
mask failures. Start servers, watchers, and other long-running processes with
|
|
27
27
|
`agent-tool proc start --label <name> -- <command>`, never a backgrounded shell
|
|
28
28
|
command, so they can be found and stopped.
|
|
29
29
|
|
|
30
|
-
1.
|
|
30
|
+
1. Start from the base branch's health: `agent-tool repo base-health` (with
|
|
31
|
+
`--branch <base-branch>` for another base). `green`, `pending`, and `no-ci`
|
|
32
|
+
need nothing more; report `no-ci` as missing CI on pushes. When it is
|
|
33
|
+
`red`, read the failing jobs' logs (`gh run view <run-id> --log-failed`
|
|
34
|
+
through `agent-tool run`) and relate them to the merges in
|
|
35
|
+
`breakingRange`. Broken logic from combined merges: fix it and add the test
|
|
36
|
+
that would have caught the combination. A flaky or timing-dependent test:
|
|
37
|
+
remove the race, ordering dependence, or shared state. Infrastructure or an
|
|
38
|
+
outside service: record it; rerun only when the log shows the cause was
|
|
39
|
+
external. Never retry until green, skip, or loosen an assertion. When
|
|
40
|
+
`openRepairs` lists a PR, do not duplicate it. Otherwise ship the repair
|
|
41
|
+
through this workflow as its own PR, naming the failing run in its body,
|
|
42
|
+
ahead of the requested change; when the change touches the same code, make
|
|
43
|
+
the repair a separate commit in that PR and say so in its description. A
|
|
44
|
+
red base does not block an unrelated change; stop only when the change
|
|
45
|
+
cannot be validated without the repair. A PR failure with the same job and
|
|
46
|
+
error as on the base is repaired on the base. Reverting the breaking merge
|
|
47
|
+
is allowed when the fix is not small and the break blocks a deploy or
|
|
48
|
+
publish; the revert names the merge and the follow-up that restores it.
|
|
49
|
+
2. Finish the requested change on a feature branch. Use
|
|
31
50
|
`agent-tool branch create <branch> --base <base-branch> --remote <remote>`
|
|
32
51
|
from a clean checkout; it fetches and pins the base, checks naming policy and
|
|
33
52
|
collisions, and creates without a local upstream. Use `branch check` with
|
|
34
|
-
explicit destination names in CI or hooks.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
explicit destination names in CI or hooks. Before pushing, validate with the
|
|
54
|
+
repository's push gate and the tests that target the changed code, not the
|
|
55
|
+
full suite: CI runs everything and is the authority. Commit only the
|
|
56
|
+
intended files.
|
|
57
|
+
3. Use `agent-tool repo context --fetch` to resolve the PR's base repository
|
|
38
58
|
and branch, or the default branch when no PR exists, and fetch its exact base.
|
|
39
59
|
Record the returned base/head identities. Integrate the fetched base
|
|
40
60
|
using the repository's normal workflow, resolving conflicts without losing
|
|
@@ -46,27 +66,31 @@ command, so they can be found and stopped.
|
|
|
46
66
|
version fields. Review the resulting committed HEAD with an independent
|
|
47
67
|
reviewer using the bundled cross-agent-review skill. Repair blocking findings
|
|
48
68
|
and review every changed HEAD again. Review failure blocks shipping.
|
|
49
|
-
|
|
69
|
+
4. Run `agent-tool branch push <reviewed-head> --remote <remote>` through
|
|
50
70
|
normal hooks; it verifies local and remote identity afterward. If a hook
|
|
51
71
|
changed content or HEAD, review that result.
|
|
52
72
|
Open the PR using the open-pr skill, or update the existing PR as needed.
|
|
53
|
-
|
|
73
|
+
5. Allow configured review bots time to respond, then use
|
|
54
74
|
`agent-tool pr threads list` to fetch review threads and all comments. Follow repository policy for feedback: fix valid findings,
|
|
55
75
|
reply with `pr threads reply <comment-id>` (body file or stdin), and use
|
|
56
76
|
`pr threads resolve <thread-id>` only for fully addressed findings.
|
|
57
77
|
Validate, commit, push, and independently review every feedback or CI repair.
|
|
58
78
|
Wait with `agent-tool pr checks --wait --head <reviewed-head>`, whose limit
|
|
59
|
-
defaults to `agent-tool.json` `merge.checksTimeoutSeconds
|
|
60
|
-
fails, read its log with `agent-tool pr logs --head <reviewed-head
|
|
61
|
-
|
|
62
|
-
`
|
|
63
|
-
|
|
79
|
+
defaults to `agent-tool.json` `merge.checksTimeoutSeconds`. When a job
|
|
80
|
+
fails, read its log with `agent-tool pr logs --head <reviewed-head>`, fix it
|
|
81
|
+
in a new commit, review it, push, and wait on the new head. A base that
|
|
82
|
+
moved (`behind: true`) needs no integration unless GitHub reports a
|
|
83
|
+
conflict, `versions check` fails against the live base, or the repository
|
|
84
|
+
sets `merge.requireStrictBaseFreshness`; under that policy the wait stops
|
|
85
|
+
early, so cancel the stale head's CI with
|
|
86
|
+
`agent-tool pr cancel-runs --head <reviewed-head>`, then integrate,
|
|
87
|
+
validate, review, push, and wait again. Then run
|
|
64
88
|
`agent-tool pr preflight <reviewed-head> <base-branch> <reviewed-base>` to
|
|
65
|
-
recheck CI, live base, PR identity, local state, and explicit
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
recheck CI, conflicts, the live base, PR identity, local state, and explicit
|
|
90
|
+
version policy. When versions are managed,
|
|
91
|
+
`agent-tool versions check <live-base-oid>` must pass. Use the squash-merge
|
|
92
|
+
skill to merge the exact reviewed HEAD.
|
|
93
|
+
6. After confirmed MERGED, follow the reset skill: run
|
|
70
94
|
`agent-tool repo cleanup <PR-number> <reviewed-head> --apply` to return to the
|
|
71
95
|
updated default branch and prune the shipped feature branch, honoring
|
|
72
96
|
stronger repository cleanup rules. Never prune with raw `git branch -D` or
|
|
@@ -75,12 +99,20 @@ command, so they can be found and stopped.
|
|
|
75
99
|
both feature refs. Check the cleanup receipt and verify the local feature ref
|
|
76
100
|
is absent unless preserved; report incomplete cleanup explicitly. Apply
|
|
77
101
|
documented dependency/hook setup.
|
|
78
|
-
|
|
102
|
+
7. When the project publishes npm packages, use `agent-tool release verify
|
|
79
103
|
<package> <version> <merge-oid> --workflow <publish-workflow>` to verify the
|
|
80
104
|
exact workflow and tarball, allowing registry propagation time. When the
|
|
81
105
|
project deploys the merged branch, verify that deployment and documented
|
|
82
106
|
live checks. Report deployment failures
|
|
83
|
-
separately from a successful merge; follow project policy for repairs.
|
|
107
|
+
separately from a successful merge; follow project policy for repairs. A
|
|
108
|
+
release that fails because another merge published the same version needs
|
|
109
|
+
a follow-up version bump through this workflow.
|
|
110
|
+
8. Run `agent-tool repo base-health` again until it is no longer `pending` and
|
|
111
|
+
the merge commit, or a newer tip, has runs (`tip.hasRuns`). When no run
|
|
112
|
+
starts within about ten minutes, as with path filters or PR-only CI, or the
|
|
113
|
+
status is `no-ci`, report that and stop waiting. A failure there belongs to
|
|
114
|
+
this session: fix it forward through this workflow before reporting the
|
|
115
|
+
work done.
|
|
84
116
|
|
|
85
117
|
Before the final report, run `agent-tool teardown` in each repository this work
|
|
86
118
|
touched. Stop what the work started (`teardown --apply`, `proc stop`), stop any
|
|
@@ -92,5 +124,6 @@ Never infer a clean review from process success alone or carry a review across
|
|
|
92
124
|
content changes. Do not weaken configured CI policy to get a merge through.
|
|
93
125
|
If a step fails, preserve useful intermediate work and report the concrete
|
|
94
126
|
remaining issue. Report PR link, merged commit, review verdict, validation, final
|
|
95
|
-
checkout state, the
|
|
96
|
-
|
|
127
|
+
checkout state, the base's health at the start and end and anything repaired or
|
|
128
|
+
hardened, the teardown result, and whether the shipped local branch was pruned
|
|
129
|
+
or preserved.
|
|
@@ -13,15 +13,20 @@ Follow the repository's review-bot policy and require all actionable blocking
|
|
|
13
13
|
review feedback to be addressed before merging.
|
|
14
14
|
|
|
15
15
|
Wait with `agent-tool pr checks --wait --head <reviewed-head>`, which waits for
|
|
16
|
-
checks to appear and for every workflow/job/event entry to finish, and
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
checks to appear and for every workflow/job/event entry to finish, and reports
|
|
17
|
+
`behind: true` when the live base has moved past the head. A moved base alone
|
|
18
|
+
needs no integration: integrate, validate, review, and push again only when
|
|
19
|
+
GitHub reports a conflict, when `versions check` fails against the live base,
|
|
20
|
+
or when the repository sets `merge.requireStrictBaseFreshness`. Under that
|
|
21
|
+
policy the wait stops early at `behind: true`; cancel that head's runs with
|
|
22
|
+
`agent-tool pr cancel-runs --head <reviewed-head>` first. Run
|
|
20
23
|
`agent-tool pr preflight <reviewed-head> <base-branch> <reviewed-base>` immediately
|
|
21
|
-
before merging. It checks local and PR identity,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
before merging. It checks local and PR identity, that the head contains the
|
|
25
|
+
reviewed base, conflicts and merge readiness, explicit version policy against
|
|
26
|
+
the live base, configured strict rulesets, and passing checks; under the strict
|
|
27
|
+
policy the live base must also equal the reviewed one. If an identity changed,
|
|
28
|
+
refresh, integrate, validate, and review again. Read unresolved feedback with
|
|
29
|
+
`pr threads list` and follow project review policy.
|
|
25
30
|
|
|
26
31
|
Use a title that satisfies `agent-tool.json` and pass both reviewed HEAD and
|
|
27
32
|
base branch:
|
|
@@ -32,8 +37,9 @@ agent-tool pr merge 'feat: describe the change' <reviewed-head-oid> <base-branch
|
|
|
32
37
|
|
|
33
38
|
The helper enforces HEAD atomically through GitHub's `expectedHeadOid`, checks
|
|
34
39
|
CI, rejects queued or automatic merges, and creates a subject-only squash with
|
|
35
|
-
the PR reference. GitHub has no atomic expected-base argument in this mutation
|
|
36
|
-
|
|
40
|
+
the PR reference. GitHub has no atomic expected-base argument in this mutation,
|
|
41
|
+
so a base can move between preflight and merge; without the strict policy that
|
|
42
|
+
is accepted, and a break the combination causes is repaired on the base. With
|
|
37
43
|
`merge.requireStrictBaseFreshness`, the helper refuses to merge unless an
|
|
38
44
|
active strict status ruleset that the actor cannot bypass protects the base. Do
|
|
39
45
|
not retarget the PR concurrently with merging.
|
package/src/cli.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { runGroup, listRuns } from "./commands/group";
|
|
|
24
24
|
import { branchCommand } from "./workflows/branch";
|
|
25
25
|
import { commitsCommand, binariesCommand, gateCommand } from "./workflows/checks";
|
|
26
26
|
import { hooksCommand } from "./workflows/hooks";
|
|
27
|
+
import { pushGateCommand } from "./workflows/pushGate";
|
|
27
28
|
import { repoCommand, policyCommand, toolchainCommand } from "./workflows/repository";
|
|
28
29
|
import { mergeReviewedHead, prWorkflowCommand } from "./workflows/pr";
|
|
29
30
|
import { releaseCommand } from "./release/commands";
|
|
@@ -47,7 +48,10 @@ Usage: agent-tool [--repo <directory>] [--config <file>] <command>
|
|
|
47
48
|
commits check --message-file <file> Commit-msg attribution and subject policy
|
|
48
49
|
checks binaries [--staged|--all|--range range|--from-upstream]
|
|
49
50
|
hooks install [--apply] [--adopt] | check
|
|
51
|
+
push-gate hook | check Canonical pre-push body; static check of the declared gate
|
|
52
|
+
push-gate run --pre-push <remote> <url> Built-in guards, then pushGate steps (the pre-push body)
|
|
50
53
|
repo context [--fetch] | cleanup <PR> <shipped-head> [--apply] [--keep-branch]
|
|
54
|
+
repo base-health [--branch name] [--limit N] CI health of the default branch's tip (GitHub only)
|
|
51
55
|
policy check | toolchain check
|
|
52
56
|
ci gate <needs.json|-> [--policy policy.json]
|
|
53
57
|
release plan <package.json> [--github-output] [--allow-private-source]
|
|
@@ -201,6 +205,8 @@ export function main(argv = process.argv.slice(2)): number | Promise<number> {
|
|
|
201
205
|
output({ applied: apply, changes: installSkills(process.cwd(), target, apply) }); return 0;
|
|
202
206
|
}
|
|
203
207
|
if (command === "bun") return bunCommand(args);
|
|
208
|
+
// The hook body needs no checkout, and `run` must resolve the root before clearing Git's hook environment.
|
|
209
|
+
if (command === "push-gate") return pushGateCommand(args);
|
|
204
210
|
if (command === "permissions") {
|
|
205
211
|
const action = args.shift();
|
|
206
212
|
usage(action === "show" || action === "install" || action === "check", "Usage: agent-tool permissions <show|install|check> [--harness <all|claude|codex>] [--apply]");
|
package/src/commands/group.ts
CHANGED
|
@@ -30,9 +30,9 @@ function save(file: string, value: unknown): void {
|
|
|
30
30
|
writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600, flag: "wx" });
|
|
31
31
|
renameSync(temporary, file);
|
|
32
32
|
}
|
|
33
|
-
interface
|
|
34
|
-
export function parseGroup(source: string): { label: string; steps:
|
|
35
|
-
const plan = JSON.parse(source) as { label: string; steps:
|
|
33
|
+
export interface PlanStep { label: string; command: string[] }
|
|
34
|
+
export function parseGroup(source: string): { label: string; steps: PlanStep[] } {
|
|
35
|
+
const plan = JSON.parse(source) as { label: string; steps: PlanStep[] };
|
|
36
36
|
const label = (value: unknown) => typeof value === "string" && value.length > 0 && value.length <= 120 && !/[\x00-\x1f]/.test(value);
|
|
37
37
|
assert(plan && typeof plan === "object" && !Array.isArray(plan) && Object.keys(plan).every(key => ["label", "steps"].includes(key)) && label(plan.label) && Array.isArray(plan.steps) && plan.steps.length > 0, "Invalid run-group plan; expected label and nonempty steps.");
|
|
38
38
|
const labels = new Set<string>();
|
|
@@ -109,6 +109,26 @@ function assertNever(value: never): never { throw new Error(`Unhandled run-group
|
|
|
109
109
|
export async function runGroup(args: string[]): Promise<number> {
|
|
110
110
|
assert(args.length === 1, "Usage: run-group <plan.json>");
|
|
111
111
|
const plan = parseGroup(readFileSync(args[0]!, "utf8"));
|
|
112
|
+
const result = await executeGroup(plan, (record, report) => output({ ...record, report }));
|
|
113
|
+
return reraiseGroupSignal(result);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface GroupResult { record: GroupRecord; report: string; code: number; signal: NodeJS.Signals | null }
|
|
117
|
+
|
|
118
|
+
/** Preserve signal termination for calling shells and supervisors, as `run` does. */
|
|
119
|
+
export async function reraiseGroupSignal({ code, signal }: Pick<GroupResult, "code" | "signal">): Promise<number> {
|
|
120
|
+
if (!signal) return code;
|
|
121
|
+
process.kill(process.pid, signal);
|
|
122
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
123
|
+
return 128 + (constants.signals[signal] ?? 0);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Run a plan's steps and save its report. `publish` runs once the report is
|
|
128
|
+
* final, while signals still reach the group's handlers (which then ignore
|
|
129
|
+
* them), so publishing cannot be cut short. The caller re-raises `signal`.
|
|
130
|
+
*/
|
|
131
|
+
export async function executeGroup(plan: { label: string; steps: PlanStep[] }, publish: (record: GroupRecord, report: string) => void): Promise<GroupResult> {
|
|
112
132
|
const before = sourceState();
|
|
113
133
|
const directory = reportsDirectory(); mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
114
134
|
const id = `${new Date().toISOString().replaceAll(":", "-")}-${randomUUID()}`;
|
|
@@ -149,20 +169,13 @@ export async function runGroup(args: string[]): Promise<number> {
|
|
|
149
169
|
await handleSignals();
|
|
150
170
|
send({ type: "finished", passed: code === 0, endedAt, durationMs }); send(settle);
|
|
151
171
|
save(report, record);
|
|
152
|
-
|
|
172
|
+
publish(record, report);
|
|
153
173
|
// Signals that arrived while publishing reach the handlers, which ignore them now.
|
|
154
174
|
await handleSignals();
|
|
155
175
|
} finally {
|
|
156
176
|
for (const [value, handler] of handlers) process.removeListener(value, handler);
|
|
157
177
|
}
|
|
158
|
-
|
|
159
|
-
if (signal) {
|
|
160
|
-
// Preserve signal termination for calling shells and supervisors, as `run` does.
|
|
161
|
-
process.kill(process.pid, signal);
|
|
162
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
163
|
-
return 128 + (constants.signals[signal] ?? 0);
|
|
164
|
-
}
|
|
165
|
-
return code;
|
|
178
|
+
return { record, report, code, signal: interrupt.signal };
|
|
166
179
|
}
|
|
167
180
|
|
|
168
181
|
export function listRuns(args: string[]): number {
|
package/src/config.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface RequiredCheck {
|
|
|
11
11
|
workflow?: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/** A declared push-gate step: run-group's step shape plus a visible reason when it may be slow. */
|
|
15
|
+
export interface PushGateStep { label: string; command: string[]; allowSlow?: string }
|
|
16
|
+
export interface PushGateConfig { steps: PushGateStep[]; budgetSeconds: number }
|
|
17
|
+
|
|
14
18
|
export interface AgentToolConfig extends WorkflowConfig {
|
|
15
19
|
schemaVersion: 1;
|
|
16
20
|
subject: { conventional: boolean; maxLength: number; types: string[]; lowercaseInitial: boolean; rejectTerminalPeriod: boolean; ignoreGenerated: boolean };
|
|
@@ -22,6 +26,8 @@ export interface AgentToolConfig extends WorkflowConfig {
|
|
|
22
26
|
screenshots: ScreenshotsConfig;
|
|
23
27
|
graph: GraphConfig;
|
|
24
28
|
permissions: { executables: Record<string, PermissionClass> };
|
|
29
|
+
/** Null when the repository declares no push gate. */
|
|
30
|
+
pushGate: PushGateConfig | null;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export const DEFAULT_CONFIG: AgentToolConfig = {
|
|
@@ -43,8 +49,35 @@ export const DEFAULT_CONFIG: AgentToolConfig = {
|
|
|
43
49
|
screenshots: structuredClone(SCREENSHOTS_DEFAULTS),
|
|
44
50
|
graph: structuredClone(GRAPH_DEFAULTS),
|
|
45
51
|
permissions: { executables: {} },
|
|
52
|
+
pushGate: null,
|
|
46
53
|
};
|
|
47
54
|
|
|
55
|
+
export const PUSH_GATE_BUDGET_SECONDS = 120;
|
|
56
|
+
|
|
57
|
+
/** Same step rules as run-group plans, plus an optional non-empty `allowSlow` reason. */
|
|
58
|
+
function parsePushGate(value: unknown): PushGateConfig {
|
|
59
|
+
const input = object(value, "pushGate");
|
|
60
|
+
keys(input, ["steps", "budgetSeconds"], "pushGate");
|
|
61
|
+
const invalid = (setting: string): never => { throw new Error(`Invalid config setting 'pushGate.${setting}'.`); };
|
|
62
|
+
const budgetSeconds = input.budgetSeconds ?? PUSH_GATE_BUDGET_SECONDS;
|
|
63
|
+
if (!Number.isSafeInteger(budgetSeconds) || (budgetSeconds as number) < 1 || (budgetSeconds as number) > 86400) invalid("budgetSeconds");
|
|
64
|
+
const steps = input.steps ?? [];
|
|
65
|
+
if (!Array.isArray(steps)) invalid("steps");
|
|
66
|
+
const label = (text: unknown) => typeof text === "string" && text.length > 0 && text.length <= 120 && !/[\x00-\x1f]/.test(text);
|
|
67
|
+
const labels = new Set<string>();
|
|
68
|
+
const parsed = (steps as unknown[]).map(step => {
|
|
69
|
+
const entry = object(step, "pushGate.steps entry");
|
|
70
|
+
keys(entry, ["label", "command", "allowSlow"], "pushGate.steps entry");
|
|
71
|
+
const { command, allowSlow } = entry;
|
|
72
|
+
if (!label(entry.label) || labels.has(entry.label as string)) invalid("steps");
|
|
73
|
+
if (!Array.isArray(command) || !command.length || !command.every(arg => typeof arg === "string" && !arg.includes("\0")) || !command[0]) invalid("steps");
|
|
74
|
+
if (allowSlow !== undefined && (typeof allowSlow !== "string" || !allowSlow.trim() || /[\x00-\x1f]/.test(allowSlow))) invalid("steps");
|
|
75
|
+
labels.add(entry.label as string);
|
|
76
|
+
return { label: entry.label as string, command: [...command as string[]], ...(allowSlow === undefined ? {} : { allowSlow: allowSlow as string }) };
|
|
77
|
+
});
|
|
78
|
+
return { steps: parsed, budgetSeconds: budgetSeconds as number };
|
|
79
|
+
}
|
|
80
|
+
|
|
48
81
|
function object(value: unknown, name: string): Record<string, unknown> {
|
|
49
82
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
50
83
|
throw new Error(`${name} must be an object.`);
|
|
@@ -77,6 +110,7 @@ export function parseConfig(source: string): AgentToolConfig {
|
|
|
77
110
|
if (input.images !== undefined) result.images = parseImages(input.images);
|
|
78
111
|
if (input.screenshots !== undefined) result.screenshots = parseScreenshots(input.screenshots);
|
|
79
112
|
if (input.graph !== undefined) result.graph = parseGraph(input.graph);
|
|
113
|
+
if (input.pushGate !== undefined && input.pushGate !== null) result.pushGate = parsePushGate(input.pushGate);
|
|
80
114
|
if (input.branch !== undefined && !Object.hasOwn(input.branch as object, "enforce")) result.branch.enforce = true;
|
|
81
115
|
const invalid = (setting: string): never => { throw new Error(`Invalid config setting '${setting}'.`); };
|
|
82
116
|
if (typeof result.subject.conventional !== "boolean") invalid("subject.conventional");
|
|
@@ -19,7 +19,7 @@ export type Decision = "allow" | "ask";
|
|
|
19
19
|
export interface CatalogEntry { command: string; class: PermissionClass; applyClass?: PermissionClass }
|
|
20
20
|
|
|
21
21
|
export const CATALOG: CatalogEntry[] = [
|
|
22
|
-
...["--help", "--version", "logs", "runs list", "doctor", "config show", "branch check", "branch status", "commits check", "checks binaries", "repo context", "policy check", "toolchain check", "ci gate", "release plan", "release verify", "pr context", "pr checks", "pr logs", "pr preflight", "pr threads list", "versions plan", "versions check", "dependencies check-terraform-plan", "dependencies diff", "skills list", "skills check", "hooks check", "images list", "graph check", "state-machines", "permissions show", "permissions check", "proc list"]
|
|
22
|
+
...["--help", "--version", "logs", "runs list", "doctor", "config show", "branch check", "branch status", "commits check", "checks binaries", "repo context", "policy check", "toolchain check", "ci gate", "release plan", "release verify", "pr context", "pr checks", "pr logs", "pr preflight", "pr threads list", "versions plan", "versions check", "dependencies check-terraform-plan", "dependencies diff", "skills list", "skills check", "hooks check", "push-gate hook", "push-gate check", "repo base-health", "images list", "graph check", "state-machines", "permissions show", "permissions check", "proc list"]
|
|
23
23
|
.map(command => ({ command, class: "read" as const })),
|
|
24
24
|
...["bun install", "bun update", "bun remove", "bun test", "branch create", "versions bump", "versions prepare", "versions resolve-conflicts", "images build", "screenshots build", "review", "init", "proc stop"]
|
|
25
25
|
.map(command => ({ command, class: "local" as const })),
|
|
@@ -38,7 +38,7 @@ export const CATALOG: CatalogEntry[] = [
|
|
|
38
38
|
...["bumpVersions", "resolveVersionConflicts", "solicitClaudeCodeReview", "solicitCodexReview", "solicitOpencodeReview"].map(command => ({ command, class: "local" as const })),
|
|
39
39
|
{ command: "openPr", class: "share" },
|
|
40
40
|
];
|
|
41
|
-
// `run`, `run-group` and `proc start` execute arbitrary commands, so they stay unclassified and keep the harness default.
|
|
41
|
+
// `run`, `run-group`, `push-gate run` and `proc start` execute arbitrary commands, so they stay unclassified and keep the harness default.
|
|
42
42
|
// `bun x` runs only executables that `permissions.executables` classifies; project.ts adds those.
|
|
43
43
|
// Package scripts are not classified, so `bun run` keeps the harness default.
|
|
44
44
|
|
|
@@ -113,6 +113,14 @@ export function installPermissions(rootDir: string, target: string, apply = fals
|
|
|
113
113
|
return changes.map(({ relative, status }) => ({ path: relative, status }));
|
|
114
114
|
}
|
|
115
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";
|
|
122
|
+
}
|
|
123
|
+
|
|
116
124
|
/** Read-only CI gate: generated rules are current and recorded as managed. */
|
|
117
125
|
export function checkPermissions(rootDir: string, target: string): PermissionCheck[] {
|
|
118
126
|
const root = realpathSync(rootDir);
|
package/src/skills/bundled.ts
CHANGED
|
@@ -5,8 +5,8 @@ export const BUNDLED_SKILLS: Readonly<Record<string, string>> = {
|
|
|
5
5
|
"open-issue": "---\nname: open-issue\ndescription: Open a GitHub issue the user explicitly requested, assigned to the authenticated GitHub user, with a reviewable title and body.\n---\n\n# Open Issue\n\nOpen an issue only when the user explicitly asks for one; finding a bug,\nrecording evidence, or following another skill does not authorize it. Follow\nrepository guidance for where issues belong, labels, and templates.\n\nResolve the target repository with `agent-tool repo context` (its `repo`\nfield) from the checkout, or the `owner/repo` the user named; never infer it\nfrom a folder name. Before creating, search open issues for a duplicate:\n\n```sh\ngh issue list --repo <owner/repo> --state open --search '<key words>' --json number,title,url\n```\n\nIf one matches, report it instead of opening another, and assign it with\n`gh issue edit <number> --repo <owner/repo> --add-assignee @me` when the user\nwants it tracked.\n\nWrite a specific title and a body that states the observed behavior, the\nexpected behavior, and reproduction steps or evidence (commands, versions,\nlinks). Never include secret values. Use only labels that already exist\n(`gh label list --repo <owner/repo>`). Put the body in a temporary file, then\ncreate the issue assigned to the authenticated GitHub user:\n\n```sh\ngh issue create --repo <owner/repo> --title '<title>' --body-file /path/to/issue-body.md --assignee @me\n```\n\nAlways pass `--assignee @me`; assign other people only when the user names\nthem, in addition to `@me` unless the user says otherwise. Confirm the result\nwith `gh issue view <url> --json url,assignees` and, if the assignee is missing,\nadd it with `gh issue edit <url> --add-assignee @me`. Report the issue URL and\nits assignees, or the exact error if assignment failed.\n",
|
|
6
6
|
"open-pr": "---\nname: open-pr\ndescription: Open a GitHub pull request for the current feature branch with a validated title and a reviewable description.\n---\n\n# Open PR\n\nUse the installed `agent-tool`. Follow repository policy for validation, commits,\nand branch naming. Resolve the repository and default branch with `agent-tool repo context`;\ndo not assume the branch is named main. Preserve unrelated work and finish\nrequested changes and appropriate checks before publishing them.\n\nEnsure the intended commit is on a feature branch and use\n`agent-tool branch push <reviewed-head> --remote <remote>` through normal hooks.\nIt names the destination explicitly and verifies local/remote HEAD afterward;\na changed result needs another review. Respect existing push authorization.\nIf the user only requested a draft description, prepare it without publishing.\n\nWrite a title that satisfies the data-only `agent-tool.json` subject policy.\nDescribe the concrete resulting behavior and relevant validation. When the\nbranch changes package manifests, run\n`agent-tool dependencies diff --base <base-oid>` and name every `newPackages`\nentry in the body with its manifest and version, so a reviewer sees new\nthird-party code however it was added. Put multiline body text in a temporary\nfile, then run:\n\n```sh\nagent-tool pr open 'feat: describe the change' --body-file /path/to/pr-body.txt\n```\n\nOmitting the title uses the latest commit subject. The tool refuses duplicate\nopen PRs and requires the branch to be pushed at its local HEAD. It does not\npush for you. Resolve a fork's head/base identities explicitly if the repository\nuses fork PRs; the initial open helper supports same-repository branches.\n\nReport the created PR link and any remaining validation or review work. Run\n`agent-tool teardown` first, stop what the work started, and report what remains.\n",
|
|
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
|
-
"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`, and other commands whose output drives a
|
|
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
|
|
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.\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, push, and wait again. 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 across\ncontent changes. Do not weaken configured CI policy to get a merge through.\nIf 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
|
+
"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. Read unresolved feedback with\n`pr threads list` and follow project 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
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"
|
|
11
11
|
};
|
|
12
12
|
/** Markdown files a skill ships beside its SKILL.md, by skill and then by path within the skill directory. */
|
package/src/skills/install.ts
CHANGED
|
@@ -84,6 +84,20 @@ export function installSkills(rootDir: string, target: string, apply = false): S
|
|
|
84
84
|
return pending.map(item => item.change);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
const DIRECTORY_HARNESSES: Record<string, string> = { ".claude/skills": "claude", ".agents/skills": "codex", ".opencode/skills": "opencode" };
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Each `--harness` whose directory a repository's ownership manifest records,
|
|
91
|
+
* or null without a manifest, so a check covers every installed directory,
|
|
92
|
+
* OpenCode's included. An unrecognized directory adds `all`.
|
|
93
|
+
*/
|
|
94
|
+
export function installedSkillHarnesses(rootDir: string): string[] | null {
|
|
95
|
+
const root = realpathSync(rootDir);
|
|
96
|
+
if (!existsSync(safeDestination(root, MANIFEST))) return null;
|
|
97
|
+
const directories = new Set(Object.keys(readManifest(root)).map(file => file.split("/", 2).join("/")));
|
|
98
|
+
return [...new Set([...directories].map(directory => DIRECTORY_HARNESSES[directory] ?? "all"))].sort();
|
|
99
|
+
}
|
|
100
|
+
|
|
87
101
|
export interface SkillCheck { path: string; status: "missing" | "outdated" | "unmanaged" | "unchanged" }
|
|
88
102
|
|
|
89
103
|
/** Read-only CI gate: require current bundled bytes and their ownership records. */
|