@primitive.ai/prim 0.1.0-alpha.105 → 0.1.0-alpha.107
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 +32 -18
- package/SKILL.md +88 -57
- package/dist/{chunk-IDMLJ4TM.js → chunk-4CO4A6NR.js} +1 -1
- package/dist/{chunk-RCFDZ4DY.js → chunk-6L7EYXVF.js} +3 -3
- package/dist/{chunk-H6JAQVW4.js → chunk-6VFUHQ4J.js} +1 -1
- package/dist/{chunk-5HFTJEA6.js → chunk-72CQVK4E.js} +1 -1
- package/dist/{chunk-LNFWFYSN.js → chunk-7NNJ67YN.js} +69 -35
- package/dist/{chunk-GSBHBU7N.js → chunk-FFYZ3XMX.js} +1469 -533
- package/dist/{chunk-MZEVEPL3.js → chunk-LVRD562C.js} +1 -1
- package/dist/chunk-P5I4HGMW.js +233 -0
- package/dist/{chunk-C4D2LMTS.js → chunk-TPWJQD5E.js} +1 -1
- package/dist/daemon/server.js +1457 -531
- package/dist/hook-runtime/daemon/server.js +1457 -531
- package/dist/hook-runtime/hooks/post-commit.js +1454 -528
- package/dist/hook-runtime/hooks/post-rewrite.js +1454 -528
- package/dist/hook-runtime/hooks/post-tool-use.js +7201 -6195
- package/dist/hook-runtime/hooks/pre-tool-use.js +3359 -2351
- package/dist/hook-runtime/hooks/prim-hook.js +3390 -2382
- package/dist/hook-runtime/hooks/session-start.js +1454 -528
- package/dist/hook-runtime/index.js +2319 -1122
- 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 +3 -3
- package/dist/index.js +575 -380
- package/package.json +1 -1
- package/dist/chunk-6WCBVSND.js +0 -107
package/package.json
CHANGED
package/dist/chunk-6WCBVSND.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
atomicWriteFile,
|
|
3
|
-
primConfigDirectory,
|
|
4
|
-
withFileLockSync
|
|
5
|
-
} from "./chunk-XG7S3LIL.js";
|
|
6
|
-
|
|
7
|
-
// src/demo/state.ts
|
|
8
|
-
import { createHash, randomUUID } from "crypto";
|
|
9
|
-
import { existsSync, lstatSync, readFileSync, readdirSync } from "fs";
|
|
10
|
-
import { join, resolve } from "path";
|
|
11
|
-
var RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
12
|
-
var demoDirectory = () => join(primConfigDirectory(), "demo");
|
|
13
|
-
var runPath = (id) => {
|
|
14
|
-
if (!RUN_ID.test(id)) throw new Error("invalid demo run ID");
|
|
15
|
-
return join(demoDirectory(), "runs", `${id}.json`);
|
|
16
|
-
};
|
|
17
|
-
function readDemoJson(path) {
|
|
18
|
-
const stat = lstatSync(path);
|
|
19
|
-
if (!stat.isFile() || stat.size > 16384) throw new Error(`invalid demo state: ${path}`);
|
|
20
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
21
|
-
}
|
|
22
|
-
function saveDemoJson(path, value) {
|
|
23
|
-
atomicWriteFile(path, `${JSON.stringify(value)}
|
|
24
|
-
`, { mode: 384, ensureParent: true });
|
|
25
|
-
}
|
|
26
|
-
function readRun(id) {
|
|
27
|
-
const run = readDemoJson(runPath(id));
|
|
28
|
-
if (run.version !== 1 || run.id !== id || !["prepared", "proposal", "conflict", "completed", "skipped"].includes(run.stage) || typeof run.terminal !== "boolean" || !Array.isArray(run.launcher) || run.launcher.length !== 2 || run.launcher.some((value) => typeof value !== "string" || !value.startsWith("/")) || run.agent !== void 0 && !["claude_code", "codex", "cursor", "hermes"].includes(run.agent)) {
|
|
29
|
-
throw new Error("invalid demo run state");
|
|
30
|
-
}
|
|
31
|
-
return run;
|
|
32
|
-
}
|
|
33
|
-
var saveRun = (run) => saveDemoJson(runPath(run.id), run);
|
|
34
|
-
var lockRun = (id, action) => withFileLockSync(`${runPath(id)}.lock`, () => action(readRun(id)), { timeoutMs: 500 });
|
|
35
|
-
function prepareRun(agent, terminal = false) {
|
|
36
|
-
const run = {
|
|
37
|
-
version: 1,
|
|
38
|
-
id: randomUUID(),
|
|
39
|
-
stage: "prepared",
|
|
40
|
-
terminal,
|
|
41
|
-
agent,
|
|
42
|
-
launcher: [process.execPath, resolve(process.argv[1])]
|
|
43
|
-
};
|
|
44
|
-
saveRun(run);
|
|
45
|
-
return run;
|
|
46
|
-
}
|
|
47
|
-
var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
48
|
-
function demoCommand(run, action, choice) {
|
|
49
|
-
return [
|
|
50
|
-
...run.launcher,
|
|
51
|
-
"demo",
|
|
52
|
-
action,
|
|
53
|
-
run.id,
|
|
54
|
-
...choice === void 0 ? [] : ["--choice", choice]
|
|
55
|
-
].map(quote).join(" ");
|
|
56
|
-
}
|
|
57
|
-
function onboardingFinished() {
|
|
58
|
-
const path = join(demoDirectory(), "onboarding.json");
|
|
59
|
-
if (!existsSync(path)) return false;
|
|
60
|
-
const value = readDemoJson(path);
|
|
61
|
-
if (value.outcome !== "completed" && value.outcome !== "skipped") {
|
|
62
|
-
throw new Error("invalid local onboarding outcome");
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
function finishOnboarding(outcome) {
|
|
67
|
-
saveDemoJson(join(demoDirectory(), "onboarding.json"), { outcome });
|
|
68
|
-
}
|
|
69
|
-
function pendingRuns() {
|
|
70
|
-
const path = join(demoDirectory(), "runs");
|
|
71
|
-
if (!existsSync(path)) return [];
|
|
72
|
-
return readdirSync(path).filter((name) => name.endsWith(".json") && RUN_ID.test(name.slice(0, -5))).map((name) => name.slice(0, -5)).filter((id) => !["completed", "skipped"].includes(readRun(id).stage));
|
|
73
|
-
}
|
|
74
|
-
function sessionKey(agent, session) {
|
|
75
|
-
return createHash("sha256").update(`${agent}\0${session}`).digest("hex");
|
|
76
|
-
}
|
|
77
|
-
function exclusionPath(key) {
|
|
78
|
-
if (!/^[0-9a-f]{64}$/u.test(key)) throw new Error("invalid demo session identity");
|
|
79
|
-
return join(demoDirectory(), "excluded-sessions", `${key}.json`);
|
|
80
|
-
}
|
|
81
|
-
function sessionExcluded(agent, session) {
|
|
82
|
-
if (typeof session !== "string" || !session) return false;
|
|
83
|
-
const path = exclusionPath(sessionKey(agent, session));
|
|
84
|
-
if (!existsSync(path)) return false;
|
|
85
|
-
const record = readDemoJson(path);
|
|
86
|
-
if (typeof record.runId !== "string" || !RUN_ID.test(record.runId)) {
|
|
87
|
-
throw new Error("invalid demo capture exclusion");
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export {
|
|
93
|
-
RUN_ID,
|
|
94
|
-
runPath,
|
|
95
|
-
readDemoJson,
|
|
96
|
-
saveDemoJson,
|
|
97
|
-
saveRun,
|
|
98
|
-
lockRun,
|
|
99
|
-
prepareRun,
|
|
100
|
-
demoCommand,
|
|
101
|
-
onboardingFinished,
|
|
102
|
-
finishOnboarding,
|
|
103
|
-
pendingRuns,
|
|
104
|
-
sessionKey,
|
|
105
|
-
exclusionPath,
|
|
106
|
-
sessionExcluded
|
|
107
|
-
};
|