@outerlayer/cli 0.18.0 → 0.19.0

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 (102) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +21 -2
  3. package/dist/{agent-setup-RBTEACYU.js → agent-setup-TPR4BBFV.js} +15 -16
  4. package/dist/{artifact-link-cmd-AVM2EKTV.js → artifact-link-cmd-W7XF5BFB.js} +2 -2
  5. package/dist/build-info.json +1 -1
  6. package/dist/{builder-DUI2ZH2H.js → builder-C4QNTYMS.js} +3 -3
  7. package/dist/{check-5C4YDZYV.js → check-UWQAL2MN.js} +44 -43
  8. package/dist/{chunk-S26M3YBJ.js → chunk-3UZTIRLF.js} +1 -1
  9. package/dist/{chunk-W5VPCONO.js → chunk-452TM7J4.js} +33 -227
  10. package/dist/{chunk-UYOYTKE2.js → chunk-5GHGAF6P.js} +3 -3
  11. package/dist/{chunk-QQM2UJ6T.js → chunk-5MYFOW5V.js} +182 -28
  12. package/dist/{chunk-Y5GE76XC.js → chunk-5TN7GLYX.js} +33 -81
  13. package/dist/{chunk-GOBOJMOJ.js → chunk-6D7GT22T.js} +4 -4
  14. package/dist/{chunk-3OFZM4X6.js → chunk-6U3MV7TZ.js} +151 -20
  15. package/dist/{chunk-F4XSVQJ4.js → chunk-6X4SQ5MY.js} +2 -2
  16. package/dist/{chunk-Y5MXET4M.js → chunk-7KSSBQTS.js} +11 -10
  17. package/dist/{chunk-JF42URPU.js → chunk-7SJPQWBM.js} +33 -9
  18. package/dist/{chunk-N3CUDFCW.js → chunk-7VUK5RFS.js} +15 -2
  19. package/dist/{chunk-SWCTGCSC.js → chunk-7YP7T6GV.js} +1 -1
  20. package/dist/{chunk-KDVIU23F.js → chunk-BWSUPRDK.js} +1 -1
  21. package/dist/{chunk-S76AYB4M.js → chunk-CG36IONK.js} +5 -5
  22. package/dist/chunk-CJJDJ7AT.js +56 -0
  23. package/dist/{chunk-FUB7LRUE.js → chunk-DADWEUH3.js} +5 -5
  24. package/dist/{chunk-RAZTWYZN.js → chunk-DJ3ZUSC3.js} +7 -8
  25. package/dist/{chunk-MQJSXHV7.js → chunk-G3IJ3N6F.js} +5 -3
  26. package/dist/{chunk-KK4VBOH6.js → chunk-HPJNLETG.js} +10 -11
  27. package/dist/{chunk-IP7BIBXJ.js → chunk-IF2OSI5T.js} +35 -1
  28. package/dist/{chunk-T4Y6SCG3.js → chunk-IXYZUUYQ.js} +2 -2
  29. package/dist/chunk-KYS3TQAG.js +296 -0
  30. package/dist/chunk-LLM3I5YU.js +89 -0
  31. package/dist/{chunk-B3UKB46N.js → chunk-LRG3ZMZD.js} +4 -5
  32. package/dist/{chunk-ULSIJGLS.js → chunk-NFIR3GEE.js} +56 -14
  33. package/dist/{chunk-MNTSH4CL.js → chunk-NNLA7LLQ.js} +1 -1
  34. package/dist/{chunk-WGAUY5LE.js → chunk-QEFKA2QD.js} +1 -1
  35. package/dist/{chunk-BMYGAGBJ.js → chunk-QNLX477Q.js} +155 -23
  36. package/dist/chunk-TUSYOL2O.js +113 -0
  37. package/dist/{chunk-ESC6UR76.js → chunk-TWF3RICI.js} +6 -6
  38. package/dist/{chunk-NL4XPC7W.js → chunk-UVG35MWF.js} +1 -1
  39. package/dist/{chunk-L2USZT6T.js → chunk-VMJPFQNE.js} +1 -1
  40. package/dist/chunk-VRRGENS4.js +144 -0
  41. package/dist/{chunk-X5N6KC6V.js → chunk-WFSUUUAN.js} +2 -3
  42. package/dist/{chunk-6CHIYEZZ.js → chunk-XSZD4AZ6.js} +9 -83
  43. package/dist/{chunk-LXAY4A2G.js → chunk-YQR6E6OV.js} +34 -49
  44. package/dist/{chunk-47TTLEDX.js → chunk-ZHAUSEEN.js} +35 -13
  45. package/dist/{claude-launcher-YVXI76NX.js → claude-launcher-FPPHZPMR.js} +20 -7
  46. package/dist/{cli-C77H54BV.js → cli-HROW5T7X.js} +203 -228
  47. package/dist/{command-H5CILO4S.js → command-OEAV7BVX.js} +29 -30
  48. package/dist/{config-FXDG4NPJ.js → config-CLSGABD5.js} +2 -2
  49. package/dist/{connect-cmd-ZW5FV3ZW.js → connect-cmd-UNYKGDAL.js} +7 -7
  50. package/dist/context-cleanup-HSVYDGMI.js +9 -0
  51. package/dist/control-plane-launch-NYVDJESK.js +216 -0
  52. package/dist/{dist-QTX4RSCL.js → dist-WO7NOJNG.js} +2 -2
  53. package/dist/{docker-RC3PRX3Q.js → docker-BFU3AQGY.js} +4 -4
  54. package/dist/{doctor-2NQQML6P.js → doctor-23BBJWBX.js} +32 -33
  55. package/dist/{emit-artifact-cmd-7MP63KXU.js → emit-artifact-cmd-O6SCM7TV.js} +17 -17
  56. package/dist/{emit-cmd-PPN4QQF2.js → emit-cmd-7SP3I6UZ.js} +6 -6
  57. package/dist/{emit-criteria-cmd-3RXPDLNK.js → emit-criteria-cmd-LQNERZRV.js} +11 -12
  58. package/dist/{emit-finding-cmd-OL7JB6H3.js → emit-finding-cmd-AJPKHIOV.js} +12 -13
  59. package/dist/{emit-result-cmd-UZVMOCF4.js → emit-result-cmd-RUICOKWQ.js} +17 -17
  60. package/dist/emit-step-cmd-347XNGPQ.js +26 -0
  61. package/dist/{governing-source-BUU4IABS.js → governing-source-V5EEGPTA.js} +21 -22
  62. package/dist/{hook-fast-W5MKHMJT.js → hook-fast-YAZG5MDX.js} +3 -3
  63. package/dist/{import-capture-cmd-ZO6KGHI2.js → import-capture-cmd-KKFFOGWP.js} +4 -4
  64. package/dist/{import-ruler-cmd-KJMWL5V6.js → import-ruler-cmd-5P6JOXQN.js} +2 -2
  65. package/dist/index.js +4 -4
  66. package/dist/{init-WNXXYMO7.js → init-LWHDMZQG.js} +30 -31
  67. package/dist/{init-VWXIZEAN.js → init-MOINY2DD.js} +30 -31
  68. package/dist/{init-cmd-WS6TIRYT.js → init-cmd-HSMRID6A.js} +67 -26
  69. package/dist/{init-update-E3J6TVIN.js → init-update-LWX5MPPR.js} +21 -22
  70. package/dist/{install-CBWIEF3R.js → install-4SEFIIW2.js} +3 -3
  71. package/dist/{login-browser-O63QZN7D.js → login-browser-DX35MARZ.js} +2 -2
  72. package/dist/{loop-UGI2BJOT.js → loop-SYYPVFYW.js} +44 -43
  73. package/dist/{machine-JOW4RNZ7.js → machine-6X63G2KH.js} +26 -27
  74. package/dist/{mcp-serve-cmd-DOTY5FKY.js → mcp-serve-cmd-N3UTY6EE.js} +5 -5
  75. package/dist/{runner-env-4NB2GA7O.js → runner-env-FRZFFHDF.js} +4 -4
  76. package/dist/{runner-key-TC3NFWFV.js → runner-key-276SJU5R.js} +30 -31
  77. package/dist/{session-sender-NNVPSPY7.js → session-sender-GGIY5OAX.js} +19 -15
  78. package/dist/shell-function-NRD4KVUK.js +6 -0
  79. package/dist/{spec-cmd-OWVTBB4J.js → spec-cmd-SIZBRN7D.js} +12 -13
  80. package/dist/{starter-pack-OPWUDOWX.js → starter-pack-6LQVLBIA.js} +5 -5
  81. package/dist/{status-TKCLLKFG.js → status-NAK6DYSF.js} +33 -32
  82. package/dist/{sync-cmd-Q6VYNPWG.js → sync-cmd-G7GF4UTW.js} +18 -14
  83. package/dist/{watch-ARAGADTF.js → watch-EVM5GSMP.js} +18 -14
  84. package/dist/{work-claim-cmd-34FERLYX.js → work-claim-cmd-3J3QW56U.js} +16 -17
  85. package/dist/{work-cmd-7S5B2H2P.js → work-cmd-5EPPD33Y.js} +12 -13
  86. package/dist/{work-comment-cmd-SZJSPM5S.js → work-comment-cmd-2ACOZQAE.js} +12 -13
  87. package/dist/work-logs-cmd-QDD2NMJL.js +60 -0
  88. package/dist/{work-open-pr-cmd-RPXKCBWS.js → work-open-pr-cmd-XNCEI4ZM.js} +13 -14
  89. package/dist/{work-pr-cmd-5LGANL32.js → work-pr-cmd-H4OQR26N.js} +12 -13
  90. package/package.json +2 -2
  91. package/skill-pack/maintained/outerlayer-cli/SKILL.md +9 -2
  92. package/skill-pack/maintained/outerlayer-cli/references/find-out-why-a-build-ended.md +76 -0
  93. package/skill-pack/shipped.json +1 -0
  94. package/skill-pack/template/build/references/release.md +3 -1
  95. package/dist/chunk-WBT5X3NH.js +0 -40
  96. package/dist/chunk-XCCLFVXM.js +0 -401
  97. package/dist/context-adopt-O5OFXMKI.js +0 -109
  98. package/dist/context-materialize-Y5IJ4MQT.js +0 -23
  99. package/dist/{chunk-NACDBXUG.js → chunk-BM63HB2M.js} +1 -1
  100. package/dist/{chunk-ZRL6HKBY.js → chunk-FVMYKL6L.js} +1 -1
  101. package/dist/{chunk-52NC2FIU.js → chunk-NTRCK4NH.js} +1 -1
  102. package/dist/{chunk-XGP3VYOG.js → chunk-P53VEAOF.js} +1 -1
