@primitive.ai/prim 0.1.0-alpha.104 → 0.1.0-alpha.106

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 CHANGED
@@ -45,21 +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, a first-run, 2–3 minute **simulated tour** demonstrates
49
- sample ingestion, Decision creation, a warning, a blocked write, and a correction.
50
- Your agent guides two choices; no sample Decisions enter the real graph.
51
- The tour follows one order-saving task and ends with a receipt of the demonstrated
52
- lifecycle, then offers one real project Decision for your individual approval.
53
- Use `prim setup --skip-demo` to skip and remember that choice, or
54
- `prim demo --agent <claude|codex|cursor|hermes>` to replay.
55
- For a person at a terminal, `prim demo` prompts directly.
56
-
57
- The agent tour waits for trusted hooks before showing samples and excludes
58
- passive capture for the remainder of that agent session, including resumes.
59
- Start a new session afterward for normal capture. Explicitly approved real
60
- Decisions can still be created, and other sessions continue capturing.
61
- The tour uses disposable local files and scripted verdicts; it does not test
62
- production ingestion or Enforcement. It offers real-memory seeding afterward.
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.
63
80
 
64
81
  Or run the steps individually:
65
82
 
package/SKILL.md CHANGED
@@ -144,54 +144,60 @@ 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: run the local tour before memory seeding
148
-
149
- After successful `prim setup`, follow any demo `nextAction` automatically. Setup
150
- starts this optional tour once per local OS-user configuration; `setup --skip-demo`
151
- remembers a skip, and `prim demo --agent <claude|codex|cursor|hermes>` replays it.
152
- Pass your agent explicitly, including when your shell tool allocates a terminal.
153
-
154
- The tour is entirely fictional: extraction, Decisions, and verdicts are simulated.
155
- Execute each generated command **exactly as a standalone shell invocation**; do not
156
- wrap it, append another command, substitute another executable, or use a subagent.
157
- Its hook acknowledgment establishes session isolation before any sample is shown.
158
- If the result is pending, surface its hook-trust instruction and retry only after
159
- trust is established. Never fabricate the missing output or read sample fixtures
160
- yourself to bypass isolation.
161
-
162
- Once isolation is acknowledged, open with the tour's mission: add order saving.
163
- Connect the team's context, the Decisions, and the implementation to that task.
164
- Show the source conversation becoming a provisional Decision with quoted evidence.
165
- Distinguish the fixture's file-scope mapping from what the conversation states.
166
- Present the source, Decision cards, and warning/block evidence. Pause for only the
167
- two teaching choices: confirming the fictional authoring proposal, then choosing
168
- the shared-repository correction (or retrying direct storage). Use `confirm` only
169
- after the user's confirmation; never treat a general setup request or `--yes` as
170
- that answer. Follow `skipAction` if the user declines or stops the tour.
171
- After confirmation, acknowledge the adopted sample Decision before presenting
172
- enforcement: the user's confirmation turned a proposal into an adopted record.
173
- Present warning and block as separate beats: attempt, governing Decision,
174
- conflict, consequence, actual file proof, and next move. Preserve that explanation
175
- on a blocked retry. These scripted outcomes do not define universal state rules.
176
- On the compliant choice, show both actual diffs: the unfinished order-saving
177
- function becomes a repository call, and service calls return to the shared client.
178
- Explain that the requested implementation landed while preserving both Decisions.
179
- On completion, lead with the five-item simulated success receipt, then report
180
- sample cleanup and the new-session requirement. Never present completion for a
181
- skip, pending tour, or error. Offer to propose one real project Decision for
182
- individual approval using the seeding procedure below; keep it separate from the
183
- fictional examples, and continue one at a time only if the user wants to proceed.
184
-
185
- Never record these examples with `decisions create`, save them to shared memory,
186
- or include them in later seeding candidates. The tour excludes passive capture
187
- for the remainder of this agent session, including resumes; tell the user to start
188
- a new session for normal capture. Other sessions and real-work enforcement remain
189
- active, and explicitly approved real Decisions can still be created here.
190
-
191
- After completion or skip, offer memory seeding and run `prim welcome --agent <your
192
- agent>` with `--capture-excluded` when this session ran the tour. An unfinished
193
- tour is listed in `recoverableRuns`; use its skip command for cleanup before replay.
194
- Do not begin real-memory proposals while the tour is pending.
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
+ 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
+ **Fictional project · real conflict check** label. This uses the production semantic
161
+ evaluator on private demo records and a demo-only blocking policy; native production
162
+ hooks did not supply the verdict. Production outcomes still vary by agent and
163
+ Decision state, including Claude's permission prompt.
164
+
165
+ The participant is the fictional earlier author, now playing a new engineer in this
166
+ same chat. At `awaitUserPrompt`, show the copyable CSV-export task and **wait for the
167
+ user to enter it**. Only then run `attemptAction`. Do not auto-submit it, ask them to
168
+ adopt the prior Decision, or implement the feature yourself.
169
+
170
+ At the actual block, show the unchanged file and ask **Adhere or Supersede?**
171
+ Adhere uses `choices.adhere`. Supersede approves the displayed replacement,
172
+ **Allow customer names and email addresses in CSV exports**, and requires a short
173
+ reason in the user's own words. Append `'--reason'` and their single-quoted reason
174
+ to `choices.supersede.command`; escape any apostrophe as `'\''`, matching the
175
+ command's existing shell quoting. Never invent a reason or execute a placeholder.
176
+ Do not call production `reconcile` or `decisions create` for these samples.
177
+
178
+ An unavailable or uncertain judgment remains pending; never invent a block or pass.
179
+ Use `statusAction` for diagnosis and the returned action for recovery. A resolution
180
+ retry uses the same approved bytes and completion receipt. Show success **before**
181
+ following welcome. Continue when the real outcome email is durably queued; provider
182
+ acceptance is not inbox delivery. Cleanup errors retain the path and defer seeding.
183
+
184
+ After completion or explicit skip, follow the exact welcome `nextAction` once.
185
+ It preserves the executable and agent and requests `--after-demo`. Its viewer-based
186
+ `org` result governs the transition: `seed` proposes one real Decision for individual
187
+ approval; `active` continues real work; `unknown` reports unavailable history and
188
+ must never be treated as empty. Do not repeat the feed or seed from fictional data.
189
+
190
+ Passive capture stays excluded for this session, including resumes. Start a new
191
+ session to resume capture; other sessions and real-work enforcement stay active.
192
+ Explicitly approved real Decisions remain available here. Never save this story,
193
+ its Decisions, reason or outcome to repository memory or the real Decision graph.
194
+
195
+ Setup runs the optional story once per local OS-user configuration. `setup --skip-demo`
196
+ remembers a skip; `prim demo --agent <claude|codex|cursor|hermes>` explicitly replays.
197
+ Old completion markers do not force a replay. `recoverableRuns` offers cleanup of
198
+ unfinished runs, including legacy local tours; it does not gate a fresh tour.
199
+ A missing backend/email configuration leaves the optional story pending while setup
200
+ remains successful. Surface the returned remedy or offer its skip action.
195
201
 
