@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.
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  commitAttributionFromEnvironment,
10
10
  toCommitMove
11
- } from "../chunk-6VFUHQ4J.js";
11
+ } from "../chunk-AIAYIXBJ.js";
12
12
  import {
13
13
  getOrCreateWorkspaceId
14
14
  } from "../chunk-EZXEWFDG.js";
@@ -16,10 +16,10 @@ import {
16
16
  appendMove,
17
17
  resolveOrg
18
18
  } from "../chunk-JJI7FU24.js";
19
- import "../chunk-LVRD562C.js";
19
+ import "../chunk-YQFJUBNU.js";
20
20
  import {
21
21
  cachedCollectScopeAdmits
22
- } from "../chunk-FFYZ3XMX.js";
22
+ } from "../chunk-GFJ4QIVR.js";
23
23
  import "../chunk-2IRLFOEL.js";
24
24
  import {
25
25
  githubRepositoryFullName,
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  canonicalRewritePairs,
7
7
  toRewriteMove
8
- } from "../chunk-6VFUHQ4J.js";
8
+ } from "../chunk-AIAYIXBJ.js";
9
9
  import {
10
10
  getOrCreateWorkspaceId
11
11
  } from "../chunk-EZXEWFDG.js";
@@ -13,10 +13,10 @@ import {
13
13
  appendMove,
14
14
  resolveOrg
15
15
  } from "../chunk-JJI7FU24.js";
16
- import "../chunk-LVRD562C.js";
16
+ import "../chunk-YQFJUBNU.js";
17
17
  import {
18
18
  cachedCollectScopeAdmits
19
- } from "../chunk-FFYZ3XMX.js";
19
+ } from "../chunk-GFJ4QIVR.js";
20
20
  import "../chunk-2IRLFOEL.js";
21
21
  import {
22
22
  githubRepositoryFullName,
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  requireDurableIngestAcknowledgement
4
- } from "../chunk-4CO4A6NR.js";
4
+ } from "../chunk-EQYIPUFX.js";
5
5
  import {
6
6
  enrichHookPayloadWithFileRefs,
7
7
  preserveHookFileMetadata
8
- } from "../chunk-XY4CRWTF.js";
8
+ } from "../chunk-FDXDV2AT.js";
9
9
  import {
10
10
  postToolInvocationId,
11
11
  toMove,
12
12
  toolOutcomeFor
13
- } from "../chunk-6VFUHQ4J.js";
13
+ } from "../chunk-AIAYIXBJ.js";
14
14
  import {
15
15
  getOrCreateWorkspaceId
16
16
  } from "../chunk-EZXEWFDG.js";
@@ -20,21 +20,21 @@ import {
20
20
  } from "../chunk-JJI7FU24.js";
21
21
  import {
22
22
  observeDemoInvocation
23
- } from "../chunk-HT2CJ3YD.js";
23
+ } from "../chunk-D24AUSVP.js";
24
24
  import {
25
25
  appendCodexContext,
26
26
  prepareCodexContext
27
- } from "../chunk-TPWJQD5E.js";
28
- import "../chunk-7GSBXHK4.js";
29
- import "../chunk-72CQVK4E.js";
27
+ } from "../chunk-QJOK2VOE.js";
28
+ import "../chunk-LFZYNNQQ.js";
29
+ import "../chunk-RXD6LFA2.js";
30
30
  import {
31
31
  scrubFromCwd
32
- } from "../chunk-LVRD562C.js";
32
+ } from "../chunk-YQFJUBNU.js";
33
33
  import {
34
34
  bold,
35
35
  cachedCollectScopeAdmits,
36
36
  color
37
- } from "../chunk-FFYZ3XMX.js";
37
+ } from "../chunk-GFJ4QIVR.js";
38
38
  import {
39
39
  getClient,
40
40
  terminalSafeLine
@@ -13,22 +13,22 @@ import {
13
13
  failOpenOutput,
14
14
  observeDemoInvocation,
15
15
  readHookMode
16
- } from "../chunk-HT2CJ3YD.js";
16
+ } from "../chunk-D24AUSVP.js";
17
17
  import {
18
18
  appendCodexContext,
19
19
  hasVisibleCodexMessage,
20
20
  prepareCodexContext
21
- } from "../chunk-TPWJQD5E.js";
22
- import "../chunk-7GSBXHK4.js";
23
- import "../chunk-72CQVK4E.js";
21
+ } from "../chunk-QJOK2VOE.js";
22
+ import "../chunk-LFZYNNQQ.js";
23
+ import "../chunk-RXD6LFA2.js";
24
24
  import {
25
25
  DEFAULT_RULES,
26
26
  scrub
27
- } from "../chunk-LVRD562C.js";
27
+ } from "../chunk-YQFJUBNU.js";
28
28
  import {
29
29
  boundedHealthError,
30
30
  cachedCollectScopeAdmits
31
- } from "../chunk-FFYZ3XMX.js";
31
+ } from "../chunk-GFJ4QIVR.js";
32
32
  import {
33
33
  HttpError,
34
34
  getClient
@@ -18,12 +18,12 @@ import {
18
18
  import {
19
19
  enrichHookPayloadWithFileRefs,
20
20
  preserveHookFileMetadata
21
- } from "../chunk-XY4CRWTF.js";
21
+ } from "../chunk-FDXDV2AT.js";
22
22
  import {
23
23
  postToolInvocationId,
24
24
  shouldFlushAfter,
25
25
  toMove
26
- } from "../chunk-6VFUHQ4J.js";
26
+ } from "../chunk-AIAYIXBJ.js";
27
27
  import {
28
28
  getOrCreateWorkspaceId
29
29
  } from "../chunk-EZXEWFDG.js";
