@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/README.md
CHANGED
|
@@ -45,24 +45,38 @@ skill, and the welcome:
|
|
|
45
45
|
prim setup # add --agent cursor, codex, or hermes; --no-daemon explicitly opts out
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
After successful setup,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
After successful setup, the optional **author story** puts you in a new engineer's
|
|
49
|
+
shoes in a disposable project:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
Implement CSV export → Your earlier Decision blocks email → Adhere or supersede
|
|
53
|
+
→ Real outcome email
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Enter the feature prompt in the same agent chat. The real semantic evaluator checks
|
|
57
|
+
it against your private, fictional prior Decision. Choose a name-only export or
|
|
58
|
+
approve the displayed replacement with your own short reason. A real email explains
|
|
59
|
+
what your Decision protected or why it changed. Continue once that email is queued;
|
|
60
|
+
queued and provider-accepted do not mean delivered to your inbox.
|
|
61
|
+
|
|
62
|
+
The compact diagrams and actual file evidence live in each JSON `presentation`.
|
|
63
|
+
Your agent renders them once. After owned-file cleanup, participants without real
|
|
64
|
+
Decisions enter the existing individually approved creation flow. Existing Decisions
|
|
65
|
+
remain intact; unavailable history is not treated as an empty graph.
|
|
66
|
+
|
|
67
|
+
Use `prim setup --skip-demo` to remember a skip, or
|
|
68
|
+
`prim demo --agent <claude|codex|cursor|hermes>` to replay. Direct terminal `prim demo`
|
|
69
|
+
uses the same prompts. Setup defaults to compact diagnostics; `prim setup --details`
|
|
70
|
+
shows full child output. Default agent setup returns one JSON result with `welcome`,
|
|
71
|
+
`onboarding`, and its `nextAction`. Existing completed tours do not replay automatically.
|
|
72
|
+
|
|
73
|
+
Agent hooks must acknowledge isolation before any sample is shown. Passive capture
|
|
74
|
+
then stays excluded for this session, including resumes; start a new session to
|
|
75
|
+
resume it. Other sessions, real-work enforcement and explicitly approved real
|
|
76
|
+
Decision creation remain available. Synthetic records never join the team's graph.
|
|
77
|
+
This exercises a real evaluator and demo-only blocking policy, not native production
|
|
78
|
+
Enforcement or live ingestion. Backend/email unavailability leaves the optional
|
|
79
|
+
story pending while successful setup remains successful.
|
|
66
80
|
|
|
67
81
|
Or run the steps individually:
|
|
68
82
|
|
package/SKILL.md
CHANGED
|
@@ -144,63 +144,94 @@ Treat changes to shared agent instructions and standards—such as `AGENTS.md`,
|
|
|
144
144
|
|
|
145
145
|
Apply the same attention during non-code deliberation: planning or “grill me” workflows, spec refinement, behavior design, PR planning or review, and conversations imported from Granola or other connected sources. These workflows can settle important forks before any code changes. Accumulate the confirmed decisions and record them at a natural phase or task boundary; do not interrupt or call Primitive after every answer.
|
|
146
146
|
|
|
147
|
-
### Onboarding:
|
|
148
|
-
|
|
149
|
-
After successful `prim setup`, follow
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
147
|
+
### Onboarding: experience your Decision protecting a teammate
|
|
148
|
+
|
|
149
|
+
After successful `prim setup`, follow its `nextAction` automatically; the `onboarding`
|
|
150
|
+
object contains the preparation instructions.
|
|
151
|
+
Pass your agent explicitly: Claude, Codex, Cursor and Hermes use the same sequence.
|
|
152
|
+
Run each generated command exactly as a standalone invocation. The first action
|
|
153
|
+
establishes capture isolation before the story is revealed. Do not delegate, wrap
|
|
154
|
+
commands, read fixtures, or manufacture an acknowledgment. If pending, use the
|
|
155
|
+
returned isolation reason and diagnostic action. Unknown trust is not proof that
|
|
156
|
+
hooks are disabled; for Codex, check `/hooks` and approve only if prompted.
|
|
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
|
+
|
|
192
|
+
Render each `presentation` once as Markdown, preserving diagrams and file evidence.
|
|
193
|
+
Do not echo JSON/STDERR, expand the records, or add a prose recap. Keep the
|
|
194
|
+
**Fictional project · real conflict check** label. This uses the production semantic
|
|
195
|
+
evaluator on private demo records and a demo-only blocking policy; native production
|
|
196
|
+
hooks did not supply the verdict. Production outcomes still vary by agent and
|
|
197
|
+
Decision state, including Claude's permission prompt.
|
|
198
|
+
|
|
199
|
+
The participant is the fictional earlier author, now playing a new engineer in this
|
|
200
|
+
same chat. At `awaitUserPrompt`, show the copyable CSV-export task and **wait for the
|
|
201
|
+
user to enter it**. Only then run `attemptAction`. Do not auto-submit it, ask them to
|
|
202
|
+
adopt the prior Decision, or implement the feature yourself.
|
|
203
|
+
|
|
204
|
+
At the actual block, show the unchanged file and ask **Adhere or Supersede?**
|
|
205
|
+
Adhere uses `choices.adhere`. Supersede approves the displayed replacement,
|
|
206
|
+
**Allow customer names and email addresses in CSV exports**, and requires a short
|
|
207
|
+
reason in the user's own words. Append `'--reason'` and their single-quoted reason
|
|
208
|
+
to `choices.supersede.command`; escape any apostrophe as `'\''`, matching the
|
|
209
|
+
command's existing shell quoting. Never invent a reason or execute a placeholder.
|
|
210
|
+
Do not call production `reconcile` or `decisions create` for these samples.
|
|
211
|
+
|
|
212
|
+
An unavailable or uncertain judgment remains pending; never invent a block or pass.
|
|
213
|
+
Use `statusAction` for diagnosis and the returned action for recovery. A resolution
|
|
214
|
+
retry uses the same approved bytes and completion receipt. Show success **before**
|
|
215
|
+
following welcome. Continue when the real outcome email is durably queued; provider
|
|
216
|
+
acceptance is not inbox delivery. Cleanup errors retain the path and defer seeding.
|
|
217
|
+
|
|
218
|
+
After completion or explicit skip, follow the exact welcome `nextAction` once.
|
|
219
|
+
It preserves the executable and agent and requests `--after-demo`. Its viewer-based
|
|
220
|
+
`org` result governs the transition: `seed` proposes one real Decision for individual
|
|
221
|
+
approval; `active` continues real work; `unknown` reports unavailable history and
|
|
222
|
+
must never be treated as empty. Do not repeat the feed or seed from fictional data.
|
|
223
|
+
|
|
224
|
+
Passive capture stays excluded for this session, including resumes. Start a new
|
|
225
|
+
session to resume capture; other sessions and real-work enforcement stay active.
|
|
226
|
+
Explicitly approved real Decisions remain available here. Never save this story,
|
|
227
|
+
its Decisions, reason or outcome to repository memory or the real Decision graph.
|
|
228
|
+
|
|
229
|
+
Setup runs the optional story once per local OS-user configuration. `setup --skip-demo`
|
|
230
|
+
remembers a skip; `prim demo --agent <claude|codex|cursor|hermes>` explicitly replays.
|
|
231
|
+
Old completion markers do not force a replay. `recoverableRuns` offers cleanup of
|
|
232
|
+
unfinished runs, including legacy local tours; it does not gate a fresh tour.
|
|
233
|
+
A missing backend/email configuration leaves the optional story pending while setup
|
|
234
|
+
remains successful. Surface the returned remedy or offer its skip action.
|
|
204
235
|
|
|
205
236
|
### Onboarding: seed the graph from memory, one proposal at a time
|
|
206
237
|
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
analyzeShellTargets,
|
|
6
6
|
extractFileTargets
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7NNJ67YN.js";
|
|
8
8
|
import {
|
|
9
9
|
scrubEnvironmentPaths
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LVRD562C.js";
|
|
11
11
|
import {
|
|
12
12
|
cachedCollectScopeAdmits
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-FFYZ3XMX.js";
|
|
14
14
|
import {
|
|
15
15
|
canonicalRepositoryPath,
|
|
16
16
|
currentBranch,
|
|
@@ -1,56 +1,90 @@
|
|
|
1
1
|
import {
|
|
2
|
+
RUN_ID,
|
|
3
|
+
demoArgv,
|
|
2
4
|
demoCommand,
|
|
3
5
|
exclusionPath,
|
|
4
6
|
lockRun,
|
|
7
|
+
observeRun,
|
|
8
|
+
readRun,
|
|
5
9
|
runPath,
|
|
6
10
|
saveDemoJson,
|
|
7
11
|
saveRun,
|
|
8
12
|
sessionExcluded,
|
|
9
13
|
sessionKey
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-P5I4HGMW.js";
|
|
15
|
+
import {
|
|
16
|
+
packageVersion
|
|
17
|
+
} from "./chunk-XG7S3LIL.js";
|
|
11
18
|
|
|
12
19
|
// src/demo/isolation.ts
|
|
13
20
|
import { existsSync } from "fs";
|
|
14
21
|
function observeDemoInvocation(envelope, agent, checkExclusion = true) {
|
|
15
22
|
const session = typeof envelope.session_id === "string" && envelope.session_id ? envelope.session_id : agent === "hermes" ? envelope.extra?.session_key : void 0;
|
|
16
23
|
let invocation = false;
|
|
17
|
-
if (envelope.hook_event_name === "PreToolUse"
|
|
24
|
+
if (envelope.hook_event_name === "PreToolUse") {
|
|
18
25
|
const tool = agent === "cursor" ? "Shell" : agent === "hermes" ? "terminal" : "Bash";
|
|
19
26
|
const input = envelope.tool_input;
|
|
20
|
-
const command = input?.command;
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
];
|
|
34
|
-
const match = actions.find(
|
|
35
|
-
([action, choice]) => demoCommand(run, action, choice) === command
|
|
36
|
-
);
|
|
37
|
-
if (run.terminal || !match) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (match[0] === "skip") return true;
|
|
41
|
-
const key = sessionKey(agent, session);
|
|
42
|
-
if (run.agent && run.agent !== agent || run.binding && run.binding !== key) {
|
|
43
|
-
run.acknowledgment = void 0;
|
|
44
|
-
saveRun(run);
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
saveDemoJson(exclusionPath(key), { runId: run.id });
|
|
48
|
-
run.binding = key;
|
|
49
|
-
run.agent = agent;
|
|
50
|
-
run.acknowledgment = { command, at: Date.now() };
|
|
51
|
-
saveRun(run);
|
|
52
|
-
return true;
|
|
27
|
+
const command = input?.command ?? input?.cmd;
|
|
28
|
+
if (typeof command === "string" && command.length < 8192) {
|
|
29
|
+
const argv = demoArgv(command);
|
|
30
|
+
const id = argv?.[4] ?? command.match(/\x27([0-9a-f-]{36})\x27/u)?.[1];
|
|
31
|
+
if (id && RUN_ID.test(id) && existsSync(runPath(id))) {
|
|
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 } : {}
|
|
53
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
|
+
}
|
|
54
88
|
}
|
|
55
89
|
}
|
|
56
90
|
}
|