@primitive.ai/prim 0.1.0-alpha.106 → 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.
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  enrichHookPayloadWithFileRefs,
7
7
  preserveHookFileMetadata
8
- } from "../chunk-XY4CRWTF.js";
8
+ } from "../chunk-6L7EYXVF.js";
9
9
  import {
10
10
  postToolInvocationId,
11
11
  toMove,
@@ -20,12 +20,12 @@ import {
20
20
  } from "../chunk-JJI7FU24.js";
21
21
  import {
22
22
  observeDemoInvocation
23
- } from "../chunk-HT2CJ3YD.js";
23
+ } from "../chunk-7NNJ67YN.js";
24
24
  import {
25
25
  appendCodexContext,
26
26
  prepareCodexContext
27
27
  } from "../chunk-TPWJQD5E.js";
28
- import "../chunk-7GSBXHK4.js";
28
+ import "../chunk-P5I4HGMW.js";
29
29
  import "../chunk-72CQVK4E.js";
30
30
  import {
31
31
  scrubFromCwd
@@ -13,13 +13,13 @@ import {
13
13
  failOpenOutput,
14
14
  observeDemoInvocation,
15
15
  readHookMode
16
- } from "../chunk-HT2CJ3YD.js";
16
+ } from "../chunk-7NNJ67YN.js";
17
17
  import {
18
18
  appendCodexContext,
19
19
  hasVisibleCodexMessage,
20
20
  prepareCodexContext
21
21
  } from "../chunk-TPWJQD5E.js";
22
- import "../chunk-7GSBXHK4.js";
22
+ import "../chunk-P5I4HGMW.js";
23
23
  import "../chunk-72CQVK4E.js";
24
24
  import {
25
25
  DEFAULT_RULES,
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  enrichHookPayloadWithFileRefs,
20
20
  preserveHookFileMetadata
21
- } from "../chunk-XY4CRWTF.js";
21
+ } from "../chunk-6L7EYXVF.js";
22
22
  import {
23
23
  postToolInvocationId,
24
24
  shouldFlushAfter,
@@ -33,11 +33,11 @@ import {
33
33
  } from "../chunk-JJI7FU24.js";
34
34
  import {
35
35
  observeDemoInvocation
36
- } from "../chunk-HT2CJ3YD.js";
36
+ } from "../chunk-7NNJ67YN.js";
37
37
  import {
38
38
  prepareCodexContext
39
39
  } from "../chunk-TPWJQD5E.js";
40
- import "../chunk-7GSBXHK4.js";
40
+ import "../chunk-P5I4HGMW.js";
41
41
  import "../chunk-72CQVK4E.js";
