@mnaimfaizy/agent-kit 1.0.0-beta.7 → 1.0.0-beta.8
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 +2 -2
- package/package.json +1 -1
- package/src/callers.mjs +8 -5
- package/src/checks/secrets-and-variables.mjs +65 -15
- package/src/init.mjs +1 -1
package/README.md
CHANGED
|
@@ -11,13 +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
|
+
- `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; a Stage switch such as `CLAUDE_PLAN_ENABLED` is optional), and warns about a variable [ADR 0009](../docs/adr/0009-stage-settings-resolve-in-the-caller.md) renamed that is still set under its old name, naming the new one, 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.
|
|
15
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.
|
|
16
16
|
- No runtime dependencies. Needs Node.js 22 or later, `git`, and (outside `--ci`) `gh` logged in with admin on the repository.
|
|
17
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`.
|
|
18
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.
|
|
19
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.
|
|
20
20
|
|
|
21
|
-
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.8` is published from tag `v1.0.0-beta.8`, with npm provenance.
|
|
22
22
|
|
|
23
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
|
@@ -111,14 +111,17 @@ export function secretNames(value) {
|
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Every `vars.X` a file reads. A variable is optional when every read of it
|
|
114
|
-
* falls back with `||` (as the model variables do)
|
|
115
|
-
* (
|
|
116
|
-
*
|
|
117
|
-
* expression.
|
|
114
|
+
* falls back with `||` (as the model variables do) or only tests `== 'false'`
|
|
115
|
+
* (a Stage switch: unset means on); otherwise it is required (the Kill switch
|
|
116
|
+
* variables: unset means the flow never runs). The `||` may follow closing
|
|
117
|
+
* parentheses, and may sit on the next line of a multi-line expression.
|
|
118
118
|
*/
|
|
119
119
|
export function variableRefs(text) {
|
|
120
120
|
const refs = new Map();
|
|
121
|
-
const re = new RegExp(
|
|
121
|
+
const re = new RegExp(
|
|
122
|
+
`vars\\.(${NAME})((?:\\s*\\))*\\s*\\|\\||\\s*==\\s*'false'(?![\\w']))?`,
|
|
123
|
+
"g",
|
|
124
|
+
);
|
|
122
125
|
for (const m of lines(text).join("\n").matchAll(re)) {
|
|
123
126
|
const optional = Boolean(m[2]);
|
|
124
127
|
const prev = refs.get(m[1]);
|
|
@@ -218,6 +218,21 @@ export function checkSecrets({ github, repo, ownerType, requirements }) {
|
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Variables ADR 0009 renamed, old name to new. The Callers have no fallback to
|
|
223
|
+
* an old name, so one still set does nothing once the Caller reads the new one.
|
|
224
|
+
*/
|
|
225
|
+
export const RENAMED_VARIABLES = {
|
|
226
|
+
CLAUDE_PIPELINE_ENABLED: "CLAUDE_AGENT_FLOW_ENABLED",
|
|
227
|
+
CLAUDE_MODEL_PLAN: "CLAUDE_PLAN_MODEL",
|
|
228
|
+
CLAUDE_MODEL_IMPLEMENT: "CLAUDE_IMPLEMENT_MODEL",
|
|
229
|
+
CLAUDE_MODEL_REVIEW: "CLAUDE_REVIEW_MODEL",
|
|
230
|
+
CLAUDE_MODEL_REVIEW_RESPONSE: "CLAUDE_REVIEW_RESPONSE_MODEL",
|
|
231
|
+
CLAUDE_MODEL_AUDIT: "CLAUDE_SECURITY_AUDIT_MODEL",
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const killSwitch = (name) => /_ENABLED$/.test(name);
|
|
235
|
+
|
|
221
236
|
export function checkVariables({ github, repo, ownerType, requirements }) {
|
|
222
237
|
const ID = "variables";
|
|
223
238
|
const TITLE = "Repository variables the Callers read are set";
|
|
@@ -227,26 +242,61 @@ export function checkVariables({ github, repo, ownerType, requirements }) {
|
|
|
227
242
|
} catch (err) {
|
|
228
243
|
return result(ID, TITLE, "skip", `Could not list repository variables: ${err.message}`);
|
|
229
244
|
}
|
|
245
|
+
const isSet = (name) => listed.names.has(name.toUpperCase());
|
|
230
246
|
const required = requirements.variables.filter((v) => !v.optional && !isProvided(v.name));
|
|
231
|
-
const missing = required.filter((v) => !
|
|
232
|
-
|
|
247
|
+
const missing = required.filter((v) => !isSet(v.name));
|
|
248
|
+
// An old name still set while a Caller reads its replacement: the value is ignored.
|
|
249
|
+
const read = new Map(requirements.variables.map((v) => [v.name.toUpperCase(), v]));
|
|
250
|
+
const renamed = Object.entries(RENAMED_VARIABLES)
|
|
251
|
+
.filter(([oldName, newName]) => isSet(oldName) && read.has(newName))
|
|
252
|
+
.map(([oldName, newName]) => ({ oldName, newName, v: read.get(newName) }));
|
|
253
|
+
if (missing.length === 0 && renamed.length === 0) {
|
|
233
254
|
return result(ID, TITLE, "pass", `All ${required.length} required variable(s) are set.`);
|
|
234
255
|
}
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
256
|
+
const details = [
|
|
257
|
+
...missing.map(
|
|
258
|
+
(v) =>
|
|
259
|
+
`not set: ${v.name} (${v.where.join(", ")})` +
|
|
260
|
+
(killSwitch(v.name)
|
|
261
|
+
? " — the Kill switch: the flow never runs until it is set to true"
|
|
262
|
+
: ""),
|
|
263
|
+
),
|
|
264
|
+
...renamed.map(
|
|
265
|
+
({ oldName, newName, v }) =>
|
|
266
|
+
`renamed: ${oldName} is still set, but the Callers read ${newName} (${v.where.join(", ")}). ` +
|
|
267
|
+
`${oldName} is ignored: ` +
|
|
268
|
+
(isSet(newName)
|
|
269
|
+
? `${newName} is set too, so delete ${oldName}.`
|
|
270
|
+
: `set ${newName} to its value, then delete ${oldName}.`),
|
|
271
|
+
),
|
|
272
|
+
];
|
|
273
|
+
if (listed.orgNote && missing.length) details.push(listed.orgNote);
|
|
242
274
|
// The Kill switch takes true; for anything else, gh prompts for the value.
|
|
275
|
+
const toSet = [
|
|
276
|
+
...missing.map((v) => v.name),
|
|
277
|
+
...renamed.filter((r) => !isSet(r.newName)).map((r) => r.newName),
|
|
278
|
+
].filter((name, i, all) => all.indexOf(name) === i);
|
|
243
279
|
const { fix, notes } = splitFixes(
|
|
244
|
-
|
|
245
|
-
setCommand("variable",
|
|
280
|
+
toSet.map((name) =>
|
|
281
|
+
setCommand("variable", name, repo, killSwitch(name) ? ["--body", "true"] : []),
|
|
246
282
|
),
|
|
247
283
|
);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
284
|
+
// Each old name goes last, once its replacement has a value: deleting first
|
|
285
|
+
// would lose the value before it is copied. The old names are the kit's own.
|
|
286
|
+
for (const { oldName } of renamed) {
|
|
287
|
+
fix.push(command("gh", "variable", "delete", oldName, "--repo", repo));
|
|
288
|
+
}
|
|
289
|
+
if (missing.length) {
|
|
290
|
+
return result(ID, TITLE, "fail", `${missing.length} required variable(s) missing.`, {
|
|
291
|
+
details: [...details, ...notes],
|
|
292
|
+
fix,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
return result(
|
|
296
|
+
ID,
|
|
297
|
+
TITLE,
|
|
298
|
+
"warn",
|
|
299
|
+
`${renamed.length} renamed variable(s) still set under the old name.`,
|
|
300
|
+
{ details: [...details, ...notes], fix },
|
|
301
|
+
);
|
|
252
302
|
}
|
package/src/init.mjs
CHANGED
|
@@ -457,7 +457,7 @@ export function manualSteps({ flows, tag, kitRepo, serverUrl }) {
|
|
|
457
457
|
step(
|
|
458
458
|
"Last, after you have reviewed and pushed the Callers, turn the flows on (Kill switch variables):",
|
|
459
459
|
...(pipeline
|
|
460
|
-
? [command("gh", "variable", "set", "
|
|
460
|
+
? [command("gh", "variable", "set", "CLAUDE_AGENT_FLOW_ENABLED", "--body", "true")]
|
|
461
461
|
: []),
|
|
462
462
|
...(audit
|
|
463
463
|
? [command("gh", "variable", "set", "CLAUDE_SECURITY_AUDIT_ENABLED", "--body", "true")]
|