@primitive.ai/prim 0.1.0-alpha.107 → 0.1.0-alpha.109
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 +2 -2
- package/SKILL.md +21 -16
- package/dist/{chunk-6VFUHQ4J.js → chunk-AIAYIXBJ.js} +1 -1
- package/dist/{chunk-7NNJ67YN.js → chunk-D24AUSVP.js} +1 -1
- package/dist/{chunk-4CO4A6NR.js → chunk-EQYIPUFX.js} +1 -1
- package/dist/{chunk-6L7EYXVF.js → chunk-FDXDV2AT.js} +3 -3
- package/dist/{chunk-FFYZ3XMX.js → chunk-GFJ4QIVR.js} +210 -117
- package/dist/{chunk-2EKPBZNA.js → chunk-IQZA65NV.js} +19 -24
- package/dist/{chunk-P5I4HGMW.js → chunk-LFZYNNQQ.js} +1 -1
- package/dist/{chunk-TPWJQD5E.js → chunk-QJOK2VOE.js} +1 -1
- package/dist/{chunk-72CQVK4E.js → chunk-RXD6LFA2.js} +1 -1
- package/dist/{chunk-LVRD562C.js → chunk-YQFJUBNU.js} +1 -1
- package/dist/daemon/server.js +210 -117
- package/dist/hook-runtime/daemon/server.js +210 -117
- package/dist/hook-runtime/hooks/post-commit.js +210 -117
- package/dist/hook-runtime/hooks/post-rewrite.js +210 -117
- package/dist/hook-runtime/hooks/post-tool-use.js +210 -117
- package/dist/hook-runtime/hooks/pre-tool-use.js +210 -117
- package/dist/hook-runtime/hooks/prim-hook.js +210 -117
- package/dist/hook-runtime/hooks/session-start.js +225 -137
- package/dist/hook-runtime/index.js +4297 -355
- package/dist/hooks/post-commit.js +3 -3
- package/dist/hooks/post-rewrite.js +3 -3
- package/dist/hooks/post-tool-use.js +9 -9
- package/dist/hooks/pre-tool-use.js +6 -6
- package/dist/hooks/prim-hook.js +8 -8
- package/dist/hooks/session-start.js +4 -4
- package/dist/index.js +321 -158
- package/package.json +3 -1
|
@@ -1261,11 +1261,10 @@ function supportedShebangEnd(content, spec) {
|
|
|
1261
1261
|
}
|
|
1262
1262
|
return Buffer.byteLength(text.slice(0, newline + 1), "utf8");
|
|
1263
1263
|
}
|
|
1264
|
-
function shellInsertionPoint(content,
|
|
1264
|
+
function shellInsertionPoint(content, spec) {
|
|
1265
1265
|
const text = decodeHookText(content, spec);
|
|
1266
1266
|
if (text.startsWith("#!")) return supportedShebangEnd(content, spec);
|
|
1267
|
-
|
|
1268
|
-
throw new Error(`unsupported ${spec.hookName} hook interpreter`);
|
|
1267
|
+
return 0;
|
|
1269
1268
|
}
|
|
1270
1269
|
function allIndexes(haystack, needle) {
|
|
1271
1270
|
const indexes = [];
|
|
@@ -1301,8 +1300,8 @@ function blockRange(content, spec) {
|
|
|
1301
1300
|
return { kind: "stale", start, end };
|
|
1302
1301
|
}
|
|
1303
1302
|
var HUSKY_V8_SOURCE_RE = /^\.[ \t]+"\$\(dirname(?:[ \t]+--)?[ \t]+"\$0"\)\/_\/husky\.sh"[ \t]*$/mu;
|
|
1304
|
-
function blockInsertionPoint(content,
|
|
1305
|
-
const shebangEnd = shellInsertionPoint(content,
|
|
1303
|
+
function blockInsertionPoint(content, spec, huskyV8) {
|
|
1304
|
+
const shebangEnd = shellInsertionPoint(content, spec);
|
|
1306
1305
|
if (!huskyV8) return shebangEnd;
|
|
1307
1306
|
const rest = content.subarray(shebangEnd).toString("utf8");
|
|
1308
1307
|
const match = HUSKY_V8_SOURCE_RE.exec(rest);
|
|
@@ -1384,7 +1383,7 @@ function insertBlock(content, at, spec) {
|
|
|
1384
1383
|
content.subarray(at)
|
|
1385
1384
|
]);
|
|
1386
1385
|
}
|
|
1387
|
-
function migratedLegacyContent(existing,
|
|
1386
|
+
function migratedLegacyContent(existing, spec, huskyV8) {
|
|
1388
1387
|
const text = existing.toString("utf8");
|
|
1389
1388
|
if (spec.hookName === "pre-commit" && isOwnedStandalonePreCommit(text)) {
|
|
1390
1389
|
return createdScaffold(spec);
|
|
@@ -1407,7 +1406,7 @@ ${LEGACY_GLOBAL_OWNED_HEADER}
|
|
|
1407
1406
|
]);
|
|
1408
1407
|
return insertBlock(
|
|
1409
1408
|
withoutLegacyGate,
|
|
1410
|
-
blockInsertionPoint(withoutLegacyGate,
|
|
1409
|
+
blockInsertionPoint(withoutLegacyGate, spec, huskyV8),
|
|
1411
1410
|
spec
|
|
1412
1411
|
);
|
|
1413
1412
|
}
|
|
@@ -1422,11 +1421,11 @@ ${LEGACY_PRIM_OWNED_HEADER}
|
|
|
1422
1421
|
}
|
|
1423
1422
|
return void 0;
|
|
1424
1423
|
}
|
|
1425
|
-
function mergedContent(existing,
|
|
1424
|
+
function mergedContent(existing, spec, relocate, huskyV8) {
|
|
1426
1425
|
if (!existing) return { content: createdScaffold(spec), migrates: false };
|
|
1427
1426
|
const range = blockRange(existing, spec);
|
|
1428
1427
|
if (range.kind === "absent") {
|
|
1429
|
-
const migrated = migratedLegacyContent(existing,
|
|
1428
|
+
const migrated = migratedLegacyContent(existing, spec, huskyV8);
|
|
1430
1429
|
if (migrated) return { content: migrated, migrates: true };
|
|
1431
1430
|
} else if (range.kind !== "newer") {
|
|
1432
1431
|
const oldCreated = oldCreatedPrefixes(spec).some(
|
|
@@ -1441,8 +1440,8 @@ function mergedContent(existing, allowShebangless, spec, relocate, huskyV8) {
|
|
|
1441
1440
|
};
|
|
1442
1441
|
}
|
|
1443
1442
|
}
|
|
1444
|
-
const shebangEnd = shellInsertionPoint(existing,
|
|
1445
|
-
const insertion = blockInsertionPoint(existing,
|
|
1443
|
+
const shebangEnd = shellInsertionPoint(existing, spec);
|
|
1444
|
+
const insertion = blockInsertionPoint(existing, spec, huskyV8);
|
|
1446
1445
|
switch (range.kind) {
|
|
1447
1446
|
case "newer":
|
|
1448
1447
|
return { content: existing, migrates: false };
|
|
@@ -1454,11 +1453,7 @@ function mergedContent(existing, allowShebangless, spec, relocate, huskyV8) {
|
|
|
1454
1453
|
if (relocate && misplaced) {
|
|
1455
1454
|
const without = withoutRange(existing, range.start, range.end);
|
|
1456
1455
|
return {
|
|
1457
|
-
content: insertBlock(
|
|
1458
|
-
without,
|
|
1459
|
-
blockInsertionPoint(without, allowShebangless, spec, huskyV8),
|
|
1460
|
-
spec
|
|
1461
|
-
),
|
|
1456
|
+
content: insertBlock(without, blockInsertionPoint(without, spec, huskyV8), spec),
|
|
1462
1457
|
migrates: range.kind === "stale"
|
|
1463
1458
|
};
|
|
1464
1459
|
}
|
|
@@ -1532,12 +1527,12 @@ function unlinkHookUnchanged(path, expected, stat, spec) {
|
|
|
1532
1527
|
assertTargetUnchanged(path, expected, spec, stat);
|
|
1533
1528
|
unlinkSync2(path);
|
|
1534
1529
|
}
|
|
1535
|
-
function workingLegacyBlock(content,
|
|
1530
|
+
function workingLegacyBlock(content, spec) {
|
|
1536
1531
|
try {
|
|
1537
1532
|
const range = blockRange(content, spec);
|
|
1538
1533
|
if (range.kind !== "stale") return false;
|
|
1539
1534
|
const block = content.subarray(range.start, range.end).toString("utf8");
|
|
1540
|
-
const from = shellInsertionPoint(content,
|
|
1535
|
+
const from = shellInsertionPoint(content, spec);
|
|
1541
1536
|
return isRecognizedLegacyBlock(spec.hookName, block) && !mayTerminateBefore(content, from, range.start);
|
|
1542
1537
|
} catch {
|
|
1543
1538
|
return false;
|
|
@@ -1562,11 +1557,11 @@ function ensureTarget(target, spec, policy) {
|
|
|
1562
1557
|
return skip("skipped");
|
|
1563
1558
|
}
|
|
1564
1559
|
const huskyV8 = isHuskyV8Hook(target.hookPath);
|
|
1565
|
-
const next = mergedContent(existing,
|
|
1560
|
+
const next = mergedContent(existing, spec, policy.relocate, huskyV8);
|
|
1566
1561
|
if (existing && next.content.equals(existing)) return skip("unchanged");
|
|
1567
1562
|
if (!policy.writable(target.location)) {
|
|
1568
1563
|
if (target.location === "worktree") return skip("deferred");
|
|
1569
|
-
return skip(existing && workingLegacyBlock(existing,
|
|
1564
|
+
return skip(existing && workingLegacyBlock(existing, spec) ? "kept" : "external");
|
|
1570
1565
|
}
|
|
1571
1566
|
if (next.migrates && inspectGitHookEntrypoint() !== "ready") return skip("runtime_missing");
|
|
1572
1567
|
rewriteHookAtomically(target.hookPath, next.content, existing, spec, stat);
|
|
@@ -1648,7 +1643,7 @@ function inspectEffectiveGitHook(hookName, cwd = process.cwd()) {
|
|
|
1648
1643
|
let insertion;
|
|
1649
1644
|
try {
|
|
1650
1645
|
content = readHookFile(target.hookPath);
|
|
1651
|
-
insertion = shellInsertionPoint(content,
|
|
1646
|
+
insertion = shellInsertionPoint(content, spec);
|
|
1652
1647
|
range = blockRange(content, spec);
|
|
1653
1648
|
} catch (error) {
|
|
1654
1649
|
const message = error instanceof Error ? error.message : "";
|
|
@@ -1658,9 +1653,9 @@ function inspectEffectiveGitHook(hookName, cwd = process.cwd()) {
|
|
|
1658
1653
|
);
|
|
1659
1654
|
}
|
|
1660
1655
|
const huskyV8 = isHuskyV8Hook(target.hookPath);
|
|
1661
|
-
const preferred = blockInsertionPoint(content,
|
|
1656
|
+
const preferred = blockInsertionPoint(content, spec, huskyV8);
|
|
1662
1657
|
const current = range.kind === "current" || range.kind === "newer";
|
|
1663
|
-
const legacy = range.kind === "stale" && workingLegacyBlock(content,
|
|
1658
|
+
const legacy = range.kind === "stale" && workingLegacyBlock(content, spec);
|
|
1664
1659
|
const reason = range.kind === "absent" ? "missing_block" : range.kind === "stale" && !legacy ? "stale_block" : terminatesBefore(content, insertion, range.start) ? "unreachable_block" : !executable ? "not_executable" : legacy ? "legacy_block" : base.entrypoint !== "ready" ? "entrypoint_missing" : range.start < preferred ? "misplaced_block" : void 0;
|
|
1665
1660
|
return {
|
|
1666
1661
|
...base,
|
|
@@ -1743,7 +1738,7 @@ ${LEGACY_PRIM_OWNED_HEADER}
|
|
|
1743
1738
|
}
|
|
1744
1739
|
return unchanged;
|
|
1745
1740
|
}
|
|
1746
|
-
const shebangEnd = shellInsertionPoint(existing,
|
|
1741
|
+
const shebangEnd = shellInsertionPoint(existing, spec);
|
|
1747
1742
|
const suffix = existing.subarray(range.end);
|
|
1748
1743
|
const createdSuffix = Buffer.from(`
|
|
1749
1744
|
# ${spec.createdMark}
|