@primitive.ai/prim 0.1.0-alpha.108 → 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 +1 -1
- package/SKILL.md +13 -11
- package/dist/{chunk-2EKPBZNA.js → chunk-IQZA65NV.js} +19 -24
- package/dist/hook-runtime/hooks/session-start.js +15 -20
- package/dist/hook-runtime/index.js +4038 -215
- package/dist/hooks/session-start.js +1 -1
- package/dist/index.js +268 -131
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ so the agent runs it directly — instead of fetching a doc and executing a comm
|
|
|
107
107
|
it, which an auto-mode safety classifier blocks as untrusted-origin code:
|
|
108
108
|
|
|
109
109
|
```text
|
|
110
|
-
Install the Primitive CLI and activate passive decision capture for this repository: run `npx --yes @primitive.ai/prim@latest setup` and
|
|
110
|
+
Install the Primitive CLI and activate passive decision capture for this repository: run `npx --yes @primitive.ai/prim@latest setup` and show concise progress plus actionable warnings. Drive setup and its onboarding nextAction yourself; I'll handle browser authorization and any hook-trust review the agent requires. This request authorizes setup's built-in activation of this repository and an idempotent retry of that step, but not activation in another repository or creation of a Decision. If enable or health fails, surface the actual error; do not claim fresh activation approval is required. Then show me the welcome.
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
That single command runs the whole install and current-repository activation in one
|
package/SKILL.md
CHANGED
|
@@ -161,17 +161,19 @@ observed hook execution, and verified capture are different states. Preserve
|
|
|
161
161
|
`health` warnings and `readiness` rather than declaring everything active.
|
|
162
162
|
|
|
163
163
|
If isolation is pending, run `diagnosticAction` once. It is safe before isolation:
|
|
164
|
-
it reports the installed runtime
|
|
165
|
-
run. The acknowledgment event is **PreToolUse**,
|
|
166
|
-
**Shell** for Cursor, and **terminal** for Hermes.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
run
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
it reports the installed runtime, native Codex trust when available, and the last
|
|
165
|
+
content-free observation for this run. The acknowledgment event is **PreToolUse**,
|
|
166
|
+
with **Bash** for Codex/Claude, **Shell** for Cursor, and **terminal** for Hermes.
|
|
167
|
+
Codex snapshots hooks in running sessions: a trusted file is not proof that the
|
|
168
|
+
session loaded it. Setup requests a native reload without changing trust. If the
|
|
169
|
+
diagnostic returns `repairAction`, run it once, then follow `resumeAction` for the
|
|
170
|
+
same run. If refresh cannot reach the calling host, have the user exit and resume
|
|
171
|
+
that same Codex session to load its hooks. Ask for hook review only when reported;
|
|
172
|
+
never repeat trust instructions for already-trusted hooks. Missing evidence is
|
|
173
|
+
unknown, not proof of healthy or disabled hooks. After one repair, retry only on
|
|
174
|
+
new evidence. Retain the run even after an expired npm cache. Never fabricate an
|
|
175
|
+
acknowledgment, dump hook configuration/transcripts, or restart the retry budget
|
|
176
|
+
with a new tour. Offer skip only as an option, not as the diagnosis.
|
|
175
177
|
|
|
176
178
|
Run follow-up actions with the configuration-directory access already authorized
|
|
177
179
|
for setup, subject to host policy. Report EPERM/EACCES with the actual path and
|
|
@@ -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}
|
|
@@ -29607,11 +29607,10 @@ function supportedShebangEnd(content, spec) {
|
|
|
29607
29607
|
}
|
|
29608
29608
|
return Buffer.byteLength(text.slice(0, newline + 1), "utf8");
|
|
29609
29609
|
}
|
|
29610
|
-
function shellInsertionPoint(content,
|
|
29610
|
+
function shellInsertionPoint(content, spec) {
|
|
29611
29611
|
const text = decodeHookText(content, spec);
|
|
29612
29612
|
if (text.startsWith("#!")) return supportedShebangEnd(content, spec);
|
|
29613
|
-
|
|
29614
|
-
throw new Error(`unsupported ${spec.hookName} hook interpreter`);
|
|
29613
|
+
return 0;
|
|
29615
29614
|
}
|
|
29616
29615
|
function allIndexes(haystack, needle) {
|
|
29617
29616
|
const indexes = [];
|
|
@@ -29647,8 +29646,8 @@ function blockRange(content, spec) {
|
|
|
29647
29646
|
return { kind: "stale", start, end };
|
|
29648
29647
|
}
|
|
29649
29648
|
var HUSKY_V8_SOURCE_RE = /^\.[ \t]+"\$\(dirname(?:[ \t]+--)?[ \t]+"\$0"\)\/_\/husky\.sh"[ \t]*$/mu;
|
|
29650
|
-
function blockInsertionPoint(content,
|
|
29651
|
-
const shebangEnd = shellInsertionPoint(content,
|
|
29649
|
+
function blockInsertionPoint(content, spec, huskyV8) {
|
|
29650
|
+
const shebangEnd = shellInsertionPoint(content, spec);
|
|
29652
29651
|
if (!huskyV8) return shebangEnd;
|
|
29653
29652
|
const rest = content.subarray(shebangEnd).toString("utf8");
|
|
29654
29653
|
const match = HUSKY_V8_SOURCE_RE.exec(rest);
|
|
@@ -29730,7 +29729,7 @@ function insertBlock(content, at, spec) {
|
|
|
29730
29729
|
content.subarray(at)
|
|
29731
29730
|
]);
|
|
29732
29731
|
}
|
|
29733
|
-
function migratedLegacyContent(existing,
|
|
29732
|
+
function migratedLegacyContent(existing, spec, huskyV8) {
|
|
29734
29733
|
const text = existing.toString("utf8");
|
|
29735
29734
|
if (spec.hookName === "pre-commit" && isOwnedStandalonePreCommit(text)) {
|
|
29736
29735
|
return createdScaffold(spec);
|
|
@@ -29753,7 +29752,7 @@ ${LEGACY_GLOBAL_OWNED_HEADER}
|
|
|
29753
29752
|
]);
|
|
29754
29753
|
return insertBlock(
|
|
29755
29754
|
withoutLegacyGate,
|
|
29756
|
-
blockInsertionPoint(withoutLegacyGate,
|
|
29755
|
+
blockInsertionPoint(withoutLegacyGate, spec, huskyV8),
|
|
29757
29756
|
spec
|
|
29758
29757
|
);
|
|
29759
29758
|
}
|
|
@@ -29768,11 +29767,11 @@ ${LEGACY_PRIM_OWNED_HEADER}
|
|
|
29768
29767
|
}
|
|
29769
29768
|
return void 0;
|
|
29770
29769
|
}
|
|
29771
|
-
function mergedContent(existing,
|
|
29770
|
+
function mergedContent(existing, spec, relocate, huskyV8) {
|
|
29772
29771
|
if (!existing) return { content: createdScaffold(spec), migrates: false };
|
|
29773
29772
|
const range = blockRange(existing, spec);
|
|
29774
29773
|
if (range.kind === "absent") {
|
|
29775
|
-
const migrated = migratedLegacyContent(existing,
|
|
29774
|
+
const migrated = migratedLegacyContent(existing, spec, huskyV8);
|
|
29776
29775
|
if (migrated) return { content: migrated, migrates: true };
|
|
29777
29776
|
} else if (range.kind !== "newer") {
|
|
29778
29777
|
const oldCreated = oldCreatedPrefixes(spec).some(
|
|
@@ -29787,8 +29786,8 @@ function mergedContent(existing, allowShebangless, spec, relocate, huskyV8) {
|
|
|
29787
29786
|
};
|
|
29788
29787
|
}
|
|
29789
29788
|
}
|
|
29790
|
-
const shebangEnd = shellInsertionPoint(existing,
|
|
29791
|
-
const insertion = blockInsertionPoint(existing,
|
|
29789
|
+
const shebangEnd = shellInsertionPoint(existing, spec);
|
|
29790
|
+
const insertion = blockInsertionPoint(existing, spec, huskyV8);
|
|
29792
29791
|
switch (range.kind) {
|
|
29793
29792
|
case "newer":
|
|
29794
29793
|
return { content: existing, migrates: false };
|
|
@@ -29800,11 +29799,7 @@ function mergedContent(existing, allowShebangless, spec, relocate, huskyV8) {
|
|
|
29800
29799
|
if (relocate && misplaced) {
|
|
29801
29800
|
const without = withoutRange(existing, range.start, range.end);
|
|
29802
29801
|
return {
|
|
29803
|
-
content: insertBlock(
|
|
29804
|
-
without,
|
|
29805
|
-
blockInsertionPoint(without, allowShebangless, spec, huskyV8),
|
|
29806
|
-
spec
|
|
29807
|
-
),
|
|
29802
|
+
content: insertBlock(without, blockInsertionPoint(without, spec, huskyV8), spec),
|
|
29808
29803
|
migrates: range.kind === "stale"
|
|
29809
29804
|
};
|
|
29810
29805
|
}
|
|
@@ -29874,12 +29869,12 @@ function rewriteHookAtomically(path, next, expected, spec, stat) {
|
|
|
29874
29869
|
}
|
|
29875
29870
|
}
|
|
29876
29871
|
}
|
|
29877
|
-
function workingLegacyBlock(content,
|
|
29872
|
+
function workingLegacyBlock(content, spec) {
|
|
29878
29873
|
try {
|
|
29879
29874
|
const range = blockRange(content, spec);
|
|
29880
29875
|
if (range.kind !== "stale") return false;
|
|
29881
29876
|
const block = content.subarray(range.start, range.end).toString("utf8");
|
|
29882
|
-
const from = shellInsertionPoint(content,
|
|
29877
|
+
const from = shellInsertionPoint(content, spec);
|
|
29883
29878
|
return isRecognizedLegacyBlock(spec.hookName, block) && !mayTerminateBefore(content, from, range.start);
|
|
29884
29879
|
} catch {
|
|
29885
29880
|
return false;
|
|
@@ -29904,11 +29899,11 @@ function ensureTarget(target, spec, policy) {
|
|
|
29904
29899
|
return skip("skipped");
|
|
29905
29900
|
}
|
|
29906
29901
|
const huskyV8 = isHuskyV8Hook(target.hookPath);
|
|
29907
|
-
const next = mergedContent(existing,
|
|
29902
|
+
const next = mergedContent(existing, spec, policy.relocate, huskyV8);
|
|
29908
29903
|
if (existing && next.content.equals(existing)) return skip("unchanged");
|
|
29909
29904
|
if (!policy.writable(target.location)) {
|
|
29910
29905
|
if (target.location === "worktree") return skip("deferred");
|
|
29911
|
-
return skip(existing && workingLegacyBlock(existing,
|
|
29906
|
+
return skip(existing && workingLegacyBlock(existing, spec) ? "kept" : "external");
|
|
29912
29907
|
}
|
|
29913
29908
|
if (next.migrates && inspectGitHookEntrypoint() !== "ready") return skip("runtime_missing");
|
|
29914
29909
|
rewriteHookAtomically(target.hookPath, next.content, existing, spec, stat);
|