@@ -33,19 +33,19 @@ import {
33
33
  } from "../chunk-JJI7FU24.js";
34
34
  import {
35
35
  observeDemoInvocation
36
- } from "../chunk-HT2CJ3YD.js";
36
+ } from "../chunk-D24AUSVP.js";
37
37
  import {
38
38
  prepareCodexContext
39
- } from "../chunk-TPWJQD5E.js";
40
- import "../chunk-7GSBXHK4.js";
41
- import "../chunk-72CQVK4E.js";
39
+ } from "../chunk-QJOK2VOE.js";
40
+ import "../chunk-LFZYNNQQ.js";
41
+ import "../chunk-RXD6LFA2.js";
42
42
  import {
43
43
  scrubFromCwd,
44
44
  writeHookDebug
45
- } from "../chunk-LVRD562C.js";
45
+ } from "../chunk-YQFJUBNU.js";
46
46
  import {
47
47
  cachedCollectScopeAdmits
48
- } from "../chunk-FFYZ3XMX.js";
48
+ } from "../chunk-GFJ4QIVR.js";
49
49
  import "../chunk-2IRLFOEL.js";
50
50
  import {
51
51
  normalizeEnvelope,
@@ -28,11 +28,11 @@ import {
28
28
  } from "../chunk-EZXEWFDG.js";
29
29
  import {
30
30
  prepareCodexContext
31
- } from "../chunk-TPWJQD5E.js";
32
- import "../chunk-72CQVK4E.js";
31
+ } from "../chunk-QJOK2VOE.js";
32
+ import "../chunk-RXD6LFA2.js";
33
33
  import {
34
34
  fetchAndCacheCollectScope
35
- } from "../chunk-FFYZ3XMX.js";
35
+ } from "../chunk-GFJ4QIVR.js";
36
36
  import {
37
37
  getSiteUrl,
38
38
  isSessionEnded
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  } from "./chunk-2EKPBZNA.js";
23
23
  import {
24
24
  requireDurableIngestAcknowledgement
25
- } from "./chunk-4CO4A6NR.js";
25
+ } from "./chunk-EQYIPUFX.js";
26
26
  import {
27
27
  checkAffectedDecisions,
28
28
  daemonOrDirectGet,
@@ -61,17 +61,21 @@ import {
61
61
  RUN_ID,
62
62
  demoCommand,
63
63
  demoDiagnosticCommand,
64
+ demoResumeCommand,
64
65
  demoWelcomeCommand,
65
66
  exclusionPath,
66
67
  finishOnboarding,
68
+ isolationDiagnostics,
67
69
  lockRun,
68
70
  lockRunAsync,
69
71
  onboardingFinished,
70
72
  pendingRuns,
73
+ preparationKey,
71
74
  prepareRun,
72
75
  readDemoJson,
76
+ readRun,
73
77
  saveRun
74
- } from "./chunk-7GSBXHK4.js";
78
+ } from "./chunk-LFZYNNQQ.js";
75
79
  import {
76
80
  MS_PER_SECOND,
77
81
  deliveryBacklogState,
@@ -80,7 +84,7 @@ import {
80
84
  formatStatusline,
81
85
  formatTeammates,
82
86
  repositoryBindingDiagnosticLabel
83
- } from "./chunk-72CQVK4E.js";
87
+ } from "./chunk-RXD6LFA2.js";
84
88
  import {
85
89
  bold,
86
90
  boundedHealthError,
@@ -105,7 +109,7 @@ import {
105
109
  isMoveIngestRequest,
106
110
  isReconcileResolutionResponse,
107
111
  stripAnsi
108
- } from "./chunk-FFYZ3XMX.js";
112
+ } from "./chunk-GFJ4QIVR.js";
109
113
  import {
110
114
  CliManagementResponseError,
111
115
  HttpError,
@@ -2295,14 +2299,24 @@ function registerCodexCommands(program2) {
2295
2299
  });