196
202
  ### Onboarding: seed the graph from memory, one proposal at a time
197
203
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  scheduleCollectScopeRefresh
3
- } from "./chunk-GSBHBU7N.js";
3
+ } from "./chunk-FFYZ3XMX.js";
4
4
 
5
5
  // src/ingest-response.ts
6
6
  var IngestAcknowledgementError = class extends Error {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-EZXEWFDG.js";
4
4
  import {
5
5
  scrubEnvironmentPaths
6
- } from "./chunk-MZEVEPL3.js";
6
+ } from "./chunk-LVRD562C.js";
7
7
  import {
8
8
  isValidRepoSyncId
9
9
  } from "./chunk-XG7S3LIL.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-GSBHBU7N.js";
3
+ } from "./chunk-FFYZ3XMX.js";
4
4
  import {
5
5
  stripControlChars
6
6
  } from "./chunk-2IRLFOEL.js";
@@ -1,6 +1,10 @@
1
+ import {
2
+ isDemoStatusResponse
3
+ } from "./chunk-FFYZ3XMX.js";
1
4
  import {
2
5
  atomicWriteFile,
3
6
  primConfigDirectory,
7
+ withFileLock,
4
8
  withFileLockSync
5
9
  } from "./chunk-XG7S3LIL.js";
6
10
 
@@ -25,7 +29,17 @@ function saveDemoJson(path, value) {
25
29
  }
