@mnaimfaizy/agent-kit 1.0.0-beta.14 → 1.0.0-beta.15

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.
Files changed (76) hide show
  1. package/README.md +22 -4
  2. package/custom-harness.schema.json +243 -0
  3. package/harnesses.json +244 -6
  4. package/package.json +3 -2
  5. package/src/checks/ci-workflow.mjs +105 -0
  6. package/src/checks/claude-app.mjs +11 -2
  7. package/src/checks/custom-harness.mjs +157 -0
  8. package/src/checks/github-app.mjs +214 -0
  9. package/src/checks/rulesets.mjs +9 -8
  10. package/src/checks/secrets-and-variables.mjs +27 -8
  11. package/src/checks/stages.mjs +705 -0
  12. package/src/cli.mjs +270 -33
  13. package/src/deep-scan/agent.mjs +88 -21
  14. package/src/deep-scan/credential.mjs +81 -32
  15. package/src/deep-scan/docker-driver.mjs +105 -42
  16. package/src/deep-scan/harness-text.mjs +99 -0
  17. package/src/deep-scan/lifecycle.mjs +68 -178
  18. package/src/deep-scan/limits.mjs +13 -7
  19. package/src/deep-scan/model-proxy.mjs +21 -10
  20. package/src/deep-scan/preflight.mjs +19 -6
  21. package/src/deep-scan/recipe.mjs +4 -0
  22. package/src/deep-scan/runtime.mjs +54 -6
  23. package/src/deep-scan/sandbox-run.mjs +232 -0
  24. package/src/deep-scan/sbx-driver.mjs +224 -39
  25. package/src/deep-scan/tar.mjs +69 -22
  26. package/src/deep-scan/verify.mjs +6 -1
  27. package/src/deep-scan.mjs +73 -13
  28. package/src/doctor.mjs +113 -4
  29. package/src/harness/adapters.mjs +30 -0
  30. package/src/harness/antigravity.mjs +187 -0
  31. package/src/harness/claude-code.mjs +8 -1
  32. package/src/harness/codex.mjs +219 -0
  33. package/src/harness/cursor.mjs +199 -0
  34. package/src/harness/custom/registry.mjs +21 -0
  35. package/src/harness/custom/schema.mjs +90 -0
  36. package/src/harness/custom.mjs +299 -0
  37. package/src/harness/facts.mjs +44 -7
  38. package/src/harness/gemini.mjs +164 -0
  39. package/src/harness/install-layer.mjs +86 -3
  40. package/src/harness/opencode.mjs +289 -0
  41. package/src/harness/resolve.mjs +156 -0
  42. package/src/harness/support-levels.mjs +151 -3
  43. package/src/harness-live/assess.mjs +29 -6
  44. package/src/harness-live/cursor-real.mjs +146 -0
  45. package/src/harness-live/cursor-version.mjs +70 -0
  46. package/src/harness-live/cursor.mjs +80 -0
  47. package/src/harness-live/custom.mjs +91 -0
  48. package/src/harness-live/fixture-harness.mjs +45 -0
  49. package/src/harness-live/harnesses.mjs +263 -0
  50. package/src/harness-live/host.mjs +113 -4
  51. package/src/harness-live/opencode.mjs +289 -0
  52. package/src/harness-live/probes.mjs +87 -7
  53. package/src/harness-live/run.mjs +101 -20
  54. package/src/harness-live/setup.mjs +126 -0
  55. package/src/harness-live/stage.mjs +25 -15
  56. package/src/harness-live/suite.mjs +276 -95
  57. package/src/harness-test.mjs +116 -0
  58. package/src/init.mjs +313 -13
  59. package/src/model-proxy/core.mjs +128 -20
  60. package/src/model-proxy/profiles/anthropic.mjs +54 -10
  61. package/src/model-proxy/profiles/gemini-api.mjs +311 -0
  62. package/src/model-proxy/profiles/openai.mjs +327 -0
  63. package/src/model-proxy/stub-dialects/gemini-api.mjs +178 -0
  64. package/src/model-proxy/stub-dialects/openai.mjs +173 -0
  65. package/src/model-proxy/stub.mjs +9 -1
  66. package/src/stage/audit.mjs +79 -0
  67. package/src/stage/egress-route.mjs +207 -0
  68. package/src/stage/implement/carry.mjs +308 -0
  69. package/src/stage/implement/sandbox.mjs +271 -0
  70. package/src/stage/implement/verify.mjs +70 -0
  71. package/src/stage/implement.mjs +218 -0
  72. package/src/stage/plan.mjs +115 -0
  73. package/src/stage/review-response.mjs +172 -0
  74. package/src/stage/review.mjs +185 -0
  75. package/src/stage/workspace.mjs +274 -0
  76. package/src/stage.mjs +1068 -0
