@mnaimfaizy/agent-kit 1.0.0-beta.6 → 1.0.0-beta.7
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/src/callers.mjs +23 -1
- package/src/checks/review-response.mjs +205 -0
- package/src/cli.mjs +6 -3
- package/src/doctor.mjs +7 -0
- package/src/init.mjs +34 -8
- package/src/templates.mjs +12 -8
package/README.md
CHANGED
|
@@ -11,12 +11,13 @@ npx @mnaimfaizy/agent-kit upgrade --tag <new-tag> # move to another tag (asks
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
- The package holds only code. Kit files are read from the git tag your `uses:` pins name, never bundled.
|
|
14
|
+
- `doctor` checks, from your Callers, every secret and repository variable they read (each flow's Kill switch, such as `CLAUDE_REVIEW_RESPONSE_ENABLED`, is required), every Trigger label they use (such as `agent:address-review`), the Claude GitHub App, and the rulesets. With a Review response Caller, it reports `CLAUDE_REVIEW_RESPONSE_MODE`: unset or `manual` passes as manual, any other value but `auto` warns, and `auto` fails unless the review Caller passes `response_mode` and a `response_workflow` naming a Review response Caller that passes `response_mode` and has a `workflow_dispatch` trigger with a `pr_number` input.
|
|
14
15
|
- `doctor` is read-only. It runs git in your checkout without hooks or configured filter commands, never changes files or GitHub settings, and for anything to fix prints a POSIX-shell `gh` command for you to run.
|
|
15
16
|
- No runtime dependencies. Needs Node.js 22 or later, `git`, and (outside `--ci`) `gh` logged in with admin on the repository.
|
|
16
17
|
- Tags before `v1.0.0-alpha.11` have no `kit-owned-paths.txt`, and the CLI refuses them: adopt those by hand with that tag's `docs/adopt.md`.
|
|
17
18
|
- `upgrade --tag <vY>` reads the current tag from your Agent-kit `uses:` pins (they must agree), replaces each Kit-owned path vY lists (delete, then copy), deletes paths only the old tag listed, rewrites only the `@<tag>` of those pins, prints the `examples/` diff between the two tags for you to apply by hand, and then runs the `doctor --ci` checks. Every refusal is checked before anything is written. It refuses a path with uncommitted changes unless `--force`, refuses symbolic links in or above a Kit-owned path, and copies only regular and executable files from the tag. Ignored files inside a replaced path are deleted with it, and listed first. After a Dependabot pin bump, when the pins already name vY, add `--from <vX>` to also delete paths only vX listed and see the `examples/` diff. It asks before writing; pass `--yes` when there is no terminal. It writes only local files and commits nothing; where `core.fileMode` is off (Windows), it stages each copied file with the tag's mode (`git add --chmod=+x` or `-x`), so the executable bit is neither lost nor kept by mistake.
|
|
18
|
-
- `init --tag <vX>` copies the Kit-owned paths, writes `.github/workflows/agent-pipeline.yml` and/or `
|
|
19
|
+
- `init --tag <vX>` copies the Kit-owned paths, writes `.github/workflows/agent-pipeline.yml`, `security-audit.yml` and/or `agent-review-response.yml` from the tag's `examples/` with your answers filled in (`--flows pipeline,audit,review-response`, `--actors`, `--default-branch`, `--verify`, `--preset`), writes the Threat pack skeleton to `.security/` (or `--threat-pack-dir`) and `.github/dependabot.yml` if there is none, and prints the GitHub-side steps as `gh` commands. It refuses to overwrite an existing Caller or Kit-owned path without `--force`, never overwrites an existing Threat pack file, and leaves Kit-owned paths that already match the tag alone (so `init --flows audit` later adds that flow); use `upgrade` to change tags. `--yes` asks nothing.
|
|
19
20
|
|
|
20
|
-
The package version matches the Agent-kit Release line: `@mnaimfaizy/agent-kit@1.0.0-beta.
|
|
21
|
+
The package version matches the Agent-kit Release line: `@mnaimfaizy/agent-kit@1.0.0-beta.7` is published from tag `v1.0.0-beta.7`, with npm provenance.
|
|
21
22
|
|
|
22
23
|
Full documentation: [Getting started](https://github.com/mnaimfaizy/agent-kit/blob/main/docs/getting-started.md) and [Adopt](https://github.com/mnaimfaizy/agent-kit/blob/main/docs/adopt.md#check-an-adoption-with-doctor).
|
package/package.json
CHANGED
package/src/callers.mjs
CHANGED
|
@@ -145,6 +145,22 @@ function unsupportedSecrets(value) {
|
|
|
145
145
|
return null;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
/**
|
|
149
|
+
* The input names of a workflow's `workflow_dispatch` trigger: [] when it
|
|
150
|
+
* takes none, null when the workflow has no such trigger. `on:` may be a
|
|
151
|
+
* mapping, one event name, or a list of names.
|
|
152
|
+
*/
|
|
153
|
+
function dispatchInputs(on) {
|
|
154
|
+
const named = (text) => /(?:^|[\s,[])workflow_dispatch(?:$|[\s,\]])/.test(text);
|
|
155
|
+
if (typeof on === "string") return named(on) ? [] : null;
|
|
156
|
+
if (!on || typeof on !== "object") return null;
|
|
157
|
+
if (on.$seq) return on.$seq.some((line) => named(String(line))) ? [] : null;
|
|
158
|
+
if (!("workflow_dispatch" in on)) return null;
|
|
159
|
+
const trigger = on.workflow_dispatch;
|
|
160
|
+
const inputs = trigger && typeof trigger === "object" && !trigger.$seq ? trigger.inputs : null;
|
|
161
|
+
return inputs && typeof inputs === "object" && !inputs.$seq ? Object.keys(inputs) : [];
|
|
162
|
+
}
|
|
163
|
+
|
|
148
164
|
/**
|
|
149
165
|
* The jobs of one workflow file that call an Agent-kit reusable workflow.
|
|
150
166
|
* `parseIncomplete` is set when the file has more Agent-kit pins than jobs
|
|
@@ -174,7 +190,13 @@ export function parseCaller(text) {
|
|
|
174
190
|
? `${pins.length} Agent-kit pin(s) but only ${jobs.length} job(s) doctor could read; ` +
|
|
175
191
|
"the rest were not checked"
|
|
176
192
|
: null;
|
|
177
|
-
return {
|
|
193
|
+
return {
|
|
194
|
+
jobs,
|
|
195
|
+
pins,
|
|
196
|
+
variables: variableRefs(text),
|
|
197
|
+
dispatchInputs: dispatchInputs(doc.on),
|
|
198
|
+
parseIncomplete,
|
|
199
|
+
};
|
|
178
200
|
}
|
|
179
201
|
|
|
180
202
|
/** Workflow files in .github/workflows/ (relative paths, sorted). */
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// Review response mode: what CLAUDE_REVIEW_RESPONSE_MODE is set to, and, in
|
|
2
|
+
// auto mode, whether the Callers carry what the Handoff needs. The Trigger
|
|
3
|
+
// label and the Kill switch variable are covered by the trigger-labels and
|
|
4
|
+
// variables checks, which read them from the Callers like any other flow's.
|
|
5
|
+
//
|
|
6
|
+
// Auto mode needs both ends wired: the review Caller passes `response_mode`
|
|
7
|
+
// and names the Review response Caller in `response_workflow`, and that
|
|
8
|
+
// Caller passes `response_mode` and takes a `workflow_dispatch` with a
|
|
9
|
+
// `pr_number` input. Anything short of that never starts a round, without an
|
|
10
|
+
// error anywhere a Consumer would look.
|
|
11
|
+
|
|
12
|
+
import { result } from "./result.mjs";
|
|
13
|
+
|
|
14
|
+
const ID = "review-response-mode";
|
|
15
|
+
const TITLE = "Review response mode is set up";
|
|
16
|
+
export const MODE_VARIABLE = "CLAUDE_REVIEW_RESPONSE_MODE";
|
|
17
|
+
const RESPONSE_REUSABLE = "agent-review-response-reusable.yml";
|
|
18
|
+
const REVIEW_REUSABLE = "agent-review-reusable.yml";
|
|
19
|
+
/** What the review workflow's handoff accepts as `response_workflow`. */
|
|
20
|
+
const WORKFLOW_PATH = /^\.github\/workflows\/[A-Za-z0-9_-][A-Za-z0-9._-]*\.ya?ml$/;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The variable's value as a workflow run sees it: the repository's, else the
|
|
24
|
+
* organization's. null when neither sets it. Throws when it cannot be read.
|
|
25
|
+
*/
|
|
26
|
+
export function readMode(github, repo, ownerType) {
|
|
27
|
+
try {
|
|
28
|
+
return String(github.getJson(`repos/${repo}/actions/variables/${MODE_VARIABLE}`).value ?? "");
|
|
29
|
+
} catch (err) {
|
|
30
|
+
if (err?.httpStatus !== 404) throw err;
|
|
31
|
+
}
|
|
32
|
+
if (ownerType !== "Organization") return null;
|
|
33
|
+
const lines = github.getLines(
|
|
34
|
+
`repos/${repo}/actions/organization-variables`,
|
|
35
|
+
`.variables[] | select(.name == "${MODE_VARIABLE}") | .value`,
|
|
36
|
+
);
|
|
37
|
+
return lines.length ? lines[0] : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const jobsUsing = (callers, file) =>
|
|
41
|
+
callers.flatMap((caller) =>
|
|
42
|
+
caller.jobs
|
|
43
|
+
.filter((job) => job.uses.file === file)
|
|
44
|
+
.map((job) => ({ caller, job, where: `${caller.path}:${job.name}` })),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const passes = (job, input) =>
|
|
48
|
+
typeof job.with?.[input] === "string" && job.with[input].trim() !== "";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Where a job's `response_mode` comes from: "auto" (the literal), "variable"
|
|
52
|
+
* (an expression reading the mode variable), "other" (anything else), or
|
|
53
|
+
* null when the job does not pass it.
|
|
54
|
+
*/
|
|
55
|
+
export function modeSource(job) {
|
|
56
|
+
if (!passes(job, "response_mode")) return null;
|
|
57
|
+
const value = job.with.response_mode.trim();
|
|
58
|
+
if (value === "auto") return "auto";
|
|
59
|
+
// An expression that reads the variable: `${{ vars.CLAUDE_REVIEW_RESPONSE_MODE || 'manual' }}`.
|
|
60
|
+
if (/^\$\{\{.*\bvars\.CLAUDE_REVIEW_RESPONSE_MODE\b.*\}\}$/i.test(value)) return "variable";
|
|
61
|
+
return "other";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Does any Caller hardcode `response_mode: auto`, whatever the variable says? */
|
|
65
|
+
const hardcodesAuto = (callers) =>
|
|
66
|
+
[...jobsUsing(callers, RESPONSE_REUSABLE), ...jobsUsing(callers, REVIEW_REUSABLE)].some(
|
|
67
|
+
({ job }) => modeSource(job) === "auto",
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Why a job would not see `auto` as its `response_mode`, given the
|
|
72
|
+
* variable's value; null when it would.
|
|
73
|
+
*/
|
|
74
|
+
function notAuto(job, mode, consequence) {
|
|
75
|
+
const source = modeSource(job);
|
|
76
|
+
if (source === null) {
|
|
77
|
+
return `does not pass response_mode (vars.${MODE_VARIABLE}), so ${consequence}.`;
|
|
78
|
+
}
|
|
79
|
+
if (source === "other") {
|
|
80
|
+
return (
|
|
81
|
+
`passes response_mode ${JSON.stringify(job.with.response_mode.trim())}, which neither ` +
|
|
82
|
+
`reads vars.${MODE_VARIABLE} nor is auto, so ${consequence}.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (source === "variable" && mode !== "auto") {
|
|
86
|
+
return `reads response_mode from vars.${MODE_VARIABLE}, which is not auto, so ${consequence}.`;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Why auto mode would never start a round from these Callers; empty when it
|
|
93
|
+
* would. `mode` is the variable's value (null when unset).
|
|
94
|
+
*/
|
|
95
|
+
export function autoModeProblems(callers, mode = "auto") {
|
|
96
|
+
const problems = [];
|
|
97
|
+
const responders = jobsUsing(callers, RESPONSE_REUSABLE);
|
|
98
|
+
// A responder file whose trigger is wrong is reported once, here, not again
|
|
99
|
+
// for every review Caller that names it.
|
|
100
|
+
const responderFiles = new Set(responders.map((r) => r.caller.path));
|
|
101
|
+
for (const caller of new Set(responders.map((r) => r.caller))) {
|
|
102
|
+
if (caller.dispatchInputs === null) {
|
|
103
|
+
problems.push(
|
|
104
|
+
`${caller.path}: has no workflow_dispatch trigger, so the review handoff cannot start it.`,
|
|
105
|
+
);
|
|
106
|
+
} else if (!caller.dispatchInputs.includes("pr_number")) {
|
|
107
|
+
problems.push(
|
|
108
|
+
`${caller.path}: its workflow_dispatch trigger has no pr_number input, so GitHub refuses the review handoff's dispatch.`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const { job, where } of responders) {
|
|
113
|
+
const why = notAuto(job, mode, "its gate refuses every dispatched round");
|
|
114
|
+
if (why) problems.push(`${where}: ${why}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const reviewers = jobsUsing(callers, REVIEW_REUSABLE);
|
|
118
|
+
if (reviewers.length === 0) {
|
|
119
|
+
problems.push(
|
|
120
|
+
`No Caller uses ${REVIEW_REUSABLE}, so no review hands off: auto mode never starts a round.`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
for (const { job, where } of reviewers) {
|
|
124
|
+
const why = notAuto(job, mode, "its reviews never hand off");
|
|
125
|
+
if (why) problems.push(`${where}: ${why}`);
|
|
126
|
+
const target = passes(job, "response_workflow") ? job.with.response_workflow.trim() : "";
|
|
127
|
+
if (!target) {
|
|
128
|
+
problems.push(
|
|
129
|
+
`${where}: does not pass response_workflow, your Review response Caller as .github/workflows/<file>.yml.`,
|
|
130
|
+
);
|
|
131
|
+
} else if (target.includes("${{")) {
|
|
132
|
+
problems.push(`${where}: response_workflow is an expression, which doctor cannot check.`);
|
|
133
|
+
} else if (!WORKFLOW_PATH.test(target)) {
|
|
134
|
+
problems.push(
|
|
135
|
+
`${where}: response_workflow ${JSON.stringify(target)} is not a file directly under .github/workflows/.`,
|
|
136
|
+
);
|
|
137
|
+
} else if (!responderFiles.has(target)) {
|
|
138
|
+
problems.push(
|
|
139
|
+
`${where}: response_workflow ${JSON.stringify(target)} is not a Review response Caller here ` +
|
|
140
|
+
`(a workflow whose job uses ${RESPONSE_REUSABLE}).`,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return problems;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function checkReviewResponseMode({ github, repo, ownerType, callers }) {
|
|
148
|
+
if (jobsUsing(callers, RESPONSE_REUSABLE).length === 0) {
|
|
149
|
+
return result(ID, TITLE, "pass", "No Caller uses the Review response flow.");
|
|
150
|
+
}
|
|
151
|
+
let mode;
|
|
152
|
+
try {
|
|
153
|
+
mode = readMode(github, repo, ownerType);
|
|
154
|
+
} catch (err) {
|
|
155
|
+
return result(ID, TITLE, "skip", `Could not read ${MODE_VARIABLE}: ${err.message}`);
|
|
156
|
+
}
|
|
157
|
+
// A Caller that hardcodes `response_mode: auto` is in auto mode whatever
|
|
158
|
+
// the variable says, so its wiring is checked too.
|
|
159
|
+
if (mode !== "auto" && hardcodesAuto(callers)) {
|
|
160
|
+
const problems = autoModeProblems(callers, mode);
|
|
161
|
+
if (problems.length) {
|
|
162
|
+
return result(
|
|
163
|
+
ID,
|
|
164
|
+
TITLE,
|
|
165
|
+
"fail",
|
|
166
|
+
`A Caller passes response_mode: auto, but ${problems.length} problem(s) keep the handoff from starting a round.`,
|
|
167
|
+
{ details: problems },
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return result(
|
|
171
|
+
ID,
|
|
172
|
+
TITLE,
|
|
173
|
+
"pass",
|
|
174
|
+
"Auto (response_mode: auto in the Callers): a finished review that left findings starts a round.",
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
if (mode === null || mode === "" || mode === "manual") {
|
|
178
|
+
return result(
|
|
179
|
+
ID,
|
|
180
|
+
TITLE,
|
|
181
|
+
"pass",
|
|
182
|
+
`Manual: ${MODE_VARIABLE} is ${mode === null ? "not set" : JSON.stringify(mode)}, so only the Trigger label starts a round.`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
if (mode !== "auto") {
|
|
186
|
+
return result(
|
|
187
|
+
ID,
|
|
188
|
+
TITLE,
|
|
189
|
+
"warn",
|
|
190
|
+
`${MODE_VARIABLE} is ${JSON.stringify(mode)}, which is not exactly auto, so Review response stays manual.`,
|
|
191
|
+
{ details: ["Set it to auto for auto mode, or to manual (or delete it) for manual mode."] },
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
const problems = autoModeProblems(callers, mode);
|
|
195
|
+
if (problems.length) {
|
|
196
|
+
return result(
|
|
197
|
+
ID,
|
|
198
|
+
TITLE,
|
|
199
|
+
"fail",
|
|
200
|
+
`${MODE_VARIABLE} is auto, but ${problems.length} problem(s) keep the handoff from starting a round.`,
|
|
201
|
+
{ details: problems },
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return result(ID, TITLE, "pass", "Auto: a finished review that left findings starts a round.");
|
|
205
|
+
}
|
package/src/cli.mjs
CHANGED
|
@@ -35,13 +35,16 @@ Options for doctor:
|
|
|
35
35
|
|
|
36
36
|
Options for init (each one is asked for when missing, on a terminal):
|
|
37
37
|
--tag <vX> The Agent-kit tag to adopt.
|
|
38
|
-
--flows <list> pipeline, audit
|
|
38
|
+
--flows <list> pipeline, audit and/or review-response
|
|
39
|
+
(comma-separated).
|
|
39
40
|
--actors <logins> GitHub logins allowed to trigger runs.
|
|
40
41
|
--default-branch <b> Default branch (default: origin's HEAD, else main).
|
|
41
|
-
--verify <commands> verify_commands
|
|
42
|
+
--verify <commands> verify_commands (pipeline: implement's checks;
|
|
43
|
+
review-response: the agent's checks). In a
|
|
42
44
|
prompt, \\n separates commands.
|
|
43
45
|
--preset <name|none> Inline examples/setup-presets/<name>.sh as
|
|
44
|
-
setup_commands (pipeline;
|
|
46
|
+
setup_commands (pipeline, review-response;
|
|
47
|
+
default none).
|
|
45
48
|
--threat-pack-dir <d> Where the Threat pack goes (audit; default .security).
|
|
46
49
|
--yes Ask nothing; every answer comes from flags.
|
|
47
50
|
--force Overwrite existing Callers, Threat pack files and
|
package/src/doctor.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { checkKitOwnedTrees } from "./checks/kit-owned-trees.mjs";
|
|
|
9
9
|
import { checkLabels } from "./checks/labels.mjs";
|
|
10
10
|
import { checkPins } from "./checks/pins.mjs";
|
|
11
11
|
import { result, sanitizeLine } from "./checks/result.mjs";
|
|
12
|
+
import { checkReviewResponseMode } from "./checks/review-response.mjs";
|
|
12
13
|
import {
|
|
13
14
|
checkCreationRule,
|
|
14
15
|
checkPersonalTagPush,
|
|
@@ -46,6 +47,7 @@ export const LOCAL_ONLY_CHECKS = [
|
|
|
46
47
|
["ruleset-creation", "Release branches have a creation rule"],
|
|
47
48
|
["ruleset-tags", "Release tags have a v* tag ruleset"],
|
|
48
49
|
["release-tag-push", "Release tags can be pushed under the tag ruleset"],
|
|
50
|
+
["review-response-mode", "Review response mode is set up"],
|
|
49
51
|
];
|
|
50
52
|
|
|
51
53
|
const skipAll = (ids, reason) => ids.map(([id, title]) => result(id, title, "skip", reason));
|
|
@@ -303,6 +305,11 @@ function localChecks({ runner, cwd, info, files, callers, snapshot }) {
|
|
|
303
305
|
out.push(...skipAll(LOCAL_ONLY_CHECKS.slice(4, 7), rulesetError));
|
|
304
306
|
}
|
|
305
307
|
out.push(guarded("release-tag-push", () => checkPersonalTagPush({ ownerType, files })));
|
|
308
|
+
out.push(
|
|
309
|
+
guarded("review-response-mode", () =>
|
|
310
|
+
checkReviewResponseMode({ github, repo, ownerType, callers }),
|
|
311
|
+
),
|
|
312
|
+
);
|
|
306
313
|
return raw;
|
|
307
314
|
}
|
|
308
315
|
|
package/src/init.mjs
CHANGED
|
@@ -63,11 +63,20 @@ const LABELS = [
|
|
|
63
63
|
["agent:implement", "0E8A16", "Agent-kit: implement the Verified plan"],
|
|
64
64
|
["agent:review", "5319E7", "Agent-kit: review this PR"],
|
|
65
65
|
];
|
|
66
|
+
const RESPONSE_LABEL = [
|
|
67
|
+
"agent:address-review",
|
|
68
|
+
"FBCA04",
|
|
69
|
+
"Agent-kit: answer the review on this PR",
|
|
70
|
+
];
|
|
66
71
|
|
|
67
72
|
/** The `init` answers, as flags name them, with what each one asks. */
|
|
68
73
|
export const QUESTIONS = [
|
|
69
74
|
{ key: "tag", flag: "--tag <vX>", ask: "Agent-kit tag to adopt (for example v1.0.0)" },
|
|
70
|
-
{
|
|
75
|
+
{
|
|
76
|
+
key: "flows",
|
|
77
|
+
flag: "--flows pipeline,audit,review-response",
|
|
78
|
+
ask: "Flows to set up (pipeline, audit, review-response)",
|
|
79
|
+
},
|
|
71
80
|
{
|
|
72
81
|
key: "actors",
|
|
73
82
|
flag: "--actors <login,...>",
|
|
@@ -78,19 +87,19 @@ export const QUESTIONS = [
|
|
|
78
87
|
key: "verify",
|
|
79
88
|
flag: "--verify <commands>",
|
|
80
89
|
ask: "verify_commands (lint/tests/typecheck; use \\n between commands)",
|
|
81
|
-
only: "pipeline",
|
|
90
|
+
only: ["pipeline", "review-response"],
|
|
82
91
|
},
|
|
83
92
|
{
|
|
84
93
|
key: "preset",
|
|
85
94
|
flag: "--preset <name|none>",
|
|
86
95
|
ask: "setup_commands preset (python, node, mixed, redis-service, or none)",
|
|
87
|
-
only: "pipeline",
|
|
96
|
+
only: ["pipeline", "review-response"],
|
|
88
97
|
},
|
|
89
98
|
{
|
|
90
99
|
key: "threatPackDir",
|
|
91
100
|
flag: "--threat-pack-dir <dir>",
|
|
92
101
|
ask: "Folder for the Threat pack",
|
|
93
|
-
only: "audit",
|
|
102
|
+
only: ["audit"],
|
|
94
103
|
},
|
|
95
104
|
];
|
|
96
105
|
|
|
@@ -118,7 +127,9 @@ export function parseAnswer(key, raw, { prompted = false } = {}) {
|
|
|
118
127
|
const flows = [...new Set(split(s))];
|
|
119
128
|
const bad = flows.filter((f) => !(f in FLOWS));
|
|
120
129
|
if (flows.length === 0 || bad.length) {
|
|
121
|
-
return {
|
|
130
|
+
return {
|
|
131
|
+
error: `--flows takes pipeline, audit and/or review-response, got ${JSON.stringify(s)}`,
|
|
132
|
+
};
|
|
122
133
|
}
|
|
123
134
|
return { value: Object.keys(FLOWS).filter((f) => flows.includes(f)) };
|
|
124
135
|
}
|
|
@@ -184,7 +195,7 @@ export async function collectAnswers({ flags, prompt, yes, defaultBranch }) {
|
|
|
184
195
|
const answers = {};
|
|
185
196
|
const missing = [];
|
|
186
197
|
for (const q of QUESTIONS) {
|
|
187
|
-
if (q.only && answers.flows && !answers.flows.includes(
|
|
198
|
+
if (q.only && answers.flows && !q.only.some((f) => answers.flows.includes(f))) continue;
|
|
188
199
|
let raw = flags[q.key];
|
|
189
200
|
let prompted = false;
|
|
190
201
|
const fallback = q.key === "defaultBranch" ? defaultBranch : DEFAULTS[q.key];
|
|
@@ -414,6 +425,7 @@ export function planInit({ runner, root, snap, answers, force }) {
|
|
|
414
425
|
export function manualSteps({ flows, tag, kitRepo, serverUrl }) {
|
|
415
426
|
const pipeline = flows.includes("pipeline");
|
|
416
427
|
const audit = flows.includes("audit");
|
|
428
|
+
const response = flows.includes("review-response");
|
|
417
429
|
const lines = [];
|
|
418
430
|
let n = 0;
|
|
419
431
|
const step = (title, ...cmds) => {
|
|
@@ -425,13 +437,16 @@ export function manualSteps({ flows, tag, kitRepo, serverUrl }) {
|
|
|
425
437
|
command("gh", "secret", "set", "CLAUDE_CODE_OAUTH_TOKEN"),
|
|
426
438
|
...(audit ? [command("gh", "secret", "set", "AGENT_KIT_ADVISORIES_TOKEN")] : []),
|
|
427
439
|
);
|
|
428
|
-
|
|
440
|
+
const labels = [...(pipeline ? LABELS : []), ...(response ? [RESPONSE_LABEL] : [])];
|
|
441
|
+
if (labels.length) {
|
|
429
442
|
step(
|
|
430
443
|
"Trigger labels:",
|
|
431
|
-
...
|
|
444
|
+
...labels.map(([name, color, description]) =>
|
|
432
445
|
command("gh", "label", "create", name, "--color", color, "--description", description),
|
|
433
446
|
),
|
|
434
447
|
);
|
|
448
|
+
}
|
|
449
|
+
if (pipeline) {
|
|
435
450
|
step("Install the Claude GitHub App on this repository: https://github.com/apps/claude");
|
|
436
451
|
}
|
|
437
452
|
step(
|
|
@@ -447,7 +462,18 @@ export function manualSteps({ flows, tag, kitRepo, serverUrl }) {
|
|
|
447
462
|
...(audit
|
|
448
463
|
? [command("gh", "variable", "set", "CLAUDE_SECURITY_AUDIT_ENABLED", "--body", "true")]
|
|
449
464
|
: []),
|
|
465
|
+
...(response
|
|
466
|
+
? [command("gh", "variable", "set", "CLAUDE_REVIEW_RESPONSE_ENABLED", "--body", "true")]
|
|
467
|
+
: []),
|
|
450
468
|
);
|
|
469
|
+
if (response) {
|
|
470
|
+
step(
|
|
471
|
+
"Optional, Review response auto mode (a finished review starts a round): first give your " +
|
|
472
|
+
"review Caller response_mode and response_workflow, as " +
|
|
473
|
+
`${serverUrl}/${kitRepo}/blob/${tag}/docs/review-response.md#auto-mode says, then:`,
|
|
474
|
+
command("gh", "variable", "set", "CLAUDE_REVIEW_RESPONSE_MODE", "--body", "auto"),
|
|
475
|
+
);
|
|
476
|
+
}
|
|
451
477
|
return lines;
|
|
452
478
|
}
|
|
453
479
|
|
package/src/templates.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
export class TemplateError extends Error {}
|
|
9
9
|
|
|
10
|
-
/** The
|
|
10
|
+
/** The flows init sets up, keyed by the name `--flows` takes, in the order it writes them. */
|
|
11
11
|
export const FLOWS = {
|
|
12
12
|
pipeline: {
|
|
13
13
|
example: "examples/plan-implement-review-caller.yml",
|
|
@@ -17,6 +17,10 @@ export const FLOWS = {
|
|
|
17
17
|
example: "examples/security-audit-caller.yml",
|
|
18
18
|
caller: ".github/workflows/security-audit.yml",
|
|
19
19
|
},
|
|
20
|
+
"review-response": {
|
|
21
|
+
example: "examples/review-response-caller.yml",
|
|
22
|
+
caller: ".github/workflows/agent-review-response.yml",
|
|
23
|
+
},
|
|
20
24
|
};
|
|
21
25
|
|
|
22
26
|
export const DEFAULT_THREAT_PACK_DIR = ".security";
|
|
@@ -44,31 +48,31 @@ export const PLACEHOLDERS = [
|
|
|
44
48
|
{
|
|
45
49
|
name: "your-github-login",
|
|
46
50
|
pattern: /your-github-login/g,
|
|
47
|
-
counts: { pipeline:
|
|
51
|
+
counts: { pipeline: 5, audit: 1, "review-response": 1 },
|
|
48
52
|
replace: (v) => () => v.actors.join('","'),
|
|
49
53
|
},
|
|
50
54
|
{
|
|
51
55
|
name: "the @vX.Y.Z pin of each Agent-kit uses:",
|
|
52
56
|
pattern: KIT_PIN,
|
|
53
|
-
counts: { pipeline: 3, audit: 1 },
|
|
57
|
+
counts: { pipeline: 3, audit: 1, "review-response": 1 },
|
|
54
58
|
replace: (v) => (_, path) => `${path}@${v.tag}`,
|
|
55
59
|
},
|
|
56
60
|
{
|
|
57
61
|
name: '"main" (the default branch)',
|
|
58
62
|
pattern: /"main"/g,
|
|
59
|
-
counts: { pipeline: 2, audit: 0 },
|
|
63
|
+
counts: { pipeline: 2, audit: 0, "review-response": 0 },
|
|
60
64
|
replace: (v) => () => `"${v.defaultBranch}"`,
|
|
61
65
|
},
|
|
62
66
|
{
|
|
63
67
|
name: "the placeholder verify_commands echo line",
|
|
64
68
|
pattern: VERIFY_LINE,
|
|
65
|
-
counts: { pipeline: 1, audit: 0 },
|
|
69
|
+
counts: { pipeline: 1, audit: 0, "review-response": 1 },
|
|
66
70
|
replace: (v) => (_, indent) => indentLines(v.verify, indent),
|
|
67
71
|
},
|
|
68
72
|
{
|
|
69
73
|
name: "the commented `# setup_commands: |` block",
|
|
70
74
|
pattern: SETUP_BLOCK,
|
|
71
|
-
counts: { pipeline: 1, audit: 0 },
|
|
75
|
+
counts: { pipeline: 1, audit: 0, "review-response": 1 },
|
|
72
76
|
replace: (v) => (match, indent) =>
|
|
73
77
|
v.preset === null
|
|
74
78
|
? match
|
|
@@ -77,13 +81,13 @@ export const PLACEHOLDERS = [
|
|
|
77
81
|
{
|
|
78
82
|
name: '".security/threat-model.md"',
|
|
79
83
|
pattern: /"\.security\/threat-model\.md"/g,
|
|
80
|
-
counts: { pipeline: 0, audit: 1 },
|
|
84
|
+
counts: { pipeline: 0, audit: 1, "review-response": 0 },
|
|
81
85
|
replace: (v) => () => `"${v.threatPackDir}/threat-model.md"`,
|
|
82
86
|
},
|
|
83
87
|
{
|
|
84
88
|
name: '".security/findings-ledger.md"',
|
|
85
89
|
pattern: /"\.security\/findings-ledger\.md"/g,
|
|
86
|
-
counts: { pipeline: 0, audit: 1 },
|
|
90
|
+
counts: { pipeline: 0, audit: 1, "review-response": 0 },
|
|
87
91
|
replace: (v) => () => `"${v.threatPackDir}/findings-ledger.md"`,
|
|
88
92
|
},
|
|
89
93
|
];
|