2296
2300
  codex.command("status").description("Report whether each prim surface (gate, capture) is installed per scope").action(() => {
2297
2301
  const result = performStatus3();
2302
+ const readiness = {
2303
+ configured: result.user.complete || result.project.complete,
2304
+ runtime: inspectHookRuntime(),
2305
+ trust: "unknown",
2306
+ hookExecution: "not-verified",
2307
+ passiveCapture: "not-verified"
2308
+ };
2298
2309
  const mark = (b) => b ? "\u2713" : "\u2717";
2299
- const line = (label2, s) => `[prim] ${label2}: gate ${mark(s.gate)} \xB7 capture ${mark(s.capture)} (${s.path})`;
2310
+ const line = (label2, s) => `[prim] ${label2}: ${!s.present ? "not installed (optional when another scope is complete)" : `configured gate ${mark(s.gate)} \xB7 capture ${mark(s.capture)}`} (${s.path})`;
2300
2311
  console.error(`${line("user", result.user)}
2301
2312
  ${line("project", result.project)}`);
2302
2313
  const uncovered = uncoveredWorktreeHooks(result);
2303
2314
  if (uncovered !== null)
2304
2315
  console.error(`[prim] warning: ${uncoveredWorktreeAdvice(uncovered)}`);
2305
- console.log(JSON.stringify(result, null, JSON_INDENT));
2316
+ console.error(
2317
+ "[prim] Configuration is not proof of hook execution or capture. Use the pending tour\u2019s diagnosticAction to check isolation."
2318
+ );
2319
+ console.log(JSON.stringify({ ...result, readiness }, null, JSON_INDENT));
2306
2320
  });
2307
2321
  }
2308
2322
 
@@ -6703,7 +6717,8 @@ var REPOSITORY_EDIT = 'import { orders } from "./shared";\nexport const saveOrde
6703
6717
 
6704
6718
  // src/demo/story.ts
6705
6719
  var DEMO_TASK = "Implement CSV export for customer records, including name and email.";
6706
- var DEMO_ORIGINAL = "Exclude customer email addresses from CSV exports";
6720
+ var DEMO_ORIGINAL = "Exclude customer contact information e.g. email addresses from public-facing data pipelines";
6721
+ var DEMO_RATIONALE = "Customer contact details are collected for account communication, not public distribution. Keeping them out of public-facing pipelines supports our data-minimization and purpose-limitation obligations and reduces the risk of unauthorized disclosure.";
6707
6722
  var DEMO_REPLACEMENT = "Allow customer names and email addresses in CSV exports";
6708
6723
  var DEMO_INITIAL = '// Fictional customer export project.\nexport const customerCsv = "";\n';
6709
6724
  var DEMO_ADHERE = '// Fictional customer export project.\nexport const customerCsv = "name\\nAvery";\n';
@@ -6806,7 +6821,7 @@ function compactDiff(before, after) {
6806
6821
  }
6807
6822
  function demoTrustGuidance(agent) {
6808
6823
  if (agent === "codex")
6809
- return "Check /hooks in Codex. Approve only if a trust action is offered. If hooks are already active, retry the exact standalone command once; do not keep asking for trust or a new session. If still pending, run diagnosticAction and inspect hook errors.";
6824
+ return "Check /hooks in Codex. Approve only if a trust action is offered. If hooks are already active, retry the exact standalone command once; do not keep asking for trust or a new session. If still pending, run diagnosticAction once. Inspect its expected PreToolUse/Bash event and runtime; UserPromptSubmit does not acknowledge the tour. Do not prepare a new run.";
6810
6825
  if (agent === "hermes")
6811
6826
  return "Approve the installed prim hooks when Hermes prompts, then retry the exact nextAction.";
6812
6827
  if (agent === "cursor")
@@ -6845,34 +6860,55 @@ function resultFor2(run) {
6845
6860
  };
6846
6861
  }