@@ -1,401 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from 'node:module';
3
- import { homeFromEnv } from './chunk-VNVZDWO3.js';
4
- import { mkdirSync, chmodSync, writeFileSync, readFileSync, readdirSync, existsSync, unlinkSync } from 'fs';
5
- import { join, isAbsolute, dirname, basename, resolve } from 'path';
6
- import { execFileSync } from 'child_process';
7
-
8
- createRequire(import.meta.url);
9
- var CONTEXT_EXCLUDE_MARKER = "outerlayer context materialization";
10
- var VERSION = 1;
11
- var CONTEXT_EXCLUDE_BEGIN_PREFIX = `# BEGIN ${CONTEXT_EXCLUDE_MARKER}`;
12
- var BEGIN_PREFIX = CONTEXT_EXCLUDE_BEGIN_PREFIX;
13
- var BEGIN = `${BEGIN_PREFIX} v${VERSION}`;
14
- var END = `# END ${CONTEXT_EXCLUDE_MARKER}`;
15
- var ENTRIES = ["/AGENTS.md", "/.claude/", "/.outerlayer/"];
16
- var BLOCK_LINES = [BEGIN, ...ENTRIES, END];
17
- function excludeFilePath(gitCommonDir) {
18
- return join(gitCommonDir, "info", "exclude");
19
- }
20
- function readLines(path) {
21
- if (!existsSync(path)) return [];
22
- const content = readFileSync(path, "utf8");
23
- if (content === "") return [];
24
- const lines = content.split("\n");
25
- if (lines[lines.length - 1] === "") lines.pop();
26
- return lines;
27
- }
28
- function writeLines(path, lines) {
29
- mkdirSync(dirname(path), { recursive: true });
30
- writeFileSync(path, lines.length ? lines.join("\n") + "\n" : "");
31
- }
32
- function findWellFormedBlock(lines) {
33
- let i = 0;
34
- while (i < lines.length) {
35
- if (!lines[i].startsWith(BEGIN_PREFIX)) {
36
- i++;
37
- continue;
38
- }
39
- const beginIdx = i;
40
- let endIdx = -1;
41
- let j = beginIdx + 1;
42
- for (; j < lines.length; j++) {
43
- if (lines[j] === END) {
44
- endIdx = j;
45
- break;
46
- }
47
- if (lines[j].startsWith(BEGIN_PREFIX)) break;
48
- }
49
- if (endIdx !== -1) return { beginIdx, endIdx };
50
- i = j;
51
- }
52
- return void 0;
53
- }
54
- function ensureContextExcludes(gitCommonDir) {
55
- const path = excludeFilePath(gitCommonDir);
56
- const lines = readLines(path);
57
- const block = findWellFormedBlock(lines);
58
- if (block !== void 0) {
59
- const { beginIdx, endIdx } = block;
60
- const current = lines.slice(beginIdx, endIdx + 1);
61
- if (current.length === BLOCK_LINES.length && current.every((l, i) => l === BLOCK_LINES[i])) {
62
- return { changed: false };
63
- }
64
- const next = [...lines.slice(0, beginIdx), ...BLOCK_LINES, ...lines.slice(endIdx + 1)];
65
- writeLines(path, next);
66
- return { changed: true };
67
- }
68
- writeLines(path, [...lines, ...BLOCK_LINES]);
69
- return { changed: true };
70
- }
71
- function contextExcludesPresent(gitCommonDir) {
72
- const lines = readLines(excludeFilePath(gitCommonDir));
73
- const beginIdx = lines.findIndex((l) => l === BEGIN);
74
- if (beginIdx === -1) return false;
75
- return BLOCK_LINES.every((l, i) => lines[beginIdx + i] === l);
76
- }
77
- var HOOKS_DIR_NAME = "git-hooks";
78
- var CO_AUTHOR_FILE = "co-author";
79
- var HOOKS = [
80
- "applypatch-msg",
81
- "pre-applypatch",
82
- "post-applypatch",
83
- "pre-commit",
84
- "pre-merge-commit",
85
- "prepare-commit-msg",
86
- "commit-msg",
87
- "post-commit",
88
- "pre-rebase",
89
- "post-checkout",
90
- "post-merge",
91
- "pre-push",
92
- "pre-receive",
93
- "update",
94
- "post-receive",
95
- "post-update",
96
- "reference-transaction",
97
- "pre-auto-gc",
98
- "post-rewrite",
99
- "sendemail-validate",
100
- "post-index-change"
101
- ];
102
- var READS_STDIN = /* @__PURE__ */ new Set(["pre-push", "pre-receive", "post-receive", "reference-transaction", "post-rewrite"]);
103
- var PRE_COMMIT_GUARD_MARKER = "# outerlayer materialized-context commit guard";
104
- var RUN_GUARD = `common=$(git rev-parse --git-common-dir 2>/dev/null)
105
- guard=$common/hooks/pre-commit
106
- if [ "$guard" != "$hook" ] && [ -f "$guard" ] && [ -x "$guard" ] &&
107
- sed -n 2p "$guard" | grep -q '^${PRE_COMMIT_GUARD_MARKER}'; then
108
- "$guard" "$@" || exit $?
109
- fi
110
- `;
111
- var ADD_TRAILER = `
112
- # Every commit of the build names the requester once: a trailer already there is left alone.
113
- file=\${1-}
114
- if [ -n "$file" ] && [ -f "$file" ]; then
115
- git interpret-trailers --in-place --if-exists addIfDifferent --trailer "Co-authored-by: $(cat "$here/${CO_AUTHOR_FILE}")" "$file" ||
116
- echo "outerlayer: could not add the co-author line to the commit message" >&2
117
- fi
118
- `;
119
- var HOOK_WRAPPER_MARKER = "# Written by the OuterLayer runner.";
120
- function script(name) {
121
- const adds = name === "prepare-commit-msg";
122
- return `#!/bin/sh
123
- ${HOOK_WRAPPER_MARKER} Runs the repository's own ${name} hook, then
124
- # ${adds ? "adds the co-author line to the commit message" : "hands its status on"}.
125
- here=$(dirname "$0")
126
-
127
- # The hooks path git would use without this directory: cut the list of configuration
128
- # entries the runner passes just before its own core.hooksPath entry, then ask git.
129
- n=\${GIT_CONFIG_COUNT-0}
130
- case $n in '' | *[!0-9]*) n=0 ;; esac
131
- cut=$n
132
- i=$n
133
- while [ "$i" -gt 0 ]; do
134
- i=$((i - 1))
135
- eval "key=\\\${GIT_CONFIG_KEY_$i-}"
136
- eval "value=\\\${GIT_CONFIG_VALUE_$i-}"
137
- if [ "$key" = core.hooksPath ] && { [ "$value" = "$here" ] || [ "$value" -ef "$here" ]; }; then
138
- cut=$i
139
- break
140
- fi
141
- done
142
- path=$(GIT_CONFIG_COUNT=$cut git config --type=path core.hooksPath 2>/dev/null) || path=
143
- if [ -z "$path" ]; then
144
- path=$(git rev-parse --git-common-dir 2>/dev/null)/hooks
145
- fi
146
-
147
- hook=$path/${name}
148
- ${name === "pre-commit" ? RUN_GUARD : ""}status=0
149
- if [ "$path" -ef "$here" ] || [ ! -f "$hook" ] || [ ! -x "$hook" ]; then
150
- ${READS_STDIN.has(name) ? " cat >/dev/null\n" : ""} :
151
- else
152
- ${adds ? ` "$hook" "$@" || status=$?` : ` exec "$hook" "$@"`}
153
- fi
154
- ${adds ? `[ "$status" -eq 0 ] || exit "$status"
155
- ${ADD_TRAILER}` : ""}exit 0
156
- `;
157
- }
158
- function writeCommitHooks(buildDir, coAuthor) {
159
- const dir = join(buildDir, HOOKS_DIR_NAME);
160
- mkdirSync(dir, { recursive: true });
161
- chmodSync(dir, 493);
162
- for (const name of HOOKS) {
163
- const path = join(dir, name);
164
- writeFileSync(path, script(name));
165
- chmodSync(path, 493);
166
- }
167
- const data = join(dir, CO_AUTHOR_FILE);
168
- writeFileSync(data, `${coAuthor.name} <${coAuthor.email}>
169
- `);
170
- chmodSync(data, 420);
171
- return dir;
172
- }
173
- var JOURNAL_HOOK_MARKER = "# outerlayer post-rewrite journal";
174
- var PRE_COMMIT_GUARD_VERSION = `${PRE_COMMIT_GUARD_MARKER} v1`;
175
- var PRE_COMMIT_GUARD_BODY_SIGNATURE = "outerlayer: refusing to commit materialized control-plane context";
176
- var PRE_COMMIT_GUARD_SCRIPT = `#!/bin/sh
177
- ${PRE_COMMIT_GUARD_VERSION}
178
- unset GIT_LITERAL_PATHSPECS GIT_GLOB_PATHSPECS GIT_NOGLOB_PATHSPECS GIT_ICASE_PATHSPECS
179
- PATH="$PATH:/usr/bin:/bin"
180
- export PATH
181
- COMMON_DIR="$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)"
182
- if [ -z "$COMMON_DIR" ]; then
183
- COMMON_DIR="$(git rev-parse --git-common-dir 2>/dev/null)" || exit 0
184
- case "$COMMON_DIR" in /*) ;; *) COMMON_DIR="$PWD/$COMMON_DIR" ;; esac
185
- fi
186
- grep -qF "${CONTEXT_EXCLUDE_BEGIN_PREFIX}" "$COMMON_DIR/info/exclude" 2>/dev/null || exit 0
187
-
188
- if git rev-parse --verify -q HEAD >/dev/null 2>&1; then
189
- BASE=HEAD
190
- REMEDY="git restore --staged <path>"
191
- else
192
- BASE="$(git hash-object -t tree --stdin < /dev/null)"
193
- REMEDY="git rm --cached <path>"
194
- fi
195
- [ -n "$BASE" ] || exit 0
196
-
197
- BLOCKED="$(git diff --cached --name-only --diff-filter=A --no-renames --ignore-submodules=none "$BASE" -- ':(icase)AGENTS.md' ':(icase).claude' ':(icase).outerlayer' 2>/dev/null)"
198
- [ -n "$BLOCKED" ] || exit 0
199
-
200
- echo "${PRE_COMMIT_GUARD_BODY_SIGNATURE}:" >&2
201
- printf '%s\\n' "$BLOCKED" | while IFS= read -r path; do
202
- [ -n "$path" ] && echo " $path" >&2
203
- done
204
- echo "These paths come from a private control plane and must never enter this" >&2
205
- echo "repository's history. Unstage them to continue:" >&2
206
- echo " $REMEDY" >&2
207
- exit 1
208
- `;
209
- function managedHookScripts() {
210
- return [["pre-commit", printableHookScript(PRE_COMMIT_GUARD_SCRIPT)]];
211
- }
212
- function printableHookScript(script2) {
213
- const lines = script2.split("\n");
214
- return [lines[0], ...lines.slice(2)].join("\n");
215
- }
216
- function git(cwd, args) {
217
- try {
218
- return execFileSync("git", ["-C", cwd, ...args], {
219
- encoding: "utf8",
220
- stdio: ["ignore", "pipe", "ignore"],
221
- timeout: 2e3
222
- }).trim();
223
- } catch {
224
- return void 0;
225
- }
226
- }
227
- function hooksDir(cwd) {
228
- const dir = git(cwd, ["rev-parse", "--git-path", "hooks"]);
229
- if (dir === void 0) return void 0;
230
- return isAbsolute(dir) ? dir : resolve(cwd, dir);
231
- }
232
- function commonHooksDir(cwd) {
233
- const abs = git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
234
- if (abs !== void 0) return join(abs, "hooks");
235
- const rel = git(cwd, ["rev-parse", "--git-common-dir"]);
236
- if (rel === void 0) return void 0;
237
- return join(isAbsolute(rel) ? rel : join(cwd, rel), "hooks");
238
- }
239
- function installHookFile(dir, name, script2, marker) {
240
- const path = join(dir, name);
241
- let existing;
242
- try {
243
- existing = readFileSync(path, "utf8");
244
- } catch {
245
- existing = void 0;
246
- }
247
- if (existing !== void 0) {
248
- if (!isOwnRecognitionLine(existing, marker)) return "skipped-foreign";
249
- if (existing === script2) {
250
- try {
251
- chmodSync(path, 493);
252
- } catch {
253
- }
254
- return "unchanged";
255
- }
256
- }
257
- mkdirSync(dir, { recursive: true });
258
- writeFileSync(path, script2);
259
- chmodSync(path, 493);
260
- return existing === void 0 ? "installed" : "updated";
261
- }
262
- function removeOurHookFile(path, marker) {
263
- if (!existsSync(path)) return false;
264
- let content;
265
- try {
266
- content = readFileSync(path, "utf8");
267
- } catch {
268
- return false;
269
- }
270
- if (!isOwnRecognitionLine(content, marker)) return false;
271
- unlinkSync(path);
272
- return true;
273
- }
274
- function isOwnRecognitionLine(content, marker) {
275
- const secondLine = content.split("\n", 2)[1];
276
- return secondLine !== void 0 && secondLine.startsWith(marker);
277
- }
278
- function removeJournalHooks(cwd) {
279
- const dir = hooksDir(cwd);
280
- if (dir === void 0) return { removed: false };
281
- let removed = false;
282
- for (const name of ["post-rewrite", "post-commit", "prepare-commit-msg"]) {
283
- if (removeOurHookFile(join(dir, name), JOURNAL_HOOK_MARKER)) removed = true;
284
- }
285
- return { removed, path: dir };
286
- }
287
- function installPreCommitGuardHook(cwd) {
288
- const inRepo = git(cwd, ["rev-parse", "--is-inside-work-tree"]);
289
- if (inRepo !== "true") return { status: "not-a-repo", adopted: false };
290
- const hooksPath = git(cwd, ["config", "core.hooksPath"]) ?? "";
291
- if (hooksPath !== "") {
292
- const expanded = expandHooksPathTilde(hooksPath);
293
- const effectiveDir = isAbsolute(expanded) ? expanded : join(git(cwd, ["rev-parse", "--show-toplevel"]) ?? cwd, expanded);
294
- const path2 = join(effectiveDir, "pre-commit");
295
- return { status: "skipped-custom-hooks-path", path: path2, adopted: guardAdoptedAtEffectiveHook(path2) };
296
- }
297
- const dir = hooksDir(cwd);
298
- if (dir === void 0) return { status: "not-a-repo", adopted: false };
299
- const path = join(dir, "pre-commit");
300
- const status = installHookFile(dir, "pre-commit", PRE_COMMIT_GUARD_SCRIPT, PRE_COMMIT_GUARD_MARKER);
301
- return { status, path, adopted: status === "skipped-foreign" ? guardBodyPresent(path) : true };
302
- }
303
- function removePreCommitGuardHook(cwd) {
304
- const dir = commonHooksDir(cwd);
305
- if (dir === void 0) return { removed: false };
306
- const path = join(dir, "pre-commit");
307
- return { removed: removeOurHookFile(path, PRE_COMMIT_GUARD_MARKER), path };
308
- }
309
- var GUARD_BODY_LINE_PREFIXES = [`echo "${PRE_COMMIT_GUARD_BODY_SIGNATURE}`, `echo '${PRE_COMMIT_GUARD_BODY_SIGNATURE}`];
310
- function guardBodyPresent(path) {
311
- let content;
312
- try {
313
- content = readFileSync(path, "utf8");
314
- } catch {
315
- return false;
316
- }
317
- return content.split("\n").some((line) => {
318
- const trimmed = line.trimStart();
319
- return GUARD_BODY_LINE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));
320
- });
321
- }
322
- function guardAdoptedAtEffectiveHook(effectiveHookPath) {
323
- if (guardBodyPresent(effectiveHookPath)) return true;
324
- const shimDir = dirname(effectiveHookPath);
325
- if (basename(shimDir) !== "_") return false;
326
- return guardBodyPresent(join(dirname(shimDir), basename(effectiveHookPath)));
327
- }
328
- function expandHooksPathTilde(hooksPath) {
329
- if (hooksPath === "~") return homeFromEnv();
330
- if (hooksPath.startsWith("~/")) return join(homeFromEnv(), hooksPath.slice(2));
331
- return hooksPath;
332
- }
333
- function ensurePreCommitGuardHook(repoRoot, gitCommonDir) {
334
- const hooksPath = git(repoRoot, ["config", "core.hooksPath"]) ?? "";
335
- if (hooksPath !== "" && !isRunnerHookWrapper(hooksPath, repoRoot)) {
336
- const expanded = expandHooksPathTilde(hooksPath);
337
- const effectivePath = isAbsolute(expanded) ? join(expanded, "pre-commit") : join(repoRoot, expanded, "pre-commit");
338
- return { status: "skipped-custom-hooks-path", adopted: guardAdoptedAtEffectiveHook(effectivePath) };
339
- }
340
- return installPreCommitGuardInGitDir(gitCommonDir);
341
- }
342
- function installPreCommitGuardInGitDir(gitCommonDir) {
343
- const path = join(gitCommonDir, "hooks", "pre-commit");
344
- const status = installHookFile(join(gitCommonDir, "hooks"), "pre-commit", PRE_COMMIT_GUARD_SCRIPT, PRE_COMMIT_GUARD_MARKER);
345
- return { status, adopted: status === "skipped-foreign" ? guardBodyPresent(path) : true };
346
- }
347
- function isRunnerHookWrapper(hooksPath, repoRoot) {
348
- const dir = resolve(repoRoot, expandHooksPathTilde(hooksPath));
349
- if (basename(dir) !== HOOKS_DIR_NAME) return false;
350
- try {
351
- const script2 = readFileSync(join(dir, "pre-commit"), "utf8");
352
- const secondLine = script2.indexOf("\n") + 1;
353
- return secondLine > 0 && script2.startsWith(HOOK_WRAPPER_MARKER, secondLine);
354
- } catch {
355
- return false;
356
- }
357
- }
358
- function deadHooksState(cwd) {
359
- const inRepo = git(cwd, ["rev-parse", "--is-inside-work-tree"]);
360
- if (inRepo !== "true") return { dead: false };
361
- const hooksPath = git(cwd, ["config", "core.hooksPath"]) ?? "";
362
- if (hooksPath === "") return { dead: false };
363
- const top = git(cwd, ["rev-parse", "--show-toplevel"]);
364
- if (top === void 0) return { dead: false };
365
- const expanded = expandHooksPathTilde(hooksPath);
366
- const hooksDir2 = isAbsolute(expanded) ? expanded : join(top, expanded);
367
- let entries;
368
- try {
369
- entries = readdirSync(hooksDir2);
370
- } catch (err) {
371
- const code = err.code;
372
- if (code === "ENOENT" || code === "ENOTDIR") return { dead: true, hooksDir: hooksDir2, repoRoot: top };
373
- return { dead: false, hooksDir: hooksDir2, repoRoot: top, unreadableError: err };
374
- }
375
- const dead = entries.filter((e) => e !== ".gitignore").length === 0;
376
- return { dead, hooksDir: hooksDir2, repoRoot: top };
377
- }
378
- var ALLOWED_PACKAGE_MANAGERS = ["yarn", "npm", "pnpm", "bun"];
379
- function preparePackageManagerCommand(repoRoot) {
380
- let declared = "";
381
- try {
382
- const pkg = JSON.parse(readFileSync(join(repoRoot, "package.json"), "utf8"));
383
- if (typeof pkg.packageManager === "string") declared = pkg.packageManager.split("@")[0] ?? "";
384
- } catch {
385
- declared = "";
386
- }
387
- if (!ALLOWED_PACKAGE_MANAGERS.includes(declared)) declared = "";
388
- if (declared === "yarn") return "yarn prepare";
389
- return `${declared || "npm"} run prepare`;
390
- }
391
- function huskyPrepareScript(repoRoot) {
392
- try {
393
- const pkg = JSON.parse(readFileSync(join(repoRoot, "package.json"), "utf8"));
394
- const script2 = pkg.scripts?.prepare;
395
- if (typeof script2 === "string" && /husky/i.test(script2)) return script2;
396
- } catch {
397
- }
398
- return null;
399
- }
400
-
401
- export { HOOKS_DIR_NAME, contextExcludesPresent, deadHooksState, ensureContextExcludes, ensurePreCommitGuardHook, huskyPrepareScript, installPreCommitGuardHook, installPreCommitGuardInGitDir, managedHookScripts, preparePackageManagerCommand, removeJournalHooks, removePreCommitGuardHook, writeCommitHooks };
@@ -1,109 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from 'node:module';
3
- import { defaultGitRunner, hasSymlinkComponent } from './chunk-W5VPCONO.js';
4
- import { writeContextManifest, writePinIfChanged, touchLastCheck, clearDegraded, writeSourceCache, SOURCE_CACHE_TTL_SUCCESS_MS, writeBuildHold } from './chunk-LXAY4A2G.js';
5
- import './chunk-T4Y6SCG3.js';
6
- import './chunk-ZRL6HKBY.js';
7
- import './chunk-52NC2FIU.js';
8
- import './chunk-MNTSH4CL.js';
9
- import './chunk-X5N6KC6V.js';
10
- import './chunk-N3CUDFCW.js';
11
- import './chunk-EABW6AJQ.js';
12
- import './chunk-RA3O54FC.js';
13
- import './chunk-M2ZWWTWZ.js';
14
- import './chunk-N2PXGQRL.js';
15
- import './chunk-BQXFBI7T.js';
16
- import { ensureContextExcludes, installPreCommitGuardInGitDir } from './chunk-XCCLFVXM.js';
17
- import './chunk-ZJSNLVCE.js';
18
- import './chunk-BJ3KTMDH.js';
19
- import './chunk-CRB3POP4.js';
20
- import './chunk-VNVZDWO3.js';
21
- import './chunk-Z5GEFMRW.js';
22
- import { lstatSync, readFileSync, mkdirSync, writeFileSync, chmodSync } from 'fs';
23
- import { join, dirname } from 'path';
24
-
25
- createRequire(import.meta.url);
26
- var CONFLICT_MESSAGE = "this repository tracks AGENTS.md, .claude or .outerlayer in git, which would shadow the control plane's context: remove them in a commit";
27
- var refused = (code, message) => ({ status: "refused", code, message });
28
- function readSummary(stagedDir) {
29
- try {
30
- const parsed = JSON.parse(readFileSync(join(stagedDir, "staged.json"), "utf8"));
31
- if (parsed.schemaVersion === 1 && typeof parsed.sha === "string" && typeof parsed.repository === "string" && typeof parsed.ref === "string" && Array.isArray(parsed.files) && parsed.files.every((f) => typeof f === "string")) {
32
- return parsed;
33
- }
34
- } catch {
35
- }
36
- return void 0;
37
- }
38
- function isContextPath(rel) {
39
- if (rel.split("/").some((segment) => segment === ".." || segment === "")) return false;
40
- return rel === "AGENTS.md" || rel.startsWith(".claude/") || rel.startsWith(".outerlayer/");
41
- }
42
- function adoptStagedContext(input) {
43
- const git = input.git ?? defaultGitRunner;
44
- const now = input.now ?? Date.now;
45
- const summary = readSummary(input.stagedDir);
46
- if (summary === void 0) return refused("context_adoption_failed", `${join(input.stagedDir, "staged.json")} is missing or malformed`);
47
- const run = (args) => {
48
- const result = git(args, { cwd: input.cwd, timeoutMs: 5e3 });
49
- return result.ok ? result.stdout.toString("utf8").trim() : void 0;
50
- };
51
- const repoRoot = run(["rev-parse", "--show-toplevel"]);
52
- const gitCommonDir = run(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
53
- if (repoRoot === void 0 || gitCommonDir === void 0) return refused("context_adoption_failed", `${input.cwd} is not a git checkout`);
54
- const tracked = git(["ls-files", "-z", "--", "AGENTS.md", ".claude", ".outerlayer"], { cwd: repoRoot, timeoutMs: 5e3 });
55
- if (!tracked.ok) return refused("context_adoption_failed", "git could not list the checkout's tracked files");
56
- if (tracked.stdout.length > 0) return refused("context_adoption_conflict", CONFLICT_MESSAGE);
57
- const tree = join(input.stagedDir, "tree");
58
- const copies = [];
59
- for (const rel of summary.files) {
60
- if (!isContextPath(rel)) return refused("context_adoption_failed", `the staged context lists ${rel}, which is not a context path`);
61
- let content;
62
- let executable;
63
- try {
64
- const source = join(tree, rel);
65
- const stat = lstatSync(source);
66
- if (!stat.isFile()) return refused("context_adoption_failed", `the staged ${rel} is not a regular file`);
67
- executable = (stat.mode & 73) !== 0;
68
- content = readFileSync(source);
69
- } catch {
70
- return refused("context_adoption_failed", `the staged ${rel} could not be read`);
71
- }
72
- if (hasSymlinkComponent(repoRoot, rel)) return refused("context_adoption_failed", `${rel} in the checkout passes through a symlink, so it is not written`);
73
- copies.push({ rel, content, mode: executable ? 493 : 420 });
74
- }
75
- for (const { rel, content, mode } of copies) {
76
- const destination = join(repoRoot, rel);
77
- mkdirSync(dirname(destination), { recursive: true });
78
- writeFileSync(destination, content);
79
- chmodSync(destination, mode);
80
- }
81
- const at = new Date(now()).toISOString();
82
- writeContextManifest(gitCommonDir, { schemaVersion: 1, sha: summary.sha, files: summary.files, materializedAt: at });
83
- ensureContextExcludes(gitCommonDir);
84
- const guard = installPreCommitGuardInGitDir(gitCommonDir);
85
- writePinIfChanged(repoRoot, summary.sha);
86
- touchLastCheck(gitCommonDir, now());
87
- clearDegraded(gitCommonDir);
88
- writeSourceCache(gitCommonDir, { checkedAt: at, status: "governed", repository: summary.repository, ref: summary.ref, ttlMs: SOURCE_CACHE_TTL_SUCCESS_MS });
89
- writeBuildHold(gitCommonDir, { sha: summary.sha, repository: summary.repository, ref: summary.ref, at });
90
- const guardMissing = !guard.adopted;
91
- return {
92
- status: "adopted",
93
- sha: summary.sha,
94
- files: copies.length,
95
- ...guardMissing ? { message: "the commit guard is NOT installed: a pre-commit hook this build did not write occupies its slot" } : {}
96
- };
97
- }
98
- function runContextAdopt(stagedDir, cwd, deps = {}) {
99
- let outcome;
100
- try {
101
- outcome = adoptStagedContext({ stagedDir, cwd, ...deps });
102
- } catch (err) {
103
- outcome = refused("context_adoption_failed", err instanceof Error ? err.message : String(err));
104
- }
105
- return { exitCode: outcome.status === "adopted" ? 0 : 1, stdout: `${JSON.stringify(outcome)}
106
- ` };
107
- }
108
-
109
- export { adoptStagedContext, runContextAdopt };
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from 'node:module';
3
- export { defaultGitRunner, hasSymlinkComponent, isStagingWriteFault, lookupGoverningSource, materializeContext, parseOwnerRepo, parseRemoteHost, resolveGitCommonDir } from './chunk-W5VPCONO.js';
4
- import './chunk-LXAY4A2G.js';
5
- import './chunk-T4Y6SCG3.js';
6
- import './chunk-ZRL6HKBY.js';
7
- import './chunk-52NC2FIU.js';
8
- import './chunk-MNTSH4CL.js';
9
- import './chunk-X5N6KC6V.js';
10
- import './chunk-N3CUDFCW.js';
11
- import './chunk-EABW6AJQ.js';
12
- import './chunk-RA3O54FC.js';
13
- import './chunk-M2ZWWTWZ.js';
14
- import './chunk-N2PXGQRL.js';
15
- import './chunk-BQXFBI7T.js';
16
- import './chunk-XCCLFVXM.js';
17
- import './chunk-ZJSNLVCE.js';
18
- import './chunk-BJ3KTMDH.js';
19
- import './chunk-CRB3POP4.js';
20
- import './chunk-VNVZDWO3.js';
21
- import './chunk-Z5GEFMRW.js';
22
-
23
- createRequire(import.meta.url);
@@ -2,8 +2,8 @@
2
2
  import { createRequire } from 'node:module';
3
3
  import { revokeTokenOnDashboard } from './chunk-GOSFARMS.js';
4
4
  import { C } from './chunk-ANPNT6PM.js';
5
- import { readCloudConfig, writeCloudConfig, cloudConfigPath } from './chunk-EABW6AJQ.js';
6
5
  import { findGitDirs } from './chunk-BJ3KTMDH.js';
6
+ import { readCloudConfig, writeCloudConfig, cloudConfigPath } from './chunk-EABW6AJQ.js';
7
7
  import { cliInvocation } from './chunk-CRB3POP4.js';
8
8
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
9
9
  import { generateKeyPairSync, privateDecrypt, constants, createPrivateKey } from 'crypto';
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { readCloudConfig, cloudConfigPath } from './chunk-EABW6AJQ.js';
4
- import { signRunnerRequest, signerFor } from './chunk-M2ZWWTWZ.js';
5
4
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
5
+ import { signRunnerRequest, signerFor } from './chunk-M2ZWWTWZ.js';
6
6
 
7
7
  createRequire(import.meta.url);
8
8
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { readCloudConfig } from './chunk-EABW6AJQ.js';
4
3
  import { readRepoConnection, findGitDirs } from './chunk-BJ3KTMDH.js';
4
+ import { readCloudConfig } from './chunk-EABW6AJQ.js';
5
5
  import { cliInvocation } from './chunk-CRB3POP4.js';
6
6
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
7
7
 
@@ -2,8 +2,8 @@
2
2
  import { createRequire } from 'node:module';
3
3
  import { MAX_ALLOW_HOSTS, allowHostProblem } from './chunk-UXYLWVTQ.js';
4
4
  import { parseSize } from './chunk-7RQ73DLO.js';
5
- import { isRefusedInConfig, resolveDestinations, isReservedVariable } from './chunk-BQXFBI7T.js';
6
5
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
6
+ import { isRefusedInConfig, resolveDestinations, isReservedVariable } from './chunk-BQXFBI7T.js';
7
7
  import { existsSync, statSync, accessSync, constants, readFileSync } from 'fs';
8
8
  import { hostname } from 'os';
9
9
  import { join } from 'path';