@primitive.ai/prim 0.1.0-alpha.106 → 0.1.0-alpha.108
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 +42 -5
- package/dist/{chunk-6VFUHQ4J.js → chunk-AIAYIXBJ.js} +1 -1
- package/dist/{chunk-HT2CJ3YD.js → chunk-D24AUSVP.js} +65 -28
- package/dist/{chunk-4CO4A6NR.js → chunk-EQYIPUFX.js} +1 -1
- package/dist/{chunk-XY4CRWTF.js → chunk-FDXDV2AT.js} +3 -3
- package/dist/{chunk-FFYZ3XMX.js → chunk-GFJ4QIVR.js} +210 -117
- package/dist/{chunk-7GSBXHK4.js → chunk-LFZYNNQQ.js} +71 -7
- 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 +890 -749
- package/dist/hook-runtime/hooks/pre-tool-use.js +484 -343
- package/dist/hook-runtime/hooks/prim-hook.js +543 -402
- package/dist/hook-runtime/hooks/session-start.js +210 -117
- package/dist/hook-runtime/index.js +608 -354
- 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 +184 -71
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ After successful setup, the optional **author story** puts you in a new engineer
|
|
|
49
49
|
shoes in a disposable project:
|
|
50
50
|
|
|
51
51
|
```text
|
|
52
|
-
Implement CSV export → Your earlier Decision blocks email →
|
|
52
|
+
Implement CSV export → Your earlier Decision blocks email → Accept or Supercede
|
|
53
53
|
→ Real outcome email
|
|
54
54
|
```
|
|
55
55
|
|
package/SKILL.md
CHANGED
|
@@ -155,9 +155,43 @@ commands, read fixtures, or manufacture an acknowledgment. If pending, use the
|
|
|
155
155
|
returned isolation reason and diagnostic action. Unknown trust is not proof that
|
|
156
156
|
hooks are disabled; for Codex, check `/hooks` and approve only if prompted.
|
|
157
157
|
|
|
158
|
+
Setup authorization includes following its returned `nextAction`; do not end the
|
|
159
|
+
turn at welcome or ask whether to start the tour. Installation, hook configuration,
|
|
160
|
+
observed hook execution, and verified capture are different states. Preserve
|
|
161
|
+
`health` warnings and `readiness` rather than declaring everything active.
|
|
162
|
+
|
|
163
|
+
If isolation is pending, run `diagnosticAction` once. It is safe before isolation:
|
|
164
|
+
it reports the installed runtime and the last content-free observation for this
|
|
165
|
+
run. The acknowledgment event is **PreToolUse**, with **Bash** for Codex/Claude,
|
|
166
|
+
**Shell** for Cursor, and **terminal** for Hermes. Missing evidence is unknown,
|
|
167
|
+
not proof of disabled hooks or absence of errors. Check the host's hook event/error
|
|
168
|
+
view; do not list the agent's home directory or dump transcripts. After the one
|
|
169
|
+
trust retry, retry only after a concrete repair. Use `resumeAction` for the same
|
|
170
|
+
run, including after an expired npm cache; do not restart the retry budget by
|
|
171
|
+
creating a fresh run. If the host does not execute local command hooks in this
|
|
172
|
+
session, explain that limitation and retain the resume action for a supported
|
|
173
|
+
local session. Never simulate the acknowledgment. Offer skip only as an option,
|
|
174
|
+
not as the diagnosis.
|
|
175
|
+
|
|
176
|
+
Run follow-up actions with the configuration-directory access already authorized
|
|
177
|
+
for setup, subject to host policy. Report EPERM/EACCES with the actual path and
|
|
178
|
+
remedy; never infer sandbox/network failure from a quiet command. While npm is
|
|
179
|
+
starting, give a brief progress update after about 15 seconds and keep polling
|
|
180
|
+
that invocation; do not launch duplicates. Only after an actual npm cache error,
|
|
181
|
+
retry once with a newly allocated temporary `npm_config_cache` directory. Reuse
|
|
182
|
+
that cache for subsequent commands. Do not clear the user's cache or change
|
|
183
|
+
permissions recursively. Bootstrap happens before Primitive can print progress.
|
|
184
|
+
Setup opens the authorization browser itself: surface its URL and let the user
|
|
185
|
+
click Authorize; do not invoke computer-use tools to automate that click.
|
|
186
|
+
|
|
187
|
+
Render the returned presentation once; keep raw JSON, launch paths, UUIDs and
|
|
188
|
+
routine STDERR out of the conversation. Surface actionable warnings verbatim.
|
|
189
|
+
If blocked, end with the observed cause (or explicitly unknown boundary), the
|
|
190
|
+
single next repair, and the command to resume the retained run.
|
|
191
|
+
|
|
158
192
|
Render each `presentation` once as Markdown, preserving diagrams and file evidence.
|
|
159
|
-
Do not echo JSON/STDERR, expand the records, or add a prose recap. Keep the
|
|
160
|
-
**
|
|
193
|
+
Do not echo JSON/STDERR, expand the records, or add a prose recap. Keep the returned
|
|
194
|
+
**[DEMO]** titles. This uses the production semantic
|
|
161
195
|
evaluator on private demo records and a demo-only blocking policy; native production
|
|
162
196
|
hooks did not supply the verdict. Production outcomes still vary by agent and
|
|
163
197
|
Decision state, including Claude's permission prompt.
|
|
@@ -167,10 +201,13 @@ same chat. At `awaitUserPrompt`, show the copyable CSV-export task and **wait fo
|
|
|
167
201
|
user to enter it**. Only then run `attemptAction`. Do not auto-submit it, ask them to
|
|
168
202
|
adopt the prior Decision, or implement the feature yourself.
|
|
169
203
|
|
|
170
|
-
At the actual block, show the unchanged file and
|
|
171
|
-
|
|
204
|
+
At the actual block, show the returned unchanged file and **Accept / Supercede** choices.
|
|
205
|
+
Accept uses `choices.adhere`; Supercede uses `choices.supersede`. Supercede approves the replacement,
|
|
172
206
|
**Allow customer names and email addresses in CSV exports**, and requires a short
|
|
173
|
-
reason in the user's own words.
|
|
207
|
+
reason in the user's own words. If missing, ask `choices.supersede.prompt` exactly;
|
|
208
|
+
if already supplied, do not ask again. The exploration prompts in the success message
|
|
209
|
+
are suggestions for the participant, not actions to execute automatically.
|
|
210
|
+
Append `'--reason'` and their single-quoted reason
|
|
174
211
|
to `choices.supersede.command`; escape any apostrophe as `'\''`, matching the
|
|
175
212
|
command's existing shell quoting. Never invent a reason or execute a placeholder.
|
|
176
213
|
Do not call production `reconcile` or `decisions create` for these samples.
|
|
@@ -4,50 +4,87 @@ import {
|
|
|
4
4
|
demoCommand,
|
|
5
5
|
exclusionPath,
|
|
6
6
|
lockRun,
|
|
7
|
+
observeRun,
|
|
8
|
+
readRun,
|
|
7
9
|
runPath,
|
|
8
10
|
saveDemoJson,
|
|
9
11
|
saveRun,
|
|
10
12
|
sessionExcluded,
|
|
11
13
|
sessionKey
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LFZYNNQQ.js";
|
|
15
|
+
import {
|
|
16
|
+
packageVersion
|
|
17
|
+
} from "./chunk-XG7S3LIL.js";
|
|
13
18
|
|
|
14
19
|
// src/demo/isolation.ts
|
|
15
20
|
import { existsSync } from "fs";
|
|
16
21
|
function observeDemoInvocation(envelope, agent, checkExclusion = true) {
|
|
17
22
|
const session = typeof envelope.session_id === "string" && envelope.session_id ? envelope.session_id : agent === "hermes" ? envelope.extra?.session_key : void 0;
|
|
18
23
|
let invocation = false;
|
|
19
|
-
if (envelope.hook_event_name === "PreToolUse"
|
|
24
|
+
if (envelope.hook_event_name === "PreToolUse") {
|
|
20
25
|
const tool = agent === "cursor" ? "Shell" : agent === "hermes" ? "terminal" : "Bash";
|
|
21
26
|
const input = envelope.tool_input;
|
|
22
|
-
const command = input?.command;
|
|
23
|
-
if (
|
|
27
|
+
const command = input?.command ?? input?.cmd;
|
|
28
|
+
if (typeof command === "string" && command.length < 8192) {
|
|
24
29
|
const argv = demoArgv(command);
|
|
25
|
-
const id = argv?.[4];
|
|
30
|
+
const id = argv?.[4] ?? command.match(/\x27([0-9a-f-]{36})\x27/u)?.[1];
|
|
26
31
|
if (id && RUN_ID.test(id) && existsSync(runPath(id))) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
if (action === "skip") return true;
|
|
38
|
-
const key = sessionKey(agent, session);
|
|
39
|
-
if (run.agent && run.agent !== agent || run.binding && run.binding !== key) {
|
|
40
|
-
run.acknowledgment = void 0;
|
|
41
|
-
saveRun(run);
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
saveDemoJson(exclusionPath(key), { runId: run.id });
|
|
45
|
-
run.binding = key;
|
|
46
|
-
run.agent = agent;
|
|
47
|
-
run.acknowledgment = { command, at: Date.now() };
|
|
48
|
-
saveRun(run);
|
|
49
|
-
return true;
|
|
32
|
+
const identity = typeof session === "string" && session ? sessionKey(agent, session) : void 0;
|
|
33
|
+
const observed = (result, errorCode) => observeRun(id, {
|
|
34
|
+
at: Date.now(),
|
|
35
|
+
agent,
|
|
36
|
+
runtimeVersion: packageVersion() ?? void 0,
|
|
37
|
+
session: identity,
|
|
38
|
+
result,
|
|
39
|
+
...errorCode ? { errorCode } : {}
|
|
50
40
|
});
|
|
41
|
+
const action = argv?.[3];
|
|
42
|
+
const choice = argv?.[6];
|
|
43
|
+
const reason = argv?.[8];
|
|
44
|
+
const recognized = ["start", "attempt", "resolve", "status", "skip"].includes(action);
|
|
45
|
+
const validChoice = action !== "resolve" || choice === "adhere" || choice === "supersede" && typeof reason === "string" && reason.trim().length > 0 && reason.length <= 500;
|
|
46
|
+
const matches = (run) => !run.terminal && recognized && validChoice && demoCommand(run, action, choice, reason) === command;
|
|
47
|
+
let candidate;
|
|
48
|
+
try {
|
|
49
|
+
candidate = readRun(id);
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
if (envelope.tool_name !== tool || typeof input?.command !== "string") {
|
|
53
|
+
observed("tool-mismatch");
|
|
54
|
+
} else if (!candidate || !matches(candidate)) {
|
|
55
|
+
observed("command-mismatch");
|
|
56
|
+
} else
|
|
57
|
+
try {
|
|
58
|
+
invocation = lockRun(id, (run) => {
|
|
59
|
+
if (!matches(run)) {
|
|
60
|
+
observed("command-mismatch");
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (action === "skip") return true;
|
|
64
|
+
if (!identity) {
|
|
65
|
+
observed("session-missing");
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const key = identity;
|
|
69
|
+
if (run.agent && run.agent !== agent || run.binding && run.binding !== key) {
|
|
70
|
+
observed("session-mismatch");
|
|
71
|
+
run.acknowledgment = void 0;
|
|
72
|
+
saveRun(run);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
saveDemoJson(exclusionPath(key), { runId: run.id });
|
|
76
|
+
run.binding = key;
|
|
77
|
+
run.agent = agent;
|
|
78
|
+
run.acknowledgment = { command, at: Date.now() };
|
|
79
|
+
saveRun(run);
|
|
80
|
+
observed("acknowledged");
|
|
81
|
+
return true;
|
|
82
|
+
});
|
|
83
|
+
} catch (error) {
|
|
84
|
+
const code = error.code;
|
|
85
|
+
observed("write-failed", code && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : void 0);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
51
88
|
}
|
|
52
89
|
}
|
|
53
90
|
}
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
analyzeShellTargets,
|
|
6
6
|
extractFileTargets
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-D24AUSVP.js";
|
|
8
8
|
import {
|
|
9
9
|
scrubEnvironmentPaths
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YQFJUBNU.js";
|
|
11
11
|
import {
|
|
12
12
|
cachedCollectScopeAdmits
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GFJ4QIVR.js";
|
|
14
14
|
import {
|
|
15
15
|
canonicalRepositoryPath,
|
|
16
16
|
currentBranch,
|