6847
6862
  function present(run) {
6848
- if (run.stage === "prepared") return "Tour ready. Run nextAction to check session isolation.";
6863
+ if (run.stage === "prepared") return "Tour prepared \u2192 Isolation pending \u2192 Story not started.";
6849
6864
  if (run.stage === "skipped") return "Tour skipped. Owned sample files removed.";
6865
+ const server = run.server;
6866
+ if (!server) throw new Error("Start the story first");
6850
6867
  if (run.stage === "prompt")
6851
- return `${label}
6852
-
6853
- Imagine you\u2019re a new engineer joining a team. In this story, you previously authored a Decision; now experience it as the new engineer. We\u2019ll email the outcome to your signed-in address.
6854
- ${diagram("[1 Enter task] \u2192 [2 Your Decision stops it] \u2192 [3 Choose \u2192 Email]")}
6855
-
6856
- Enter this prompt in this chat:
6868
+ return `[DEMO] How Primitive Catches Conflicts
6857
6869
 
6858
- \`\`\`text
6859
- ${DEMO_TASK}
6860
- \`\`\``;
6870
+ You're a new engineer on ${safeMarkdown(server.story.orgName)}'s team.
6871
+ And you've been tasked with implementing CSV export functionality for customer records.
6872
+ Enter this prompt to do so:
6873
+ ${DEMO_TASK}`;
6861
6874
  if (run.stage === "conflict")
6862
- return `${label}
6875
+ return `[DEMO] Primitive Caught a Conflict
6863
6876
 
6864
- **YOUR DECISION STOPPED THIS**
6865
- ${diagram("CSV export [name, email]\n \u2502\n \u2715 email excluded\n \u2502\n customers.ts unchanged")}
6877
+ You proposed:
6878
+ "${DEMO_TASK}"
6866
6879
 
6867
- **${DEMO_ORIGINAL}**
6868
- Fictional prior author: ${safeMarkdown(run.server?.authorName ?? "you")}
6880
+ But this conflicts with ${safeMarkdown(server.authorName)}'s Decision from ${safeMarkdown(server.story.decisionDate)}:
6881
+ Intent: ${DEMO_ORIGINAL}
6882
+ Rationale ${DEMO_RATIONALE}
6869
6883
 
6870
- \`\`\`ts
6884
+ \`\`\`
6871
6885
  ${readSample(run, "customers.ts").trimEnd()}
6872
6886
  \`\`\`
6873
6887
 
6874
- Choose **Adhere** (export names only) or **Supersede** with **${DEMO_REPLACEMENT}** and your short reason.`;
6875
- if (run.stage === "completed" || run.stage === "cleanup") {
6888
+ You can either:
6889
+ - Accept ${safeMarkdown(server.authorName)}'s Decision and export only names, or
6890
+ - Supercede ${safeMarkdown(server.authorName)}'s Decision and proceed with exporting both names and email addresses`;
6891
+ if (run.stage === "completed") {
6892
+ const accepted = server.choice === "adhere";
6893
+ const after = accepted ? DEMO_ADHERE : DEMO_SUPERSEDE;
6894
+ return `[DEMO] ${accepted ? "Accepted" : "Superceded"} ${safeMarkdown(server.authorName)}'s Decision
6895
+
6896
+ Implemented CSV Export with ${accepted ? "only names" : "both names and email addresses"}:
6897
+ \`\`\`
6898
+ ${compactDiff(DEMO_INITIAL, after)}
6899
+ \`\`\`
6900
+
6901
+ Check ${safeMarkdown(server.story.recipient)} for details regarding this Decision.
6902
+
6903
+ Start a new session and continue working to begin capturing Decisions.
6904
+ Or, you can explore existing Decisions by prompting your agent e.g.:
6905
+ - Show me my team's recent decisions and summarize what each one settled.
6906
+ - Pick the most load-bearing decision in our graph and walk me through its blast radius \u2014 what would changing it disturb?
6907
+ - Before I refactor, check which prior decisions govern the files I'm about to touch.
6908
+ - Find a file governed by one of our decisions, try a conflicting edit, and show me what the conflict gate says. Don't keep the change.
6909
+ - Is anything in our decision graph under review or waiting on me? Show me what needs attention.`;
6910
+ }
6911
+ if (run.stage === "cleanup") {
6876
6912
  const choice = run.server?.choice;
6877
6913
  const after = choice === "adhere" ? DEMO_ADHERE : DEMO_SUPERSEDE;
6878
6914
  return `${label}
@@ -6885,7 +6921,7 @@ Your Decision \u2192 ${choice === "adhere" ? "preserved" : "replacement + your r
6885
6921
  ${compactDiff(DEMO_INITIAL, after)}
6886
6922
  \`\`\`
6887
6923
 
6888
- ${run.stage === "cleanup" ? "Sample cleanup still needs attention." : "Owned sample files removed."} ${run.server?.email === "accepted" ? "The provider accepted the email; inbox delivery is not confirmed." : "Queued is not inbox delivery."}
6924
+ Sample cleanup still needs attention. ${run.server?.email === "accepted" ? "The provider accepted the email; inbox delivery is not confirmed." : "Queued is not inbox delivery."}
6889
6925
 
6890
6926
  ${run.binding ? captureNotice : "Ready for your real Decisions."}`;
6891
6927
  }
@@ -6906,7 +6942,8 @@ function handoff(run) {
6906
6942
  supersede: {
6907
6943
  command: demoCommand(run, "resolve", "supersede"),
6908
6944
  requiredArgument: "--reason <user-provided reason>",
6909
- replacement: DEMO_REPLACEMENT
6945
+ replacement: DEMO_REPLACEMENT,
6946
+ prompt: `What's your rationale for superceding ${safeMarkdown(run.server?.authorName ?? "the author")}'s existing Decision?`
6910
6947
  }
6911
6948
  }
6912
6949
  };
@@ -6971,7 +7008,30 @@ async function finishResolution(run, choice, reason) {
6971
7008
  finishOnboarding("completed");
6972
7009
  }
6973
7010
  }