package/src/init.mjs CHANGED
@@ -3,6 +3,8 @@
3
3
  // examples/ with its placeholders filled in, writes the Threat pack skeleton
4
4
  // and (if there is none) .github/dependabot.yml, then prints the GitHub-side
5
5
  // steps as `gh` commands for the Consumer to run. It writes only local files.
6
+ // The steps for the chosen harness come from the tag's cli/harnesses.json
7
+ // (ADR 0030); nothing about a harness is written into a Caller.
6
8
  //
7
9
  // Plan first, then write: every file is read and every refusal checked
8
10
  // before anything on disk changes.
@@ -28,7 +30,7 @@ import {
28
30
  uncommittedChanges,
29
31
  } from "./local-writes.mjs";
30
32
  import { caseCollisions, checkSafePath, fileDirConflicts } from "./safe-paths.mjs";
31
- import { isReleaseTag } from "./tags.mjs";
33
+ import { CLI_VERSION, isReleaseTag } from "./tags.mjs";
32
34
  import {
33
35
  DEFAULT_THREAT_PACK_DIR,
34
36
  FLOWS,
@@ -70,6 +72,32 @@ const RESPONSE_LABEL = [
70
72
  "Agent-kit: answer the review on this PR",
71
73
  ];
72
74
 
75
+ const DEFAULT_HARNESS = "claude-code";
76
+ const HARNESS_NAME = /^[a-z][a-z0-9-]*$/;
77
+ const SECRET_INPUT = /^[a-z][a-z0-9_]*$/;
78
+ const HARNESS_FILE = "cli/harnesses.json";
79
+ /** The first tag that ships `cli/harnesses.json`: older ones run claude-code alone. */
80
+ const FIRST_HARNESS_TAG = "v1.0.0-beta.14";
81
+ /** The page that describes the Custom harness file. */
82
+ const CUSTOM_DOCS_URL = `https://github.com/${DEFAULT_KIT_REPO}/blob/v${CLI_VERSION}/docs/adr/0027-a-harness-adapter-returns-a-launch-plan-as-data.md`;
83
+
84
+ /** The Stages each flow runs, and how a reason names each one. */
85
+ const FLOW_STAGES = {
86
+ pipeline: ["plan", "implement", "review"],
87
+ audit: ["security-audit"],
88
+ "review-response": ["review-response"],
89
+ };
90
+ const STAGE_NAMES = {
91
+ plan: "plan",
92
+ implement: "implement",
93
+ review: "review",
94
+ "security-audit": "static security audit",
95
+ "review-response": "Review response",
96
+ };
97
+ /** The Stages that need a pair at `tried` or above (ADR 0028). */
98
+ const SECURITY_STAGES = new Set(["security-audit"]);
99
+ const LEVELS = ["documented", "tried", "verified"];
100
+
73
101
  /** The `init` answers, as flags name them, with what each one asks. */
74
102
  export const QUESTIONS = [
75
103
  { key: "tag", flag: "--tag <vX>", ask: "Agent-kit tag to adopt (for example v1.0.0)" },
@@ -93,7 +121,7 @@ export const QUESTIONS = [
93
121
  {
94
122
  key: "preset",
95
123
  flag: "--preset <name|none>",
96
- ask: "setup_commands preset (python, node, mixed, redis-service, or none)",
124
+ ask: "setup_commands preset (python, node, mixed, or none)",
97
125
  only: ["pipeline", "review-response"],
98
126
  },
99
127
  {
@@ -102,10 +130,15 @@ export const QUESTIONS = [
102
130
  ask: "Folder for the Threat pack",
103
131
  only: ["audit"],
104
132
  },
133
+ { key: "harness", flag: "--harness <name>", ask: "Harness for every Stage" },
105
134
  ];
106
135
 
107
136
  /** Answers with a default: asked about only on a terminal, never required. */
108
- const DEFAULTS = { preset: "none", threatPackDir: DEFAULT_THREAT_PACK_DIR };
137
+ const DEFAULTS = {
138
+ preset: "none",
139
+ threatPackDir: DEFAULT_THREAT_PACK_DIR,
140
+ harness: DEFAULT_HARNESS,
141
+ };
109
142
 
110
143
  const split = (s) =>
111
144
  String(s)
@@ -180,6 +213,18 @@ export function parseAnswer(key, raw, { prompted = false } = {}) {
180
213
  }
181
214
  return { value: dir };
182
215
  }
216
+ case "harness":
217
+ // Which names exist is the tag's to say, so planInit checks that.
218
+ if (s.startsWith("custom:")) {
219
+ return {
220
+ error:
221
+ "--harness takes a built-in harness. A Custom harness is a file you write " +
222
+ `deliberately, so init does not set one up: see ${CUSTOM_DOCS_URL}`,
223
+ };
224
+ }
225
+ return HARNESS_NAME.test(s)
226
+ ? { value: s }
227
+ : { error: `--harness takes a harness name, got ${JSON.stringify(s)}` };
183
228
  default:
184
229
  throw new Error(`unknown answer ${key}`);
185
230
  }
@@ -249,6 +294,65 @@ function tagText(snap, path) {
249
294
  return text;
250
295
  }
251
296
 
297
+ /**
298
+ * A preset's Caller inputs (ADRs 0029 and 0047): its script as
299
+ * `setup_commands`, and the `sandbox_image`, `setup_registries` and, where it
300
+ * names any, `setup_paths` its header names, which are taken out of the
301
+ * script. An older tag's preset names no image or registries: null.
302
+ * @returns {{ script: string, sandbox: { image: string, registries: string[], paths: string[] } | null }}
303
+ */
304
+ function presetParts(text) {
305
+ const named = (input) => new RegExp(`^# ${input}:(.*)\n`, "m");
306
+ const image = named("sandbox_image").exec(text);
307
+ const registries = named("setup_registries").exec(text);
308
+ if (!image || !registries) return { script: text, sandbox: null };
309
+ const paths = named("setup_paths").exec(text);
310
+ return {
311
+ script: text
312
+ .replace(named("sandbox_image"), "")
313
+ .replace(named("setup_registries"), "")
314
+ .replace(named("setup_paths"), ""),
315
+ sandbox: {
316
+ image: image[1].trim(),
317
+ registries: registries[1].split(/\s+/).filter(Boolean),
318
+ paths: paths ? paths[1].split(/\s+/).filter(Boolean) : [],
319
+ },
320
+ };
321
+ }
322
+
323
+ /**
324
+ * The Caller with the preset's `sandbox_image`, `setup_registries` and any
325
+ * `setup_paths` before its `setup_commands`: the implement Stage's Caller and
326
+ * the Review response's both take them.
327
+ */
328
+ function withSandbox(text, sandbox, { preset, tag }) {
329
+ const { image, registries, paths } = sandbox;
330
+ // The values go into YAML as written, so their shape is checked.
331
+ const plain = /^[A-Za-z0-9._/:@-]*$/;
332
+ if (![image, ...registries].every((value) => plain.test(value))) {
333
+ throw new Refusal(
334
+ `examples/setup-presets/${preset}.sh at ${tag} names a sandbox_image or setup_registries that cannot be written into the Caller.`,
335
+ );
336
+ }
337
+ if (!paths.every((path) => /^(\/[A-Za-z0-9._@+-]+)+$/.test(path))) {
338
+ throw new Refusal(
339
+ `examples/setup-presets/${preset}.sh at ${tag} names setup_paths that cannot be written into the Caller.`,
340
+ );
341
+ }
342
+ return text.replace(/^( *)setup_commands: \|$/m, (line, indent) =>
343
+ [
344
+ `${indent}sandbox_image: "${image}"`,
345
+ ...(registries.length
346
+ ? [`${indent}setup_registries: |`, ...registries.map((host) => `${indent} ${host}`)]
347
+ : [`${indent}setup_registries: ""`]),
348
+ ...(paths.length
349
+ ? [`${indent}setup_paths: |`, ...paths.map((path) => `${indent} ${path}`)]
350
+ : []),
351
+ line,
352
+ ].join("\n"),
353
+ );
354
+ }
355
+
252
356
  function presetText(snap, name) {
253
357
  const path = `examples/setup-presets/${name}.sh`;
254
358
  const text = tagText(snap, path);
@@ -274,6 +378,153 @@ function presetText(snap, name) {
274
378
  return text;
275
379
  }
276
380
 
381
+ /** A line of text that prints as one line, as it is. */
382
+ const isLine = (v) => typeof v === "string" && v !== "" && !/[\p{Cc}\p{Zl}\p{Zp}]/u.test(v);
383
+
384
+ /** Whether init can go by a harness's entry, and print its text as it is. */
385
+ const readable = (h) =>
386
+ isLine(h?.displayName) &&
387
+ // It starts a printed line, which must not look like a `$` command.
388
+ /^[\p{L}\p{N}]/u.test(h.displayName) &&
389
+ Array.isArray(h.secrets) &&
390
+ h.secrets.length > 0 &&
391
+ h.secrets.every(
392
+ (x) => typeof x?.name === "string" && SECRET_INPUT.test(x.name) && isLine(x.whereToGet),
393
+ ) &&
394
+ typeof h.supportLevels === "object" &&
395
+ h.supportLevels !== null;
396
+
397
+ /**
398
+ * The harnesses in the tag's `cli/harnesses.json`, or null for a tag from
399
+ * before it. The tag's file, never the installed CLI's adapters; its shape
400
+ * only grows, so fields this CLI does not know are ignored.
401
+ */
402
+ function tagHarnesses(snap) {
403
+ const text = tagText(snap, HARNESS_FILE);
404
+ if (text === null) return null;
405
+ let harnesses;
406
+ try {
407
+ harnesses = JSON.parse(text)?.harnesses;
408
+ } catch {
409
+ // Refused below, with every other shape this CLI cannot read.
410
+ }
411
+ if (
412
+ !harnesses ||
413
+ !Object.hasOwn(harnesses, DEFAULT_HARNESS) ||
414
+ !Object.keys(harnesses).every((name) => HARNESS_NAME.test(name))
415
+ ) {
416
+ throw unreadableHarnesses(snap);
417
+ }
418
+ return harnesses;
419
+ }
420
+
421
+ const unreadableHarnesses = (snap) =>
422
+ new Refusal(`${HARNESS_FILE} at ${snap.tag} is not a harness list this CLI can read.`);
423
+
424
+ /**
425
+ * Why `stage` cannot run on `harness` at `tag`, as sentences, or null if it
426
+ * can. `fallback` is the default harness, which the Stage would stay on.
427
+ */
428
+ function cannotRun(harness, fallback, stage, tag) {
429
+ const { level, wired } = harness.supportLevels[stage] ?? {};
430
+ const name = harness.displayName;
431
+ if (!LEVELS.includes(level)) {
432
+ return `${name} has no Support Level for it at ${tag}, so it cannot run there.`;
433
+ }
434
+ // A tag whose file does not say is judged by the Support Level alone.
435
+ if (wired !== undefined && wired !== true) return `${tag} does not run it on ${name} yet.`;
436
+ if (level !== "documented" || !SECURITY_STAGES.has(stage)) return null;
437
+ const why = `${name} is at Support Level documented on it, and a security Stage needs tried.`;
438
+ // The default harness may sit below the same bar; do not imply it meets it.
439
+ return fallback.supportLevels[stage]?.level === "documented"
440
+ ? `${why} ${fallback.displayName} is documented on it too, and runs it as the default harness.`
441
+ : why;
442
+ }
443
+
444
+ /**
445
+ * What the chosen harness means for the chosen flows: the Stages kept on
446
+ * claude-code, and the harnesses a Stage then runs on. Null for a tag with no
447
+ * `cli/harnesses.json`, which takes claude-code only.
448
+ */
449
+ function planHarness(snap, { harness: chosen = DEFAULT_HARNESS, flows }) {
450
+ const harnesses = tagHarnesses(snap);
451
+ if (harnesses === null) {
452
+ if (chosen === DEFAULT_HARNESS) return null;
453
+ throw new Refusal(
454
+ `${snap.tag} has no ${HARNESS_FILE}: it predates harness choice, so init accepts only ` +
455
+ `${DEFAULT_HARNESS} with it. Harness choice starts with ${FIRST_HARNESS_TAG}.`,
456
+ );
457
+ }
458
+ if (!Object.hasOwn(harnesses, chosen)) {
459
+ throw new Refusal(
460
+ `${snap.tag} has no harness ${JSON.stringify(chosen)}; it has: ` +
461
+ `${Object.keys(harnesses).join(", ")}.`,
462
+ );
463
+ }
464
+ const fallback = harnesses[DEFAULT_HARNESS];
465
+ if (![harnesses[chosen], fallback].every(readable)) throw unreadableHarnesses(snap);
466
+ const stages = flows.flatMap((flow) => FLOW_STAGES[flow]);
467
+ const pins =
468
+ chosen === DEFAULT_HARNESS
469
+ ? []
470
+ : stages.flatMap((stage) => {
471
+ const why = cannotRun(harnesses[chosen], fallback, stage, snap.tag);
472
+ if (!why) return [];
473
+ return [
474
+ { stage, reason: `${STAGE_NAMES[stage]} stays on ${fallback.displayName}: ${why}` },
475
+ ];
476
+ });
477
+ const used = [
478
+ ...(pins.length < stages.length ? [chosen] : []),
479
+ ...(pins.length ? [DEFAULT_HARNESS] : []),
480
+ ];
481
+ return { chosen, pins, used: used.map((name) => harnesses[name]) };
482
+ }
483
+
484
+ /**
485
+ * The secrets of a harness a new Consumer's run reads. A harness's secrets are
486
+ * alternatives, but where each names a `provider` (opencode's), a run reads
487
+ * only the one its model's `provider/model` names, and no model variable is
488
+ * set yet: the default model's.
489
+ */
490
+ function readBy({ secrets, defaultModel }) {
491
+ const provider = isLine(defaultModel) ? /^([^/]+)\/./.exec(defaultModel)?.[1] : undefined;
492
+ const matched = secrets.filter((s) => provider !== undefined && s.provider === provider);
493
+ return matched.length ? { secrets: matched, model: defaultModel } : { secrets };
494
+ }
495
+
496
+ /**
497
+ * The Secrets step's lines for one harness: its preferred credential and the
498
+ * alternatives, each under the repository secret the written Callers pass.
499
+ * Where the model picks the credential, the default model's alone.
500
+ */
501
+ function secretLines(harness, callers) {
502
+ const { displayName } = harness;
503
+ const { secrets, model } = readBy(harness);
504
+ const passed = secrets.flatMap(({ name, whereToGet }) => {
505
+ const read = new RegExp(`^\\s*${name}:\\s*\\$\\{\\{\\s*secrets\\.([A-Za-z_]\\w*)`, "m");
506
+ const secret = read.exec(callers)?.[1];
507
+ return secret ? [{ secret, whereToGet }] : [];
508
+ });
509
+ // Callers that pass none of them: name each secret after its input.
510
+ const offered = passed.length
511
+ ? passed
512
+ : secrets.map(({ name, whereToGet }) => ({ secret: name.toUpperCase(), whereToGet }));
513
+ const [preferred, ...others] = offered;
514
+ return [
515
+ { note: `${displayName}, ${preferred.secret}: ${preferred.whereToGet}` },
516
+ command("gh", "secret", "set", preferred.secret),
517
+ ...others.map((x) => ({ note: ` or set ${x.secret} instead: ${x.whereToGet}` })),
518
+ ...(model === undefined
519
+ ? []
520
+ : [
521
+ {
522
+ note: ` Its default model is ${model}. For another provider's model, set AGENT_KIT_MODEL to it, as provider/model, and set that provider's secret instead.`,
523
+ },
524
+ ]),
525
+ ];
526
+ }
527
+
277
528
  /**
278
529
  * Work out everything init would write and throw Refusal for anything that
279
530
  * stops it. Touches nothing on disk.
@@ -335,12 +586,15 @@ export function planInit({ runner, root, snap, answers, force }) {
335
586
  );
336
587
  }
337
588
 
589
+ const harness = planHarness(snap, answers);
590
+
591
+ const preset = answers.preset ? presetParts(presetText(snap, answers.preset)) : null;
338
592
  const values = {
339
593
  actors: answers.actors,
340
594
  tag,
341
595
  defaultBranch: answers.defaultBranch,
342
596
  verify: answers.verify ?? "",
343
- preset: answers.preset ? presetText(snap, answers.preset) : null,
597
+ preset: preset?.script ?? null,
344
598
  threatPackDir: dir,
345
599
  };
346
600
  for (const flow of answers.flows) {
@@ -354,6 +608,9 @@ export function planInit({ runner, root, snap, answers, force }) {
354
608
  if (err instanceof TemplateError) throw new Refusal(err.message);
355
609
  throw err;
356
610
  }
611
+ if ((flow === "pipeline" || flow === "review-response") && preset?.sandbox) {
612
+ rendered = withSandbox(rendered, preset.sandbox, { preset: answers.preset, tag });
613
+ }
357
614
  if (fileTarget(caller, "Caller")) {
358
615
  conflicts.push(`${caller} (Caller)`);
359
616
  overwrites.push(caller);
@@ -416,7 +673,7 @@ export function planInit({ runner, root, snap, answers, force }) {
416
673
  const { changed: dirty, ignored } = replaced.length
417
674
  ? uncommittedChanges({ runner, root, paths: replaced })
418
675
  : { changed: [], ignored: [] };
419
- return { deletes, writes, conflicts, notes, dependabot, dirty, ignored, unchanged };
676
+ return { deletes, writes, conflicts, notes, dependabot, dirty, ignored, unchanged, harness };
420
677
  }
421
678
 
422
679
  /**
@@ -433,16 +690,18 @@ function variableRead(name, callers) {
433
690
  /**
434
691
  * The GitHub-side steps init does not take, as POSIX-shell commands built
435
692
  * with checks/result.mjs `command()` (every argument fixed or allowlisted).
693
+ * `harness` is planInit's, or null for a tag without cli/harnesses.json.
436
694
  */
437
- export function manualSteps({ flows, tag, kitRepo, serverUrl, callers = "" }) {
695
+ export function manualSteps({ flows, tag, kitRepo, serverUrl, callers = "", harness = null }) {
438
696
  const pipeline = flows.includes("pipeline");
439
697
  const audit = flows.includes("audit");
440
698
  const response = flows.includes("review-response");
441
699
  const lines = [];
442
700
  let n = 0;
701
+ // A command prints after `$`; a `{ note }` prints as text between commands.
443
702
  const step = (title, ...cmds) => {
444
703
  lines.push(`${++n}. ${title}`);
445
- for (const c of cmds) lines.push(` $ ${c}`);
704
+ for (const c of cmds) lines.push(typeof c === "string" ? ` $ ${c}` : ` ${c.note}`);
446
705
  };
447
706
  // Offered only when the Callers pass it; an older tag's do not.
448
707
  const apiKey = /\bsecrets\.ANTHROPIC_API_KEY\b/.test(callers)
@@ -450,11 +709,38 @@ export function manualSteps({ flows, tag, kitRepo, serverUrl, callers = "" }) {
450
709
  : "";
451
710
  const setVariable = (name, value) =>
452
711
  command("gh", "variable", "set", variableRead(name, callers), "--body", value);
453
- step(
454
- `Secrets (gh asks for each value; CLAUDE_CODE_OAUTH_TOKEN comes from \`claude setup-token\`${apiKey}):`,
455
- command("gh", "secret", "set", "CLAUDE_CODE_OAUTH_TOKEN"),
456
- ...(audit ? [command("gh", "secret", "set", "AGENT_KIT_ADVISORIES_TOKEN")] : []),
457
- );
712
+ if (harness && harness.chosen !== DEFAULT_HARNESS) {
713
+ step(
714
+ `Harness (repository variables; unset is ${DEFAULT_HARNESS}):`,
715
+ {
716
+ note:
717
+ "AGENT_KIT_HARNESS applies to every Stage of every Caller, the Deep scan and flows " +
718
+ "you add later included; the pins here cover only the flows of this run.",
719
+ },
720
+ setVariable("AGENT_KIT_HARNESS", harness.chosen),
721
+ ...harness.pins.flatMap(({ stage, reason }) => [
722
+ { note: reason },
723
+ setVariable(
724
+ `AGENT_KIT_${stage.toUpperCase().replaceAll("-", "_")}_HARNESS`,
725
+ DEFAULT_HARNESS,
726
+ ),
727
+ ]),
728
+ );
729
+ }
730
+ const advisories = audit ? [command("gh", "secret", "set", "AGENT_KIT_ADVISORIES_TOKEN")] : [];
731
+ if (harness) {
732
+ step(
733
+ "Secrets (gh asks for each value):",
734
+ ...harness.used.flatMap((h) => secretLines(h, callers)),
735
+ ...advisories,
736
+ );
737
+ } else {
738
+ step(
739
+ `Secrets (gh asks for each value; CLAUDE_CODE_OAUTH_TOKEN comes from \`claude setup-token\`${apiKey}):`,
740
+ command("gh", "secret", "set", "CLAUDE_CODE_OAUTH_TOKEN"),
741
+ ...advisories,
742
+ );
743
+ }
458
744
  const labels = [...(pipeline ? LABELS : []), ...(response ? [RESPONSE_LABEL] : [])];
459
745
  if (labels.length) {
460
746
  step(
@@ -467,8 +753,21 @@ export function manualSteps({ flows, tag, kitRepo, serverUrl, callers = "" }) {
467
753
  if (pipeline) {
468
754
  step("Install the Claude GitHub App on this repository: https://github.com/apps/claude");
469
755
  }
756
+ // Offered only where a Caller names it: an older tag's workflows take none.
757
+ if ((pipeline || response) && /\bAGENT_KIT_APP_ID\b/.test(callers)) {
758
+ step(
759
+ "Optional, your own GitHub App, so CI starts on agent pushes with no approval (skip it " +
760
+ "to use the job token and ci_workflow): create an App with Contents and Pull requests: " +
761
+ "read and write (https://github.com/settings/apps/new), install it on this repository, " +
762
+ "uncomment app_id and app_private_key in the Callers, then set both (one without the " +
763
+ "other fails the run):",
764
+ command("gh", "variable", "set", "AGENT_KIT_APP_ID"),
765
+ command("gh", "secret", "set", "AGENT_KIT_APP_PRIVATE_KEY"),
766
+ { note: "The secret is a file: append < path/to/your-app.private-key.pem to that command." },
767
+ );
768
+ }
470
769
  step(
471
- "Rulesets the Claude GitHub App cannot bypass: list yours, then follow " +
770
+ "Rulesets no GitHub App can bypass: list yours, then follow " +
472
771
  `${serverUrl}/${kitRepo}/blob/${tag}/docs/repository-hardening.md`,
473
772
  command("gh", "api", "repos/{owner}/{repo}/rulesets"),
474
773
  );
@@ -649,6 +948,7 @@ export async function runInit({
649
948
  tag: answers.tag,
650
949
  kitRepo: DEFAULT_KIT_REPO,
651
950
  serverUrl,
951
+ harness: plan.harness,
652
952
  callers: answers.flows
653
953
  .map((flow) => FLOWS[flow].caller)
654
954
  .map((path) => plan.writes.find((w) => w.path === path).bytes.toString("utf8"))