@joshuafolkken/kit 1.872.0 → 1.879.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.
- package/.github/workflows/publish.yml +39 -2
- package/README.md +3 -3
- package/package.json +6 -2
- package/scripts/init/distributed-paths.ts +14 -11
- package/scripts/init/hook-command-bootstrap.ts +51 -0
- package/scripts/init/hook-command-rewrite.ts +9 -1
- package/scripts/init/init-logic.ts +2 -8
- package/templates/workflows/ci.yml +6 -2
- package/dist/hooks/chunk-25JL6FMS.js +0 -4970
- package/dist/hooks/chunk-2ANGT3XM.js +0 -375
- package/dist/hooks/chunk-2EI5GBSW.js +0 -42
- package/dist/hooks/chunk-2OT5XE2N.js +0 -5014
- package/dist/hooks/chunk-33ELOKEV.js +0 -910
- package/dist/hooks/chunk-33YRTKM7.js +0 -230
- package/dist/hooks/chunk-36JQU5NN.js +0 -77
- package/dist/hooks/chunk-3EJBTWVS.js +0 -1769
- package/dist/hooks/chunk-3FK5SFAC.js +0 -432
- package/dist/hooks/chunk-3PWPYDD2.js +0 -240
- package/dist/hooks/chunk-3TQU7TDH.js +0 -375
- package/dist/hooks/chunk-3TVLSFZ6.js +0 -432
- package/dist/hooks/chunk-3VXYCB4E.js +0 -77
- package/dist/hooks/chunk-44M6JXGV.js +0 -3398
- package/dist/hooks/chunk-46EEEHC3.js +0 -240
- package/dist/hooks/chunk-4A7UVP2P.js +0 -364
- package/dist/hooks/chunk-4LFQEZS4.js +0 -137
- package/dist/hooks/chunk-4OCX3V2T.js +0 -469
- package/dist/hooks/chunk-4OHA5DE7.js +0 -49
- package/dist/hooks/chunk-4PMDW3YD.js +0 -68
- package/dist/hooks/chunk-4QHBNAI4.js +0 -68
- package/dist/hooks/chunk-4SSB3FEE.js +0 -3273
- package/dist/hooks/chunk-5A2WQ2CQ.js +0 -5390
- package/dist/hooks/chunk-5EVA2JQB.js +0 -5390
- package/dist/hooks/chunk-5P7VF5VE.js +0 -3230
- package/dist/hooks/chunk-5QWJGGZP.js +0 -49
- package/dist/hooks/chunk-5U5EZYG6.js +0 -77
- package/dist/hooks/chunk-5VUUF3ZV.js +0 -240
- package/dist/hooks/chunk-5WA7UBT3.js +0 -374
- package/dist/hooks/chunk-6EBGRQ3Q.js +0 -301
- package/dist/hooks/chunk-6TVHWMD3.js +0 -432
- package/dist/hooks/chunk-6VAGLEMB.js +0 -68
- package/dist/hooks/chunk-75BTXKFJ.js +0 -3424
- package/dist/hooks/chunk-75RHN67S.js +0 -137
- package/dist/hooks/chunk-76KC3BDD.js +0 -3414
- package/dist/hooks/chunk-76SLS7CZ.js +0 -898
- package/dist/hooks/chunk-7DHZ4DWT.js +0 -5015
- package/dist/hooks/chunk-7INSJDGE.js +0 -458
- package/dist/hooks/chunk-7VJ4FTDX.js +0 -268
- package/dist/hooks/chunk-7XCYNHQK.js +0 -77
- package/dist/hooks/chunk-A5YJ3H7E.js +0 -375
- package/dist/hooks/chunk-AAEXXUUL.js +0 -268
- package/dist/hooks/chunk-ABVEVV2M.js +0 -432
- package/dist/hooks/chunk-ACN3YXFL.js +0 -68
- package/dist/hooks/chunk-AD3XE3QZ.js +0 -397
- package/dist/hooks/chunk-AENFZPZH.js +0 -230
- package/dist/hooks/chunk-AFKRFQ6W.js +0 -68
- package/dist/hooks/chunk-AHD5IPWI.js +0 -375
- package/dist/hooks/chunk-AMK5JGV7.js +0 -77
- package/dist/hooks/chunk-ARN7NCQI.js +0 -425
- package/dist/hooks/chunk-AUFY653N.js +0 -3425
- package/dist/hooks/chunk-AXQBNFEF.js +0 -375
- package/dist/hooks/chunk-AYC7R6U4.js +0 -3316
- package/dist/hooks/chunk-AYEA2FJ7.js +0 -5015
- package/dist/hooks/chunk-B4HPNY2I.js +0 -375
- package/dist/hooks/chunk-B57S3VWT.js +0 -922
- package/dist/hooks/chunk-BINZ3PLI.js +0 -364
- package/dist/hooks/chunk-BODUSXKK.js +0 -410
- package/dist/hooks/chunk-BQBAT2YK.js +0 -375
- package/dist/hooks/chunk-BUJEBW75.js +0 -391
- package/dist/hooks/chunk-BVNWORKA.js +0 -72
- package/dist/hooks/chunk-BWI47LQS.js +0 -5205
- package/dist/hooks/chunk-C25HRMJX.js +0 -137
- package/dist/hooks/chunk-CBFZNC74.js +0 -375
- package/dist/hooks/chunk-CECYXS4Y.js +0 -3424
- package/dist/hooks/chunk-CELGUP5F.js +0 -49
- package/dist/hooks/chunk-CMHANU3F.js +0 -3442
- package/dist/hooks/chunk-CMN372LI.js +0 -68
- package/dist/hooks/chunk-CPGZLMMK.js +0 -3299
- package/dist/hooks/chunk-CTQKXDC7.js +0 -268
- package/dist/hooks/chunk-CYAT4RIT.js +0 -68
- package/dist/hooks/chunk-CYTWYCH2.js +0 -5014
- package/dist/hooks/chunk-CZSOLRBA.js +0 -77
- package/dist/hooks/chunk-D2PIDYJR.js +0 -3438
- package/dist/hooks/chunk-DE57HI6T.js +0 -137
- package/dist/hooks/chunk-DGXDGAPG.js +0 -5306
- package/dist/hooks/chunk-DNYRSYQG.js +0 -5014
- package/dist/hooks/chunk-DTAXH2A2.js +0 -240
- package/dist/hooks/chunk-E2IZUWI5.js +0 -375
- package/dist/hooks/chunk-E4L2K2BL.js +0 -397
- package/dist/hooks/chunk-ECXVCCVD.js +0 -3079
- package/dist/hooks/chunk-EPHO443D.js +0 -68
- package/dist/hooks/chunk-EUFK2BI2.js +0 -375
- package/dist/hooks/chunk-EYCD5ZAV.js +0 -137
- package/dist/hooks/chunk-F2SDYJU4.js +0 -240
- package/dist/hooks/chunk-F4B5D5TF.js +0 -68
- package/dist/hooks/chunk-FGEO3NDX.js +0 -432
- package/dist/hooks/chunk-FJYI52RE.js +0 -137
- package/dist/hooks/chunk-FYTZHIY4.js +0 -3085
- package/dist/hooks/chunk-G7JL2A5K.js +0 -375
- package/dist/hooks/chunk-GA3ITDBW.js +0 -42
- package/dist/hooks/chunk-GDR4H4SV.js +0 -469
- package/dist/hooks/chunk-GFKDXPSM.js +0 -2855
- package/dist/hooks/chunk-GIMRTKFU.js +0 -566
- package/dist/hooks/chunk-GOPHRLGO.js +0 -240
- package/dist/hooks/chunk-GX4HO7SJ.js +0 -230
- package/dist/hooks/chunk-GZ6FUVIK.js +0 -566
- package/dist/hooks/chunk-H5HPY5M5.js +0 -2869
- package/dist/hooks/chunk-HCF3OGEE.js +0 -1829
- package/dist/hooks/chunk-HDEXAOUM.js +0 -469
- package/dist/hooks/chunk-HM2TY3TN.js +0 -469
- package/dist/hooks/chunk-HOA7NXA2.js +0 -55
- package/dist/hooks/chunk-HOFEWH6H.js +0 -240
- package/dist/hooks/chunk-HUUI6S5J.js +0 -2669
- package/dist/hooks/chunk-I4D3NVUD.js +0 -469
- package/dist/hooks/chunk-I4Q6WAJE.js +0 -68
- package/dist/hooks/chunk-IB6N4CR2.js +0 -432
- package/dist/hooks/chunk-IFLDYJMD.js +0 -469
- package/dist/hooks/chunk-IGU466YD.js +0 -77
- package/dist/hooks/chunk-IJCQUHKY.js +0 -375
- package/dist/hooks/chunk-IKUMBDJB.js +0 -230
- package/dist/hooks/chunk-IM3BDIBJ.js +0 -5005
- package/dist/hooks/chunk-IMYMAODK.js +0 -3431
- package/dist/hooks/chunk-IN2ZVGXA.js +0 -5005
- package/dist/hooks/chunk-ITVJ2MKQ.js +0 -18
- package/dist/hooks/chunk-J5RIJYTM.js +0 -2669
- package/dist/hooks/chunk-JFLMH4K5.js +0 -3460
- package/dist/hooks/chunk-JR25IFML.js +0 -77
- package/dist/hooks/chunk-JT5AUXFI.js +0 -432
- package/dist/hooks/chunk-JY5YVN6N.js +0 -3234
- package/dist/hooks/chunk-K5Q4ETVI.js +0 -391
- package/dist/hooks/chunk-K67V2F24.js +0 -137
- package/dist/hooks/chunk-KATZESEC.js +0 -3273
- package/dist/hooks/chunk-KFH4H7W7.js +0 -469
- package/dist/hooks/chunk-KMUEI6RX.js +0 -910
- package/dist/hooks/chunk-KMV4OY77.js +0 -3438
- package/dist/hooks/chunk-KQAZNWEY.js +0 -137
- package/dist/hooks/chunk-KZZR6JER.js +0 -5015
- package/dist/hooks/chunk-LAR6DREP.js +0 -77
- package/dist/hooks/chunk-LNCJWEZD.js +0 -5015
- package/dist/hooks/chunk-LRYD2GLM.js +0 -6
- package/dist/hooks/chunk-LXBKYHDV.js +0 -77
- package/dist/hooks/chunk-LYLKIUNE.js +0 -5024
- package/dist/hooks/chunk-LZKCFOVC.js +0 -432
- package/dist/hooks/chunk-M4FCIYRI.js +0 -77
- package/dist/hooks/chunk-M5M7327Q.js +0 -3425
- package/dist/hooks/chunk-MF72MHSX.js +0 -3455
- package/dist/hooks/chunk-MK56LKDO.js +0 -397
- package/dist/hooks/chunk-N3MJADY7.js +0 -240
- package/dist/hooks/chunk-NFQSUDBN.js +0 -458
- package/dist/hooks/chunk-NHREKY45.js +0 -137
- package/dist/hooks/chunk-NP5TTAAW.js +0 -375
- package/dist/hooks/chunk-NQTLTKTJ.js +0 -2993
- package/dist/hooks/chunk-NVRCZPBZ.js +0 -391
- package/dist/hooks/chunk-O46HMMLJ.js +0 -469
- package/dist/hooks/chunk-OFJGH2L4.js +0 -240
- package/dist/hooks/chunk-OLFMCZH5.js +0 -240
- package/dist/hooks/chunk-OMCZS46I.js +0 -49
- package/dist/hooks/chunk-OQZEZW5G.js +0 -469
- package/dist/hooks/chunk-P2MDAT2Y.js +0 -1897
- package/dist/hooks/chunk-P3M2JJIF.js +0 -68
- package/dist/hooks/chunk-PDVHQITQ.js +0 -3453
- package/dist/hooks/chunk-PNT2AMDH.js +0 -391
- package/dist/hooks/chunk-PR2LVSY6.js +0 -3445
- package/dist/hooks/chunk-PRR5R4JK.js +0 -137
- package/dist/hooks/chunk-PXT44QVN.js +0 -566
- package/dist/hooks/chunk-PZLWJLAP.js +0 -469
- package/dist/hooks/chunk-Q2FEAZJ2.js +0 -77
- package/dist/hooks/chunk-Q32WETDO.js +0 -3265
- package/dist/hooks/chunk-Q45DUBLE.js +0 -3600
- package/dist/hooks/chunk-Q7NZSWQ5.js +0 -240
- package/dist/hooks/chunk-QH2JNAMK.js +0 -3085
- package/dist/hooks/chunk-QPU5H2OS.js +0 -68
- package/dist/hooks/chunk-QRAHZ5TO.js +0 -1829
- package/dist/hooks/chunk-QUZ5HPIE.js +0 -469
- package/dist/hooks/chunk-QVCRG34O.js +0 -2893
- package/dist/hooks/chunk-R3MY4E3S.js +0 -1675
- package/dist/hooks/chunk-R6TXJJXP.js +0 -77
- package/dist/hooks/chunk-REJU6VT7.js +0 -1829
- package/dist/hooks/chunk-REQAQLRC.js +0 -2993
- package/dist/hooks/chunk-RFCXPAHH.js +0 -391
- package/dist/hooks/chunk-RHI6Y22X.js +0 -137
- package/dist/hooks/chunk-RKZVOBBS.js +0 -469
- package/dist/hooks/chunk-RL57TT2Y.js +0 -566
- package/dist/hooks/chunk-RORDOD4S.js +0 -3321
- package/dist/hooks/chunk-RZKYW5P2.js +0 -77
- package/dist/hooks/chunk-SJPJ6VSI.js +0 -391
- package/dist/hooks/chunk-SKSIJQQQ.js +0 -432
- package/dist/hooks/chunk-SSQDZKXG.js +0 -268
- package/dist/hooks/chunk-SYHFKE4C.js +0 -77
- package/dist/hooks/chunk-TCGNI2ZY.js +0 -42
- package/dist/hooks/chunk-TG3WXJF5.js +0 -137
- package/dist/hooks/chunk-TH7IJAY5.js +0 -77
- package/dist/hooks/chunk-TLZ27PCY.js +0 -240
- package/dist/hooks/chunk-U652FXTN.js +0 -566
- package/dist/hooks/chunk-UEK47YUF.js +0 -268
- package/dist/hooks/chunk-UIO45H3O.js +0 -432
- package/dist/hooks/chunk-UNLZEEVH.js +0 -5005
- package/dist/hooks/chunk-UNRVF3SZ.js +0 -432
- package/dist/hooks/chunk-USLFAFOI.js +0 -3453
- package/dist/hooks/chunk-VAEELMLL.js +0 -442
- package/dist/hooks/chunk-VALSWLDQ.js +0 -3453
- package/dist/hooks/chunk-VC5JEPNY.js +0 -3398
- package/dist/hooks/chunk-VEZVK6C7.js +0 -230
- package/dist/hooks/chunk-VK5JKFAR.js +0 -49
- package/dist/hooks/chunk-VNF2KP7Z.js +0 -469
- package/dist/hooks/chunk-VWWCUMW6.js +0 -2669
- package/dist/hooks/chunk-W4JARUQV.js +0 -137
- package/dist/hooks/chunk-WEOBMNJG.js +0 -2993
- package/dist/hooks/chunk-WKJU3J5Y.js +0 -5390
- package/dist/hooks/chunk-WMN4TSVF.js +0 -3299
- package/dist/hooks/chunk-WNON54PT.js +0 -3469
- package/dist/hooks/chunk-WOVKBPPX.js +0 -137
- package/dist/hooks/chunk-WRVFORYJ.js +0 -432
- package/dist/hooks/chunk-WUBVYGQZ.js +0 -240
- package/dist/hooks/chunk-WWULTUOM.js +0 -68
- package/dist/hooks/chunk-WXHKKB45.js +0 -4962
- package/dist/hooks/chunk-XAI3YTHJ.js +0 -469
- package/dist/hooks/chunk-XFZH6JZJ.js +0 -77
- package/dist/hooks/chunk-XGPWX6IA.js +0 -137
- package/dist/hooks/chunk-XIXXIVGY.js +0 -566
- package/dist/hooks/chunk-XKDOYJGA.js +0 -922
- package/dist/hooks/chunk-YALTVBHM.js +0 -432
- package/dist/hooks/chunk-YEBEPBFK.js +0 -5014
- package/dist/hooks/chunk-YI2BQ3DK.js +0 -3441
- package/dist/hooks/chunk-YVNBCFGG.js +0 -1829
- package/dist/hooks/chunk-YXBN3RGG.js +0 -432
- package/dist/hooks/chunk-Z2OOJSW3.js +0 -3163
- package/dist/hooks/chunk-ZA3HVBOY.js +0 -2644
- package/dist/hooks/chunk-ZKID46U3.js +0 -137
- package/dist/hooks/chunk-ZPMU2JV6.js +0 -49
- package/dist/hooks/chunk-ZRKY4W7O.js +0 -432
- package/dist/hooks/chunk-ZTMRB7LJ.js +0 -268
- package/dist/hooks/chunk-ZVPPBQ3L.js +0 -3413
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
lane_paths,
|
|
3
|
-
stamp_file,
|
|
4
|
-
time_density_hook,
|
|
5
|
-
time_hook_transcript
|
|
6
|
-
} from "./chunk-5P7VF5VE.js";
|
|
7
|
-
import {
|
|
8
|
-
josh_environment_file
|
|
9
|
-
} from "./chunk-ITVJ2MKQ.js";
|
|
10
|
-
|
|
11
|
-
// scripts/josh/hook-decision.ts
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
var payload_schema = z.object({
|
|
14
|
-
transcript_path: z.string().min(1),
|
|
15
|
-
// **`nullish`, not `optional`.** A payload spelling the absent agent as `null` has to read as "no
|
|
16
|
-
// fork"; rejected, it would fail `safeParse` for the whole payload and take the guard off every
|
|
17
|
-
// call of the main line, in silence — the failure every other path here is written to avoid.
|
|
18
|
-
agent_id: z.string().nullish(),
|
|
19
|
-
tool_name: z.string().min(1),
|
|
20
|
-
tool_input: z.unknown()
|
|
21
|
-
});
|
|
22
|
-
var refusal_schema = z.object({ refused_at_ms: z.number() });
|
|
23
|
-
var HOOK_EVENT_NAME = "PreToolUse";
|
|
24
|
-
var DENY_DECISION = "deny";
|
|
25
|
-
var NEVER_MS = 0;
|
|
26
|
-
var MISSING_FILE = "ENOENT";
|
|
27
|
-
var DISABLED_VALUES = ["off", "0", "false", "no"];
|
|
28
|
-
function is_switch_enabled(key) {
|
|
29
|
-
return !DISABLED_VALUES.includes((process.env[key] ?? "").trim().toLowerCase());
|
|
30
|
-
}
|
|
31
|
-
function parse_hook_payload(raw_payload) {
|
|
32
|
-
const parsed = payload_schema.safeParse(JSON.parse(raw_payload));
|
|
33
|
-
return parsed.success ? parsed.data : void 0;
|
|
34
|
-
}
|
|
35
|
-
function deny_envelope(reason) {
|
|
36
|
-
return JSON.stringify({
|
|
37
|
-
hookSpecificOutput: {
|
|
38
|
-
hookEventName: HOOK_EVENT_NAME,
|
|
39
|
-
permissionDecision: DENY_DECISION,
|
|
40
|
-
permissionDecisionReason: reason
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function notice_envelope(notice) {
|
|
45
|
-
return JSON.stringify({
|
|
46
|
-
systemMessage: notice,
|
|
47
|
-
hookSpecificOutput: { hookEventName: HOOK_EVENT_NAME, additionalContext: notice }
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function stamp_fault(switch_key) {
|
|
51
|
-
return `\u26A0 ${switch_key}: the run is past the limit but the refusal stamp could not be written, so this call was allowed rather than refused. Without the stamp a refusal could repeat and wedge the run. Batch the calls that do not need each other anyway, and check the temp directory is writable.`;
|
|
52
|
-
}
|
|
53
|
-
function is_missing_file(error) {
|
|
54
|
-
if (!(error instanceof Error) || !("code" in error)) return false;
|
|
55
|
-
return typeof error.code === "string" && error.code === MISSING_FILE;
|
|
56
|
-
}
|
|
57
|
-
function error_text(error) {
|
|
58
|
-
if (error instanceof Error) return error.message;
|
|
59
|
-
return typeof error === "string" ? error : "a value that is not an error";
|
|
60
|
-
}
|
|
61
|
-
function fault_notice(switch_key, error) {
|
|
62
|
-
if (is_missing_file(error)) return void 0;
|
|
63
|
-
const detail = error_text(error);
|
|
64
|
-
return `\u26A0 ${switch_key}: the guard could not read the run's history, so this call was allowed without being checked \u2014 silence here is not evidence that the run is batching. Cause: ${detail}`;
|
|
65
|
-
}
|
|
66
|
-
function last_refusal_ms(target) {
|
|
67
|
-
const raw = stamp_file.read_stamp_text(target);
|
|
68
|
-
if (raw === void 0) return NEVER_MS;
|
|
69
|
-
try {
|
|
70
|
-
return refusal_schema.parse(JSON.parse(raw)).refused_at_ms;
|
|
71
|
-
} catch {
|
|
72
|
-
return NEVER_MS;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function record_refusal(target, now_ms) {
|
|
76
|
-
try {
|
|
77
|
-
stamp_file.write_stamp(target, { refused_at_ms: now_ms });
|
|
78
|
-
return true;
|
|
79
|
-
} catch {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function create_refusal_stamp(prefix) {
|
|
84
|
-
function path(transcript_path) {
|
|
85
|
-
return stamp_file.stamp_path(prefix, transcript_path);
|
|
86
|
-
}
|
|
87
|
-
return { path, last_ms: last_refusal_ms, record: record_refusal };
|
|
88
|
-
}
|
|
89
|
-
var { load_environment_file } = josh_environment_file;
|
|
90
|
-
var NO_OUTCOME = { reason: void 0, notice: void 0, fault: void 0 };
|
|
91
|
-
function fire_once(stamp, run, should_fire, switch_key) {
|
|
92
|
-
const target = stamp.path(run.transcript);
|
|
93
|
-
if (!should_fire(stamp.last_ms(target))) return { fired: false, fault: void 0 };
|
|
94
|
-
if (!stamp.record(target, run.now_ms)) return { fired: false, fault: stamp_fault(switch_key) };
|
|
95
|
-
return { fired: true, fault: void 0 };
|
|
96
|
-
}
|
|
97
|
-
function block_outcome(context) {
|
|
98
|
-
const { spec, stamp, tail, call, run } = context;
|
|
99
|
-
const result = fire_once(
|
|
100
|
-
stamp,
|
|
101
|
-
run,
|
|
102
|
-
(last_fired_ms) => spec.should_block(tail, call, last_fired_ms, run),
|
|
103
|
-
spec.switch_key
|
|
104
|
-
);
|
|
105
|
-
if (result.fired) return { reason: spec.reason, notice: void 0, fault: void 0 };
|
|
106
|
-
return { reason: void 0, notice: void 0, fault: result.fault };
|
|
107
|
-
}
|
|
108
|
-
function notify_outcome(context) {
|
|
109
|
-
const { spec, notify_stamp, tail, call, run } = context;
|
|
110
|
-
if (notify_stamp === void 0 || spec.notify === void 0) return NO_OUTCOME;
|
|
111
|
-
const { notify } = spec;
|
|
112
|
-
const result = fire_once(
|
|
113
|
-
notify_stamp,
|
|
114
|
-
run,
|
|
115
|
-
(last_fired_ms) => notify.should_notify(tail, call, last_fired_ms, run),
|
|
116
|
-
spec.switch_key
|
|
117
|
-
);
|
|
118
|
-
if (result.fired) return { reason: void 0, notice: notify.text(call), fault: void 0 };
|
|
119
|
-
return { reason: void 0, notice: void 0, fault: result.fault };
|
|
120
|
-
}
|
|
121
|
-
function is_clear(outcome) {
|
|
122
|
-
return outcome.reason === void 0 && outcome.notice === void 0 && outcome.fault === void 0;
|
|
123
|
-
}
|
|
124
|
-
function guard_reason_for_payload(parts, payload, now_ms) {
|
|
125
|
-
const call = { name: payload.tool_name, input: payload.tool_input };
|
|
126
|
-
if (!parts.spec.is_candidate(call)) return NO_OUTCOME;
|
|
127
|
-
const transcript = time_hook_transcript.transcript_of(payload.transcript_path, payload.agent_id);
|
|
128
|
-
const tail = time_density_hook.read_tail(transcript);
|
|
129
|
-
const context = { ...parts, tail, call, run: { transcript, now_ms } };
|
|
130
|
-
const blocked = block_outcome(context);
|
|
131
|
-
if (!is_clear(blocked)) return blocked;
|
|
132
|
-
return notify_outcome(context);
|
|
133
|
-
}
|
|
134
|
-
function guard_outcome(parts, raw_payload, now_ms) {
|
|
135
|
-
const payload = parse_hook_payload(raw_payload);
|
|
136
|
-
if (payload === void 0 || !is_switch_enabled(parts.spec.switch_key)) return NO_OUTCOME;
|
|
137
|
-
return guard_reason_for_payload(parts, payload, now_ms);
|
|
138
|
-
}
|
|
139
|
-
function create_transcript_guard(spec) {
|
|
140
|
-
const stamp = create_refusal_stamp(spec.prefix);
|
|
141
|
-
const notify_stamp = spec.notify ? create_refusal_stamp(spec.notify.prefix) : void 0;
|
|
142
|
-
const parts = { spec, stamp, notify_stamp };
|
|
143
|
-
function is_enabled() {
|
|
144
|
-
return is_switch_enabled(spec.switch_key);
|
|
145
|
-
}
|
|
146
|
-
function refusal_path(transcript_path) {
|
|
147
|
-
return stamp.path(transcript_path);
|
|
148
|
-
}
|
|
149
|
-
function outcome(raw_payload, now_ms = Date.now()) {
|
|
150
|
-
try {
|
|
151
|
-
return guard_outcome(parts, raw_payload, now_ms);
|
|
152
|
-
} catch (error) {
|
|
153
|
-
return { reason: void 0, notice: void 0, fault: fault_notice(spec.switch_key, error) };
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function refusal(raw_payload, now_ms = Date.now()) {
|
|
157
|
-
return outcome(raw_payload, now_ms).reason;
|
|
158
|
-
}
|
|
159
|
-
return { is_enabled, outcome, refusal, refusal_path };
|
|
160
|
-
}
|
|
161
|
-
function write_outcome(raw_payload, outcome) {
|
|
162
|
-
load_environment_file();
|
|
163
|
-
const { reason, notice, fault } = outcome(raw_payload);
|
|
164
|
-
if (reason !== void 0) process.stdout.write(`${deny_envelope(reason)}
|
|
165
|
-
`);
|
|
166
|
-
else if (notice !== void 0) process.stdout.write(`${notice_envelope(notice)}
|
|
167
|
-
`);
|
|
168
|
-
else if (fault !== void 0) process.stdout.write(`${notice_envelope(fault)}
|
|
169
|
-
`);
|
|
170
|
-
}
|
|
171
|
-
function write_decision(raw_payload, refusal) {
|
|
172
|
-
write_outcome(raw_payload, (raw) => ({
|
|
173
|
-
reason: refusal(raw),
|
|
174
|
-
notice: void 0,
|
|
175
|
-
fault: void 0
|
|
176
|
-
}));
|
|
177
|
-
}
|
|
178
|
-
function report_no_payload(command) {
|
|
179
|
-
process.stderr.write(
|
|
180
|
-
`${command} reads a Claude Code hook payload on stdin; it is not run by hand.
|
|
181
|
-
`
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
var hook_decision = {
|
|
185
|
-
DISABLED_VALUES,
|
|
186
|
-
NEVER_MS,
|
|
187
|
-
create_refusal_stamp,
|
|
188
|
-
create_transcript_guard,
|
|
189
|
-
deny_envelope,
|
|
190
|
-
fault_notice,
|
|
191
|
-
is_switch_enabled,
|
|
192
|
-
load_environment_file,
|
|
193
|
-
notice_envelope,
|
|
194
|
-
parse_hook_payload,
|
|
195
|
-
report_no_payload,
|
|
196
|
-
stamp_fault,
|
|
197
|
-
write_decision,
|
|
198
|
-
write_outcome
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
// scripts/run/run-issue-number.ts
|
|
202
|
-
var ISSUE_NUMBER_PATTERN = /^[1-9]\d*$/u;
|
|
203
|
-
var BAD_ISSUE_MESSAGE = "Not an issue number: ";
|
|
204
|
-
function require_issue_number(issue) {
|
|
205
|
-
if (!ISSUE_NUMBER_PATTERN.test(issue)) throw new Error(`${BAD_ISSUE_MESSAGE}${issue}`);
|
|
206
|
-
}
|
|
207
|
-
var run_issue_number = { BAD_ISSUE_MESSAGE, ISSUE_NUMBER_PATTERN, require_issue_number };
|
|
208
|
-
|
|
209
|
-
// scripts/lane/lane-child-marker.ts
|
|
210
|
-
var KEY = "JOSH_LANE_CHILD";
|
|
211
|
-
function environment_for(issue) {
|
|
212
|
-
run_issue_number.require_issue_number(issue);
|
|
213
|
-
return { [KEY]: issue };
|
|
214
|
-
}
|
|
215
|
-
function marked_issue(source = process.env) {
|
|
216
|
-
const value = source[KEY];
|
|
217
|
-
if (value === void 0) return void 0;
|
|
218
|
-
return run_issue_number.ISSUE_NUMBER_PATTERN.test(value) ? value : void 0;
|
|
219
|
-
}
|
|
220
|
-
function is_child_of(directory, source = process.env) {
|
|
221
|
-
const marked = marked_issue(source);
|
|
222
|
-
return marked !== void 0 && marked === lane_paths.lane_issue_of(directory, { ...source });
|
|
223
|
-
}
|
|
224
|
-
var lane_child_marker = { KEY, env_for: environment_for, is_child_of, marked_issue };
|
|
225
|
-
|
|
226
|
-
export {
|
|
227
|
-
hook_decision,
|
|
228
|
-
run_issue_number,
|
|
229
|
-
lane_child_marker
|
|
230
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hook_decision,
|
|
3
|
-
time_batch_guard
|
|
4
|
-
} from "./chunk-U652FXTN.js";
|
|
5
|
-
|
|
6
|
-
// scripts/hooks/batch-guard.ts
|
|
7
|
-
import { text } from "node:stream/consumers";
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
9
|
-
var SWITCH_ENV_KEY = "JOSH_BATCH_GUARD";
|
|
10
|
-
function is_batch_candidate(call) {
|
|
11
|
-
return time_batch_guard.is_guarded_call(call) || time_batch_guard.is_notice_call(call);
|
|
12
|
-
}
|
|
13
|
-
var GUARD = hook_decision.create_transcript_guard({
|
|
14
|
-
prefix: time_batch_guard.STAMP_PREFIX,
|
|
15
|
-
switch_key: SWITCH_ENV_KEY,
|
|
16
|
-
is_candidate: is_batch_candidate,
|
|
17
|
-
should_block: time_batch_guard.should_block,
|
|
18
|
-
reason: time_batch_guard.REASON,
|
|
19
|
-
// The whole-file write is notified rather than refused, on a record of its own so it never spends
|
|
20
|
-
// the refusal's stamp (joshuafolkken/kit#1848).
|
|
21
|
-
notify: {
|
|
22
|
-
prefix: time_batch_guard.NOTICE_STAMP_PREFIX,
|
|
23
|
-
should_notify: time_batch_guard.should_notify,
|
|
24
|
-
text: time_batch_guard.NOTICE
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
var batch_refusal = GUARD.refusal;
|
|
28
|
-
var batch_outcome = GUARD.outcome;
|
|
29
|
-
var { is_enabled, refusal_path } = GUARD;
|
|
30
|
-
var notice_refusal_path = hook_decision.create_refusal_stamp(
|
|
31
|
-
time_batch_guard.NOTICE_STAMP_PREFIX
|
|
32
|
-
).path;
|
|
33
|
-
var { deny_envelope, load_environment_file, DISABLED_VALUES } = hook_decision;
|
|
34
|
-
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
35
|
-
if (process.stdin.isTTY) hook_decision.report_no_payload("batch:guard");
|
|
36
|
-
else hook_decision.write_outcome(await text(process.stdin), batch_outcome);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
SWITCH_ENV_KEY,
|
|
41
|
-
batch_refusal,
|
|
42
|
-
batch_outcome,
|
|
43
|
-
is_enabled,
|
|
44
|
-
refusal_path,
|
|
45
|
-
notice_refusal_path,
|
|
46
|
-
deny_envelope,
|
|
47
|
-
load_environment_file,
|
|
48
|
-
DISABLED_VALUES
|
|
49
|
-
};
|