@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
@@ -0,0 +1,45 @@
1
+ // The live suite's fixture Custom harness (ADR 0031): Codex CLI installed
2
+ // from npm, as a Consumer's file would have it. Its version, config.toml and
3
+ // checkout lists come from the Codex adapter, so a pin bump moves them; the
4
+ // rest of the file is written here. A module, since the published package
5
+ // holds code alone under src/.
6
+
7
+ import { codex } from "../harness/codex.mjs";
8
+
9
+ const adapter = codex({ proxyUrl: "{proxy_url}" });
10
+
11
+ export default {
12
+ display_name: "Codex CLI from npm",
13
+ package: "@openai/codex",
14
+ version: adapter.identity.version,
15
+ profile: "openai",
16
+ default_model: "gpt-6.2-sol",
17
+ effort_values: ["low", "medium", "high"],
18
+ launch: {
19
+ argv: [
20
+ "codex",
21
+ "exec",
22
+ "--json",
23
+ "--strict-config",
24
+ "--skip-git-repo-check",
25
+ "--ephemeral",
26
+ "--ignore-rules",
27
+ "--dangerously-bypass-approvals-and-sandbox",
28
+ ["--model", "{model}"],
29
+ ["--config", 'model_reasoning_effort="{effort}"'],
30
+ "-",
31
+ ],
32
+ stdin: "{brief}",
33
+ files: [
34
+ {
35
+ path: "/agent-kit/custom/config.toml",
36
+ text: adapter.launch.files[0].text,
37
+ },
38
+ ],
39
+ env: {
40
+ CODEX_HOME: "/agent-kit/custom",
41
+ },
42
+ },
43
+ checkout_config: adapter.checkoutConfig,
44
+ instruction_files: adapter.instructionFiles,
45
+ };
@@ -0,0 +1,263 @@
1
+ // What the live suite knows about each harness it proves (ADR 0031): the stub
2
+ // model's dialect and the credential kinds it is run on, the header the proxy
3
+ // writes the real key in, the variable that names the model proxy in the
4
+ // sandbox, and the control for the checkout-config probe: the harness started
5
+ // again in the same sandbox with the checkout's config loaded on purpose, so a
6
+ // run in which none of it left a marker is known to have been able to.
7
+
8
+ import { antigravity } from "../harness/antigravity.mjs";
9
+ import { claudeCode, TOOLS } from "../harness/claude-code.mjs";
10
+ import { codex } from "../harness/codex.mjs";
11
+ import { gemini } from "../harness/gemini.mjs";
12
+ import { anthropicDialect } from "../model-proxy/stub-dialects/anthropic.mjs";
13
+ import { geminiApiDialect } from "../model-proxy/stub-dialects/gemini-api.mjs";
14
+ import { openaiDialect } from "../model-proxy/stub-dialects/openai.mjs";
15
+ import { canary, FAKE_CREDENTIAL, plantedConfig, plantedEnvFiles } from "./host.mjs";
16
+ import { liveOpencode } from "./opencode.mjs";
17
+
18
+ /**
19
+ * @typedef {{
20
+ * adapter: (request?: object) => import("../harness/claude-code.mjs").LaunchPlan,
21
+ * dialect: import("../model-proxy/stub.mjs").StubDialect,
22
+ * credential: (kind: string) => string,
23
+ * upstreamAuth: (kind: string, credential: string) => [string, string],
24
+ * baseUrlVariable: string,
25
+ * removed: readonly string[],
26
+ * harmlessVariables: readonly string[],
27
+ * configControl: readonly string[],
28
+ * assertions?: ReadonlyArray<NamedAssertion>,
29
+ * control: (launch: { plan: import("../harness/claude-code.mjs").LaunchPlan, url: string }) =>
30
+ * { argv: string[], stdin: string },
31
+ * model?: string,
32
+ * shellTool?: string,
33
+ * committed?: Record<string, string>,
34
+ * profiles?: Readonly<Record<string, Partial<LiveHarness>>>,
35
+ * before?: Function,
36
+ * after?: Function,
37
+ * }} LiveHarness `removed` are the checkout paths the Launcher must have
38
+ * removed from the sandbox's copy. `configControl` holds the start of each
39
+ * marker's name the control run must leave. `harmlessVariables` are the
40
+ * `NAME=value` pairs with a GitHub prefix that the harness itself sets.
41
+ * `assertions` are the harness's own, beside the Guards. `profiles` are the
42
+ * model providers a harness is proven on, one run of every scenario each,
43
+ * with what differs by provider (the `model` named among it). `before` and
44
+ * `after` run in a read-only Stage's sandbox around its agent step, and what
45
+ * `after` returns joins the evidence. `control` is missing for a Custom
46
+ * harness, whose own config the suite cannot know how to load; `shellTool`
47
+ * is its file's `probe_shell_tool`, and `committed` its file, planted on
48
+ * the fixture repository's default branch.
49
+ *
50
+ * @typedef {{
51
+ * name: string,
52
+ * check: (evidence: {
53
+ * requests: ReadonlyArray<{ method: string, path: string, body: string }>,
54
+ * transcript: string | null,
55
+ * launcherOutput: string,
56
+ * stage: boolean,
57
+ * decoy?: { registered: boolean, attachedByStage: boolean, attachedWithout: boolean },
58
+ * egress?: { logging: boolean, lines: string[] },
59
+ * }) => string | null,
60
+ * }} NamedAssertion What a run must show of one harness, by name, so that a pin
61
+ * bump that breaks it says why (ADR 0031): `check` gives why it failed, or
62
+ * null.
63
+ */
64
+
65
+ /** A word quoted for `sh`. */
66
+ const quote = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
67
+
68
+ const DONE = "Say that you are done.";
69
+
70
+ /** The removed paths of a plan whose launch removes the checkout's config. */
71
+ const removedBy = ({ launch, checkoutConfig }) =>
72
+ launch.removeCheckoutConfig ? [...checkoutConfig] : [];
73
+
74
+ /** What a harness says when it will not send a model request over plain HTTP. */
75
+ const PLAIN_HTTP_REFUSED =
76
+ /(base[ _]?url.*\bhttps\b|\bmust use https\b|\bhttps is required\b|insecure.*\burl\b|plain[ -]http)/i;
77
+
78
+ /**
79
+ * Gemini CLI documents HTTPS for any base URL but a loopback one, and the
80
+ * pinned version does not enforce it (ADR 0023): the proxy is plain HTTP, and
81
+ * not loopback from the sandbox.
82
+ * @type {Readonly<NamedAssertion>}
83
+ */
84
+ const PLAIN_HTTP = Object.freeze({
85
+ name: "gemini-plain-http-base-url",
86
+ check({ requests, transcript, launcherOutput }) {
87
+ if (requests.length > 0) return null;
88
+ const said = `${transcript ?? ""}\n${launcherOutput}`
89
+ .split("\n")
90
+ .find((line) => PLAIN_HTTP_REFUSED.test(line));
91
+ return said === undefined
92
+ ? "no request of Gemini CLI's reached the model API, so the plain-HTTP base URL is not shown accepted: read the agent step's output."
93
+ : `Gemini CLI ${gemini().identity.version} refused the plain-HTTP base URL of the model proxy (ADR 0023), so it needs the in-sandbox loopback forwarder before this pin ships. It said: ${said.trim()}`;
94
+ },
95
+ });
96
+
97
+ /**
98
+ * Antigravity CLI, in API-key mode, takes the model proxy's plain-HTTP base
99
+ * URL at the pinned version (ADR 0023, #578).
100
+ * @type {Readonly<NamedAssertion>}
101
+ */
102
+ const ANTIGRAVITY_PLAIN_HTTP = Object.freeze({
103
+ name: "antigravity-plain-http-base-url",
104
+ check({ requests, transcript, launcherOutput }) {
105
+ if (requests.length > 0) return null;
106
+ const said = `${transcript ?? ""}\n${launcherOutput}`
107
+ .split("\n")
108
+ .find((line) => PLAIN_HTTP_REFUSED.test(line));
109
+ return said === undefined
110
+ ? "no request of Antigravity CLI's reached the model API, so the plain-HTTP base URL is not shown accepted: read the agent step's output."
111
+ : `Antigravity CLI ${antigravity().identity.version} refused the plain-HTTP base URL of the model proxy (ADR 0023), so it needs an in-sandbox loopback forwarder before this pin ships. It said: ${said.trim()}`;
112
+ },
113
+ });
114
+
115
+ /**
116
+ * What the suite knows for one scenario: its harness's entry, with its
117
+ * provider's own over it.
118
+ * @param {{ harness: string, profile?: string }} scenario
119
+ * @returns {Readonly<LiveHarness>}
120
+ */
121
+ export function liveFor({ harness, profile }) {
122
+ const entry = LIVE_HARNESSES[harness];
123
+ return profile === undefined ? entry : { ...entry, ...entry.profiles[profile] };
124
+ }
125
+
126
+ /** @type {Readonly<Record<string, Readonly<LiveHarness>>>} */
127
+ export const LIVE_HARNESSES = Object.freeze({
128
+ "claude-code": Object.freeze({
129
+ adapter: claudeCode,
130
+ dialect: anthropicDialect,
131
+ credential: (kind) => FAKE_CREDENTIAL[kind](),
132
+ upstreamAuth: (kind, credential) =>
133
+ kind === "api-key" ? ["x-api-key", credential] : ["authorization", `Bearer ${credential}`],
134
+ baseUrlVariable: "ANTHROPIC_BASE_URL",
135
+ removed: removedBy(claudeCode()),
136
+ harmlessVariables: Object.freeze([]),
137
+ configControl: Object.freeze(["settings-", "local-", "mcp-server"]),
138
+ control: ({ url }) => ({
139
+ argv: [
140
+ "claude",
141
+ "--print",
142
+ "--setting-sources",
143
+ "user,project,local",
144
+ "--settings",
145
+ JSON.stringify({ env: { ANTHROPIC_BASE_URL: url } }),
146
+ "--tools",
147
+ TOOLS.join(","),
148
+ "--permission-mode",
149
+ "dontAsk",
150
+ "--no-session-persistence",
151
+ "--max-turns",
152
+ "2",
153
+ ],
154
+ stdin: DONE,
155
+ }),
156
+ }),
157
+ codex: Object.freeze({
158
+ adapter: codex,
159
+ dialect: openaiDialect,
160
+ credential: () => `sk-proj-${canary()}`,
161
+ upstreamAuth: (_kind, credential) => ["authorization", `Bearer ${credential}`],
162
+ baseUrlVariable: "OPENAI_BASE_URL",
163
+ removed: removedBy(codex()),
164
+ // Codex CLI names `cat` as its shell's pager, GitHub's CLI's among them.
165
+ harmlessVariables: Object.freeze(["GH_PAGER=cat"]),
166
+ configControl: Object.freeze(["codex-hook-", "codex-mcp-server"]),
167
+ // The removed config is put back, the project marked trusted, hooks
168
+ // turned on and their trust check skipped, in the Launcher's own config.
169
+ control({ plan }) {
170
+ const planted = Object.entries(plantedConfig()).filter(([path]) =>
171
+ path.startsWith(".codex/"),
172
+ );
173
+ const [config] = plan.launch.files;
174
+ const loading = config.text
175
+ .replace('trust_level = "untrusted"', 'trust_level = "trusted"')
176
+ .replace("\nhooks = false\n", "\nhooks = true\n");
177
+ const argv = [...plan.launch.argv.slice(0, -1), "--dangerously-bypass-hook-trust", "-"];
178
+ const script = [
179
+ "set -eu",
180
+ "mkdir -p /workspace/.codex",
181
+ ...planted.map(
182
+ ([path, text]) => `printf '%s' ${quote(text)} > ${quote(`/workspace/${path}`)}`,
183
+ ),
184
+ `printf '%s' ${quote(loading)} > ${quote(config.path)}`,
185
+ `exec ${argv.map(quote).join(" ")}`,
186
+ ].join("\n");
187
+ return { argv: ["sh", "-c", script], stdin: DONE };
188
+ },
189
+ }),
190
+ gemini: Object.freeze({
191
+ adapter: gemini,
192
+ dialect: geminiApiDialect,
193
+ credential: () => `AIza-${canary()}`,
194
+ upstreamAuth: (_kind, credential) => ["x-goog-api-key", credential],
195
+ baseUrlVariable: "GOOGLE_GEMINI_BASE_URL",
196
+ removed: removedBy(gemini()),
197
+ // Gemini CLI tells GitHub's CLI in its shell not to prompt.
198
+ harmlessVariables: Object.freeze(["GH_PROMPT_DISABLED=1"]),
199
+ configControl: Object.freeze(["gemini-hook-", "gemini-mcp-server"]),
200
+ assertions: Object.freeze([PLAIN_HTTP]),
201
+ // The removed config is put back, hooks turned on and the checkout's
202
+ // `.env` read in the Launcher's own settings, the image's system settings
203
+ // left unread, and no limit on which MCP server may start.
204
+ control({ plan }) {
205
+ const planted = [
206
+ ...Object.entries(plantedConfig()).filter(([path]) => path.startsWith(".gemini/")),
207
+ ...Object.entries(plantedEnvFiles()),
208
+ ];
209
+ const [config] = plan.launch.files;
210
+ const loading = JSON.stringify(
211
+ {
212
+ ...JSON.parse(config.text),
213
+ hooksConfig: { enabled: true },
214
+ advanced: { ignoreLocalEnv: false },
215
+ },
216
+ null,
217
+ 2,
218
+ );
219
+ const argv = [...plan.launch.argv];
220
+ argv.splice(argv.indexOf("--allowed-mcp-server-names"), 2);
221
+ const script = [
222
+ "set -eu",
223
+ "mkdir -p /workspace/.gemini",
224
+ ...planted.map(
225
+ ([path, text]) => `printf '%s' ${quote(text)} > ${quote(`/workspace/${path}`)}`,
226
+ ),
227
+ `printf '%s' ${quote(loading)} > ${quote(config.path)}`,
228
+ "export GEMINI_CLI_SYSTEM_SETTINGS_PATH=/tmp/agent-kit-no-system-settings.json",
229
+ `exec ${argv.map(quote).join(" ")}`,
230
+ ].join("\n");
231
+ return { argv: ["sh", "-c", script], stdin: DONE };
232
+ },
233
+ }),
234
+ antigravity: Object.freeze({
235
+ adapter: antigravity,
236
+ dialect: geminiApiDialect,
237
+ credential: () => `AIza-${canary()}`,
238
+ upstreamAuth: (_kind, credential) => ["x-goog-api-key", credential],
239
+ baseUrlVariable: "GOOGLE_GEMINI_BASE_URL",
240
+ removed: removedBy(antigravity()),
241
+ harmlessVariables: Object.freeze([]),
242
+ configControl: Object.freeze(["agy-hook-", "agy-mcp-server"]),
243
+ assertions: Object.freeze([ANTIGRAVITY_PLAIN_HTTP]),
244
+ // The removed config is put back: Antigravity CLI loads it from the
245
+ // working directory with no trust asked, so the Launcher's own launch is
246
+ // the one that loads it.
247
+ control({ plan }) {
248
+ const planted = Object.entries(plantedConfig()).filter(([path]) =>
249
+ /^[._]agents?\//.test(path),
250
+ );
251
+ const script = [
252
+ "set -eu",
253
+ ...planted.flatMap(([path, text]) => [
254
+ `mkdir -p ${quote(`/workspace/${path.slice(0, path.lastIndexOf("/"))}`)}`,
255
+ `printf '%s' ${quote(text)} > ${quote(`/workspace/${path}`)}`,
256
+ ]),
257
+ `exec ${plan.launch.argv.map(quote).join(" ")}`,
258
+ ].join("\n");
259
+ return { argv: ["sh", "-c", script], stdin: DONE };
260
+ },
261
+ }),
262
+ opencode: liveOpencode,
263
+ });
@@ -44,7 +44,7 @@ export const FAKE_CREDENTIAL = Object.freeze({
44
44
  /** A shell command that leaves the marker `name`, for a planted config to run. */
45
45
  const mark = (name) => `mkdir -p ${MARKER_DIR} && touch ${MARKER_DIR}/${name}`;
46
46
 
47
- /** Claude Code hooks that each leave a marker, prefixed `from`. */
47
+ /** Hooks, in the shape Claude Code and Codex CLI share, that each leave a marker, prefixed `from`. */
48
48
  const hooks = (from) =>
49
49
  Object.fromEntries(
50
50
  ["SessionStart", "UserPromptSubmit", "PreToolUse", "Stop"].map((event) => [
@@ -53,6 +53,31 @@ const hooks = (from) =>
53
53
  ]),
54
54
  );
55
55
 
56
+ /** Hooks in Gemini CLI's own events, each leaving a marker. */
57
+ const geminiHooks = () =>
58
+ Object.fromEntries(
59
+ ["SessionStart", "BeforeAgent", "BeforeTool", "AfterAgent"].map((event) => [
60
+ event,
61
+ [{ hooks: [{ type: "command", command: mark(`gemini-hook-${event}`) }] }],
62
+ ]),
63
+ );
64
+
65
+ /**
66
+ * Hooks in Antigravity CLI's shape, one folder's, each leaving a marker: a
67
+ * named hook with its events' commands.
68
+ */
69
+ const antigravityHooks = (folder) => ({
70
+ planted: Object.fromEntries(
71
+ ["SessionStart", "PreInvocation"].map((event) => [
72
+ event,
73
+ [{ type: "command", command: mark(`agy-hook-${folder}-${event}`) }],
74
+ ]),
75
+ ),
76
+ });
77
+
78
+ /** The folders of a checkout Antigravity CLI loads config from, beside `.gemini/`. */
79
+ const ANTIGRAVITY_FOLDERS = [".agents", ".agent", "_agents", "_agent"];
80
+
56
81
  /**
57
82
  * The executable harness config planted in the checkout, by path: each entry
58
83
  * runs a command, or sets a variable, if the harness loads it.
@@ -69,9 +94,71 @@ export function plantedConfig() {
69
94
  ".mcp.json": JSON.stringify({
70
95
  mcpServers: { planted: { command: "sh", args: ["-c", mark("mcp-server")] } },
71
96
  }),
97
+ // Codex CLI's own: what it loads from a project it trusts.
98
+ ".codex/config.toml": [
99
+ "[shell_environment_policy]",
100
+ `set = { ${PLANTED_ENV} = "1" }`,
101
+ "",
102
+ "[mcp_servers.planted]",
103
+ 'command = "sh"',
104
+ `args = ["-c", ${JSON.stringify(mark("codex-mcp-server"))}]`,
105
+ "",
106
+ ].join("\n"),
107
+ ".codex/hooks.json": JSON.stringify({ hooks: hooks("codex-hook") }),
108
+ ".agents/plugins/marketplace.json": JSON.stringify({ name: "planted", plugins: [] }),
109
+ ".agents/skills/planted/SKILL.md":
110
+ "---\nname: planted\ndescription: A planted skill.\n---\n\nNothing here is real.\n",
111
+ // Antigravity CLI's own: hooks and MCP servers, from each of its folders,
112
+ // with no trust asked.
113
+ ...Object.fromEntries(
114
+ ANTIGRAVITY_FOLDERS.flatMap((folder) => [
115
+ [`${folder}/hooks.json`, JSON.stringify(antigravityHooks(folder))],
116
+ [
117
+ `${folder}/mcp_config.json`,
118
+ JSON.stringify({
119
+ mcpServers: {
120
+ planted: { command: "sh", args: ["-c", mark(`agy-mcp-server-${folder}`)] },
121
+ },
122
+ }),
123
+ ],
124
+ ]),
125
+ ),
126
+ // opencode's own: its project config, at the root and in `.opencode/`.
127
+ ...Object.fromEntries(
128
+ [
129
+ ["opencode.json", "opencode-mcp-server"],
130
+ ["opencode.jsonc", "opencode-mcp-server-jsonc"],
131
+ [".opencode/opencode.json", "opencode-dir-mcp-server"],
132
+ ].map(([path, name]) => [
133
+ path,
134
+ JSON.stringify({
135
+ mcp: {
136
+ servers: {
137
+ [name]: { type: "local", command: ["sh", "-c", mark(name)] },
138
+ },
139
+ },
140
+ }),
141
+ ]),
142
+ ),
143
+ // Gemini CLI's own: what it loads from a folder it trusts. A checkout can
144
+ // also turn a system hook off by name, since those lists merge.
145
+ ".gemini/settings.json": JSON.stringify({
146
+ hooks: geminiHooks(),
147
+ hooksConfig: { disabled: ["planted-system-hook"] },
148
+ mcpServers: { planted: { command: "sh", args: ["-c", mark("gemini-mcp-server")] } },
149
+ }),
72
150
  };
73
151
  }
74
152
 
153
+ /**
154
+ * Environment files that set a variable if the harness loads them, by path.
155
+ * Apart from the rest of the planted config: a Deep scan refuses a repository
156
+ * with a committed `.env` before anything runs.
157
+ */
158
+ export function plantedEnvFiles() {
159
+ return { ".env": `${PLANTED_ENV}=1\n`, ".gemini/.env": `${PLANTED_ENV}=1\n` };
160
+ }
161
+
75
162
  /** The fixture repository's own files: what a Deep scan reads at the trusted ref. */
76
163
  function fixtureFiles(control) {
77
164
  const note = "A fixture for the live suite; nothing here is real.\n";
@@ -105,16 +192,38 @@ function fixtureFiles(control) {
105
192
  * copy-in carries), canary files in the temporary and home folders, and
106
193
  * canaries in the runner's GitHub variables. The launcher's own canary is on
107
194
  * its process's command line, where the workflow puts it.
108
- * @param {{ runner: import("../exec.mjs").Runner, launcherCanary: string }} opts
195
+ * @param {{ runner: import("../exec.mjs").Runner, launcherCanary: string, envFiles?: boolean,
196
+ * committed?: Record<string, string>, configPaths?: readonly string[] }} opts
197
+ * `envFiles` commits the planted environment files too. `committed` are files
198
+ * more to commit on `main`. Each of `configPaths`, a harness's checkout
199
+ * config, is planted unless a planted file already sits at it or under it,
200
+ * so its removal is seen.
109
201
  */
110
- export function plant({ runner, launcherCanary }) {
202
+ export function plant({
203
+ runner,
204
+ launcherCanary,
205
+ envFiles = false,
206
+ committed = {},
207
+ configPaths = [],
208
+ }) {
111
209
  const root = mkdtempSync(join(tmpdir(), "agent-kit-live-repo-"));
112
210
  const control = `AKCONTROL-${id()}`;
113
211
  const write = (path, text) => {
114
212
  mkdirSync(dirname(path), { recursive: true });
115
213
  writeFileSync(path, text);
116
214
  };
117
- for (const [path, text] of Object.entries(fixtureFiles(control))) write(join(root, path), text);
215
+ const files = {
216
+ ...fixtureFiles(control),
217
+ ...(envFiles ? plantedEnvFiles() : {}),
218
+ ...committed,
219
+ };
220
+ const overlaps = (a, b) => a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
221
+ for (const path of configPaths) {
222
+ if (!Object.keys(files).some((file) => overlaps(file, path))) {
223
+ files[path] = "# Planted by the live suite: the checkout's harness config.\n";
224
+ }
225
+ }
226
+ for (const [path, text] of Object.entries(files)) write(join(root, path), text);
118
227
  const git = (...args) => {
119
228
  const r = runner("git", [
120
229
  "-C",