42
42
  import {
43
43
  scrubFromCwd,
package/dist/index.js CHANGED
@@ -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-P5I4HGMW.js";
75
79
  import {
76
80
  MS_PER_SECOND,
77
81
  deliveryBacklogState,
@@ -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
 
@@ -6806,7 +6820,7 @@ function compactDiff(before, after) {
6806
6820
  }
6807
6821
  function demoTrustGuidance(agent) {
6808
6822
  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.";
6823
+ 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
6824
  if (agent === "hermes")
6811
6825
  return "Approve the installed prim hooks when Hermes prompts, then retry the exact nextAction.";
6812
6826
  if (agent === "cursor")
@@ -6845,7 +6859,7 @@ function resultFor2(run) {
6845
6859
  };
6846
6860
  }
6847
6861
  function present(run) {
6848
- if (run.stage === "prepared") return "Tour ready. Run nextAction to check session isolation.";
6862
+ if (run.stage === "prepared") return "Tour prepared \u2192 Isolation pending \u2192 Story not started.";
6849
6863
  if (run.stage === "skipped") return "Tour skipped. Owned sample files removed.";
6850
6864
  if (run.stage === "prompt")
6851
6865
  return `${label}
@@ -6971,7 +6985,30 @@ async function finishResolution(run, choice, reason) {
6971
6985
  finishOnboarding("completed");
6972
6986
  }
6973
6987
  }
6988
+ function pendingIsolation(run, isolation, action, choice, reason) {
6989
+ return {
6990
+ fictional: true,
6991
+ evaluation: "live",
6992
+ runId: run.id,
6993
+ stage: "pending",
6994
+ isolation,
6995
+ ...action === "status" ? { resumeAction: demoResumeCommand(run) } : { nextAction: demoCommand(run, action, choice, reason) },
6996
+ diagnostics: isolationDiagnostics(run),
6997
+ ...action === "status" ? {} : { diagnosticAction: demoDiagnosticCommand(run) },
6998
+ skipAction: demoCommand(run, "skip"),
6999
+ presentation: `Tour prepared \u2192 **Isolation pending** \u2192 ${run.stage === "prepared" ? "Story not started" : "Story paused"}.
7000
+
7001
+ ${isolation}. Checking the installed pre-tool hook before continuing.`,
7002
+ guidance: demoTrustGuidance(run.agent),
7003
+ 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.`
7004
+ };
7005
+ }
6974
7006
  async function advanceDemo(id, action, choice, reason) {
7007
+ if (action === "status") {
7008
+ const run = readRun(id);
7009
+ if (!run.terminal && !run.acknowledgment)
7010
+ return pendingIsolation(run, "acknowledgment-missing", action);
7011
+ }
6975
7012
  return await lockRunAsync(id, async (run) => {
6976
7013
  if (action === "resolve") requireResolution(choice, reason);
6977
7014
  if (action === "skip") {
@@ -6989,19 +7026,8 @@ async function advanceDemo(id, action, choice, reason) {
6989
7026
  throw new Error(
6990
7027
  `Legacy tour: clean up with ${demoCommand(run, "skip")}, then run prim demo again`
6991
7028
  );
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
- };
7029
+ const isolation = action === "status" && !run.terminal && !run.acknowledgment ? "acknowledgment-missing" : consumeAcknowledgment(run, action, choice, reason);
7030
+ if (isolation) return pendingIsolation(run, isolation, action, choice, reason);
7005
7031
  if (action === "status") {
7006
7032
  const server = run.server ? await demoStatus(run.server.runId) : void 0;
7007
7033
  return { ...handoff(run), ...server ? { server } : {} };
@@ -7074,9 +7100,19 @@ function parseAgent(value) {
7074
7100
  }
7075
7101
  function reportError(error) {
7076
7102
  const message = terminalSafeLine(error instanceof Error ? error.message : String(error));
7103
+ const code = error?.code;
7077
7104
  process.stderr.write(`[prim] demo: ${message}
7078
7105
  `);
7079
- printJson2({ fictional: true, evaluation: "live", stage: "error", message });
7106
+ printJson2({
7107
+ fictional: true,
7108
+ evaluation: "live",
7109
+ stage: "error",
7110
+ message,
7111
+ ...code === "EPERM" || code === "EACCES" ? {
7112
+ code,
7113
+ 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."
7114
+ } : {}
7115
+ });
7080
7116
  process.exitCode = 1;
7081
7117
  }
7082
7118
  async function terminalTour(run) {
@@ -7110,35 +7146,76 @@ async function terminalTour(run) {
7110
7146
  }
7111
7147
  }
7112
7148
  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) => {
7149
+ 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
7150
  try {
7115
7151
  const agent = parseAgent(options.agent);
7116
7152
  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);
7153
+ const runs = pendingRuns().map(readRun);
7154
+ const recovery = runs.map((run2) => ({
7155
+ runId: run2.id,
7156
+ resumeAction: run2.version === 2 ? demoResumeCommand(run2) : void 0,
7157
+ skipAction: demoCommand(
7158
+ { ...run2, launcher: [process.execPath, resolve3(process.argv[1])] },
7159
+ "skip"
7160
+ )
7161
+ }));
7162
+ const key = preparationKey(agent);
7163
+ const pending = options.resumePending && key ? runs.find(
7164
+ (run2) => run2.version === 2 && run2.preparationKey === key && run2.agent === agent
7165
+ ) : void 0;
7166
+ const run = pending ? lockRun(pending.id, (run2) => {
7167
+ run2.launcher = [process.execPath, resolve3(process.argv[1])];
7168
+ run2.acknowledgment = void 0;
7169
+ saveRun(run2);
7170
+ return run2;
7171
+ }) : prepareRun(agent, terminal);
7127
7172
  if (terminal) {
7128
7173
  const result = await terminalTour(run);
7129
7174
  if (!process.stdout.isTTY) printJson2(result);
7130
7175
  return;
7131
7176
  }
7132
- process.stderr.write("[prim] Tour ready \u2192 run nextAction to check session isolation.\n");
7177
+ process.stderr.write(
7178
+ "[prim] Tour prepared \u2192 verify isolation to continue. Follow nextAction.\n"
7179
+ );
7133
7180
  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.",
7181
+ fictional: true,
7182
+ evaluation: "live",
7183
+ runId: run.id,
7184
+ stage: run.stage,
7185
+ nextAction: demoCommand(run, run.stage === "prepared" ? "start" : "status"),
7186
+ skipAction: demoCommand(run, "skip"),
7187
+ statusAction: demoDiagnosticCommand(run),
7188
+ presentation: `Tour prepared \u2192 Isolation pending \u2192 ${run.stage === "prepared" ? "Story not started" : "Story paused"}.`,
7189
+ 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
7190
  recoverableRuns: recovery
7137
7191
  });
7138
7192
  } catch (error) {
7139
7193
  reportError(error);
7140
7194
  }
7141
7195
  });
7196
+ demo.command("resume <runId>").description("Recover this run's launcher without revealing story content").action((id) => {
7197
+ try {
7198
+ printJson2(
7199
+ lockRun(id, (run) => {
7200
+ if (run.version !== 2) throw new Error("Legacy tour must be skipped before replay");
7201
+ run.launcher = [process.execPath, resolve3(process.argv[1])];
7202
+ run.acknowledgment = void 0;
7203
+ saveRun(run);
7204
+ return {
7205
+ fictional: true,
7206
+ evaluation: "live",
7207
+ runId: id,
7208
+ stage: "pending",
7209
+ nextAction: demoCommand(run, run.stage === "prepared" ? "start" : "status"),
7210
+ diagnosticAction: demoDiagnosticCommand(run),
7211
+ presentation: "Run nextAction to verify isolation and resume this tour."
7212
+ };
7213
+ })
7214
+ );
7215
+ } catch (error) {
7216
+ reportError(error);
7217
+ }
7218
+ });
7142
7219
  for (const action of ["start", "attempt", "resolve", "status", "skip"]) {
7143
7220
  const sub = demo.command(`${action} ${action === "skip" ? "[runId]" : "<runId>"}`);
7144
7221
  if (action === "resolve")
@@ -8196,7 +8273,7 @@ function managedHookRemedy(inspection) {
8196
8273
  }
8197
8274
  return "run `prim hooks install`";
8198
8275
  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";
8276
+ 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
8277
  case "entrypoint_missing":
8201
8278
  return "run `prim enable` to stage the hook runtime";
8202
8279
  default:
@@ -9642,6 +9719,7 @@ function detectAgent(env) {
9642
9719
  if (env.HERMES_INTERACTIVE) {
9643
9720
  return "hermes";
9644
9721
  }
9722
+ if (env.CODEX_THREAD_ID) return "codex";
9645
9723
  if (env.CURSOR_AGENT) {
9646
9724
  return "cursor";
9647
9725
  }
@@ -9676,7 +9754,7 @@ function registerSetupCommand(program2, dependencies = {}) {
9676
9754
  ).option(
9677
9755
  "--migrate",
9678
9756
  "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) => {
9757
+ ).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
9758
  const { agent: agentInput, detected } = resolveAgent(opts.agent, process.env);
9681
9759
  if (agentInput !== "claude" && agentInput !== "codex" && agentInput !== "cursor" && agentInput !== "hermes") {
9682
9760
  process.stderr.write(
@@ -9702,25 +9780,21 @@ function registerSetupCommand(program2, dependencies = {}) {
9702
9780
  const self = process.argv[1];
9703
9781
  const globals = program2.optsWithGlobals();
9704
9782
  const run = dependencies.run ?? ((args, capture = false) => {
9705
- const compact = !opts.details;
9706
- const structuredChild = args.includes("demo") || args[0] === "welcome";
9707
9783
  const childArgs = opts.details ? args.filter((arg) => arg !== "--compact") : args;
9708
9784
  const r = spawnSync2(
9709
9785
  process.execPath,
9710
9786
  [self, ...childArgs],
9711
9787
  setupStepSpawnOptions(capture, process.env, {
9712
9788
  startsDaemon: opts.daemon,
9713
- compact: compact || structuredChild
9789
+ compact: true
9714
9790
  })
9715
9791
  );
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);
9792
+ if (!capture && r.status !== 0 && r.stdout) process.stderr.write(r.stdout);
9719
9793
  if (r.error) process.stderr.write(`[prim] ${r.error.message}
9720
9794
  `);
9721
9795
  return {
9722
9796
  code: r.status ?? 1,
9723
- stdout: capture || compact || structuredChild ? r.stdout ?? "" : ""
9797
+ stdout: r.stdout ?? ""
9724
9798
  };
9725
9799
  });
9726
9800
  const results = {};
@@ -9801,11 +9875,13 @@ function registerSetupCommand(program2, dependencies = {}) {
9801
9875
  const { code } = run(enableArgs);
9802
9876
  results[enableStep.key] = code === 0 ? "ok" : enableStep.required ? "failed" : "skipped";
9803
9877
  }
9878
+ let health;
9804
9879
  const healthStep = setupSteps.find((candidate) => candidate.key === "health");
9805
9880
  if (healthStep) {
9806
9881
  note(`${healthStep.label} \xB7 verifying\u2026`);
9807
- const { code } = run(healthStep.args);
9808
- results[healthStep.key] = code === 0 ? "ok" : healthStep.required ? "failed" : "skipped";
9882
+ const { code, stdout } = run(healthStep.args);
9883
+ health = setupChildPayload(stdout);
9884
+ results[healthStep.key] = code !== 0 || health?.status === "fail" ? healthStep.required ? "failed" : "skipped" : health?.status === "warn" ? "warn" : "ok";
9809
9885
  }
9810
9886
  const installationSucceeded = !Object.values(results).includes("failed");
9811
9887
  let tourDue = false;
@@ -9844,6 +9920,7 @@ function registerSetupCommand(program2, dependencies = {}) {
9844
9920
  const demoResult = run([
9845
9921
  ...globals.nonInteractive ? ["--non-interactive"] : [],
9846
9922
  "demo",
9923
+ "--resume-pending",
9847
9924
  ...agentDriven ? ["--agent", agent] : []
9848
9925
  ]);
9849
9926
  onboarding = setupChildPayload(demoResult.stdout) ?? {
@@ -9860,6 +9937,16 @@ function registerSetupCommand(program2, dependencies = {}) {
9860
9937
  setup: true,
9861
9938
  status: failed.length ? "incomplete" : "complete",
9862
9939
  steps: results,
9940
+ ...health ? { health } : {},
9941
+ readiness: {
9942
+ installation: failed.length ? "incomplete" : "installed",
9943
+ health: results.health ?? "not-checked",
9944
+ passiveCapture: "not-verified",
9945
+ onboarding: onboarding?.stage ?? (opts.skipDemo ? "skipped" : "not-due")
9946
+ },
9947
+ ...onboarding?.nextAction ? {
9948
+ 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."
9949
+ } : {},
9863
9950
  welcome: setupChildPayload(welcomeResult.stdout),
9864
9951
  ...onboarding ? { onboarding, nextAction: onboarding.nextAction } : {}
9865
9952
  });
@@ -10302,7 +10389,7 @@ function registerWelcomeCommand(program2, deps = { getClient }) {
10302
10389
  const agent = resolveWelcomeAgent(options.agent, process.env);
10303
10390
  if (options.deferSeeding) {
10304
10391
  process.stderr.write(
10305
- "Welcome to Primitive. Setup is complete; the optional author story comes before real Decision seeding.\n"
10392
+ "Primitive installed \u2192 session isolation next \u2192 story \u2192 real Decisions. Follow setup\u2019s nextAction.\n"
10306
10393
  );
10307
10394
  printJson({ welcomed: true, onboarding: "demo", seedingDeferred: true });
10308
10395
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitive.ai/prim",
3
- "version": "0.1.0-alpha.106",
3
+ "version": "0.1.0-alpha.107",
4
4
  "description": "CLI for Primitive's decision graph — passive decision capture, conflict gate, and team presence",
5
5
  "type": "module",
6
6
  "license": "MIT",