7011
+ function pendingIsolation(run, isolation, action, choice, reason) {
7012
+ return {
7013
+ fictional: true,
7014
+ evaluation: "live",
7015
+ runId: run.id,
7016
+ stage: "pending",
7017
+ isolation,
7018
+ ...action === "status" ? { resumeAction: demoResumeCommand(run) } : { nextAction: demoCommand(run, action, choice, reason) },
7019
+ diagnostics: isolationDiagnostics(run),
7020
+ ...action === "status" ? {} : { diagnosticAction: demoDiagnosticCommand(run) },
7021
+ skipAction: demoCommand(run, "skip"),
7022
+ presentation: `Tour prepared \u2192 **Isolation pending** \u2192 ${run.stage === "prepared" ? "Story not started" : "Story paused"}.
7023
+
7024
+ ${isolation}. Checking the installed pre-tool hook before continuing.`,
7025
+ guidance: demoTrustGuidance(run.agent),
7026
+ recovery: `${action === "status" ? "Use this evidence to repair the hook before resumeAction." : "Run diagnosticAction once."} If no hook observation exists, the CLI has no evidence this command reached its installed pre-tool hook. Check the host hook event/error view and configuration-directory access; absence of a log is not proof of healthy hooks. Retry only after a repair, using this run. Never fabricate acknowledgment or read sample files.`
7027
+ };
7028
+ }
6974
7029
  async function advanceDemo(id, action, choice, reason) {
7030
+ if (action === "status") {
7031
+ const run = readRun(id);
7032
+ if (!run.terminal && !run.acknowledgment)
7033
+ return pendingIsolation(run, "acknowledgment-missing", action);
7034
+ }
6975
7035
  return await lockRunAsync(id, async (run) => {
6976
7036
  if (action === "resolve") requireResolution(choice, reason);
6977
7037
  if (action === "skip") {
@@ -6989,19 +7049,8 @@ async function advanceDemo(id, action, choice, reason) {
6989
7049
  throw new Error(
6990
7050
  `Legacy tour: clean up with ${demoCommand(run, "skip")}, then run prim demo again`
6991
7051
  );
6992
- const isolation = consumeAcknowledgment(run, action, choice, reason);
6993
- if (isolation)
6994
- return {
6995
- fictional: true,
6996
- evaluation: "live",
6997
- runId: id,
6998
- stage: "pending",
6999
- isolation,
7000
- nextAction: demoCommand(run, action, choice, reason),
7001
- diagnosticAction: demoDiagnosticCommand(run),
7002
- skipAction: demoCommand(run, "skip"),
7003
- presentation: `Session isolation pending (${isolation}). ${demoTrustGuidance(run.agent)}`
7004
- };
7052
+ const isolation = action === "status" && !run.terminal && !run.acknowledgment ? "acknowledgment-missing" : consumeAcknowledgment(run, action, choice, reason);
7053
+ if (isolation) return pendingIsolation(run, isolation, action, choice, reason);
7005
7054
  if (action === "status") {
7006
7055
  const server = run.server ? await demoStatus(run.server.runId) : void 0;
7007
7056
  return { ...handoff(run), ...server ? { server } : {} };
@@ -7074,9 +7123,19 @@ function parseAgent(value) {
7074
7123
  }
7075
7124
  function reportError(error) {
7076
7125
  const message = terminalSafeLine(error instanceof Error ? error.message : String(error));
7126
+ const code = error?.code;
7077
7127
  process.stderr.write(`[prim] demo: ${message}
7078
7128
  `);
7079
- printJson2({ fictional: true, evaluation: "live", stage: "error", message });
7129
+ printJson2({
7130
+ fictional: true,
7131
+ evaluation: "live",
7132
+ stage: "error",
7133
+ message,
7134
+ ...code === "EPERM" || code === "EACCES" ? {
7135
+ code,
7136
+ recovery: "The host denied access to Primitive local state. Run the same action with the configuration-directory access authorized for setup, within host policy. Do not create another run or change permissions recursively."
7137
+ } : {}
7138
+ });
7080
7139
  process.exitCode = 1;
7081
7140
  }
7082
7141
  async function terminalTour(run) {
@@ -7084,7 +7143,7 @@ async function terminalTour(run) {
7084
7143
  const show = (result) => {
7085
7144
  const text = result.presentation.replace(/^```(?:text|ts|diff)?\n/gmu, "").replace(/```/gu, "").replace(/\*\*(.*?)\*\*/gu, (_match, title) => bold(title));
7086
7145
  process.stderr.write(
7087
- `${text.replace("YOUR DECISION STOPPED THIS", color("YOUR DECISION STOPPED THIS", "red")).replace("PASS \u2014 CSV export implemented", color("PASS \u2014 CSV export implemented", "green"))}
7146
+ `${text.replace("[DEMO] Primitive Caught a Conflict", color("[DEMO] Primitive Caught a Conflict", "red")).replace("PASS \u2014 CSV export implemented", color("PASS \u2014 CSV export implemented", "green"))}
7088
7147
  `
7089
7148
  );
7090
7149
  if (["completed", "skipped"].includes(result.stage) && "nextAction" in result) {
@@ -7100,45 +7159,89 @@ async function terminalTour(run) {
7100
7159
  if (task.trim() !== DEMO_TASK) return show(await advanceDemo(run.id, "skip"));
7101
7160
  const blocked = show(await advanceDemo(run.id, "attempt"));
7102
7161
  if (blocked.stage !== "conflict") return blocked;
7103
- const choice = (await rl.question("Adhere or supersede? [adhere/supersede/skip] ")).trim().toLowerCase();
7162
+ const answer = (await rl.question("Accept or Supercede? [accept/supercede/skip] ")).trim().toLowerCase();
7163
+ const choice = answer === "accept" ? "adhere" : answer === "supercede" ? "supersede" : answer;
7104
7164
  if (choice !== "adhere" && choice !== "supersede")
7105
7165
  return show(await advanceDemo(run.id, "skip"));
7106
- const reason = choice === "supersede" ? await rl.question("Your reason for the replacement: ") : void 0;
7166
+ const reason = choice === "supersede" ? await rl.question(
7167
+ `What's your rationale for superceding ${terminalSafeLine("server" in blocked ? blocked.server?.authorName ?? "the author" : "the author")}'s existing Decision? `
7168
+ ) : void 0;
7107
7169
  return show(await advanceDemo(run.id, "resolve", choice, reason));
7108
7170
  } finally {
7109
7171
  rl.close();
7110
7172
  }
7111
7173
  }
7112
7174
  function registerDemoCommands(program2) {
7113
- const demo = program2.command("demo").description("Experience your Decision protecting a fictional teammate change").option("--agent <agent>", "calling agent; requires session isolation").option("--details", "include supporting story detail").action(async (options, command) => {
7175
+ const demo = program2.command("demo").description("Experience your Decision protecting a fictional teammate change").option("--agent <agent>", "calling agent; requires session isolation").option("--details", "include supporting story detail").option("--resume-pending", "reuse a pending tour prepared in this Codex session").action(async (options, command) => {
7114
7176
  try {
7115
7177
  const agent = parseAgent(options.agent);
7116
7178
  const terminal = !agent && !isNonInteractive(command.optsWithGlobals()) && !!process.stdin.isTTY && !!process.stderr.isTTY && !process.env.CLAUDECODE && !process.env.CODEX_THREAD_ID && !process.env.CURSOR_AGENT && !process.env.HERMES_INTERACTIVE;
7117
- const recovery = pendingRuns().map(
7118
- (id) => lockRun(id, (run2) => ({
7119
- runId: id,
7120
- skipAction: demoCommand(
7121
- { ...run2, launcher: [process.execPath, resolve3(process.argv[1])] },
7122
- "skip"
7123
- )
7124
- }))
7125
- );
7126
- const run = prepareRun(agent, terminal);
7179
+ const runs = pendingRuns().map(readRun);
7180
+ const recovery = runs.map((run2) => ({
7181
+ runId: run2.id,
7182
+ resumeAction: run2.version === 2 ? demoResumeCommand(run2) : void 0,
7183
+ skipAction: demoCommand(
7184
+ { ...run2, launcher: [process.execPath, resolve3(process.argv[1])] },
7185
+ "skip"
7186
+ )
7187
+ }));
7188
+ const key = preparationKey(agent);
7189
+ const pending = options.resumePending && key ? runs.find(
7190
+ (run2) => run2.version === 2 && run2.preparationKey === key && run2.agent === agent
7191
+ ) : void 0;
7192
+ const run = pending ? lockRun(pending.id, (run2) => {
7193
+ run2.launcher = [process.execPath, resolve3(process.argv[1])];
7194
+ run2.acknowledgment = void 0;
7195
+ saveRun(run2);
7196
+ return run2;
7197
+ }) : prepareRun(agent, terminal);
7127
7198
  if (terminal) {
7128
7199
  const result = await terminalTour(run);
7129
7200
  if (!process.stdout.isTTY) printJson2(result);
7130
7201
  return;
7131
7202
  }
7132
- process.stderr.write("[prim] Tour ready \u2192 run nextAction to check session isolation.\n");
7203
+ process.stderr.write(
7204
+ "[prim] Tour prepared \u2192 verify isolation to continue. Follow nextAction.\n"
7205
+ );
7133
7206
  printJson2({
7134
- ...handoff(run),
7135
- instructions: "Run nextAction exactly as a standalone command. Render presentation once, preserving diagrams. At awaitUserPrompt, wait for the user to enter that task before running attemptAction. At the block, wait for adhere or supersede; supersede requires the user's own reason and approval of the displayed replacement. Append --reason and the reason using the same single-quoted argv format (escape an apostrophe as '\\''). Never invent a reason, delegate this tour, or save fictional samples to memory or real Decisions. On completion display success before following welcome. A new session resumes passive capture.",
7207
+ fictional: true,
7208
+ evaluation: "live",
7209
+ runId: run.id,
7210
+ stage: run.stage,
7211
+ nextAction: demoCommand(run, run.stage === "prepared" ? "start" : "status"),
7212
+ skipAction: demoCommand(run, "skip"),
7213
+ statusAction: demoDiagnosticCommand(run),
7214
+ presentation: `Tour prepared \u2192 Isolation pending \u2192 ${run.stage === "prepared" ? "Story not started" : "Story paused"}.`,
7215
+ instructions: "Continue nextAction now within the authorized setup request; do not stop at welcome or ask whether to begin. Run nextAction exactly as a standalone command with the same authorized local-state access as setup. Render presentation once, preserving diagrams. At awaitUserPrompt, wait for the user to enter that task before running attemptAction. At the block, wait for adhere or supersede; supersede requires the user's own reason and approval of the displayed replacement. Append --reason and the reason using the same single-quoted argv format (escape an apostrophe as '\\''). Never invent a reason, delegate this tour, or save fictional samples to memory or real Decisions. On completion display success before following welcome. A new session resumes passive capture.",
7136
7216
  recoverableRuns: recovery
7137
7217
  });
7138
7218
  } catch (error) {
7139
7219
  reportError(error);
7140
7220
  }
7141
7221
  });
7222
+ demo.command("resume <runId>").description("Recover this run's launcher without revealing story content").action((id) => {
7223
+ try {
7224
+ printJson2(
7225
+ lockRun(id, (run) => {
7226
+ if (run.version !== 2) throw new Error("Legacy tour must be skipped before replay");
7227
+ run.launcher = [process.execPath, resolve3(process.argv[1])];
7228
+ run.acknowledgment = void 0;
7229
+ saveRun(run);
7230
+ return {
7231
+ fictional: true,
7232
+ evaluation: "live",
7233
+ runId: id,
7234
+ stage: "pending",
7235
+ nextAction: demoCommand(run, run.stage === "prepared" ? "start" : "status"),
7236
+ diagnosticAction: demoDiagnosticCommand(run),
7237
+ presentation: "Run nextAction to verify isolation and resume this tour."
7238
+ };
7239
+ })
7240
+ );
7241
+ } catch (error) {
7242
+ reportError(error);
7243
+ }
7244
+ });
7142
7245
  for (const action of ["start", "attempt", "resolve", "status", "skip"]) {
7143
7246
  const sub = demo.command(`${action} ${action === "skip" ? "[runId]" : "<runId>"}`);
7144
7247
  if (action === "resolve")
@@ -8196,7 +8299,7 @@ function managedHookRemedy(inspection) {
8196
8299
  }
8197
8300
  return "run `prim hooks install`";
8198
8301
  case "unsupported_interpreter":
8199
- return "verify the hook interpreter; direct shell hooks need a supported shebang (for example #!/bin/sh); Husky v9 must use its .husky/_ dispatcher";
8302
+ return "existing hook preserved: add a supported shebang (for example #!/bin/sh) to a direct shell hook, or run the repository\u2019s Husky prepare script so Husky v9 selects .husky/_; then rerun prim setup. Primitive does not rewrite an unknown interpreter or change core.hooksPath silently";
8200
8303
  case "entrypoint_missing":
8201
8304
  return "run `prim enable` to stage the hook runtime";
8202
8305
  default:
@@ -9642,6 +9745,7 @@ function detectAgent(env) {
9642
9745
  if (env.HERMES_INTERACTIVE) {
9643
9746
  return "hermes";
9644
9747
  }
9748
+ if (env.CODEX_THREAD_ID) return "codex";
9645
9749
  if (env.CURSOR_AGENT) {
9646
9750
  return "cursor";
9647
9751
  }
@@ -9676,7 +9780,7 @@ function registerSetupCommand(program2, dependencies = {}) {
9676
9780
  ).option(
9677
9781
  "--migrate",
9678
9782
  "with the default user scope, remove any project-scoped prim config in this repo (else just warn)"
9679
- ).option("--no-daemon", "stop and disable the companion daemon").option("--details", "show full installation diagnostics and child output").option("--skip-demo", "skip the optional author story and remember that choice").action((opts) => {
9783
+ ).option("--no-daemon", "stop and disable the companion daemon").option("--details", "show full human installation diagnostics on STDERR").option("--skip-demo", "skip the optional author story and remember that choice").action((opts) => {
9680
9784
  const { agent: agentInput, detected } = resolveAgent(opts.agent, process.env);
9681
9785
  if (agentInput !== "claude" && agentInput !== "codex" && agentInput !== "cursor" && agentInput !== "hermes") {
9682
9786
  process.stderr.write(
@@ -9702,25 +9806,21 @@ function registerSetupCommand(program2, dependencies = {}) {
9702
9806
  const self = process.argv[1];
9703
9807
  const globals = program2.optsWithGlobals();
9704
9808
  const run = dependencies.run ?? ((args, capture = false) => {
9705
- const compact = !opts.details;
9706
- const structuredChild = args.includes("demo") || args[0] === "welcome";
9707
9809
  const childArgs = opts.details ? args.filter((arg) => arg !== "--compact") : args;
9708
9810
  const r = spawnSync2(
9709
9811
  process.execPath,
9710
9812
  [self, ...childArgs],
9711
9813
  setupStepSpawnOptions(capture, process.env, {
9712
9814
  startsDaemon: opts.daemon,
9713
- compact: compact || structuredChild
9815
+ compact: true
9714
9816
  })
9715
9817
  );
9716
- if (!capture && opts.details && structuredChild && r.stdout)
9717
- process.stdout.write(r.stdout);
9718
- if (!capture && compact && r.status !== 0 && r.stdout) process.stderr.write(r.stdout);
9818
+ if (!capture && r.status !== 0 && r.stdout) process.stderr.write(r.stdout);
9719
9819
  if (r.error) process.stderr.write(`[prim] ${r.error.message}
9720
9820
  `);
9721
9821
  return {
9722
9822
  code: r.status ?? 1,
9723
- stdout: capture || compact || structuredChild ? r.stdout ?? "" : ""
9823
+ stdout: r.stdout ?? ""
9724
9824
  };
9725
9825
  });
9726
9826
  const results = {};
@@ -9801,11 +9901,13 @@ function registerSetupCommand(program2, dependencies = {}) {
9801
9901
  const { code } = run(enableArgs);
9802
9902
  results[enableStep.key] = code === 0 ? "ok" : enableStep.required ? "failed" : "skipped";
9803
9903
  }
9904
+ let health;
9804
9905
  const healthStep = setupSteps.find((candidate) => candidate.key === "health");
9805
9906
  if (healthStep) {
9806
9907
  note(`${healthStep.label} \xB7 verifying\u2026`);
9807
- const { code } = run(healthStep.args);
9808
- results[healthStep.key] = code === 0 ? "ok" : healthStep.required ? "failed" : "skipped";
9908
+ const { code, stdout } = run(healthStep.args);
9909
+ health = setupChildPayload(stdout);
9910
+ results[healthStep.key] = code !== 0 || health?.status === "fail" ? healthStep.required ? "failed" : "skipped" : health?.status === "warn" ? "warn" : "ok";
9809
9911
  }
9810
9912
  const installationSucceeded = !Object.values(results).includes("failed");
9811
9913
  let tourDue = false;
@@ -9844,6 +9946,7 @@ function registerSetupCommand(program2, dependencies = {}) {
9844
9946
  const demoResult = run([
9845
9947
  ...globals.nonInteractive ? ["--non-interactive"] : [],
9846
9948
  "demo",
9949
+ "--resume-pending",
9847
9950
  ...agentDriven ? ["--agent", agent] : []
9848
9951
  ]);
9849
9952
  onboarding = setupChildPayload(demoResult.stdout) ?? {
@@ -9860,6 +9963,16 @@ function registerSetupCommand(program2, dependencies = {}) {
9860
9963
  setup: true,
9861
9964
  status: failed.length ? "incomplete" : "complete",
9862
9965
  steps: results,
9966
+ ...health ? { health } : {},
9967
+ readiness: {
9968
+ installation: failed.length ? "incomplete" : "installed",
9969
+ health: results.health ?? "not-checked",
9970
+ passiveCapture: "not-verified",
9971
+ onboarding: onboarding?.stage ?? (opts.skipDemo ? "skipped" : "not-due")
9972
+ },
9973
+ ...onboarding?.nextAction ? {
9974
+ instructions: "Setup installation is complete. Continue nextAction now; onboarding is pending. Render each presentation once. Do not stop at welcome, repeat raw output, or claim passive capture is verified."
9975
+ } : {},
9863
9976
  welcome: setupChildPayload(welcomeResult.stdout),
9864
9977
  ...onboarding ? { onboarding, nextAction: onboarding.nextAction } : {}
9865
9978
  });
@@ -10302,7 +10415,7 @@ function registerWelcomeCommand(program2, deps = { getClient }) {
10302
10415
  const agent = resolveWelcomeAgent(options.agent, process.env);
10303
10416
  if (options.deferSeeding) {
10304
10417
  process.stderr.write(
10305
- "Welcome to Primitive. Setup is complete; the optional author story comes before real Decision seeding.\n"
10418
+ "Primitive installed \u2192 session isolation next \u2192 story \u2192 real Decisions. Follow setup\u2019s nextAction.\n"
10306
10419
  );
10307
10420
  printJson({ welcomed: true, onboarding: "demo", seedingDeferred: true });
10308
10421
  return;