@intentius/chant 0.124.76 → 0.124.77
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/dist/__fixtures__/agent-guard/plywood.d.ts +8 -0
- package/dist/__fixtures__/agent-guard/plywood.d.ts.map +1 -0
- package/dist/__fixtures__/agent-guard/plywood.js +19 -0
- package/dist/__fixtures__/agent-guard/terragucci.d.ts +8 -0
- package/dist/__fixtures__/agent-guard/terragucci.d.ts.map +1 -0
- package/dist/__fixtures__/agent-guard/terragucci.js +30 -0
- package/dist/__fixtures__/gated-ledger.d.ts +10 -0
- package/dist/__fixtures__/gated-ledger.d.ts.map +1 -0
- package/dist/__fixtures__/gated-ledger.js +51 -0
- package/dist/agent-guard.d.ts +143 -0
- package/dist/agent-guard.d.ts.map +1 -0
- package/dist/agent-guard.js +456 -0
- package/dist/ci-commit.d.ts +54 -3
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +69 -7
- package/dist/ci-own-jobs.d.ts +81 -0
- package/dist/ci-own-jobs.d.ts.map +1 -0
- package/dist/ci-own-jobs.js +234 -0
- package/dist/ci-product.d.ts +39 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +40 -0
- package/dist/cli/handlers/approve.d.ts +5 -1
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +17 -11
- package/dist/cli/handlers/build.d.ts +1 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +88 -2
- package/dist/cli/handlers/commit.d.ts.map +1 -1
- package/dist/cli/handlers/commit.js +3 -1
- package/dist/cli/handlers/notify-relay.d.ts +18 -1
- package/dist/cli/handlers/notify-relay.d.ts.map +1 -1
- package/dist/cli/handlers/notify-relay.js +90 -14
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +3 -1
- package/dist/cli/handlers/release.d.ts +5 -1
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +17 -5
- package/dist/cli/handlers/run-generate.d.ts.map +1 -1
- package/dist/cli/handlers/run-generate.js +2 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +21 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +60 -4
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/pr-env-components.d.ts +65 -0
- package/dist/components/pr-env-components.d.ts.map +1 -0
- package/dist/components/pr-env-components.js +163 -0
- package/dist/components/pr-policy.d.ts +15 -0
- package/dist/components/pr-policy.d.ts.map +1 -1
- package/dist/components/pr-policy.js +24 -1
- package/dist/components/release-compile.d.ts +15 -3
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +66 -15
- package/dist/gate-policy.d.ts +14 -1
- package/dist/gate-policy.d.ts.map +1 -1
- package/dist/gate-policy.js +16 -6
- package/dist/lexicon.d.ts +17 -1
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lexicon.js +1 -0
- package/dist/lifecycle/gated-op.d.ts +95 -0
- package/dist/lifecycle/gated-op.d.ts.map +1 -0
- package/dist/lifecycle/gated-op.js +96 -0
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +83 -2
- package/dist/notify-relay-repo.d.ts +131 -0
- package/dist/notify-relay-repo.d.ts.map +1 -0
- package/dist/notify-relay-repo.js +202 -0
- package/dist/notify-relay.d.ts +25 -1
- package/dist/notify-relay.d.ts.map +1 -1
- package/dist/notify-relay.js +28 -2
- package/dist/op/op-waves-capability.js +2 -2
- package/dist/policy-engine.d.ts +95 -0
- package/dist/policy-engine.d.ts.map +1 -0
- package/dist/policy-engine.js +158 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/state-export.d.ts +126 -0
- package/dist/state-export.d.ts.map +1 -0
- package/dist/state-export.js +157 -0
- package/dist/state-migration.d.ts +148 -0
- package/dist/state-migration.d.ts.map +1 -0
- package/dist/state-migration.js +147 -0
- package/dist/state-unlock.d.ts +167 -0
- package/dist/state-unlock.d.ts.map +1 -0
- package/dist/state-unlock.js +197 -0
- package/dist/wave-runtime.mjs +329 -329
- package/dist/workspace/declaration.schema.json +1 -1
- package/dist/workspace/release-workflow.d.ts +10 -0
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +8 -3
- package/package.json +1 -1
- package/src/__fixtures__/agent-guard/plywood.ts +27 -0
- package/src/__fixtures__/agent-guard/terragucci.ts +39 -0
- package/src/__fixtures__/gated-ledger.ts +58 -0
- package/src/agent-guard.test.ts +320 -0
- package/src/agent-guard.ts +548 -0
- package/src/ci-commit.test.ts +50 -2
- package/src/ci-commit.ts +93 -9
- package/src/ci-own-jobs.test.ts +109 -0
- package/src/ci-own-jobs.ts +253 -0
- package/src/ci-product.ts +81 -0
- package/src/cli/handlers/approve-cwd.test.ts +112 -0
- package/src/cli/handlers/approve.ts +22 -11
- package/src/cli/handlers/build-own-jobs.test.ts +80 -0
- package/src/cli/handlers/build-pr-loop-control.test.ts +88 -0
- package/src/cli/handlers/build-run-group.test.ts +60 -0
- package/src/cli/handlers/build.ts +83 -3
- package/src/cli/handlers/commit.ts +3 -0
- package/src/cli/handlers/notify-relay.ts +99 -17
- package/src/cli/handlers/pr.ts +3 -1
- package/src/cli/handlers/release.ts +15 -5
- package/src/cli/handlers/run-generate.ts +2 -1
- package/src/cli/main.ts +21 -1
- package/src/cli/parse-args.ts +45 -3
- package/src/cli/registry.ts +16 -0
- package/src/components/pr-env-components.test.ts +138 -0
- package/src/components/pr-env-components.ts +214 -0
- package/src/components/pr-policy.test.ts +41 -1
- package/src/components/pr-policy.ts +25 -1
- package/src/components/release-compile.test.ts +47 -0
- package/src/components/release-compile.ts +70 -13
- package/src/gate-policy-bundle.test.ts +14 -0
- package/src/gate-policy.test.ts +7 -0
- package/src/gate-policy.ts +22 -7
- package/src/lexicon.ts +18 -1
- package/src/lifecycle/gated-op.ts +158 -0
- package/src/lifecycle/git.test.ts +92 -0
- package/src/lifecycle/git.ts +71 -2
- package/src/notify-relay-repo.test.ts +284 -0
- package/src/notify-relay-repo.ts +234 -0
- package/src/notify-relay.test.ts +12 -0
- package/src/notify-relay.ts +30 -3
- package/src/op/op-waves-capability.ts +2 -2
- package/src/policy-engine.test.ts +163 -0
- package/src/policy-engine.ts +201 -0
- package/src/release-floors.ts +1 -1
- package/src/state-export.test.ts +125 -0
- package/src/state-export.ts +228 -0
- package/src/state-migration.test.ts +134 -0
- package/src/state-migration.ts +237 -0
- package/src/state-unlock.test.ts +166 -0
- package/src/state-unlock.ts +294 -0
- package/src/workspace/declaration.schema.json +1 -1
- package/src/workspace/release-workflow.test.ts +34 -0
- package/src/workspace/release-workflow.ts +17 -3
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent guard (#4770): a speed bump that keeps a coding agent in a
|
|
3
|
+
* checkout from running what applies, approves or overrides, so the change
|
|
4
|
+
* goes through a pull request and a person's approval. terragucci and
|
|
5
|
+
* plywood each had one; a product now passes its words and rules here.
|
|
6
|
+
*
|
|
7
|
+
* Two layers, both written by {@link installAgentGuard}:
|
|
8
|
+
*
|
|
9
|
+
* - a Claude Code PreToolUse hook on Bash: one Node script that reads the
|
|
10
|
+
* tool call on stdin and blocks (exit 2, Claude Code's block code) a
|
|
11
|
+
* command line that would run a refused command;
|
|
12
|
+
* - a wrapper per engine binary, for the agent's shell to put ahead of the
|
|
13
|
+
* real binary on PATH: it refuses the same commands and runs the next
|
|
14
|
+
* binary of that name on PATH for everything else.
|
|
15
|
+
*
|
|
16
|
+
* The rule lives once, in {@link makeGuard}. The script carries its source
|
|
17
|
+
* (`makeGuard.toString()`) and its config as JSON, and imports Node's modules
|
|
18
|
+
* only; {@link agentGuard} runs the same function in process, so a product's
|
|
19
|
+
* `guard check` and the hook give the same answers.
|
|
20
|
+
*
|
|
21
|
+
* Two installs: `local` writes the script and wrappers under the checkout's
|
|
22
|
+
* git directory, with absolute paths, and the hook into
|
|
23
|
+
* `.claude/settings.local.json`, listed in `.git/info/exclude`; `project`
|
|
24
|
+
* writes the script to `.claude/hooks/<product>-guard.mjs` and the hook into
|
|
25
|
+
* `.claude/settings.json` as `$CLAUDE_PROJECT_DIR/...`, meant to be
|
|
26
|
+
* committed, and the wrappers to `.<product>/agent-bin`.
|
|
27
|
+
*
|
|
28
|
+
* An agent that calls the real binary by its path, through a script, or with
|
|
29
|
+
* credentials of its own gets past it; the control is the credentials. Roots
|
|
30
|
+
* are written into the script, so the guard is written again after they
|
|
31
|
+
* change.
|
|
32
|
+
*/
|
|
33
|
+
import { spawnSync } from "node:child_process";
|
|
34
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
35
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
36
|
+
import { NEXT_RELEASE } from "./release-floors.js";
|
|
37
|
+
/** The first chant with the shared agent guard (#4770). Products feature-detect on it, or on `installAgentGuard`. */
|
|
38
|
+
export const AGENT_GUARD_FLOOR = NEXT_RELEASE;
|
|
39
|
+
/**
|
|
40
|
+
* The rule. It references nothing outside itself: the guard's script carries
|
|
41
|
+
* its source text, so keep it to its parameters and ES2020.
|
|
42
|
+
*/
|
|
43
|
+
export function makeGuard(config, deps) {
|
|
44
|
+
const { realpathSync, resolve, basename, join, relative, sep } = deps;
|
|
45
|
+
const real = (p) => {
|
|
46
|
+
try {
|
|
47
|
+
return realpathSync(p);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return resolve(p);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const repo = real(config.repo !== undefined ? config.repo : resolve(deps.scriptDir || ".", config.repoFromScript || "."));
|
|
54
|
+
const roots = config.roots === undefined ? undefined : config.roots.map((r) => real(join(repo, r)));
|
|
55
|
+
const words = config.words;
|
|
56
|
+
const rules = config.rules;
|
|
57
|
+
const inside = (at, dir) => at === dir || at.startsWith(dir === sep ? dir : dir + sep);
|
|
58
|
+
const bare = (f) => f.replace(/^--?/, "");
|
|
59
|
+
const flagIs = (a, names) => {
|
|
60
|
+
if (!names || !/^--?[^-]/.test(a))
|
|
61
|
+
return false;
|
|
62
|
+
const n = bare(a).replace(/=.*$/, "");
|
|
63
|
+
return names.some((f) => bare(f) === n);
|
|
64
|
+
};
|
|
65
|
+
const message = (what, where) => {
|
|
66
|
+
const at = where === undefined ? "" : (words.where === undefined ? " in {root}" : words.where).split("{root}").join(where);
|
|
67
|
+
return words.product + " guard: " + words.refusal.split("{what}").join(what).split("{where}").join(at);
|
|
68
|
+
};
|
|
69
|
+
function verdict(bin, args, cwd) {
|
|
70
|
+
const e = rules.engines[bin];
|
|
71
|
+
if (!e)
|
|
72
|
+
return undefined;
|
|
73
|
+
let dir = cwd;
|
|
74
|
+
let all = false;
|
|
75
|
+
let refusedFlag;
|
|
76
|
+
const ws = [];
|
|
77
|
+
for (let i = 0; i < args.length; i++) {
|
|
78
|
+
const a = args[i];
|
|
79
|
+
if (flagIs(a, e.dirFlags)) {
|
|
80
|
+
const eq = a.indexOf("=");
|
|
81
|
+
if (eq >= 0)
|
|
82
|
+
dir = resolve(cwd, a.slice(eq + 1));
|
|
83
|
+
else if (i + 1 < args.length)
|
|
84
|
+
dir = resolve(cwd, args[++i]);
|
|
85
|
+
}
|
|
86
|
+
else if (e.allFlags && e.allFlags.indexOf(a) >= 0)
|
|
87
|
+
all = true;
|
|
88
|
+
else if (flagIs(a, e.refuseFlags))
|
|
89
|
+
refusedFlag = refusedFlag || a.replace(/=.*$/, "");
|
|
90
|
+
else if (e.valuedFlags && e.valuedFlags.indexOf(a) >= 0)
|
|
91
|
+
i++;
|
|
92
|
+
else if (a !== "--" && !a.startsWith("-"))
|
|
93
|
+
ws.push(a);
|
|
94
|
+
}
|
|
95
|
+
for (const p of e.prefixes || []) {
|
|
96
|
+
if (p.words.every((w, i) => ws[i] === w)) {
|
|
97
|
+
ws.splice(0, p.words.length);
|
|
98
|
+
if (p.all)
|
|
99
|
+
all = true;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const cmd = ws[0];
|
|
104
|
+
const sub = cmd !== undefined && e.refuseSub && Object.prototype.hasOwnProperty.call(e.refuseSub, cmd) ? e.refuseSub[cmd] : undefined;
|
|
105
|
+
const command = cmd !== undefined && e.refuse.indexOf(cmd) >= 0 ? cmd : sub && ws[1] !== undefined && sub.indexOf(ws[1]) >= 0 ? cmd + " " + ws[1] : refusedFlag;
|
|
106
|
+
if (command === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
let where;
|
|
109
|
+
if (roots !== undefined) {
|
|
110
|
+
const at = real(dir);
|
|
111
|
+
const hit = roots.find((r) => r === at || (all && inside(r, at)));
|
|
112
|
+
if (!hit)
|
|
113
|
+
return undefined;
|
|
114
|
+
where = relative(repo, hit) || ".";
|
|
115
|
+
}
|
|
116
|
+
const what = bin + " " + command;
|
|
117
|
+
return { bin, command, what, ...(where === undefined ? {} : { where }), message: message(what, where) };
|
|
118
|
+
}
|
|
119
|
+
function productVerdict(args, cwd) {
|
|
120
|
+
const p = rules.product;
|
|
121
|
+
if (!p || !inside(real(cwd), repo))
|
|
122
|
+
return undefined;
|
|
123
|
+
const ws = args.filter((a) => !a.startsWith("-"));
|
|
124
|
+
const bin = words.product;
|
|
125
|
+
const found = (command) => ({ bin, command, what: bin + " " + command, message: message(bin + " " + command, undefined) });
|
|
126
|
+
for (const c of p.commands)
|
|
127
|
+
if (c.every((w, i) => ws[i] === w))
|
|
128
|
+
return found(c.join(" "));
|
|
129
|
+
for (const [flag, value] of p.flagValues || []) {
|
|
130
|
+
const i = args.findIndex((a) => a === flag || a.startsWith(flag + "="));
|
|
131
|
+
if (i >= 0 && (args[i] === flag + "=" + value || (args[i] === flag && args[i + 1] === value)))
|
|
132
|
+
return found(((ws[0] === undefined ? "" : ws[0] + " ") + flag + " " + value).trim());
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
/** A shell command line's words and operators, quotes taken off. Enough for a guard, not a shell. */
|
|
137
|
+
function lex(text) {
|
|
138
|
+
const out = [];
|
|
139
|
+
let cur = null;
|
|
140
|
+
const end = () => {
|
|
141
|
+
if (cur !== null)
|
|
142
|
+
out.push({ word: cur });
|
|
143
|
+
cur = null;
|
|
144
|
+
};
|
|
145
|
+
for (let i = 0; i < text.length; i++) {
|
|
146
|
+
const c = text[i];
|
|
147
|
+
if (c === "'") {
|
|
148
|
+
const j = text.indexOf("'", i + 1);
|
|
149
|
+
cur = (cur === null ? "" : cur) + (j < 0 ? text.slice(i + 1) : text.slice(i + 1, j));
|
|
150
|
+
i = j < 0 ? text.length : j;
|
|
151
|
+
}
|
|
152
|
+
else if (c === '"') {
|
|
153
|
+
let s = "";
|
|
154
|
+
for (i++; i < text.length && text[i] !== '"'; i++) {
|
|
155
|
+
if (text[i] === "\\" && i + 1 < text.length)
|
|
156
|
+
i++;
|
|
157
|
+
s += text[i];
|
|
158
|
+
}
|
|
159
|
+
cur = (cur === null ? "" : cur) + s;
|
|
160
|
+
}
|
|
161
|
+
else if (c === "\\" && i + 1 < text.length)
|
|
162
|
+
cur = (cur === null ? "" : cur) + text[++i];
|
|
163
|
+
else if (c === "$" && text[i + 1] === "(") {
|
|
164
|
+
end();
|
|
165
|
+
out.push({ op: "$(" });
|
|
166
|
+
i++;
|
|
167
|
+
}
|
|
168
|
+
else if (";&|\n()`".indexOf(c) >= 0) {
|
|
169
|
+
end();
|
|
170
|
+
out.push({ op: c });
|
|
171
|
+
}
|
|
172
|
+
else if (/\s/.test(c))
|
|
173
|
+
end();
|
|
174
|
+
else
|
|
175
|
+
cur = (cur === null ? "" : cur) + c;
|
|
176
|
+
}
|
|
177
|
+
end();
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
/** Words that run the words after them as the command, with their flags that take a value. */
|
|
181
|
+
const LAUNCHERS = {
|
|
182
|
+
command: [],
|
|
183
|
+
builtin: [],
|
|
184
|
+
exec: ["-a"],
|
|
185
|
+
env: ["-u", "--unset", "-C", "--chdir", "-S", "--split-string"],
|
|
186
|
+
sudo: ["-u", "-g", "-h", "-p", "-C", "-D", "-r", "-t", "-U"],
|
|
187
|
+
doas: ["-u", "-C"],
|
|
188
|
+
time: ["-f", "-o", "--format", "--output"],
|
|
189
|
+
nohup: [],
|
|
190
|
+
nice: ["-n", "--adjustment"],
|
|
191
|
+
xargs: ["-a", "-d", "-E", "-e", "-I", "-i", "-L", "-l", "-n", "-P", "-s", "--arg-file", "--delimiter", "--max-args", "--max-procs"],
|
|
192
|
+
};
|
|
193
|
+
const SHELLS = ["sh", "bash", "zsh", "dash", "ksh"];
|
|
194
|
+
const RUNNERS = ["npx", "bunx", "pnpx"];
|
|
195
|
+
const RUNNER_VALUED = ["-p", "--package", "-c", "--call"];
|
|
196
|
+
function checkCommand(text, cwd, depth = 0) {
|
|
197
|
+
if (depth > 3)
|
|
198
|
+
return undefined;
|
|
199
|
+
let dir = cwd;
|
|
200
|
+
const segments = [[]];
|
|
201
|
+
for (const t of lex(text)) {
|
|
202
|
+
if (t.op)
|
|
203
|
+
segments.push([]);
|
|
204
|
+
else
|
|
205
|
+
segments[segments.length - 1].push(t.word);
|
|
206
|
+
}
|
|
207
|
+
for (let seg of segments) {
|
|
208
|
+
for (;;) {
|
|
209
|
+
if (seg.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(seg[0]))
|
|
210
|
+
seg = seg.slice(1);
|
|
211
|
+
else if (seg.length && Object.prototype.hasOwnProperty.call(LAUNCHERS, basename(seg[0]))) {
|
|
212
|
+
const valued = LAUNCHERS[basename(seg[0])];
|
|
213
|
+
seg = seg.slice(1);
|
|
214
|
+
while (seg.length && seg[0].startsWith("-") && seg[0] !== "-") {
|
|
215
|
+
if (seg[0] === "--") {
|
|
216
|
+
seg = seg.slice(1);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
seg = seg.slice(valued.indexOf(seg[0]) >= 0 ? 2 : 1);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (!seg.length)
|
|
226
|
+
continue;
|
|
227
|
+
const head = basename(seg[0]);
|
|
228
|
+
if (head === "cd") {
|
|
229
|
+
const home = deps.home === undefined ? dir : deps.home;
|
|
230
|
+
const to = seg[1] === undefined || seg[1] === "~" ? home : seg[1].startsWith("~/") ? join(home, seg[1].slice(2)) : seg[1];
|
|
231
|
+
if (to !== "-")
|
|
232
|
+
dir = resolve(dir, to);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (SHELLS.indexOf(head) >= 0) {
|
|
236
|
+
const c = seg.findIndex((a, i) => i > 0 && /^-[A-Za-z]*c[A-Za-z]*$/.test(a));
|
|
237
|
+
if (c >= 0 && seg[c + 1] !== undefined) {
|
|
238
|
+
const v = checkCommand(seg[c + 1], dir, depth + 1);
|
|
239
|
+
if (v)
|
|
240
|
+
return v;
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (head === "eval") {
|
|
245
|
+
const v = checkCommand(seg.slice(1).join(" "), dir, depth + 1);
|
|
246
|
+
if (v)
|
|
247
|
+
return v;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
let rest = seg;
|
|
251
|
+
if (RUNNERS.indexOf(head) >= 0) {
|
|
252
|
+
rest = rest.slice(1);
|
|
253
|
+
while (rest.length && rest[0].startsWith("-"))
|
|
254
|
+
rest = rest.slice(RUNNER_VALUED.indexOf(rest[0]) >= 0 ? 2 : 1);
|
|
255
|
+
if (!rest.length)
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
// npx names a package as @scope/name, with a version after an @.
|
|
259
|
+
const name = basename(rest[0]).replace(/@.*$/, "");
|
|
260
|
+
const v = Object.prototype.hasOwnProperty.call(rules.engines, name) ? verdict(name, rest.slice(1), dir) : name === words.product ? productVerdict(rest.slice(1), dir) : undefined;
|
|
261
|
+
if (v)
|
|
262
|
+
return v;
|
|
263
|
+
}
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
return { checkCommand: (text, cwd) => checkCommand(text, cwd), verdict, productVerdict, repo };
|
|
267
|
+
}
|
|
268
|
+
/** The guard in process, for a product's `guard check`: the rule the hook runs. */
|
|
269
|
+
export function agentGuard(spec, at) {
|
|
270
|
+
return makeGuard({ ...spec, repo: at.repo, ...(at.roots ? { roots: at.roots } : {}) }, nodeDeps());
|
|
271
|
+
}
|
|
272
|
+
function nodeDeps(scriptDir) {
|
|
273
|
+
return { realpathSync, resolve, basename, join, relative, sep, home: process.env.HOME, ...(scriptDir ? { scriptDir } : {}) };
|
|
274
|
+
}
|
|
275
|
+
/** The guard's script: {@link makeGuard}'s source, the config, and the hook and wrapper entry points. */
|
|
276
|
+
export function agentGuardScript(config) {
|
|
277
|
+
const p = JSON.stringify(config.words.product);
|
|
278
|
+
return `// Written by ${config.words.product} guard. Run it again after the pipeline's roots change.
|
|
279
|
+
import { spawnSync } from "node:child_process";
|
|
280
|
+
import { accessSync, constants, realpathSync, statSync } from "node:fs";
|
|
281
|
+
import { basename, delimiter, dirname, join, relative, resolve, sep } from "node:path";
|
|
282
|
+
import { fileURLToPath } from "node:url";
|
|
283
|
+
|
|
284
|
+
const CONFIG = ${JSON.stringify(config)};
|
|
285
|
+
const PRODUCT = ${p};
|
|
286
|
+
// esbuild with keepNames (tsx) wraps the function's inner functions in __name.
|
|
287
|
+
const __name = (f) => f;
|
|
288
|
+
${makeGuard.toString()}
|
|
289
|
+
const guard = makeGuard(CONFIG, { realpathSync, resolve, basename, join, relative, sep, home: process.env.HOME, scriptDir: dirname(fileURLToPath(import.meta.url)) });
|
|
290
|
+
export const checkCommand = guard.checkCommand;
|
|
291
|
+
export const verdict = guard.verdict;
|
|
292
|
+
|
|
293
|
+
const real = (p) => { try { return realpathSync(p); } catch { return resolve(p); } };
|
|
294
|
+
|
|
295
|
+
/** The next binary of this name on PATH, past the wrappers' own directory. */
|
|
296
|
+
function realBinary(bin, self) {
|
|
297
|
+
const skip = real(self);
|
|
298
|
+
for (const d of (process.env.PATH ?? "").split(delimiter)) {
|
|
299
|
+
if (!d || real(d) === skip) continue;
|
|
300
|
+
const p = join(d, bin);
|
|
301
|
+
try {
|
|
302
|
+
accessSync(p, constants.X_OK);
|
|
303
|
+
if (statSync(p).isFile()) return p;
|
|
304
|
+
} catch {}
|
|
305
|
+
}
|
|
306
|
+
return undefined;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (process.argv[1] && real(process.argv[1]) === real(fileURLToPath(import.meta.url))) {
|
|
310
|
+
const [mode, ...rest] = process.argv.slice(2);
|
|
311
|
+
if (mode === "wrap") {
|
|
312
|
+
const [bin, self, ...args] = rest;
|
|
313
|
+
const v = verdict(bin, args, process.cwd());
|
|
314
|
+
if (v) {
|
|
315
|
+
process.stderr.write(v.message + "\\n");
|
|
316
|
+
process.exit(${config.rules.wrapperExit ?? 3});
|
|
317
|
+
}
|
|
318
|
+
const exe = realBinary(bin, self);
|
|
319
|
+
if (!exe) {
|
|
320
|
+
process.stderr.write(PRODUCT + " guard: no " + bin + " on PATH besides the guard's own\\n");
|
|
321
|
+
process.exit(127);
|
|
322
|
+
}
|
|
323
|
+
for (const s of ["SIGINT", "SIGTERM", "SIGHUP"]) process.on(s, () => {});
|
|
324
|
+
const r = spawnSync(exe, args, { stdio: "inherit" });
|
|
325
|
+
if (r.error) {
|
|
326
|
+
process.stderr.write(PRODUCT + " guard: " + r.error.message + "\\n");
|
|
327
|
+
process.exit(127);
|
|
328
|
+
}
|
|
329
|
+
if (r.signal) {
|
|
330
|
+
process.removeAllListeners(r.signal);
|
|
331
|
+
process.kill(process.pid, r.signal);
|
|
332
|
+
}
|
|
333
|
+
process.exit(r.status ?? 1);
|
|
334
|
+
} else if (mode === "hook" || mode === undefined) {
|
|
335
|
+
let input = "";
|
|
336
|
+
for await (const chunk of process.stdin) input += chunk;
|
|
337
|
+
let event;
|
|
338
|
+
try { event = JSON.parse(input); } catch { process.exit(0); }
|
|
339
|
+
const command = event?.tool_input?.command;
|
|
340
|
+
if (typeof command !== "string") process.exit(0);
|
|
341
|
+
const v = checkCommand(command, typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd());
|
|
342
|
+
if (v) {
|
|
343
|
+
process.stderr.write(v.message + "\\n");
|
|
344
|
+
process.exit(2);
|
|
345
|
+
}
|
|
346
|
+
process.exit(0);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
`;
|
|
350
|
+
}
|
|
351
|
+
const shq = (s) => `'${s.split("'").join(`'\\''`)}'`;
|
|
352
|
+
/** A wrapper on PATH: the guard's script for one binary. `node` absolute (with `node` on PATH as the fallback) or undefined for `node`; `script` absolute, or relative to the wrapper's directory. */
|
|
353
|
+
export function agentGuardWrapper(product, bin, script, node) {
|
|
354
|
+
const at = isAbsolute(script) ? shq(script) : `"$here/"${shq(script)}`;
|
|
355
|
+
return `#!/bin/sh
|
|
356
|
+
# Written by ${product} guard: refuses what the guard refuses of ${bin}, and runs the next ${bin} on PATH for the rest.
|
|
357
|
+
here=$(cd "$(dirname "$0")" && pwd)
|
|
358
|
+
NODE=${node ? shq(node) : "node"}
|
|
359
|
+
${node ? `[ -x "$NODE" ] || NODE=node\n` : ""}exec "$NODE" ${at} wrap ${bin} "$here" "$@"
|
|
360
|
+
`;
|
|
361
|
+
}
|
|
362
|
+
/** Claude Code's settings files: the shared one, and the local one it keeps out of commits. */
|
|
363
|
+
export const CLAUDE_SETTINGS_SHARED = ".claude/settings.json";
|
|
364
|
+
export const CLAUDE_SETTINGS_LOCAL = ".claude/settings.local.json";
|
|
365
|
+
/**
|
|
366
|
+
* A Claude Code settings file's text with the guard's PreToolUse hook on
|
|
367
|
+
* Bash, in place of an earlier one (an entry naming `command` or any of
|
|
368
|
+
* `markers`). Everything else in the file is kept. Throws when the file is
|
|
369
|
+
* not a JSON object.
|
|
370
|
+
*/
|
|
371
|
+
export function withAgentGuardHook(text, command, at, markers = [], fail = (m) => new Error(m)) {
|
|
372
|
+
let doc = {};
|
|
373
|
+
if (text !== undefined && text.trim() !== "") {
|
|
374
|
+
let parsed;
|
|
375
|
+
try {
|
|
376
|
+
parsed = JSON.parse(text);
|
|
377
|
+
}
|
|
378
|
+
catch (e) {
|
|
379
|
+
throw fail(`${at} is not JSON (${e.message}); fix it, then write the guard again`);
|
|
380
|
+
}
|
|
381
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
382
|
+
throw fail(`${at} is not a JSON object`);
|
|
383
|
+
doc = parsed;
|
|
384
|
+
}
|
|
385
|
+
const hooks = (doc.hooks && typeof doc.hooks === "object" && !Array.isArray(doc.hooks) ? doc.hooks : {});
|
|
386
|
+
const pre = Array.isArray(hooks.PreToolUse) ? hooks.PreToolUse : [];
|
|
387
|
+
const needles = [JSON.stringify(command).slice(1, -1), ...markers.map((m) => JSON.stringify(m).slice(1, -1))];
|
|
388
|
+
const kept = pre.filter((e) => !needles.some((n) => JSON.stringify(e).includes(n)));
|
|
389
|
+
doc.hooks = { ...hooks, PreToolUse: [...kept, { matcher: "Bash", hooks: [{ type: "command", command }] }] };
|
|
390
|
+
return `${JSON.stringify(doc, null, 2)}\n`;
|
|
391
|
+
}
|
|
392
|
+
/** Write the guard: the script, a wrapper per engine, and the hook. */
|
|
393
|
+
export function installAgentGuard(o) {
|
|
394
|
+
const fail = o.fail ?? ((m) => new Error(m));
|
|
395
|
+
const product = o.words.product;
|
|
396
|
+
const repo = resolve(o.repo);
|
|
397
|
+
const git = (args) => {
|
|
398
|
+
const r = spawnSync("git", ["-C", repo, ...args], { encoding: "utf-8" });
|
|
399
|
+
if (r.status !== 0)
|
|
400
|
+
throw fail(`${product} guard runs in a git checkout (git ${args.join(" ")}: ${(r.stderr || "").trim()})`);
|
|
401
|
+
return r.stdout.trim();
|
|
402
|
+
};
|
|
403
|
+
const spec = { words: o.words, rules: o.rules };
|
|
404
|
+
const roots = o.roots ? { roots: o.roots } : {};
|
|
405
|
+
const shown = (p) => (p.startsWith(repo + sep) ? relative(repo, p) : p);
|
|
406
|
+
const written = [];
|
|
407
|
+
const put = (p, text, mode) => {
|
|
408
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
409
|
+
writeFileSync(p, text);
|
|
410
|
+
if (mode !== undefined)
|
|
411
|
+
chmodSync(p, mode);
|
|
412
|
+
written.push(shown(p));
|
|
413
|
+
};
|
|
414
|
+
let script;
|
|
415
|
+
let bin;
|
|
416
|
+
let settings;
|
|
417
|
+
let hookCommand;
|
|
418
|
+
let markers;
|
|
419
|
+
if (o.install === "local") {
|
|
420
|
+
const dir = o.dir ? resolve(repo, o.dir) : join(git(["rev-parse", "--absolute-git-dir"]), product, "guard");
|
|
421
|
+
const node = o.node ?? process.execPath;
|
|
422
|
+
script = join(dir, "guard.mjs");
|
|
423
|
+
bin = join(dir, "bin");
|
|
424
|
+
put(script, agentGuardScript({ ...spec, repo, ...roots }));
|
|
425
|
+
for (const b of Object.keys(o.rules.engines))
|
|
426
|
+
put(join(bin, b), agentGuardWrapper(product, b, script, node), 0o755);
|
|
427
|
+
settings = CLAUDE_SETTINGS_LOCAL;
|
|
428
|
+
hookCommand = `"${node}" "${script}" hook`;
|
|
429
|
+
markers = [`${product}/guard/guard.mjs`];
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
const rel = `.claude/hooks/${product}-guard.mjs`;
|
|
433
|
+
script = join(repo, rel);
|
|
434
|
+
bin = join(repo, `.${product}`, "agent-bin");
|
|
435
|
+
put(script, agentGuardScript({ ...spec, repoFromScript: "../..", ...roots }));
|
|
436
|
+
for (const b of Object.keys(o.rules.engines))
|
|
437
|
+
put(join(bin, b), agentGuardWrapper(product, b, relative(bin, script)), 0o755);
|
|
438
|
+
settings = CLAUDE_SETTINGS_SHARED;
|
|
439
|
+
hookCommand = `node "$CLAUDE_PROJECT_DIR/${rel}" hook`;
|
|
440
|
+
markers = [`${product}-guard.mjs`];
|
|
441
|
+
}
|
|
442
|
+
let hook;
|
|
443
|
+
if (!o.noHook) {
|
|
444
|
+
hook = join(repo, settings);
|
|
445
|
+
put(hook, withAgentGuardHook(existsSync(hook) ? readFileSync(hook, "utf-8") : undefined, hookCommand, settings, markers, fail));
|
|
446
|
+
// The local hook names paths on this machine: keep the file out of commits unless git already ignores it.
|
|
447
|
+
if (o.install === "local" && spawnSync("git", ["-C", repo, "check-ignore", "-q", settings]).status !== 0) {
|
|
448
|
+
const common = git(["rev-parse", "--git-common-dir"]);
|
|
449
|
+
const exclude = join(isAbsolute(common) ? common : resolve(repo, common), "info", "exclude");
|
|
450
|
+
mkdirSync(dirname(exclude), { recursive: true });
|
|
451
|
+
const now = existsSync(exclude) ? readFileSync(exclude, "utf-8") : "";
|
|
452
|
+
writeFileSync(exclude, `${now}${now === "" || now.endsWith("\n") ? "" : "\n"}/${settings}\n`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return { script, bin, ...(hook ? { hook } : {}), hookCommand, written, path: `export PATH="${bin}:$PATH"` };
|
|
456
|
+
}
|
package/dist/ci-commit.d.ts
CHANGED
|
@@ -35,6 +35,12 @@ export declare const CI_COMMIT_FLOOR = "0.124.71";
|
|
|
35
35
|
export declare const CI_COMMIT_PUSH_FLOOR = "0.124.72";
|
|
36
36
|
/** The first chant whose commit job takes `allowedFiles` (#4758). */
|
|
37
37
|
export declare const CI_COMMIT_FILES_FLOOR = "0.124.73";
|
|
38
|
+
/**
|
|
39
|
+
* The first chant whose commit job takes `commandEnv`, gives the command
|
|
40
|
+
* `CHANT_COMMIT_PR`, keeps the tail of its standard error and replies with a
|
|
41
|
+
* product's refusal text ({@link setCommitRefusalReply}) (#4724).
|
|
42
|
+
*/
|
|
43
|
+
export declare const CI_COMMIT_REPLY_FLOOR = "0.124.77";
|
|
38
44
|
/** What starts a commit run: a person's comment, or a check job's finding. */
|
|
39
45
|
export type CommitTrigger = "comment" | "check";
|
|
40
46
|
export declare const COMMIT_TRIGGERS: readonly CommitTrigger[];
|
|
@@ -94,6 +100,14 @@ export interface OpCommitSpec {
|
|
|
94
100
|
* the new head. Not run when nothing was pushed.
|
|
95
101
|
*/
|
|
96
102
|
after?: string[];
|
|
103
|
+
/**
|
|
104
|
+
* Variables of the commit job the command sees, by name (#4724), such as a
|
|
105
|
+
* database reader's user and password. Every other variable is left out,
|
|
106
|
+
* as before. A forge token's name is refused. GitHub and Forgejo pass each
|
|
107
|
+
* one from the secret of the same name to the step that runs the command;
|
|
108
|
+
* on GitLab they are the project's CI/CD variables.
|
|
109
|
+
*/
|
|
110
|
+
commandEnv?: string[];
|
|
97
111
|
}
|
|
98
112
|
/** A commit job's settings, every default filled and checked. */
|
|
99
113
|
export interface CommitSettings {
|
|
@@ -113,6 +127,8 @@ export interface CommitSettings {
|
|
|
113
127
|
jobToken: boolean;
|
|
114
128
|
/** Lines the push job runs after a push (#4749). */
|
|
115
129
|
after: string[];
|
|
130
|
+
/** The job variables the command sees (#4724). */
|
|
131
|
+
commandEnv: string[];
|
|
116
132
|
}
|
|
117
133
|
export declare const COMMIT_MAX_RUNS = 3;
|
|
118
134
|
export declare const COMMIT_TIMEOUT_MINUTES = 10;
|
|
@@ -134,7 +150,10 @@ export declare const COMMIT_ENV: {
|
|
|
134
150
|
readonly timeout: "CHANT_COMMIT_TIMEOUT";
|
|
135
151
|
readonly env: "CHANT_COMMIT_ENV";
|
|
136
152
|
readonly mergeBase: "CHANT_COMMIT_MERGE_BASE";
|
|
153
|
+
readonly commandEnv: "CHANT_COMMIT_COMMAND_ENV";
|
|
137
154
|
};
|
|
155
|
+
/** The variable the command reads the pull request's number from (#4724), such as for a default name. */
|
|
156
|
+
export declare const COMMIT_PR_ENV = "CHANT_COMMIT_PR";
|
|
138
157
|
/** GitLab starts no pipeline on a note: a pipeline of the default branch started with these runs a comment commit job. */
|
|
139
158
|
export declare const GITLAB_COMMIT_PR_VAR = "CHANT_COMMIT_PR";
|
|
140
159
|
export declare const GITLAB_COMMIT_WORD_VAR = "CHANT_COMMIT";
|
|
@@ -147,6 +166,10 @@ export declare const COMMIT_BASE_REF = "refs/chant/commit-base";
|
|
|
147
166
|
export declare const COMMIT_DECISION_FILE = "decision.json";
|
|
148
167
|
export declare const COMMIT_PATCH_FILE = "change.patch";
|
|
149
168
|
export declare const COMMIT_RC_FILE = "rc";
|
|
169
|
+
/** The tail of the command's standard error (#4724), which a product's refusal reply reads. */
|
|
170
|
+
export declare const COMMIT_OUTPUT_FILE = "output";
|
|
171
|
+
/** How much of the command's standard error {@link COMMIT_OUTPUT_FILE} keeps, from the end. */
|
|
172
|
+
export declare const COMMIT_OUTPUT_LIMIT = 8192;
|
|
150
173
|
/** What `chant commit land` leaves when it pushed (#4749): the pushed commit, which the push job's `after` lines read. */
|
|
151
174
|
export declare const COMMIT_PUSHED_FILE = "pushed";
|
|
152
175
|
/**
|
|
@@ -257,7 +280,11 @@ export interface CommitPrepareInput {
|
|
|
257
280
|
* the decision.
|
|
258
281
|
*/
|
|
259
282
|
export declare function prepareCommitRun(i: CommitPrepareInput): Promise<CommitDecision>;
|
|
260
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* Run an argv in `cwd`, with no shell. A failure or a timeout is an outcome.
|
|
285
|
+
* `output` is the tail of its standard error (#4724), at most
|
|
286
|
+
* {@link COMMIT_OUTPUT_LIMIT} bytes.
|
|
287
|
+
*/
|
|
261
288
|
export type CommitRunCommand = (argv: readonly string[], o: {
|
|
262
289
|
cwd: string;
|
|
263
290
|
env: Record<string, string>;
|
|
@@ -265,14 +292,20 @@ export type CommitRunCommand = (argv: readonly string[], o: {
|
|
|
265
292
|
}) => Promise<{
|
|
266
293
|
exitCode: number | null;
|
|
267
294
|
timedOut: boolean;
|
|
295
|
+
output?: string;
|
|
268
296
|
}>;
|
|
269
297
|
export declare const runCommitArgv: CommitRunCommand;
|
|
270
298
|
/**
|
|
271
299
|
* The variables the command sees: process basics, with the checkout's
|
|
272
300
|
* `node_modules/.bin` first on `PATH` so a product's bin installed on the
|
|
273
|
-
* target branch runs on the head's files. Never a forge or cloud token.
|
|
301
|
+
* target branch runs on the head's files. Never a forge or cloud token. Also
|
|
302
|
+
* the variables the spec's `commandEnv` names, and {@link COMMIT_PR_ENV}, the
|
|
303
|
+
* pull request's number (#4724).
|
|
274
304
|
*/
|
|
275
|
-
export declare function commitCommandEnv(env: Record<string, string | undefined>, checkout: string
|
|
305
|
+
export declare function commitCommandEnv(env: Record<string, string | undefined>, checkout: string, o?: {
|
|
306
|
+
names?: readonly string[];
|
|
307
|
+
pr?: number;
|
|
308
|
+
}): Record<string, string>;
|
|
276
309
|
export interface CommitRunInput {
|
|
277
310
|
settings: CommitSettings;
|
|
278
311
|
dir: string;
|
|
@@ -289,6 +322,22 @@ export declare function runCommit(i: CommitRunInput): Promise<{
|
|
|
289
322
|
rc: string;
|
|
290
323
|
changed: boolean;
|
|
291
324
|
}>;
|
|
325
|
+
/**
|
|
326
|
+
* A product's reply to a command that exited non-zero (#4724): the text that
|
|
327
|
+
* says why, from the command's exit code and the tail of its standard error,
|
|
328
|
+
* or undefined for chant's own reply. The output comes from a command run on
|
|
329
|
+
* the pull request's files, so a reply quotes from it only what it checked.
|
|
330
|
+
* A reply makes the run `refused`, not `failed`.
|
|
331
|
+
*/
|
|
332
|
+
export type CommitRefusalReply = (o: {
|
|
333
|
+
settings: CommitSettings;
|
|
334
|
+
rc: string;
|
|
335
|
+
output: string;
|
|
336
|
+
}) => string | undefined;
|
|
337
|
+
/** Set the refusal reply for this process (a product's bin, once, as it sets its words). Returns the one it replaced. */
|
|
338
|
+
export declare function setCommitRefusalReply(reply: CommitRefusalReply | undefined): CommitRefusalReply | undefined;
|
|
339
|
+
/** The refusal reply {@link setCommitRefusalReply} set, if any. */
|
|
340
|
+
export declare function activeCommitRefusalReply(): CommitRefusalReply | undefined;
|
|
292
341
|
export interface CommitLandOutcome {
|
|
293
342
|
result: CommitResult;
|
|
294
343
|
reason: string;
|
|
@@ -320,6 +369,8 @@ export interface CommitLandInput {
|
|
|
320
369
|
record: (input: OpRunRecordInput) => Promise<void>;
|
|
321
370
|
now: () => Date;
|
|
322
371
|
runOrigin?: RunOrigin;
|
|
372
|
+
/** The product's reply to a command that exited non-zero (#4724). */
|
|
373
|
+
refusalReply?: CommitRefusalReply;
|
|
323
374
|
}
|
|
324
375
|
/**
|
|
325
376
|
* `chant commit land`: from the commit job's patch to a pushed commit, or a
|
package/dist/ci-commit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ci-commit.d.ts","sourceRoot":"","sources":["../src/ci-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"ci-commit.d.ts","sourceRoot":"","sources":["../src/ci-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAQH,OAAO,EAA6E,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,uHAAuH;AACvH,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C,wIAAwI;AACxI,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAC/C,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAChD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,aAAe,CAAC;AAElD,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC;AAChD,eAAO,MAAM,eAAe,EAAE,SAAS,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