26
30
  function readRun(id) {
27
31
  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)) {
32
+ if (![1, 2].includes(run.version) || run.id !== id || ![
33
+ "prepared",
34
+ "proposal",
35
+ "conflict",
36
+ "prompt",
37
+ "approved",
38
+ "applied",
39
+ "cleanup",
40
+ "completed",
41
+ "skipped"
42
+ ].includes(run.stage) || run.needsStatus !== void 0 && typeof run.needsStatus !== "boolean" || run.server !== void 0 && !isDemoStatusResponse(run.server) || run.receipt !== void 0 && (!Number.isSafeInteger(run.receipt.revision) || run.receipt.revision < 0 || !/^[a-f0-9]{64}$/u.test(run.receipt.appliedDigest)) || 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
43
  throw new Error("invalid demo run state");
30
44
  }
31
45
  return run;
@@ -34,7 +48,7 @@ var saveRun = (run) => saveDemoJson(runPath(run.id), run);
34
48
  var lockRun = (id, action) => withFileLockSync(`${runPath(id)}.lock`, () => action(readRun(id)), { timeoutMs: 500 });
35
49
  function prepareRun(agent, terminal = false) {
36
50
  const run = {
37
- version: 1,
51
+ version: 2,
38
52
  id: randomUUID(),
39
53
  stage: "prepared",
40
54
  terminal,
@@ -45,13 +59,31 @@ function prepareRun(agent, terminal = false) {
45
59
  return run;
46
60
  }
47
61
  var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
48
- function demoCommand(run, action, choice) {
62
+ function demoCommand(run, action, choice, reason) {
49
63
  return [
50
64
  ...run.launcher,
51
65
  "demo",
52
66
  action,
53
67
  run.id,
54
- ...choice === void 0 ? [] : ["--choice", choice]
68
+ ...choice === void 0 ? [] : ["--choice", choice],
69
+ ...reason === void 0 ? [] : ["--reason", reason]
70
+ ].map(quote).join(" ");
71
+ }
72
+ function demoWelcomeCommand(run) {
73
+ return [
74
+ process.execPath,
75
+ resolve(process.argv[1]),
76
+ "welcome",
77
+ "--after-demo",
78
+ ...run.agent ? ["--agent", run.agent === "claude_code" ? "claude" : run.agent] : [],
79
+ ...run.binding ? ["--capture-excluded"] : []
80
+ ].map(quote).join(" ");
81
+ }
82
+ function demoDiagnosticCommand(run) {
83
+ return [
84
+ process.execPath,
85
+ resolve(process.argv[1]),
86
+ ...run.agent ? [run.agent === "claude_code" ? "claude" : run.agent, "status"] : ["doctor"]
55
87
  ].map(quote).join(" ");
56
88
  }
57
89
  function onboardingFinished() {
@@ -88,6 +120,32 @@ function sessionExcluded(agent, session) {
88
120
  }
89
121
  return true;
90
122
  }
123
+ var lockRunAsync = (id, action) => withFileLock(`${runPath(id)}.lock`, () => action(readRun(id)), { timeoutMs: 500 });
124
+ function demoArgv(command) {
125
+ const result = [];
126
+ let i = 0;
127
+ while (i < command.length) {
128
+ if (command[i++] !== "'") return;
129
+ let value = "";
130
+ let closed = false;
131
+ while (i < command.length) {
132
+ if (command.slice(i, i + 4) === "'\\''") {
133
+ value += "'";
134
+ i += 4;
135
+ } else if (command[i] === "'") {
136
+ i++;
137
+ closed = true;
138
+ break;
139
+ } else {
140
+ value += command[i++];
141
+ }
142
+ }
143
+ if (!closed) return;
144
+ result.push(value);
145
+ if (i === command.length) return result;
146
+ if (command[i++] !== " " || i === command.length) return;
147
+ }
148
+ }
91
149
 
92
150
  export {
93
151
  RUN_ID,
@@ -98,10 +156,14 @@ export {
98
156
  lockRun,
99
157
  prepareRun,
100
158
  demoCommand,
159
+ demoWelcomeCommand,
160
+ demoDiagnosticCommand,
101
161
  onboardingFinished,
102
162
  finishOnboarding,
103
163
  pendingRuns,
104
164
  sessionKey,
105
165
  exclusionPath,
106
- sessionExcluded
166
+ sessionExcluded,
167
+ lockRunAsync,
168
+ demoArgv
107
169
  };