@zgeoff/skill-gate 0.2.6 → 0.2.8
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/README.md +27 -107
- package/dist/build-bash-change-output.d.ts +2 -0
- package/dist/build-bash-skill-gate-output.d.ts +2 -0
- package/dist/build-edit-output.d.ts +3 -0
- package/dist/build-patch-gate-output.d.ts +2 -0
- package/dist/classify-command-reads.d.ts +5 -0
- package/dist/collect-command-reads.d.ts +1 -0
- package/dist/collect-prompt-skills.d.ts +1 -0
- package/dist/collect-rule-warnings.d.ts +2 -0
- package/dist/harness.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +744 -241
- package/dist/load-ledger.d.ts +6 -0
- package/dist/parse-hook-input.d.ts +3 -0
- package/dist/parse-patch-paths.d.ts +1 -0
- package/dist/parse-shell-commands.d.ts +3 -1
- package/dist/pick-harness-wording.d.ts +3 -0
- package/dist/read-available-skills.d.ts +1 -0
- package/dist/read-project-dir.d.ts +1 -0
- package/dist/read-session-loads.d.ts +2 -0
- package/dist/read-session-transcript.d.ts +2 -0
- package/dist/record-codex-loads.d.ts +3 -0
- package/dist/resolve-state-dir.d.ts +3 -0
- package/dist/run-skill-gate.d.ts +2 -1
- package/dist/types.d.ts +41 -0
- package/dist/with-ledger-lock.d.ts +1 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -2565,13 +2565,10 @@ var require_picomatch2 = __commonJS(function(exports, module) {
|
|
|
2565
2565
|
});
|
|
2566
2566
|
|
|
2567
2567
|
// src/run-skill-gate.ts
|
|
2568
|
-
import { statSync } from "fs";
|
|
2569
|
-
import { mkdir, rm } from "fs/promises";
|
|
2570
|
-
import
|
|
2571
|
-
|
|
2572
|
-
function isRecord(value) {
|
|
2573
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2574
|
-
}
|
|
2568
|
+
import { statSync as statSync2 } from "fs";
|
|
2569
|
+
import { mkdir as mkdir3, rm } from "fs/promises";
|
|
2570
|
+
import path15 from "path";
|
|
2571
|
+
|
|
2575
2572
|
// ../../node_modules/.bun/@simple-git+args-pathspec@1.0.4/node_modules/@simple-git/args-pathspec/dist/index.mjs
|
|
2576
2573
|
var t = /* @__PURE__ */ new WeakMap;
|
|
2577
2574
|
function c(...n) {
|
|
@@ -5764,7 +5761,7 @@ function F3(t) {
|
|
|
5764
5761
|
throw new I3(t);
|
|
5765
5762
|
}
|
|
5766
5763
|
|
|
5767
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
5764
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/util.js
|
|
5768
5765
|
function getEnumValues(entries) {
|
|
5769
5766
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
5770
5767
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -5971,7 +5968,7 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
5971
5968
|
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
5972
5969
|
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
5973
5970
|
};
|
|
5974
|
-
function
|
|
5971
|
+
function pick(schema, mask) {
|
|
5975
5972
|
const currDef = schema._zod.def;
|
|
5976
5973
|
const checks = currDef.checks;
|
|
5977
5974
|
const hasChecks = checks && checks.length > 0;
|
|
@@ -6102,6 +6099,18 @@ function prefixIssues(path, issues) {
|
|
|
6102
6099
|
function unwrapMessage(message) {
|
|
6103
6100
|
return typeof message === "string" ? message : message?.message;
|
|
6104
6101
|
}
|
|
6102
|
+
function sizeCaps(defChecks) {
|
|
6103
|
+
const caps = [];
|
|
6104
|
+
for (const ch of defChecks ?? []) {
|
|
6105
|
+
const d = ch._zod.def;
|
|
6106
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
6107
|
+
break;
|
|
6108
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
6109
|
+
if (max >= 0)
|
|
6110
|
+
caps.push([max, ch]);
|
|
6111
|
+
}
|
|
6112
|
+
return caps;
|
|
6113
|
+
}
|
|
6105
6114
|
function attachSchema(issues, start, inst) {
|
|
6106
6115
|
var _a;
|
|
6107
6116
|
for (let i = start;i < issues.length; i++) {
|
|
@@ -6299,7 +6308,7 @@ function constantCatch(value) {
|
|
|
6299
6308
|
return fn;
|
|
6300
6309
|
}
|
|
6301
6310
|
|
|
6302
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6311
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/core.js
|
|
6303
6312
|
var _a;
|
|
6304
6313
|
var _zodDesc = { value: undefined, enumerable: false };
|
|
6305
6314
|
var _E = "captureStackTrace" in Error ? Error : null;
|
|
@@ -6417,7 +6426,7 @@ function config(newConfig) {
|
|
|
6417
6426
|
Object.assign(globalConfig, newConfig);
|
|
6418
6427
|
return globalConfig;
|
|
6419
6428
|
}
|
|
6420
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6429
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/errors.js
|
|
6421
6430
|
function _getMessage() {
|
|
6422
6431
|
const internals = this._zod;
|
|
6423
6432
|
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
@@ -6532,7 +6541,7 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
6532
6541
|
return fieldErrors;
|
|
6533
6542
|
}
|
|
6534
6543
|
|
|
6535
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6544
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/parse.js
|
|
6536
6545
|
function finalizeParams(callee, params) {
|
|
6537
6546
|
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
6538
6547
|
}
|
|
@@ -6679,7 +6688,7 @@ var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
6679
6688
|
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
6680
6689
|
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
6681
6690
|
};
|
|
6682
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6691
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/regexes.js
|
|
6683
6692
|
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
6684
6693
|
var cuid2 = /^[0-9a-z]+$/;
|
|
6685
6694
|
var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
@@ -6733,10 +6742,11 @@ function datetime(args) {
|
|
|
6733
6742
|
var anyString = /^[\s\S]{0,}$/;
|
|
6734
6743
|
var integer = /^-?\d+$/;
|
|
6735
6744
|
var number = /^-?\d+(?:\.\d+)?$/;
|
|
6745
|
+
var boolean = /^(?:true|false)$/i;
|
|
6736
6746
|
var lowercase = /^[^A-Z]*$/;
|
|
6737
6747
|
var uppercase = /^[^a-z]*$/;
|
|
6738
6748
|
|
|
6739
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6749
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/checks.js
|
|
6740
6750
|
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
6741
6751
|
var _a;
|
|
6742
6752
|
inst._zod ?? (inst._zod = {});
|
|
@@ -6922,7 +6932,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
|
|
|
6922
6932
|
};
|
|
6923
6933
|
});
|
|
6924
6934
|
|
|
6925
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6935
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/doc.js
|
|
6926
6936
|
class Doc {
|
|
6927
6937
|
constructor(args = [], closed = {}) {
|
|
6928
6938
|
this.content = [];
|
|
@@ -6964,14 +6974,14 @@ ${content.join(`
|
|
|
6964
6974
|
}
|
|
6965
6975
|
}
|
|
6966
6976
|
|
|
6967
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6977
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/versions.js
|
|
6968
6978
|
var version = {
|
|
6969
6979
|
major: 4,
|
|
6970
6980
|
minor: 6,
|
|
6971
|
-
patch:
|
|
6981
|
+
patch: 6
|
|
6972
6982
|
};
|
|
6973
6983
|
|
|
6974
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
6984
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/schemas.js
|
|
6975
6985
|
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
6976
6986
|
var _a;
|
|
6977
6987
|
inst ?? (inst = {});
|
|
@@ -7457,6 +7467,26 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
|
7457
7467
|
});
|
|
7458
7468
|
};
|
|
7459
7469
|
});
|
|
7470
|
+
var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
7471
|
+
$ZodType.init(inst, def);
|
|
7472
|
+
inst._zod.pattern = boolean;
|
|
7473
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
7474
|
+
if (def.coerce)
|
|
7475
|
+
try {
|
|
7476
|
+
payload.value = Boolean(payload.value);
|
|
7477
|
+
} catch (_) {}
|
|
7478
|
+
const input = payload.value;
|
|
7479
|
+
if (typeof input === "boolean")
|
|
7480
|
+
return payload;
|
|
7481
|
+
payload.issues.push({
|
|
7482
|
+
expected: "boolean",
|
|
7483
|
+
code: "invalid_type",
|
|
7484
|
+
input,
|
|
7485
|
+
inst
|
|
7486
|
+
});
|
|
7487
|
+
return payload;
|
|
7488
|
+
};
|
|
7489
|
+
});
|
|
7460
7490
|
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
7461
7491
|
$ZodType.init(inst, def);
|
|
7462
7492
|
inst._zod.parse = (payload) => payload;
|
|
@@ -7473,6 +7503,29 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
|
7473
7503
|
return payload;
|
|
7474
7504
|
};
|
|
7475
7505
|
});
|
|
7506
|
+
function capSize(inst, size) {
|
|
7507
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
7508
|
+
if (!caps.length)
|
|
7509
|
+
return;
|
|
7510
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
7511
|
+
const parse = inst._zod.parse;
|
|
7512
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7513
|
+
const n = size(payload.value);
|
|
7514
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
7515
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
7516
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
7517
|
+
const start = payload.issues.length;
|
|
7518
|
+
ch._zod.check(payload);
|
|
7519
|
+
payload.issues[start].continue = false;
|
|
7520
|
+
attachSchema(payload.issues, start, inst);
|
|
7521
|
+
return payload;
|
|
7522
|
+
}
|
|
7523
|
+
}
|
|
7524
|
+
}
|
|
7525
|
+
return parse(payload, ctx);
|
|
7526
|
+
};
|
|
7527
|
+
}
|
|
7528
|
+
var arraySize = (input) => Array.isArray(input) ? input.length : -1;
|
|
7476
7529
|
function handleArrayResult(result, final, index) {
|
|
7477
7530
|
if (result.issues.length) {
|
|
7478
7531
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -7516,6 +7569,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
7516
7569
|
}
|
|
7517
7570
|
return payload;
|
|
7518
7571
|
};
|
|
7572
|
+
capSize(inst, arraySize);
|
|
7519
7573
|
});
|
|
7520
7574
|
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
7521
7575
|
const isPresent = key in input;
|
|
@@ -8536,7 +8590,7 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
8536
8590
|
payload.issues.push(issue(_iss));
|
|
8537
8591
|
}
|
|
8538
8592
|
}
|
|
8539
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
8593
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/memoizer.js
|
|
8540
8594
|
class $ZodCyclicError extends Error {
|
|
8541
8595
|
constructor() {
|
|
8542
8596
|
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
@@ -8805,7 +8859,7 @@ function isBackEdge(ctx, value) {
|
|
|
8805
8859
|
const backEdges = ctx[STATE]?.backEdges;
|
|
8806
8860
|
return backEdges !== undefined && isRef(value) && backEdges.has(value);
|
|
8807
8861
|
}
|
|
8808
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
8862
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/locales/en.js
|
|
8809
8863
|
var error = () => {
|
|
8810
8864
|
const Sizable = {
|
|
8811
8865
|
string: { unit: "characters", verb: "to have" },
|
|
@@ -8927,7 +8981,7 @@ function en_default() {
|
|
|
8927
8981
|
localeError: error()
|
|
8928
8982
|
};
|
|
8929
8983
|
}
|
|
8930
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
8984
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/registries.js
|
|
8931
8985
|
var _a2;
|
|
8932
8986
|
class $ZodRegistry {
|
|
8933
8987
|
constructor() {
|
|
@@ -8974,7 +9028,7 @@ function registry() {
|
|
|
8974
9028
|
}
|
|
8975
9029
|
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
|
|
8976
9030
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
8977
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
9031
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/api.js
|
|
8978
9032
|
function snapshotChecks(def) {
|
|
8979
9033
|
if (def.checks)
|
|
8980
9034
|
def.checks = [...def.checks];
|
|
@@ -9220,6 +9274,12 @@ function _isoDuration(Class, params) {
|
|
|
9220
9274
|
...normalizeParams(params)
|
|
9221
9275
|
});
|
|
9222
9276
|
}
|
|
9277
|
+
function _boolean(Class, params) {
|
|
9278
|
+
return new Class({
|
|
9279
|
+
type: "boolean",
|
|
9280
|
+
...normalizeParams(params)
|
|
9281
|
+
});
|
|
9282
|
+
}
|
|
9223
9283
|
function _unknown(Class) {
|
|
9224
9284
|
return new Class({
|
|
9225
9285
|
type: "unknown"
|
|
@@ -9365,7 +9425,7 @@ function _check(fn, params) {
|
|
|
9365
9425
|
ch._zod.check = fn;
|
|
9366
9426
|
return ch;
|
|
9367
9427
|
}
|
|
9368
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
9428
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/to-json-schema.js
|
|
9369
9429
|
function assignProps(target, ...sources) {
|
|
9370
9430
|
for (const source of sources) {
|
|
9371
9431
|
for (const key of Reflect.ownKeys(source)) {
|
|
@@ -9888,7 +9948,7 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
|
|
|
9888
9948
|
extractDefs(ctx, schema);
|
|
9889
9949
|
return finalize(ctx, schema);
|
|
9890
9950
|
};
|
|
9891
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
9951
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/core/json-schema-processors.js
|
|
9892
9952
|
var narrowMin = (agg, key, value) => {
|
|
9893
9953
|
if (agg[key] === undefined || value > agg[key])
|
|
9894
9954
|
agg[key] = value;
|
|
@@ -10021,6 +10081,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
10021
10081
|
}
|
|
10022
10082
|
}
|
|
10023
10083
|
};
|
|
10084
|
+
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
10085
|
+
json.type = "boolean";
|
|
10086
|
+
};
|
|
10024
10087
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
10025
10088
|
json.not = {};
|
|
10026
10089
|
};
|
|
@@ -10368,7 +10431,7 @@ var optionalProcessor = (schema, ctx, _json, params) => {
|
|
|
10368
10431
|
const seen = ctx.seen.get(schema);
|
|
10369
10432
|
seen.ref = def.innerType;
|
|
10370
10433
|
};
|
|
10371
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
10434
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/errors.js
|
|
10372
10435
|
var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
10373
10436
|
function _lazyMethod(proto, key, make) {
|
|
10374
10437
|
Object.defineProperty(proto, key, {
|
|
@@ -10413,7 +10476,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, undefi
|
|
|
10413
10476
|
Parent: Error
|
|
10414
10477
|
});
|
|
10415
10478
|
|
|
10416
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
10479
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/parse.js
|
|
10417
10480
|
var parse2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
10418
10481
|
var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
10419
10482
|
var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
@@ -10427,7 +10490,7 @@ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
|
10427
10490
|
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
10428
10491
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
10429
10492
|
|
|
10430
|
-
// ../../node_modules/.bun/zod@4.6.
|
|
10493
|
+
// ../../node_modules/.bun/zod@4.6.6/node_modules/zod/v4/classic/schemas.js
|
|
10431
10494
|
function _ensureDefaultLocale() {
|
|
10432
10495
|
if (!globalConfig.localeError)
|
|
10433
10496
|
config(en_default());
|
|
@@ -10844,6 +10907,14 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
|
10844
10907
|
$ZodJWT.init(inst, def);
|
|
10845
10908
|
ZodStringFormat.init(inst, def);
|
|
10846
10909
|
});
|
|
10910
|
+
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
10911
|
+
$ZodBoolean.init(inst, def);
|
|
10912
|
+
ZodType.init(inst, def);
|
|
10913
|
+
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
10914
|
+
});
|
|
10915
|
+
function boolean2(params) {
|
|
10916
|
+
return _boolean(ZodBoolean, params);
|
|
10917
|
+
}
|
|
10847
10918
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
10848
10919
|
$ZodUnknown.init(inst, def);
|
|
10849
10920
|
ZodType.init(inst, def);
|
|
@@ -10921,7 +10992,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
10921
10992
|
return merge(this, other);
|
|
10922
10993
|
},
|
|
10923
10994
|
pick(mask) {
|
|
10924
|
-
return
|
|
10995
|
+
return pick(this, mask);
|
|
10925
10996
|
},
|
|
10926
10997
|
omit(mask) {
|
|
10927
10998
|
return omit(this, mask);
|
|
@@ -11260,6 +11331,19 @@ function formatSkillList(skills) {
|
|
|
11260
11331
|
return `${names.slice(0, -1).join(", ")} and ${names.at(-1)} ${noun}`;
|
|
11261
11332
|
}
|
|
11262
11333
|
|
|
11334
|
+
// src/pick-harness-wording.ts
|
|
11335
|
+
function pickHarnessWording(harness) {
|
|
11336
|
+
return M3(harness ?? "claude-code").returnType().with("claude-code", () => ({
|
|
11337
|
+
loadSkill: "with the Skill tool",
|
|
11338
|
+
readFile: "with the Read tool",
|
|
11339
|
+
editTools: "Edit, Write or MultiEdit"
|
|
11340
|
+
})).with("codex", () => ({
|
|
11341
|
+
loadSkill: "by reading its SKILL.md with cat, for example `cat .agents/skills/<name>/SKILL.md`",
|
|
11342
|
+
readFile: "with cat",
|
|
11343
|
+
editTools: "apply_patch"
|
|
11344
|
+
})).exhaustive();
|
|
11345
|
+
}
|
|
11346
|
+
|
|
11263
11347
|
// src/build-bash-change-output.ts
|
|
11264
11348
|
var RULES_PATH = ".claude/skill-gate.json";
|
|
11265
11349
|
function buildBashChangeOutput(event, changedPaths, missing, context = {}) {
|
|
@@ -11267,10 +11351,11 @@ function buildBashChangeOutput(event, changedPaths, missing, context = {}) {
|
|
|
11267
11351
|
return null;
|
|
11268
11352
|
}
|
|
11269
11353
|
const subject = changedPaths.length === 1 ? `changed the gated path ${changedPaths[0]}` : `changed the gated paths ${changedPaths.join(", ")}`;
|
|
11354
|
+
const wording = pickHarnessWording(context.harness);
|
|
11270
11355
|
const pronoun = missing.length === 1 ? "it" : "them";
|
|
11271
11356
|
const review = `then review what the command changed against ${pronoun} and fix what breaks a rule.`;
|
|
11272
|
-
const load = context.compacted === true ? `Load the ${formatSkillList(missing)} again
|
|
11273
|
-
const reason = `skill-gate: this Bash command ${subject} before the session loaded the skills it needs. ${load} Change a gated path only with
|
|
11357
|
+
const load = context.compacted === true ? `Load the ${formatSkillList(missing)} again ${wording.loadSkill}, ${review} This session was compacted, and a skill loaded before the compaction no longer counts.` : `Load the ${formatSkillList(missing)} ${wording.loadSkill}, ${review}`;
|
|
11358
|
+
const reason = `skill-gate: this Bash command ${subject} before the session loaded the skills it needs. ${load} Change a gated path only with ${wording.editTools}, never through Bash. ${RULES_PATH} lists the skills each path needs.`;
|
|
11274
11359
|
return M3(event).returnType().with("PostToolUse", () => ({ decision: "block", reason })).with("PostToolUseFailure", () => ({
|
|
11275
11360
|
hookSpecificOutput: { hookEventName: "PostToolUseFailure", additionalContext: reason }
|
|
11276
11361
|
})).exhaustive();
|
|
@@ -11292,8 +11377,9 @@ function buildBashSkillGateOutput(gatedPaths, missing, context = {}) {
|
|
|
11292
11377
|
return null;
|
|
11293
11378
|
}
|
|
11294
11379
|
const subject = gatedPaths.length === 1 ? `${gatedPaths[0]} is a gated path, so change it` : `${gatedPaths.join(", ")} are gated paths, so change them`;
|
|
11295
|
-
const
|
|
11296
|
-
const
|
|
11380
|
+
const wording = pickHarnessWording(context.harness);
|
|
11381
|
+
const load = buildLoadInstruction(missing, context.compacted === true, wording.loadSkill);
|
|
11382
|
+
const rule = `${subject} with the ${wording.editTools} tool, never through Bash.`;
|
|
11297
11383
|
return {
|
|
11298
11384
|
hookSpecificOutput: {
|
|
11299
11385
|
hookEventName: "PreToolUse",
|
|
@@ -11301,11 +11387,11 @@ function buildBashSkillGateOutput(gatedPaths, missing, context = {}) {
|
|
|
11301
11387
|
}
|
|
11302
11388
|
};
|
|
11303
11389
|
}
|
|
11304
|
-
function buildLoadInstruction(missing, compacted) {
|
|
11390
|
+
function buildLoadInstruction(missing, compacted, loadSkill) {
|
|
11305
11391
|
if (missing.length === 0) {
|
|
11306
11392
|
return "";
|
|
11307
11393
|
}
|
|
11308
|
-
return compacted ? ` Load the ${formatSkillList(missing)} again
|
|
11394
|
+
return compacted ? ` Load the ${formatSkillList(missing)} again ${loadSkill} before the next change. This session was compacted, and a skill loaded before the compaction no longer counts.` : ` Load the ${formatSkillList(missing)} ${loadSkill} before the next change.`;
|
|
11309
11395
|
}
|
|
11310
11396
|
|
|
11311
11397
|
// src/format-unknown-key-warning.ts
|
|
@@ -11313,19 +11399,58 @@ function formatUnknownKeyWarning(key) {
|
|
|
11313
11399
|
return `skill-gate: .claude/skill-gate.json holds the key \`${key}\`, which this version of @zgeoff/skill-gate does not know. The gate skips the key and keeps the rest of the rules; update the package or remove the key.`;
|
|
11314
11400
|
}
|
|
11315
11401
|
|
|
11316
|
-
// src/
|
|
11402
|
+
// src/collect-rule-warnings.ts
|
|
11317
11403
|
var RULES_PATH3 = ".claude/skill-gate.json";
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
const warnings = [
|
|
11404
|
+
function collectRuleWarnings(unknown, context) {
|
|
11405
|
+
return [
|
|
11321
11406
|
...context.rulesError === undefined ? [] : [`skill-gate: ${RULES_PATH3} ${context.rulesError}.`],
|
|
11322
11407
|
...(context.unknownKeys ?? []).map((key) => formatUnknownKeyWarning(key)),
|
|
11323
|
-
...
|
|
11408
|
+
...unknown.map((entry) => `skill-gate: the rule "${entry.match}" in ${RULES_PATH3} names the skill "${entry.skill}", but .claude/skills/${entry.skill}/SKILL.md does not exist. Fix the rule or add the skill; until then the gate skips that skill.`)
|
|
11324
11409
|
];
|
|
11410
|
+
}
|
|
11411
|
+
|
|
11412
|
+
// src/build-patch-gate-output.ts
|
|
11413
|
+
var RULES_PATH4 = ".claude/skill-gate.json";
|
|
11414
|
+
function buildPatchGateOutput(entries, context = {}) {
|
|
11415
|
+
const wording = pickHarnessWording(context.harness);
|
|
11416
|
+
const warnings = collectRuleWarnings(entries.flatMap((entry) => entry.plan.unknown), context);
|
|
11417
|
+
const warning = warnings.length === 0 ? undefined : [...new Set(warnings)].join(`
|
|
11418
|
+
`);
|
|
11419
|
+
const blocked = entries.filter((entry) => entry.plan.missing.length > 0);
|
|
11420
|
+
if (blocked.length > 0) {
|
|
11421
|
+
const needs = blocked.map((entry) => `${entry.filePath} needs the ${formatSkillList(entry.plan.missing)}`).join("; ");
|
|
11422
|
+
const again = context.compacted === true ? " again" : "";
|
|
11423
|
+
const compaction = context.compacted === true ? " This session was compacted, and a skill loaded before the compaction no longer counts." : "";
|
|
11424
|
+
const reason = `This patch changes a gated path before the session loaded the skills it needs: ${needs}. Load each missing skill${again} ${wording.loadSkill}, then retry the patch.${compaction} Change a gated path only with ${wording.editTools}, never through Bash. ${RULES_PATH4} lists the skills each path needs.`;
|
|
11425
|
+
return {
|
|
11426
|
+
...warning === undefined ? {} : { systemMessage: warning },
|
|
11427
|
+
hookSpecificOutput: {
|
|
11428
|
+
hookEventName: "PreToolUse",
|
|
11429
|
+
permissionDecision: "deny",
|
|
11430
|
+
permissionDecisionReason: warning === undefined ? reason : `${reason}
|
|
11431
|
+
${warning}`
|
|
11432
|
+
}
|
|
11433
|
+
};
|
|
11434
|
+
}
|
|
11435
|
+
if (warning === undefined) {
|
|
11436
|
+
return null;
|
|
11437
|
+
}
|
|
11438
|
+
return {
|
|
11439
|
+
systemMessage: warning,
|
|
11440
|
+
hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: warning }
|
|
11441
|
+
};
|
|
11442
|
+
}
|
|
11443
|
+
|
|
11444
|
+
// src/build-skill-gate-output.ts
|
|
11445
|
+
var RULES_PATH5 = ".claude/skill-gate.json";
|
|
11446
|
+
function buildSkillGateOutput(filePath, plan, context = {}) {
|
|
11447
|
+
const wording = pickHarnessWording(context.harness);
|
|
11448
|
+
const editToolsNote = `Change a gated path only with ${wording.editTools}, never through Bash.`;
|
|
11449
|
+
const warnings = collectRuleWarnings(plan.unknown, context);
|
|
11325
11450
|
const warning = warnings.length === 0 ? undefined : warnings.join(`
|
|
11326
11451
|
`);
|
|
11327
11452
|
if (plan.missing.length > 0) {
|
|
11328
|
-
const reason = context.compacted === true ? `Load the ${formatSkillList(plan.missing)} again
|
|
11453
|
+
const reason = context.compacted === true ? `Load the ${formatSkillList(plan.missing)} again ${wording.loadSkill} before editing ${filePath}, then retry the edit. This session was compacted, and a skill loaded before the compaction no longer counts. ${editToolsNote} ${RULES_PATH5} lists the skills each path needs.` : `Load the ${formatSkillList(plan.missing)} ${wording.loadSkill} before editing ${filePath}, then retry the edit. ${editToolsNote} ${RULES_PATH5} lists the skills each path needs.`;
|
|
11329
11454
|
return {
|
|
11330
11455
|
...warning === undefined ? {} : { systemMessage: warning },
|
|
11331
11456
|
hookSpecificOutput: {
|
|
@@ -11345,18 +11470,26 @@ ${warning}`
|
|
|
11345
11470
|
};
|
|
11346
11471
|
}
|
|
11347
11472
|
|
|
11473
|
+
// src/build-edit-output.ts
|
|
11474
|
+
function buildEditOutput(harness, entries, context) {
|
|
11475
|
+
return M3(harness).with("claude-code", () => {
|
|
11476
|
+
const [first] = entries;
|
|
11477
|
+
return first === undefined ? null : buildSkillGateOutput(first.filePath, first.plan, context);
|
|
11478
|
+
}).with("codex", () => buildPatchGateOutput(entries, { ...context, harness })).exhaustive();
|
|
11479
|
+
}
|
|
11480
|
+
|
|
11348
11481
|
// src/build-tool-gate-output.ts
|
|
11349
|
-
var
|
|
11482
|
+
var RULES_PATH6 = ".claude/skill-gate.json";
|
|
11350
11483
|
function buildToolGateOutput(toolName, plan, context = {}) {
|
|
11351
11484
|
const warnings = [
|
|
11352
|
-
...context.rulesError === undefined ? [] : [`skill-gate: ${
|
|
11485
|
+
...context.rulesError === undefined ? [] : [`skill-gate: ${RULES_PATH6} ${context.rulesError}.`],
|
|
11353
11486
|
...(context.unknownKeys ?? []).map((key) => formatUnknownKeyWarning(key)),
|
|
11354
11487
|
...plan.unknown.map((entry) => formatUnknownWarning(entry))
|
|
11355
11488
|
];
|
|
11356
11489
|
const warning = warnings.length === 0 ? undefined : warnings.join(`
|
|
11357
11490
|
`);
|
|
11358
11491
|
if (plan.missingSkills.length > 0 || plan.missingReferences.length > 0) {
|
|
11359
|
-
const reason = buildDenyReason(toolName, plan, context.compacted === true);
|
|
11492
|
+
const reason = buildDenyReason(toolName, plan, context.compacted === true, context.harness);
|
|
11360
11493
|
return {
|
|
11361
11494
|
...warning === undefined ? {} : { systemMessage: warning },
|
|
11362
11495
|
hookSpecificOutput: {
|
|
@@ -11376,16 +11509,17 @@ ${warning}`
|
|
|
11376
11509
|
};
|
|
11377
11510
|
}
|
|
11378
11511
|
function formatUnknownWarning(entry) {
|
|
11379
|
-
return entry.kind === "skill" ? `skill-gate: the tool gate "${entry.tool}" in ${
|
|
11512
|
+
return entry.kind === "skill" ? `skill-gate: the tool gate "${entry.tool}" in ${RULES_PATH6} names the skill "${entry.name}", but .claude/skills/${entry.name}/SKILL.md does not exist. Fix the rule or add the skill; until then the gate skips that skill.` : `skill-gate: the tool gate "${entry.tool}" in ${RULES_PATH6} names the reference "${entry.name}", but .claude/skills/${entry.name} does not exist. Fix the rule or add the file; until then the gate skips that reference.`;
|
|
11380
11513
|
}
|
|
11381
|
-
function buildDenyReason(toolName, plan, compacted) {
|
|
11514
|
+
function buildDenyReason(toolName, plan, compacted, harness) {
|
|
11515
|
+
const wording = pickHarnessWording(harness);
|
|
11382
11516
|
const again = compacted ? " again" : "";
|
|
11383
11517
|
const steps = [
|
|
11384
|
-
...plan.missingSkills.length === 0 ? [] : [`load the ${formatSkillList(plan.missingSkills)}${again}
|
|
11385
|
-
...plan.missingReferences.length === 0 ? [] : [`read ${formatReferenceList(plan.missingReferences)}${again}
|
|
11518
|
+
...plan.missingSkills.length === 0 ? [] : [`load the ${formatSkillList(plan.missingSkills)}${again} ${wording.loadSkill}`],
|
|
11519
|
+
...plan.missingReferences.length === 0 ? [] : [`read ${formatReferenceList(plan.missingReferences)}${again} ${wording.readFile}`]
|
|
11386
11520
|
].join(" and ");
|
|
11387
11521
|
const compaction = compacted ? " This session was compacted, and a skill or reference loaded before the compaction no longer counts." : "";
|
|
11388
|
-
return `Before calling ${toolName}, ${steps}, then retry the call.${compaction} ${
|
|
11522
|
+
return `Before calling ${toolName}, ${steps}, then retry the call.${compaction} ${RULES_PATH6} lists the skills and references each tool needs.`;
|
|
11389
11523
|
}
|
|
11390
11524
|
function formatReferenceList(references) {
|
|
11391
11525
|
const paths = references.map((reference) => `.claude/skills/${reference}`);
|
|
@@ -11427,82 +11561,23 @@ function isGlobMatch(pattern, relativePath) {
|
|
|
11427
11561
|
return import_picomatch.default.isMatch(relativePath, pattern, { dot: true });
|
|
11428
11562
|
}
|
|
11429
11563
|
|
|
11430
|
-
// src/collect-session-loads.ts
|
|
11431
|
-
function collectSessionLoads(transcript) {
|
|
11432
|
-
const entries = transcript.split(`
|
|
11433
|
-
`).map((line) => parseEntry(line));
|
|
11434
|
-
const lastBoundary = entries.findLastIndex((entry) => isCompactBoundary(entry));
|
|
11435
|
-
const current = entries.slice(lastBoundary + 1);
|
|
11436
|
-
const succeeded = collectSucceededToolUseIDs(current);
|
|
11437
|
-
const skills = current.flatMap((entry) => collectEntrySkills(entry, succeeded));
|
|
11438
|
-
const readPaths = current.flatMap((entry) => collectContentBlocks(entry, "assistant")).flatMap((block) => collectReadCall(block, succeeded));
|
|
11439
|
-
return {
|
|
11440
|
-
skills: [...new Set(skills)],
|
|
11441
|
-
readPaths: [...new Set(readPaths)],
|
|
11442
|
-
compacted: lastBoundary !== -1
|
|
11443
|
-
};
|
|
11444
|
-
}
|
|
11445
|
-
function parseEntry(line) {
|
|
11446
|
-
try {
|
|
11447
|
-
return JSON.parse(line);
|
|
11448
|
-
} catch {
|
|
11449
|
-
return null;
|
|
11450
|
-
}
|
|
11451
|
-
}
|
|
11452
|
-
function isCompactBoundary(entry) {
|
|
11453
|
-
return isRecord(entry) && entry["type"] === "system" && entry["subtype"] === "compact_boundary";
|
|
11454
|
-
}
|
|
11455
|
-
function collectSucceededToolUseIDs(entries) {
|
|
11456
|
-
return entries.flatMap((entry) => collectContentBlocks(entry, "user")).filter((block) => block["type"] === "tool_result" && block["is_error"] !== true).flatMap((block) => typeof block["tool_use_id"] === "string" ? [block["tool_use_id"]] : []);
|
|
11457
|
-
}
|
|
11458
|
-
function collectContentBlocks(entry, type) {
|
|
11459
|
-
if (!isRecord(entry) || entry["type"] !== type || !isRecord(entry["message"])) {
|
|
11460
|
-
return [];
|
|
11461
|
-
}
|
|
11462
|
-
const content = entry["message"]["content"];
|
|
11463
|
-
return Array.isArray(content) ? content.filter((block) => isRecord(block)) : [];
|
|
11464
|
-
}
|
|
11465
|
-
function collectEntrySkills(entry, succeeded) {
|
|
11466
|
-
const command = findSlashCommand(entry);
|
|
11467
|
-
if (command !== undefined) {
|
|
11468
|
-
return [command];
|
|
11469
|
-
}
|
|
11470
|
-
return collectContentBlocks(entry, "assistant").flatMap((block) => collectSkillCall(block, succeeded));
|
|
11471
|
-
}
|
|
11472
|
-
var SLASH_COMMAND_PATTERN = /^\s*(?:<command-message>[^<]*<\/command-message>\s*)?<command-name>\/(?<skill>[^<\s]+)<\/command-name>/u;
|
|
11473
|
-
function findSlashCommand(entry) {
|
|
11474
|
-
if (!isRecord(entry) || entry["type"] !== "user" || entry["isSidechain"] === true || !isRecord(entry["message"])) {
|
|
11475
|
-
return;
|
|
11476
|
-
}
|
|
11477
|
-
const content = entry["message"]["content"];
|
|
11478
|
-
return typeof content === "string" ? SLASH_COMMAND_PATTERN.exec(content)?.groups?.["skill"] : undefined;
|
|
11479
|
-
}
|
|
11480
|
-
function collectSkillCall(block, succeeded) {
|
|
11481
|
-
const input = block["input"];
|
|
11482
|
-
const id = block["id"];
|
|
11483
|
-
if (block["type"] !== "tool_use" || block["name"] !== "Skill" || !isRecord(input)) {
|
|
11484
|
-
return [];
|
|
11485
|
-
}
|
|
11486
|
-
const skill = input["skill"];
|
|
11487
|
-
return typeof skill === "string" && typeof id === "string" && succeeded.includes(id) ? [skill] : [];
|
|
11488
|
-
}
|
|
11489
|
-
function collectReadCall(block, succeeded) {
|
|
11490
|
-
const input = block["input"];
|
|
11491
|
-
const id = block["id"];
|
|
11492
|
-
if (block["type"] !== "tool_use" || block["name"] !== "Read" || !isRecord(input)) {
|
|
11493
|
-
return [];
|
|
11494
|
-
}
|
|
11495
|
-
const filePath = input["file_path"];
|
|
11496
|
-
return typeof filePath === "string" && typeof id === "string" && succeeded.includes(id) ? [filePath] : [];
|
|
11497
|
-
}
|
|
11498
|
-
|
|
11499
11564
|
// src/collect-written-paths.ts
|
|
11500
11565
|
import path from "path";
|
|
11501
11566
|
|
|
11502
11567
|
// src/parse-shell-commands.ts
|
|
11503
|
-
function parseShellCommands(text) {
|
|
11568
|
+
function parseShellCommands(text, options = {}) {
|
|
11504
11569
|
const tokens = splitShellTokens(text);
|
|
11505
|
-
|
|
11570
|
+
if (tokens === null) {
|
|
11571
|
+
return null;
|
|
11572
|
+
}
|
|
11573
|
+
const commands = buildShellCommands(tokens);
|
|
11574
|
+
return options.withGuards === true ? commands : commands.map((command) => ({
|
|
11575
|
+
words: command.words,
|
|
11576
|
+
redirects: command.redirects,
|
|
11577
|
+
stdin: command.stdin,
|
|
11578
|
+
enters: command.enters,
|
|
11579
|
+
leaves: command.leaves
|
|
11580
|
+
}));
|
|
11506
11581
|
}
|
|
11507
11582
|
function splitShellTokens(text) {
|
|
11508
11583
|
const tokens = [];
|
|
@@ -11727,15 +11802,28 @@ function buildShellCommands(tokens) {
|
|
|
11727
11802
|
let operator = null;
|
|
11728
11803
|
let pipedIn = false;
|
|
11729
11804
|
const listStarts = [0];
|
|
11805
|
+
let chain = [];
|
|
11806
|
+
let viaOr = false;
|
|
11807
|
+
let inherited = { chain: [], viaOr: false };
|
|
11808
|
+
const outerStates = [];
|
|
11730
11809
|
const collectDraft = (separator) => {
|
|
11731
11810
|
const pipedOut = separator === "|" || separator === "|&";
|
|
11732
11811
|
if (draft.words.length > 0 || draft.redirects.length > 0) {
|
|
11733
11812
|
const piped = pipedIn || pipedOut;
|
|
11734
11813
|
draft.enters += piped ? 1 : 0;
|
|
11735
11814
|
draft.leaves += piped ? 1 : 0;
|
|
11815
|
+
draft.guard = chain.length > 0 || viaOr ? { viaOr, before: [...chain] } : null;
|
|
11816
|
+
if (separator === "&&" || separator === "||") {
|
|
11817
|
+
chain.push(draft.words);
|
|
11818
|
+
viaOr ||= separator === "||";
|
|
11819
|
+
}
|
|
11736
11820
|
commands.push(draft);
|
|
11737
11821
|
draft = buildCommandDraft();
|
|
11738
11822
|
}
|
|
11823
|
+
if (separator !== null && LIST_ENDS.has(separator)) {
|
|
11824
|
+
chain = [...inherited.chain];
|
|
11825
|
+
viaOr = inherited.viaOr;
|
|
11826
|
+
}
|
|
11739
11827
|
operator = null;
|
|
11740
11828
|
pipedIn = pipedOut;
|
|
11741
11829
|
const listStart = listStarts.at(-1) ?? 0;
|
|
@@ -11758,8 +11846,14 @@ function buildShellCommands(tokens) {
|
|
|
11758
11846
|
if (subshell.opens) {
|
|
11759
11847
|
draft.enters += 1;
|
|
11760
11848
|
listStarts.push(commands.length);
|
|
11849
|
+
outerStates.push({ chain, viaOr, inherited });
|
|
11850
|
+
inherited = { chain: [...chain], viaOr };
|
|
11761
11851
|
} else {
|
|
11762
11852
|
listStarts.pop();
|
|
11853
|
+
const outer = outerStates.pop();
|
|
11854
|
+
if (outer !== undefined) {
|
|
11855
|
+
({ chain, viaOr, inherited } = outer);
|
|
11856
|
+
}
|
|
11763
11857
|
if (last !== undefined) {
|
|
11764
11858
|
last.leaves += 1;
|
|
11765
11859
|
}
|
|
@@ -11790,7 +11884,7 @@ function buildShellCommands(tokens) {
|
|
|
11790
11884
|
return commands;
|
|
11791
11885
|
}
|
|
11792
11886
|
function buildCommandDraft() {
|
|
11793
|
-
return { words: [], redirects: [], stdin: null, enters: 0, leaves: 0 };
|
|
11887
|
+
return { words: [], redirects: [], stdin: null, enters: 0, leaves: 0, guard: null };
|
|
11794
11888
|
}
|
|
11795
11889
|
|
|
11796
11890
|
// src/collect-written-paths.ts
|
|
@@ -12075,6 +12169,95 @@ function resolveNextDir(command, directory) {
|
|
|
12075
12169
|
}
|
|
12076
12170
|
return directory === null ? null : path.join(directory, target.text);
|
|
12077
12171
|
}
|
|
12172
|
+
// ../std/src/is-record.ts
|
|
12173
|
+
function isRecord(value) {
|
|
12174
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12175
|
+
}
|
|
12176
|
+
// src/parse-patch-paths.ts
|
|
12177
|
+
var PATCH_HEADER = /^\*\*\* (?:Add File|Update File|Delete File|Move to): (?<path>.+)$/u;
|
|
12178
|
+
function parsePatchPaths(patch) {
|
|
12179
|
+
const paths = patch.split(`
|
|
12180
|
+
`).flatMap((line) => PATCH_HEADER.exec(line.replace(/\r$/u, ""))?.groups?.["path"]?.trim() ?? []);
|
|
12181
|
+
return [...new Set(paths)];
|
|
12182
|
+
}
|
|
12183
|
+
|
|
12184
|
+
// src/parse-hook-input.ts
|
|
12185
|
+
function parseHookInput(harness, value) {
|
|
12186
|
+
return M3(harness).with("claude-code", () => parseClaudeInput(value)).with("codex", () => parseCodexInput(value)).exhaustive();
|
|
12187
|
+
}
|
|
12188
|
+
function parseClaudeInput(value) {
|
|
12189
|
+
if (!isRecord(value) || !isRecord(value["tool_input"])) {
|
|
12190
|
+
return null;
|
|
12191
|
+
}
|
|
12192
|
+
const cwd = value["cwd"];
|
|
12193
|
+
const transcriptPath = value["transcript_path"];
|
|
12194
|
+
const editPath = value["tool_input"]["file_path"];
|
|
12195
|
+
const command = value["tool_input"]["command"];
|
|
12196
|
+
const toolName = value["tool_name"];
|
|
12197
|
+
if (typeof cwd !== "string" || typeof transcriptPath !== "string") {
|
|
12198
|
+
return null;
|
|
12199
|
+
}
|
|
12200
|
+
if (typeof editPath !== "string" && typeof command !== "string" && typeof toolName !== "string") {
|
|
12201
|
+
return null;
|
|
12202
|
+
}
|
|
12203
|
+
return {
|
|
12204
|
+
kind: "tool",
|
|
12205
|
+
harness: "claude-code",
|
|
12206
|
+
event: pickHookEvent(value["hook_event_name"]),
|
|
12207
|
+
toolName: typeof toolName === "string" ? toolName : null,
|
|
12208
|
+
cwd,
|
|
12209
|
+
editPaths: typeof editPath === "string" ? [editPath] : [],
|
|
12210
|
+
command: typeof command === "string" ? command : null,
|
|
12211
|
+
transcriptPath,
|
|
12212
|
+
sessionID: null,
|
|
12213
|
+
toolUseID: value["tool_use_id"],
|
|
12214
|
+
agentID: value["agent_id"]
|
|
12215
|
+
};
|
|
12216
|
+
}
|
|
12217
|
+
function pickHookEvent(value) {
|
|
12218
|
+
return value === "PostToolUse" || value === "PostToolUseFailure" ? value : "PreToolUse";
|
|
12219
|
+
}
|
|
12220
|
+
function parseCodexInput(value) {
|
|
12221
|
+
if (!isRecord(value) || typeof value["cwd"] !== "string") {
|
|
12222
|
+
return null;
|
|
12223
|
+
}
|
|
12224
|
+
const cwd = value["cwd"];
|
|
12225
|
+
const transcriptPath = pickString(value["transcript_path"]);
|
|
12226
|
+
const sessionID = pickString(value["session_id"]);
|
|
12227
|
+
const event = value["hook_event_name"];
|
|
12228
|
+
if (event === "UserPromptSubmit" || event === "PostCompact") {
|
|
12229
|
+
return {
|
|
12230
|
+
kind: "lifecycle",
|
|
12231
|
+
event,
|
|
12232
|
+
cwd,
|
|
12233
|
+
transcriptPath,
|
|
12234
|
+
sessionID,
|
|
12235
|
+
prompt: pickString(value["prompt"])
|
|
12236
|
+
};
|
|
12237
|
+
}
|
|
12238
|
+
const toolName = value["tool_name"];
|
|
12239
|
+
if (event !== "PreToolUse" && event !== "PostToolUse" || typeof toolName !== "string") {
|
|
12240
|
+
return null;
|
|
12241
|
+
}
|
|
12242
|
+
const toolInput = value["tool_input"];
|
|
12243
|
+
const text = isRecord(toolInput) ? pickString(toolInput["command"]) : null;
|
|
12244
|
+
return {
|
|
12245
|
+
kind: "tool",
|
|
12246
|
+
harness: "codex",
|
|
12247
|
+
event,
|
|
12248
|
+
toolName,
|
|
12249
|
+
cwd,
|
|
12250
|
+
editPaths: toolName === "apply_patch" && text !== null ? parsePatchPaths(text) : [],
|
|
12251
|
+
command: toolName === "Bash" ? text : null,
|
|
12252
|
+
transcriptPath,
|
|
12253
|
+
sessionID,
|
|
12254
|
+
toolUseID: value["tool_use_id"],
|
|
12255
|
+
agentID: undefined
|
|
12256
|
+
};
|
|
12257
|
+
}
|
|
12258
|
+
function pickString(value) {
|
|
12259
|
+
return typeof value === "string" ? value : null;
|
|
12260
|
+
}
|
|
12078
12261
|
|
|
12079
12262
|
// src/parse-skill-gate-rules.ts
|
|
12080
12263
|
function parseSkillGateRules(text) {
|
|
@@ -12240,6 +12423,19 @@ async function readAvailableReferences(readContent, skillsDir, tools) {
|
|
|
12240
12423
|
return references.filter((_, index) => contents[index] !== null);
|
|
12241
12424
|
}
|
|
12242
12425
|
|
|
12426
|
+
// src/read-available-skills.ts
|
|
12427
|
+
import path4 from "path";
|
|
12428
|
+
async function readAvailableSkills(skillsDir) {
|
|
12429
|
+
const skills = [];
|
|
12430
|
+
const scan = new Bun.Glob("*/SKILL.md").scan({ cwd: skillsDir, followSymlinks: true });
|
|
12431
|
+
try {
|
|
12432
|
+
for await (const skillFile of scan) {
|
|
12433
|
+
skills.push(path4.dirname(skillFile));
|
|
12434
|
+
}
|
|
12435
|
+
} catch {}
|
|
12436
|
+
return skills;
|
|
12437
|
+
}
|
|
12438
|
+
|
|
12243
12439
|
// src/to-content-hash.ts
|
|
12244
12440
|
function toContentHash(bytes) {
|
|
12245
12441
|
return Bun.hash(bytes).toString(16);
|
|
@@ -12261,12 +12457,12 @@ async function readCommitHashes(git, commit, relativePaths) {
|
|
|
12261
12457
|
}
|
|
12262
12458
|
|
|
12263
12459
|
// src/read-committed-paths.ts
|
|
12264
|
-
import
|
|
12460
|
+
import path5 from "path";
|
|
12265
12461
|
async function readCommittedPaths(git, directory, from, to) {
|
|
12266
12462
|
const toRoot = await git.revparse(["--show-cdup"]);
|
|
12267
12463
|
const listArgs = from === null ? ["ls-tree", "-r", "--full-tree", "--name-only", "-z", to] : ["diff", "--name-only", "--no-renames", "-z", from, to];
|
|
12268
12464
|
const names = await git.raw(listArgs);
|
|
12269
|
-
return names.split("\x00").filter((entry) => entry !== "").map((entry) =>
|
|
12465
|
+
return names.split("\x00").filter((entry) => entry !== "").map((entry) => path5.join(directory, toRoot.trim(), entry));
|
|
12270
12466
|
}
|
|
12271
12467
|
|
|
12272
12468
|
// src/read-file-content.ts
|
|
@@ -12285,17 +12481,215 @@ async function readFileContent(filePath) {
|
|
|
12285
12481
|
}
|
|
12286
12482
|
|
|
12287
12483
|
// src/read-file-hashes.ts
|
|
12288
|
-
import
|
|
12484
|
+
import path6 from "path";
|
|
12289
12485
|
async function readFileHashes(readContent, projectDir, relativePaths) {
|
|
12290
12486
|
const entries = await Promise.all(relativePaths.map(async (relativePath) => {
|
|
12291
|
-
const content = await readContent(
|
|
12487
|
+
const content = await readContent(path6.join(projectDir, relativePath));
|
|
12292
12488
|
return [relativePath, content === null ? null : toContentHash(content)];
|
|
12293
12489
|
}));
|
|
12294
12490
|
return Object.fromEntries(entries);
|
|
12295
12491
|
}
|
|
12296
12492
|
|
|
12493
|
+
// src/read-project-dir.ts
|
|
12494
|
+
async function readProjectDir(cwd) {
|
|
12495
|
+
const fromEnv = process.env["CLAUDE_PROJECT_DIR"];
|
|
12496
|
+
if (fromEnv !== undefined && fromEnv !== "") {
|
|
12497
|
+
return fromEnv;
|
|
12498
|
+
}
|
|
12499
|
+
try {
|
|
12500
|
+
const output = await wo(cwd).revparse(["--show-toplevel"]);
|
|
12501
|
+
const topLevel = output.trim();
|
|
12502
|
+
return topLevel === "" ? cwd : topLevel;
|
|
12503
|
+
} catch {
|
|
12504
|
+
return cwd;
|
|
12505
|
+
}
|
|
12506
|
+
}
|
|
12507
|
+
|
|
12508
|
+
// src/collect-session-loads.ts
|
|
12509
|
+
function collectSessionLoads(transcript) {
|
|
12510
|
+
const entries = transcript.split(`
|
|
12511
|
+
`).map((line) => parseEntry(line));
|
|
12512
|
+
const lastBoundary = entries.findLastIndex((entry) => isCompactBoundary(entry));
|
|
12513
|
+
const current = entries.slice(lastBoundary + 1);
|
|
12514
|
+
const succeeded = collectSucceededToolUseIDs(current);
|
|
12515
|
+
const skills = current.flatMap((entry) => collectEntrySkills(entry, succeeded));
|
|
12516
|
+
const readPaths = current.flatMap((entry) => collectContentBlocks(entry, "assistant")).flatMap((block) => collectReadCall(block, succeeded));
|
|
12517
|
+
return {
|
|
12518
|
+
skills: [...new Set(skills)],
|
|
12519
|
+
readPaths: [...new Set(readPaths)],
|
|
12520
|
+
compacted: lastBoundary !== -1
|
|
12521
|
+
};
|
|
12522
|
+
}
|
|
12523
|
+
function parseEntry(line) {
|
|
12524
|
+
try {
|
|
12525
|
+
return JSON.parse(line);
|
|
12526
|
+
} catch {
|
|
12527
|
+
return null;
|
|
12528
|
+
}
|
|
12529
|
+
}
|
|
12530
|
+
function isCompactBoundary(entry) {
|
|
12531
|
+
return isRecord(entry) && entry["type"] === "system" && entry["subtype"] === "compact_boundary";
|
|
12532
|
+
}
|
|
12533
|
+
function collectSucceededToolUseIDs(entries) {
|
|
12534
|
+
return entries.flatMap((entry) => collectContentBlocks(entry, "user")).filter((block) => block["type"] === "tool_result" && block["is_error"] !== true).flatMap((block) => typeof block["tool_use_id"] === "string" ? [block["tool_use_id"]] : []);
|
|
12535
|
+
}
|
|
12536
|
+
function collectContentBlocks(entry, type) {
|
|
12537
|
+
if (!isRecord(entry) || entry["type"] !== type || !isRecord(entry["message"])) {
|
|
12538
|
+
return [];
|
|
12539
|
+
}
|
|
12540
|
+
const content = entry["message"]["content"];
|
|
12541
|
+
return Array.isArray(content) ? content.filter((block) => isRecord(block)) : [];
|
|
12542
|
+
}
|
|
12543
|
+
function collectEntrySkills(entry, succeeded) {
|
|
12544
|
+
const command = findSlashCommand(entry);
|
|
12545
|
+
if (command !== undefined) {
|
|
12546
|
+
return [command];
|
|
12547
|
+
}
|
|
12548
|
+
return collectContentBlocks(entry, "assistant").flatMap((block) => collectSkillCall(block, succeeded));
|
|
12549
|
+
}
|
|
12550
|
+
var SLASH_COMMAND_PATTERN = /^\s*(?:<command-message>[^<]*<\/command-message>\s*)?<command-name>\/(?<skill>[^<\s]+)<\/command-name>/u;
|
|
12551
|
+
function findSlashCommand(entry) {
|
|
12552
|
+
if (!isRecord(entry) || entry["type"] !== "user" || entry["isSidechain"] === true || !isRecord(entry["message"])) {
|
|
12553
|
+
return;
|
|
12554
|
+
}
|
|
12555
|
+
const content = entry["message"]["content"];
|
|
12556
|
+
return typeof content === "string" ? SLASH_COMMAND_PATTERN.exec(content)?.groups?.["skill"] : undefined;
|
|
12557
|
+
}
|
|
12558
|
+
function collectSkillCall(block, succeeded) {
|
|
12559
|
+
const input = block["input"];
|
|
12560
|
+
const id = block["id"];
|
|
12561
|
+
if (block["type"] !== "tool_use" || block["name"] !== "Skill" || !isRecord(input)) {
|
|
12562
|
+
return [];
|
|
12563
|
+
}
|
|
12564
|
+
const skill = input["skill"];
|
|
12565
|
+
return typeof skill === "string" && typeof id === "string" && succeeded.includes(id) ? [skill] : [];
|
|
12566
|
+
}
|
|
12567
|
+
function collectReadCall(block, succeeded) {
|
|
12568
|
+
const input = block["input"];
|
|
12569
|
+
const id = block["id"];
|
|
12570
|
+
if (block["type"] !== "tool_use" || block["name"] !== "Read" || !isRecord(input)) {
|
|
12571
|
+
return [];
|
|
12572
|
+
}
|
|
12573
|
+
const filePath = input["file_path"];
|
|
12574
|
+
return typeof filePath === "string" && typeof id === "string" && succeeded.includes(id) ? [filePath] : [];
|
|
12575
|
+
}
|
|
12576
|
+
|
|
12577
|
+
// src/load-ledger.ts
|
|
12578
|
+
import { mkdir, rename } from "fs/promises";
|
|
12579
|
+
import path7 from "path";
|
|
12580
|
+
var loadLedgerSchema = object({
|
|
12581
|
+
skills: array(string2()),
|
|
12582
|
+
readPaths: array(string2()),
|
|
12583
|
+
compacted: boolean2()
|
|
12584
|
+
});
|
|
12585
|
+
var EMPTY_LEDGER = { skills: [], readPaths: [], compacted: false };
|
|
12586
|
+
async function readLoadLedger(ledgerPath) {
|
|
12587
|
+
if (ledgerPath === null) {
|
|
12588
|
+
return EMPTY_LEDGER;
|
|
12589
|
+
}
|
|
12590
|
+
const text = await Bun.file(ledgerPath).text().catch(() => null);
|
|
12591
|
+
if (text === null) {
|
|
12592
|
+
return EMPTY_LEDGER;
|
|
12593
|
+
}
|
|
12594
|
+
try {
|
|
12595
|
+
const parsed = loadLedgerSchema.safeParse(JSON.parse(text));
|
|
12596
|
+
return parsed.success ? parsed.data : EMPTY_LEDGER;
|
|
12597
|
+
} catch {
|
|
12598
|
+
return EMPTY_LEDGER;
|
|
12599
|
+
}
|
|
12600
|
+
}
|
|
12601
|
+
async function writeLoadLedger(ledgerPath, ledger) {
|
|
12602
|
+
if (ledgerPath === null) {
|
|
12603
|
+
return;
|
|
12604
|
+
}
|
|
12605
|
+
try {
|
|
12606
|
+
await mkdir(path7.dirname(ledgerPath), { recursive: true });
|
|
12607
|
+
const tempPath = `${ledgerPath}.${process.pid}.tmp`;
|
|
12608
|
+
await Bun.write(tempPath, JSON.stringify(ledger));
|
|
12609
|
+
await rename(tempPath, ledgerPath);
|
|
12610
|
+
} catch {}
|
|
12611
|
+
}
|
|
12612
|
+
function addLoads(ledger, loads) {
|
|
12613
|
+
return {
|
|
12614
|
+
skills: [...new Set([...ledger.skills, ...loads.skills])],
|
|
12615
|
+
readPaths: [...new Set([...ledger.readPaths, ...loads.readPaths])],
|
|
12616
|
+
compacted: ledger.compacted
|
|
12617
|
+
};
|
|
12618
|
+
}
|
|
12619
|
+
function voidLoads() {
|
|
12620
|
+
return { skills: [], readPaths: [], compacted: true };
|
|
12621
|
+
}
|
|
12622
|
+
|
|
12623
|
+
// src/read-session-transcript.ts
|
|
12624
|
+
import path8 from "path";
|
|
12625
|
+
async function readSessionTranscript(hookInput) {
|
|
12626
|
+
if (hookInput.transcriptPath === null) {
|
|
12627
|
+
return "";
|
|
12628
|
+
}
|
|
12629
|
+
if (hookInput.agentID === undefined) {
|
|
12630
|
+
return readTranscript(hookInput.transcriptPath);
|
|
12631
|
+
}
|
|
12632
|
+
if (typeof hookInput.agentID !== "string" || !/^[\w-]+$/u.test(hookInput.agentID)) {
|
|
12633
|
+
return "";
|
|
12634
|
+
}
|
|
12635
|
+
const subagentsDir = path8.join(hookInput.transcriptPath.replace(/\.jsonl$/u, ""), "subagents");
|
|
12636
|
+
const transcriptName = `agent-${hookInput.agentID}.jsonl`;
|
|
12637
|
+
const agentTranscript = await readTranscript(path8.join(subagentsDir, transcriptName));
|
|
12638
|
+
if (agentTranscript !== "") {
|
|
12639
|
+
return agentTranscript;
|
|
12640
|
+
}
|
|
12641
|
+
return readWorkflowAgentTranscript(subagentsDir, transcriptName);
|
|
12642
|
+
}
|
|
12643
|
+
async function readTranscript(transcriptPath) {
|
|
12644
|
+
const transcriptFile = Bun.file(transcriptPath);
|
|
12645
|
+
const exists = await transcriptFile.exists();
|
|
12646
|
+
return exists ? transcriptFile.text() : "";
|
|
12647
|
+
}
|
|
12648
|
+
async function readWorkflowAgentTranscript(subagentsDir, transcriptName) {
|
|
12649
|
+
const scan = new Bun.Glob(`workflows/*/${transcriptName}`).scan({ cwd: subagentsDir });
|
|
12650
|
+
let transcriptPath = null;
|
|
12651
|
+
try {
|
|
12652
|
+
for await (const scannedPath of scan) {
|
|
12653
|
+
transcriptPath = scannedPath;
|
|
12654
|
+
break;
|
|
12655
|
+
}
|
|
12656
|
+
} catch {}
|
|
12657
|
+
return transcriptPath === null ? "" : readTranscript(path8.join(subagentsDir, transcriptPath));
|
|
12658
|
+
}
|
|
12659
|
+
|
|
12660
|
+
// src/resolve-state-dir.ts
|
|
12661
|
+
import { tmpdir } from "os";
|
|
12662
|
+
import path9 from "path";
|
|
12663
|
+
function resolveStateDir(hookInput) {
|
|
12664
|
+
if (hookInput.transcriptPath !== null) {
|
|
12665
|
+
const sessionDir = hookInput.transcriptPath.replace(/\.jsonl$/u, "");
|
|
12666
|
+
const folder = sessionDir === hookInput.transcriptPath ? `${sessionDir}.d` : sessionDir;
|
|
12667
|
+
return path9.join(folder, "skill-gate");
|
|
12668
|
+
}
|
|
12669
|
+
if (hookInput.sessionID === null || !/^[\w-]+$/u.test(hookInput.sessionID)) {
|
|
12670
|
+
return null;
|
|
12671
|
+
}
|
|
12672
|
+
return path9.join(tmpdir(), "skill-gate", hookInput.sessionID);
|
|
12673
|
+
}
|
|
12674
|
+
function resolveLedgerPath(hookInput) {
|
|
12675
|
+
const stateDir = resolveStateDir(hookInput);
|
|
12676
|
+
if (stateDir === null || hookInput.sessionID === null || !/^[\w-]+$/u.test(hookInput.sessionID)) {
|
|
12677
|
+
return null;
|
|
12678
|
+
}
|
|
12679
|
+
return path9.join(stateDir, `loads-${hookInput.sessionID}.json`);
|
|
12680
|
+
}
|
|
12681
|
+
|
|
12682
|
+
// src/read-session-loads.ts
|
|
12683
|
+
function readSessionLoads(hookInput) {
|
|
12684
|
+
return M3(hookInput.harness).with("claude-code", () => readClaudeLoads(hookInput)).with("codex", () => readLoadLedger(resolveLedgerPath(hookInput))).exhaustive();
|
|
12685
|
+
}
|
|
12686
|
+
async function readClaudeLoads(hookInput) {
|
|
12687
|
+
const transcript = await readSessionTranscript(hookInput);
|
|
12688
|
+
return collectSessionLoads(transcript);
|
|
12689
|
+
}
|
|
12690
|
+
|
|
12297
12691
|
// src/read-work-tree.ts
|
|
12298
|
-
import
|
|
12692
|
+
import path10 from "path";
|
|
12299
12693
|
async function readWorkTree(git, directory) {
|
|
12300
12694
|
const isWorkTree = await git.checkIsRepo();
|
|
12301
12695
|
if (!isWorkTree) {
|
|
@@ -12304,21 +12698,198 @@ async function readWorkTree(git, directory) {
|
|
|
12304
12698
|
const toRoot = await git.revparse(["--show-cdup"]);
|
|
12305
12699
|
const status = await git.status();
|
|
12306
12700
|
const head = await git.revparse(["--verify", "HEAD"]).catch(() => null);
|
|
12307
|
-
const dirtyPaths = status.files.flatMap((file) => file.from === undefined ? [file.path] : [file.path, file.from]).map((entry) =>
|
|
12701
|
+
const dirtyPaths = status.files.flatMap((file) => file.from === undefined ? [file.path] : [file.path, file.from]).map((entry) => path10.join(directory, toRoot.trim(), entry));
|
|
12308
12702
|
return { head: head?.trim() ?? null, dirtyPaths };
|
|
12309
12703
|
}
|
|
12310
12704
|
|
|
12705
|
+
// src/record-codex-loads.ts
|
|
12706
|
+
import { statSync } from "fs";
|
|
12707
|
+
import path14 from "path";
|
|
12708
|
+
|
|
12709
|
+
// src/classify-command-reads.ts
|
|
12710
|
+
import path11 from "path";
|
|
12711
|
+
function classifyCommandReads(readFiles, projectDir, references) {
|
|
12712
|
+
const skillRoots = [
|
|
12713
|
+
path11.join(projectDir, ".agents", "skills"),
|
|
12714
|
+
path11.join(projectDir, ".claude", "skills")
|
|
12715
|
+
];
|
|
12716
|
+
const claudeRoot = path11.join(projectDir, ".claude", "skills");
|
|
12717
|
+
const skills = readFiles.flatMap((file) => skillRoots.flatMap((root) => {
|
|
12718
|
+
const parts = path11.relative(root, file).split(path11.sep);
|
|
12719
|
+
const [name, fileName] = parts;
|
|
12720
|
+
return parts.length === 2 && name !== ".." && fileName === "SKILL.md" && name !== undefined ? [name] : [];
|
|
12721
|
+
}));
|
|
12722
|
+
const readPaths = readFiles.flatMap((file) => references.filter((reference) => skillRoots.some((root) => path11.resolve(root, reference) === file)).map((reference) => path11.resolve(claudeRoot, reference)));
|
|
12723
|
+
return { skills: [...new Set(skills)], readPaths: [...new Set(readPaths)] };
|
|
12724
|
+
}
|
|
12725
|
+
|
|
12726
|
+
// src/collect-command-reads.ts
|
|
12727
|
+
import path12 from "path";
|
|
12728
|
+
function collectCommandReads(command, cwd) {
|
|
12729
|
+
const commands = parseShellCommands(command, { withGuards: true }) ?? [];
|
|
12730
|
+
const reads = [];
|
|
12731
|
+
const parentDirs = [];
|
|
12732
|
+
let current = cwd;
|
|
12733
|
+
for (const entry of commands) {
|
|
12734
|
+
const enteredFrom = current;
|
|
12735
|
+
parentDirs.push(...Array.from({ length: entry.enters }, () => enteredFrom));
|
|
12736
|
+
if (current !== null && isSureToRun(entry)) {
|
|
12737
|
+
const directory = current;
|
|
12738
|
+
reads.push(...collectReaderPaths(entry).map((word) => path12.resolve(directory, word)));
|
|
12739
|
+
}
|
|
12740
|
+
current = resolveNextDir2(entry, current);
|
|
12741
|
+
for (let left = 0;left < entry.leaves && parentDirs.length > 0; left += 1) {
|
|
12742
|
+
current = parentDirs.pop() ?? null;
|
|
12743
|
+
}
|
|
12744
|
+
}
|
|
12745
|
+
return [...new Set(reads)];
|
|
12746
|
+
}
|
|
12747
|
+
function isSureToRun(command) {
|
|
12748
|
+
const guard = command.guard ?? null;
|
|
12749
|
+
return guard === null || !guard.viaOr && guard.before.every((words) => isSureToSucceed(words));
|
|
12750
|
+
}
|
|
12751
|
+
var SURE_PROGRAMS = new Set(["cd", "pushd", "true", ":", "export"]);
|
|
12752
|
+
var ASSIGNMENT2 = /^[A-Za-z_]\w*=/u;
|
|
12753
|
+
function isSureToSucceed(words) {
|
|
12754
|
+
const firstWord = words.find((word) => !ASSIGNMENT2.test(word.text));
|
|
12755
|
+
return firstWord !== undefined && firstWord.literal && SURE_PROGRAMS.has(firstWord.text);
|
|
12756
|
+
}
|
|
12757
|
+
var READERS = new Set(["cat", "head", "tail", "sed", "nl", "less", "bat"]);
|
|
12758
|
+
function collectReaderPaths(command) {
|
|
12759
|
+
const firstWord = command.words.findIndex((word) => !ASSIGNMENT2.test(word.text));
|
|
12760
|
+
const words = firstWord === -1 ? [] : command.words.slice(firstWord);
|
|
12761
|
+
const [program, ...args] = words;
|
|
12762
|
+
if (program === undefined || !program.literal) {
|
|
12763
|
+
return [];
|
|
12764
|
+
}
|
|
12765
|
+
const name = path12.basename(program.text);
|
|
12766
|
+
if (!READERS.has(name)) {
|
|
12767
|
+
return [];
|
|
12768
|
+
}
|
|
12769
|
+
const quiet = args.some((arg) => /^-[A-Za-z]*n[A-Za-z]*$/u.test(arg.text) || arg.text === "--quiet" || arg.text === "--silent");
|
|
12770
|
+
if (name === "sed" && !quiet) {
|
|
12771
|
+
return [];
|
|
12772
|
+
}
|
|
12773
|
+
const operands = args.filter((arg) => arg.literal && arg.text !== "" && !arg.text.startsWith("-")).map((arg) => arg.text);
|
|
12774
|
+
const redirected = command.redirects.filter((redirect) => redirect.operator === "<" && redirect.target.literal).map((redirect) => redirect.target.text);
|
|
12775
|
+
return [...operands, ...redirected];
|
|
12776
|
+
}
|
|
12777
|
+
function resolveNextDir2(command, directory) {
|
|
12778
|
+
const firstWord = command.words.findIndex((word) => !ASSIGNMENT2.test(word.text));
|
|
12779
|
+
const [program, ...args] = firstWord === -1 ? [] : command.words.slice(firstWord);
|
|
12780
|
+
if (program?.text !== "cd" || !program.literal) {
|
|
12781
|
+
return directory;
|
|
12782
|
+
}
|
|
12783
|
+
const target = args.find((arg) => !arg.text.startsWith("-"));
|
|
12784
|
+
if (target === undefined || !target.literal) {
|
|
12785
|
+
return null;
|
|
12786
|
+
}
|
|
12787
|
+
return directory === null && !path12.isAbsolute(target.text) ? null : path12.resolve(directory ?? "/", target.text);
|
|
12788
|
+
}
|
|
12789
|
+
|
|
12790
|
+
// src/collect-prompt-skills.ts
|
|
12791
|
+
var SKILL_MENTION = /(?<![\w$])\$(?<skill>[\w][\w:.-]*)/gu;
|
|
12792
|
+
function collectPromptSkills(prompt) {
|
|
12793
|
+
const names = [...prompt.matchAll(SKILL_MENTION)].flatMap((found) => {
|
|
12794
|
+
const name = found.groups?.["skill"]?.replace(/[.:-]+$/u, "");
|
|
12795
|
+
return name === undefined || name === "" ? [] : [name];
|
|
12796
|
+
});
|
|
12797
|
+
return [...new Set(names)];
|
|
12798
|
+
}
|
|
12799
|
+
|
|
12800
|
+
// src/with-ledger-lock.ts
|
|
12801
|
+
import { mkdir as mkdir2, rmdir, stat } from "fs/promises";
|
|
12802
|
+
import path13 from "path";
|
|
12803
|
+
async function withLedgerLock(ledgerPath, job) {
|
|
12804
|
+
if (ledgerPath === null) {
|
|
12805
|
+
return job();
|
|
12806
|
+
}
|
|
12807
|
+
const lockPath = `${ledgerPath}.lock`;
|
|
12808
|
+
const held = await acquireLock(lockPath);
|
|
12809
|
+
try {
|
|
12810
|
+
return await job();
|
|
12811
|
+
} finally {
|
|
12812
|
+
if (held) {
|
|
12813
|
+
await rmdir(lockPath).catch(() => null);
|
|
12814
|
+
}
|
|
12815
|
+
}
|
|
12816
|
+
}
|
|
12817
|
+
var RETRY_MS = 10;
|
|
12818
|
+
var GIVE_UP_MS = 5000;
|
|
12819
|
+
var STALE_MS = 30000;
|
|
12820
|
+
async function acquireLock(lockPath) {
|
|
12821
|
+
try {
|
|
12822
|
+
await mkdir2(path13.dirname(lockPath), { recursive: true });
|
|
12823
|
+
} catch {
|
|
12824
|
+
return false;
|
|
12825
|
+
}
|
|
12826
|
+
const deadline = Date.now() + GIVE_UP_MS;
|
|
12827
|
+
while (Date.now() < deadline) {
|
|
12828
|
+
try {
|
|
12829
|
+
await mkdir2(lockPath);
|
|
12830
|
+
return true;
|
|
12831
|
+
} catch {
|
|
12832
|
+
const info = await stat(lockPath).catch(() => null);
|
|
12833
|
+
const isStale = info !== null && Date.now() - info.mtimeMs > STALE_MS;
|
|
12834
|
+
await (isStale ? rmdir(lockPath).catch(() => null) : Bun.sleep(RETRY_MS));
|
|
12835
|
+
}
|
|
12836
|
+
}
|
|
12837
|
+
return false;
|
|
12838
|
+
}
|
|
12839
|
+
|
|
12840
|
+
// src/record-codex-loads.ts
|
|
12841
|
+
async function recordLifecycle(input, projectDir) {
|
|
12842
|
+
const ledgerPath = resolveLedgerPath(input);
|
|
12843
|
+
await M3(input.event).with("PostCompact", () => withLedgerLock(ledgerPath, () => writeLoadLedger(ledgerPath, voidLoads()))).with("UserPromptSubmit", async () => {
|
|
12844
|
+
const mentioned = collectPromptSkills(input.prompt ?? "");
|
|
12845
|
+
if (mentioned.length === 0) {
|
|
12846
|
+
return;
|
|
12847
|
+
}
|
|
12848
|
+
const present = new Set([
|
|
12849
|
+
...await readAvailableSkills(path14.join(projectDir, ".agents", "skills")),
|
|
12850
|
+
...await readAvailableSkills(path14.join(projectDir, ".claude", "skills"))
|
|
12851
|
+
]);
|
|
12852
|
+
const skills = mentioned.filter((skill) => present.has(skill));
|
|
12853
|
+
if (skills.length > 0) {
|
|
12854
|
+
await addLedgerLoads(ledgerPath, { skills, readPaths: [] });
|
|
12855
|
+
}
|
|
12856
|
+
}).exhaustive();
|
|
12857
|
+
}
|
|
12858
|
+
async function recordCommandReads(input, command, projectDir, rulesText) {
|
|
12859
|
+
const parsedRules = parseSkillGateRules(rulesText);
|
|
12860
|
+
const references = parsedRules.ok ? parsedRules.tools.flatMap((gate) => gate.references) : [];
|
|
12861
|
+
const readFiles = collectCommandReads(command, input.cwd).filter((file) => statSync(file, { throwIfNoEntry: false })?.isFile() === true);
|
|
12862
|
+
const reads = classifyCommandReads(readFiles, projectDir, references);
|
|
12863
|
+
if (reads.skills.length === 0 && reads.readPaths.length === 0) {
|
|
12864
|
+
return;
|
|
12865
|
+
}
|
|
12866
|
+
await addLedgerLoads(resolveLedgerPath(input), reads);
|
|
12867
|
+
}
|
|
12868
|
+
async function addLedgerLoads(ledgerPath, loads) {
|
|
12869
|
+
await withLedgerLock(ledgerPath, async () => {
|
|
12870
|
+
const ledger = await readLoadLedger(ledgerPath);
|
|
12871
|
+
await writeLoadLedger(ledgerPath, addLoads(ledger, loads));
|
|
12872
|
+
});
|
|
12873
|
+
}
|
|
12874
|
+
|
|
12311
12875
|
// src/run-skill-gate.ts
|
|
12312
|
-
async function runSkillGate() {
|
|
12876
|
+
async function runSkillGate(harness = "claude-code") {
|
|
12313
12877
|
const payload = await Bun.stdin.json().catch(() => null);
|
|
12314
|
-
const
|
|
12315
|
-
if (
|
|
12878
|
+
const parsedInput = parseHookInput(harness, payload);
|
|
12879
|
+
if (parsedInput === null) {
|
|
12316
12880
|
process.exit(0);
|
|
12317
12881
|
}
|
|
12318
12882
|
process.env["GIT_OPTIONAL_LOCKS"] = "0";
|
|
12319
|
-
const projectDir =
|
|
12320
|
-
const rulesFile = Bun.file(
|
|
12883
|
+
const projectDir = await readProjectDir(parsedInput.cwd);
|
|
12884
|
+
const rulesFile = Bun.file(path15.join(projectDir, ".claude", "skill-gate.json"));
|
|
12321
12885
|
const hasRules = await rulesFile.exists();
|
|
12886
|
+
if (parsedInput.kind === "lifecycle") {
|
|
12887
|
+
if (hasRules) {
|
|
12888
|
+
await recordLifecycle(parsedInput, projectDir);
|
|
12889
|
+
}
|
|
12890
|
+
process.exit(0);
|
|
12891
|
+
}
|
|
12892
|
+
const input = parsedInput;
|
|
12322
12893
|
if (hasRules && input.toolName !== null && input.event === "PreToolUse") {
|
|
12323
12894
|
await checkToolCall({
|
|
12324
12895
|
hookInput: input,
|
|
@@ -12328,72 +12899,45 @@ async function runSkillGate() {
|
|
|
12328
12899
|
});
|
|
12329
12900
|
}
|
|
12330
12901
|
if (hasRules && input.command !== null) {
|
|
12331
|
-
await
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
});
|
|
12902
|
+
const rulesText = await rulesFile.text();
|
|
12903
|
+
if (input.harness === "codex" && input.event === "PostToolUse") {
|
|
12904
|
+
await recordCommandReads(input, input.command, projectDir, rulesText);
|
|
12905
|
+
}
|
|
12906
|
+
await checkBash({ hookInput: input, command: input.command, projectDir, rulesText });
|
|
12337
12907
|
}
|
|
12338
|
-
if (input.
|
|
12908
|
+
if (input.editPaths.length === 0 || input.event !== "PreToolUse") {
|
|
12339
12909
|
process.exit(0);
|
|
12340
12910
|
}
|
|
12341
|
-
const
|
|
12342
|
-
|
|
12343
|
-
if (!hasRules || isOutsideProject(relativePath)) {
|
|
12911
|
+
const edits = input.editPaths.map((editPath) => path15.resolve(input.cwd, editPath)).map((filePath) => ({ filePath, relativePath: toProjectPath(projectDir, filePath) })).filter((edit) => !isOutsideProject(edit.relativePath));
|
|
12912
|
+
if (!hasRules || edits.length === 0) {
|
|
12344
12913
|
process.exit(0);
|
|
12345
12914
|
}
|
|
12346
12915
|
const rulesText = await rulesFile.text();
|
|
12347
12916
|
const parsed = parseSkillGateRules(rulesText);
|
|
12348
12917
|
if (!parsed.ok) {
|
|
12349
|
-
|
|
12918
|
+
const emptyPlan = { missing: [], unknown: [] };
|
|
12919
|
+
const unchecked = edits.map((edit) => ({ filePath: edit.filePath, plan: emptyPlan }));
|
|
12920
|
+
printOutput(buildEditOutput(input.harness, unchecked, { rulesError: parsed.error }));
|
|
12350
12921
|
process.exit(0);
|
|
12351
12922
|
}
|
|
12352
|
-
const availableSkills = await readAvailableSkills(
|
|
12353
|
-
const
|
|
12354
|
-
const
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
12923
|
+
const availableSkills = await readAvailableSkills(path15.join(projectDir, ".claude", "skills"));
|
|
12924
|
+
const loaded = await readSessionLoads(input);
|
|
12925
|
+
const entries = edits.map((edit) => ({
|
|
12926
|
+
filePath: edit.filePath,
|
|
12927
|
+
plan: planSkillGate({
|
|
12928
|
+
rules: parsed.rules,
|
|
12929
|
+
relativePath: edit.relativePath,
|
|
12930
|
+
loadedSkills: loaded.skills,
|
|
12931
|
+
availableSkills
|
|
12932
|
+
})
|
|
12933
|
+
}));
|
|
12934
|
+
printOutput(buildEditOutput(input.harness, entries, {
|
|
12362
12935
|
compacted: loaded.compacted,
|
|
12363
12936
|
unknownKeys: parsed.unknownKeys
|
|
12364
12937
|
}));
|
|
12365
12938
|
process.exit(0);
|
|
12366
12939
|
}
|
|
12367
|
-
|
|
12368
|
-
if (!isRecord(value) || !isRecord(value["tool_input"])) {
|
|
12369
|
-
return null;
|
|
12370
|
-
}
|
|
12371
|
-
const cwd = value["cwd"];
|
|
12372
|
-
const transcriptPath = value["transcript_path"];
|
|
12373
|
-
const editPath = value["tool_input"]["file_path"];
|
|
12374
|
-
const command = value["tool_input"]["command"];
|
|
12375
|
-
const toolName = value["tool_name"];
|
|
12376
|
-
if (typeof cwd !== "string" || typeof transcriptPath !== "string") {
|
|
12377
|
-
return null;
|
|
12378
|
-
}
|
|
12379
|
-
if (typeof editPath !== "string" && typeof command !== "string" && typeof toolName !== "string") {
|
|
12380
|
-
return null;
|
|
12381
|
-
}
|
|
12382
|
-
return {
|
|
12383
|
-
event: pickHookEvent(value["hook_event_name"]),
|
|
12384
|
-
toolName: typeof toolName === "string" ? toolName : null,
|
|
12385
|
-
cwd,
|
|
12386
|
-
filePath: typeof editPath === "string" ? editPath : null,
|
|
12387
|
-
command: typeof command === "string" ? command : null,
|
|
12388
|
-
transcriptPath,
|
|
12389
|
-
toolUseID: value["tool_use_id"],
|
|
12390
|
-
agentID: value["agent_id"]
|
|
12391
|
-
};
|
|
12392
|
-
}
|
|
12393
|
-
function pickHookEvent(value) {
|
|
12394
|
-
return value === "PostToolUse" || value === "PostToolUseFailure" ? value : "PreToolUse";
|
|
12395
|
-
}
|
|
12396
|
-
var PATH_GATED_TOOLS2 = new Set(["Edit", "Write", "MultiEdit", "Bash"]);
|
|
12940
|
+
var PATH_GATED_TOOLS2 = new Set(["Edit", "Write", "MultiEdit", "Bash", "apply_patch"]);
|
|
12397
12941
|
async function checkToolCall(check) {
|
|
12398
12942
|
const parsedRules = parseSkillGateRules(check.rulesText);
|
|
12399
12943
|
if (!parsedRules.ok) {
|
|
@@ -12406,9 +12950,8 @@ async function checkToolCall(check) {
|
|
|
12406
12950
|
if (!parsedRules.tools.some((gate) => gate.tool === check.toolName)) {
|
|
12407
12951
|
return;
|
|
12408
12952
|
}
|
|
12409
|
-
const skillsDir =
|
|
12410
|
-
const
|
|
12411
|
-
const loads = collectSessionLoads(transcript);
|
|
12953
|
+
const skillsDir = path15.join(check.projectDir, ".claude", "skills");
|
|
12954
|
+
const loads = await readSessionLoads(check.hookInput);
|
|
12412
12955
|
const plan = planToolGate({
|
|
12413
12956
|
tools: parsedRules.tools,
|
|
12414
12957
|
toolName: check.toolName,
|
|
@@ -12418,6 +12961,7 @@ async function checkToolCall(check) {
|
|
|
12418
12961
|
availableReferences: await readAvailableReferences(readFileContent, skillsDir, parsedRules.tools)
|
|
12419
12962
|
});
|
|
12420
12963
|
printOutput(buildToolGateOutput(check.toolName, plan, {
|
|
12964
|
+
harness: check.hookInput.harness,
|
|
12421
12965
|
compacted: loads.compacted,
|
|
12422
12966
|
unknownKeys: parsedRules.unknownKeys
|
|
12423
12967
|
}));
|
|
@@ -12428,47 +12972,6 @@ function printOutput(output) {
|
|
|
12428
12972
|
console.log(JSON.stringify(output));
|
|
12429
12973
|
}
|
|
12430
12974
|
}
|
|
12431
|
-
async function readSessionTranscript(hookInput) {
|
|
12432
|
-
if (hookInput.agentID === undefined) {
|
|
12433
|
-
return readTranscript(hookInput.transcriptPath);
|
|
12434
|
-
}
|
|
12435
|
-
if (typeof hookInput.agentID !== "string" || !/^[\w-]+$/u.test(hookInput.agentID)) {
|
|
12436
|
-
return "";
|
|
12437
|
-
}
|
|
12438
|
-
const subagentsDir = path7.join(hookInput.transcriptPath.replace(/\.jsonl$/u, ""), "subagents");
|
|
12439
|
-
const transcriptName = `agent-${hookInput.agentID}.jsonl`;
|
|
12440
|
-
const agentTranscript = await readTranscript(path7.join(subagentsDir, transcriptName));
|
|
12441
|
-
if (agentTranscript !== "") {
|
|
12442
|
-
return agentTranscript;
|
|
12443
|
-
}
|
|
12444
|
-
return readWorkflowAgentTranscript(subagentsDir, transcriptName);
|
|
12445
|
-
}
|
|
12446
|
-
async function readTranscript(transcriptPath) {
|
|
12447
|
-
const transcriptFile = Bun.file(transcriptPath);
|
|
12448
|
-
const exists = await transcriptFile.exists();
|
|
12449
|
-
return exists ? transcriptFile.text() : "";
|
|
12450
|
-
}
|
|
12451
|
-
async function readWorkflowAgentTranscript(subagentsDir, transcriptName) {
|
|
12452
|
-
const scan = new Bun.Glob(`workflows/*/${transcriptName}`).scan({ cwd: subagentsDir });
|
|
12453
|
-
let transcriptPath = null;
|
|
12454
|
-
try {
|
|
12455
|
-
for await (const scannedPath of scan) {
|
|
12456
|
-
transcriptPath = scannedPath;
|
|
12457
|
-
break;
|
|
12458
|
-
}
|
|
12459
|
-
} catch {}
|
|
12460
|
-
return transcriptPath === null ? "" : readTranscript(path7.join(subagentsDir, transcriptPath));
|
|
12461
|
-
}
|
|
12462
|
-
async function readAvailableSkills(skillsDir) {
|
|
12463
|
-
const skills = [];
|
|
12464
|
-
const scan = new Bun.Glob("*/SKILL.md").scan({ cwd: skillsDir, followSymlinks: true });
|
|
12465
|
-
try {
|
|
12466
|
-
for await (const skillFile of scan) {
|
|
12467
|
-
skills.push(path7.dirname(skillFile));
|
|
12468
|
-
}
|
|
12469
|
-
} catch {}
|
|
12470
|
-
return skills;
|
|
12471
|
-
}
|
|
12472
12975
|
async function checkBash(check) {
|
|
12473
12976
|
const parsedRules = parseSkillGateRules(check.rulesText);
|
|
12474
12977
|
if (!parsedRules.ok) {
|
|
@@ -12495,8 +12998,8 @@ function resolveSnapshotPath(hookInput) {
|
|
|
12495
12998
|
if (typeof hookInput.toolUseID !== "string" || !/^[\w-]+$/u.test(hookInput.toolUseID)) {
|
|
12496
12999
|
return null;
|
|
12497
13000
|
}
|
|
12498
|
-
const
|
|
12499
|
-
return
|
|
13001
|
+
const stateDir = resolveStateDir(hookInput);
|
|
13002
|
+
return stateDir === null ? null : path15.join(stateDir, `${hookInput.toolUseID}.json`);
|
|
12500
13003
|
}
|
|
12501
13004
|
async function writeGatedSnapshot(git, snapshotPath, projectDir, rules) {
|
|
12502
13005
|
const snapshot = await readGatedSnapshot(git, projectDir, rules);
|
|
@@ -12504,7 +13007,7 @@ async function writeGatedSnapshot(git, snapshotPath, projectDir, rules) {
|
|
|
12504
13007
|
return;
|
|
12505
13008
|
}
|
|
12506
13009
|
try {
|
|
12507
|
-
await
|
|
13010
|
+
await mkdir3(path15.dirname(snapshotPath), { recursive: true });
|
|
12508
13011
|
await Bun.write(snapshotPath, JSON.stringify(snapshot));
|
|
12509
13012
|
} catch {
|
|
12510
13013
|
await rm(snapshotPath, { force: true });
|
|
@@ -12529,10 +13032,10 @@ function collectGatedProjectPaths(projectDir, rules, absolutePaths) {
|
|
|
12529
13032
|
return [...new Set(absolutePaths.map((entry) => toProjectPath(projectDir, entry)))].filter((relativePath) => !isOutsideProject(relativePath) && collectGateSkills(rules, relativePath).length > 0);
|
|
12530
13033
|
}
|
|
12531
13034
|
function toProjectPath(projectDir, absolute) {
|
|
12532
|
-
return
|
|
13035
|
+
return path15.relative(projectDir, absolute).split(path15.sep).join("/");
|
|
12533
13036
|
}
|
|
12534
13037
|
function isOutsideProject(fromProject) {
|
|
12535
|
-
return fromProject === ".." || fromProject.startsWith("../") ||
|
|
13038
|
+
return fromProject === ".." || fromProject.startsWith("../") || path15.isAbsolute(fromProject);
|
|
12536
13039
|
}
|
|
12537
13040
|
async function checkBashCommand(check, rules) {
|
|
12538
13041
|
const written = collectWrittenPaths(check.command).map((entry) => readWrittenPath(check.hookInput.cwd, entry));
|
|
@@ -12540,9 +13043,8 @@ async function checkBashCommand(check, rules) {
|
|
|
12540
13043
|
if (candidates.length === 0) {
|
|
12541
13044
|
return;
|
|
12542
13045
|
}
|
|
12543
|
-
const skills = await readAvailableSkills(
|
|
12544
|
-
const
|
|
12545
|
-
const sessionLoads = collectSessionLoads(sessionTranscript);
|
|
13046
|
+
const skills = await readAvailableSkills(path15.join(check.projectDir, ".claude", "skills"));
|
|
13047
|
+
const sessionLoads = await readSessionLoads(check.hookInput);
|
|
12546
13048
|
const bashPlan = planBashSkillGate({
|
|
12547
13049
|
rules,
|
|
12548
13050
|
paths: candidates.map((entry) => ({
|
|
@@ -12553,16 +13055,17 @@ async function checkBashCommand(check, rules) {
|
|
|
12553
13055
|
availableSkills: skills
|
|
12554
13056
|
});
|
|
12555
13057
|
printOutput(buildBashSkillGateOutput(bashPlan.gatedPaths, bashPlan.missing, {
|
|
13058
|
+
harness: check.hookInput.harness,
|
|
12556
13059
|
compacted: sessionLoads.compacted
|
|
12557
13060
|
}));
|
|
12558
13061
|
}
|
|
12559
13062
|
function readWrittenPath(cwd, written) {
|
|
12560
|
-
const absolute =
|
|
13063
|
+
const absolute = path15.resolve(cwd, written.path);
|
|
12561
13064
|
if (written.fileName === undefined) {
|
|
12562
13065
|
return absolute;
|
|
12563
13066
|
}
|
|
12564
|
-
const isDirectory =
|
|
12565
|
-
return isDirectory ?
|
|
13067
|
+
const isDirectory = statSync2(absolute, { throwIfNoEntry: false })?.isDirectory() === true;
|
|
13068
|
+
return isDirectory ? path15.join(absolute, written.fileName) : absolute;
|
|
12566
13069
|
}
|
|
12567
13070
|
async function checkBashResult(check, rules, result) {
|
|
12568
13071
|
const record = await readSnapshot(result.snapshotPath);
|
|
@@ -12595,19 +13098,19 @@ async function runBashResultStep(check, rules, result, step) {
|
|
|
12595
13098
|
}).with({ kind: "gate" }, (gate) => checkChangedPaths(check, rules, result, gate.changedPaths)).exhaustive();
|
|
12596
13099
|
}
|
|
12597
13100
|
async function checkChangedPaths(check, rules, result, changedPaths) {
|
|
12598
|
-
const skills = await readAvailableSkills(
|
|
12599
|
-
const
|
|
12600
|
-
const sessionLoads = collectSessionLoads(sessionTranscript);
|
|
13101
|
+
const skills = await readAvailableSkills(path15.join(check.projectDir, ".claude", "skills"));
|
|
13102
|
+
const sessionLoads = await readSessionLoads(check.hookInput);
|
|
12601
13103
|
const changePlan = planBashSkillGate({
|
|
12602
13104
|
rules,
|
|
12603
13105
|
paths: changedPaths.map((relativePath) => ({
|
|
12604
|
-
path:
|
|
13106
|
+
path: path15.join(check.projectDir, relativePath),
|
|
12605
13107
|
relativePath
|
|
12606
13108
|
})),
|
|
12607
13109
|
loadedSkills: sessionLoads.skills,
|
|
12608
13110
|
availableSkills: skills
|
|
12609
13111
|
});
|
|
12610
13112
|
printOutput(buildBashChangeOutput(result.event, changePlan.gatedPaths, changePlan.missing, {
|
|
13113
|
+
harness: check.hookInput.harness,
|
|
12611
13114
|
compacted: sessionLoads.compacted
|
|
12612
13115
|
}));
|
|
12613
13116
|
}
|