@hasna/hooks 0.14.1 → 0.15.1
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 +30 -10
- package/bin/hooks/stop-review.js +17 -9
- package/bin/hooks-mcp.js +741 -311
- package/bin/index.js +1669 -632
- package/bin/native-safety-entry.js +2 -2
- package/bin/native-safety-worker.cjs +37 -35
- package/bin/release-manifest.json +297 -0
- package/bin/serve.js +577 -151
- package/dist/index.js +1809 -1176
- package/dist/lib/error-events.d.ts +59 -0
- package/dist/lib/install-record.d.ts +136 -0
- package/dist/lib/manifest.d.ts +6 -0
- package/dist/lib/release-manifest.d.ts +162 -0
- package/dist/lib/store.d.ts +25 -2
- package/dist/openapi.d.ts +147 -0
- package/dist/registry-auth.d.ts +6 -1
- package/dist/registry-http.d.ts +2 -1
- package/dist/sdk/generated.d.ts +26 -0
- package/dist/sdk/index.js +14 -0
- package/hooks/codewith-native-common.ts +190 -6
- package/hooks/hook-signed-link-guard/README.md +46 -0
- package/hooks/hook-signed-link-guard/src/classify.ts +7 -3
- package/hooks/hook-signed-link-guard/src/jq.ts +205 -34
- package/hooks/hook-stop-review/README.md +5 -2
- package/hooks/hook-stop-review/src/jev.ts +9 -4
- package/hooks/hook-stop-review/src/policy.ts +7 -3
- package/hooks/hook-stop-review/src/runtime.ts +5 -4
- package/hooks/hook-trash-guard/README.md +15 -10
- package/hooks/hook-trash-guard/src/hook.ts +130 -12
- package/hooks/hook-workspace-repos-guard/src/hook.ts +27 -12
- package/hooks/pre-bash/README.md +47 -1
- package/hooks/pre-bash/src/hook.ts +168 -12
- package/hooks/shell-words.ts +40 -2
- package/package.json +3 -2
- package/scripts/build-release-manifest.ts +27 -0
- package/scripts/validate-package.ts +5 -1
- package/scripts/validate-release-manifest.ts +67 -0
package/bin/hooks-mcp.js
CHANGED
|
@@ -806,7 +806,7 @@ var init_semver = __esm(() => {
|
|
|
806
806
|
});
|
|
807
807
|
|
|
808
808
|
// src/lib/manifest.ts
|
|
809
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from "fs";
|
|
809
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "fs";
|
|
810
810
|
import { basename, dirname, isAbsolute, join as join3, normalize, resolve as resolve2, sep } from "path";
|
|
811
811
|
import { z } from "zod";
|
|
812
812
|
function parseManifest(json) {
|
|
@@ -900,7 +900,7 @@ function readCustomManifest(name) {
|
|
|
900
900
|
return;
|
|
901
901
|
}
|
|
902
902
|
}
|
|
903
|
-
var HOOK_NAME_RE, manifestSchema, ScriptContainmentError, HookIdentityError;
|
|
903
|
+
var HOOK_NAME_RE, INSTALL_RECORD_FILE = ".hooks-install.json", manifestSchema, ScriptContainmentError, HookIdentityError;
|
|
904
904
|
var init_manifest = __esm(() => {
|
|
905
905
|
init_config();
|
|
906
906
|
init_semver();
|
|
@@ -1457,6 +1457,239 @@ var init_db = __esm(() => {
|
|
|
1457
1457
|
init_legacy_import();
|
|
1458
1458
|
});
|
|
1459
1459
|
|
|
1460
|
+
// src/lib/install-record.ts
|
|
1461
|
+
var exports_install_record = {};
|
|
1462
|
+
__export(exports_install_record, {
|
|
1463
|
+
withStableInstall: () => withStableInstall,
|
|
1464
|
+
readInstallRecord: () => readInstallRecord,
|
|
1465
|
+
inspectInstall: () => inspectInstall,
|
|
1466
|
+
finishInstall: () => finishInstall,
|
|
1467
|
+
commitInstall: () => commitInstall,
|
|
1468
|
+
InstallRecordError: () => InstallRecordError,
|
|
1469
|
+
INSTALL_RECORD_SCHEMA: () => INSTALL_RECORD_SCHEMA,
|
|
1470
|
+
INSTALL_RECORD_FILE: () => INSTALL_RECORD_FILE
|
|
1471
|
+
});
|
|
1472
|
+
import { createHash as createHash5, randomBytes as randomBytes2 } from "crypto";
|
|
1473
|
+
import { closeSync as closeSync3, fsyncSync, lstatSync as lstatSync4, mkdirSync as mkdirSync4, openSync as openSync3, readFileSync as readFileSync6, renameSync as renameSync2, rmSync as rmSync2, writeSync } from "fs";
|
|
1474
|
+
import { dirname as dirname7, isAbsolute as isAbsolute4, join as join11, resolve as resolve5, sep as sep3 } from "path";
|
|
1475
|
+
function sha2562(bytes) {
|
|
1476
|
+
return createHash5("sha256").update(bytes).digest("hex");
|
|
1477
|
+
}
|
|
1478
|
+
function recordPath(name) {
|
|
1479
|
+
return join11(customHookDir(name), INSTALL_RECORD_FILE);
|
|
1480
|
+
}
|
|
1481
|
+
function hashOrNull(path) {
|
|
1482
|
+
try {
|
|
1483
|
+
if (!lstatSync4(path).isFile())
|
|
1484
|
+
return NOT_A_FILE;
|
|
1485
|
+
return sha2562(readFileSync6(path));
|
|
1486
|
+
} catch (error) {
|
|
1487
|
+
if (error.code === "ENOENT")
|
|
1488
|
+
return null;
|
|
1489
|
+
throw error;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
function writeFileAtomic(path, bytes, mode) {
|
|
1493
|
+
const tmp = `${path}.tmp-${randomBytes2(8).toString("hex")}`;
|
|
1494
|
+
const fd = openSync3(tmp, "wx", mode);
|
|
1495
|
+
try {
|
|
1496
|
+
writeSync(fd, typeof bytes === "string" ? Buffer.from(bytes, "utf8") : bytes);
|
|
1497
|
+
fsyncSync(fd);
|
|
1498
|
+
} finally {
|
|
1499
|
+
closeSync3(fd);
|
|
1500
|
+
}
|
|
1501
|
+
try {
|
|
1502
|
+
renameSync2(tmp, path);
|
|
1503
|
+
} catch (error) {
|
|
1504
|
+
rmSync2(tmp, { force: true });
|
|
1505
|
+
throw error;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
function scriptPathIn(dir, rel) {
|
|
1509
|
+
if (isAbsolute4(rel))
|
|
1510
|
+
throw new ScriptContainmentError(rel, dir);
|
|
1511
|
+
const target = resolve5(dir, rel);
|
|
1512
|
+
if (target === resolve5(dir) || !target.startsWith(resolve5(dir) + sep3))
|
|
1513
|
+
throw new ScriptContainmentError(rel, dir);
|
|
1514
|
+
if (target === join11(resolve5(dir), "manifest.json") || target === join11(resolve5(dir), INSTALL_RECORD_FILE)) {
|
|
1515
|
+
throw new ScriptContainmentError(rel, dir);
|
|
1516
|
+
}
|
|
1517
|
+
return target;
|
|
1518
|
+
}
|
|
1519
|
+
function readInstallRecord(name) {
|
|
1520
|
+
const path = recordPath(name);
|
|
1521
|
+
let raw;
|
|
1522
|
+
try {
|
|
1523
|
+
if (!lstatSync4(path).isFile())
|
|
1524
|
+
throw new InstallRecordError(`install record (${path}) is not a regular file`);
|
|
1525
|
+
raw = readFileSync6(path, "utf8");
|
|
1526
|
+
} catch (error) {
|
|
1527
|
+
if (error.code === "ENOENT")
|
|
1528
|
+
return null;
|
|
1529
|
+
throw error instanceof InstallRecordError ? error : new InstallRecordError(`install record (${path}) could not be read`);
|
|
1530
|
+
}
|
|
1531
|
+
let value;
|
|
1532
|
+
try {
|
|
1533
|
+
value = JSON.parse(raw);
|
|
1534
|
+
} catch {
|
|
1535
|
+
throw new InstallRecordError(`install record (${path}) is not valid JSON`);
|
|
1536
|
+
}
|
|
1537
|
+
const isHash = (v) => typeof v === "string" && /^[0-9a-f]{64}$/.test(v);
|
|
1538
|
+
const isHashOrNull = (v) => v === null || isHash(v);
|
|
1539
|
+
if (value === null || typeof value !== "object" || value.schema !== INSTALL_RECORD_SCHEMA || typeof value.name !== "string" || typeof value.version !== "string" || typeof value.source !== "string" || value.script === null || typeof value.script !== "object" || typeof value.script.path !== "string" || !isHash(value.script.sha256) || typeof value.script.content_base64 !== "string" || value.manifest === null || typeof value.manifest !== "object" || !isHash(value.manifest.sha256) || typeof value.manifest.content_base64 !== "string" || value.replaces === null || typeof value.replaces !== "object" || !isHashOrNull(value.replaces.script_sha256) || !isHashOrNull(value.replaces.manifest_sha256)) {
|
|
1540
|
+
throw new InstallRecordError(`install record (${path}) is malformed`);
|
|
1541
|
+
}
|
|
1542
|
+
if (value.name !== shortManifestName(name))
|
|
1543
|
+
throw new InstallRecordError(`install record (${path}) names another hook`);
|
|
1544
|
+
const script = Buffer.from(value.script.content_base64, "base64");
|
|
1545
|
+
const manifest = Buffer.from(value.manifest.content_base64, "base64");
|
|
1546
|
+
if (sha2562(script) !== value.script.sha256 || sha2562(manifest) !== value.manifest.sha256) {
|
|
1547
|
+
throw new InstallRecordError(`install record (${path}) does not hash to what it records`);
|
|
1548
|
+
}
|
|
1549
|
+
let parsed;
|
|
1550
|
+
try {
|
|
1551
|
+
parsed = parseManifest(manifest.toString("utf8"));
|
|
1552
|
+
} catch {
|
|
1553
|
+
throw new InstallRecordError(`install record (${path}) holds an invalid manifest`);
|
|
1554
|
+
}
|
|
1555
|
+
if (shortManifestName(parsed.name) !== value.name || scriptRelFor(parsed) !== value.script.path) {
|
|
1556
|
+
throw new InstallRecordError(`install record (${path}) does not agree with the manifest it holds`);
|
|
1557
|
+
}
|
|
1558
|
+
scriptPathIn(customHookDir(name), value.script.path);
|
|
1559
|
+
return value;
|
|
1560
|
+
}
|
|
1561
|
+
function commitInstall(name, manifest, scriptContent, scriptRelPath, options) {
|
|
1562
|
+
const short = shortManifestName(name);
|
|
1563
|
+
const dir = customHookDir(short);
|
|
1564
|
+
if (scriptRelPath !== scriptRelFor(manifest)) {
|
|
1565
|
+
throw new InstallRecordError(`'${short}' cannot be installed: script path '${scriptRelPath}' is not the one its manifest resolves to`);
|
|
1566
|
+
}
|
|
1567
|
+
const scriptPath = scriptPathIn(dir, scriptRelPath);
|
|
1568
|
+
mkdirSync4(dir, { recursive: true });
|
|
1569
|
+
assertContained(scriptPath, dir, scriptRelPath);
|
|
1570
|
+
const scriptBytes = typeof scriptContent === "string" ? Buffer.from(scriptContent, "utf8") : scriptContent;
|
|
1571
|
+
const manifestBytes = options.manifestBytes ?? Buffer.from(JSON.stringify(manifest, null, 2) + `
|
|
1572
|
+
`, "utf8");
|
|
1573
|
+
const manifestPath = join11(dir, "manifest.json");
|
|
1574
|
+
const replaced = { script_sha256: hashOrNull(scriptPath), manifest_sha256: hashOrNull(manifestPath) };
|
|
1575
|
+
if (replaced.script_sha256 === NOT_A_FILE || replaced.manifest_sha256 === NOT_A_FILE) {
|
|
1576
|
+
throw new InstallRecordError(`'${short}' cannot be installed: its script or manifest path holds something that is not a regular file`);
|
|
1577
|
+
}
|
|
1578
|
+
const record = {
|
|
1579
|
+
schema: INSTALL_RECORD_SCHEMA,
|
|
1580
|
+
name: short,
|
|
1581
|
+
version: manifest.version,
|
|
1582
|
+
source: options.source,
|
|
1583
|
+
source_ref: options.sourceRef ?? null,
|
|
1584
|
+
installed_at: new Date().toISOString(),
|
|
1585
|
+
script: { path: scriptRelPath, sha256: sha2562(scriptBytes), content_base64: scriptBytes.toString("base64") },
|
|
1586
|
+
manifest: { sha256: sha2562(manifestBytes), content_base64: manifestBytes.toString("base64") },
|
|
1587
|
+
replaces: replaced
|
|
1588
|
+
};
|
|
1589
|
+
options.onStep?.("before-commit");
|
|
1590
|
+
writeFileAtomic(join11(dir, INSTALL_RECORD_FILE), JSON.stringify(record, null, 2) + `
|
|
1591
|
+
`, 384);
|
|
1592
|
+
options.onStep?.("record-committed");
|
|
1593
|
+
materialize(dir, record, options.onStep);
|
|
1594
|
+
return { dir, scriptPath, record };
|
|
1595
|
+
}
|
|
1596
|
+
function materialize(dir, record, onStep) {
|
|
1597
|
+
const scriptPath = scriptPathIn(dir, record.script.path);
|
|
1598
|
+
const scriptBytes = Buffer.from(record.script.content_base64, "base64");
|
|
1599
|
+
const manifestBytes = Buffer.from(record.manifest.content_base64, "base64");
|
|
1600
|
+
if (hashOrNull(scriptPath) !== record.script.sha256) {
|
|
1601
|
+
mkdirSync4(dirname7(scriptPath), { recursive: true });
|
|
1602
|
+
writeFileAtomic(scriptPath, scriptBytes, 420);
|
|
1603
|
+
}
|
|
1604
|
+
onStep?.("script-written");
|
|
1605
|
+
const manifestPath = join11(dir, "manifest.json");
|
|
1606
|
+
if (hashOrNull(manifestPath) !== record.manifest.sha256)
|
|
1607
|
+
writeFileAtomic(manifestPath, manifestBytes, 420);
|
|
1608
|
+
onStep?.("manifest-written");
|
|
1609
|
+
}
|
|
1610
|
+
function inspectInstall(name) {
|
|
1611
|
+
let record;
|
|
1612
|
+
try {
|
|
1613
|
+
record = readInstallRecord(name);
|
|
1614
|
+
} catch (error) {
|
|
1615
|
+
if (!(error instanceof InstallRecordError) && !(error instanceof ScriptContainmentError))
|
|
1616
|
+
throw error;
|
|
1617
|
+
return { state: "invalid", reason: error.message };
|
|
1618
|
+
}
|
|
1619
|
+
if (!record)
|
|
1620
|
+
return { state: "none" };
|
|
1621
|
+
const dir = customHookDir(name);
|
|
1622
|
+
const unfinished = [];
|
|
1623
|
+
const checks = [
|
|
1624
|
+
["manifest", join11(dir, "manifest.json"), record.manifest.sha256, record.replaces.manifest_sha256],
|
|
1625
|
+
["script", scriptPathIn(dir, record.script.path), record.script.sha256, record.replaces.script_sha256]
|
|
1626
|
+
];
|
|
1627
|
+
for (const [file, path, committed, replaced] of checks) {
|
|
1628
|
+
const actual = hashOrNull(path);
|
|
1629
|
+
if (actual === committed)
|
|
1630
|
+
continue;
|
|
1631
|
+
if (actual === null || actual === replaced) {
|
|
1632
|
+
unfinished.push(file);
|
|
1633
|
+
continue;
|
|
1634
|
+
}
|
|
1635
|
+
return { state: "edited", record, file, expected: committed, actual };
|
|
1636
|
+
}
|
|
1637
|
+
return unfinished.length > 0 ? { state: "unfinished", record, files: unfinished } : { state: "consistent", record };
|
|
1638
|
+
}
|
|
1639
|
+
function finishInstall(name) {
|
|
1640
|
+
const state = inspectInstall(name);
|
|
1641
|
+
if (state.state !== "unfinished")
|
|
1642
|
+
return state;
|
|
1643
|
+
materialize(customHookDir(name), state.record);
|
|
1644
|
+
return inspectInstall(name);
|
|
1645
|
+
}
|
|
1646
|
+
function installFingerprint(name) {
|
|
1647
|
+
let raw = "none";
|
|
1648
|
+
try {
|
|
1649
|
+
raw = sha2562(readFileSync6(recordPath(name)));
|
|
1650
|
+
} catch (error) {
|
|
1651
|
+
if (error.code !== "ENOENT")
|
|
1652
|
+
raw = "unreadable";
|
|
1653
|
+
}
|
|
1654
|
+
if (raw === "none")
|
|
1655
|
+
return raw;
|
|
1656
|
+
try {
|
|
1657
|
+
return `${raw}:${inspectInstall(name).state}`;
|
|
1658
|
+
} catch {
|
|
1659
|
+
return `${raw}:undecidable`;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
function withStableInstall(name, read) {
|
|
1663
|
+
for (let attempt = 0;; attempt++) {
|
|
1664
|
+
let before;
|
|
1665
|
+
try {
|
|
1666
|
+
finishInstall(name);
|
|
1667
|
+
before = installFingerprint(name);
|
|
1668
|
+
} catch {
|
|
1669
|
+
return read();
|
|
1670
|
+
}
|
|
1671
|
+
const value = read();
|
|
1672
|
+
let after;
|
|
1673
|
+
try {
|
|
1674
|
+
after = installFingerprint(name);
|
|
1675
|
+
} catch {
|
|
1676
|
+
return value;
|
|
1677
|
+
}
|
|
1678
|
+
if (after === before || attempt >= 3)
|
|
1679
|
+
return value;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
var INSTALL_RECORD_SCHEMA = 1, InstallRecordError, NOT_A_FILE = "not-a-regular-file";
|
|
1683
|
+
var init_install_record = __esm(() => {
|
|
1684
|
+
init_manifest();
|
|
1685
|
+
InstallRecordError = class InstallRecordError extends Error {
|
|
1686
|
+
constructor(message) {
|
|
1687
|
+
super(message);
|
|
1688
|
+
this.name = "InstallRecordError";
|
|
1689
|
+
}
|
|
1690
|
+
};
|
|
1691
|
+
});
|
|
1692
|
+
|
|
1460
1693
|
// src/lib/redact.ts
|
|
1461
1694
|
function redactText(value) {
|
|
1462
1695
|
let out = value;
|
|
@@ -1555,9 +1788,9 @@ function absoluteOverride(env, key2) {
|
|
|
1555
1788
|
return value && isAbsolute7(value) ? value : null;
|
|
1556
1789
|
}
|
|
1557
1790
|
function hasnaHomeDir(env) {
|
|
1558
|
-
const
|
|
1559
|
-
if (
|
|
1560
|
-
return
|
|
1791
|
+
const override2 = absoluteOverride(env, HASNA_HOME_ENV_KEY);
|
|
1792
|
+
if (override2)
|
|
1793
|
+
return override2;
|
|
1561
1794
|
const home = homeDir(env);
|
|
1562
1795
|
return home ? join24(home, HASNA_HOME_DIR) : null;
|
|
1563
1796
|
}
|
|
@@ -1890,13 +2123,13 @@ function resolveCredential(name, env, options = {}) {
|
|
|
1890
2123
|
const overrideKeyName = credentialOverrideEnvKey(name);
|
|
1891
2124
|
const overrideRaw = Object.prototype.hasOwnProperty.call(env, overrideKeyName) ? env[overrideKeyName] : undefined;
|
|
1892
2125
|
if (overrideRaw !== undefined) {
|
|
1893
|
-
const
|
|
1894
|
-
if (!
|
|
2126
|
+
const override2 = overrideRaw.trim();
|
|
2127
|
+
if (!override2) {
|
|
1895
2128
|
throw new CredentialResolutionError(name, `${overrideKeyName} is set but empty. It is a deliberate override, so it is not resolved around: ` + `either give it a real key or unset it to fall back to the credential on disk.`, [overrideKeyName]);
|
|
1896
2129
|
}
|
|
1897
|
-
assertUsableCredential(name, overrideKeyName,
|
|
2130
|
+
assertUsableCredential(name, overrideKeyName, override2);
|
|
1898
2131
|
return sealCredential({
|
|
1899
|
-
apiKey:
|
|
2132
|
+
apiKey: override2,
|
|
1900
2133
|
tier: "override",
|
|
1901
2134
|
source: overrideKeyName,
|
|
1902
2135
|
deliberate: true,
|
|
@@ -2403,7 +2636,7 @@ var init_stop_review_context = __esm(() => {
|
|
|
2403
2636
|
|
|
2404
2637
|
// src/lib/hook-env.ts
|
|
2405
2638
|
import { dirname as dirname27, isAbsolute as isAbsolute12 } from "path";
|
|
2406
|
-
import { existsSync as
|
|
2639
|
+
import { existsSync as existsSync16, realpathSync as realpathSync9, statSync as statSync2 } from "fs";
|
|
2407
2640
|
import { tmpdir as tmpdir2 } from "os";
|
|
2408
2641
|
function isDeniedEnvName(name) {
|
|
2409
2642
|
const upper = name.toUpperCase();
|
|
@@ -2451,7 +2684,7 @@ function isUnsafePathEntry(entry, home) {
|
|
|
2451
2684
|
}
|
|
2452
2685
|
function sanitizeHookPath(pathValue, home) {
|
|
2453
2686
|
const baseline = PATH_BASELINE.slice();
|
|
2454
|
-
if (process.platform === "darwin" &&
|
|
2687
|
+
if (process.platform === "darwin" && existsSync16("/opt/homebrew/bin"))
|
|
2455
2688
|
baseline.push("/opt/homebrew/bin");
|
|
2456
2689
|
const bunDir = dirname27(process.execPath);
|
|
2457
2690
|
const seen = new Set;
|
|
@@ -2585,9 +2818,9 @@ __export(exports_run, {
|
|
|
2585
2818
|
HookTimeoutError: () => HookTimeoutError,
|
|
2586
2819
|
BUN_ISOLATION_FLAGS: () => BUN_ISOLATION_FLAGS
|
|
2587
2820
|
});
|
|
2588
|
-
import { randomBytes as
|
|
2821
|
+
import { randomBytes as randomBytes4 } from "crypto";
|
|
2589
2822
|
import { rmSync as rmSync5, writeFileSync as writeFileSync12 } from "fs";
|
|
2590
|
-
import { basename as basename18, dirname as dirname31, isAbsolute as isAbsolute17, join as
|
|
2823
|
+
import { basename as basename18, dirname as dirname31, isAbsolute as isAbsolute17, join as join36 } from "path";
|
|
2591
2824
|
function extensionOf(scriptPath) {
|
|
2592
2825
|
const base = basename18(scriptPath);
|
|
2593
2826
|
const dot = base.lastIndexOf(".");
|
|
@@ -2658,7 +2891,7 @@ async function readPipeWithDeadline(stream, deadlineMs) {
|
|
|
2658
2891
|
async function executeVerifiedScript(options) {
|
|
2659
2892
|
const scriptDir = dirname31(options.scriptPath);
|
|
2660
2893
|
const interpreter = interpreterFor(options.name, options.scriptPath, options.content);
|
|
2661
|
-
const tempPath =
|
|
2894
|
+
const tempPath = join36(scriptDir, `.hooks-verified-${randomBytes4(12).toString("hex")}.${interpreter.tempExt}`);
|
|
2662
2895
|
let proc = null;
|
|
2663
2896
|
let timedOut = false;
|
|
2664
2897
|
const timeoutTimer = options.timeout ? setTimeout(() => {
|
|
@@ -2868,16 +3101,16 @@ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
|
2868
3101
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2869
3102
|
import { z as z3 } from "zod";
|
|
2870
3103
|
init_registry();
|
|
2871
|
-
import { existsSync as
|
|
2872
|
-
import { join as
|
|
2873
|
-
import { fileURLToPath as
|
|
3104
|
+
import { existsSync as existsSync17, readFileSync as readFileSync21 } from "fs";
|
|
3105
|
+
import { join as join38, dirname as dirname33 } from "path";
|
|
3106
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
2874
3107
|
|
|
2875
3108
|
// src/lib/installer.ts
|
|
2876
3109
|
init_registry();
|
|
2877
|
-
import { existsSync as
|
|
2878
|
-
import { join as
|
|
3110
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync13, readFileSync as readFileSync16, readdirSync as readdirSync13, realpathSync as realpathSync6, rmdirSync as rmdirSync4, unlinkSync as unlinkSync7, writeFileSync as writeFileSync11 } from "fs";
|
|
3111
|
+
import { join as join26, dirname as dirname19, basename as basename14, resolve as resolve29 } from "path";
|
|
2879
3112
|
import { homedir as homedir8 } from "os";
|
|
2880
|
-
import { fileURLToPath as
|
|
3113
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
2881
3114
|
|
|
2882
3115
|
// src/lib/readiness-process.ts
|
|
2883
3116
|
var supervisor = String.raw`
|
|
@@ -3683,12 +3916,13 @@ function hookRegisteredInSettings(settings, name, eventSpec, hookMatcher) {
|
|
|
3683
3916
|
}
|
|
3684
3917
|
|
|
3685
3918
|
// src/lib/store.ts
|
|
3686
|
-
import { createHash as
|
|
3687
|
-
import { existsSync as
|
|
3688
|
-
import { join as
|
|
3919
|
+
import { createHash as createHash6 } from "crypto";
|
|
3920
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync3, renameSync as renameSync3, lstatSync as lstatSync5 } from "fs";
|
|
3921
|
+
import { join as join12 } from "path";
|
|
3689
3922
|
init_db();
|
|
3690
3923
|
init_config();
|
|
3691
3924
|
init_manifest();
|
|
3925
|
+
import { Database as Database2 } from "bun:sqlite";
|
|
3692
3926
|
|
|
3693
3927
|
// src/lib/registry-artifact.ts
|
|
3694
3928
|
init_semver();
|
|
@@ -3706,13 +3940,178 @@ function registryDigest(value) {
|
|
|
3706
3940
|
}
|
|
3707
3941
|
|
|
3708
3942
|
// src/lib/store.ts
|
|
3709
|
-
|
|
3943
|
+
init_registry();
|
|
3944
|
+
init_resolve();
|
|
3945
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
3946
|
+
|
|
3947
|
+
// src/lib/release-manifest.ts
|
|
3948
|
+
init_config();
|
|
3949
|
+
init_registry();
|
|
3950
|
+
import { createHash as createHash4, randomBytes } from "crypto";
|
|
3951
|
+
import { existsSync as existsSync8, lstatSync as lstatSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5, realpathSync as realpathSync4, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
3952
|
+
import { basename as basename2, dirname as dirname6, join as join10, relative, resolve as resolve4, sep as sep2 } from "path";
|
|
3953
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3954
|
+
var RELEASE_MANIFEST_SCHEMA = 1;
|
|
3955
|
+
var RELEASE_MANIFEST_RELATIVE_PATH = "bin/release-manifest.json";
|
|
3956
|
+
|
|
3957
|
+
class ReleaseManifestError extends Error {
|
|
3958
|
+
constructor(message) {
|
|
3959
|
+
super(message);
|
|
3960
|
+
this.name = "ReleaseManifestError";
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
function sha256(bytes) {
|
|
3964
|
+
return createHash4("sha256").update(bytes).digest("hex");
|
|
3965
|
+
}
|
|
3966
|
+
function isWithin2(child, parent) {
|
|
3967
|
+
return child === parent || child.startsWith(parent + sep2);
|
|
3968
|
+
}
|
|
3969
|
+
function parseReleaseManifest(raw, path) {
|
|
3970
|
+
let parsed;
|
|
3971
|
+
try {
|
|
3972
|
+
parsed = JSON.parse(raw);
|
|
3973
|
+
} catch {
|
|
3974
|
+
throw new ReleaseManifestError(`release manifest (${path}) is not valid JSON`);
|
|
3975
|
+
}
|
|
3976
|
+
const value = parsed;
|
|
3977
|
+
if (value === null || typeof value !== "object" || value.schema !== RELEASE_MANIFEST_SCHEMA || typeof value.package !== "string" || typeof value.version !== "string" || value.hooks === null || typeof value.hooks !== "object" || Array.isArray(value.hooks)) {
|
|
3978
|
+
throw new ReleaseManifestError(`release manifest (${path}) is malformed`);
|
|
3979
|
+
}
|
|
3980
|
+
for (const [name, entry] of Object.entries(value.hooks)) {
|
|
3981
|
+
if (entry === null || typeof entry !== "object" || typeof entry.version !== "string" || typeof entry.script !== "string" || typeof entry.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(entry.sha256)) {
|
|
3982
|
+
throw new ReleaseManifestError(`release manifest (${path}) has a malformed entry for '${name}'`);
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
return value;
|
|
3986
|
+
}
|
|
3987
|
+
function releaseRootOf(moduleDir = dirname6(fileURLToPath2(import.meta.url))) {
|
|
3988
|
+
for (let dir = resolve4(moduleDir);; dir = dirname6(dir)) {
|
|
3989
|
+
const name = basename2(dir);
|
|
3990
|
+
if (name === "bin" || name === "dist") {
|
|
3991
|
+
const root = dirname6(dir);
|
|
3992
|
+
if (existsSync8(join10(root, "package.json")) && existsSync8(join10(root, "hooks")))
|
|
3993
|
+
return root;
|
|
3994
|
+
}
|
|
3995
|
+
if (dirname6(dir) === dir)
|
|
3996
|
+
break;
|
|
3997
|
+
}
|
|
3998
|
+
return null;
|
|
3999
|
+
}
|
|
4000
|
+
var override;
|
|
4001
|
+
function loadReleaseAt(root) {
|
|
4002
|
+
const path = join10(root, RELEASE_MANIFEST_RELATIVE_PATH);
|
|
4003
|
+
let raw;
|
|
4004
|
+
try {
|
|
4005
|
+
if (!lstatSync3(path).isFile())
|
|
4006
|
+
throw new ReleaseManifestError(`release manifest (${path}) is not a regular file`);
|
|
4007
|
+
raw = readFileSync5(path);
|
|
4008
|
+
} catch (error) {
|
|
4009
|
+
if (error.code === "ENOENT")
|
|
4010
|
+
return null;
|
|
4011
|
+
throw error instanceof ReleaseManifestError ? error : new ReleaseManifestError(`release manifest (${path}) could not be read`);
|
|
4012
|
+
}
|
|
4013
|
+
return { root: realpathSync4(root), path, sha256: sha256(raw), manifest: parseReleaseManifest(raw.toString("utf8"), path) };
|
|
4014
|
+
}
|
|
4015
|
+
function currentRelease() {
|
|
4016
|
+
if (override !== undefined)
|
|
4017
|
+
return override;
|
|
4018
|
+
const root = releaseRootOf();
|
|
4019
|
+
return root ? loadReleaseAt(root) : null;
|
|
4020
|
+
}
|
|
4021
|
+
function anchorsDir() {
|
|
4022
|
+
return join10(getHooksDataDir(), "release-anchors");
|
|
4023
|
+
}
|
|
4024
|
+
function anchorPathFor(release) {
|
|
4025
|
+
return join10(anchorsDir(), `${sha256(release.root)}.json`);
|
|
4026
|
+
}
|
|
4027
|
+
function anchorStateOf(release) {
|
|
4028
|
+
const path = anchorPathFor(release);
|
|
4029
|
+
let raw;
|
|
4030
|
+
try {
|
|
4031
|
+
if (!lstatSync3(path).isFile())
|
|
4032
|
+
return { state: "invalid", path };
|
|
4033
|
+
raw = readFileSync5(path, "utf8");
|
|
4034
|
+
} catch (error) {
|
|
4035
|
+
if (error.code === "ENOENT")
|
|
4036
|
+
return { state: "absent", path };
|
|
4037
|
+
return { state: "invalid", path };
|
|
4038
|
+
}
|
|
4039
|
+
let anchor;
|
|
4040
|
+
try {
|
|
4041
|
+
anchor = JSON.parse(raw);
|
|
4042
|
+
} catch {
|
|
4043
|
+
return { state: "invalid", path };
|
|
4044
|
+
}
|
|
4045
|
+
if (anchor === null || typeof anchor !== "object" || anchor.schema !== 1 || anchor.package_root !== release.root || typeof anchor.manifest_sha256 !== "string" || !/^[0-9a-f]{64}$/.test(anchor.manifest_sha256)) {
|
|
4046
|
+
return { state: "invalid", path };
|
|
4047
|
+
}
|
|
4048
|
+
if (anchor.manifest_sha256 !== release.sha256) {
|
|
4049
|
+
return { state: "mismatch", path, expected: anchor.manifest_sha256, actual: release.sha256 };
|
|
4050
|
+
}
|
|
4051
|
+
return { state: "match", path, anchor };
|
|
4052
|
+
}
|
|
4053
|
+
function releaseTrustFor(name, actual, scriptPath) {
|
|
4054
|
+
let release;
|
|
4055
|
+
try {
|
|
4056
|
+
release = currentRelease();
|
|
4057
|
+
} catch (error) {
|
|
4058
|
+
if (!(error instanceof ReleaseManifestError))
|
|
4059
|
+
throw error;
|
|
4060
|
+
return { governed: true, ok: false, release: "unreadable", expected: "release-manifest-invalid", reason: "manifest" };
|
|
4061
|
+
}
|
|
4062
|
+
if (!release)
|
|
4063
|
+
return { governed: false };
|
|
4064
|
+
const label = `${release.manifest.package}@${release.manifest.version}`;
|
|
4065
|
+
if (scriptPath !== undefined) {
|
|
4066
|
+
let real;
|
|
4067
|
+
try {
|
|
4068
|
+
real = realpathSync4(scriptPath);
|
|
4069
|
+
} catch {
|
|
4070
|
+
real = resolve4(scriptPath);
|
|
4071
|
+
}
|
|
4072
|
+
if (!isWithin2(real, release.root))
|
|
4073
|
+
return { governed: false };
|
|
4074
|
+
const entry2 = release.manifest.hooks[name];
|
|
4075
|
+
if (entry2 && relative(release.root, real).split(sep2).join("/") !== entry2.script) {
|
|
4076
|
+
return { governed: true, ok: false, release: label, expected: "release-manifest-script-mismatch", reason: "manifest" };
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
const entry = release.manifest.hooks[name];
|
|
4080
|
+
if (!entry)
|
|
4081
|
+
return { governed: true, ok: false, release: label, expected: "release-manifest-entry-missing", reason: "unlisted" };
|
|
4082
|
+
const anchor = anchorStateOf(release);
|
|
4083
|
+
if (anchor.state === "mismatch" || anchor.state === "invalid") {
|
|
4084
|
+
return { governed: true, ok: false, release: label, expected: "release-manifest-anchor-mismatch", reason: "anchor" };
|
|
4085
|
+
}
|
|
4086
|
+
if (entry.sha256 !== actual)
|
|
4087
|
+
return { governed: true, ok: false, release: label, expected: entry.sha256, reason: "content" };
|
|
4088
|
+
return { governed: true, ok: true, release: label, expected: entry.sha256, anchored: anchor.state === "match" };
|
|
4089
|
+
}
|
|
4090
|
+
|
|
4091
|
+
// src/lib/store.ts
|
|
4092
|
+
init_install_record();
|
|
3710
4093
|
function sha256Of(input) {
|
|
3711
|
-
return
|
|
4094
|
+
return createHash6("sha256").update(input).digest("hex");
|
|
3712
4095
|
}
|
|
3713
4096
|
function storeDb() {
|
|
3714
4097
|
return isLocalStoreRefused() ? null : getDb();
|
|
3715
4098
|
}
|
|
4099
|
+
function readHookRecordReadOnly(name) {
|
|
4100
|
+
if (isLocalStoreRefused())
|
|
4101
|
+
return null;
|
|
4102
|
+
const path = process.env.HASNA_HOOKS_DB_PATH ?? process.env.HOOKS_DB_PATH ?? join12(getHooksDataDir(), "hooks.db");
|
|
4103
|
+
if (path === ":memory:" || !existsSync9(path))
|
|
4104
|
+
return null;
|
|
4105
|
+
let db = null;
|
|
4106
|
+
try {
|
|
4107
|
+
db = new Database2(path, { readonly: true });
|
|
4108
|
+
return getHookRecord(db, name);
|
|
4109
|
+
} catch {
|
|
4110
|
+
return null;
|
|
4111
|
+
} finally {
|
|
4112
|
+
db?.close();
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
3716
4115
|
function getHookRecord(db, name) {
|
|
3717
4116
|
return db.query("SELECT * FROM hooks WHERE name = ?").get(name);
|
|
3718
4117
|
}
|
|
@@ -3764,11 +4163,11 @@ function assertLockShape(parsed, path) {
|
|
|
3764
4163
|
}
|
|
3765
4164
|
function readLock() {
|
|
3766
4165
|
const path = getLockPath();
|
|
3767
|
-
if (!
|
|
4166
|
+
if (!existsSync9(path))
|
|
3768
4167
|
return { hooks: {} };
|
|
3769
4168
|
let raw;
|
|
3770
4169
|
try {
|
|
3771
|
-
raw =
|
|
4170
|
+
raw = readFileSync7(path, "utf-8");
|
|
3772
4171
|
} catch {
|
|
3773
4172
|
throw new LockFileError(`hooks.lock (${path}) could not be read. Repair: fix permissions or move the file aside and run 'hooks sync'.`);
|
|
3774
4173
|
}
|
|
@@ -3783,15 +4182,15 @@ function readLock() {
|
|
|
3783
4182
|
}
|
|
3784
4183
|
function writeLock(lock) {
|
|
3785
4184
|
const path = getLockPath();
|
|
3786
|
-
|
|
4185
|
+
mkdirSync5(path.substring(0, path.lastIndexOf("/")) || ".", { recursive: true });
|
|
3787
4186
|
const sorted = {};
|
|
3788
4187
|
for (const name of Object.keys(lock.hooks).sort()) {
|
|
3789
4188
|
sorted[name] = lock.hooks[name];
|
|
3790
4189
|
}
|
|
3791
|
-
const tmp = `${path}.tmp-${
|
|
3792
|
-
|
|
4190
|
+
const tmp = `${path}.tmp-${randomBytes3(8).toString("hex")}`;
|
|
4191
|
+
writeFileSync3(tmp, JSON.stringify({ hooks: sorted }, null, 2) + `
|
|
3793
4192
|
`, "utf-8");
|
|
3794
|
-
|
|
4193
|
+
renameSync3(tmp, path);
|
|
3795
4194
|
return path;
|
|
3796
4195
|
}
|
|
3797
4196
|
function setPinnedHook(name, entry) {
|
|
@@ -3803,11 +4202,11 @@ function getPinnedHook(name) {
|
|
|
3803
4202
|
return readLock().hooks[name];
|
|
3804
4203
|
}
|
|
3805
4204
|
function registryManagedMarker(name) {
|
|
3806
|
-
return
|
|
4205
|
+
return join12(getHooksDataDir(), "registry-managed", sha256Of(name) + ".json");
|
|
3807
4206
|
}
|
|
3808
4207
|
function isRegistryManaged(name) {
|
|
3809
4208
|
try {
|
|
3810
|
-
|
|
4209
|
+
lstatSync5(registryManagedMarker(name));
|
|
3811
4210
|
return true;
|
|
3812
4211
|
} catch (error) {
|
|
3813
4212
|
if (error.code === "ENOENT")
|
|
@@ -3815,7 +4214,7 @@ function isRegistryManaged(name) {
|
|
|
3815
4214
|
throw error;
|
|
3816
4215
|
}
|
|
3817
4216
|
}
|
|
3818
|
-
function checkScriptHash(name, actual) {
|
|
4217
|
+
function checkScriptHash(name, actual, options = {}) {
|
|
3819
4218
|
const canonical = shortManifestName(name);
|
|
3820
4219
|
if (!HOOK_NAME_RE.test(canonical))
|
|
3821
4220
|
return { ok: false, pinned: false, expected: "invalid-hook-name", actual, name };
|
|
@@ -3830,8 +4229,34 @@ function checkScriptHash(name, actual) {
|
|
|
3830
4229
|
}
|
|
3831
4230
|
if (isRegistryManaged(customIdentity ?? canonical))
|
|
3832
4231
|
name = customIdentity ?? canonical;
|
|
3833
|
-
|
|
3834
|
-
|
|
4232
|
+
else if (customIdentity !== undefined) {
|
|
4233
|
+
const installed = inspectInstall(customIdentity);
|
|
4234
|
+
if (installed.state === "invalid") {
|
|
4235
|
+
return { ok: false, pinned: true, expected: "install-record-invalid", actual, name: customIdentity, governedBy: "install-record", state: installed.state };
|
|
4236
|
+
}
|
|
4237
|
+
if (installed.state !== "none") {
|
|
4238
|
+
const label = `${installed.record.name}@${installed.record.version}`;
|
|
4239
|
+
const base = { name: customIdentity, governedBy: "install-record", release: label, state: installed.state };
|
|
4240
|
+
if (installed.state === "edited") {
|
|
4241
|
+
return { ok: false, pinned: true, expected: installed.expected, actual: installed.file === "script" ? actual : installed.actual, ...base, release: null };
|
|
4242
|
+
}
|
|
4243
|
+
const committed = installed.record.script.sha256;
|
|
4244
|
+
return { ok: installed.state === "consistent" && actual === committed, pinned: true, expected: committed, actual, ...base };
|
|
4245
|
+
}
|
|
4246
|
+
} else if (getHook(canonical)) {
|
|
4247
|
+
const release = releaseTrustFor(canonical, actual, resolveScriptPath(canonical));
|
|
4248
|
+
if (release.governed) {
|
|
4249
|
+
if (release.ok)
|
|
4250
|
+
return { ok: true, pinned: true, expected: release.expected, actual, name: canonical, governedBy: "release", release: release.release };
|
|
4251
|
+
const explicit = release.reason === "content" ? getPinnedHook(canonical) : undefined;
|
|
4252
|
+
if (explicit && explicit.sha256 === actual && explicit.release === release.release) {
|
|
4253
|
+
return { ok: true, pinned: true, expected: actual, actual, name: canonical, governedBy: "pin", release: null };
|
|
4254
|
+
}
|
|
4255
|
+
return { ok: false, pinned: true, expected: release.expected, actual, name: canonical, governedBy: "release", release: release.release };
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
const db = options.readOnly ? null : storeDb();
|
|
4259
|
+
const record = options.readOnly ? readHookRecordReadOnly(name) : db ? getHookRecord(db, name) : null;
|
|
3835
4260
|
const pin2 = getPinnedHook(name);
|
|
3836
4261
|
const expected = record?.sha256 ?? pin2?.sha256 ?? null;
|
|
3837
4262
|
if (isRegistryManaged(name) && (!pin2 || !pin2.manifest_sha256)) {
|
|
@@ -3844,9 +4269,11 @@ function checkScriptHash(name, actual) {
|
|
|
3844
4269
|
}
|
|
3845
4270
|
}
|
|
3846
4271
|
if (expected !== null && expected !== actual) {
|
|
3847
|
-
return { ok: false, pinned: true, expected, actual, name };
|
|
4272
|
+
return { ok: false, pinned: true, expected, actual, name, governedBy: "pin", release: null };
|
|
3848
4273
|
}
|
|
3849
4274
|
if (expected === null) {
|
|
4275
|
+
if (options.readOnly)
|
|
4276
|
+
return { ok: true, pinned: false, expected: null, actual, name, governedBy: "first-run", release: null };
|
|
3850
4277
|
const now2 = new Date().toISOString();
|
|
3851
4278
|
const version = pin2?.version ?? record?.version ?? "0.0.0";
|
|
3852
4279
|
const source = pin2?.source ?? record?.source_type ?? "local";
|
|
@@ -3860,10 +4287,10 @@ function checkScriptHash(name, actual) {
|
|
|
3860
4287
|
});
|
|
3861
4288
|
}
|
|
3862
4289
|
setPinnedHook(name, { version, sha256: actual, source });
|
|
3863
|
-
return { ok: true, pinned: false, expected: null, actual, name };
|
|
4290
|
+
return { ok: true, pinned: false, expected: null, actual, name, governedBy: "first-run", release: null };
|
|
3864
4291
|
}
|
|
3865
4292
|
const now = new Date().toISOString();
|
|
3866
|
-
if (db) {
|
|
4293
|
+
if (db && !options.readOnly) {
|
|
3867
4294
|
upsertHookRecord(db, {
|
|
3868
4295
|
name,
|
|
3869
4296
|
version: record?.version ?? pin2?.version ?? "0.0.0",
|
|
@@ -3872,20 +4299,20 @@ function checkScriptHash(name, actual) {
|
|
|
3872
4299
|
last_verified_at: now
|
|
3873
4300
|
});
|
|
3874
4301
|
}
|
|
3875
|
-
return { ok: true, pinned: true, expected, actual, name };
|
|
4302
|
+
return { ok: true, pinned: true, expected, actual, name, governedBy: "pin", release: null };
|
|
3876
4303
|
}
|
|
3877
4304
|
|
|
3878
4305
|
// src/lib/codex-settings.ts
|
|
3879
|
-
import { closeSync as
|
|
3880
|
-
import { dirname as
|
|
3881
|
-
import { createHash as
|
|
4306
|
+
import { closeSync as closeSync4, existsSync as existsSync10, lstatSync as lstatSync6, mkdirSync as mkdirSync6, openSync as openSync4, readFileSync as readFileSync8, renameSync as renameSync4, unlinkSync, writeFileSync as writeFileSync4 } from "fs";
|
|
4307
|
+
import { dirname as dirname8 } from "path";
|
|
4308
|
+
import { createHash as createHash7, randomUUID } from "crypto";
|
|
3882
4309
|
var snapshots = new WeakMap;
|
|
3883
4310
|
function current(path) {
|
|
3884
4311
|
try {
|
|
3885
|
-
const stat =
|
|
4312
|
+
const stat = lstatSync6(path);
|
|
3886
4313
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1048576)
|
|
3887
4314
|
throw new Error("invalid_file");
|
|
3888
|
-
return
|
|
4315
|
+
return readFileSync8(path, "utf8");
|
|
3889
4316
|
} catch (error) {
|
|
3890
4317
|
if (error.code === "ENOENT")
|
|
3891
4318
|
return null;
|
|
@@ -3916,7 +4343,7 @@ function readCodexSettings(path) {
|
|
|
3916
4343
|
function assertSettingsPreimage(raw, expected) {
|
|
3917
4344
|
if (expected === undefined)
|
|
3918
4345
|
return;
|
|
3919
|
-
if (!/^(?:absent|[a-f0-9]{64})$/.test(expected) || (raw === null ? "absent" :
|
|
4346
|
+
if (!/^(?:absent|[a-f0-9]{64})$/.test(expected) || (raw === null ? "absent" : createHash7("sha256").update(raw).digest("hex")) !== expected) {
|
|
3920
4347
|
throw new Error("Hook settings changed since planning; no settings were written.");
|
|
3921
4348
|
}
|
|
3922
4349
|
}
|
|
@@ -3930,11 +4357,11 @@ function writeCodexSettings(path, settings, expectedSha256, beforeWrite) {
|
|
|
3930
4357
|
` });
|
|
3931
4358
|
}
|
|
3932
4359
|
function writeHookSettingsPreimage(path, settings, before, beforeWrite) {
|
|
3933
|
-
|
|
4360
|
+
mkdirSync6(dirname8(path), { recursive: true, mode: 448 });
|
|
3934
4361
|
const lock = `${path}.hooks-write.lock`;
|
|
3935
4362
|
let fd;
|
|
3936
4363
|
try {
|
|
3937
|
-
fd =
|
|
4364
|
+
fd = openSync4(lock, "wx", 384);
|
|
3938
4365
|
} catch {
|
|
3939
4366
|
throw new Error("Codex settings are being edited; retry after the active writer finishes.");
|
|
3940
4367
|
}
|
|
@@ -3944,34 +4371,34 @@ function writeHookSettingsPreimage(path, settings, before, beforeWrite) {
|
|
|
3944
4371
|
throw new Error("Hook settings changed since reading; re-read before retrying.");
|
|
3945
4372
|
const next = JSON.stringify(settings, null, 2) + `
|
|
3946
4373
|
`;
|
|
3947
|
-
|
|
4374
|
+
writeFileSync4(temp, next, { flag: "wx", mode: 384 });
|
|
3948
4375
|
if (current(path) !== before)
|
|
3949
4376
|
throw new Error("Hook settings changed since reading; re-read before retrying.");
|
|
3950
4377
|
beforeWrite?.();
|
|
3951
|
-
|
|
4378
|
+
renameSync4(temp, path);
|
|
3952
4379
|
} finally {
|
|
3953
|
-
if (
|
|
4380
|
+
if (existsSync10(temp))
|
|
3954
4381
|
unlinkSync(temp);
|
|
3955
|
-
|
|
4382
|
+
closeSync4(fd);
|
|
3956
4383
|
unlinkSync(lock);
|
|
3957
4384
|
}
|
|
3958
4385
|
}
|
|
3959
4386
|
|
|
3960
4387
|
// src/lib/claude-skills-coordination.ts
|
|
3961
|
-
import { createHash as
|
|
3962
|
-
import { existsSync as
|
|
4388
|
+
import { createHash as createHash11 } from "crypto";
|
|
4389
|
+
import { existsSync as existsSync12, lstatSync as lstatSync7 } from "fs";
|
|
3963
4390
|
import { homedir as homedir7 } from "os";
|
|
3964
|
-
import { join as
|
|
4391
|
+
import { join as join19, resolve as resolve10 } from "path";
|
|
3965
4392
|
|
|
3966
4393
|
// node_modules/@hasna/skills/dist/index.js
|
|
3967
|
-
import { existsSync as
|
|
4394
|
+
import { existsSync as existsSync11 } from "fs";
|
|
3968
4395
|
import { homedir as homedir6 } from "os";
|
|
3969
|
-
import { join as
|
|
4396
|
+
import { join as join13, resolve as resolve6 } from "path";
|
|
3970
4397
|
import { homedir as pathsResolverHomedir2 } from "os";
|
|
3971
4398
|
import { join as pathsResolverJoin2 } from "path";
|
|
3972
|
-
import { createHash as
|
|
4399
|
+
import { createHash as createHash8 } from "crypto";
|
|
3973
4400
|
import { existsSync as existsSync52, readdirSync as readdirSync3, readFileSync as readFileSync42, statSync as statSync4 } from "fs";
|
|
3974
|
-
import { join as join52, sep as
|
|
4401
|
+
import { join as join52, sep as sep4 } from "path";
|
|
3975
4402
|
import { dirname as dirname32, join as join72, resolve as resolve22 } from "path";
|
|
3976
4403
|
import { createHash as createHash32 } from "crypto";
|
|
3977
4404
|
import { createHash as createHash22 } from "crypto";
|
|
@@ -3979,21 +4406,21 @@ import { lstatSync as lstatSync42, readFileSync as readFileSync62, readdirSync a
|
|
|
3979
4406
|
import { join as join82 } from "path";
|
|
3980
4407
|
import { createHash as createHash52 } from "crypto";
|
|
3981
4408
|
import { createHash as createHash42 } from "crypto";
|
|
3982
|
-
import { closeSync as closeSync22, constants as constants22, fstatSync as fstatSync22, lstatSync as
|
|
3983
|
-
import { basename as
|
|
3984
|
-
import { basename as basename5, isAbsolute as isAbsolute6, join as join92, resolve as
|
|
4409
|
+
import { closeSync as closeSync22, constants as constants22, fstatSync as fstatSync22, lstatSync as lstatSync52, openSync as openSync22, readSync } from "fs";
|
|
4410
|
+
import { basename as basename22, dirname as dirname42, isAbsolute as isAbsolute32, resolve as resolve32 } from "path";
|
|
4411
|
+
import { basename as basename5, isAbsolute as isAbsolute6, join as join92, resolve as resolve62, sep as sep32 } from "path";
|
|
3985
4412
|
import { createHash as createHash62 } from "crypto";
|
|
3986
|
-
import { basename as basename3, dirname as dirname52, isAbsolute as
|
|
3987
|
-
import { createHash as
|
|
3988
|
-
import { closeSync as closeSync32, constants as constants3, fstatSync as fstatSync3, lstatSync as
|
|
3989
|
-
import { basename as basename4, dirname as dirname62, isAbsolute as isAbsolute5, resolve as
|
|
4413
|
+
import { basename as basename3, dirname as dirname52, isAbsolute as isAbsolute42, resolve as resolve42 } from "path";
|
|
4414
|
+
import { createHash as createHash72 } from "crypto";
|
|
4415
|
+
import { closeSync as closeSync32, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync62, openSync as openSync32, readSync as readSync2 } from "fs";
|
|
4416
|
+
import { basename as basename4, dirname as dirname62, isAbsolute as isAbsolute5, resolve as resolve52, sep as sep22 } from "path";
|
|
3990
4417
|
import { createHash as createHash33 } from "crypto";
|
|
3991
4418
|
import { lstatSync as lstatSync34, opendirSync as opendirSync6, readFileSync as readFileSync27, readdirSync as readdirSync14, realpathSync as realpathSync14 } from "fs";
|
|
3992
4419
|
import { basename as basename17, dirname as dirname30, isAbsolute as isAbsolute30, join as join42, relative as relative10, resolve as resolve28, sep as sep16 } from "path";
|
|
3993
4420
|
import { isDeepStrictEqual as isDeepStrictEqual9 } from "util";
|
|
3994
|
-
import { dirname as
|
|
3995
|
-
import { lstatSync as lstatSync8, readFileSync as
|
|
3996
|
-
import { dirname as
|
|
4421
|
+
import { dirname as dirname82, isAbsolute as isAbsolute9, join as join102, resolve as resolve7 } from "path";
|
|
4422
|
+
import { lstatSync as lstatSync8, readFileSync as readFileSync82, opendirSync } from "fs";
|
|
4423
|
+
import { dirname as dirname72, isAbsolute as isAbsolute8, sep as sep42 } from "path";
|
|
3997
4424
|
import { createHash as createHash9 } from "crypto";
|
|
3998
4425
|
import { lstatSync as lstatSync9, opendirSync as opendirSync2 } from "fs";
|
|
3999
4426
|
import { dirname as dirname9, isAbsolute as isAbsolute10, join as join112, resolve as resolve8 } from "path";
|
|
@@ -4001,7 +4428,7 @@ import { createHash as createHash10 } from "crypto";
|
|
|
4001
4428
|
import { closeSync as closeSync5, constants as constants5, fstatSync as fstatSync5, lstatSync as lstatSync10, openSync as openSync5, readSync as readSync3 } from "fs";
|
|
4002
4429
|
import { dirname as dirname10, isAbsolute as isAbsolute11, resolve as resolve9 } from "path";
|
|
4003
4430
|
import { createHash as createHash14, randomUUID as randomUUID2 } from "crypto";
|
|
4004
|
-
import { constants as constants7, closeSync as closeSync7, fchmodSync as fchmodSync2, fstatSync as fstatSync7, fsyncSync as fsyncSync3, linkSync as linkSync2, lstatSync as lstatSync12, mkdirSync as mkdirSync42, openSync as openSync7, opendirSync as opendirSync3, readSync as readSync5, renameSync as renameSync22, rmdirSync, rmSync, unlinkSync as unlinkSync2, writeSync as writeSync2 } from "fs";
|
|
4431
|
+
import { constants as constants7, closeSync as closeSync7, fchmodSync as fchmodSync2, fstatSync as fstatSync7, fsyncSync as fsyncSync3, linkSync as linkSync2, lstatSync as lstatSync12, mkdirSync as mkdirSync42, openSync as openSync7, opendirSync as opendirSync3, readSync as readSync5, renameSync as renameSync22, rmdirSync, rmSync as rmSync3, unlinkSync as unlinkSync2, writeSync as writeSync2 } from "fs";
|
|
4005
4432
|
import { dirname as dirname12, isAbsolute as isAbsolute13, join as join14, parse as parse4, resolve as resolve11 } from "path";
|
|
4006
4433
|
import { createHash as createHash13 } from "crypto";
|
|
4007
4434
|
import { createHash as createHash15 } from "crypto";
|
|
@@ -4023,14 +4450,14 @@ import { lstatSync as lstatSync17, readdirSync as readdirSync8, readFileSync as
|
|
|
4023
4450
|
import { lstatSync as lstatSync16, readdirSync as readdirSync7, readFileSync as readFileSync13, realpathSync as realpathSync7 } from "fs";
|
|
4024
4451
|
import { basename as basename8, dirname as dirname17, isAbsolute as isAbsolute18, join as join20, normalize as normalize3 } from "path";
|
|
4025
4452
|
import { createHash as createHash19 } from "crypto";
|
|
4026
|
-
import { fileURLToPath as
|
|
4453
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
4027
4454
|
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
4028
|
-
import { closeSync as closeSync8, constants as constants8, fstatSync as fstatSync8, lstatSync as lstatSync14, openSync as openSync8, readFileSync as readFileSync11, realpathSync as
|
|
4455
|
+
import { closeSync as closeSync8, constants as constants8, fstatSync as fstatSync8, lstatSync as lstatSync14, openSync as openSync8, readFileSync as readFileSync11, realpathSync as realpathSync42 } from "fs";
|
|
4029
4456
|
import { dirname as dirname15, join as join17, parse as parse6, relative as relative3, resolve as resolve14, sep as sep7 } from "path";
|
|
4030
4457
|
import { AsyncLocalStorage } from "async_hooks";
|
|
4031
4458
|
import { execFileSync, spawnSync as spawnSync3 } from "child_process";
|
|
4032
4459
|
import { createHash as createHash20 } from "crypto";
|
|
4033
|
-
import { accessSync, constants as constants9, lstatSync as lstatSync15, mkdirSync as
|
|
4460
|
+
import { accessSync, constants as constants9, lstatSync as lstatSync15, mkdirSync as mkdirSync52, mkdtempSync, readdirSync as readdirSync6, readFileSync as readFileSync12, realpathSync as realpathSync5, rmSync as rmSync22, statSync as statSync7 } from "fs";
|
|
4034
4461
|
import { basename as basename7, delimiter, dirname as dirname16, isAbsolute as isAbsolute16, join as join18, relative as relative4, resolve as resolve15, sep as sep8 } from "path";
|
|
4035
4462
|
import { createHash as createHash23 } from "crypto";
|
|
4036
4463
|
import { closeSync as closeSync19, constants as constants20, fstatSync as fstatSync19, lstatSync as lstatSync32, openSync as openSync19, opendirSync as opendirSync5, readSync as readSync14 } from "fs";
|
|
@@ -4038,14 +4465,14 @@ import { basename as basename15, dirname as dirname28, isAbsolute as isAbsolute2
|
|
|
4038
4465
|
import { isAbsolute as isAbsolute27, join as join40, resolve as resolve25 } from "path";
|
|
4039
4466
|
import { createRequire } from "module";
|
|
4040
4467
|
import { createHash as createHash25, randomUUID as randomUUID3 } from "crypto";
|
|
4041
|
-
import { closeSync as closeSync12, constants as constants12, fstatSync as fstatSync12, fsyncSync as fsyncSync4, lstatSync as lstatSync22, mkdirSync as mkdirSync7, openSync as openSync12, readFileSync as readFileSync18, readSync as readSync7, readlinkSync as readlinkSync5, realpathSync as realpathSync10, renameSync as
|
|
4468
|
+
import { closeSync as closeSync12, constants as constants12, fstatSync as fstatSync12, fsyncSync as fsyncSync4, lstatSync as lstatSync22, mkdirSync as mkdirSync7, openSync as openSync12, readFileSync as readFileSync18, readSync as readSync7, readlinkSync as readlinkSync5, realpathSync as realpathSync10, renameSync as renameSync32, unlinkSync as unlinkSync4, writeFileSync as writeFileSync42 } from "fs";
|
|
4042
4469
|
import { dirname as dirname20, isAbsolute as isAbsolute21, join as join27, resolve as resolve18 } from "path";
|
|
4043
4470
|
import { isDeepStrictEqual as isDeepStrictEqual6 } from "util";
|
|
4044
4471
|
import { createHash as createHash26 } from "crypto";
|
|
4045
4472
|
import { constants as constants13, closeSync as closeSync13, fstatSync as fstatSync13, lstatSync as lstatSync23, openSync as openSync13, readSync as readSync8, readdirSync as readdirSync11, realpathSync as realpathSync11 } from "fs";
|
|
4046
4473
|
import { basename as basename11, dirname as dirname21, isAbsolute as isAbsolute22, join as join28, relative as relative8, resolve as resolve19, sep as sep12 } from "path";
|
|
4047
4474
|
import { createHash as createHash27 } from "crypto";
|
|
4048
|
-
import { closeSync as closeSync14, constants as constants14, fstatSync as fstatSync14, lstatSync as lstatSync24, openSync as openSync14, readSync as readSync9, renameSync as
|
|
4475
|
+
import { closeSync as closeSync14, constants as constants14, fstatSync as fstatSync14, lstatSync as lstatSync24, openSync as openSync14, readSync as readSync9, renameSync as renameSync42, unlinkSync as unlinkSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
4049
4476
|
import { basename as basename12, dirname as dirname22, join as join29 } from "path";
|
|
4050
4477
|
import { lstatSync as lstatSync25, readFileSync as readFileSync19 } from "fs";
|
|
4051
4478
|
import { dirname as dirname23, join as join30, resolve as resolve20, sep as sep13 } from "path";
|
|
@@ -7665,10 +8092,10 @@ var require_resolve_block_map = __commonJS((exports) => {
|
|
|
7665
8092
|
let offset = bm.offset;
|
|
7666
8093
|
let commentEnd = null;
|
|
7667
8094
|
for (const collItem of bm.items) {
|
|
7668
|
-
const { start, key, sep:
|
|
8095
|
+
const { start, key, sep: sep43, value } = collItem;
|
|
7669
8096
|
const keyProps = resolveProps.resolveProps(start, {
|
|
7670
8097
|
indicator: "explicit-key-ind",
|
|
7671
|
-
next: key ??
|
|
8098
|
+
next: key ?? sep43?.[0],
|
|
7672
8099
|
offset,
|
|
7673
8100
|
onError,
|
|
7674
8101
|
parentIndent: bm.indent,
|
|
@@ -7682,7 +8109,7 @@ var require_resolve_block_map = __commonJS((exports) => {
|
|
|
7682
8109
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
7683
8110
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
7684
8111
|
}
|
|
7685
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
8112
|
+
if (!keyProps.anchor && !keyProps.tag && !sep43) {
|
|
7686
8113
|
commentEnd = keyProps.end;
|
|
7687
8114
|
if (keyProps.comment) {
|
|
7688
8115
|
if (map.comment)
|
|
@@ -7707,7 +8134,7 @@ var require_resolve_block_map = __commonJS((exports) => {
|
|
|
7707
8134
|
ctx.atKey = false;
|
|
7708
8135
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
7709
8136
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
7710
|
-
const valueProps = resolveProps.resolveProps(
|
|
8137
|
+
const valueProps = resolveProps.resolveProps(sep43 ?? [], {
|
|
7711
8138
|
indicator: "map-value-ind",
|
|
7712
8139
|
next: value,
|
|
7713
8140
|
offset: keyNode.range[2],
|
|
@@ -7723,7 +8150,7 @@ var require_resolve_block_map = __commonJS((exports) => {
|
|
|
7723
8150
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
7724
8151
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
7725
8152
|
}
|
|
7726
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
8153
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep43, null, valueProps, onError);
|
|
7727
8154
|
if (ctx.schema.compat)
|
|
7728
8155
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
7729
8156
|
offset = valueNode.range[2];
|
|
@@ -7805,7 +8232,7 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
7805
8232
|
let comment = "";
|
|
7806
8233
|
if (end) {
|
|
7807
8234
|
let hasSpace = false;
|
|
7808
|
-
let
|
|
8235
|
+
let sep43 = "";
|
|
7809
8236
|
for (const token of end) {
|
|
7810
8237
|
const { source, type } = token;
|
|
7811
8238
|
switch (type) {
|
|
@@ -7819,13 +8246,13 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
7819
8246
|
if (!comment)
|
|
7820
8247
|
comment = cb;
|
|
7821
8248
|
else
|
|
7822
|
-
comment +=
|
|
7823
|
-
|
|
8249
|
+
comment += sep43 + cb;
|
|
8250
|
+
sep43 = "";
|
|
7824
8251
|
break;
|
|
7825
8252
|
}
|
|
7826
8253
|
case "newline":
|
|
7827
8254
|
if (comment)
|
|
7828
|
-
|
|
8255
|
+
sep43 += source;
|
|
7829
8256
|
hasSpace = true;
|
|
7830
8257
|
break;
|
|
7831
8258
|
default:
|
|
@@ -7863,18 +8290,18 @@ var require_resolve_flow_collection = __commonJS((exports) => {
|
|
|
7863
8290
|
let offset = fc.offset + fc.start.source.length;
|
|
7864
8291
|
for (let i = 0;i < fc.items.length; ++i) {
|
|
7865
8292
|
const collItem = fc.items[i];
|
|
7866
|
-
const { start, key, sep:
|
|
8293
|
+
const { start, key, sep: sep43, value } = collItem;
|
|
7867
8294
|
const props = resolveProps.resolveProps(start, {
|
|
7868
8295
|
flow: fcName,
|
|
7869
8296
|
indicator: "explicit-key-ind",
|
|
7870
|
-
next: key ??
|
|
8297
|
+
next: key ?? sep43?.[0],
|
|
7871
8298
|
offset,
|
|
7872
8299
|
onError,
|
|
7873
8300
|
parentIndent: fc.indent,
|
|
7874
8301
|
startOnNewline: false
|
|
7875
8302
|
});
|
|
7876
8303
|
if (!props.found) {
|
|
7877
|
-
if (!props.anchor && !props.tag && !
|
|
8304
|
+
if (!props.anchor && !props.tag && !sep43 && !value) {
|
|
7878
8305
|
if (i === 0 && props.comma)
|
|
7879
8306
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
7880
8307
|
else if (i < fc.items.length - 1)
|
|
@@ -7926,8 +8353,8 @@ var require_resolve_flow_collection = __commonJS((exports) => {
|
|
|
7926
8353
|
}
|
|
7927
8354
|
}
|
|
7928
8355
|
}
|
|
7929
|
-
if (!isMap && !
|
|
7930
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
8356
|
+
if (!isMap && !sep43 && !props.found) {
|
|
8357
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep43, null, props, onError);
|
|
7931
8358
|
coll.items.push(valueNode);
|
|
7932
8359
|
offset = valueNode.range[2];
|
|
7933
8360
|
if (isBlock(value))
|
|
@@ -7939,7 +8366,7 @@ var require_resolve_flow_collection = __commonJS((exports) => {
|
|
|
7939
8366
|
if (isBlock(key))
|
|
7940
8367
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
7941
8368
|
ctx.atKey = false;
|
|
7942
|
-
const valueProps = resolveProps.resolveProps(
|
|
8369
|
+
const valueProps = resolveProps.resolveProps(sep43 ?? [], {
|
|
7943
8370
|
flow: fcName,
|
|
7944
8371
|
indicator: "map-value-ind",
|
|
7945
8372
|
next: value,
|
|
@@ -7950,8 +8377,8 @@ var require_resolve_flow_collection = __commonJS((exports) => {
|
|
|
7950
8377
|
});
|
|
7951
8378
|
if (valueProps.found) {
|
|
7952
8379
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
7953
|
-
if (
|
|
7954
|
-
for (const st of
|
|
8380
|
+
if (sep43)
|
|
8381
|
+
for (const st of sep43) {
|
|
7955
8382
|
if (st === valueProps.found)
|
|
7956
8383
|
break;
|
|
7957
8384
|
if (st.type === "newline") {
|
|
@@ -7968,7 +8395,7 @@ var require_resolve_flow_collection = __commonJS((exports) => {
|
|
|
7968
8395
|
else
|
|
7969
8396
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
7970
8397
|
}
|
|
7971
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
8398
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep43, null, valueProps, onError) : null;
|
|
7972
8399
|
if (valueNode) {
|
|
7973
8400
|
if (isBlock(value))
|
|
7974
8401
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -8141,7 +8568,7 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
8141
8568
|
chompStart = i + 1;
|
|
8142
8569
|
}
|
|
8143
8570
|
let value = "";
|
|
8144
|
-
let
|
|
8571
|
+
let sep43 = "";
|
|
8145
8572
|
let prevMoreIndented = false;
|
|
8146
8573
|
for (let i = 0;i < contentStart; ++i)
|
|
8147
8574
|
value += lines[i][0].slice(trimIndent) + `
|
|
@@ -8159,33 +8586,33 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
8159
8586
|
indent = "";
|
|
8160
8587
|
}
|
|
8161
8588
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
8162
|
-
value +=
|
|
8163
|
-
|
|
8589
|
+
value += sep43 + indent.slice(trimIndent) + content;
|
|
8590
|
+
sep43 = `
|
|
8164
8591
|
`;
|
|
8165
8592
|
} else if (indent.length > trimIndent || content[0] === "\t") {
|
|
8166
|
-
if (
|
|
8167
|
-
|
|
8593
|
+
if (sep43 === " ")
|
|
8594
|
+
sep43 = `
|
|
8168
8595
|
`;
|
|
8169
|
-
else if (!prevMoreIndented &&
|
|
8596
|
+
else if (!prevMoreIndented && sep43 === `
|
|
8170
8597
|
`)
|
|
8171
|
-
|
|
8598
|
+
sep43 = `
|
|
8172
8599
|
|
|
8173
8600
|
`;
|
|
8174
|
-
value +=
|
|
8175
|
-
|
|
8601
|
+
value += sep43 + indent.slice(trimIndent) + content;
|
|
8602
|
+
sep43 = `
|
|
8176
8603
|
`;
|
|
8177
8604
|
prevMoreIndented = true;
|
|
8178
8605
|
} else if (content === "") {
|
|
8179
|
-
if (
|
|
8606
|
+
if (sep43 === `
|
|
8180
8607
|
`)
|
|
8181
8608
|
value += `
|
|
8182
8609
|
`;
|
|
8183
8610
|
else
|
|
8184
|
-
|
|
8611
|
+
sep43 = `
|
|
8185
8612
|
`;
|
|
8186
8613
|
} else {
|
|
8187
|
-
value +=
|
|
8188
|
-
|
|
8614
|
+
value += sep43 + content;
|
|
8615
|
+
sep43 = " ";
|
|
8189
8616
|
prevMoreIndented = false;
|
|
8190
8617
|
}
|
|
8191
8618
|
}
|
|
@@ -8364,27 +8791,27 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
8364
8791
|
if (!match)
|
|
8365
8792
|
return source;
|
|
8366
8793
|
let res = match[1];
|
|
8367
|
-
let
|
|
8794
|
+
let sep43 = " ";
|
|
8368
8795
|
let pos = first.lastIndex;
|
|
8369
8796
|
line.lastIndex = pos;
|
|
8370
8797
|
while (match = line.exec(source)) {
|
|
8371
8798
|
if (match[1] === "") {
|
|
8372
|
-
if (
|
|
8799
|
+
if (sep43 === `
|
|
8373
8800
|
`)
|
|
8374
|
-
res +=
|
|
8801
|
+
res += sep43;
|
|
8375
8802
|
else
|
|
8376
|
-
|
|
8803
|
+
sep43 = `
|
|
8377
8804
|
`;
|
|
8378
8805
|
} else {
|
|
8379
|
-
res +=
|
|
8380
|
-
|
|
8806
|
+
res += sep43 + match[1];
|
|
8807
|
+
sep43 = " ";
|
|
8381
8808
|
}
|
|
8382
8809
|
pos = line.lastIndex;
|
|
8383
8810
|
}
|
|
8384
8811
|
const last = /[ \t]*(.*)/sy;
|
|
8385
8812
|
last.lastIndex = pos;
|
|
8386
8813
|
match = last.exec(source);
|
|
8387
|
-
return res +
|
|
8814
|
+
return res + sep43 + (match?.[1] ?? "");
|
|
8388
8815
|
}
|
|
8389
8816
|
function doubleQuotedValue(source, onError) {
|
|
8390
8817
|
let res = "";
|
|
@@ -9151,14 +9578,14 @@ var require_cst_stringify = __commonJS((exports) => {
|
|
|
9151
9578
|
}
|
|
9152
9579
|
}
|
|
9153
9580
|
}
|
|
9154
|
-
function stringifyItem({ start, key, sep:
|
|
9581
|
+
function stringifyItem({ start, key, sep: sep43, value }) {
|
|
9155
9582
|
let res = "";
|
|
9156
9583
|
for (const st of start)
|
|
9157
9584
|
res += st.source;
|
|
9158
9585
|
if (key)
|
|
9159
9586
|
res += stringifyToken(key);
|
|
9160
|
-
if (
|
|
9161
|
-
for (const st of
|
|
9587
|
+
if (sep43)
|
|
9588
|
+
for (const st of sep43)
|
|
9162
9589
|
res += st.source;
|
|
9163
9590
|
if (value)
|
|
9164
9591
|
res += stringifyToken(value);
|
|
@@ -10297,18 +10724,18 @@ var require_parser = __commonJS((exports) => {
|
|
|
10297
10724
|
if (this.type === "map-value-ind") {
|
|
10298
10725
|
const prev = getPrevProps(this.peek(2));
|
|
10299
10726
|
const start = getFirstKeyStartProps(prev);
|
|
10300
|
-
let
|
|
10727
|
+
let sep43;
|
|
10301
10728
|
if (scalar.end) {
|
|
10302
|
-
|
|
10303
|
-
|
|
10729
|
+
sep43 = scalar.end;
|
|
10730
|
+
sep43.push(this.sourceToken);
|
|
10304
10731
|
delete scalar.end;
|
|
10305
10732
|
} else
|
|
10306
|
-
|
|
10733
|
+
sep43 = [this.sourceToken];
|
|
10307
10734
|
const map = {
|
|
10308
10735
|
type: "block-map",
|
|
10309
10736
|
offset: scalar.offset,
|
|
10310
10737
|
indent: scalar.indent,
|
|
10311
|
-
items: [{ start, key: scalar, sep:
|
|
10738
|
+
items: [{ start, key: scalar, sep: sep43 }]
|
|
10312
10739
|
};
|
|
10313
10740
|
this.onKeyLine = true;
|
|
10314
10741
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -10462,15 +10889,15 @@ var require_parser = __commonJS((exports) => {
|
|
|
10462
10889
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
10463
10890
|
const start2 = getFirstKeyStartProps(it.start);
|
|
10464
10891
|
const key = it.key;
|
|
10465
|
-
const
|
|
10466
|
-
|
|
10892
|
+
const sep43 = it.sep;
|
|
10893
|
+
sep43.push(this.sourceToken);
|
|
10467
10894
|
delete it.key;
|
|
10468
10895
|
delete it.sep;
|
|
10469
10896
|
this.stack.push({
|
|
10470
10897
|
type: "block-map",
|
|
10471
10898
|
offset: this.offset,
|
|
10472
10899
|
indent: this.indent,
|
|
10473
|
-
items: [{ start: start2, key, sep:
|
|
10900
|
+
items: [{ start: start2, key, sep: sep43 }]
|
|
10474
10901
|
});
|
|
10475
10902
|
} else if (start.length > 0) {
|
|
10476
10903
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -10664,13 +11091,13 @@ var require_parser = __commonJS((exports) => {
|
|
|
10664
11091
|
const prev = getPrevProps(parent);
|
|
10665
11092
|
const start = getFirstKeyStartProps(prev);
|
|
10666
11093
|
fixFlowSeqItems(fc);
|
|
10667
|
-
const
|
|
10668
|
-
|
|
11094
|
+
const sep43 = fc.end.splice(1, fc.end.length);
|
|
11095
|
+
sep43.push(this.sourceToken);
|
|
10669
11096
|
const map = {
|
|
10670
11097
|
type: "block-map",
|
|
10671
11098
|
offset: fc.offset,
|
|
10672
11099
|
indent: fc.indent,
|
|
10673
|
-
items: [{ start, key: fc, sep:
|
|
11100
|
+
items: [{ start, key: fc, sep: sep43 }]
|
|
10674
11101
|
};
|
|
10675
11102
|
this.onKeyLine = true;
|
|
10676
11103
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -10906,9 +11333,9 @@ function pathsResolverAssertApp2(app) {
|
|
|
10906
11333
|
}
|
|
10907
11334
|
function pathsResolverDataBaseDir(options) {
|
|
10908
11335
|
const env = options.env ?? process.env;
|
|
10909
|
-
const
|
|
10910
|
-
if (typeof
|
|
10911
|
-
return
|
|
11336
|
+
const override2 = env[PATHS_RESOLVER_DATA_ENV];
|
|
11337
|
+
if (typeof override2 === "string" && override2.length > 0)
|
|
11338
|
+
return override2;
|
|
10912
11339
|
const home = options.home ?? pathsResolverHomedir2();
|
|
10913
11340
|
const platform = options.platform ?? process.platform;
|
|
10914
11341
|
return platform === "darwin" ? pathsResolverJoin2(home, "Library", "Application Support", "Hasna") : pathsResolverJoin2(home, ".local", "share", "hasna");
|
|
@@ -10927,7 +11354,7 @@ function effectiveHome() {
|
|
|
10927
11354
|
return process.env["HOME"] || process.env["USERPROFILE"] || homedir6() || "/tmp";
|
|
10928
11355
|
}
|
|
10929
11356
|
function legacyDataRoot() {
|
|
10930
|
-
return
|
|
11357
|
+
return join13(effectiveHome(), ".hasna", "skills");
|
|
10931
11358
|
}
|
|
10932
11359
|
function resolverDataRoot(home = effectiveHome(), env) {
|
|
10933
11360
|
return dataDir2({ app: "skills", home, env });
|
|
@@ -10936,13 +11363,13 @@ function adoptResolverDataRoot2(resolved, env = process.env) {
|
|
|
10936
11363
|
const dataOverride = env.HASNA_DATA_HOME;
|
|
10937
11364
|
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
10938
11365
|
return true;
|
|
10939
|
-
return
|
|
11366
|
+
return existsSync11(join13(resolved, DEFAULT_SQLITE_FILENAME)) || existsSync11(join13(resolved, GLOBAL_CONFIG_FILENAME));
|
|
10940
11367
|
}
|
|
10941
11368
|
function exactDataRoot() {
|
|
10942
11369
|
for (const key of [DATA_DIR_ENV, HASNA_SKILLS_HOME_ENV, SKILLS_HOME_ENV]) {
|
|
10943
11370
|
const dir = process.env[key]?.trim();
|
|
10944
11371
|
if (dir)
|
|
10945
|
-
return
|
|
11372
|
+
return resolve6(dir);
|
|
10946
11373
|
}
|
|
10947
11374
|
return;
|
|
10948
11375
|
}
|
|
@@ -10951,7 +11378,7 @@ function getDataRoot() {
|
|
|
10951
11378
|
if (exact)
|
|
10952
11379
|
return exact;
|
|
10953
11380
|
const resolved = resolverDataRoot();
|
|
10954
|
-
return adoptResolverDataRoot2(resolved) ?
|
|
11381
|
+
return adoptResolverDataRoot2(resolved) ? resolve6(resolved) : resolve6(legacyDataRoot());
|
|
10955
11382
|
}
|
|
10956
11383
|
var GLOBAL_ONLY_KEYS = new Set(["sessionPinMigration", "driftReportProject", "driftReportAssignee", "driftReportTodosBin"]);
|
|
10957
11384
|
function getDataDirReadOnly() {
|
|
@@ -11146,7 +11573,7 @@ function collectDirectory(files, dir, rel) {
|
|
|
11146
11573
|
}
|
|
11147
11574
|
function collectFile(files, absolute, rel) {
|
|
11148
11575
|
const buffer = readFileSync42(absolute);
|
|
11149
|
-
files.push(normalizeBundleFile(rel.split(
|
|
11576
|
+
files.push(normalizeBundleFile(rel.split(sep4).join("/"), buffer));
|
|
11150
11577
|
}
|
|
11151
11578
|
function normalizeBundleFile(rel, buffer) {
|
|
11152
11579
|
if (rel === "skill.json") {
|
|
@@ -11171,7 +11598,7 @@ function* bundleHashParts(files) {
|
|
|
11171
11598
|
yield new TextEncoder().encode("\x00");
|
|
11172
11599
|
}
|
|
11173
11600
|
function hashBundleFiles(files) {
|
|
11174
|
-
const hash =
|
|
11601
|
+
const hash = createHash8(CONTENT_HASH_ALGORITHM);
|
|
11175
11602
|
for (const part of bundleHashParts(files))
|
|
11176
11603
|
hash.update(part);
|
|
11177
11604
|
return hash.digest("hex");
|
|
@@ -11682,7 +12109,7 @@ var sameFile = (a, b) => a.dev === b.dev && a.ino === b.ino && a.mode === b.mode
|
|
|
11682
12109
|
function parents(path) {
|
|
11683
12110
|
const result = [];
|
|
11684
12111
|
for (let at = dirname42(path);; at = dirname42(at)) {
|
|
11685
|
-
const stat =
|
|
12112
|
+
const stat = lstatSync52(at, { bigint: true });
|
|
11686
12113
|
need(stat.isDirectory() && !stat.isSymbolicLink(), "path traverses a symlink or non-directory");
|
|
11687
12114
|
result.push([at, stat]);
|
|
11688
12115
|
if (at === dirname42(at))
|
|
@@ -11691,13 +12118,13 @@ function parents(path) {
|
|
|
11691
12118
|
}
|
|
11692
12119
|
function readNativeSettingsWitnessFile(path, budget, filename = "settings.json") {
|
|
11693
12120
|
absolutePath(path);
|
|
11694
|
-
need(
|
|
12121
|
+
need(basename22(path) === filename, `requires ${filename}`);
|
|
11695
12122
|
return readNativeDiscoveryWitnessFile(path, budget);
|
|
11696
12123
|
}
|
|
11697
12124
|
function readNativeDiscoveryWitnessFile(path, budget) {
|
|
11698
12125
|
absolutePath(path);
|
|
11699
12126
|
need(Number.isSafeInteger(budget.remaining) && budget.remaining >= 0, "has an invalid byte budget");
|
|
11700
|
-
const ancestors = parents(path), initial =
|
|
12127
|
+
const ancestors = parents(path), initial = lstatSync52(path, { bigint: true });
|
|
11701
12128
|
need(initial.isFile() && !initial.isSymbolicLink() && initial.size <= BigInt(CLAUDE_SETTINGS_WITNESS_LIMITS.bytes), "is not a bounded regular file");
|
|
11702
12129
|
need(initial.size <= BigInt(budget.remaining), "exceeds its aggregate byte limit");
|
|
11703
12130
|
const fd = openSync22(path, constants22.O_RDONLY | constants22.O_NOFOLLOW | constants22.O_NONBLOCK);
|
|
@@ -11712,10 +12139,10 @@ function readNativeDiscoveryWitnessFile(path, budget) {
|
|
|
11712
12139
|
break;
|
|
11713
12140
|
length += count;
|
|
11714
12141
|
}
|
|
11715
|
-
const after = fstatSync22(fd, { bigint: true }), current2 =
|
|
12142
|
+
const after = fstatSync22(fd, { bigint: true }), current2 = lstatSync52(path, { bigint: true });
|
|
11716
12143
|
need(current2.isFile() && sameFile(opened, after) && sameFile(after, current2) && BigInt(length) === opened.size, "changed during read");
|
|
11717
12144
|
for (const [ancestor, before] of ancestors) {
|
|
11718
|
-
const now =
|
|
12145
|
+
const now = lstatSync52(ancestor, { bigint: true });
|
|
11719
12146
|
need(now.isDirectory() && before.dev === now.dev && before.ino === now.ino && before.mode === now.mode, "parent changed during read");
|
|
11720
12147
|
}
|
|
11721
12148
|
budget.remaining -= length;
|
|
@@ -11973,9 +12400,9 @@ function upgradeClaudeSettingsWitness(previous, reviewedSettingsPath) {
|
|
|
11973
12400
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget), current2 = readNativeSettingsWitnessFile(previous.path, budget);
|
|
11974
12401
|
const beforeDigest = previous.hashMode === undefined || previous.hashMode === "bytes" ? createHash42("sha256").update(before).digest("hex") : settingsDigest(before, previous.hashMode === "claude-settings-v1" ? 1 : 2);
|
|
11975
12402
|
need(beforeDigest === previous.sha256, "reviewed preimage does not match the legacy witness");
|
|
11976
|
-
const
|
|
11977
|
-
need(settingsDigest(before, 3) ===
|
|
11978
|
-
return { path: previous.path, hashMode: "claude-settings-v3", sha256 };
|
|
12403
|
+
const sha2563 = settingsDigest(current2, 3);
|
|
12404
|
+
need(settingsDigest(before, 3) === sha2563, "non-preference settings changed; explicit discovery review required");
|
|
12405
|
+
return { path: previous.path, hashMode: "claude-settings-v3", sha256: sha2563 };
|
|
11979
12406
|
}
|
|
11980
12407
|
function captureClaudeSettingsV4(path, budget = { remaining: 256 * 1024 * 1024 }) {
|
|
11981
12408
|
return { path, hashMode: "claude-settings-v4", sha256: settingsDigest(readNativeSettingsWitnessFile(path, budget), 4) };
|
|
@@ -11993,9 +12420,9 @@ function upgradeClaudeSettingsWitnessV4(previous, reviewedSettingsPath) {
|
|
|
11993
12420
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget), current2 = readNativeSettingsWitnessFile(previous.path, budget);
|
|
11994
12421
|
const beforeDigest = previous.hashMode === undefined || previous.hashMode === "bytes" ? createHash42("sha256").update(before).digest("hex") : settingsDigest(before, previous.hashMode === "claude-settings-v1" ? 1 : previous.hashMode === "claude-settings-v2" ? 2 : 3);
|
|
11995
12422
|
need(beforeDigest === previous.sha256, "reviewed preimage does not match the prior witness");
|
|
11996
|
-
const
|
|
11997
|
-
need(settingsDigest(before, 4) ===
|
|
11998
|
-
return { path: previous.path, hashMode: "claude-settings-v4", sha256 };
|
|
12423
|
+
const sha2563 = settingsDigest(current2, 4);
|
|
12424
|
+
need(settingsDigest(before, 4) === sha2563, "non-preference settings changed; explicit discovery review required");
|
|
12425
|
+
return { path: previous.path, hashMode: "claude-settings-v4", sha256: sha2563 };
|
|
11999
12426
|
}
|
|
12000
12427
|
var V5_DISCOVERY_KEY = /skill|plugin|hook|marketplace/i;
|
|
12001
12428
|
var V5_BOUND_KEYS = new Set(["apiKeyHelper", "awsAuthRefresh", "awsCredentialExport", "otelHeadersHelper", "fileSuggestion", "outputStyle", "agent"]);
|
|
@@ -12072,9 +12499,9 @@ function upgradeClaudeSettingsWitnessV5(previous, reviewedSettingsPath) {
|
|
|
12072
12499
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget), current2 = readNativeSettingsWitnessFile(previous.path, budget);
|
|
12073
12500
|
const beforeDigest = previous.hashMode === undefined || previous.hashMode === "bytes" ? createHash42("sha256").update(before).digest("hex") : settingsDigest(before, previous.hashMode === "claude-settings-v1" ? 1 : previous.hashMode === "claude-settings-v2" ? 2 : previous.hashMode === "claude-settings-v3" ? 3 : 4);
|
|
12074
12501
|
need(beforeDigest === previous.sha256, "reviewed preimage does not match the prior witness");
|
|
12075
|
-
const
|
|
12076
|
-
need(settingsDigestV5(before) ===
|
|
12077
|
-
return { path: previous.path, hashMode: "claude-settings-v5", sha256 };
|
|
12502
|
+
const sha2563 = settingsDigestV5(current2);
|
|
12503
|
+
need(settingsDigestV5(before) === sha2563, "discovery settings changed; explicit discovery review required");
|
|
12504
|
+
return { path: previous.path, hashMode: "claude-settings-v5", sha256: sha2563 };
|
|
12078
12505
|
}
|
|
12079
12506
|
function hashNativeJsonControls(text, excludedMetadata) {
|
|
12080
12507
|
need(Buffer.byteLength(text) <= CLAUDE_SETTINGS_WITNESS_LIMITS.bytes, "exceeds its byte limit");
|
|
@@ -12224,7 +12651,7 @@ var stringArray = (value) => value?.kind === "array" && value.items.every(isStri
|
|
|
12224
12651
|
var stringObject = (value) => value?.kind === "object" && value.entries.every(([, item]) => isString(item));
|
|
12225
12652
|
function claudeMarketplaceEntrySourceValid(source) {
|
|
12226
12653
|
const path = source?.path;
|
|
12227
|
-
return typeof path === "string" && path.length > 0 && path.length <= PATH_CHARACTERS && !/[\x00-\x1f\x7f]/.test(path) &&
|
|
12654
|
+
return typeof path === "string" && path.length > 0 && path.length <= PATH_CHARACTERS && !/[\x00-\x1f\x7f]/.test(path) && isAbsolute42(path) && resolve42(path) === path && basename3(path) === "marketplace.json" && basename3(dirname52(path)) === ".claude-plugin" && typeof source.marketplace === "string" && NAME.test(source.marketplace) && !source.marketplace.includes("..") && typeof source.plugin === "string" && NAME.test(source.plugin);
|
|
12228
12655
|
}
|
|
12229
12656
|
function canonical2(value) {
|
|
12230
12657
|
if (value.kind === "string")
|
|
@@ -12352,7 +12779,7 @@ function captureClaudeMarketplaceEntry(path, marketplace, plugin, budget2 = { re
|
|
|
12352
12779
|
var CLAUDE_ORPHAN_MARKER_MODE = "claude-plugin-orphaned-at-v1";
|
|
12353
12780
|
var CACHE = `${sep22}.claude${sep22}plugins${sep22}cache${sep22}`;
|
|
12354
12781
|
function isClaudePluginCacheOrphanMarker(path) {
|
|
12355
|
-
if (typeof path !== "string" || basename4(path) !== ".orphaned_at" || !isAbsolute5(path) ||
|
|
12782
|
+
if (typeof path !== "string" || basename4(path) !== ".orphaned_at" || !isAbsolute5(path) || resolve52(path) !== path || path.includes("\x00"))
|
|
12356
12783
|
return false;
|
|
12357
12784
|
const at = path.indexOf(CACHE);
|
|
12358
12785
|
if (at < 0 || path.indexOf(CACHE, at + 1) >= 0)
|
|
@@ -12365,7 +12792,7 @@ function same(left, right) {
|
|
|
12365
12792
|
}
|
|
12366
12793
|
function safe(path) {
|
|
12367
12794
|
for (let cursor = path;; cursor = dirname62(cursor)) {
|
|
12368
|
-
if (
|
|
12795
|
+
if (lstatSync62(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
12369
12796
|
throw new Error("Refusing symlink Claude orphan marker input");
|
|
12370
12797
|
if (dirname62(cursor) === cursor)
|
|
12371
12798
|
break;
|
|
@@ -12377,7 +12804,7 @@ function hashClaudePluginCacheOrphanMarker(path, budget2, changes) {
|
|
|
12377
12804
|
if (changes?.has(path))
|
|
12378
12805
|
throw new Error("Claude orphan markers cannot intersect a planned write");
|
|
12379
12806
|
safe(path);
|
|
12380
|
-
const before =
|
|
12807
|
+
const before = lstatSync62(path, { throwIfNoEntry: false });
|
|
12381
12808
|
if (!before)
|
|
12382
12809
|
return null;
|
|
12383
12810
|
const uid = process.getuid?.();
|
|
@@ -12398,7 +12825,7 @@ function hashClaudePluginCacheOrphanMarker(path, budget2, changes) {
|
|
|
12398
12825
|
}
|
|
12399
12826
|
if (!/^[1-9][0-9]{12}$/.test(bytes.subarray(0, length).toString("latin1")))
|
|
12400
12827
|
throw new Error("Malformed Claude orphan marker timestamp");
|
|
12401
|
-
const after = fstatSync3(fd), current2 =
|
|
12828
|
+
const after = fstatSync3(fd), current2 = lstatSync62(path, { throwIfNoEntry: false });
|
|
12402
12829
|
safe(path);
|
|
12403
12830
|
if (!same(opened, after) || !same(after, current2) || length !== after.size)
|
|
12404
12831
|
throw new Error("Claude orphan marker changed during read");
|
|
@@ -12407,7 +12834,7 @@ function hashClaudePluginCacheOrphanMarker(path, budget2, changes) {
|
|
|
12407
12834
|
throw new Error("Raw discovery aggregate byte limit exceeded");
|
|
12408
12835
|
budget2.remaining -= length;
|
|
12409
12836
|
}
|
|
12410
|
-
return
|
|
12837
|
+
return createHash72("sha256").update(`${CLAUDE_ORPHAN_MARKER_MODE}\x00${path}\x00file`).digest("hex");
|
|
12411
12838
|
} finally {
|
|
12412
12839
|
closeSync32(fd);
|
|
12413
12840
|
}
|
|
@@ -12465,7 +12892,7 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12465
12892
|
text(control.pluginId, 1024);
|
|
12466
12893
|
text(control.namespace, 64);
|
|
12467
12894
|
text(control.pluginParent);
|
|
12468
|
-
requireBound(isAbsolute6(control.pluginParent) &&
|
|
12895
|
+
requireBound(isAbsolute6(control.pluginParent) && resolve62(control.pluginParent) === control.pluginParent && /^[a-f0-9]{64}$/.test(control.manifestSha256));
|
|
12469
12896
|
if (control.remotePluginId !== undefined)
|
|
12470
12897
|
requireBound(typeof control.remotePluginId === "string" && /^[A-Za-z0-9_~-]{1,1024}$/.test(control.remotePluginId));
|
|
12471
12898
|
if (control.skillsOnly !== undefined)
|
|
@@ -12483,7 +12910,7 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12483
12910
|
text(control.pluginId, 1024);
|
|
12484
12911
|
text(control.namespace, 64);
|
|
12485
12912
|
text(control.pluginParent);
|
|
12486
|
-
requireBound(!ids.has(control.pluginId) && isAbsolute6(control.pluginParent) &&
|
|
12913
|
+
requireBound(!ids.has(control.pluginId) && isAbsolute6(control.pluginParent) && resolve62(control.pluginParent) === control.pluginParent && ["local", "git", "npm"].includes(control.sourceType) && typeof control.sourceSha256 === "string" && /^[a-f0-9]{64}$/.test(control.sourceSha256));
|
|
12487
12914
|
ids.add(control.pluginId);
|
|
12488
12915
|
}
|
|
12489
12916
|
}
|
|
@@ -12492,7 +12919,7 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12492
12919
|
requireBound(agent === "gemini" && object(executable) && Object.keys(executable).length === 3 && executable.command === "gemini");
|
|
12493
12920
|
for (const path of [executable.path, executable.target]) {
|
|
12494
12921
|
text(path);
|
|
12495
|
-
requireBound(!/[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]/.test(path) && isAbsolute6(path) &&
|
|
12922
|
+
requireBound(!/[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]/.test(path) && isAbsolute6(path) && resolve62(path) === path);
|
|
12496
12923
|
}
|
|
12497
12924
|
}
|
|
12498
12925
|
if (bridge.disabledBuiltins !== undefined)
|
|
@@ -12520,11 +12947,11 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12520
12947
|
requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && Object.keys(proof).every((key) => ["roots", "parents", "directories"].includes(key)) && roots.length + parents2.length > 0 && new Set(roots).size === roots.length && new Set(parents2).size === parents2.length);
|
|
12521
12948
|
for (const root of roots) {
|
|
12522
12949
|
text(root);
|
|
12523
|
-
requireBound(isAbsolute6(root) &&
|
|
12950
|
+
requireBound(isAbsolute6(root) && resolve62(root) === root);
|
|
12524
12951
|
}
|
|
12525
12952
|
for (const parent of parents2) {
|
|
12526
12953
|
text(parent);
|
|
12527
|
-
requireBound(isAbsolute6(parent) &&
|
|
12954
|
+
requireBound(isAbsolute6(parent) && resolve62(parent) === parent);
|
|
12528
12955
|
}
|
|
12529
12956
|
for (const directory of array(proof.directories, AGENT_POLICY_LIMITS.discoveryDirectories)) {
|
|
12530
12957
|
requireBound(object(directory));
|
|
@@ -12544,7 +12971,7 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12544
12971
|
text(input.namespace, 64);
|
|
12545
12972
|
text(input.pluginParent);
|
|
12546
12973
|
text(input.sourceRoot);
|
|
12547
|
-
requireBound(!ids.has(input.pluginId) && [input.pluginParent, input.sourceRoot].every((path) => isAbsolute6(path) &&
|
|
12974
|
+
requireBound(!ids.has(input.pluginId) && [input.pluginParent, input.sourceRoot].every((path) => isAbsolute6(path) && resolve62(path) === path) && typeof input.sourceSha256 === "string" && /^[a-f0-9]{64}$/.test(input.sourceSha256));
|
|
12548
12975
|
ids.add(input.pluginId);
|
|
12549
12976
|
}
|
|
12550
12977
|
if (proof.directories !== undefined)
|
|
@@ -12558,14 +12985,14 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12558
12985
|
const proof = record(value.codexSemanticCache, 9), witness = record(proof.witness, 7);
|
|
12559
12986
|
requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && [8, 9].includes(Object.keys(proof).length) && Object.keys(proof).every((key) => ["schema", "configPath", "hookRootAlias", "witness", "appOnlyParents", "previousPolicySha256", "supersededSources", "supersededDirectories", "reviewedHookParents"].includes(key)) && proof.schema === "hasna.codex-semantic-cache-discovery.v1" && typeof proof.previousPolicySha256 === "string" && /^[a-f0-9]{64}$/.test(proof.previousPolicySha256) && [6, 7].includes(Object.keys(witness).length) && Object.keys(witness).every((key) => ["schema", "cacheRoot", "controls", "appOnlyParents", "skills", "sha256", "hookParents"].includes(key)) && witness.schema === "hasna.codex-semantic-cache-witness.v1" && typeof witness.sha256 === "string" && /^[a-f0-9]{64}$/.test(witness.sha256));
|
|
12560
12987
|
text(proof.configPath);
|
|
12561
|
-
requireBound(isAbsolute6(proof.configPath) &&
|
|
12988
|
+
requireBound(isAbsolute6(proof.configPath) && resolve62(proof.configPath) === proof.configPath && basename5(proof.configPath) === "config.toml");
|
|
12562
12989
|
text(witness.cacheRoot);
|
|
12563
|
-
requireBound(isAbsolute6(witness.cacheRoot) &&
|
|
12990
|
+
requireBound(isAbsolute6(witness.cacheRoot) && resolve62(witness.cacheRoot) === witness.cacheRoot);
|
|
12564
12991
|
if (proof.hookRootAlias !== null) {
|
|
12565
12992
|
requireBound(object(proof.hookRootAlias) && Object.keys(proof.hookRootAlias).length === 2);
|
|
12566
12993
|
for (const key of ["alias", "target"]) {
|
|
12567
12994
|
text(proof.hookRootAlias[key]);
|
|
12568
|
-
requireBound(isAbsolute6(proof.hookRootAlias[key]) &&
|
|
12995
|
+
requireBound(isAbsolute6(proof.hookRootAlias[key]) && resolve62(proof.hookRootAlias[key]) === proof.hookRootAlias[key]);
|
|
12569
12996
|
}
|
|
12570
12997
|
}
|
|
12571
12998
|
const parents2 = array(proof.appOnlyParents, 4096);
|
|
@@ -12573,7 +13000,7 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12573
13000
|
requireBound(object(parent) && Object.keys(parent).length === 5 && parent.role === "app-only");
|
|
12574
13001
|
for (const key of ["pluginId", "namespace", "pluginParent", "remotePluginId"])
|
|
12575
13002
|
text(parent[key]);
|
|
12576
|
-
requireBound(isAbsolute6(parent.pluginParent) &&
|
|
13003
|
+
requireBound(isAbsolute6(parent.pluginParent) && resolve62(parent.pluginParent) === parent.pluginParent);
|
|
12577
13004
|
}
|
|
12578
13005
|
if (proof.reviewedHookParents !== undefined)
|
|
12579
13006
|
for (const parent of array(proof.reviewedHookParents, 4096)) {
|
|
@@ -12585,9 +13012,9 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12585
13012
|
text(parent.remotePluginId);
|
|
12586
13013
|
else {
|
|
12587
13014
|
text(parent.marketplaceSourcePath);
|
|
12588
|
-
requireBound(typeof parent.marketplaceSha256 === "string" && /^[a-f0-9]{64}$/.test(parent.marketplaceSha256) && isAbsolute6(parent.marketplaceSourcePath) &&
|
|
13015
|
+
requireBound(typeof parent.marketplaceSha256 === "string" && /^[a-f0-9]{64}$/.test(parent.marketplaceSha256) && isAbsolute6(parent.marketplaceSourcePath) && resolve62(parent.marketplaceSourcePath) === parent.marketplaceSourcePath && basename5(parent.marketplaceSourcePath) === "marketplace.json");
|
|
12589
13016
|
}
|
|
12590
|
-
requireBound(isAbsolute6(parent.pluginParent) &&
|
|
13017
|
+
requireBound(isAbsolute6(parent.pluginParent) && resolve62(parent.pluginParent) === parent.pluginParent);
|
|
12591
13018
|
}
|
|
12592
13019
|
for (const row of [...array(witness.controls, 4096), ...array(witness.appOnlyParents, 4096)]) {
|
|
12593
13020
|
requireBound(object(row));
|
|
@@ -12607,9 +13034,9 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12607
13034
|
text(row.remotePluginId);
|
|
12608
13035
|
else {
|
|
12609
13036
|
text(row.marketplaceSourcePath);
|
|
12610
|
-
requireBound(typeof row.marketplaceSha256 === "string" && /^[a-f0-9]{64}$/.test(row.marketplaceSha256) && isAbsolute6(row.marketplaceSourcePath) &&
|
|
13037
|
+
requireBound(typeof row.marketplaceSha256 === "string" && /^[a-f0-9]{64}$/.test(row.marketplaceSha256) && isAbsolute6(row.marketplaceSourcePath) && resolve62(row.marketplaceSourcePath) === row.marketplaceSourcePath && basename5(row.marketplaceSourcePath) === "marketplace.json");
|
|
12611
13038
|
}
|
|
12612
|
-
requireBound(isAbsolute6(row.pluginParent) &&
|
|
13039
|
+
requireBound(isAbsolute6(row.pluginParent) && resolve62(row.pluginParent) === row.pluginParent);
|
|
12613
13040
|
for (const key of ["manifestSha256", "hooksSha256"])
|
|
12614
13041
|
requireBound(typeof row[key] === "string" && /^[a-f0-9]{64}$/.test(row[key]));
|
|
12615
13042
|
if (row.installation === "remote-receipt")
|
|
@@ -12646,13 +13073,13 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12646
13073
|
if (source.hashMode === CLAUDE_ORPHAN_MARKER_MODE)
|
|
12647
13074
|
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && isClaudePluginCacheOrphanMarker(source.path) && source.managedPlugins === undefined && source.reviewArtifact === undefined);
|
|
12648
13075
|
if (source.hashMode === "executable-v1")
|
|
12649
|
-
requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && value.sources.some((row) => row.hashMode === "codex-settings-v6") && isAbsolute6(source.path) &&
|
|
13076
|
+
requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && value.sources.some((row) => row.hashMode === "codex-settings-v6") && isAbsolute6(source.path) && resolve62(source.path) === source.path);
|
|
12650
13077
|
if (source.hashMode === "codex-settings-v6") {
|
|
12651
13078
|
const seen = new Set;
|
|
12652
13079
|
for (const hook of array(source.hookSources, AGENT_POLICY_LIMITS.discoverySources)) {
|
|
12653
13080
|
requireBound(object(hook) && Object.keys(hook).length === 2 && Object.keys(hook).every((key) => ["path", "sha256"].includes(key)));
|
|
12654
13081
|
text(hook.path);
|
|
12655
|
-
requireBound(isAbsolute6(hook.path) &&
|
|
13082
|
+
requireBound(isAbsolute6(hook.path) && resolve62(hook.path) === hook.path && !seen.has(hook.path));
|
|
12656
13083
|
seen.add(hook.path);
|
|
12657
13084
|
requireBound(hook.sha256 === null || typeof hook.sha256 === "string" && /^[a-f0-9]{64}$/.test(hook.sha256));
|
|
12658
13085
|
requireBound(value.sources.some((row) => row.path === hook.path && row.sha256 === hook.sha256 && [undefined, "bytes"].includes(row.hashMode) && row.format === undefined && row.fields === undefined));
|
|
@@ -12660,15 +13087,15 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12660
13087
|
} else
|
|
12661
13088
|
requireBound(source.hookSources === undefined);
|
|
12662
13089
|
if (source.hashMode === "claude-plugin-manifest-v1")
|
|
12663
|
-
requireBound(agent === "claude" && value.agent === "claude" && ["automatic", "reviewed"].includes(value.method) && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) &&
|
|
13090
|
+
requireBound(agent === "claude" && value.agent === "claude" && ["automatic", "reviewed"].includes(value.method) && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) && resolve62(source.path) === source.path && source.path.endsWith(join92(sep32, ".claude-plugin", "plugin.json")) && source.managedPlugins === undefined);
|
|
12664
13091
|
if (source.hashMode === "sumi-settings-v1")
|
|
12665
|
-
requireBound(agent === "sumi" && value.agent === "sumi" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) &&
|
|
13092
|
+
requireBound(agent === "sumi" && value.agent === "sumi" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) && resolve62(source.path) === source.path && basename5(source.path) === "sumi.json");
|
|
12666
13093
|
if (source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4" || source.hashMode === "codex-settings-v5" || source.hashMode === "codex-settings-v6" || source.hashMode === "codex-settings-v7" || source.hashMode === "codex-settings-v8"))
|
|
12667
|
-
requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) &&
|
|
13094
|
+
requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) && resolve62(source.path) === source.path && basename5(source.path) === "config.toml");
|
|
12668
13095
|
if (source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || source.hashMode === "claude-settings-v4" || source.hashMode === "claude-settings-v5"))
|
|
12669
|
-
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) &&
|
|
13096
|
+
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) && resolve62(source.path) === source.path && basename5(source.path) === "settings.json");
|
|
12670
13097
|
if (source.hashMode === "claude-marketplace-registry" || source.hashMode === "claude-marketplace-registry-v2")
|
|
12671
|
-
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) &&
|
|
13098
|
+
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute6(source.path) && resolve62(source.path) === source.path && basename5(source.path) === "known_marketplaces.json");
|
|
12672
13099
|
if (source.hashMode === "claude-marketplace-entry-v1")
|
|
12673
13100
|
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && claudeMarketplaceEntrySourceValid(source));
|
|
12674
13101
|
if (source.hashMode === "claude-plugin-registry") {
|
|
@@ -12687,7 +13114,7 @@ function assertAgentPolicyCollections(policy) {
|
|
|
12687
13114
|
requireBound(agent === "codex" && value.method === "reviewed" && source.hashMode === "bytes" && object(artifact) && Object.keys(artifact).length === 6 && Object.keys(artifact).every((key) => ["version", "kind", "storeRoot", "originalPath", "sha256", "catalogSha256"].includes(key)) && artifact.version === 1 && artifact.kind === "codex-native-catalog" && artifact.sha256 === source.sha256 && /^[a-f0-9]{64}$/.test(artifact.catalogSha256));
|
|
12688
13115
|
for (const path of [artifact.storeRoot, artifact.originalPath]) {
|
|
12689
13116
|
text(path);
|
|
12690
|
-
requireBound(isAbsolute6(path) &&
|
|
13117
|
+
requireBound(isAbsolute6(path) && resolve62(path) === path);
|
|
12691
13118
|
}
|
|
12692
13119
|
requireBound(source.path === join92(artifact.storeRoot, "agent-discovery", "artifacts", artifact.sha256, "catalog.json"));
|
|
12693
13120
|
}
|
|
@@ -12793,7 +13220,7 @@ var ENV_PREFIX = new RegExp(`^(${PINNED_LAUNCHER_ENV_PREFIXES.join("|")})_`);
|
|
|
12793
13220
|
var ENV_EXACT = new Set(PINNED_LAUNCHER_ENV_NAMES);
|
|
12794
13221
|
var COMMAND_LINE = new RegExp(`^set -- '([^']+)' ${PINNED_LAUNCHER_BUN_FLAGS2.join(" ")} '--cwd=([^']+)' '([^']+)' "\\$@"$`, "m");
|
|
12795
13222
|
var PINNED_LAUNCHER_MAX_BYTES = 16 * 1024;
|
|
12796
|
-
var INSTALLED_PACKAGE = `${
|
|
13223
|
+
var INSTALLED_PACKAGE = `${sep42}node_modules${sep42}@hasna${sep42}skills${sep42}`;
|
|
12797
13224
|
var DRIFT_REPORT_RETRY_MS = 6 * 60 * 60 * 1000;
|
|
12798
13225
|
var DRIFT_REPORT_LOCK_TTL_MS = 3 * 60 * 1000;
|
|
12799
13226
|
var DRIFT_REPORT_WORKER_DEADLINE_MS = DRIFT_REPORT_LOCK_TTL_MS - 30000;
|
|
@@ -12886,10 +13313,10 @@ function assertHermesEnvironment(home) {
|
|
|
12886
13313
|
throw new NativeBridgeIntegrityRefusal("NATIVE_SKILL_DRIFT: Hermes project plugins require a dedicated discovery review");
|
|
12887
13314
|
}
|
|
12888
13315
|
function read(path) {
|
|
12889
|
-
for (let current2 = path;; current2 =
|
|
13316
|
+
for (let current2 = path;; current2 = dirname82(current2)) {
|
|
12890
13317
|
if (lstatSync8(current2, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
12891
13318
|
throw new Error("NATIVE_SKILL_DRIFT: symlink Hermes protection input");
|
|
12892
|
-
if (
|
|
13319
|
+
if (dirname82(current2) === current2)
|
|
12893
13320
|
break;
|
|
12894
13321
|
}
|
|
12895
13322
|
const stat = lstatSync8(path, { throwIfNoEntry: false });
|
|
@@ -12897,7 +13324,7 @@ function read(path) {
|
|
|
12897
13324
|
return null;
|
|
12898
13325
|
if (!stat.isFile() || stat.size > 1024 * 1024)
|
|
12899
13326
|
throw new Error("NATIVE_SKILL_DRIFT: invalid Hermes protection input");
|
|
12900
|
-
return
|
|
13327
|
+
return readFileSync82(path, "utf8");
|
|
12901
13328
|
}
|
|
12902
13329
|
function assertHermesProtection(home, config, command, profile, supervisor2) {
|
|
12903
13330
|
assertHermesEnvironment(home);
|
|
@@ -12929,10 +13356,10 @@ function assertHermesProtection(home, config, command, profile, supervisor2) {
|
|
|
12929
13356
|
}
|
|
12930
13357
|
function assertNoHermesLegacyShadow(root) {
|
|
12931
13358
|
let entries = 0;
|
|
12932
|
-
for (let cursor = resolve7(root);; cursor =
|
|
13359
|
+
for (let cursor = resolve7(root);; cursor = dirname82(cursor)) {
|
|
12933
13360
|
if (lstatSync8(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
12934
13361
|
throw new NativeBridgeIntegrityRefusal("NATIVE_SKILL_DRIFT: symlink Hermes legacy discovery root");
|
|
12935
|
-
if (
|
|
13362
|
+
if (dirname82(cursor) === cursor)
|
|
12936
13363
|
break;
|
|
12937
13364
|
}
|
|
12938
13365
|
function scan(path, depth) {
|
|
@@ -14120,8 +14547,8 @@ function captureCodexHookMcpDependencies(configPath, reviewed, configText, chang
|
|
|
14120
14547
|
function read2(path) {
|
|
14121
14548
|
const source = rows.get(path);
|
|
14122
14549
|
need5(source);
|
|
14123
|
-
const
|
|
14124
|
-
need5(source.sha256 ===
|
|
14550
|
+
const sha25622 = hashRawDiscoveryFile(path, budget2);
|
|
14551
|
+
need5(source.sha256 === sha25622);
|
|
14125
14552
|
if (changes?.has(path)) {
|
|
14126
14553
|
const text3 = changes.get(path);
|
|
14127
14554
|
need5(Buffer.byteLength(text3) <= 1024 * 1024);
|
|
@@ -14129,11 +14556,11 @@ function captureCodexHookMcpDependencies(configPath, reviewed, configText, chang
|
|
|
14129
14556
|
sources.set(path, { path, sha256: createHash16("sha256").update(text3).digest("hex") });
|
|
14130
14557
|
return text3;
|
|
14131
14558
|
}
|
|
14132
|
-
sources.set(path, { path, sha256:
|
|
14133
|
-
if (
|
|
14559
|
+
sources.set(path, { path, sha256: sha25622 });
|
|
14560
|
+
if (sha25622 === null)
|
|
14134
14561
|
return null;
|
|
14135
14562
|
const text2 = readNativeSettingsWitnessFile(path, budget2, basename6(path));
|
|
14136
|
-
need5(Buffer.byteLength(text2) <= 1024 * 1024 && createHash16("sha256").update(text2).digest("hex") ===
|
|
14563
|
+
need5(Buffer.byteLength(text2) <= 1024 * 1024 && createHash16("sha256").update(text2).digest("hex") === sha25622);
|
|
14137
14564
|
hashNativeJsonControls(text2);
|
|
14138
14565
|
return text2;
|
|
14139
14566
|
}
|
|
@@ -14856,10 +15283,10 @@ function upgradeCodexSettingsWitness(previous, reviewedSettingsPath) {
|
|
|
14856
15283
|
const budget2 = { remaining: 2 * 1024 * 1024 };
|
|
14857
15284
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
|
|
14858
15285
|
need7((previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before)) === previous.sha256);
|
|
14859
|
-
const
|
|
14860
|
-
if (settingsDigest2(before) !==
|
|
15286
|
+
const sha25622 = settingsDigest2(current2);
|
|
15287
|
+
if (settingsDigest2(before) !== sha25622)
|
|
14861
15288
|
throw new Error("Codex non-preference settings changed; explicit discovery review required");
|
|
14862
|
-
return { path: previous.path, hashMode: "codex-settings-v2", sha256:
|
|
15289
|
+
return { path: previous.path, hashMode: "codex-settings-v2", sha256: sha25622 };
|
|
14863
15290
|
}
|
|
14864
15291
|
function hashCodexSettingsReplacementV3(text2, budget2 = { remaining: 256 * 1024 * 1024 }) {
|
|
14865
15292
|
need7(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
|
|
@@ -14872,10 +15299,10 @@ function upgradeCodexSettingsWitnessV3(previous, reviewedSettingsPath) {
|
|
|
14872
15299
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
|
|
14873
15300
|
const original = previous.hashMode === "codex-settings-v2" ? settingsDigest2(before) : previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before);
|
|
14874
15301
|
need7(original === previous.sha256);
|
|
14875
|
-
const
|
|
14876
|
-
if (settingsDigest2(before, 3) !==
|
|
15302
|
+
const sha25622 = settingsDigest2(current2, 3);
|
|
15303
|
+
if (settingsDigest2(before, 3) !== sha25622)
|
|
14877
15304
|
throw new Error("Codex settings outside the reviewed V3 contract changed; explicit discovery review required");
|
|
14878
|
-
return { path: previous.path, hashMode: "codex-settings-v3", sha256:
|
|
15305
|
+
return { path: previous.path, hashMode: "codex-settings-v3", sha256: sha25622 };
|
|
14879
15306
|
}
|
|
14880
15307
|
function hashCodexSettingsReplacementV4(text2, budget2 = { remaining: 256 * 1024 * 1024 }) {
|
|
14881
15308
|
need7(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
|
|
@@ -14888,10 +15315,10 @@ function upgradeCodexSettingsWitnessV4(previous, reviewedSettingsPath) {
|
|
|
14888
15315
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
|
|
14889
15316
|
const original = previous.hashMode === "codex-settings-v3" ? settingsDigest2(before, 3) : previous.hashMode === "codex-settings-v2" ? settingsDigest2(before, 2) : previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before);
|
|
14890
15317
|
need7(original === previous.sha256);
|
|
14891
|
-
const
|
|
14892
|
-
if (settingsDigest2(before, 4) !==
|
|
15318
|
+
const sha25622 = settingsDigest2(current2, 4);
|
|
15319
|
+
if (settingsDigest2(before, 4) !== sha25622)
|
|
14893
15320
|
throw new Error("Codex settings outside the reviewed V4 contract changed; explicit discovery review required");
|
|
14894
|
-
return { path: previous.path, hashMode: "codex-settings-v4", sha256:
|
|
15321
|
+
return { path: previous.path, hashMode: "codex-settings-v4", sha256: sha25622 };
|
|
14895
15322
|
}
|
|
14896
15323
|
function hashCodexSettingsReplacementV5(text2, budget2 = { remaining: 256 * 1024 * 1024 }) {
|
|
14897
15324
|
need7(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
|
|
@@ -14904,10 +15331,10 @@ function upgradeCodexSettingsWitnessV5(previous, reviewedSettingsPath) {
|
|
|
14904
15331
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
|
|
14905
15332
|
const original = previous.hashMode === "codex-settings-v4" ? settingsDigest2(before, 4) : previous.hashMode === "codex-settings-v3" ? settingsDigest2(before, 3) : previous.hashMode === "codex-settings-v2" ? settingsDigest2(before, 2) : previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before);
|
|
14906
15333
|
need7(original === previous.sha256);
|
|
14907
|
-
const
|
|
14908
|
-
if (settingsDigest2(before, 5) !==
|
|
15334
|
+
const sha25622 = settingsDigest2(current2, 5);
|
|
15335
|
+
if (settingsDigest2(before, 5) !== sha25622)
|
|
14909
15336
|
throw new Error("Codex settings outside the reviewed V5 contract changed; explicit discovery review required");
|
|
14910
|
-
return { path: previous.path, hashMode: "codex-settings-v5", sha256:
|
|
15337
|
+
return { path: previous.path, hashMode: "codex-settings-v5", sha256: sha25622 };
|
|
14911
15338
|
}
|
|
14912
15339
|
var V7_DISCOVERY_KEY = /skill|plugin|hook|marketplace|instruction/i;
|
|
14913
15340
|
var V7_BOUND_KEYS = new Set(["mcp_servers", "agents", "project_doc_fallback_filenames", "compact_prompt", "experimental_compact_prompt_file"]);
|
|
@@ -15007,10 +15434,10 @@ function upgradeCodexSettingsWitnessV7(previous, reviewedSettingsPath) {
|
|
|
15007
15434
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
|
|
15008
15435
|
const original = previous.hashMode === "codex-settings-v5" ? settingsDigest2(before, 5) : previous.hashMode === "codex-settings-v4" ? settingsDigest2(before, 4) : previous.hashMode === "codex-settings-v3" ? settingsDigest2(before, 3) : previous.hashMode === "codex-settings-v2" ? settingsDigest2(before, 2) : previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before);
|
|
15009
15436
|
need7(original === previous.sha256);
|
|
15010
|
-
const
|
|
15011
|
-
if (settingsDigestV7(before) !==
|
|
15437
|
+
const sha25622 = settingsDigestV7(current2);
|
|
15438
|
+
if (settingsDigestV7(before) !== sha25622)
|
|
15012
15439
|
throw new Error("Codex discovery settings outside the reviewed V7 contract changed; explicit discovery review required");
|
|
15013
|
-
return { path: previous.path, hashMode: "codex-settings-v7", sha256:
|
|
15440
|
+
return { path: previous.path, hashMode: "codex-settings-v7", sha256: sha25622 };
|
|
15014
15441
|
}
|
|
15015
15442
|
function settingsDigestV8(text2) {
|
|
15016
15443
|
need7(Buffer.byteLength(text2) <= 1024 * 1024);
|
|
@@ -15037,10 +15464,10 @@ function upgradeCodexSettingsWitnessV8(previous, reviewedSettingsPath) {
|
|
|
15037
15464
|
const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
|
|
15038
15465
|
const original = previous.hashMode === "codex-settings-v7" ? settingsDigestV7(before) : previous.hashMode === "codex-settings-v5" ? settingsDigest2(before, 5) : previous.hashMode === "codex-settings-v4" ? settingsDigest2(before, 4) : previous.hashMode === "codex-settings-v3" ? settingsDigest2(before, 3) : previous.hashMode === "codex-settings-v2" ? settingsDigest2(before, 2) : previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before);
|
|
15039
15466
|
need7(original === previous.sha256);
|
|
15040
|
-
const
|
|
15041
|
-
if (settingsDigestV8(before) !==
|
|
15467
|
+
const sha25622 = settingsDigestV8(current2);
|
|
15468
|
+
if (settingsDigestV8(before) !== sha25622)
|
|
15042
15469
|
throw new Error("Codex discovery settings outside the reviewed V8 contract changed; explicit discovery review required");
|
|
15043
|
-
return { path: previous.path, hashMode: "codex-settings-v8", sha256:
|
|
15470
|
+
return { path: previous.path, hashMode: "codex-settings-v8", sha256: sha25622 };
|
|
15044
15471
|
}
|
|
15045
15472
|
function captureCodexSettingsV6(path, reviewedSources, budget2 = { remaining: 256 * 1024 * 1024 }, changes) {
|
|
15046
15473
|
const original = readNativeSettingsWitnessFile(path, budget2, "config.toml");
|
|
@@ -15176,10 +15603,10 @@ var DARWIN_HELPER_SHA256 = "3dd94f36877227e0e89055caef077cc5e60d0a46f436e7684598
|
|
|
15176
15603
|
function darwinAcls(entries, deadline) {
|
|
15177
15604
|
if (entries.length > 256)
|
|
15178
15605
|
refused("lock path has too many ancestors");
|
|
15179
|
-
const helper =
|
|
15606
|
+
const helper = fileURLToPath3(new URL("../native/kernel-lock-acl-darwin", import.meta.url));
|
|
15180
15607
|
let fd;
|
|
15181
15608
|
try {
|
|
15182
|
-
if (
|
|
15609
|
+
if (realpathSync42(helper) !== helper)
|
|
15183
15610
|
refused("unsafe ACL helper path");
|
|
15184
15611
|
fd = openSync8(helper, constants8.O_RDONLY | constants8.O_NOFOLLOW | constants8.O_NONBLOCK);
|
|
15185
15612
|
const info = fstatSync8(fd);
|
|
@@ -15244,17 +15671,17 @@ function canonicalRoot(root) {
|
|
|
15244
15671
|
if (!info)
|
|
15245
15672
|
refused("existing lock root is required");
|
|
15246
15673
|
if (info.isSymbolicLink()) {
|
|
15247
|
-
if (process.platform !== "darwin" || cursor !== "/var" && cursor !== "/tmp" ||
|
|
15674
|
+
if (process.platform !== "darwin" || cursor !== "/var" && cursor !== "/tmp" || realpathSync42(cursor) !== `/private${cursor}`)
|
|
15248
15675
|
refused("unsafe lock root path");
|
|
15249
15676
|
} else if (!info.isDirectory())
|
|
15250
15677
|
refused("unsafe lock root path");
|
|
15251
15678
|
}
|
|
15252
|
-
return
|
|
15679
|
+
return realpathSync42(requested);
|
|
15253
15680
|
}
|
|
15254
15681
|
function trustedHelper() {
|
|
15255
15682
|
let helper;
|
|
15256
15683
|
try {
|
|
15257
|
-
helper =
|
|
15684
|
+
helper = realpathSync42("/usr/bin/perl");
|
|
15258
15685
|
} catch {
|
|
15259
15686
|
return refused("trusted system Perl is required");
|
|
15260
15687
|
}
|
|
@@ -15642,7 +16069,7 @@ function skillsState(root, leaf, roots) {
|
|
|
15642
16069
|
verify();
|
|
15643
16070
|
for (const component of chain.slice(1)) {
|
|
15644
16071
|
try {
|
|
15645
|
-
|
|
16072
|
+
mkdirSync52(component, { mode: 448 });
|
|
15646
16073
|
} catch (error) {
|
|
15647
16074
|
if (error.code !== "EEXIST")
|
|
15648
16075
|
throw error;
|
|
@@ -15679,7 +16106,7 @@ function probeParent(roots) {
|
|
|
15679
16106
|
if (lstatSync15(component, { throwIfNoEntry: false }))
|
|
15680
16107
|
continue;
|
|
15681
16108
|
try {
|
|
15682
|
-
|
|
16109
|
+
mkdirSync52(component, { mode: 448 });
|
|
15683
16110
|
} catch (error) {
|
|
15684
16111
|
if (error.code !== "EEXIST")
|
|
15685
16112
|
throw error;
|
|
@@ -15698,7 +16125,7 @@ function removeProbeHome(home) {
|
|
|
15698
16125
|
try {
|
|
15699
16126
|
const stat2 = lstatSync15(home.path, { bigint: true });
|
|
15700
16127
|
if (stat2.isDirectory() && stat2.dev === home.dev && stat2.ino === home.ino)
|
|
15701
|
-
|
|
16128
|
+
rmSync22(home.path, { recursive: true, force: true });
|
|
15702
16129
|
} catch {}
|
|
15703
16130
|
}
|
|
15704
16131
|
function probe(path, args, parent, stdio) {
|
|
@@ -16093,9 +16520,9 @@ function requireRemoteReceiptSnapshot(catalog, cache) {
|
|
|
16093
16520
|
}
|
|
16094
16521
|
function appControls(path, read2) {
|
|
16095
16522
|
const text2 = read2(path);
|
|
16096
|
-
let value,
|
|
16523
|
+
let value, sha25622;
|
|
16097
16524
|
try {
|
|
16098
|
-
|
|
16525
|
+
sha25622 = hashNativeJsonControls(text2);
|
|
16099
16526
|
value = JSON.parse(text2);
|
|
16100
16527
|
} catch {
|
|
16101
16528
|
refuse2();
|
|
@@ -16110,7 +16537,7 @@ function appControls(path, read2) {
|
|
|
16110
16537
|
if (!identifier2(name) || !object4(entry) || !Object.keys(entry).every((key2) => ["id", "category", "required"].includes(key2)) || typeof entry.id !== "string" || !/^[A-Za-z0-9_-]{1,256}$/.test(entry.id) || entry.category !== undefined && (typeof entry.category !== "string" || !entry.category.trim() || entry.category.length > 256 || /[\x00-\x1f\x7f]/.test(entry.category)) || entry.required !== undefined && typeof entry.required !== "boolean")
|
|
16111
16538
|
refuse2();
|
|
16112
16539
|
}
|
|
16113
|
-
return
|
|
16540
|
+
return sha25622;
|
|
16114
16541
|
}
|
|
16115
16542
|
function codexAppDeclarationValid(path) {
|
|
16116
16543
|
try {
|
|
@@ -16125,9 +16552,9 @@ function codexAppDeclarationValid(path) {
|
|
|
16125
16552
|
}
|
|
16126
16553
|
function mcpControls(path, read2) {
|
|
16127
16554
|
const text2 = read2(path);
|
|
16128
|
-
let value,
|
|
16555
|
+
let value, sha25622;
|
|
16129
16556
|
try {
|
|
16130
|
-
|
|
16557
|
+
sha25622 = hashNativeJsonControls(text2);
|
|
16131
16558
|
value = JSON.parse(text2);
|
|
16132
16559
|
} catch {
|
|
16133
16560
|
refuse2();
|
|
@@ -16141,7 +16568,7 @@ function mcpControls(path, read2) {
|
|
|
16141
16568
|
for (const [name, server] of servers)
|
|
16142
16569
|
if (!isCodexLocalStdioMcpServer(name, server))
|
|
16143
16570
|
refuse2();
|
|
16144
|
-
return
|
|
16571
|
+
return sha25622;
|
|
16145
16572
|
}
|
|
16146
16573
|
function isBundledCleanupHooks(root, namespace, value) {
|
|
16147
16574
|
const object4 = (v) => Boolean(v && typeof v === "object" && !Array.isArray(v));
|
|
@@ -17867,12 +18294,12 @@ function writeExecutableCache(dataDir22, entries) {
|
|
|
17867
18294
|
if (lstatSync22(path, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
17868
18295
|
return;
|
|
17869
18296
|
descriptor = openSync12(temporary, constants12.O_WRONLY | constants12.O_CREAT | constants12.O_EXCL | (constants12.O_NOFOLLOW ?? 0), 384);
|
|
17870
|
-
|
|
18297
|
+
writeFileSync42(descriptor, `${JSON.stringify({ schema: CODEX_NATIVE_POLICY_EXECUTABLE_CACHE_SCHEMA, entries: entries.slice(-16) })}
|
|
17871
18298
|
`);
|
|
17872
18299
|
fsyncSync4(descriptor);
|
|
17873
18300
|
closeSync12(descriptor);
|
|
17874
18301
|
descriptor = undefined;
|
|
17875
|
-
|
|
18302
|
+
renameSync32(temporary, path);
|
|
17876
18303
|
} catch {} finally {
|
|
17877
18304
|
if (descriptor !== undefined)
|
|
17878
18305
|
closeSync12(descriptor);
|
|
@@ -18166,12 +18593,12 @@ function recordCodexNativePolicyAcceptance(dataDir22, verification, accepted) {
|
|
|
18166
18593
|
let descriptor;
|
|
18167
18594
|
try {
|
|
18168
18595
|
descriptor = openSync12(temporary, constants12.O_WRONLY | constants12.O_CREAT | constants12.O_EXCL | (constants12.O_NOFOLLOW ?? 0), 384);
|
|
18169
|
-
|
|
18596
|
+
writeFileSync42(descriptor, `${JSON.stringify(value)}
|
|
18170
18597
|
`);
|
|
18171
18598
|
fsyncSync4(descriptor);
|
|
18172
18599
|
closeSync12(descriptor);
|
|
18173
18600
|
descriptor = undefined;
|
|
18174
|
-
|
|
18601
|
+
renameSync32(temporary, path);
|
|
18175
18602
|
} catch (error) {
|
|
18176
18603
|
refuse3("NATIVE_SKILL_POLICY_RECEIPT_FAILED", error.message);
|
|
18177
18604
|
} finally {
|
|
@@ -19094,7 +19521,7 @@ function openNarrowedWitnessLedger(dataDir22, options = { record: true }) {
|
|
|
19094
19521
|
const merged = merge(latest, added);
|
|
19095
19522
|
writeFileSync5(temporary, `${JSON.stringify({ schema: SCHEMA, entries: merged }, null, 2)}
|
|
19096
19523
|
`, { mode: 384, flag: "wx" });
|
|
19097
|
-
|
|
19524
|
+
renameSync42(temporary, path);
|
|
19098
19525
|
entries = merged;
|
|
19099
19526
|
added.length = 0;
|
|
19100
19527
|
} catch {
|
|
@@ -45249,7 +45676,7 @@ function claudeSkillsUsage(before, home) {
|
|
|
45249
45676
|
}
|
|
45250
45677
|
if (events3.length)
|
|
45251
45678
|
evidence.push(`Skills-managed hook entries in ${events3.join(", ")}`);
|
|
45252
|
-
const bridge =
|
|
45679
|
+
const bridge = join19(home, ".claude", "skills", "skills-cli", "SKILL.md");
|
|
45253
45680
|
let bridgePresent;
|
|
45254
45681
|
try {
|
|
45255
45682
|
bridgePresent = lstatSync7(bridge, { throwIfNoEntry: false }) !== undefined;
|
|
@@ -45261,9 +45688,9 @@ function claudeSkillsUsage(before, home) {
|
|
|
45261
45688
|
return evidence;
|
|
45262
45689
|
}
|
|
45263
45690
|
function skillsPolicyLocations(dataDir3) {
|
|
45264
|
-
const state = (path) =>
|
|
45691
|
+
const state = (path) => existsSync12(path) ? "present" : "absent";
|
|
45265
45692
|
if (dataDir3 !== undefined)
|
|
45266
|
-
return [`${
|
|
45693
|
+
return [`${join19(resolve10(dataDir3), "agent-policy.json")} (explicit data directory, absent)`];
|
|
45267
45694
|
const env = process.env, home = env.HOME || env.USERPROFILE || homedir7() || "/tmp", searched = [];
|
|
45268
45695
|
let selected = false;
|
|
45269
45696
|
for (const key2 of ["HASNA_SKILLS_DIR", "HASNA_SKILLS_HOME", "SKILLS_HOME"]) {
|
|
@@ -45274,13 +45701,13 @@ function skillsPolicyLocations(dataDir3) {
|
|
|
45274
45701
|
searched.push(`$${key2} (unset)`);
|
|
45275
45702
|
else {
|
|
45276
45703
|
selected = true;
|
|
45277
|
-
searched.push(`$${key2} -> ${
|
|
45704
|
+
searched.push(`$${key2} -> ${join19(resolve10(value), "agent-policy.json")} (selected, absent)`);
|
|
45278
45705
|
}
|
|
45279
45706
|
}
|
|
45280
|
-
const
|
|
45281
|
-
const base = typeof
|
|
45282
|
-
const xdg =
|
|
45283
|
-
const adopted = typeof
|
|
45707
|
+
const override2 = env.HASNA_DATA_HOME;
|
|
45708
|
+
const base = typeof override2 === "string" && override2.length > 0 ? override2 : process.platform === "darwin" ? join19(home, "Library", "Application Support", "Hasna") : join19(home, ".local", "share", "hasna");
|
|
45709
|
+
const xdg = join19(base, "skills"), xdgPolicy = join19(xdg, "agent-policy.json");
|
|
45710
|
+
const adopted = typeof override2 === "string" && override2.trim().length > 0 || existsSync12(join19(xdg, "server.db")) || existsSync12(join19(xdg, "config.json"));
|
|
45284
45711
|
if (selected)
|
|
45285
45712
|
searched.push(`${xdgPolicy} (not consulted, ${state(xdgPolicy)})`);
|
|
45286
45713
|
else if (adopted) {
|
|
@@ -45288,7 +45715,7 @@ function skillsPolicyLocations(dataDir3) {
|
|
|
45288
45715
|
searched.push(`${xdgPolicy} (selected, absent)`);
|
|
45289
45716
|
} else
|
|
45290
45717
|
searched.push(`${xdgPolicy} (not selected: the directory holds no server.db or config.json and HASNA_DATA_HOME is unset; ${state(xdgPolicy)})`);
|
|
45291
|
-
const legacy =
|
|
45718
|
+
const legacy = join19(home, ".hasna", "skills", "agent-policy.json");
|
|
45292
45719
|
searched.push(selected ? `${legacy} (not consulted, ${state(legacy)})` : `${legacy} (selected, absent)`);
|
|
45293
45720
|
return searched;
|
|
45294
45721
|
}
|
|
@@ -45300,13 +45727,13 @@ function planCoordinatedClaudeSettings(before, replacement, options) {
|
|
|
45300
45727
|
const plan = planClaudeHookEventsUpdate({
|
|
45301
45728
|
...options,
|
|
45302
45729
|
events: selected,
|
|
45303
|
-
expectedSettingsSha256: before === null ? "absent" :
|
|
45730
|
+
expectedSettingsSha256: before === null ? "absent" : createHash11("sha256").update(before).digest("hex"),
|
|
45304
45731
|
replacement
|
|
45305
45732
|
});
|
|
45306
45733
|
if (!plan) {
|
|
45307
45734
|
const usage = claudeSkillsUsage(before, options.home);
|
|
45308
45735
|
if (usage.length)
|
|
45309
|
-
throw new ClaudeSettingsRefusal("skills_policy_unresolved", `Skills manages ${
|
|
45736
|
+
throw new ClaudeSettingsRefusal("skills_policy_unresolved", `Skills manages ${join19(options.home, ".claude", "settings.json")} (${usage.join("; ")}), but no Skills agent policy resolved, ` + "so Hooks cannot coordinate this change and wrote nothing. Locations searched, in Skills resolution order: " + skillsPolicyLocations(options.dataDir).map((location, index) => `${index + 1}) ${location}`).join("; ") + ". Run hooks with the environment that selects the Skills data directory (for example HASNA_SKILLS_DIR), " + "or repair the integration with `skills hook install`.");
|
|
45310
45737
|
}
|
|
45311
45738
|
return plan;
|
|
45312
45739
|
}
|
|
@@ -45321,32 +45748,32 @@ function coordinateClaudeSettings(before, replacement, options, beforeWrite) {
|
|
|
45321
45748
|
|
|
45322
45749
|
// src/lib/target-adapters.ts
|
|
45323
45750
|
import { spawnSync } from "child_process";
|
|
45324
|
-
import { chmodSync as chmodSync2, existsSync as
|
|
45751
|
+
import { chmodSync as chmodSync2, existsSync as existsSync14, mkdirSync as mkdirSync12, readFileSync as readFileSync10, readdirSync as readdirSync10, rmdirSync as rmdirSync2, statSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync10, renameSync as renameSync6 } from "fs";
|
|
45325
45752
|
import { tmpdir } from "os";
|
|
45326
|
-
import { basename as basename10, dirname as dirname11, join as
|
|
45753
|
+
import { basename as basename10, dirname as dirname11, join as join25 } from "path";
|
|
45327
45754
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
45328
45755
|
|
|
45329
45756
|
// src/lib/profiles.ts
|
|
45330
45757
|
init_app_home();
|
|
45331
|
-
import { existsSync as
|
|
45332
|
-
import { join as
|
|
45758
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync9, writeFileSync as writeFileSync8, readdirSync as readdirSync5, rmSync as rmSync4, cpSync as cpSync2 } from "fs";
|
|
45759
|
+
import { join as join23 } from "path";
|
|
45333
45760
|
function getProfilesDir() {
|
|
45334
|
-
const newDir =
|
|
45335
|
-
const oldDir =
|
|
45336
|
-
if (!
|
|
45337
|
-
|
|
45761
|
+
const newDir = join23(getEffectiveDataRoot(), "profiles");
|
|
45762
|
+
const oldDir = join23(getHomeDir(), ".hooks", "profiles");
|
|
45763
|
+
if (!existsSync13(newDir) && existsSync13(oldDir)) {
|
|
45764
|
+
mkdirSync10(newDir, { recursive: true });
|
|
45338
45765
|
cpSync2(oldDir, newDir, { recursive: true });
|
|
45339
45766
|
}
|
|
45340
45767
|
return newDir;
|
|
45341
45768
|
}
|
|
45342
45769
|
function ensureProfilesDir() {
|
|
45343
45770
|
const dir = getProfilesDir();
|
|
45344
|
-
if (!
|
|
45345
|
-
|
|
45771
|
+
if (!existsSync13(dir)) {
|
|
45772
|
+
mkdirSync10(dir, { recursive: true });
|
|
45346
45773
|
}
|
|
45347
45774
|
}
|
|
45348
45775
|
function profilePath(id) {
|
|
45349
|
-
return
|
|
45776
|
+
return join23(getProfilesDir(), `${id}.json`);
|
|
45350
45777
|
}
|
|
45351
45778
|
function shortUuid() {
|
|
45352
45779
|
return crypto.randomUUID().slice(0, 8);
|
|
@@ -45372,23 +45799,23 @@ function createProfile(input2) {
|
|
|
45372
45799
|
function getProfile(id) {
|
|
45373
45800
|
const path = profilePath(id);
|
|
45374
45801
|
try {
|
|
45375
|
-
if (!
|
|
45802
|
+
if (!existsSync13(path))
|
|
45376
45803
|
return null;
|
|
45377
|
-
return JSON.parse(
|
|
45804
|
+
return JSON.parse(readFileSync9(path, "utf-8"));
|
|
45378
45805
|
} catch {
|
|
45379
45806
|
return null;
|
|
45380
45807
|
}
|
|
45381
45808
|
}
|
|
45382
45809
|
function listProfiles() {
|
|
45383
45810
|
const dir = getProfilesDir();
|
|
45384
|
-
if (!
|
|
45811
|
+
if (!existsSync13(dir))
|
|
45385
45812
|
return [];
|
|
45386
45813
|
try {
|
|
45387
45814
|
const files = readdirSync5(dir).filter((f) => f.endsWith(".json"));
|
|
45388
45815
|
const profiles = [];
|
|
45389
45816
|
for (const file2 of files) {
|
|
45390
45817
|
try {
|
|
45391
|
-
const content =
|
|
45818
|
+
const content = readFileSync9(join23(dir, file2), "utf-8");
|
|
45392
45819
|
profiles.push(JSON.parse(content));
|
|
45393
45820
|
} catch {}
|
|
45394
45821
|
}
|
|
@@ -45457,7 +45884,7 @@ function messageOf(error61) {
|
|
|
45457
45884
|
function readJsonObject(path) {
|
|
45458
45885
|
let text3;
|
|
45459
45886
|
try {
|
|
45460
|
-
text3 =
|
|
45887
|
+
text3 = readFileSync10(path, "utf-8");
|
|
45461
45888
|
} catch (error61) {
|
|
45462
45889
|
if (error61?.code === "ENOENT")
|
|
45463
45890
|
return { status: "absent" };
|
|
@@ -45475,16 +45902,16 @@ function readJsonObject(path) {
|
|
|
45475
45902
|
}
|
|
45476
45903
|
function writeText(path, content) {
|
|
45477
45904
|
const dir = dirname11(path);
|
|
45478
|
-
|
|
45479
|
-
const temp =
|
|
45905
|
+
mkdirSync12(dir, { recursive: true });
|
|
45906
|
+
const temp = join25(dir, `.${basename10(path)}.${randomUUID5()}.tmp`);
|
|
45480
45907
|
try {
|
|
45481
45908
|
writeFileSync10(temp, content);
|
|
45482
|
-
if (
|
|
45909
|
+
if (existsSync14(path))
|
|
45483
45910
|
chmodSync2(temp, statSync(path).mode & 4095);
|
|
45484
45911
|
renameSync6(temp, path);
|
|
45485
45912
|
} catch (error61) {
|
|
45486
45913
|
try {
|
|
45487
|
-
if (
|
|
45914
|
+
if (existsSync14(temp))
|
|
45488
45915
|
unlinkSync3(temp);
|
|
45489
45916
|
} catch {}
|
|
45490
45917
|
throw error61;
|
|
@@ -45586,7 +46013,7 @@ function installKimi(hook, command, options, timeoutSeconds) {
|
|
|
45586
46013
|
|
|
45587
46014
|
${kimiBlock(command, timeoutSeconds)}
|
|
45588
46015
|
`;
|
|
45589
|
-
const candidate =
|
|
46016
|
+
const candidate = join25(tmpdir(), `hooks-kimi-config-${randomUUID5()}.toml`);
|
|
45590
46017
|
writeFileSync10(candidate, next);
|
|
45591
46018
|
let validationNote;
|
|
45592
46019
|
try {
|
|
@@ -45601,7 +46028,7 @@ ${kimiBlock(command, timeoutSeconds)}
|
|
|
45601
46028
|
}
|
|
45602
46029
|
} finally {
|
|
45603
46030
|
try {
|
|
45604
|
-
if (
|
|
46031
|
+
if (existsSync14(candidate))
|
|
45605
46032
|
unlinkSync3(candidate);
|
|
45606
46033
|
} catch {}
|
|
45607
46034
|
}
|
|
@@ -45750,29 +46177,29 @@ function museDiagnostic(outcome) {
|
|
|
45750
46177
|
return redactedDiagnostic(outcome.stderr) || redactedDiagnostic(outcome.stdout) || `exit ${outcome.status}`;
|
|
45751
46178
|
}
|
|
45752
46179
|
function removeMuseBundle(bundle) {
|
|
45753
|
-
const manifestPath =
|
|
46180
|
+
const manifestPath = join25(bundle, ".muse-plugin", "plugin.json");
|
|
45754
46181
|
try {
|
|
45755
|
-
if (
|
|
46182
|
+
if (existsSync14(manifestPath))
|
|
45756
46183
|
unlinkSync3(manifestPath);
|
|
45757
46184
|
} catch {}
|
|
45758
|
-
for (const dir of [
|
|
46185
|
+
for (const dir of [join25(bundle, ".muse-plugin"), bundle]) {
|
|
45759
46186
|
try {
|
|
45760
|
-
if (
|
|
46187
|
+
if (existsSync14(dir))
|
|
45761
46188
|
rmdirSync2(dir);
|
|
45762
46189
|
} catch {}
|
|
45763
46190
|
}
|
|
45764
46191
|
}
|
|
45765
46192
|
function museBundles(options) {
|
|
45766
46193
|
const root = musePluginRoot({ home: homeOf(options), env: options.env ?? process.env });
|
|
45767
|
-
if (!
|
|
46194
|
+
if (!existsSync14(root))
|
|
45768
46195
|
return [];
|
|
45769
46196
|
const out = [];
|
|
45770
46197
|
for (const entry of readdirSync10(root)) {
|
|
45771
|
-
const manifestPath =
|
|
45772
|
-
if (!
|
|
46198
|
+
const manifestPath = join25(root, entry, ".muse-plugin", "plugin.json");
|
|
46199
|
+
if (!existsSync14(manifestPath))
|
|
45773
46200
|
continue;
|
|
45774
46201
|
try {
|
|
45775
|
-
const manifest = JSON.parse(
|
|
46202
|
+
const manifest = JSON.parse(readFileSync10(manifestPath, "utf-8"));
|
|
45776
46203
|
for (const capability of manifest.capabilities?.hooks ?? []) {
|
|
45777
46204
|
const command = Array.isArray(capability.command) ? capability.command.join(" ") : "";
|
|
45778
46205
|
const hook = hookFromCommand(command) ?? hookFromMuseCommand(capability.command);
|
|
@@ -45786,10 +46213,10 @@ function museBundles(options) {
|
|
|
45786
46213
|
function museOwnFiles(options) {
|
|
45787
46214
|
const home = homeOf(options);
|
|
45788
46215
|
const env = options.env ?? process.env;
|
|
45789
|
-
const configBase = env.XDG_CONFIG_HOME?.startsWith("/") ? env.XDG_CONFIG_HOME :
|
|
45790
|
-
const dataBase = env.XDG_DATA_HOME?.startsWith("/") ? env.XDG_DATA_HOME :
|
|
45791
|
-
const searched = [
|
|
45792
|
-
const found = searched.filter((path) =>
|
|
46216
|
+
const configBase = env.XDG_CONFIG_HOME?.startsWith("/") ? env.XDG_CONFIG_HOME : join25(home, ".config");
|
|
46217
|
+
const dataBase = env.XDG_DATA_HOME?.startsWith("/") ? env.XDG_DATA_HOME : join25(home, ".local", "share");
|
|
46218
|
+
const searched = [join25(configBase, "muse", "settings.json"), join25(dataBase, "muse")];
|
|
46219
|
+
const found = searched.filter((path) => existsSync14(path));
|
|
45793
46220
|
return { present: found.length > 0, found, searched };
|
|
45794
46221
|
}
|
|
45795
46222
|
function readMuseState(options, runner = options.run ?? defaultRunner) {
|
|
@@ -45843,8 +46270,8 @@ function readMuseState(options, runner = options.run ?? defaultRunner) {
|
|
|
45843
46270
|
function installMuse(hook, command, options, timeoutSeconds) {
|
|
45844
46271
|
const runner = options.run ?? defaultRunner;
|
|
45845
46272
|
const bundle = adapterPath("muse", options, hook);
|
|
45846
|
-
const manifestPath =
|
|
45847
|
-
const existedBefore =
|
|
46273
|
+
const manifestPath = join25(bundle, ".muse-plugin", "plugin.json");
|
|
46274
|
+
const existedBefore = existsSync14(manifestPath);
|
|
45848
46275
|
const manifest = museManifest(hook, command, options, timeoutSeconds);
|
|
45849
46276
|
writeText(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
45850
46277
|
`);
|
|
@@ -45903,7 +46330,7 @@ function installMuse(hook, command, options, timeoutSeconds) {
|
|
|
45903
46330
|
}
|
|
45904
46331
|
function readTextState(path) {
|
|
45905
46332
|
try {
|
|
45906
|
-
return { status: "verified", text:
|
|
46333
|
+
return { status: "verified", text: readFileSync10(path, "utf-8") };
|
|
45907
46334
|
} catch (error61) {
|
|
45908
46335
|
if (error61?.code === "ENOENT")
|
|
45909
46336
|
return { status: "absent" };
|
|
@@ -46050,8 +46477,8 @@ function removeFromAdapter(target, hook, options) {
|
|
|
46050
46477
|
return { removed: true };
|
|
46051
46478
|
}
|
|
46052
46479
|
const bundle = adapterPath("muse", options, hook);
|
|
46053
|
-
const manifestPath =
|
|
46054
|
-
const hadBundle =
|
|
46480
|
+
const manifestPath = join25(bundle, ".muse-plugin", "plugin.json");
|
|
46481
|
+
const hadBundle = existsSync14(manifestPath);
|
|
46055
46482
|
const bundleNote = hadBundle ? `the bundle at ${bundle} was left in place` : `no bundle was present at ${bundle}`;
|
|
46056
46483
|
const pluginId2 = `hasna-hook-${hook}`;
|
|
46057
46484
|
const result = (options.run ?? defaultRunner)("muse", ["plugins", "remove", pluginId2, "--json"]);
|
|
@@ -46082,8 +46509,8 @@ function removeFromAdapter(target, hook, options) {
|
|
|
46082
46509
|
}
|
|
46083
46510
|
|
|
46084
46511
|
// src/lib/installer.ts
|
|
46085
|
-
var __dirname2 = dirname19(
|
|
46086
|
-
var HOOKS_DIR =
|
|
46512
|
+
var __dirname2 = dirname19(fileURLToPath4(import.meta.url));
|
|
46513
|
+
var HOOKS_DIR = existsSync15(join26(__dirname2, "..", "..", "hooks", "hook-gitguard")) ? join26(__dirname2, "..", "..", "hooks") : join26(__dirname2, "..", "hooks");
|
|
46087
46514
|
function normalizeHookName(name) {
|
|
46088
46515
|
return name.startsWith("hook-") ? name : `hook-${name}`;
|
|
46089
46516
|
}
|
|
@@ -46172,17 +46599,17 @@ function getSettingsPath(scope = "global", target = "claude", codewithConfigPath
|
|
|
46172
46599
|
const capabilities = getTargetCapabilities(target, capabilityOptions(scope));
|
|
46173
46600
|
if (capabilities)
|
|
46174
46601
|
return capabilities.configPath;
|
|
46175
|
-
return
|
|
46602
|
+
return join26(homedir8(), ".claude", "settings.json");
|
|
46176
46603
|
}
|
|
46177
46604
|
function getHookPath(name) {
|
|
46178
46605
|
const shortName = shortHookName(name);
|
|
46179
46606
|
const resolved = resolveHookDir(shortName);
|
|
46180
46607
|
if (resolved)
|
|
46181
46608
|
return resolved;
|
|
46182
|
-
return
|
|
46609
|
+
return join26(HOOKS_DIR, normalizeHookName(shortName));
|
|
46183
46610
|
}
|
|
46184
46611
|
function hookExists(name) {
|
|
46185
|
-
return
|
|
46612
|
+
return existsSync15(getHookPath(name));
|
|
46186
46613
|
}
|
|
46187
46614
|
var settingsPreimages = new WeakMap;
|
|
46188
46615
|
var unreadableSettings = new WeakMap;
|
|
@@ -46192,7 +46619,7 @@ function readSettings2(scope = "global", target = "claude") {
|
|
|
46192
46619
|
return readCodexSettings(path);
|
|
46193
46620
|
let reason2 = "cannot be read";
|
|
46194
46621
|
try {
|
|
46195
|
-
if (
|
|
46622
|
+
if (existsSync15(path)) {
|
|
46196
46623
|
const text3 = readFileSync16(path, "utf-8");
|
|
46197
46624
|
reason2 = "is not valid JSON";
|
|
46198
46625
|
const value = JSON.parse(text3);
|
|
@@ -46209,7 +46636,7 @@ function readSettings2(scope = "global", target = "claude") {
|
|
|
46209
46636
|
console.warn("[hooks] Cannot read hook settings; repair the selected file before installation.");
|
|
46210
46637
|
}
|
|
46211
46638
|
const empty = {};
|
|
46212
|
-
if (!
|
|
46639
|
+
if (!existsSync15(path))
|
|
46213
46640
|
settingsPreimages.set(empty, { path, text: null });
|
|
46214
46641
|
else
|
|
46215
46642
|
unreadableSettings.set(empty, { path, reason: reason2 });
|
|
@@ -46217,19 +46644,19 @@ function readSettings2(scope = "global", target = "claude") {
|
|
|
46217
46644
|
}
|
|
46218
46645
|
function unreadableSettingsRefusal(settings, path) {
|
|
46219
46646
|
const captured = settingsPreimages.get(settings);
|
|
46220
|
-
if (captured?.path === path && captured.text !== null || !
|
|
46647
|
+
if (captured?.path === path && captured.text !== null || !existsSync15(path))
|
|
46221
46648
|
return;
|
|
46222
46649
|
const failed = unreadableSettings.get(settings);
|
|
46223
46650
|
const reason2 = captured?.path === path ? "was created after Hooks read the settings" : failed?.path === path ? failed.reason : "was not read as a settings object";
|
|
46224
46651
|
return new ClaudeSettingsRefusal("settings_unreadable", `${path} ${reason2}, so Hooks wrote nothing. Repair the file or move it aside, then retry.`);
|
|
46225
46652
|
}
|
|
46226
46653
|
function settingsIdentity(path) {
|
|
46227
|
-
if (
|
|
46654
|
+
if (existsSync15(path))
|
|
46228
46655
|
return realpathSync6(path);
|
|
46229
|
-
return
|
|
46656
|
+
return existsSync15(dirname19(path)) ? join26(realpathSync6(dirname19(path)), basename14(path)) : resolve29(path);
|
|
46230
46657
|
}
|
|
46231
46658
|
function coordinatesWithSkills(path, target) {
|
|
46232
|
-
return target === "claude" && settingsIdentity(path) === settingsIdentity(
|
|
46659
|
+
return target === "claude" && settingsIdentity(path) === settingsIdentity(join26(homedir8(), ".claude/settings.json"));
|
|
46233
46660
|
}
|
|
46234
46661
|
function writerRefusal(error61) {
|
|
46235
46662
|
return { error: error61 instanceof Error ? error61.message : "Unknown error", ...error61 instanceof ClaudeSettingsRefusal ? { code: error61.code } : {} };
|
|
@@ -46251,7 +46678,7 @@ function writeSettings(settings, scope = "global", target = "claude", expectedSe
|
|
|
46251
46678
|
const before = settingsPreimages.get(settings);
|
|
46252
46679
|
if (!before || before.path !== path)
|
|
46253
46680
|
throw new Error("Claude settings require a valid captured preimage before installation.");
|
|
46254
|
-
const current2 =
|
|
46681
|
+
const current2 = existsSync15(path) ? readFileSync16(path, "utf8") : null;
|
|
46255
46682
|
if (current2 !== before.text)
|
|
46256
46683
|
throw new Error("Claude settings changed during installation; no settings were written.");
|
|
46257
46684
|
if (coordinateClaudeSettings(before.text, JSON.stringify(settings, null, 2) + `
|
|
@@ -46262,8 +46689,8 @@ function writeSettings(settings, scope = "global", target = "claude", expectedSe
|
|
|
46262
46689
|
return writeHookSettingsPreimage(path, settings, captured.text, beforeWrite);
|
|
46263
46690
|
beforeWrite?.();
|
|
46264
46691
|
const dir = dirname19(path);
|
|
46265
|
-
if (!
|
|
46266
|
-
|
|
46692
|
+
if (!existsSync15(dir)) {
|
|
46693
|
+
mkdirSync13(dir, { recursive: true });
|
|
46267
46694
|
}
|
|
46268
46695
|
writeFileSync11(path, JSON.stringify(settings, null, 2) + `
|
|
46269
46696
|
`);
|
|
@@ -46364,7 +46791,7 @@ function buildCodewithTomlFragment(name, profile, mementos) {
|
|
|
46364
46791
|
function readCodewithConfig(scope, configPath) {
|
|
46365
46792
|
const path = getSettingsPath(scope, "codewith", configPath);
|
|
46366
46793
|
try {
|
|
46367
|
-
return
|
|
46794
|
+
return existsSync15(path) ? readFileSync16(path, "utf-8") : "";
|
|
46368
46795
|
} catch {
|
|
46369
46796
|
return "";
|
|
46370
46797
|
}
|
|
@@ -46372,9 +46799,9 @@ function readCodewithConfig(scope, configPath) {
|
|
|
46372
46799
|
function appendCodewithFragment(fragment, scope, configPath) {
|
|
46373
46800
|
const path = getSettingsPath(scope, "codewith", configPath);
|
|
46374
46801
|
const dir = dirname19(path);
|
|
46375
|
-
if (!
|
|
46376
|
-
|
|
46377
|
-
const existing =
|
|
46802
|
+
if (!existsSync15(dir))
|
|
46803
|
+
mkdirSync13(dir, { recursive: true });
|
|
46804
|
+
const existing = existsSync15(path) ? readFileSync16(path, "utf-8") : "";
|
|
46378
46805
|
const sep11 = existing.trim() ? `
|
|
46379
46806
|
|
|
46380
46807
|
` : "";
|
|
@@ -47360,12 +47787,12 @@ function coerceForSqlite(value) {
|
|
|
47360
47787
|
return String(value);
|
|
47361
47788
|
}
|
|
47362
47789
|
// src/mcp/server.ts
|
|
47363
|
-
var __dirname3 = dirname33(
|
|
47790
|
+
var __dirname3 = dirname33(fileURLToPath5(import.meta.url));
|
|
47364
47791
|
var pkg = { name: "@hasna/hooks", version: "0.0.0" };
|
|
47365
47792
|
try {
|
|
47366
47793
|
for (const rel of ["../../package.json", "../package.json", "../../../package.json"]) {
|
|
47367
|
-
const p =
|
|
47368
|
-
if (
|
|
47794
|
+
const p = join38(__dirname3, rel);
|
|
47795
|
+
if (existsSync17(p)) {
|
|
47369
47796
|
pkg = JSON.parse(readFileSync21(p, "utf-8"));
|
|
47370
47797
|
break;
|
|
47371
47798
|
}
|
|
@@ -47373,14 +47800,17 @@ try {
|
|
|
47373
47800
|
} catch {}
|
|
47374
47801
|
async function runVerifiedHook(name, stdin, timeoutMs) {
|
|
47375
47802
|
const { resolveHook: resolveHook2, resolveScriptPath: resolveScriptPath2 } = await Promise.resolve().then(() => (init_resolve(), exports_resolve));
|
|
47376
|
-
const
|
|
47377
|
-
const hookScript =
|
|
47378
|
-
|
|
47379
|
-
|
|
47380
|
-
|
|
47381
|
-
|
|
47382
|
-
|
|
47383
|
-
|
|
47803
|
+
const { withStableInstall: withStableInstall2 } = await Promise.resolve().then(() => (init_install_record(), exports_install_record));
|
|
47804
|
+
const { resolved, hookScript, content, sha: sha7, check: check2 } = withStableInstall2(name, () => {
|
|
47805
|
+
const resolved2 = resolveHook2(name);
|
|
47806
|
+
const hookScript2 = resolveScriptPath2(name);
|
|
47807
|
+
if (!resolved2 || !hookScript2 || !existsSync17(hookScript2)) {
|
|
47808
|
+
throw new Error(`Hook '${name}' not found`);
|
|
47809
|
+
}
|
|
47810
|
+
const content2 = readFileSync21(hookScript2);
|
|
47811
|
+
const sha8 = sha256Of(content2);
|
|
47812
|
+
return { resolved: resolved2, hookScript: hookScript2, content: content2, sha: sha8, check: checkScriptHash(name, sha8) };
|
|
47813
|
+
});
|
|
47384
47814
|
if (!check2.ok) {
|
|
47385
47815
|
throw new Error(`Hook '${name}' script changed since it was trusted (sha256 ${check2.expected} != ${check2.actual}). Run 'hooks trust ${name}' to trust the new content.`);
|
|
47386
47816
|
}
|
|
@@ -47590,7 +48020,7 @@ function createHooksServer() {
|
|
|
47590
48020
|
const settingsPath = getSettingsPath(scope);
|
|
47591
48021
|
const issues = [];
|
|
47592
48022
|
const healthy = [];
|
|
47593
|
-
const settingsExist =
|
|
48023
|
+
const settingsExist = existsSync17(settingsPath);
|
|
47594
48024
|
if (!settingsExist) {
|
|
47595
48025
|
issues.push({ hook: "(settings)", issue: `${settingsPath} not found`, severity: "warning" });
|
|
47596
48026
|
}
|
|
@@ -47600,7 +48030,7 @@ function createHooksServer() {
|
|
|
47600
48030
|
const meta3 = custom2 ? resolveHookMeta(name) : getHook(name);
|
|
47601
48031
|
let hookHealthy = true;
|
|
47602
48032
|
if (custom2) {
|
|
47603
|
-
if (!
|
|
48033
|
+
if (!existsSync17(custom2.scriptPath)) {
|
|
47604
48034
|
issues.push({ hook: name, issue: `Custom hook script missing: ${custom2.scriptPath}`, severity: "error" });
|
|
47605
48035
|
hookHealthy = false;
|
|
47606
48036
|
}
|
|
@@ -47610,7 +48040,7 @@ function createHooksServer() {
|
|
|
47610
48040
|
continue;
|
|
47611
48041
|
}
|
|
47612
48042
|
const hookDir = getHookPath(name);
|
|
47613
|
-
if (!
|
|
48043
|
+
if (!existsSync17(join38(hookDir, "src", "hook.ts"))) {
|
|
47614
48044
|
issues.push({ hook: name, issue: "Missing src/hook.ts in package", severity: "error" });
|
|
47615
48045
|
hookHealthy = false;
|
|
47616
48046
|
}
|
|
@@ -47654,9 +48084,9 @@ function createHooksServer() {
|
|
|
47654
48084
|
return { content: [{ type: "text", text: JSON.stringify({ error: `Hook '${name}' not found` }) }] };
|
|
47655
48085
|
}
|
|
47656
48086
|
const hookPath = getHookPath(name);
|
|
47657
|
-
const readmePath =
|
|
48087
|
+
const readmePath = join38(hookPath, "README.md");
|
|
47658
48088
|
let readme = "";
|
|
47659
|
-
if (
|
|
48089
|
+
if (existsSync17(readmePath)) {
|
|
47660
48090
|
readme = readFileSync21(readmePath, "utf-8");
|
|
47661
48091
|
}
|
|
47662
48092
|
if (verbose) {
|
|
@@ -47840,7 +48270,7 @@ function createHooksServer() {
|
|
|
47840
48270
|
const ctx = {
|
|
47841
48271
|
scope,
|
|
47842
48272
|
settings_path: settingsPath,
|
|
47843
|
-
settings_exists:
|
|
48273
|
+
settings_exists: existsSync17(settingsPath),
|
|
47844
48274
|
registered_hooks: hooks,
|
|
47845
48275
|
hook_count: hooks.length,
|
|
47846
48276
|
healthy,
|