@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,240 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
lane_paths,
|
|
3
|
-
stamp_file,
|
|
4
|
-
time_density_hook,
|
|
5
|
-
time_hook_transcript
|
|
6
|
-
} from "./chunk-75BTXKFJ.js";
|
|
7
|
-
import {
|
|
8
|
-
josh_environment_file
|
|
9
|
-
} from "./chunk-FXAKJKTB.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
|
-
var ENABLED_VALUES = ["on", "1", "true", "yes"];
|
|
32
|
-
function is_switch_opt_in(key) {
|
|
33
|
-
return ENABLED_VALUES.includes((process.env[key] ?? "").trim().toLowerCase());
|
|
34
|
-
}
|
|
35
|
-
function parse_hook_payload(raw_payload) {
|
|
36
|
-
const parsed = payload_schema.safeParse(JSON.parse(raw_payload));
|
|
37
|
-
return parsed.success ? parsed.data : void 0;
|
|
38
|
-
}
|
|
39
|
-
function deny_envelope(reason) {
|
|
40
|
-
return JSON.stringify({
|
|
41
|
-
hookSpecificOutput: {
|
|
42
|
-
hookEventName: HOOK_EVENT_NAME,
|
|
43
|
-
permissionDecision: DENY_DECISION,
|
|
44
|
-
permissionDecisionReason: reason
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function notice_envelope(notice) {
|
|
49
|
-
return JSON.stringify({
|
|
50
|
-
systemMessage: notice,
|
|
51
|
-
hookSpecificOutput: { hookEventName: HOOK_EVENT_NAME, additionalContext: notice }
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function stamp_fault(switch_key) {
|
|
55
|
-
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.`;
|
|
56
|
-
}
|
|
57
|
-
function is_missing_file(error) {
|
|
58
|
-
if (!(error instanceof Error) || !("code" in error)) return false;
|
|
59
|
-
return typeof error.code === "string" && error.code === MISSING_FILE;
|
|
60
|
-
}
|
|
61
|
-
function error_text(error) {
|
|
62
|
-
if (error instanceof Error) return error.message;
|
|
63
|
-
return typeof error === "string" ? error : "a value that is not an error";
|
|
64
|
-
}
|
|
65
|
-
function fault_notice(switch_key, error) {
|
|
66
|
-
if (is_missing_file(error)) return void 0;
|
|
67
|
-
const detail = error_text(error);
|
|
68
|
-
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}`;
|
|
69
|
-
}
|
|
70
|
-
function last_refusal_ms(target) {
|
|
71
|
-
const raw = stamp_file.read_stamp_text(target);
|
|
72
|
-
if (raw === void 0) return NEVER_MS;
|
|
73
|
-
try {
|
|
74
|
-
return refusal_schema.parse(JSON.parse(raw)).refused_at_ms;
|
|
75
|
-
} catch {
|
|
76
|
-
return NEVER_MS;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function record_refusal(target, now_ms) {
|
|
80
|
-
try {
|
|
81
|
-
stamp_file.write_stamp(target, { refused_at_ms: now_ms });
|
|
82
|
-
return true;
|
|
83
|
-
} catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function create_refusal_stamp(prefix) {
|
|
88
|
-
function path(transcript_path) {
|
|
89
|
-
return stamp_file.stamp_path(prefix, transcript_path);
|
|
90
|
-
}
|
|
91
|
-
return { path, last_ms: last_refusal_ms, record: record_refusal };
|
|
92
|
-
}
|
|
93
|
-
var { load_environment_file } = josh_environment_file;
|
|
94
|
-
var NO_OUTCOME = { reason: void 0, notice: void 0, fault: void 0 };
|
|
95
|
-
function fire_once(stamp, run, should_fire, switch_key) {
|
|
96
|
-
const target = stamp.path(run.transcript);
|
|
97
|
-
if (!should_fire(stamp.last_ms(target))) return { fired: false, fault: void 0 };
|
|
98
|
-
if (!stamp.record(target, run.now_ms)) return { fired: false, fault: stamp_fault(switch_key) };
|
|
99
|
-
return { fired: true, fault: void 0 };
|
|
100
|
-
}
|
|
101
|
-
function block_outcome(context) {
|
|
102
|
-
const { spec, stamp, tail, call, run } = context;
|
|
103
|
-
const result = fire_once(
|
|
104
|
-
stamp,
|
|
105
|
-
run,
|
|
106
|
-
(last_fired_ms) => spec.should_block(tail, call, last_fired_ms, run),
|
|
107
|
-
spec.switch_key
|
|
108
|
-
);
|
|
109
|
-
if (result.fired) return { reason: spec.reason, notice: void 0, fault: void 0 };
|
|
110
|
-
return { reason: void 0, notice: void 0, fault: result.fault };
|
|
111
|
-
}
|
|
112
|
-
function notify_outcome(context) {
|
|
113
|
-
const { spec, notify_stamp, tail, call, run } = context;
|
|
114
|
-
if (notify_stamp === void 0 || spec.notify === void 0) return NO_OUTCOME;
|
|
115
|
-
const { notify } = spec;
|
|
116
|
-
const result = fire_once(
|
|
117
|
-
notify_stamp,
|
|
118
|
-
run,
|
|
119
|
-
(last_fired_ms) => notify.should_notify(tail, call, last_fired_ms, run),
|
|
120
|
-
spec.switch_key
|
|
121
|
-
);
|
|
122
|
-
if (result.fired) return { reason: void 0, notice: notify.text(call, tail), fault: void 0 };
|
|
123
|
-
return { reason: void 0, notice: void 0, fault: result.fault };
|
|
124
|
-
}
|
|
125
|
-
function is_clear(outcome) {
|
|
126
|
-
return outcome.reason === void 0 && outcome.notice === void 0 && outcome.fault === void 0;
|
|
127
|
-
}
|
|
128
|
-
function guard_reason_for_payload(parts, payload, now_ms) {
|
|
129
|
-
const call = { name: payload.tool_name, input: payload.tool_input };
|
|
130
|
-
if (!parts.spec.is_candidate(call)) return NO_OUTCOME;
|
|
131
|
-
const transcript = time_hook_transcript.transcript_of(payload.transcript_path, payload.agent_id);
|
|
132
|
-
const tail = time_density_hook.read_tail(transcript);
|
|
133
|
-
const context = { ...parts, tail, call, run: { transcript, now_ms } };
|
|
134
|
-
const blocked = block_outcome(context);
|
|
135
|
-
if (!is_clear(blocked)) return blocked;
|
|
136
|
-
return notify_outcome(context);
|
|
137
|
-
}
|
|
138
|
-
function guard_outcome(parts, raw_payload, now_ms) {
|
|
139
|
-
const payload = parse_hook_payload(raw_payload);
|
|
140
|
-
if (payload === void 0 || !is_switch_enabled(parts.spec.switch_key)) return NO_OUTCOME;
|
|
141
|
-
return guard_reason_for_payload(parts, payload, now_ms);
|
|
142
|
-
}
|
|
143
|
-
function create_transcript_guard(spec) {
|
|
144
|
-
const stamp = create_refusal_stamp(spec.prefix);
|
|
145
|
-
const notify_stamp = spec.notify ? create_refusal_stamp(spec.notify.prefix) : void 0;
|
|
146
|
-
const parts = { spec, stamp, notify_stamp };
|
|
147
|
-
function is_enabled() {
|
|
148
|
-
return is_switch_enabled(spec.switch_key);
|
|
149
|
-
}
|
|
150
|
-
function refusal_path(transcript_path) {
|
|
151
|
-
return stamp.path(transcript_path);
|
|
152
|
-
}
|
|
153
|
-
function outcome(raw_payload, now_ms = Date.now()) {
|
|
154
|
-
try {
|
|
155
|
-
return guard_outcome(parts, raw_payload, now_ms);
|
|
156
|
-
} catch (error) {
|
|
157
|
-
return { reason: void 0, notice: void 0, fault: fault_notice(spec.switch_key, error) };
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function refusal(raw_payload, now_ms = Date.now()) {
|
|
161
|
-
return outcome(raw_payload, now_ms).reason;
|
|
162
|
-
}
|
|
163
|
-
return { is_enabled, outcome, refusal, refusal_path };
|
|
164
|
-
}
|
|
165
|
-
function emit_outcome(outcome) {
|
|
166
|
-
const { reason, notice, fault } = outcome;
|
|
167
|
-
if (reason !== void 0) process.stdout.write(`${deny_envelope(reason)}
|
|
168
|
-
`);
|
|
169
|
-
else if (notice !== void 0) process.stdout.write(`${notice_envelope(notice)}
|
|
170
|
-
`);
|
|
171
|
-
else if (fault !== void 0) process.stdout.write(`${notice_envelope(fault)}
|
|
172
|
-
`);
|
|
173
|
-
}
|
|
174
|
-
function write_outcome(raw_payload, outcome) {
|
|
175
|
-
load_environment_file();
|
|
176
|
-
emit_outcome(outcome(raw_payload));
|
|
177
|
-
}
|
|
178
|
-
function write_decision(raw_payload, refusal) {
|
|
179
|
-
write_outcome(raw_payload, (raw) => ({
|
|
180
|
-
reason: refusal(raw),
|
|
181
|
-
notice: void 0,
|
|
182
|
-
fault: void 0
|
|
183
|
-
}));
|
|
184
|
-
}
|
|
185
|
-
function report_no_payload(command) {
|
|
186
|
-
process.stderr.write(
|
|
187
|
-
`${command} reads a Claude Code hook payload on stdin; it is not run by hand.
|
|
188
|
-
`
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
var hook_decision = {
|
|
192
|
-
DISABLED_VALUES,
|
|
193
|
-
ENABLED_VALUES,
|
|
194
|
-
NEVER_MS,
|
|
195
|
-
create_refusal_stamp,
|
|
196
|
-
create_transcript_guard,
|
|
197
|
-
deny_envelope,
|
|
198
|
-
emit_outcome,
|
|
199
|
-
fault_notice,
|
|
200
|
-
is_switch_enabled,
|
|
201
|
-
is_switch_opt_in,
|
|
202
|
-
load_environment_file,
|
|
203
|
-
notice_envelope,
|
|
204
|
-
parse_hook_payload,
|
|
205
|
-
report_no_payload,
|
|
206
|
-
stamp_fault,
|
|
207
|
-
write_decision,
|
|
208
|
-
write_outcome
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
// scripts/run/run-issue-number.ts
|
|
212
|
-
var ISSUE_NUMBER_PATTERN = /^[1-9]\d*$/u;
|
|
213
|
-
var BAD_ISSUE_MESSAGE = "Not an issue number: ";
|
|
214
|
-
function require_issue_number(issue) {
|
|
215
|
-
if (!ISSUE_NUMBER_PATTERN.test(issue)) throw new Error(`${BAD_ISSUE_MESSAGE}${issue}`);
|
|
216
|
-
}
|
|
217
|
-
var run_issue_number = { BAD_ISSUE_MESSAGE, ISSUE_NUMBER_PATTERN, require_issue_number };
|
|
218
|
-
|
|
219
|
-
// scripts/lane/lane-child-marker.ts
|
|
220
|
-
var KEY = "JOSH_LANE_CHILD";
|
|
221
|
-
function environment_for(issue) {
|
|
222
|
-
run_issue_number.require_issue_number(issue);
|
|
223
|
-
return { [KEY]: issue };
|
|
224
|
-
}
|
|
225
|
-
function marked_issue(source = process.env) {
|
|
226
|
-
const value = source[KEY];
|
|
227
|
-
if (value === void 0) return void 0;
|
|
228
|
-
return run_issue_number.ISSUE_NUMBER_PATTERN.test(value) ? value : void 0;
|
|
229
|
-
}
|
|
230
|
-
function is_child_of(directory, source = process.env) {
|
|
231
|
-
const marked = marked_issue(source);
|
|
232
|
-
return marked !== void 0 && marked === lane_paths.lane_issue_of(directory, { ...source });
|
|
233
|
-
}
|
|
234
|
-
var lane_child_marker = { KEY, env_for: environment_for, is_child_of, marked_issue };
|
|
235
|
-
|
|
236
|
-
export {
|
|
237
|
-
hook_decision,
|
|
238
|
-
run_issue_number,
|
|
239
|
-
lane_child_marker
|
|
240
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
investigation_reads
|
|
3
|
-
} from "./chunk-BQBAT2YK.js";
|
|
4
|
-
import {
|
|
5
|
-
lane_guard_policy
|
|
6
|
-
} from "./chunk-4OCX3V2T.js";
|
|
7
|
-
import {
|
|
8
|
-
hook_decision
|
|
9
|
-
} from "./chunk-OFJGH2L4.js";
|
|
10
|
-
|
|
11
|
-
// scripts/delegation/investigation-guard.ts
|
|
12
|
-
import { text } from "node:stream/consumers";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
|
-
var SWITCH_ENV_KEY = "JOSH_INVESTIGATION_GUARD";
|
|
15
|
-
var STAMP_PREFIX = "josh-investigation-guard-";
|
|
16
|
-
var NOTICE_STAMP_PREFIX = "josh-investigation-guard-notice-";
|
|
17
|
-
function investigation_mode() {
|
|
18
|
-
return lane_guard_policy.mode_here("investigation");
|
|
19
|
-
}
|
|
20
|
-
function should_block(tail, call, refused_at_ms, run) {
|
|
21
|
-
if (investigation_mode() !== "refuse") return false;
|
|
22
|
-
return investigation_reads.should_block(tail, call, refused_at_ms, run);
|
|
23
|
-
}
|
|
24
|
-
function should_notify(tail, call, notified_at_ms, run) {
|
|
25
|
-
if (investigation_mode() !== "notice") return false;
|
|
26
|
-
return investigation_reads.should_block(tail, call, notified_at_ms, run);
|
|
27
|
-
}
|
|
28
|
-
var NOTICE = `\u{1F4A1} investigation: files read and not edited since the last delegated unit reached the threshold, so the reading from here should go to a unit of its own. This is a notice, not a refusal \u2014 the read proceeds, because a dispatched lane child ends its turn on a denial. Ask \`pnpm josh delegate investigation\`, then brief a unit with what the main line has already concluded and what is left to find out; it returns the conclusion plus its \`file:line\` citations, never the file text. Keep a read in the main line only where this run will edit that file. This recurs on the next accumulation.`;
|
|
29
|
-
function notice_text(_call, tail) {
|
|
30
|
-
const pending = investigation_reads.tally_of(tail).pending.map((absolute) => investigation_reads.repository_relative(absolute));
|
|
31
|
-
return pending.length === 0 ? NOTICE : `${NOTICE} Read and not edited so far: ${pending.join(" ")}.`;
|
|
32
|
-
}
|
|
33
|
-
var GUARD = hook_decision.create_transcript_guard({
|
|
34
|
-
prefix: STAMP_PREFIX,
|
|
35
|
-
switch_key: SWITCH_ENV_KEY,
|
|
36
|
-
is_candidate: investigation_reads.is_refusable_call,
|
|
37
|
-
should_block,
|
|
38
|
-
reason: investigation_reads.REASON,
|
|
39
|
-
// The lane-child notice fires where the refusal is withheld (kit#2382), on a record of its own so it
|
|
40
|
-
// never spends the refusal's stamp.
|
|
41
|
-
notify: {
|
|
42
|
-
prefix: NOTICE_STAMP_PREFIX,
|
|
43
|
-
should_notify,
|
|
44
|
-
text: notice_text
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
var investigation_refusal = GUARD.refusal;
|
|
48
|
-
var investigation_outcome = GUARD.outcome;
|
|
49
|
-
var { is_enabled, refusal_path } = GUARD;
|
|
50
|
-
var investigation_notice_path = hook_decision.create_refusal_stamp(NOTICE_STAMP_PREFIX).path;
|
|
51
|
-
var { deny_envelope, load_environment_file, DISABLED_VALUES } = hook_decision;
|
|
52
|
-
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
53
|
-
if (process.stdin.isTTY) hook_decision.report_no_payload("investigation:guard");
|
|
54
|
-
else hook_decision.write_outcome(await text(process.stdin), investigation_outcome);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
SWITCH_ENV_KEY,
|
|
59
|
-
NOTICE,
|
|
60
|
-
investigation_refusal,
|
|
61
|
-
investigation_outcome,
|
|
62
|
-
is_enabled,
|
|
63
|
-
refusal_path,
|
|
64
|
-
investigation_notice_path,
|
|
65
|
-
deny_envelope,
|
|
66
|
-
load_environment_file,
|
|
67
|
-
DISABLED_VALUES
|
|
68
|
-
};
|