@outerlayer/cli 0.36.0-next.20261101174803 → 0.36.0-next.20261102135508
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/agent-setup-Q3HDN23U.js +39 -0
- package/dist/agent-subcommand-Z6SOLWZW.js +25 -0
- package/dist/bridge-4KPODDN7.js +15 -0
- package/dist/build-KYXFZQ33.js +23 -0
- package/dist/build-disk-W6AL5WHI.js +20 -0
- package/dist/build-info.json +1 -1
- package/dist/builder-IMNOEYV7.js +19 -0
- package/dist/caller-NLRE272L.js +22 -0
- package/dist/{check-K4RVAP4L.js → check-WWX32IGY.js} +78 -74
- package/dist/{chunk-MKSZHT6S.js → chunk-2YC3TXWX.js} +1 -1
- package/dist/{chunk-QIOTIQWD.js → chunk-3UFX6KH2.js} +12 -11
- package/dist/{chunk-F2LPX2HS.js → chunk-3YEPLVNW.js} +8 -8
- package/dist/chunk-4DLJ343I.js +38 -0
- package/dist/{chunk-5WYT3PPE.js → chunk-4OD45RBP.js} +4 -1
- package/dist/{chunk-H7SKHAUE.js → chunk-4XXBV37R.js} +6 -6
- package/dist/{chunk-XNBUZGRO.js → chunk-6B3V6EGQ.js} +11 -9
- package/dist/{chunk-O36YAH2G.js → chunk-6HDXRDC5.js} +4 -4
- package/dist/chunk-6JLYU322.js +68 -0
- package/dist/{chunk-5GHJFETA.js → chunk-6KH3NMIT.js} +3010 -1196
- package/dist/{chunk-SPXVFFQV.js → chunk-AQE6E54X.js} +10 -9
- package/dist/{chunk-LGV5N5DG.js → chunk-ATKCHMFD.js} +1 -1
- package/dist/{chunk-7J7HRYZ3.js → chunk-B2P72DAE.js} +1 -1
- package/dist/{chunk-LEHBDEUG.js → chunk-B36NSEUM.js} +4 -5
- package/dist/{chunk-B62TYDP2.js → chunk-B5SWBFVE.js} +5 -4
- package/dist/chunk-BSPJI5T7.js +28 -0
- package/dist/{chunk-VJYSPH2J.js → chunk-BUYXEU7J.js} +26 -21
- package/dist/{chunk-CIUD3436.js → chunk-BZSJ77MO.js} +1 -1
- package/dist/{chunk-OEBFKPHK.js → chunk-CDG475ZP.js} +11 -11
- package/dist/{chunk-AGKQEOFS.js → chunk-CSBW4LGL.js} +54 -31
- package/dist/{chunk-D2OTBS47.js → chunk-CSVJGW3I.js} +2 -2
- package/dist/{chunk-GANAOCHR.js → chunk-CXJC3JLN.js} +25 -374
- package/dist/{chunk-WAZJPDR2.js → chunk-D4VGJQY7.js} +1 -1
- package/dist/{chunk-BRUDBWLO.js → chunk-D5I5SSPU.js} +7 -7
- package/dist/{chunk-KFUDKFEH.js → chunk-D6EXW4EB.js} +45 -19
- package/dist/{chunk-AF6DQJ5W.js → chunk-DG3M5DZU.js} +1 -1
- package/dist/{chunk-WT7J2627.js → chunk-DTCTXDJP.js} +1 -1
- package/dist/chunk-DTQPDMHG.js +654 -0
- package/dist/{chunk-EZRAR5YG.js → chunk-E3TP4QTM.js} +1 -1
- package/dist/{chunk-NFZJ5XHP.js → chunk-ENBOAE2W.js} +33 -32
- package/dist/{chunk-R3252UTU.js → chunk-ENMX3VQ7.js} +7 -7
- package/dist/{chunk-AH6634HC.js → chunk-FOSYM7TQ.js} +1 -2
- package/dist/{chunk-HL7UNTXO.js → chunk-FRMAQ3C4.js} +17 -10
- package/dist/{chunk-HAWPG7QW.js → chunk-FTP7SE6Y.js} +3 -3
- package/dist/{chunk-IP7BIBXJ.js → chunk-FWSVWPMS.js} +16 -7
- package/dist/{chunk-GLUQVET2.js → chunk-GFZ7PELR.js} +6 -6
- package/dist/{chunk-UZGQT6OF.js → chunk-H2NJG3TE.js} +6 -3
- package/dist/{chunk-46OBCATR.js → chunk-HRHWA6TZ.js} +1 -1
- package/dist/chunk-HTRDL42C.js +45 -0
- package/dist/{chunk-YBAVN6WS.js → chunk-I4DM7SNX.js} +7 -7
- package/dist/{chunk-24FEVLX7.js → chunk-I6U6QPN6.js} +1311 -73
- package/dist/{chunk-4DJZSNVT.js → chunk-IKFAJTLZ.js} +1 -1
- package/dist/{chunk-55PYF6S2.js → chunk-J2OMKFYB.js} +3 -3
- package/dist/{chunk-7Y5VW4JG.js → chunk-K2G3VB7W.js} +1 -1
- package/dist/chunk-K7N6LAPC.js +78 -0
- package/dist/{chunk-ULBVE7MP.js → chunk-KRCU66AM.js} +9 -9
- package/dist/{chunk-JU3VU42K.js → chunk-LHHDX7FB.js} +5 -5
- package/dist/{chunk-FUJUFLDC.js → chunk-LO4CK734.js} +8 -14
- package/dist/chunk-LSLK4RS4.js +82 -0
- package/dist/{chunk-ABAVN4RT.js → chunk-LSZUTI6O.js} +29 -26
- package/dist/chunk-MVPOYQQY.js +136 -0
- package/dist/{chunk-YQHEJ5SV.js → chunk-NXQK2I3G.js} +3 -3
- package/dist/{chunk-DJMR4YPG.js → chunk-O3MJAHLI.js} +82 -96
- package/dist/{chunk-B7PYT2BY.js → chunk-PBGNX3PS.js} +6 -3
- package/dist/{chunk-CJJDJ7AT.js → chunk-PIZA7OG2.js} +5 -3
- package/dist/{chunk-RIHB3HA2.js → chunk-PMA67TIN.js} +3 -3
- package/dist/{chunk-DJDTL6AY.js → chunk-QKOJ22OV.js} +148 -293
- package/dist/{chunk-RDWKRG4K.js → chunk-RF4JHGGB.js} +7 -7
- package/dist/{chunk-MOOZJRKM.js → chunk-SJJXDU2J.js} +27 -30
- package/dist/chunk-T5QBWM6M.js +113 -0
- package/dist/{chunk-W7I65BKE.js → chunk-TJIFYV2Z.js} +12 -12
- package/dist/{chunk-EBOQU6QC.js → chunk-TKY3SDXH.js} +6 -6
- package/dist/{chunk-ALEUIS35.js → chunk-ULBYRPAP.js} +1 -1
- package/dist/{chunk-ZP7F3OHV.js → chunk-URHS76GV.js} +48 -38
- package/dist/{chunk-X2XTCGUS.js → chunk-VAYVTUU4.js} +11 -12
- package/dist/{chunk-TSYHUUAT.js → chunk-VUH7KKVD.js} +3 -3
- package/dist/{chunk-RIIPBJK6.js → chunk-WACPWYMH.js} +4 -4
- package/dist/{chunk-AAGU5FJF.js → chunk-WGC7UFRM.js} +1 -1
- package/dist/{chunk-2SRQSGPR.js → chunk-WVAXJOWG.js} +30 -24
- package/dist/{chunk-KLXECBIE.js → chunk-XEWG4AB2.js} +151 -108
- package/dist/{chunk-KDK6AF7B.js → chunk-XIDDJSQU.js} +7 -6
- package/dist/{chunk-MXIFRYLA.js → chunk-Y4E7IS7H.js} +2 -2
- package/dist/{chunk-DHFNBNC3.js → chunk-YJQ7YA7J.js} +5 -5
- package/dist/{chunk-6A2GEFN3.js → chunk-YMVRCSKD.js} +4 -4
- package/dist/{chunk-JW5BENE6.js → chunk-YYQ5NOT5.js} +3 -3
- package/dist/chunk-ZHQC43NH.js +130 -0
- package/dist/{chunk-KB5B6ZT5.js → chunk-ZSRMJOAK.js} +20 -20
- package/dist/{claude-launcher-L77BKZOC.js → claude-launcher-LGKJZH33.js} +99 -120
- package/dist/{cli-QQY5UECM.js → cli-Q5L64EEG.js} +327 -298
- package/dist/{cli-update-notice-T3CXRWNB.js → cli-update-notice-AWYJ4A7R.js} +2 -2
- package/dist/{command-QLHQZ32L.js → command-CGEFJZNC.js} +65 -64
- package/dist/{config-5GY7FL35.js → config-T22KVOOT.js} +14 -10
- package/dist/connect-cmd-RUBP466E.js +28 -0
- package/dist/{container-start-OCJODSMB.js → container-start-JRF3SBUA.js} +65 -62
- package/dist/{context-cleanup-A7KBEBIO.js → context-cleanup-3K2AOECJ.js} +6 -2
- package/dist/{context-show-cmd-MZ74ZIVO.js → context-show-cmd-4UXO5WQJ.js} +18 -16
- package/dist/{control-plane-launch-3TZFOSCX.js → control-plane-launch-AAH4YH56.js} +31 -27
- package/dist/{demo-record-cmd-Y57UWBCX.js → demo-record-cmd-2OKCGST7.js} +10 -5
- package/dist/{demo-voice-cmd-4INIOVTC.js → demo-voice-cmd-GEPX7GIG.js} +27 -27
- package/dist/{dist-6KGTCWKR.js → dist-VVZIGSAF.js} +1 -1
- package/dist/docker-5VWK335X.js +19 -0
- package/dist/{doctor-DB2AJUAO.js → doctor-EQM3JRZI.js} +81 -76
- package/dist/emit-artifact-cmd-TA3MPHLU.js +43 -0
- package/dist/{emit-cmd-IOWTTZSA.js → emit-cmd-RO4L4PFZ.js} +9 -8
- package/dist/emit-criteria-cmd-NMTUV2KM.js +34 -0
- package/dist/emit-demo-cmd-Y2Y6LEL7.js +46 -0
- package/dist/{emit-finding-cmd-KQIGM5IF.js → emit-finding-cmd-VECM64UR.js} +20 -19
- package/dist/{emit-result-cmd-6Q7OU2NY.js → emit-result-cmd-2ERWFDUN.js} +25 -24
- package/dist/{emit-step-cmd-GZU5O2FR.js → emit-step-cmd-V2ET66N4.js} +20 -19
- package/dist/exec-client-54XKNPTI.js +16 -0
- package/dist/find-unit-CNAPU7XQ.js +23 -0
- package/dist/{findings-cmd-T7PQAVJG.js → findings-cmd-QJPPF6BY.js} +20 -19
- package/dist/{fleet-readiness-PTMOEX6L.js → fleet-readiness-DKAPHAZN.js} +16 -15
- package/dist/governing-source-7PZ6DAJU.js +40 -0
- package/dist/guest-init-5QZRGP62.js +18 -0
- package/dist/{hook-fast-RW7RU3O6.js → hook-fast-VXROB4KF.js} +7 -5
- package/dist/hook-install-GDNRMML4.js +14 -0
- package/dist/{hook-wrap-fast-545QJSBJ.js → hook-wrap-fast-LWWKKPGK.js} +4 -2
- package/dist/host-checks-WAPO5X7X.js +78 -0
- package/dist/host-key-HLLV37NV.js +16 -0
- package/dist/image-tag-PBWQBATH.js +17 -0
- package/dist/index.js +8 -9
- package/dist/init-EK3PUU6W.js +78 -0
- package/dist/{init-HUQLVUPO.js → init-Y2URPVVY.js} +62 -59
- package/dist/{init-cmd-6NQGBVAJ.js → init-cmd-XNANUDIW.js} +38 -33
- package/dist/{init-update-MA6QKX46.js → init-update-EFCTKF6D.js} +55 -46
- package/dist/install-cmd-RHFUZFV4.js +19 -0
- package/dist/layout-7XMC7S6K.js +13 -0
- package/dist/{logs-FEITSC2V.js → logs-E7MGQINH.js} +10 -3
- package/dist/loop-L6TX6OR4.js +89 -0
- package/dist/machine-VJKAY2GX.js +78 -0
- package/dist/{machine-skills-237PQFRC.js → machine-skills-HR4RNRNR.js} +5 -4
- package/dist/{mcp-install-cmd-23ZY4IBK.js → mcp-install-cmd-SMPLT43Q.js} +7 -1
- package/dist/{mcp-serve-cmd-ZINYSLY6.js → mcp-serve-cmd-XXERT673.js} +11 -7
- package/dist/{paths-XEYE7OZ2.js → paths-F2ZR2EKC.js} +10 -3
- package/dist/pending-VOFQRXP4.js +16 -0
- package/dist/pidfile-7M7O2M7T.js +17 -0
- package/dist/record-YCJ6DZOY.js +16 -0
- package/dist/{relay-IEYNSKAZ.js → relay-I2T43PPB.js} +8 -1
- package/dist/relay-protocol-GI2GC2AM.js +13 -0
- package/dist/runner-env-YW55JVU7.js +23 -0
- package/dist/runner-identity-Y5ZFCC7V.js +19 -0
- package/dist/{runner-key-CFZ47PR3.js → runner-key-R47C6374.js} +54 -54
- package/dist/session-sender-UPACLRGG.js +43 -0
- package/dist/{shell-function-NRD4KVUK.js → shell-function-GYD2ZQQG.js} +2 -1
- package/dist/{spec-cmd-CNASSB6L.js → spec-cmd-7QRE2SZK.js} +21 -20
- package/dist/{starter-pack-CCVIEY72.js → starter-pack-IMKIUA56.js} +7 -6
- package/dist/state-VAHBIMS5.js +16 -0
- package/dist/{status-VNHIHQ57.js → status-BQEYEG2V.js} +54 -54
- package/dist/{statusline-fast-E7RWVREA.js → statusline-fast-NUVHCNRX.js} +4 -2
- package/dist/{sync-cmd-5JLJBODH.js → sync-cmd-NBLYEPQG.js} +25 -24
- package/dist/update-steps-VGKNGWTZ.js +79 -0
- package/dist/{watch-AEWWTUEK.js → watch-IHV4V3HZ.js} +25 -24
- package/dist/{work-claim-cmd-GUYOJYH7.js → work-claim-cmd-WGTSU5IT.js} +24 -24
- package/dist/{work-cmd-YRPYMGII.js → work-cmd-HKOJU5FJ.js} +18 -17
- package/dist/{work-comment-cmd-U5Z6FKEU.js → work-comment-cmd-H3JCWQ2J.js} +21 -20
- package/dist/{work-demo-cmd-OLCWTVWM.js → work-demo-cmd-J4AZAIVP.js} +18 -17
- package/dist/{work-launch-TTGSHLY4.js → work-launch-LWDQXLGI.js} +1 -1
- package/dist/{work-logs-cmd-2OA7ENDU.js → work-logs-cmd-UOO4JVLG.js} +18 -17
- package/dist/{work-open-pr-cmd-6GUCDYVM.js → work-open-pr-cmd-QFRDDBAM.js} +20 -19
- package/dist/{work-pr-cmd-KK3VQUQI.js → work-pr-cmd-3Q2D5RQT.js} +19 -18
- package/dist/{work-proofs-cmd-BUOS5OJC.js → work-proofs-cmd-7Y3HGT7C.js} +21 -20
- package/dist/{work-proofs-record-6WLMOK53.js → work-proofs-record-QPUM6DY4.js} +31 -31
- package/dist/{work-stop-cmd-VZJX5X4L.js → work-stop-cmd-SD2ZRMSY.js} +18 -17
- package/package.json +1 -1
- package/dist/agent-setup-DJRQFPDU.js +0 -33
- package/dist/bridge-XM4QLKIX.js +0 -8
- package/dist/build-ZE5IG3V6.js +0 -18
- package/dist/build-disk-GMXDIZU4.js +0 -15
- package/dist/builder-LJ3FSB36.js +0 -14
- package/dist/caller-YLNJJPFU.js +0 -18
- package/dist/chunk-CXFJOX2C.js +0 -144
- package/dist/chunk-FGF52V4V.js +0 -137
- package/dist/chunk-HCVLP7XA.js +0 -53
- package/dist/chunk-KYDEBGJG.js +0 -402
- package/dist/chunk-MESOOLF4.js +0 -45
- package/dist/chunk-OHQMGLJP.js +0 -113
- package/dist/chunk-OUPQTA7N.js +0 -145
- package/dist/chunk-VRMXYQWR.js +0 -74
- package/dist/connect-cmd-THV7XBVP.js +0 -27
- package/dist/docker-5YVUZ3J2.js +0 -14
- package/dist/emit-artifact-cmd-H27MFSKH.js +0 -42
- package/dist/emit-criteria-cmd-IOUVMB2Q.js +0 -33
- package/dist/emit-demo-cmd-WJSS7KU2.js +0 -46
- package/dist/exec-client-FGGPQSYQ.js +0 -9
- package/dist/find-unit-PRZIFBIK.js +0 -19
- package/dist/governing-source-CND5ZZC3.js +0 -39
- package/dist/guest-init-WPUS45IN.js +0 -11
- package/dist/host-checks-S3B7Z4SY.js +0 -78
- package/dist/host-key-O4DFMOSV.js +0 -9
- package/dist/image-tag-WBD57QBN.js +0 -10
- package/dist/init-ILTX4V56.js +0 -78
- package/dist/install-cmd-JKPXIOEY.js +0 -12
- package/dist/layout-2ZMCT2D3.js +0 -11
- package/dist/loop-KDWDOSMQ.js +0 -89
- package/dist/machine-Z6K5XXI6.js +0 -78
- package/dist/pending-D2NNV54J.js +0 -9
- package/dist/pidfile-FLFVRKVW.js +0 -10
- package/dist/record-JMZOXD4R.js +0 -9
- package/dist/relay-protocol-5LSWUJCW.js +0 -6
- package/dist/runner-env-W2UMHY7P.js +0 -19
- package/dist/runner-identity-IIY5UJL3.js +0 -14
- package/dist/session-sender-NO4F2IQ5.js +0 -42
- package/dist/settings-XB2HYBKO.js +0 -7
- package/dist/state-UWIM42JH.js +0 -9
- package/dist/update-steps-XGOXDCOS.js +0 -79
- package/dist/{chunk-OLM2TIOW.js → chunk-NFZMENCY.js} +1 -1
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { RESERVED_EMIT_NAMES, ARTIFACT_KINDS, ArtifactCriterionIdSchema } from './chunk-WUKLQWGY.js';
|
|
4
|
+
import { CLAUDE_CODE_HOOKS } from './chunk-T5QBWM6M.js';
|
|
5
|
+
import { CLAUDE_CODE, NATIVE_AGENTS, LEGACY_AGENT } from './chunk-LSLK4RS4.js';
|
|
6
|
+
import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
|
|
7
|
+
import { resolvePackageVersion } from './chunk-RA3O54FC.js';
|
|
8
|
+
import { homeFromEnv } from './chunk-352DHUTP.js';
|
|
4
9
|
import { __commonJS, __require, __toESM } from './chunk-Z5GEFMRW.js';
|
|
10
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync, rmSync, renameSync, realpathSync, readlinkSync, symlinkSync, copyFileSync, statSync, accessSync, constants, lstatSync } from 'fs';
|
|
11
|
+
import { join as join$1, dirname } from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import { spawnSync } from 'child_process';
|
|
14
|
+
import { homedir } from 'os';
|
|
5
15
|
|
|
6
16
|
createRequire(import.meta.url);
|
|
7
17
|
|
|
@@ -7263,6 +7273,21 @@ var require_dist = __commonJS({
|
|
|
7263
7273
|
}
|
|
7264
7274
|
});
|
|
7265
7275
|
|
|
7276
|
+
// ../agents/src/adapter.ts
|
|
7277
|
+
var McpFileError = class extends Error {
|
|
7278
|
+
constructor(problem) {
|
|
7279
|
+
super(`the MCP file ${problem}`);
|
|
7280
|
+
this.problem = problem;
|
|
7281
|
+
}
|
|
7282
|
+
};
|
|
7283
|
+
var HookTextError = class extends Error {
|
|
7284
|
+
constructor(cause) {
|
|
7285
|
+
super(`the hook settings are not valid: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
7286
|
+
this.cause = cause;
|
|
7287
|
+
this.name = "HookTextError";
|
|
7288
|
+
}
|
|
7289
|
+
};
|
|
7290
|
+
|
|
7266
7291
|
// ../context-format/dist/index.js
|
|
7267
7292
|
var import_yaml = __toESM(require_dist(), 1);
|
|
7268
7293
|
function normalizePath(path) {
|
|
@@ -7566,71 +7591,8 @@ function buildAgentsMd(input) {
|
|
|
7566
7591
|
}
|
|
7567
7592
|
return { files, copies: [], warnings };
|
|
7568
7593
|
}
|
|
7569
|
-
function buildClaudeCode(input) {
|
|
7570
|
-
const files = [];
|
|
7571
|
-
const copies = [];
|
|
7572
|
-
const warnings = [];
|
|
7573
|
-
for (const entry of input.entries) {
|
|
7574
|
-
switch (entry.kind) {
|
|
7575
|
-
case "instructions": {
|
|
7576
|
-
const content = contentForEntry(input.contents, entry, warnings);
|
|
7577
|
-
if (content !== void 0) {
|
|
7578
|
-
files.push({ path: joinPath(entry.scopePath, "CLAUDE.md"), content: withHeader(entry.path, content) });
|
|
7579
|
-
}
|
|
7580
|
-
break;
|
|
7581
|
-
}
|
|
7582
|
-
case "skill": {
|
|
7583
|
-
const content = contentForEntry(input.contents, entry, warnings);
|
|
7584
|
-
if (content !== void 0) {
|
|
7585
|
-
files.push({
|
|
7586
|
-
path: joinPath(entry.scopePath, ".claude/skills", entry.skillName, "SKILL.md"),
|
|
7587
|
-
content: withHeader(entry.path, content)
|
|
7588
|
-
});
|
|
7589
|
-
}
|
|
7590
|
-
break;
|
|
7591
|
-
}
|
|
7592
|
-
case "skill-reference": {
|
|
7593
|
-
const content = contentForEntry(input.contents, entry, warnings);
|
|
7594
|
-
if (content !== void 0) {
|
|
7595
|
-
files.push({
|
|
7596
|
-
path: joinPath(entry.scopePath, ".claude/skills", entry.skillName, "references", skillReferenceRelPath(entry)),
|
|
7597
|
-
content: withHeader(entry.path, content)
|
|
7598
|
-
});
|
|
7599
|
-
}
|
|
7600
|
-
break;
|
|
7601
|
-
}
|
|
7602
|
-
case "command": {
|
|
7603
|
-
const content = contentForEntry(input.contents, entry, warnings);
|
|
7604
|
-
if (content !== void 0) {
|
|
7605
|
-
files.push({
|
|
7606
|
-
path: joinPath(entry.scopePath, ".claude/commands", commandRelPath(entry)),
|
|
7607
|
-
content: withHeader(entry.path, content)
|
|
7608
|
-
});
|
|
7609
|
-
}
|
|
7610
|
-
break;
|
|
7611
|
-
}
|
|
7612
|
-
case "mcp": {
|
|
7613
|
-
const content = contentForEntry(input.contents, entry, warnings);
|
|
7614
|
-
if (content !== void 0) {
|
|
7615
|
-
files.push({ path: joinPath(entry.scopePath, ".mcp.json"), content });
|
|
7616
|
-
}
|
|
7617
|
-
break;
|
|
7618
|
-
}
|
|
7619
|
-
}
|
|
7620
|
-
}
|
|
7621
|
-
for (const assetPath of input.assetPaths) {
|
|
7622
|
-
const parsed = parseSkillAssetPath(assetPath);
|
|
7623
|
-
if (!parsed) continue;
|
|
7624
|
-
copies.push({
|
|
7625
|
-
toPath: joinPath(parsed.scopePath, ".claude/skills", parsed.skillName, parsed.relPath),
|
|
7626
|
-
fromSourcePath: assetPath
|
|
7627
|
-
});
|
|
7628
|
-
}
|
|
7629
|
-
return { files, copies, warnings };
|
|
7630
|
-
}
|
|
7631
|
-
var ALL_TARGET_IDS = ["claude-code"];
|
|
7632
7594
|
var REMOVED_TARGET_IDS = ["cursor", "codex", "copilot", "factory"];
|
|
7633
|
-
function parseOuterlayerConfig(json) {
|
|
7595
|
+
function parseOuterlayerConfig(json, knownTargets) {
|
|
7634
7596
|
let raw;
|
|
7635
7597
|
try {
|
|
7636
7598
|
raw = JSON.parse(json);
|
|
@@ -7656,13 +7618,13 @@ function parseOuterlayerConfig(json) {
|
|
|
7656
7618
|
{
|
|
7657
7619
|
path: "targets",
|
|
7658
7620
|
code: "no_targets",
|
|
7659
|
-
message: `"targets" must be a non-empty array of target ids; valid ids: ${
|
|
7621
|
+
message: `"targets" must be a non-empty array of target ids; valid ids: ${knownTargets.join(", ")}`
|
|
7660
7622
|
}
|
|
7661
7623
|
],
|
|
7662
7624
|
warnings: []
|
|
7663
7625
|
};
|
|
7664
7626
|
}
|
|
7665
|
-
const validIds = new Set(
|
|
7627
|
+
const validIds = new Set(knownTargets);
|
|
7666
7628
|
const removedIds = new Set(REMOVED_TARGET_IDS);
|
|
7667
7629
|
const errors = [];
|
|
7668
7630
|
const targets = [];
|
|
@@ -7679,7 +7641,7 @@ function parseOuterlayerConfig(json) {
|
|
|
7679
7641
|
errors.push({
|
|
7680
7642
|
path: `targets[${i}]`,
|
|
7681
7643
|
code: "unknown_target",
|
|
7682
|
-
message: `unknown target id ${JSON.stringify(t)}; valid ids: ${
|
|
7644
|
+
message: `unknown target id ${JSON.stringify(t)}; valid ids: ${knownTargets.join(", ")}`
|
|
7683
7645
|
});
|
|
7684
7646
|
return;
|
|
7685
7647
|
}
|
|
@@ -7688,10 +7650,7 @@ function parseOuterlayerConfig(json) {
|
|
|
7688
7650
|
if (errors.length > 0) return { ok: false, errors, warnings: [] };
|
|
7689
7651
|
return { ok: true, errors: [], warnings: [], config: { targets } };
|
|
7690
7652
|
}
|
|
7691
|
-
|
|
7692
|
-
"claude-code": buildClaudeCode
|
|
7693
|
-
};
|
|
7694
|
-
function emitTree(input) {
|
|
7653
|
+
function emitTree(input, builders) {
|
|
7695
7654
|
if (input.targets.length === 0) {
|
|
7696
7655
|
return {
|
|
7697
7656
|
files: [],
|
|
@@ -7700,7 +7659,11 @@ function emitTree(input) {
|
|
|
7700
7659
|
errors: [{ path: "targets", code: "no_targets", message: "no targets configured \u2014 nothing to emit" }]
|
|
7701
7660
|
};
|
|
7702
7661
|
}
|
|
7703
|
-
const
|
|
7662
|
+
const unknown = input.targets.flatMap(
|
|
7663
|
+
(target, index) => Object.hasOwn(builders, target) ? [] : [{ path: `targets[${index}]`, code: "unknown_target", message: `unknown target id ${JSON.stringify(target)}` }]
|
|
7664
|
+
);
|
|
7665
|
+
if (unknown.length > 0) return { files: [], copies: [], warnings: [], errors: unknown };
|
|
7666
|
+
const perTarget = input.targets.map((target) => builders[target](input));
|
|
7704
7667
|
return mergeEmitResults([...perTarget, buildAgentsMd(input)]);
|
|
7705
7668
|
}
|
|
7706
7669
|
function mergeEmitResults(perTarget) {
|
|
@@ -8561,4 +8524,1279 @@ function parseProofsConfig(text) {
|
|
|
8561
8524
|
return problems.length > 0 ? { ok: false, problems } : { ok: true, value: { setup, teardown, runners } };
|
|
8562
8525
|
}
|
|
8563
8526
|
|
|
8564
|
-
|
|
8527
|
+
// ../agents/src/claude-code/credentials.ts
|
|
8528
|
+
var { forwarded, kinds, placeholders } = CLAUDE_CODE.credentials;
|
|
8529
|
+
var FORWARDED = forwarded;
|
|
8530
|
+
var KINDS = kinds;
|
|
8531
|
+
var BASE_URL_VARIABLE = "ANTHROPIC_BASE_URL";
|
|
8532
|
+
var QUIET_TRAFFIC_VARIABLE = "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC";
|
|
8533
|
+
function createClaudeCodeCredentials() {
|
|
8534
|
+
return {
|
|
8535
|
+
classify(env) {
|
|
8536
|
+
for (const variable of FORWARDED) {
|
|
8537
|
+
const value = env[variable];
|
|
8538
|
+
if (value === void 0 || value === "") continue;
|
|
8539
|
+
const kind = KINDS[variable];
|
|
8540
|
+
return { variable, provider: kind.provider, kind: kind.providerKind };
|
|
8541
|
+
}
|
|
8542
|
+
return void 0;
|
|
8543
|
+
},
|
|
8544
|
+
identify(value) {
|
|
8545
|
+
return FORWARDED.find((variable) => new RegExp(KINDS[variable].pattern).test(value));
|
|
8546
|
+
},
|
|
8547
|
+
buildEnvironment({ providerUrl, variable }) {
|
|
8548
|
+
const placeholder = placeholders[variable ?? ""];
|
|
8549
|
+
return {
|
|
8550
|
+
[BASE_URL_VARIABLE]: providerUrl(CLAUDE_CODE.providers[0]),
|
|
8551
|
+
...placeholder === void 0 ? {} : { [variable]: placeholder },
|
|
8552
|
+
[QUIET_TRAFFIC_VARIABLE]: "1"
|
|
8553
|
+
};
|
|
8554
|
+
}
|
|
8555
|
+
};
|
|
8556
|
+
}
|
|
8557
|
+
|
|
8558
|
+
// ../agents/src/claude-code/delivery.ts
|
|
8559
|
+
var PROJECT_DIR_SPELLINGS = [
|
|
8560
|
+
/"\$\{?CLAUDE_PROJECT_DIR\}?"\/\.claude(?![\w.-])/g,
|
|
8561
|
+
/\$\{CLAUDE_PROJECT_DIR\}\/\.claude(?![\w.-])/g,
|
|
8562
|
+
/\$CLAUDE_PROJECT_DIR\/\.claude(?![\w.-])/g
|
|
8563
|
+
];
|
|
8564
|
+
function controlPlaneVariableForms(variable) {
|
|
8565
|
+
return [
|
|
8566
|
+
new RegExp(`\\$\\{${variable}:-[^}]*\\}/\\.claude(?![\\w.-])`, "g"),
|
|
8567
|
+
new RegExp(`\\$\\{${variable}\\}/\\.claude(?![\\w.-])`, "g"),
|
|
8568
|
+
new RegExp(`\\$${variable}/\\.claude(?![\\w.-])`, "g")
|
|
8569
|
+
];
|
|
8570
|
+
}
|
|
8571
|
+
function rewriteHookCommand(command, dir) {
|
|
8572
|
+
return PROJECT_DIR_SPELLINGS.reduce((text, pattern) => text.replace(pattern, () => `${dir}/.claude`), command);
|
|
8573
|
+
}
|
|
8574
|
+
function rewriteControlPlanePaths(text, dir) {
|
|
8575
|
+
return text.replace(/(?<![\w./~$}:-])(\.outerlayer|\.claude)\//g, (_match, root) => `${dir}/${root}/`);
|
|
8576
|
+
}
|
|
8577
|
+
function rewriteAgentsFilePaths(text, dir, holds) {
|
|
8578
|
+
return text.replace(/(?<![\w./~$}:-])\.agents\/[\w@+./-]*/g, (match) => {
|
|
8579
|
+
const path = match.replace(/\.+$/, "");
|
|
8580
|
+
if (path.split("/").includes("..") || !holds(path)) return match;
|
|
8581
|
+
return `${dir}/${path}${match.slice(path.length)}`;
|
|
8582
|
+
});
|
|
8583
|
+
}
|
|
8584
|
+
function hookCommandEscapesControlPlane(command, controlPlaneVariable) {
|
|
8585
|
+
const remaining = [...PROJECT_DIR_SPELLINGS, ...controlPlaneVariableForms(controlPlaneVariable)].reduce((text, pattern) => text.replace(pattern, " "), command);
|
|
8586
|
+
return /\.claude(?:\/|["'\s;|&)]|$)/.test(remaining) || /\$\{?CLAUDE_PROJECT_DIR\}?"?\/\.claude/.test(remaining);
|
|
8587
|
+
}
|
|
8588
|
+
function deliverySection(dir) {
|
|
8589
|
+
return `This repository's control plane is not in the checkout. Its files are in \`${dir}\`. When the instructions name a file under \`.agents/\` that this directory holds, or a path under \`.outerlayer/\` or \`.claude/\`, read it under \`${dir}\`.`;
|
|
8590
|
+
}
|
|
8591
|
+
function join(base, ...parts) {
|
|
8592
|
+
return parts.reduce((path, part) => path === "" || path.endsWith("/") ? `${path}${part}` : `${path}/${part}`, base);
|
|
8593
|
+
}
|
|
8594
|
+
function parentOf(path) {
|
|
8595
|
+
const cut = path.lastIndexOf("/");
|
|
8596
|
+
return cut <= 0 ? path.slice(0, cut + 1) : path.slice(0, cut);
|
|
8597
|
+
}
|
|
8598
|
+
function filesOf(fs) {
|
|
8599
|
+
const exists2 = (path) => {
|
|
8600
|
+
const kind = fs.kind(path);
|
|
8601
|
+
if (kind !== "link") return kind !== "missing";
|
|
8602
|
+
try {
|
|
8603
|
+
return fs.kind(fs.realPath(path)) !== "missing";
|
|
8604
|
+
} catch {
|
|
8605
|
+
return false;
|
|
8606
|
+
}
|
|
8607
|
+
};
|
|
8608
|
+
const filesUnder2 = (dir, base = dir) => {
|
|
8609
|
+
if (fs.kind(dir) !== "directory") return [];
|
|
8610
|
+
const out = [];
|
|
8611
|
+
for (const name of fs.list(dir)) {
|
|
8612
|
+
const abs = join(dir, name);
|
|
8613
|
+
const kind = fs.kind(abs);
|
|
8614
|
+
if (kind === "directory") out.push(...filesUnder2(abs, base));
|
|
8615
|
+
else if (kind === "file") out.push(abs.slice(base.length + 1));
|
|
8616
|
+
}
|
|
8617
|
+
return out.sort();
|
|
8618
|
+
};
|
|
8619
|
+
const readText = (path) => fs.kind(path) === "file" ? fs.readText(path) : void 0;
|
|
8620
|
+
const isFile = (path) => fs.kind(path) === "file";
|
|
8621
|
+
return { exists: exists2, filesUnder: filesUnder2, readText, isFile };
|
|
8622
|
+
}
|
|
8623
|
+
function deliveredSettings(raw, dir) {
|
|
8624
|
+
if (raw === void 0) return "{}\n";
|
|
8625
|
+
const rewrite = (value) => {
|
|
8626
|
+
if (typeof value === "string") return rewriteHookCommand(value, dir);
|
|
8627
|
+
if (Array.isArray(value)) return value.map(rewrite);
|
|
8628
|
+
if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, rewrite(inner)]));
|
|
8629
|
+
return value;
|
|
8630
|
+
};
|
|
8631
|
+
try {
|
|
8632
|
+
return `${JSON.stringify(rewrite(JSON.parse(raw)), null, 2)}
|
|
8633
|
+
`;
|
|
8634
|
+
} catch {
|
|
8635
|
+
return rewriteHookCommand(raw, dir);
|
|
8636
|
+
}
|
|
8637
|
+
}
|
|
8638
|
+
function createDelivery(io) {
|
|
8639
|
+
const { fs } = io;
|
|
8640
|
+
const { exists: exists2, filesUnder: filesUnder2, readText, isFile } = filesOf(fs);
|
|
8641
|
+
return {
|
|
8642
|
+
compose({ tree, dir, maintainedSkills }) {
|
|
8643
|
+
const added = [];
|
|
8644
|
+
const put = (rel, content) => {
|
|
8645
|
+
fs.makeDir(parentOf(join(tree, rel)));
|
|
8646
|
+
fs.write(join(tree, rel), content);
|
|
8647
|
+
added.push(rel);
|
|
8648
|
+
};
|
|
8649
|
+
for (const skill of maintainedSkills) {
|
|
8650
|
+
for (const rel of filesUnder2(join(tree, ".outerlayer/skills", skill))) {
|
|
8651
|
+
const target = `.claude/skills/${skill}/${rel}`;
|
|
8652
|
+
if (exists2(join(tree, target))) continue;
|
|
8653
|
+
fs.makeDir(parentOf(join(tree, target)));
|
|
8654
|
+
fs.copy(join(tree, ".outerlayer/skills", skill, rel), join(tree, target));
|
|
8655
|
+
added.push(target);
|
|
8656
|
+
}
|
|
8657
|
+
}
|
|
8658
|
+
const agentSkills = join(tree, ".agents/skills");
|
|
8659
|
+
if (exists2(agentSkills) && fs.kind(agentSkills) === "directory") {
|
|
8660
|
+
for (const name of fs.list(agentSkills)) {
|
|
8661
|
+
if (fs.kind(join(agentSkills, name)) !== "directory" || exists2(join(tree, ".claude/skills", name))) continue;
|
|
8662
|
+
for (const rel of filesUnder2(join(agentSkills, name))) {
|
|
8663
|
+
const target = `.claude/skills/${name}/${rel}`;
|
|
8664
|
+
fs.makeDir(parentOf(join(tree, target)));
|
|
8665
|
+
fs.copy(join(agentSkills, name, rel), join(tree, target));
|
|
8666
|
+
added.push(target);
|
|
8667
|
+
}
|
|
8668
|
+
}
|
|
8669
|
+
}
|
|
8670
|
+
for (const rel of [...filesUnder2(join(tree, ".claude/skills"), tree), ...filesUnder2(join(tree, ".claude/agents"), tree)]) {
|
|
8671
|
+
const text = readText(join(tree, rel));
|
|
8672
|
+
if (text === void 0) continue;
|
|
8673
|
+
const rewritten = rewriteControlPlanePaths(text, dir);
|
|
8674
|
+
if (rewritten !== text) fs.write(join(tree, rel), rewritten);
|
|
8675
|
+
}
|
|
8676
|
+
const agents = readText(join(tree, "AGENTS.md"));
|
|
8677
|
+
const instructions = agents === void 0 ? void 0 : rewriteAgentsFilePaths(rewriteControlPlanePaths(agents, dir), dir, (path) => isFile(join(tree, path)));
|
|
8678
|
+
put("CLAUDE.md", instructions === void 0 ? `${deliverySection(dir)}
|
|
8679
|
+
` : `${deliverySection(dir)}
|
|
8680
|
+
|
|
8681
|
+
${instructions}`);
|
|
8682
|
+
put("settings.json", deliveredSettings(readText(join(tree, ".claude/settings.json")), dir));
|
|
8683
|
+
return added;
|
|
8684
|
+
},
|
|
8685
|
+
deliveredSkills(tree) {
|
|
8686
|
+
const dir = join(tree, ".claude/skills");
|
|
8687
|
+
if (!exists2(dir)) return [];
|
|
8688
|
+
return fs.list(dir).filter((name) => fs.kind(join(dir, name)) === "directory").sort();
|
|
8689
|
+
},
|
|
8690
|
+
escapesDelivery: hookCommandEscapesControlPlane
|
|
8691
|
+
};
|
|
8692
|
+
}
|
|
8693
|
+
|
|
8694
|
+
// ../agents/src/claude-code/settings.ts
|
|
8695
|
+
var REGISTERED_EVENTS = CLAUDE_CODE_HOOKS.events;
|
|
8696
|
+
var MARKER = "_outerlayer";
|
|
8697
|
+
var WRAP_MARKER = "_outerlayerWrapped";
|
|
8698
|
+
function ourCommandBins(settings, cli) {
|
|
8699
|
+
return unique(ourCommandLaunches(settings, cli).map((launch) => launch.bin));
|
|
8700
|
+
}
|
|
8701
|
+
function ourDirectScriptBins(settings, cli) {
|
|
8702
|
+
return unique(ourCommandLaunches(settings, cli).filter((launch) => !launch.viaNode && launch.script).map((launch) => launch.bin));
|
|
8703
|
+
}
|
|
8704
|
+
function ourCommandLaunches(settings, cli) {
|
|
8705
|
+
const launches = [];
|
|
8706
|
+
const add = (command) => {
|
|
8707
|
+
const parsed = cli.split(command);
|
|
8708
|
+
if (!parsed || parsed.viaNpx) return;
|
|
8709
|
+
if (!["hook", "hook-wrap", "statusline"].includes(parsed.args[0] ?? "")) return;
|
|
8710
|
+
if (parsed.bin.includes("$") || !isAbsolutePath(parsed.bin)) return;
|
|
8711
|
+
launches.push(parsed);
|
|
8712
|
+
};
|
|
8713
|
+
for (const matchers of Object.values(settings?.hooks ?? {})) {
|
|
8714
|
+
for (const matcher of matchers ?? []) for (const h of matcher.hooks ?? []) add(h.command);
|
|
8715
|
+
}
|
|
8716
|
+
add(settings?.statusLine?.command);
|
|
8717
|
+
return launches;
|
|
8718
|
+
}
|
|
8719
|
+
function isAbsolutePath(path) {
|
|
8720
|
+
return path.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("\\\\");
|
|
8721
|
+
}
|
|
8722
|
+
function unique(values) {
|
|
8723
|
+
return [...new Set(values)];
|
|
8724
|
+
}
|
|
8725
|
+
function parseLifecycleHookCommand(command, cli) {
|
|
8726
|
+
const args = cli.parse(command);
|
|
8727
|
+
if (!args || args.length !== 2 || args[0] !== "hook") return null;
|
|
8728
|
+
return REGISTERED_EVENTS.includes(args[1]) ? args[1] : null;
|
|
8729
|
+
}
|
|
8730
|
+
function parseWrappedHookCommand(command, cli) {
|
|
8731
|
+
const args = cli.parse(command);
|
|
8732
|
+
if (!args || args[0] !== "hook-wrap" || args[1] !== "--id") return null;
|
|
8733
|
+
if (args.length === 4 ? args[3] !== "--capture-output" : args.length !== 3) return null;
|
|
8734
|
+
return cli.decode(args[2]);
|
|
8735
|
+
}
|
|
8736
|
+
function isOurHookCommand(h, cli) {
|
|
8737
|
+
return h[MARKER] === true || parseLifecycleHookCommand(h.command, cli) !== null;
|
|
8738
|
+
}
|
|
8739
|
+
function wrappedOriginalCommand(h, cli) {
|
|
8740
|
+
if (typeof h[WRAP_MARKER] === "string") return h[WRAP_MARKER];
|
|
8741
|
+
return parseWrappedHookCommand(h.command, cli);
|
|
8742
|
+
}
|
|
8743
|
+
function isWrapped(h, cli) {
|
|
8744
|
+
return wrappedOriginalCommand(h, cli) !== null;
|
|
8745
|
+
}
|
|
8746
|
+
function ourEntry(cli, event) {
|
|
8747
|
+
return {
|
|
8748
|
+
hooks: [{ type: "command", command: cli.command(`hook ${event}`), [MARKER]: true }]
|
|
8749
|
+
};
|
|
8750
|
+
}
|
|
8751
|
+
function pruneOurHooks(blocks, cli) {
|
|
8752
|
+
let removedAny = false;
|
|
8753
|
+
const kept = blocks.filter((block) => {
|
|
8754
|
+
const original = block.hooks ?? [];
|
|
8755
|
+
const remaining = original.filter((h) => !isOurHookCommand(h, cli));
|
|
8756
|
+
if (remaining.length !== original.length) {
|
|
8757
|
+
removedAny = true;
|
|
8758
|
+
block.hooks = remaining;
|
|
8759
|
+
}
|
|
8760
|
+
return remaining.length > 0 || original.length === 0;
|
|
8761
|
+
});
|
|
8762
|
+
return { kept, removedAny };
|
|
8763
|
+
}
|
|
8764
|
+
function mergeHooks(settings, cli) {
|
|
8765
|
+
const next = settings ? structuredClone(settings) : {};
|
|
8766
|
+
next.hooks = next.hooks ? { ...next.hooks } : {};
|
|
8767
|
+
let changed = false;
|
|
8768
|
+
for (const event of REGISTERED_EVENTS) {
|
|
8769
|
+
const existing = next.hooks[event] ?? [];
|
|
8770
|
+
const before = JSON.stringify(existing);
|
|
8771
|
+
const foreign = pruneOurHooks(existing, cli).kept;
|
|
8772
|
+
const desired = [...foreign, ourEntry(cli, event)];
|
|
8773
|
+
if (before !== JSON.stringify(desired)) changed = true;
|
|
8774
|
+
next.hooks[event] = desired;
|
|
8775
|
+
}
|
|
8776
|
+
return { next, changed };
|
|
8777
|
+
}
|
|
8778
|
+
function removeHooks(settings, cli) {
|
|
8779
|
+
const next = settings ? structuredClone(settings) : {};
|
|
8780
|
+
if (!next.hooks) return { next, changed: false };
|
|
8781
|
+
let changed = false;
|
|
8782
|
+
for (const event of Object.keys(next.hooks)) {
|
|
8783
|
+
const { kept, removedAny } = pruneOurHooks(next.hooks[event] ?? [], cli);
|
|
8784
|
+
if (removedAny) changed = true;
|
|
8785
|
+
if (kept.length === 0) delete next.hooks[event];
|
|
8786
|
+
else next.hooks[event] = kept;
|
|
8787
|
+
}
|
|
8788
|
+
if (next.hooks && Object.keys(next.hooks).length === 0) delete next.hooks;
|
|
8789
|
+
return { next, changed };
|
|
8790
|
+
}
|
|
8791
|
+
function runsCommand(h) {
|
|
8792
|
+
return typeof h.command === "string";
|
|
8793
|
+
}
|
|
8794
|
+
function listHookCandidates(settings, cli) {
|
|
8795
|
+
const out = [];
|
|
8796
|
+
const hooks = settings?.hooks ?? {};
|
|
8797
|
+
for (const event of Object.keys(hooks)) {
|
|
8798
|
+
(hooks[event] ?? []).forEach((matcher, matcherIndex) => {
|
|
8799
|
+
matcher.hooks.forEach((h, hookIndex) => {
|
|
8800
|
+
if (!runsCommand(h) || isOurHookCommand(h, cli)) return;
|
|
8801
|
+
const original = wrappedOriginalCommand(h, cli);
|
|
8802
|
+
out.push({
|
|
8803
|
+
event,
|
|
8804
|
+
matcherIndex,
|
|
8805
|
+
hookIndex,
|
|
8806
|
+
matcher: matcher.matcher,
|
|
8807
|
+
command: original ?? h.command,
|
|
8808
|
+
wrapped: original !== null
|
|
8809
|
+
});
|
|
8810
|
+
});
|
|
8811
|
+
});
|
|
8812
|
+
}
|
|
8813
|
+
return out;
|
|
8814
|
+
}
|
|
8815
|
+
function wrapHookCommand(cli, h, opts = {}) {
|
|
8816
|
+
if (isWrapped(h, cli)) return h;
|
|
8817
|
+
const flag = opts.captureOutput ? " --capture-output" : "";
|
|
8818
|
+
return { ...h, command: cli.command(`hook-wrap --id ${cli.encode(h.command)}${flag}`), [WRAP_MARKER]: h.command };
|
|
8819
|
+
}
|
|
8820
|
+
function unwrapHookCommand(h, cli) {
|
|
8821
|
+
const original = wrappedOriginalCommand(h, cli);
|
|
8822
|
+
if (original === null) return h;
|
|
8823
|
+
const restored = { ...h, command: original };
|
|
8824
|
+
delete restored[WRAP_MARKER];
|
|
8825
|
+
return restored;
|
|
8826
|
+
}
|
|
8827
|
+
var AUTO_WRAP_EVENTS = ["PreToolUse", "PostToolUse"];
|
|
8828
|
+
function wrapHooks(settings, cli, opts = {}) {
|
|
8829
|
+
const next = settings ? structuredClone(settings) : {};
|
|
8830
|
+
const wrapped = [];
|
|
8831
|
+
if (!cli.resolvable()) {
|
|
8832
|
+
return { next, changed: false, wrapped, skippedUnresolvedBin: true };
|
|
8833
|
+
}
|
|
8834
|
+
let changed = false;
|
|
8835
|
+
if (!next.hooks) return { next, changed, wrapped };
|
|
8836
|
+
for (const event of Object.keys(next.hooks)) {
|
|
8837
|
+
if (opts.events && !opts.events.includes(event)) continue;
|
|
8838
|
+
const matchers = next.hooks[event] ?? [];
|
|
8839
|
+
for (let mi = 0; mi < matchers.length; mi++) {
|
|
8840
|
+
const matcher = matchers[mi];
|
|
8841
|
+
for (let hi = 0; hi < matcher.hooks.length; hi++) {
|
|
8842
|
+
const h = matcher.hooks[hi];
|
|
8843
|
+
if (!runsCommand(h) || isOurHookCommand(h, cli) || isWrapped(h, cli)) continue;
|
|
8844
|
+
const candidate = {
|
|
8845
|
+
event,
|
|
8846
|
+
matcherIndex: mi,
|
|
8847
|
+
hookIndex: hi,
|
|
8848
|
+
matcher: matcher.matcher,
|
|
8849
|
+
command: h.command,
|
|
8850
|
+
wrapped: false
|
|
8851
|
+
};
|
|
8852
|
+
if (opts.select && !opts.select(candidate)) continue;
|
|
8853
|
+
matcher.hooks[hi] = wrapHookCommand(cli, h, { captureOutput: opts.captureOutput });
|
|
8854
|
+
wrapped.push(candidate);
|
|
8855
|
+
changed = true;
|
|
8856
|
+
}
|
|
8857
|
+
}
|
|
8858
|
+
}
|
|
8859
|
+
return { next, changed, wrapped };
|
|
8860
|
+
}
|
|
8861
|
+
function repointWrappedHooks(settings, cli) {
|
|
8862
|
+
const next = settings ? structuredClone(settings) : {};
|
|
8863
|
+
let changed = false;
|
|
8864
|
+
if (!next.hooks || !cli.resolvable()) return { next, changed };
|
|
8865
|
+
for (const matchers of Object.values(next.hooks)) {
|
|
8866
|
+
for (const matcher of matchers ?? []) {
|
|
8867
|
+
for (let hi = 0; hi < matcher.hooks.length; hi++) {
|
|
8868
|
+
const h = matcher.hooks[hi];
|
|
8869
|
+
const parsed = cli.split(h.command);
|
|
8870
|
+
if (!parsed || parsed.args[0] !== "hook-wrap") continue;
|
|
8871
|
+
if (cli.startsLikeCommand(parsed)) continue;
|
|
8872
|
+
const original = wrappedOriginalCommand(h, cli);
|
|
8873
|
+
if (original === null) continue;
|
|
8874
|
+
const flag = parsed.args.includes("--capture-output") ? " --capture-output" : "";
|
|
8875
|
+
const desired = cli.command(`hook-wrap --id ${cli.encode(original)}${flag}`);
|
|
8876
|
+
matcher.hooks[hi] = { ...h, command: desired, [WRAP_MARKER]: original };
|
|
8877
|
+
changed = true;
|
|
8878
|
+
}
|
|
8879
|
+
}
|
|
8880
|
+
}
|
|
8881
|
+
return { next, changed };
|
|
8882
|
+
}
|
|
8883
|
+
function statuslineCommand(cli) {
|
|
8884
|
+
return cli.command("statusline");
|
|
8885
|
+
}
|
|
8886
|
+
function statuslineWrapCommand(cli, original) {
|
|
8887
|
+
return cli.command(`statusline --wrap-id ${cli.encode(original)}`);
|
|
8888
|
+
}
|
|
8889
|
+
function isOurStatuslineSlot(slot, cli) {
|
|
8890
|
+
if (slot[MARKER] === true) return true;
|
|
8891
|
+
const args = cli.parse(slot.command);
|
|
8892
|
+
if (!args || args[0] !== "statusline") return false;
|
|
8893
|
+
return args.length === 1 || statuslineWrappedOriginal(slot, cli) !== null;
|
|
8894
|
+
}
|
|
8895
|
+
function statuslineWrappedOriginal(slot, cli) {
|
|
8896
|
+
if (typeof slot[WRAP_MARKER] === "string") return slot[WRAP_MARKER];
|
|
8897
|
+
const args = cli.parse(slot.command);
|
|
8898
|
+
if (!args || args.length !== 3 || args[0] !== "statusline" || args[1] !== "--wrap-id") return null;
|
|
8899
|
+
return cli.decode(args[2]);
|
|
8900
|
+
}
|
|
8901
|
+
function mergeStatusline(settings, cli) {
|
|
8902
|
+
const next = settings ? structuredClone(settings) : {};
|
|
8903
|
+
const slot = next.statusLine;
|
|
8904
|
+
if (slot === void 0 || slot === null) {
|
|
8905
|
+
next.statusLine = { type: "command", command: statuslineCommand(cli), [MARKER]: true };
|
|
8906
|
+
return { next, changed: true, outcome: "installed" };
|
|
8907
|
+
}
|
|
8908
|
+
if (typeof slot !== "object") {
|
|
8909
|
+
return { next, changed: false, outcome: "skipped" };
|
|
8910
|
+
}
|
|
8911
|
+
if (isOurStatuslineSlot(slot, cli)) {
|
|
8912
|
+
const original2 = statuslineWrappedOriginal(slot, cli);
|
|
8913
|
+
const desired = original2 !== null ? statuslineWrapCommand(cli, original2) : statuslineCommand(cli);
|
|
8914
|
+
const stripped = slot[MARKER] !== true || original2 !== null && typeof slot[WRAP_MARKER] !== "string";
|
|
8915
|
+
if (slot.command === desired && !stripped) {
|
|
8916
|
+
return { next, changed: false, outcome: "unchanged", ...original2 !== null ? { wrappedCommand: original2 } : {} };
|
|
8917
|
+
}
|
|
8918
|
+
slot.command = desired;
|
|
8919
|
+
slot[MARKER] = true;
|
|
8920
|
+
if (original2 !== null) slot[WRAP_MARKER] = original2;
|
|
8921
|
+
return { next, changed: true, outcome: "repaired", ...original2 !== null ? { wrappedCommand: original2 } : {} };
|
|
8922
|
+
}
|
|
8923
|
+
if (slot.type !== "command" || typeof slot.command !== "string") {
|
|
8924
|
+
return { next, changed: false, outcome: "skipped" };
|
|
8925
|
+
}
|
|
8926
|
+
const original = slot.command;
|
|
8927
|
+
slot.command = statuslineWrapCommand(cli, original);
|
|
8928
|
+
slot[MARKER] = true;
|
|
8929
|
+
slot[WRAP_MARKER] = original;
|
|
8930
|
+
return { next, changed: true, outcome: "wrapped", wrappedCommand: original };
|
|
8931
|
+
}
|
|
8932
|
+
function removeStatusline(settings, cli) {
|
|
8933
|
+
const next = settings ? structuredClone(settings) : {};
|
|
8934
|
+
const slot = next.statusLine;
|
|
8935
|
+
if (!slot || typeof slot !== "object" || !isOurStatuslineSlot(slot, cli)) {
|
|
8936
|
+
return { next, changed: false };
|
|
8937
|
+
}
|
|
8938
|
+
const original = statuslineWrappedOriginal(slot, cli);
|
|
8939
|
+
if (original !== null) {
|
|
8940
|
+
delete slot[MARKER];
|
|
8941
|
+
delete slot[WRAP_MARKER];
|
|
8942
|
+
slot.command = original;
|
|
8943
|
+
return { next, changed: true, restoredCommand: original };
|
|
8944
|
+
}
|
|
8945
|
+
delete next.statusLine;
|
|
8946
|
+
return { next, changed: true };
|
|
8947
|
+
}
|
|
8948
|
+
function unwrapHooks(settings, cli) {
|
|
8949
|
+
const next = settings ? structuredClone(settings) : {};
|
|
8950
|
+
let changed = false;
|
|
8951
|
+
let unwrapped = 0;
|
|
8952
|
+
if (!next.hooks) return { next, changed, unwrapped };
|
|
8953
|
+
for (const event of Object.keys(next.hooks)) {
|
|
8954
|
+
const matchers = next.hooks[event] ?? [];
|
|
8955
|
+
for (const matcher of matchers) {
|
|
8956
|
+
for (let hi = 0; hi < matcher.hooks.length; hi++) {
|
|
8957
|
+
const h = matcher.hooks[hi];
|
|
8958
|
+
if (!isWrapped(h, cli)) continue;
|
|
8959
|
+
matcher.hooks[hi] = unwrapHookCommand(h, cli);
|
|
8960
|
+
unwrapped++;
|
|
8961
|
+
changed = true;
|
|
8962
|
+
}
|
|
8963
|
+
}
|
|
8964
|
+
}
|
|
8965
|
+
return { next, changed, unwrapped };
|
|
8966
|
+
}
|
|
8967
|
+
function parseSettings(text) {
|
|
8968
|
+
if (text === void 0) return null;
|
|
8969
|
+
if (text.trim() === "") return {};
|
|
8970
|
+
try {
|
|
8971
|
+
return JSON.parse(text);
|
|
8972
|
+
} catch (err) {
|
|
8973
|
+
throw new HookTextError(err);
|
|
8974
|
+
}
|
|
8975
|
+
}
|
|
8976
|
+
function render(settings) {
|
|
8977
|
+
return `${JSON.stringify(settings, null, 2)}
|
|
8978
|
+
`;
|
|
8979
|
+
}
|
|
8980
|
+
function install(text, cli, options) {
|
|
8981
|
+
const current = parseSettings(text);
|
|
8982
|
+
const merged = mergeHooks(current, cli);
|
|
8983
|
+
const repointed = repointWrappedHooks(merged.next, cli);
|
|
8984
|
+
let next = repointed.next;
|
|
8985
|
+
let changed = merged.changed || repointed.changed;
|
|
8986
|
+
let wrapped = [];
|
|
8987
|
+
if (options.wrap) {
|
|
8988
|
+
const wrapResult = wrapHooks(next, cli, { events: [...AUTO_WRAP_EVENTS] });
|
|
8989
|
+
if (wrapResult.changed) {
|
|
8990
|
+
next = wrapResult.next;
|
|
8991
|
+
changed = true;
|
|
8992
|
+
wrapped = wrapResult.wrapped;
|
|
8993
|
+
}
|
|
8994
|
+
}
|
|
8995
|
+
let statusline;
|
|
8996
|
+
let statuslineWrappedCommand;
|
|
8997
|
+
if (options.statusline) {
|
|
8998
|
+
const slotResult = mergeStatusline(next, cli);
|
|
8999
|
+
statusline = slotResult.outcome;
|
|
9000
|
+
statuslineWrappedCommand = slotResult.wrappedCommand;
|
|
9001
|
+
if (slotResult.changed) {
|
|
9002
|
+
next = slotResult.next;
|
|
9003
|
+
changed = true;
|
|
9004
|
+
}
|
|
9005
|
+
}
|
|
9006
|
+
return {
|
|
9007
|
+
text: render(next),
|
|
9008
|
+
changed,
|
|
9009
|
+
events: REGISTERED_EVENTS,
|
|
9010
|
+
wrapped,
|
|
9011
|
+
...statusline ? { statusline } : {},
|
|
9012
|
+
...statuslineWrappedCommand ? { statuslineWrappedCommand } : {}
|
|
9013
|
+
};
|
|
9014
|
+
}
|
|
9015
|
+
function remove(text, cli) {
|
|
9016
|
+
const hooksRemoved = removeHooks(parseSettings(text), cli);
|
|
9017
|
+
const hooksUnwrapped = unwrapHooks(hooksRemoved.next, cli);
|
|
9018
|
+
const statuslineRemoved = removeStatusline(hooksUnwrapped.next, cli);
|
|
9019
|
+
return {
|
|
9020
|
+
text: render(statuslineRemoved.next),
|
|
9021
|
+
changed: hooksRemoved.changed || hooksUnwrapped.changed || statuslineRemoved.changed,
|
|
9022
|
+
unwrapped: hooksUnwrapped.unwrapped,
|
|
9023
|
+
...statuslineRemoved.restoredCommand ? { restoredStatusline: statuslineRemoved.restoredCommand } : {}
|
|
9024
|
+
};
|
|
9025
|
+
}
|
|
9026
|
+
function installed(text, cli) {
|
|
9027
|
+
const settings = parseSettings(text);
|
|
9028
|
+
const hooks = settings?.hooks;
|
|
9029
|
+
const wrapped = [];
|
|
9030
|
+
for (const event of Object.keys(hooks ?? {})) {
|
|
9031
|
+
for (const block of hooks?.[event] ?? []) {
|
|
9032
|
+
for (const h of block.hooks ?? []) {
|
|
9033
|
+
const original = wrappedOriginalCommand(h, cli);
|
|
9034
|
+
if (original !== null) wrapped.push({ event, original });
|
|
9035
|
+
}
|
|
9036
|
+
}
|
|
9037
|
+
}
|
|
9038
|
+
const slot = settings?.statusLine;
|
|
9039
|
+
let statusline = { slot: "empty" };
|
|
9040
|
+
if (slot && typeof slot === "object") {
|
|
9041
|
+
if (isOurStatuslineSlot(slot, cli)) {
|
|
9042
|
+
const wrapping = statuslineWrappedOriginal(slot, cli);
|
|
9043
|
+
statusline = { slot: "ours", ...wrapping === null ? {} : { wrapping } };
|
|
9044
|
+
} else if (typeof slot.command === "string") {
|
|
9045
|
+
statusline = { slot: "foreign", command: slot.command };
|
|
9046
|
+
}
|
|
9047
|
+
}
|
|
9048
|
+
return {
|
|
9049
|
+
hasHooks: Boolean(hooks),
|
|
9050
|
+
events: hooks ? REGISTERED_EVENTS.filter((event) => (hooks[event] ?? []).some((block) => (block.hooks ?? []).some((h) => isOurHookCommand(h, cli)))) : [],
|
|
9051
|
+
bins: ourCommandBins(settings, cli),
|
|
9052
|
+
directScriptBins: ourDirectScriptBins(settings, cli),
|
|
9053
|
+
wrapped,
|
|
9054
|
+
statusline
|
|
9055
|
+
};
|
|
9056
|
+
}
|
|
9057
|
+
var CLAUDE_CODE_HOOK_INSTALL = {
|
|
9058
|
+
settingsFile(scope, where) {
|
|
9059
|
+
const base = scope === "user" ? where.home : where.cwd;
|
|
9060
|
+
const separator = base.includes("\\") && !base.includes("/") ? "\\" : "/";
|
|
9061
|
+
return [base.replace(/[\\/]+$/, ""), ".claude", "settings.json"].join(separator);
|
|
9062
|
+
},
|
|
9063
|
+
install,
|
|
9064
|
+
remove,
|
|
9065
|
+
installed,
|
|
9066
|
+
candidates: (text, cli) => listHookCandidates(parseSettings(text), cli),
|
|
9067
|
+
wrap(text, cli, options) {
|
|
9068
|
+
const result = wrapHooks(parseSettings(text), cli, options);
|
|
9069
|
+
return { text: render(result.next), changed: result.changed, wrapped: result.wrapped, ...result.skippedUnresolvedBin ? { skippedUnresolvedBin: true } : {} };
|
|
9070
|
+
},
|
|
9071
|
+
unwrap(text, cli) {
|
|
9072
|
+
const result = unwrapHooks(parseSettings(text), cli);
|
|
9073
|
+
return { text: render(result.next), changed: result.changed, unwrapped: result.unwrapped };
|
|
9074
|
+
},
|
|
9075
|
+
managedSettings: {
|
|
9076
|
+
locations: [
|
|
9077
|
+
" macOS (MDM): /Library/Application Support/ClaudeCode/managed-settings.json",
|
|
9078
|
+
" (domain com.anthropic.claudecode)",
|
|
9079
|
+
" Linux: /etc/claude-code/managed-settings.json",
|
|
9080
|
+
" Windows (GPO): HKLM\\SOFTWARE\\Policies\\ClaudeCode, as a REG_SZ value named Settings"
|
|
9081
|
+
],
|
|
9082
|
+
document(command) {
|
|
9083
|
+
const hooks = {};
|
|
9084
|
+
for (const event of REGISTERED_EVENTS) hooks[event] = [{ hooks: [{ type: "command", command: command(event) }] }];
|
|
9085
|
+
return { hooks };
|
|
9086
|
+
}
|
|
9087
|
+
}
|
|
9088
|
+
};
|
|
9089
|
+
|
|
9090
|
+
// ../agents/src/claude-code/diagnostics.ts
|
|
9091
|
+
var NAME = CLAUDE_CODE.label;
|
|
9092
|
+
var PROGRAM = CLAUDE_CODE.program;
|
|
9093
|
+
function compareVersions(a, b) {
|
|
9094
|
+
const parse2 = (version) => version.split(".").map((part) => Number.isFinite(Number.parseInt(part, 10)) ? Number.parseInt(part, 10) : 0);
|
|
9095
|
+
const left = parse2(a);
|
|
9096
|
+
const right = parse2(b);
|
|
9097
|
+
for (let i = 0; i < 3; i++) {
|
|
9098
|
+
if ((left[i] ?? 0) !== (right[i] ?? 0)) return (left[i] ?? 0) - (right[i] ?? 0);
|
|
9099
|
+
}
|
|
9100
|
+
return 0;
|
|
9101
|
+
}
|
|
9102
|
+
var joinPath2 = (...parts) => joinWith("/", parts);
|
|
9103
|
+
function joinWith(separator, parts) {
|
|
9104
|
+
const doubled = new RegExp(`${separator.replace(/[\\/]/g, "\\$&")}{2,}`, "g");
|
|
9105
|
+
const joined = parts.join(separator);
|
|
9106
|
+
const lead = separator === "\\" && joined.startsWith("\\\\") ? "\\\\" : "";
|
|
9107
|
+
return lead + joined.slice(lead.length).replace(doubled, separator);
|
|
9108
|
+
}
|
|
9109
|
+
var joinerOf = (input) => (...parts) => joinWith(input.separator ?? "/", parts);
|
|
9110
|
+
function exists(io, path) {
|
|
9111
|
+
return io.fs.stat(path).kind !== "missing";
|
|
9112
|
+
}
|
|
9113
|
+
function homeCheck(io, input) {
|
|
9114
|
+
const dir = joinerOf(input)(input.home, ".claude");
|
|
9115
|
+
return [
|
|
9116
|
+
exists(io, dir) ? { name: `${NAME} home`, status: "pass", detail: dir } : { name: `${NAME} home`, status: "fail", detail: `${dir} not found`, fix: `Install ${NAME}, then run a session so transcripts exist.` }
|
|
9117
|
+
];
|
|
9118
|
+
}
|
|
9119
|
+
function retentionCheck(io, input) {
|
|
9120
|
+
const name = "Retention (cleanupPeriodDays)";
|
|
9121
|
+
let settings;
|
|
9122
|
+
try {
|
|
9123
|
+
const text = io.fs.readText(joinerOf(input)(input.home, ".claude", "settings.json"));
|
|
9124
|
+
settings = text === void 0 ? null : text.trim() === "" ? {} : JSON.parse(text);
|
|
9125
|
+
} catch {
|
|
9126
|
+
return [{ name, status: "warn", detail: "settings unreadable" }];
|
|
9127
|
+
}
|
|
9128
|
+
const raw = settings?.cleanupPeriodDays;
|
|
9129
|
+
const days = typeof raw === "number" ? raw : 30;
|
|
9130
|
+
if (days === 0) {
|
|
9131
|
+
return [
|
|
9132
|
+
{
|
|
9133
|
+
name,
|
|
9134
|
+
status: "fail",
|
|
9135
|
+
detail: "set to 0 \u2014 this DISABLES transcript persistence (upstream anthropics/claude-code#23710 and #59248)",
|
|
9136
|
+
fix: `Remove cleanupPeriodDays or set it \u226514; run \`${input.cli} daemon\` to mirror before deletion.`
|
|
9137
|
+
}
|
|
9138
|
+
];
|
|
9139
|
+
}
|
|
9140
|
+
if (days < 14) {
|
|
9141
|
+
return [{ name, status: "warn", detail: `${days}d \u2014 transcripts deleted quickly`, fix: `Run \`${input.cli} daemon\` so raws are mirrored before cleanup.` }];
|
|
9142
|
+
}
|
|
9143
|
+
return [{ name, status: "pass", detail: `${days}d` }];
|
|
9144
|
+
}
|
|
9145
|
+
function versionCheck(io, input) {
|
|
9146
|
+
const name = `${NAME} version`;
|
|
9147
|
+
const ran = io.runSync(PROGRAM, ["--version"], { timeoutMs: 5e3 });
|
|
9148
|
+
if (ran.code !== 0) return [{ name, status: "warn", detail: `could not run \`${PROGRAM} --version\``, fix: `Ensure \`${PROGRAM}\` is on PATH.` }];
|
|
9149
|
+
const version = ran.stdout.trim();
|
|
9150
|
+
const parsed = version.match(/\d+\.\d+\.\d+/)?.[0];
|
|
9151
|
+
if (!parsed) return [{ name, status: "warn", detail: `unrecognized: ${version}` }];
|
|
9152
|
+
const tested = input.tested ?? CLAUDE_CODE.versions.tested;
|
|
9153
|
+
if (compareVersions(parsed, tested.to) > 0) {
|
|
9154
|
+
return [{ name, status: "pass", detail: `${parsed} (newer than ${tested.to}, the latest version this release was tested with)` }];
|
|
9155
|
+
}
|
|
9156
|
+
if (compareVersions(parsed, tested.from) < 0) {
|
|
9157
|
+
return [{ name, status: "warn", detail: `${parsed} is older than validated (${tested.from})` }];
|
|
9158
|
+
}
|
|
9159
|
+
return [{ name, status: "pass", detail: parsed }];
|
|
9160
|
+
}
|
|
9161
|
+
function settingsCheck(io, input) {
|
|
9162
|
+
for (const scope of ["user", "project"]) {
|
|
9163
|
+
const path = CLAUDE_CODE_HOOK_INSTALL.settingsFile(scope, { home: input.home, cwd: input.cwd ?? "." });
|
|
9164
|
+
if (!exists(io, path)) continue;
|
|
9165
|
+
let text;
|
|
9166
|
+
try {
|
|
9167
|
+
text = io.fs.readText(path);
|
|
9168
|
+
} catch (err) {
|
|
9169
|
+
return [{ name: "Settings JSON valid", status: "fail", detail: `${path} is unreadable`, fix: `refusing to modify ${path}: it cannot be read (${err instanceof Error ? err.message : String(err)})` }];
|
|
9170
|
+
}
|
|
9171
|
+
try {
|
|
9172
|
+
if (text === void 0) throw new Error("the file is not text");
|
|
9173
|
+
if (text.trim() !== "") JSON.parse(text);
|
|
9174
|
+
} catch (err) {
|
|
9175
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
9176
|
+
return [{ name: "Settings JSON valid", status: "fail", detail: `${path} is corrupt`, fix: `refusing to modify ${path}: it is not valid JSON (${cause})` }];
|
|
9177
|
+
}
|
|
9178
|
+
}
|
|
9179
|
+
return [{ name: "Settings JSON valid", status: "pass", detail: "all settings files parse" }];
|
|
9180
|
+
}
|
|
9181
|
+
function distinctInstalls(io, paths) {
|
|
9182
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9183
|
+
const out = [];
|
|
9184
|
+
for (const path of paths) {
|
|
9185
|
+
let real = path;
|
|
9186
|
+
try {
|
|
9187
|
+
real = io.fs.realPath(path);
|
|
9188
|
+
} catch {
|
|
9189
|
+
}
|
|
9190
|
+
if (seen.has(real)) continue;
|
|
9191
|
+
seen.add(real);
|
|
9192
|
+
out.push(path);
|
|
9193
|
+
}
|
|
9194
|
+
return out;
|
|
9195
|
+
}
|
|
9196
|
+
function installsCheck(io) {
|
|
9197
|
+
let found = io.runSync("which", ["-a", PROGRAM], { timeoutMs: 5e3 });
|
|
9198
|
+
if (found.code === null) found = io.runSync("where", [PROGRAM], { timeoutMs: 5e3 });
|
|
9199
|
+
const listed = found.code === 0 ? found.stdout.split(/\r?\n/).filter((line) => line.trim().length > 0) : [];
|
|
9200
|
+
const installs = distinctInstalls(io, listed);
|
|
9201
|
+
if (installs.length > 1) {
|
|
9202
|
+
return [{ name: `${NAME} installs`, status: "warn", detail: `multiple found: ${installs.join(", ")}`, fix: "Multiple installs can diverge in version; keep one." }];
|
|
9203
|
+
}
|
|
9204
|
+
return [];
|
|
9205
|
+
}
|
|
9206
|
+
function hookCommandsOf(settings) {
|
|
9207
|
+
const hooks = settings?.hooks;
|
|
9208
|
+
if (typeof hooks !== "object" || hooks === null) return [];
|
|
9209
|
+
const commands = [];
|
|
9210
|
+
for (const groups of Object.values(hooks)) {
|
|
9211
|
+
if (!Array.isArray(groups)) continue;
|
|
9212
|
+
for (const group of groups) {
|
|
9213
|
+
const entries = group?.hooks;
|
|
9214
|
+
if (!Array.isArray(entries)) continue;
|
|
9215
|
+
for (const entry of entries) {
|
|
9216
|
+
const command = entry?.command;
|
|
9217
|
+
if (typeof command === "string") commands.push(command);
|
|
9218
|
+
}
|
|
9219
|
+
}
|
|
9220
|
+
}
|
|
9221
|
+
return commands;
|
|
9222
|
+
}
|
|
9223
|
+
function controlPlaneHooksCheck(io, input, context) {
|
|
9224
|
+
const top = io.runSync("git", ["-C", input.cwd ?? ".", "rev-parse", "--show-toplevel"], { timeoutMs: 2e3 });
|
|
9225
|
+
if (top.code !== 0) return [];
|
|
9226
|
+
const repoRoot = top.stdout.trim();
|
|
9227
|
+
if (!exists(io, joinerOf(input)(repoRoot, ".outerlayer"))) return [];
|
|
9228
|
+
let settings;
|
|
9229
|
+
try {
|
|
9230
|
+
settings = JSON.parse(io.fs.readText(joinerOf(input)(repoRoot, ".claude", "settings.json")) ?? "");
|
|
9231
|
+
} catch {
|
|
9232
|
+
return [];
|
|
9233
|
+
}
|
|
9234
|
+
const escaping = hookCommandsOf(settings).filter((command) => context.escapesDelivery(command, input.controlPlaneVariable));
|
|
9235
|
+
if (escaping.length === 0) return [];
|
|
9236
|
+
return [
|
|
9237
|
+
{
|
|
9238
|
+
name: "Control plane hook paths",
|
|
9239
|
+
status: "warn",
|
|
9240
|
+
detail: `${escaping.length === 1 ? "this hook command reaches" : "these hook commands reach"} a .claude directory by a path a governed build does not provide, so ${escaping.length === 1 ? "it fails" : "they fail"} there without a message: ${escaping.map((command) => `\`${command}\``).join(", ")}`,
|
|
9241
|
+
fix: `Name the script as \`\${${input.controlPlaneVariable}:-$CLAUDE_PROJECT_DIR}/.claude/\u2026\`. A governed build sets ${input.controlPlaneVariable} to where it reads the control plane; a checkout that holds its own copy falls back to the project directory.`
|
|
9242
|
+
}
|
|
9243
|
+
];
|
|
9244
|
+
}
|
|
9245
|
+
function scanTranscripts(io, root) {
|
|
9246
|
+
let count = 0;
|
|
9247
|
+
let newest = 0;
|
|
9248
|
+
const walk = (dir) => {
|
|
9249
|
+
let names;
|
|
9250
|
+
try {
|
|
9251
|
+
names = io.fs.list(dir);
|
|
9252
|
+
} catch {
|
|
9253
|
+
return;
|
|
9254
|
+
}
|
|
9255
|
+
for (const name of names) {
|
|
9256
|
+
const path = joinPath2(dir, name);
|
|
9257
|
+
const stat = io.fs.stat(path);
|
|
9258
|
+
if (stat.kind === "directory") walk(path);
|
|
9259
|
+
else if (stat.kind === "file" && name.endsWith(".jsonl") && stat.size > 0) {
|
|
9260
|
+
count += 1;
|
|
9261
|
+
if (stat.mtimeMs > newest) newest = stat.mtimeMs;
|
|
9262
|
+
}
|
|
9263
|
+
}
|
|
9264
|
+
};
|
|
9265
|
+
walk(root);
|
|
9266
|
+
return { count, newest };
|
|
9267
|
+
}
|
|
9268
|
+
function createDiagnostics(io, context) {
|
|
9269
|
+
const sections = {
|
|
9270
|
+
home: (input) => homeCheck(io, input),
|
|
9271
|
+
retention: (input) => retentionCheck(io, input),
|
|
9272
|
+
version: (input) => versionCheck(io, input),
|
|
9273
|
+
settings: (input) => settingsCheck(io, input),
|
|
9274
|
+
installs: () => installsCheck(io),
|
|
9275
|
+
"control-plane-hooks": (input) => controlPlaneHooksCheck(io, input, context)
|
|
9276
|
+
};
|
|
9277
|
+
return {
|
|
9278
|
+
checks(input) {
|
|
9279
|
+
const wanted = input.sections ?? Object.keys(sections);
|
|
9280
|
+
return Object.fromEntries(wanted.map((section) => [section, sections[section](input)]));
|
|
9281
|
+
},
|
|
9282
|
+
sessions(home) {
|
|
9283
|
+
const root = joinPath2(home, ".claude", "projects");
|
|
9284
|
+
return exists(io, root) ? scanTranscripts(io, root) : void 0;
|
|
9285
|
+
}
|
|
9286
|
+
};
|
|
9287
|
+
}
|
|
9288
|
+
|
|
9289
|
+
// ../agents/src/claude-code/emit.ts
|
|
9290
|
+
function buildClaudeCode(input) {
|
|
9291
|
+
const files = [];
|
|
9292
|
+
const copies = [];
|
|
9293
|
+
const warnings = [];
|
|
9294
|
+
for (const entry of input.entries) {
|
|
9295
|
+
switch (entry.kind) {
|
|
9296
|
+
case "instructions": {
|
|
9297
|
+
const content = contentForEntry(input.contents, entry, warnings);
|
|
9298
|
+
if (content !== void 0) {
|
|
9299
|
+
files.push({ path: joinPath(entry.scopePath, "CLAUDE.md"), content: withHeader(entry.path, content) });
|
|
9300
|
+
}
|
|
9301
|
+
break;
|
|
9302
|
+
}
|
|
9303
|
+
case "skill": {
|
|
9304
|
+
const content = contentForEntry(input.contents, entry, warnings);
|
|
9305
|
+
if (content !== void 0) {
|
|
9306
|
+
files.push({
|
|
9307
|
+
path: joinPath(entry.scopePath, ".claude/skills", entry.skillName, "SKILL.md"),
|
|
9308
|
+
content: withHeader(entry.path, content)
|
|
9309
|
+
});
|
|
9310
|
+
}
|
|
9311
|
+
break;
|
|
9312
|
+
}
|
|
9313
|
+
case "skill-reference": {
|
|
9314
|
+
const content = contentForEntry(input.contents, entry, warnings);
|
|
9315
|
+
if (content !== void 0) {
|
|
9316
|
+
files.push({
|
|
9317
|
+
path: joinPath(entry.scopePath, ".claude/skills", entry.skillName, "references", skillReferenceRelPath(entry)),
|
|
9318
|
+
content: withHeader(entry.path, content)
|
|
9319
|
+
});
|
|
9320
|
+
}
|
|
9321
|
+
break;
|
|
9322
|
+
}
|
|
9323
|
+
case "command": {
|
|
9324
|
+
const content = contentForEntry(input.contents, entry, warnings);
|
|
9325
|
+
if (content !== void 0) {
|
|
9326
|
+
files.push({
|
|
9327
|
+
path: joinPath(entry.scopePath, ".claude/commands", commandRelPath(entry)),
|
|
9328
|
+
content: withHeader(entry.path, content)
|
|
9329
|
+
});
|
|
9330
|
+
}
|
|
9331
|
+
break;
|
|
9332
|
+
}
|
|
9333
|
+
case "mcp": {
|
|
9334
|
+
const content = contentForEntry(input.contents, entry, warnings);
|
|
9335
|
+
if (content !== void 0) {
|
|
9336
|
+
files.push({ path: joinPath(entry.scopePath, ".mcp.json"), content });
|
|
9337
|
+
}
|
|
9338
|
+
break;
|
|
9339
|
+
}
|
|
9340
|
+
}
|
|
9341
|
+
}
|
|
9342
|
+
for (const assetPath of input.assetPaths) {
|
|
9343
|
+
const parsed = parseSkillAssetPath(assetPath);
|
|
9344
|
+
if (!parsed) continue;
|
|
9345
|
+
copies.push({
|
|
9346
|
+
toPath: joinPath(parsed.scopePath, ".claude/skills", parsed.skillName, parsed.relPath),
|
|
9347
|
+
fromSourcePath: assetPath
|
|
9348
|
+
});
|
|
9349
|
+
}
|
|
9350
|
+
return { files, copies, warnings };
|
|
9351
|
+
}
|
|
9352
|
+
|
|
9353
|
+
// ../agents/src/claude-code/image.ts
|
|
9354
|
+
var PREFIX = "/opt/outerlayer/claude";
|
|
9355
|
+
var PACKAGE = "@anthropic-ai/claude-code";
|
|
9356
|
+
var HOOK_EVENTS = ["SessionStart", "SessionEnd", "Stop", "PostToolUse"];
|
|
9357
|
+
var MANAGED_SETTINGS = JSON.stringify({
|
|
9358
|
+
hooks: Object.fromEntries(HOOK_EVENTS.map((event) => [event, [{ hooks: [{ type: "command", command: `outerlayer hook ${event}` }] }]]))
|
|
9359
|
+
});
|
|
9360
|
+
function createClaudeCodeImage() {
|
|
9361
|
+
return {
|
|
9362
|
+
install: (version) => [`RUN npm install --global --prefix /out${PREFIX} ${PACKAGE}@${version}`],
|
|
9363
|
+
program: `${PREFIX}/bin/claude`,
|
|
9364
|
+
command: CLAUDE_CODE.program,
|
|
9365
|
+
files: [{ path: "/etc/claude-code/managed-settings.json", text: MANAGED_SETTINGS }],
|
|
9366
|
+
env: { DISABLE_AUTOUPDATER: "1" },
|
|
9367
|
+
versionKey: CLAUDE_CODE.legacy.toolsVersionKey,
|
|
9368
|
+
latestUrl: `https://registry.npmjs.org/${PACKAGE}/latest`
|
|
9369
|
+
};
|
|
9370
|
+
}
|
|
9371
|
+
|
|
9372
|
+
// ../agents/src/claude-code/launch.ts
|
|
9373
|
+
var SESSION_ID_VARIABLE = "OUTERLAYER_SESSION_ID";
|
|
9374
|
+
var RESUME_SESSION_VARIABLE = "OUTERLAYER_RESUME_SESSION";
|
|
9375
|
+
var OWN_SESSION_FLAGS = /* @__PURE__ */ new Set(["--resume", "-r", "--continue", "-c", "--session-id", "--fork-session"]);
|
|
9376
|
+
var SHIM_SCRIPT = `#!/bin/sh
|
|
9377
|
+
exec outerlayer ${CLAUDE_CODE.legacy.subcommand} "$@"
|
|
9378
|
+
`;
|
|
9379
|
+
var joinPath3 = (...parts) => parts.join("/").replace(/\/{2,}/g, "/");
|
|
9380
|
+
function sessionArgs(env, callerArgs = []) {
|
|
9381
|
+
const { [SESSION_ID_VARIABLE]: sessionId, [RESUME_SESSION_VARIABLE]: resume, ...rest } = env;
|
|
9382
|
+
const named = sessionId !== void 0 && sessionId !== "";
|
|
9383
|
+
const resumes = resume !== void 0 && resume !== "";
|
|
9384
|
+
if (callerArgs.some((arg) => OWN_SESSION_FLAGS.has(arg)) || !named && !resumes) return { args: [], env: rest };
|
|
9385
|
+
return { args: [...resumes ? ["--resume", resume, "--fork-session"] : [], ...named ? ["--session-id", sessionId] : []], env: rest };
|
|
9386
|
+
}
|
|
9387
|
+
function configDir(io, env) {
|
|
9388
|
+
return env.CLAUDE_CONFIG_DIR ?? joinPath3(env.HOME || io.home(), ".claude");
|
|
9389
|
+
}
|
|
9390
|
+
function findTranscript(io, dir, id) {
|
|
9391
|
+
const root = joinPath3(dir, "projects");
|
|
9392
|
+
let projects;
|
|
9393
|
+
try {
|
|
9394
|
+
projects = io.fs.list(root);
|
|
9395
|
+
} catch {
|
|
9396
|
+
return void 0;
|
|
9397
|
+
}
|
|
9398
|
+
for (const project of projects) {
|
|
9399
|
+
const candidate = joinPath3(root, project, `${id}.jsonl`);
|
|
9400
|
+
if (io.fs.stat(candidate).kind !== "missing") return candidate;
|
|
9401
|
+
}
|
|
9402
|
+
return void 0;
|
|
9403
|
+
}
|
|
9404
|
+
function hasReplySince(io, path, sinceMs) {
|
|
9405
|
+
if (path === void 0) return false;
|
|
9406
|
+
try {
|
|
9407
|
+
for (const line of (io.fs.readText(path) ?? "").split("\n")) {
|
|
9408
|
+
if (!line.includes('"assistant"')) continue;
|
|
9409
|
+
const entry = JSON.parse(line);
|
|
9410
|
+
if (entry.type === "assistant" && typeof entry.timestamp === "string" && Date.parse(entry.timestamp) >= sinceMs) return true;
|
|
9411
|
+
}
|
|
9412
|
+
} catch {
|
|
9413
|
+
}
|
|
9414
|
+
return false;
|
|
9415
|
+
}
|
|
9416
|
+
function isSkipped(io, candidate) {
|
|
9417
|
+
try {
|
|
9418
|
+
return io.fs.stat(candidate).size === new TextEncoder().encode(SHIM_SCRIPT).length && io.fs.readText(candidate) === SHIM_SCRIPT;
|
|
9419
|
+
} catch {
|
|
9420
|
+
return true;
|
|
9421
|
+
}
|
|
9422
|
+
}
|
|
9423
|
+
function findProgram(io, path, delimiter) {
|
|
9424
|
+
const list = path ?? "";
|
|
9425
|
+
for (const entry of list.split(delimiter)) {
|
|
9426
|
+
if (entry === "") continue;
|
|
9427
|
+
const candidate = joinPath3(entry, CLAUDE_CODE.program);
|
|
9428
|
+
if (!io.fs.executable(candidate)) continue;
|
|
9429
|
+
if (isSkipped(io, candidate)) continue;
|
|
9430
|
+
return candidate;
|
|
9431
|
+
}
|
|
9432
|
+
return void 0;
|
|
9433
|
+
}
|
|
9434
|
+
function interactive(input) {
|
|
9435
|
+
const plane = input.controlPlane;
|
|
9436
|
+
const own = input.ownSkills === void 0 ? [] : ["--add-dir", input.ownSkills];
|
|
9437
|
+
const front = plane === void 0 ? own : ["--add-dir", plane, ...own, "--settings", joinPath3(plane, "settings.json")];
|
|
9438
|
+
const env = plane === void 0 ? input.env : { ...input.env, CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD: "1" };
|
|
9439
|
+
return {
|
|
9440
|
+
program: input.program,
|
|
9441
|
+
args: [...front, ...input.callerArgs],
|
|
9442
|
+
env: Object.fromEntries(Object.entries(env).filter((entry) => entry[1] !== void 0)),
|
|
9443
|
+
driver: "exec",
|
|
9444
|
+
exitFrom: "code"
|
|
9445
|
+
};
|
|
9446
|
+
}
|
|
9447
|
+
function createLaunch(io) {
|
|
9448
|
+
return {
|
|
9449
|
+
findProgram: (path, delimiter = ":") => findProgram(io, path, delimiter),
|
|
9450
|
+
version: (program, env) => io.runSync(program, ["--version"], { env, timeoutMs: 15e3 }).stdout,
|
|
9451
|
+
interactive,
|
|
9452
|
+
session: {
|
|
9453
|
+
args: sessionArgs,
|
|
9454
|
+
exists: (id, env) => findTranscript(io, configDir(io, env), id) !== void 0,
|
|
9455
|
+
hasReplySince: (id, env, sinceMs) => hasReplySince(io, findTranscript(io, configDir(io, env), id), sinceMs),
|
|
9456
|
+
discard(id, env) {
|
|
9457
|
+
const path = findTranscript(io, configDir(io, env), id);
|
|
9458
|
+
if (path !== void 0) io.fs.remove(path);
|
|
9459
|
+
}
|
|
9460
|
+
}
|
|
9461
|
+
};
|
|
9462
|
+
}
|
|
9463
|
+
|
|
9464
|
+
// ../agents/src/claude-code/mcp.ts
|
|
9465
|
+
function documentOf(text) {
|
|
9466
|
+
if (text === void 0) return {};
|
|
9467
|
+
let doc;
|
|
9468
|
+
try {
|
|
9469
|
+
doc = JSON.parse(text);
|
|
9470
|
+
} catch {
|
|
9471
|
+
throw new McpFileError("not-json");
|
|
9472
|
+
}
|
|
9473
|
+
if (doc === null || typeof doc !== "object" || Array.isArray(doc)) throw new McpFileError("not-object");
|
|
9474
|
+
return doc;
|
|
9475
|
+
}
|
|
9476
|
+
function isObject(value) {
|
|
9477
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
9478
|
+
}
|
|
9479
|
+
var CLAUDE_CODE_MCP = {
|
|
9480
|
+
file: ".mcp.json",
|
|
9481
|
+
servers(text) {
|
|
9482
|
+
let doc;
|
|
9483
|
+
try {
|
|
9484
|
+
doc = JSON.parse(text);
|
|
9485
|
+
} catch {
|
|
9486
|
+
return void 0;
|
|
9487
|
+
}
|
|
9488
|
+
if (doc === null) return void 0;
|
|
9489
|
+
const servers = doc.mcpServers;
|
|
9490
|
+
return servers !== null && typeof servers === "object" ? servers : {};
|
|
9491
|
+
},
|
|
9492
|
+
setServer(text, name, entry, mode) {
|
|
9493
|
+
const doc = documentOf(text);
|
|
9494
|
+
const current = doc.mcpServers;
|
|
9495
|
+
if (mode === "if-absent") {
|
|
9496
|
+
if (current !== void 0 && !isObject(current)) throw new McpFileError("servers-not-object");
|
|
9497
|
+
if (current !== void 0 && name in current) return { text: text ?? "", changed: false };
|
|
9498
|
+
}
|
|
9499
|
+
const existing = isObject(current) ? current : {};
|
|
9500
|
+
const changed = JSON.stringify(existing[name] ?? null) !== JSON.stringify(entry);
|
|
9501
|
+
return { text: `${JSON.stringify({ ...doc, mcpServers: { ...existing, [name]: entry } }, null, 2)}
|
|
9502
|
+
`, changed };
|
|
9503
|
+
}
|
|
9504
|
+
};
|
|
9505
|
+
|
|
9506
|
+
// ../agents/src/claude-code/adapter.ts
|
|
9507
|
+
function createClaudeCodeAdapter(io) {
|
|
9508
|
+
const context = {
|
|
9509
|
+
emit: buildClaudeCode,
|
|
9510
|
+
...createDelivery(io),
|
|
9511
|
+
mcp: CLAUDE_CODE_MCP
|
|
9512
|
+
};
|
|
9513
|
+
return {
|
|
9514
|
+
context,
|
|
9515
|
+
launch: createLaunch(io),
|
|
9516
|
+
lifecycle: {
|
|
9517
|
+
source: { kind: "hook-process", codec: CLAUDE_CODE_HOOKS },
|
|
9518
|
+
detectInSession: (env) => Boolean(env.CLAUDECODE),
|
|
9519
|
+
install: CLAUDE_CODE_HOOK_INSTALL
|
|
9520
|
+
},
|
|
9521
|
+
deliver: { kind: "hook-reply", cap: CLAUDE_CODE.hooks.contextCap, format: CLAUDE_CODE_HOOKS.reply },
|
|
9522
|
+
credentials: createClaudeCodeCredentials(),
|
|
9523
|
+
image: createClaudeCodeImage(),
|
|
9524
|
+
diagnostics: createDiagnostics(io, context)
|
|
9525
|
+
};
|
|
9526
|
+
}
|
|
9527
|
+
|
|
9528
|
+
// ../agents/src/native/factories.ts
|
|
9529
|
+
var ADAPTER_FACTORIES = {
|
|
9530
|
+
"claude-code": createClaudeCodeAdapter
|
|
9531
|
+
};
|
|
9532
|
+
|
|
9533
|
+
// ../agents/src/claude-code/conformance-fixtures.ts
|
|
9534
|
+
var TREE_ROOT = "/work/control-plane";
|
|
9535
|
+
var PATHS = [".outerlayer/AGENTS.md", ".outerlayer/skills/build/SKILL.md", ".outerlayer/commands/ship.md", ".outerlayer/mcp.json"];
|
|
9536
|
+
({
|
|
9537
|
+
hooks: {
|
|
9538
|
+
payloads: Object.fromEntries(
|
|
9539
|
+
["SessionStart", "SessionEnd", "Stop", "PostToolUse"].map((name) => [
|
|
9540
|
+
name,
|
|
9541
|
+
JSON.stringify({ session_id: "session-1", transcript_path: "/sessions/session-1.jsonl", cwd: "/work", hook_event_name: name, tool_name: "Bash", tool_use_id: "tool-1" })
|
|
9542
|
+
])
|
|
9543
|
+
)
|
|
9544
|
+
},
|
|
9545
|
+
context: {
|
|
9546
|
+
emitInput: { entries: classifyTree(PATHS).entries},
|
|
9547
|
+
tree: {
|
|
9548
|
+
[`${TREE_ROOT}/.claude/settings.json`]: `${JSON.stringify({ hooks: { SessionStart: [{ hooks: [{ type: "command", command: '"$CLAUDE_PROJECT_DIR"/.claude/hooks/start.sh' }] }] } })}
|
|
9549
|
+
`}}
|
|
9550
|
+
});
|
|
9551
|
+
var TEMPLATE_SKILLS = ["spec", "writing-specs", "writing-tests", "build"];
|
|
9552
|
+
function templateClassLine(version) {
|
|
9553
|
+
return `<!-- yours to edit. Copied once from the default template by outerlayer init ${version}; never overwritten. -->`;
|
|
9554
|
+
}
|
|
9555
|
+
function maintainedClassLine(version, base) {
|
|
9556
|
+
if (base === MACHINE_SKILL_PATH) return `<!-- maintained by OuterLayer ${version}. Edits are overwritten by the next outerlayer command. -->`;
|
|
9557
|
+
const command = base === AGENTS_SKILLS_BASE ? "outerlayer init --update" : "outerlayer context emit";
|
|
9558
|
+
return `<!-- maintained by OuterLayer ${version}. Edits are overwritten on the next ${command}. -->`;
|
|
9559
|
+
}
|
|
9560
|
+
var OUTERLAYER_SKILLS_BASE = ".outerlayer/skills";
|
|
9561
|
+
var AGENTS_SKILLS_BASE = ".agents/skills";
|
|
9562
|
+
var MACHINE_SKILL_PATH = "~/.agents/skills";
|
|
9563
|
+
var MAINTAINED_SKILL_PATH_IN_PACK = new RegExp(`${OUTERLAYER_SKILLS_BASE.replace(".", "\\.")}/(outerlayer-[a-z]+)/`, "g");
|
|
9564
|
+
function rewriteSkillPaths(content, base) {
|
|
9565
|
+
if (base === OUTERLAYER_SKILLS_BASE) return content;
|
|
9566
|
+
if (base === MACHINE_SKILL_PATH) {
|
|
9567
|
+
return content.replace(MAINTAINED_SKILL_PATH_IN_PACK, `${MACHINE_SKILL_PATH}/$1/`).split(`${OUTERLAYER_SKILLS_BASE}/`).join(`${AGENTS_SKILLS_BASE}/`);
|
|
9568
|
+
}
|
|
9569
|
+
return content.split(`${OUTERLAYER_SKILLS_BASE}/`).join(`${base}/`);
|
|
9570
|
+
}
|
|
9571
|
+
function restoreSkillPaths(content, base) {
|
|
9572
|
+
return base === OUTERLAYER_SKILLS_BASE ? content : content.split(`${base}/`).join(`${OUTERLAYER_SKILLS_BASE}/`);
|
|
9573
|
+
}
|
|
9574
|
+
function resolvePackRoot(entryPath = fileURLToPath(import.meta.url)) {
|
|
9575
|
+
return join$1(dirname(dirname(entryPath)), "skill-pack");
|
|
9576
|
+
}
|
|
9577
|
+
function skillDir(skill, base = OUTERLAYER_SKILLS_BASE) {
|
|
9578
|
+
return `${base}/${skill}`;
|
|
9579
|
+
}
|
|
9580
|
+
function renderSkillFile(skillClass, content, version, base) {
|
|
9581
|
+
const line = skillClass === "maintained" ? maintainedClassLine(version, base) : templateClassLine(version);
|
|
9582
|
+
const { frontmatterInner, body } = splitRawFile(content);
|
|
9583
|
+
if (frontmatterInner === null) return `${line}
|
|
9584
|
+
${content}`;
|
|
9585
|
+
const block = content.slice(0, content.length - body.length);
|
|
9586
|
+
return `${block}${block.endsWith("\n") ? "" : "\n"}${line}
|
|
9587
|
+
${body}`;
|
|
9588
|
+
}
|
|
9589
|
+
function filesUnder(dir, base = dir) {
|
|
9590
|
+
const out = [];
|
|
9591
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
9592
|
+
const abs = join$1(dir, entry.name);
|
|
9593
|
+
if (entry.isDirectory()) out.push(...filesUnder(abs, base));
|
|
9594
|
+
else if (entry.isFile()) out.push(abs.slice(base.length + 1).split("\\").join("/"));
|
|
9595
|
+
}
|
|
9596
|
+
return out.sort();
|
|
9597
|
+
}
|
|
9598
|
+
function orderSkillFiles(relPaths) {
|
|
9599
|
+
return [...relPaths.filter((p) => p === "SKILL.md"), ...relPaths.filter((p) => p !== "SKILL.md")];
|
|
9600
|
+
}
|
|
9601
|
+
function loadClass(packRoot, skillClass, names, version, base) {
|
|
9602
|
+
const files = [];
|
|
9603
|
+
for (const skill of names) {
|
|
9604
|
+
const dir = join$1(packRoot, skillClass, skill);
|
|
9605
|
+
if (!existsSync(dir)) throw new Error(`skill pack is missing ${skillClass}/${skill} under ${packRoot}`);
|
|
9606
|
+
for (const rel of orderSkillFiles(filesUnder(dir))) {
|
|
9607
|
+
const raw = readFileSync(join$1(dir, rel), "utf8");
|
|
9608
|
+
files.push({
|
|
9609
|
+
skill,
|
|
9610
|
+
skillClass,
|
|
9611
|
+
path: `${skillDir(skill, base)}/${rel}`,
|
|
9612
|
+
content: rewriteSkillPaths(rel === "SKILL.md" ? renderSkillFile(skillClass, raw, version, base) : raw, base)
|
|
9613
|
+
});
|
|
9614
|
+
}
|
|
9615
|
+
}
|
|
9616
|
+
return files;
|
|
9617
|
+
}
|
|
9618
|
+
function loadTemplateFiles(packRoot = resolvePackRoot(), version = resolvePackageVersion(), base = OUTERLAYER_SKILLS_BASE) {
|
|
9619
|
+
return loadClass(packRoot, "template", TEMPLATE_SKILLS, version, base);
|
|
9620
|
+
}
|
|
9621
|
+
function loadMaintainedFiles(packRoot = resolvePackRoot(), version = resolvePackageVersion(), base = OUTERLAYER_SKILLS_BASE) {
|
|
9622
|
+
return loadClass(packRoot, "maintained", MAINTAINED_SKILLS, version, base);
|
|
9623
|
+
}
|
|
9624
|
+
function loadMachineSkillFiles(packRoot = resolvePackRoot(), version = resolvePackageVersion()) {
|
|
9625
|
+
return loadClass(packRoot, "maintained", MAINTAINED_SKILLS, version, MACHINE_SKILL_PATH).map((file) => ({ ...file, path: file.path.slice(skillDir(file.skill, MACHINE_SKILL_PATH).length + 1) }));
|
|
9626
|
+
}
|
|
9627
|
+
function writeMaintainedFiles(repoRoot, files) {
|
|
9628
|
+
const created = [];
|
|
9629
|
+
const rewritten = [];
|
|
9630
|
+
for (const file of files) {
|
|
9631
|
+
const abs = join$1(repoRoot, file.path);
|
|
9632
|
+
const exists2 = existsSync(abs);
|
|
9633
|
+
if (exists2 && readFileSync(abs, "utf8") === file.content) continue;
|
|
9634
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
9635
|
+
writeFileSync(abs, file.content);
|
|
9636
|
+
(exists2 ? rewritten : created).push(file.path);
|
|
9637
|
+
}
|
|
9638
|
+
return { created, rewritten };
|
|
9639
|
+
}
|
|
9640
|
+
function maintainedFilesForExistingSkills(repoRoot, files, base = OUTERLAYER_SKILLS_BASE) {
|
|
9641
|
+
return files.filter(
|
|
9642
|
+
(file) => existsSync(join$1(repoRoot, skillDir(file.skill, base))) || formerNameExists(repoRoot, file.skill, base) || requiredByBuild(repoRoot, file.skill, base)
|
|
9643
|
+
);
|
|
9644
|
+
}
|
|
9645
|
+
var RELATIVE_CORE = "../outerlayer-build/SKILL.md";
|
|
9646
|
+
function namesCore(text) {
|
|
9647
|
+
return text.includes("outerlayer-build");
|
|
9648
|
+
}
|
|
9649
|
+
function requiredByBuild(repoRoot, skill, base) {
|
|
9650
|
+
if (skill !== "outerlayer-build") return false;
|
|
9651
|
+
const named = (file, pattern = "outerlayer-build") => {
|
|
9652
|
+
try {
|
|
9653
|
+
return readFileSync(file, "utf8").includes(pattern);
|
|
9654
|
+
} catch {
|
|
9655
|
+
return false;
|
|
9656
|
+
}
|
|
9657
|
+
};
|
|
9658
|
+
if (named(join$1(repoRoot, skillDir("build", base), "SKILL.md"), RELATIVE_CORE)) return true;
|
|
9659
|
+
const dir = join$1(repoRoot, ".outerlayer", "validators");
|
|
9660
|
+
try {
|
|
9661
|
+
return readdirSync(dir).some((name) => name.endsWith(".yaml") && named(join$1(dir, name)));
|
|
9662
|
+
} catch {
|
|
9663
|
+
return false;
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
var FORMER_MAINTAINED_NAMES = {
|
|
9667
|
+
amend: "outerlayer-amend",
|
|
9668
|
+
"emitting-evidence": "outerlayer-evidence",
|
|
9669
|
+
"reporting-findings": "outerlayer-findings",
|
|
9670
|
+
outerlayer: "outerlayer-cli"
|
|
9671
|
+
};
|
|
9672
|
+
var MAINTAINED_LINE = /^<!-- maintained by OuterLayer \S+?\. /m;
|
|
9673
|
+
function isMaintainedCopy(repoRoot, skill, base = OUTERLAYER_SKILLS_BASE) {
|
|
9674
|
+
try {
|
|
9675
|
+
return MAINTAINED_LINE.test(readFileSync(join$1(repoRoot, skillDir(skill, base), "SKILL.md"), "utf8"));
|
|
9676
|
+
} catch {
|
|
9677
|
+
return false;
|
|
9678
|
+
}
|
|
9679
|
+
}
|
|
9680
|
+
function formerNameExists(repoRoot, skill, base) {
|
|
9681
|
+
return Object.entries(FORMER_MAINTAINED_NAMES).some(([former, current]) => current === skill && isMaintainedCopy(repoRoot, former, base));
|
|
9682
|
+
}
|
|
9683
|
+
function createNodeAgentFs() {
|
|
9684
|
+
return {
|
|
9685
|
+
kind(path) {
|
|
9686
|
+
try {
|
|
9687
|
+
const stat = lstatSync(path);
|
|
9688
|
+
if (stat.isSymbolicLink()) return "link";
|
|
9689
|
+
if (stat.isDirectory()) return "directory";
|
|
9690
|
+
return stat.isFile() ? "file" : "missing";
|
|
9691
|
+
} catch {
|
|
9692
|
+
return "missing";
|
|
9693
|
+
}
|
|
9694
|
+
},
|
|
9695
|
+
stat(path) {
|
|
9696
|
+
try {
|
|
9697
|
+
const stat = statSync(path);
|
|
9698
|
+
return { kind: stat.isDirectory() ? "directory" : stat.isFile() ? "file" : "missing", size: stat.size, mtimeMs: stat.mtimeMs };
|
|
9699
|
+
} catch {
|
|
9700
|
+
return { kind: "missing", size: 0, mtimeMs: 0 };
|
|
9701
|
+
}
|
|
9702
|
+
},
|
|
9703
|
+
executable(path) {
|
|
9704
|
+
if (process.platform === "win32") return statSync(path, { throwIfNoEntry: false }) !== void 0;
|
|
9705
|
+
try {
|
|
9706
|
+
accessSync(path, constants.X_OK);
|
|
9707
|
+
return true;
|
|
9708
|
+
} catch {
|
|
9709
|
+
return false;
|
|
9710
|
+
}
|
|
9711
|
+
},
|
|
9712
|
+
readText(path) {
|
|
9713
|
+
let content;
|
|
9714
|
+
try {
|
|
9715
|
+
content = readFileSync(path);
|
|
9716
|
+
} catch (err) {
|
|
9717
|
+
const code = err.code;
|
|
9718
|
+
if (code === "ENOENT" || code === "ENOTDIR") return void 0;
|
|
9719
|
+
throw err;
|
|
9720
|
+
}
|
|
9721
|
+
return content.includes(0) ? void 0 : content.toString("utf8");
|
|
9722
|
+
},
|
|
9723
|
+
write: (path, text) => writeFileSync(path, text),
|
|
9724
|
+
copy: (from, to) => copyFileSync(from, to),
|
|
9725
|
+
makeDir: (path) => void mkdirSync(path, { recursive: true }),
|
|
9726
|
+
list: (dir) => readdirSync(dir),
|
|
9727
|
+
link: (target, path) => symlinkSync(target, path),
|
|
9728
|
+
readLink: (path) => readlinkSync(path),
|
|
9729
|
+
realPath: (path) => realpathSync(path),
|
|
9730
|
+
rename: (from, to) => renameSync(from, to),
|
|
9731
|
+
remove: (path) => rmSync(path, { recursive: true, force: true })
|
|
9732
|
+
};
|
|
9733
|
+
}
|
|
9734
|
+
function createNodeAgentIO() {
|
|
9735
|
+
return {
|
|
9736
|
+
fs: createNodeAgentFs(),
|
|
9737
|
+
async run(program, args, options) {
|
|
9738
|
+
const { execFile } = await import('child_process');
|
|
9739
|
+
return new Promise((resolve) => {
|
|
9740
|
+
const child = execFile(program, [...args], { cwd: options?.cwd, env: options?.env === void 0 ? process.env : { ...process.env, ...options.env }, encoding: "utf8" }, (error, stdout, stderr) => {
|
|
9741
|
+
const code = error === null ? 0 : typeof error.code === "number" ? error.code : 1;
|
|
9742
|
+
resolve({ code, stdout, stderr });
|
|
9743
|
+
});
|
|
9744
|
+
if (options?.stdin !== void 0) child.stdin?.end(options.stdin);
|
|
9745
|
+
});
|
|
9746
|
+
},
|
|
9747
|
+
runSync(program, args, options) {
|
|
9748
|
+
try {
|
|
9749
|
+
const result = spawnSync(program, [...args], {
|
|
9750
|
+
env: options?.env ?? process.env,
|
|
9751
|
+
encoding: "utf8",
|
|
9752
|
+
...options?.timeoutMs === void 0 ? {} : { timeout: options.timeoutMs },
|
|
9753
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
9754
|
+
});
|
|
9755
|
+
return { code: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
9756
|
+
} catch {
|
|
9757
|
+
return { code: null, stdout: "", stderr: "" };
|
|
9758
|
+
}
|
|
9759
|
+
},
|
|
9760
|
+
home: () => homeFromEnv() || homedir(),
|
|
9761
|
+
env: () => ({ ...process.env }),
|
|
9762
|
+
now: () => /* @__PURE__ */ new Date()
|
|
9763
|
+
};
|
|
9764
|
+
}
|
|
9765
|
+
|
|
9766
|
+
// src/agents.ts
|
|
9767
|
+
var native;
|
|
9768
|
+
function defaultAgents() {
|
|
9769
|
+
native ??= Object.keys(NATIVE_AGENTS).map((id) => ({ descriptor: NATIVE_AGENTS[id], adapter: ADAPTER_FACTORIES[id](createNodeAgentIO()) }));
|
|
9770
|
+
return native;
|
|
9771
|
+
}
|
|
9772
|
+
function agentById(id, agents = defaultAgents()) {
|
|
9773
|
+
return agents.find((agent) => agent.descriptor.id === id);
|
|
9774
|
+
}
|
|
9775
|
+
function legacyAgent(agents = defaultAgents()) {
|
|
9776
|
+
const found = agentById(LEGACY_AGENT, agents);
|
|
9777
|
+
if (found === void 0) throw new Error(`the agent list has no ${LEGACY_AGENT} entry`);
|
|
9778
|
+
return found;
|
|
9779
|
+
}
|
|
9780
|
+
function contextAgents(agents = defaultAgents()) {
|
|
9781
|
+
return agents.flatMap((agent) => agent.adapter.context === void 0 ? [] : [{ descriptor: agent.descriptor, context: agent.adapter.context }]);
|
|
9782
|
+
}
|
|
9783
|
+
function legacySubcommand(agents = defaultAgents()) {
|
|
9784
|
+
return legacyAgent(agents).descriptor.legacy?.subcommand ?? LEGACY_AGENT;
|
|
9785
|
+
}
|
|
9786
|
+
function userSkillFolderIn(home, descriptor) {
|
|
9787
|
+
return join$1(home, descriptor.context.userSkillFolder.replace(/^~\//, ""));
|
|
9788
|
+
}
|
|
9789
|
+
function agentRootFolders(agents = defaultAgents()) {
|
|
9790
|
+
return [...new Set(contextAgents(agents).flatMap((agent) => agent.descriptor.context.repoSkillFolders.map((folder) => folder.split("/")[0])))];
|
|
9791
|
+
}
|
|
9792
|
+
function emitBuilders(agents = defaultAgents()) {
|
|
9793
|
+
return Object.fromEntries(contextAgents(agents).map((agent) => [agent.descriptor.id, agent.context.emit]));
|
|
9794
|
+
}
|
|
9795
|
+
function targetIds(agents = defaultAgents()) {
|
|
9796
|
+
return contextAgents(agents).map((agent) => agent.descriptor.id);
|
|
9797
|
+
}
|
|
9798
|
+
function skillBases(agents = defaultAgents()) {
|
|
9799
|
+
return [AGENTS_SKILLS_BASE, ...contextAgents(agents).flatMap((agent) => agent.descriptor.context.repoSkillFolders)];
|
|
9800
|
+
}
|
|
9801
|
+
|
|
9802
|
+
export { ADAPTER_FACTORIES, AGENTS_SKILLS_BASE, CONTEXT_PIN_FILENAME, FORMER_MAINTAINED_NAMES, HookTextError, MACHINE_SKILL_PATH, McpFileError, OUTERLAYER_SKILLS_BASE, TEMPLATE_SKILLS, agentById, agentRootFolders, classifyTree, contextAgents, createNodeAgentIO, defaultAgents, emitBuilders, emitTree, extractFacts, generatedHeaderSource, isMaintainedCopy, legacyAgent, legacySubcommand, loadMachineSkillFiles, loadMaintainedFiles, loadTemplateFiles, maintainedFilesForExistingSkills, namesCore, normalizePath, normalizeRepoName, orderSessions, parseOuterlayerConfig, parsePolicy, parseProofsConfig, resolvePackRoot, restoreSkillPaths, rewriteSkillPaths, sessionsToTimeline, skillBases, skillDir, splitRawFile, targetIds, userSkillFolderIn, writeMaintainedFiles };
|