@primitive.ai/prim 0.1.0-alpha.103 → 0.1.0-alpha.105
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 +8 -2
- package/SKILL.md +31 -22
- package/dist/{chunk-O2WV5SQZ.js → chunk-2EKPBZNA.js} +1 -1
- package/dist/{chunk-6C3CCVDI.js → chunk-NH3VC7YO.js} +1 -1
- package/dist/{chunk-K4JWJ6OM.js → chunk-PO5QAYD7.js} +8 -5
- package/dist/hook-runtime/index.js +119 -90
- package/dist/hooks/post-tool-use.js +2 -2
- package/dist/hooks/pre-tool-use.js +2 -2
- package/dist/hooks/prim-hook.js +2 -2
- package/dist/hooks/session-end.js +2 -2
- package/dist/hooks/session-start.js +3 -3
- package/dist/index.js +114 -88
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -15,7 +15,10 @@ presence — from the command line and via session + git hooks.
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
Requires Node.js
|
|
18
|
+
Requires Node.js 22.23.4+, 24.22.1+, or 26.12.1+ within those major versions.
|
|
19
|
+
Node.js 20 is no longer supported. After updating Node.js, restart the daemon
|
|
20
|
+
with `prim daemon restart` and rerun your agent's `prim <agent> install` command
|
|
21
|
+
and `prim hooks install` to repin their runtimes to the updated executable.
|
|
19
22
|
|
|
20
23
|
```bash
|
|
21
24
|
npm install -g @primitive.ai/prim
|
|
@@ -49,7 +52,10 @@ The tour follows one order-saving task and ends with a receipt of the demonstrat
|
|
|
49
52
|
lifecycle, then offers one real project Decision for your individual approval.
|
|
50
53
|
Use `prim setup --skip-demo` to skip and remember that choice, or
|
|
51
54
|
`prim demo --agent <claude|codex|cursor|hermes>` to replay.
|
|
52
|
-
For a person at a terminal, `prim demo` prompts directly
|
|
55
|
+
For a person at a terminal, `prim demo` prompts directly with compact Decision
|
|
56
|
+
cards, write outcomes, and file diffs. Use `prim demo --details` for the full source
|
|
57
|
+
and supporting detail. Interactive terminal output omits the completion JSON;
|
|
58
|
+
redirected STDOUT and agent commands retain machine-readable JSON.
|
|
53
59
|
|
|
54
60
|
The agent tour waits for trusted hooks before showing samples and excludes
|
|
55
61
|
passive capture for the remainder of that agent session, including resumes.
|
package/SKILL.md
CHANGED
|
@@ -159,28 +159,37 @@ If the result is pending, surface its hook-trust instruction and retry only afte
|
|
|
159
159
|
trust is established. Never fabricate the missing output or read sample fixtures
|
|
160
160
|
yourself to bypass isolation.
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
the
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
162
|
+
Render each result once. Consume the JSON; do not dump it, echo the CLI narration,
|
|
163
|
+
or add a second prose recap. Use compact Markdown, short code blocks, and visible
|
|
164
|
+
state changes. Aim for at most 120 narrative words per choice, excluding code;
|
|
165
|
+
do not fill the budget. Keep a short **Simulated tour** label on each response.
|
|
166
|
+
|
|
167
|
+
Once isolated, lead with **Add order saving**. Show one supporting quote flowing
|
|
168
|
+
into the extracted Decision: `Source → Decision [provisional]`. Give each Decision
|
|
169
|
+
only its headline, one-line **Why**, and file scope; label the extracted scope as
|
|
170
|
+
a demo mapping. The JSON's `sourceNote`, `decisions`, and `proposal` retain the
|
|
171
|
+
full source, evidence, rationale, and rejected alternatives for questions.
|
|
172
|
+
|
|
173
|
+
Pause for only two teaching choices: adopt the proposal, then choose the shared
|
|
174
|
+
repository correction or retry direct storage. Use `confirm` only after the user's
|
|
175
|
+
confirmation; a setup request or `--yes` is not that answer. Follow `skipAction`
|
|
176
|
+
if the user declines or stops. Acknowledge approval with **Proposed → Adopted**.
|
|
177
|
+
|
|
178
|
+
Present **WARNING — edit allowed** and **BLOCKED — file unchanged** separately.
|
|
179
|
+
For each, show the governing Decision, one reason, and compact file evidence.
|
|
180
|
+
Use the returned before/after bytes: show the warning's changed lines, and the
|
|
181
|
+
blocked write stopping before `orders.ts` with its actual contents unchanged.
|
|
182
|
+
Omit diff transport headers and hunk metadata. On retry, repeat only the block,
|
|
183
|
+
its reason, unchanged-file evidence, and correction choice. These are scripted
|
|
184
|
+
verdicts, not universal rules for Decision states; live gates vary by agent and
|
|
185
|
+
state (Claude may request permission where other agents block).
|
|
186
|
+
|
|
187
|
+
On correction, show both actual diffs and **PASS — order saving added**. Finish
|
|
188
|
+
with `✓ Extracted · ✓ Adopted · ✓ Warned · ✓ Blocked · ✓ Corrected`, sample cleanup,
|
|
189
|
+
and the new-session reminder. Never show completion for a skip, pending tour, or
|
|
190
|
+
error. Offer one real Decision for individual approval; continue one at a time
|
|
191
|
+
only if the user wants to proceed. Keep supporting detail on request instead of
|
|
192
|
+
expanding every record. Direct terminal users can replay with `prim demo --details`.
|
|
184
193
|
|
|
185
194
|
Never record these examples with `decisions create`, save them to shared memory,
|
|
186
195
|
or include them in later seeding candidates. The tour excludes passive capture
|
|
@@ -440,15 +440,18 @@ function hasSafeRuntimeLayout(paths, selected) {
|
|
|
440
440
|
(relativePath) => privateFile(join(selected.dir, relativePath), DATA_FILE_MODE)
|
|
441
441
|
);
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function sameNodeExecutable(recorded, desired) {
|
|
444
444
|
try {
|
|
445
|
-
if (!statSync(
|
|
446
|
-
accessSync(
|
|
447
|
-
return realpathSync(
|
|
445
|
+
if (!statSync(recorded).isFile()) return false;
|
|
446
|
+
accessSync(recorded, constants.X_OK);
|
|
447
|
+
return realpathSync(recorded) === realpathSync(desired);
|
|
448
448
|
} catch {
|
|
449
449
|
return false;
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
+
function recordedNodeMatchesCurrentProcess(nodePath) {
|
|
453
|
+
return sameNodeExecutable(nodePath, process.execPath);
|
|
454
|
+
}
|
|
452
455
|
function inspectHookRuntime(options = {}) {
|
|
453
456
|
let paths;
|
|
454
457
|
try {
|
|
@@ -575,7 +578,7 @@ function stageHookRuntime(options = {}) {
|
|
|
575
578
|
if (precedence === void 0) {
|
|
576
579
|
throw new Error("cannot stage hook runtime: selected release version is malformed");
|
|
577
580
|
}
|
|
578
|
-
const selectRequested = !selected || precedence < 0;
|
|
581
|
+
const selectRequested = !selected || precedence < 0 || precedence === 0 && !sameNodeExecutable(selected.manifest.nodePath, nodePath);
|
|
579
582
|
const requestedExists = existsSync(releaseDir);
|
|
580
583
|
const protectedBefore = new Set(selected ? [selected.name] : []);
|
|
581
584
|
if (selectRequested && requestedExists) protectedBefore.add(releaseName);
|
|
@@ -33849,15 +33849,18 @@ function hasSafeRuntimeLayout(paths, selected) {
|
|
|
33849
33849
|
(relativePath) => privateFile(join11(selected.dir, relativePath), DATA_FILE_MODE)
|
|
33850
33850
|
);
|
|
33851
33851
|
}
|
|
33852
|
-
function
|
|
33852
|
+
function sameNodeExecutable(recorded, desired) {
|
|
33853
33853
|
try {
|
|
33854
|
-
if (!statSync2(
|
|
33855
|
-
accessSync(
|
|
33856
|
-
return realpathSync2(
|
|
33854
|
+
if (!statSync2(recorded).isFile()) return false;
|
|
33855
|
+
accessSync(recorded, constants2.X_OK);
|
|
33856
|
+
return realpathSync2(recorded) === realpathSync2(desired);
|
|
33857
33857
|
} catch {
|
|
33858
33858
|
return false;
|
|
33859
33859
|
}
|
|
33860
33860
|
}
|
|
33861
|
+
function recordedNodeMatchesCurrentProcess(nodePath) {
|
|
33862
|
+
return sameNodeExecutable(nodePath, process.execPath);
|
|
33863
|
+
}
|
|
33861
33864
|
function inspectHookRuntime(options = {}) {
|
|
33862
33865
|
let paths;
|
|
33863
33866
|
try {
|
|
@@ -33984,7 +33987,7 @@ function stageHookRuntime(options = {}) {
|
|
|
33984
33987
|
if (precedence === void 0) {
|
|
33985
33988
|
throw new Error("cannot stage hook runtime: selected release version is malformed");
|
|
33986
33989
|
}
|
|
33987
|
-
const selectRequested = !selected || precedence < 0;
|
|
33990
|
+
const selectRequested = !selected || precedence < 0 || precedence === 0 && !sameNodeExecutable(selected.manifest.nodePath, nodePath);
|
|
33988
33991
|
const requestedExists = existsSync5(releaseDir);
|
|
33989
33992
|
const protectedBefore = new Set(selected ? [selected.name] : []);
|
|
33990
33993
|
if (selectRequested && requestedExists) protectedBefore.add(releaseName);
|
|
@@ -43217,16 +43220,10 @@ function cleanSandbox(run) {
|
|
|
43217
43220
|
}
|
|
43218
43221
|
|
|
43219
43222
|
// src/commands/demo.ts
|
|
43220
|
-
var intro = "SIMULATED TOUR \
|
|
43221
|
-
var handoff = "Sample files removed. Next:
|
|
43222
|
-
var captureNotice = "Passive
|
|
43223
|
-
var completionReceipt = [
|
|
43224
|
-
"Extracted a Decision with supporting evidence",
|
|
43225
|
-
"Adopted a Decision with your confirmation",
|
|
43226
|
-
"Surfaced a warning and allowed the edit",
|
|
43227
|
-
"Refused a conflicting write",
|
|
43228
|
-
"Applied the compliant implementation"
|
|
43229
|
-
];
|
|
43223
|
+
var intro = "SIMULATED TOUR \xB7 fictional Decisions \xB7 scripted verdicts";
|
|
43224
|
+
var handoff = "Sample files removed. Next: propose one real Decision for your approval.";
|
|
43225
|
+
var captureNotice = "Passive capture stays off in this session, including resumes.\nStart a new session to resume capture.";
|
|
43226
|
+
var completionReceipt = ["Extracted", "Adopted", "Warned", "Blocked", "Corrected"];
|
|
43230
43227
|
function resultFor2(run) {
|
|
43231
43228
|
const action = run.stage === "prepared" ? "start" : run.stage === "proposal" ? "confirm" : "resolve";
|
|
43232
43229
|
const done = run.stage === "completed" || run.stage === "skipped";
|
|
@@ -43266,46 +43263,57 @@ function consumeAcknowledgment(run, action, choice) {
|
|
|
43266
43263
|
return false;
|
|
43267
43264
|
}
|
|
43268
43265
|
}
|
|
43269
|
-
function narrateDecision(index) {
|
|
43266
|
+
function narrateDecision(index, details) {
|
|
43270
43267
|
const item = SAMPLE_DECISIONS[index];
|
|
43271
|
-
const status = index === 1 ? "proposed
|
|
43268
|
+
const status = index === 1 ? "proposed" : item.stage;
|
|
43272
43269
|
const source = index === 1 ? "Fictional authoring proposal" : item.source;
|
|
43273
43270
|
process.stderr.write(
|
|
43274
|
-
`
|
|
43275
|
-
|
|
43276
|
-
|
|
43277
|
-
|
|
43278
|
-
Rationale: ${item.rationale}
|
|
43279
|
-
Scope: ${item.files.join(", ")}
|
|
43280
|
-
Alternatives rejected: ${item.alternativesRejected.join("; ")}
|
|
43271
|
+
`${bold(`Decision [${status}]`)}
|
|
43272
|
+
${item.decision}
|
|
43273
|
+
Why: ${item.rationale}
|
|
43274
|
+
${index === 0 ? "Demo scope" : "File"}: ${item.files.join(", ")}
|
|
43281
43275
|
`
|
|
43282
43276
|
);
|
|
43283
|
-
if (
|
|
43284
|
-
const extracted = SAMPLE_DECISIONS[0];
|
|
43277
|
+
if (details) {
|
|
43285
43278
|
process.stderr.write(
|
|
43286
|
-
`Source
|
|
43287
|
-
|
|
43288
|
-
Scope basis: ${extracted.scopeBasis}
|
|
43279
|
+
`Source: ${source}
|
|
43280
|
+
Alternatives rejected: ${item.alternativesRejected.join("; ")}
|
|
43289
43281
|
`
|
|
43290
43282
|
);
|
|
43283
|
+
if (index === 0) process.stderr.write(`Scope basis: ${SAMPLE_DECISIONS[0].scopeBasis}
|
|
43284
|
+
`);
|
|
43285
|
+
}
|
|
43286
|
+
}
|
|
43287
|
+
function narrateDiff(file, before, after) {
|
|
43288
|
+
process.stderr.write(`${bold(file)}
|
|
43289
|
+
`);
|
|
43290
|
+
for (const part of diffLines(before, after)) {
|
|
43291
|
+
const prefix = part.added ? "+" : part.removed ? "-" : " ";
|
|
43292
|
+
const lines = part.value.endsWith("\n") ? part.value.slice(0, -1) : part.value;
|
|
43293
|
+
for (const line of lines.split("\n")) {
|
|
43294
|
+
const text = `${prefix} ${line}
|
|
43295
|
+
`;
|
|
43296
|
+
process.stderr.write(
|
|
43297
|
+
part.added ? color(text, "green") : part.removed ? color(text, "red") : text
|
|
43298
|
+
);
|
|
43299
|
+
}
|
|
43291
43300
|
}
|
|
43292
43301
|
}
|
|
43293
|
-
function narrateBlockedAttempt(unchanged) {
|
|
43302
|
+
function narrateBlockedAttempt(unchanged, details) {
|
|
43294
43303
|
process.stderr.write(`
|
|
43295
|
-
${bold(color("BLOCKED \u2014 file unchanged
|
|
43304
|
+
${bold(color("\xD7 BLOCKED \u2014 file unchanged", "red"))}
|
|
43296
43305
|
`);
|
|
43297
43306
|
process.stderr.write(
|
|
43298
|
-
|
|
43299
|
-
|
|
43300
|
-
|
|
43301
|
-
Outcome: this scenario refuses the proposed write.
|
|
43307
|
+
`${SAMPLE_DECISIONS[1].decision} [adopted]
|
|
43308
|
+
localStorage.setItem(\u2026) \u2500\u2500\xD7\u2500\u2500\u2192 orders.ts
|
|
43309
|
+
Bypasses repository validation.
|
|
43302
43310
|
`
|
|
43303
43311
|
);
|
|
43304
|
-
process.stderr.write(
|
|
43312
|
+
if (details) process.stderr.write(`Refused proposal:
|
|
43313
|
+
${BLOCKED_EDIT}`);
|
|
43305
43314
|
process.stderr.write(
|
|
43306
|
-
|
|
43307
|
-
${unchanged}
|
|
43308
|
-
Next: save through orders.save(...) to preserve repository validation.
|
|
43315
|
+
`${bold("orders.ts \xB7 before = after")}
|
|
43316
|
+
${unchanged}Next: shared repository \u2192 orders.save(order)
|
|
43309
43317
|
`
|
|
43310
43318
|
);
|
|
43311
43319
|
}
|
|
@@ -43313,20 +43321,20 @@ function narrateCompletion(run) {
|
|
|
43313
43321
|
process.stderr.write(`
|
|
43314
43322
|
${bold(color("WALKTHROUGH COMPLETE \u2014 simulated", "green"))}
|
|
43315
43323
|
`);
|
|
43316
|
-
process.stderr.write(`${completionReceipt.map((item) => `\u2713 ${item}`).join("\
|
|
43324
|
+
process.stderr.write(`${completionReceipt.map((item) => `\u2713 ${item}`).join(" \xB7 ")}
|
|
43317
43325
|
`);
|
|
43318
43326
|
process.stderr.write(`${handoff}
|
|
43319
43327
|
${run.terminal ? "" : `${captureNotice}
|
|
43320
43328
|
`}`);
|
|
43321
43329
|
}
|
|
43322
|
-
function advanceDemo(id, action, choice) {
|
|
43330
|
+
function advanceDemo(id, action, choice, details = false) {
|
|
43323
43331
|
return lockRun(id, (run) => {
|
|
43324
43332
|
if (action === "skip") {
|
|
43325
43333
|
cleanSandbox(run);
|
|
43326
43334
|
run.stage = "skipped";
|
|
43327
43335
|
saveRun(run);
|
|
43328
43336
|
finishOnboarding("skipped");
|
|
43329
|
-
process.stderr.write(`[prim] ${handoff}
|
|
43337
|
+
process.stderr.write(`[prim] Tour skipped. ${handoff}
|
|
43330
43338
|
`);
|
|
43331
43339
|
if (run.binding) process.stderr.write(`${captureNotice}
|
|
43332
43340
|
`);
|
|
@@ -43350,8 +43358,6 @@ function advanceDemo(id, action, choice) {
|
|
|
43350
43358
|
throw new Error("confirm the sample Decision before resolving");
|
|
43351
43359
|
}
|
|
43352
43360
|
try {
|
|
43353
|
-
process.stderr.write(`${bold(intro)}
|
|
43354
|
-
`);
|
|
43355
43361
|
if (!run.terminal && action === "start") process.stderr.write(`${captureNotice}
|
|
43356
43362
|
`);
|
|
43357
43363
|
if (run.stage === "completed") {
|
|
@@ -43366,29 +43372,41 @@ function advanceDemo(id, action, choice) {
|
|
|
43366
43372
|
saveRun(run);
|
|
43367
43373
|
}
|
|
43368
43374
|
if (run.stage === "proposal") {
|
|
43375
|
+
process.stderr.write(`${bold("Add order saving")}
|
|
43376
|
+
${intro}
|
|
43377
|
+
`);
|
|
43369
43378
|
process.stderr.write(
|
|
43370
43379
|
`
|
|
43371
|
-
${bold("
|
|
43372
|
-
|
|
43373
|
-
|
|
43380
|
+
${bold("1/4 \xB7 Extract")}
|
|
43381
|
+
Team conversation
|
|
43382
|
+
\u201C${SAMPLE_DECISIONS[0].evidence[0]}\u201D
|
|
43383
|
+
\u2193 scripted extraction
|
|
43374
43384
|
`
|
|
43375
43385
|
);
|
|
43376
|
-
process.stderr.write(
|
|
43377
|
-
|
|
43386
|
+
process.stderr.write(`${bold(color("\u2713 DECISION EXTRACTED", "green"))}
|
|
43387
|
+
`);
|
|
43388
|
+
narrateDecision(0, details);
|
|
43389
|
+
if (details) process.stderr.write(`
|
|
43390
|
+
Full source:
|
|
43378
43391
|
${SAMPLE_NOTE}
|
|
43379
43392
|
`);
|
|
43380
43393
|
process.stderr.write(`
|
|
43381
|
-
${bold(
|
|
43394
|
+
${bold("2/4 \xB7 Adopt")}
|
|
43382
43395
|
`);
|
|
43383
|
-
narrateDecision(
|
|
43384
|
-
process.stderr.write("
|
|
43385
|
-
process.stderr.write("\nNow explicitly author another sample Decision:\n");
|
|
43386
|
-
narrateDecision(1);
|
|
43387
|
-
process.stderr.write("Confirm this fictional Decision to adopt it, or skip the tour.\n");
|
|
43396
|
+
narrateDecision(1, details);
|
|
43397
|
+
process.stderr.write("Proposed \u2500\u2500 your approval \u2500\u2500\u2192 Adopted\n");
|
|
43388
43398
|
}
|
|
43389
43399
|
return {
|
|
43390
43400
|
...resultFor2(run),
|
|
43391
|
-
decisions: SAMPLE_DECISIONS.slice(0, run.stage === "proposal" ? 1 : 2)
|
|
43401
|
+
decisions: SAMPLE_DECISIONS.slice(0, run.stage === "proposal" ? 1 : 2),
|
|
43402
|
+
...run.stage === "proposal" ? {
|
|
43403
|
+
sourceNote: SAMPLE_NOTE,
|
|
43404
|
+
proposal: {
|
|
43405
|
+
...SAMPLE_DECISIONS[1],
|
|
43406
|
+
stage: "proposed",
|
|
43407
|
+
source: "Fictional authoring proposal"
|
|
43408
|
+
}
|
|
43409
|
+
} : {}
|
|
43392
43410
|
};
|
|
43393
43411
|
}
|
|
43394
43412
|
if (action === "confirm") {
|
|
@@ -43400,33 +43418,29 @@ ${bold(color("DECISION EXTRACTED \u2014 simulated", "green"))}
|
|
|
43400
43418
|
saveRun(run);
|
|
43401
43419
|
process.stderr.write(
|
|
43402
43420
|
`
|
|
43403
|
-
${bold(color("SAMPLE DECISION ADOPTED
|
|
43404
|
-
|
|
43405
|
-
Your confirmation changed this proposal into an adopted sample Decision.
|
|
43421
|
+
${bold(color("\u2713 SAMPLE DECISION ADOPTED", "green"))}
|
|
43422
|
+
Proposed \u2192 Adopted
|
|
43406
43423
|
`
|
|
43407
43424
|
);
|
|
43408
43425
|
}
|
|
43409
43426
|
const after2 = readSample(run, "service.ts");
|
|
43410
43427
|
const unchanged = readSample(run, "orders.ts");
|
|
43411
43428
|
process.stderr.write(`
|
|
43412
|
-
${bold(
|
|
43429
|
+
${bold("3/4 \xB7 Protect \xB7 simulated")}
|
|
43430
|
+
`);
|
|
43431
|
+
process.stderr.write(`${bold(color("! WARNING \u2014 edit allowed", "yellow"))}
|
|
43413
43432
|
`);
|
|
43414
43433
|
process.stderr.write(
|
|
43415
|
-
|
|
43416
|
-
|
|
43417
|
-
Conflict: direct fetch bypasses consistent retries and request tracing.
|
|
43418
|
-
Outcome: this scenario surfaces the conflict and allows the edit.
|
|
43419
|
-
`
|
|
43420
|
-
);
|
|
43421
|
-
process.stderr.write(createPatch("service.ts", before2, after2));
|
|
43422
|
-
process.stderr.write(
|
|
43423
|
-
`Proof: service.ts ${before2 === after2 ? "already matches the shared client" : "changed, as shown above"}.
|
|
43424
|
-
Next: restore the shared HTTP client for consistent retries and tracing.
|
|
43434
|
+
`${SAMPLE_DECISIONS[0].decision} [provisional]
|
|
43435
|
+
Bypasses shared retries and tracing.
|
|
43425
43436
|
`
|
|
43426
43437
|
);
|
|
43427
|
-
|
|
43438
|
+
narrateDiff("service.ts \xB7 changed", before2, after2);
|
|
43439
|
+
narrateBlockedAttempt(unchanged, details);
|
|
43440
|
+
if (!run.terminal)
|
|
43441
|
+
process.stderr.write("\nChoose: shared repository \xB7 retry direct storage\n");
|
|
43428
43442
|
process.stderr.write(
|
|
43429
|
-
"\
|
|
43443
|
+
"\nScripted verdicts. Live gates vary; Claude may ask where other agents block.\n"
|
|
43430
43444
|
);
|
|
43431
43445
|
return {
|
|
43432
43446
|
...resultFor2(run),
|
|
@@ -43445,7 +43459,9 @@ Next: restore the shared HTTP client for consistent retries and tracing.
|
|
|
43445
43459
|
throw new Error("choose repository or local-storage");
|
|
43446
43460
|
if (choice === "local-storage") {
|
|
43447
43461
|
const unchanged = readSample(run, "orders.ts");
|
|
43448
|
-
|
|
43462
|
+
process.stderr.write(`${bold("3/4 \xB7 Retry \xB7 simulated")}
|
|
43463
|
+
`);
|
|
43464
|
+
narrateBlockedAttempt(unchanged, details);
|
|
43449
43465
|
return { ...resultFor2(run), evidence: { unchanged } };
|
|
43450
43466
|
}
|
|
43451
43467
|
const before = readSample(run, "service.ts");
|
|
@@ -43454,12 +43470,14 @@ Next: restore the shared HTTP client for consistent retries and tracing.
|
|
|
43454
43470
|
writeSample(run, "orders.ts", REPOSITORY_EDIT);
|
|
43455
43471
|
const after = readSample(run, "service.ts");
|
|
43456
43472
|
const orders = readSample(run, "orders.ts");
|
|
43457
|
-
process.stderr.write(
|
|
43458
|
-
|
|
43473
|
+
process.stderr.write(`
|
|
43474
|
+
${bold("4/4 \xB7 Correct \xB7 simulated")}
|
|
43475
|
+
`);
|
|
43476
|
+
narrateDiff("orders.ts", ordersBefore, orders);
|
|
43477
|
+
narrateDiff("service.ts", before, after);
|
|
43459
43478
|
process.stderr.write(
|
|
43460
|
-
`${bold(color("PASS \u2014
|
|
43461
|
-
|
|
43462
|
-
The requested change landed while preserving both sample Decisions.
|
|
43479
|
+
`${bold(color("\u2713 PASS \u2014 order saving added", "green"))}
|
|
43480
|
+
Both sample Decisions respected.
|
|
43463
43481
|
`
|
|
43464
43482
|
);
|
|
43465
43483
|
cleanSandbox(run);
|
|
@@ -43493,25 +43511,36 @@ function parseDemoAgent(value) {
|
|
|
43493
43511
|
return value;
|
|
43494
43512
|
throw new Error("expected --agent claude, codex, cursor, or hermes");
|
|
43495
43513
|
}
|
|
43496
|
-
function reportError(error) {
|
|
43514
|
+
function reportError(error, json = true) {
|
|
43497
43515
|
const message = error instanceof Error ? error.message : String(error);
|
|
43498
43516
|
process.stderr.write(`[prim] demo: ${message}
|
|
43499
43517
|
`);
|
|
43500
|
-
printJson({ simulated: true, stage: "error", message });
|
|
43518
|
+
if (json) printJson({ simulated: true, stage: "error", message });
|
|
43501
43519
|
process.exitCode = 1;
|
|
43502
43520
|
}
|
|
43503
43521
|
function registerDemoCommands(program3) {
|
|
43504
|
-
const demo = program3.command("demo").description("Try a fictional, local Decision and enforcement walkthrough").option("--agent <agent>", "calling agent; requires hook acknowledgment before samples").
|
|
43522
|
+
const demo = program3.command("demo").description("Try a fictional, local Decision and enforcement walkthrough").option("--agent <agent>", "calling agent; requires hook acknowledgment before samples").option(
|
|
43523
|
+
"--details",
|
|
43524
|
+
"show the full source and supporting detail in the interactive terminal tour"
|
|
43525
|
+
).action(async (options, command) => {
|
|
43526
|
+
let terminal = false;
|
|
43527
|
+
const output = (result) => {
|
|
43528
|
+
if (!terminal || !process.stdout.isTTY) printJson(result);
|
|
43529
|
+
};
|
|
43505
43530
|
try {
|
|
43506
43531
|
const agent = parseDemoAgent(options.agent);
|
|
43507
|
-
|
|
43532
|
+
terminal = !agent && !isNonInteractive(command.optsWithGlobals()) && Boolean(process.stdin.isTTY && process.stderr.isTTY) && !process.env.CLAUDECODE && !process.env.CODEX_THREAD_ID && !process.env.CURSOR_AGENT && !process.env.HERMES_INTERACTIVE;
|
|
43533
|
+
if (options.details && !terminal)
|
|
43534
|
+
throw new Error(
|
|
43535
|
+
"--details requires an interactive terminal; agents receive full detail in JSON"
|
|
43536
|
+
);
|
|
43508
43537
|
const recovery = pendingRuns().map(
|
|
43509
43538
|
(id) => lockRun(id, (run2) => ({ runId: id, skipAction: demoCommand(run2, "skip") }))
|
|
43510
43539
|
);
|
|
43511
43540
|
const run = prepareRun(agent, terminal);
|
|
43512
43541
|
if (!terminal) {
|
|
43513
43542
|
process.stderr.write(
|
|
43514
|
-
"[prim]
|
|
43543
|
+
"[prim] Tour ready. Run nextAction exactly, as a standalone command. Samples wait for trusted hooks.\n"
|
|
43515
43544
|
);
|
|
43516
43545
|
if (recovery.length)
|
|
43517
43546
|
process.stderr.write(
|
|
@@ -43520,19 +43549,19 @@ function registerDemoCommands(program3) {
|
|
|
43520
43549
|
printJson({ ...resultFor2(run), recoverableRuns: recovery });
|
|
43521
43550
|
return;
|
|
43522
43551
|
}
|
|
43523
|
-
advanceDemo(run.id, "start");
|
|
43524
|
-
if (!await askConfirmation("Adopt this
|
|
43525
|
-
|
|
43552
|
+
advanceDemo(run.id, "start", void 0, options.details);
|
|
43553
|
+
if (!await askConfirmation("Adopt this sample Decision?", process.stderr)) {
|
|
43554
|
+
output(advanceDemo(run.id, "skip"));
|
|
43526
43555
|
return;
|
|
43527
43556
|
}
|
|
43528
|
-
advanceDemo(run.id, "confirm");
|
|
43557
|
+
advanceDemo(run.id, "confirm", void 0, options.details);
|
|
43529
43558
|
if (await askConfirmation("Apply the shared repository correction?", process.stderr)) {
|
|
43530
|
-
|
|
43559
|
+
output(advanceDemo(run.id, "resolve", "repository", options.details));
|
|
43531
43560
|
} else {
|
|
43532
|
-
|
|
43561
|
+
output(advanceDemo(run.id, "skip"));
|
|
43533
43562
|
}
|
|
43534
43563
|
} catch (error) {
|
|
43535
|
-
reportError(error);
|
|
43564
|
+
reportError(error, !terminal || !process.stdout.isTTY);
|
|
43536
43565
|
}
|
|
43537
43566
|
});
|
|
43538
43567
|
for (const action of ["start", "confirm", "resolve", "skip"]) {
|
|
@@ -44,8 +44,8 @@ import {
|
|
|
44
44
|
parseAgent,
|
|
45
45
|
readHookStdin,
|
|
46
46
|
shouldSuppressImportedCursorHandler
|
|
47
|
-
} from "../chunk-
|
|
48
|
-
import "../chunk-
|
|
47
|
+
} from "../chunk-NH3VC7YO.js";
|
|
48
|
+
import "../chunk-PO5QAYD7.js";
|
|
49
49
|
import "../chunk-5LRKJTLA.js";
|
|
50
50
|
import {
|
|
51
51
|
currentBranch,
|
|
@@ -38,8 +38,8 @@ import {
|
|
|
38
38
|
parseAgent,
|
|
39
39
|
readHookStdin,
|
|
40
40
|
shouldSuppressImportedCursorHandler
|
|
41
|
-
} from "../chunk-
|
|
42
|
-
import "../chunk-
|
|
41
|
+
} from "../chunk-NH3VC7YO.js";
|
|
42
|
+
import "../chunk-PO5QAYD7.js";
|
|
43
43
|
import "../chunk-5LRKJTLA.js";
|
|
44
44
|
import {
|
|
45
45
|
canonicalGitRoot,
|
package/dist/hooks/prim-hook.js
CHANGED
|
@@ -52,8 +52,8 @@ import {
|
|
|
52
52
|
parseAgent,
|
|
53
53
|
readHookStdin,
|
|
54
54
|
shouldSuppressImportedCursorHandler
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-
|
|
55
|
+
} from "../chunk-NH3VC7YO.js";
|
|
56
|
+
import "../chunk-PO5QAYD7.js";
|
|
57
57
|
import "../chunk-5LRKJTLA.js";
|
|
58
58
|
import {
|
|
59
59
|
currentBranch,
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
parseAgent,
|
|
5
5
|
readHookStdin,
|
|
6
6
|
shouldSuppressImportedCursorHandler
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-NH3VC7YO.js";
|
|
8
|
+
import "../chunk-PO5QAYD7.js";
|
|
9
9
|
import {
|
|
10
10
|
daemonRequest
|
|
11
11
|
} from "../chunk-5LRKJTLA.js";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
kickDaemonEnsure,
|
|
8
8
|
refreshClaudePlugins,
|
|
9
9
|
warmBinCache
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-2EKPBZNA.js";
|
|
11
11
|
import {
|
|
12
12
|
buildHookOutput,
|
|
13
13
|
handoffHookOutput
|
|
@@ -42,10 +42,10 @@ import {
|
|
|
42
42
|
parseAgent,
|
|
43
43
|
readHookStdin,
|
|
44
44
|
shouldSuppressImportedCursorHandler
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-NH3VC7YO.js";
|
|
46
46
|
import {
|
|
47
47
|
MANAGED_GIT_HOOK_NAMES
|
|
48
|
-
} from "../chunk-
|
|
48
|
+
} from "../chunk-PO5QAYD7.js";
|
|
49
49
|
import {
|
|
50
50
|
daemonRequest
|
|
51
51
|
} from "../chunk-5LRKJTLA.js";
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
resolveRepositoryBinding,
|
|
20
20
|
uninstallGitHookAtPath,
|
|
21
21
|
uninstallProjectGitHook
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-2EKPBZNA.js";
|
|
23
23
|
import {
|
|
24
24
|
requireDurableIngestAcknowledgement
|
|
25
25
|
} from "./chunk-IDMLJ4TM.js";
|
|
@@ -138,7 +138,7 @@ import {
|
|
|
138
138
|
stableNodePath,
|
|
139
139
|
stageHookRuntime,
|
|
140
140
|
stripCommand
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-PO5QAYD7.js";
|
|
142
142
|
import {
|
|
143
143
|
daemonIsLive,
|
|
144
144
|
daemonRequest
|
|
@@ -6610,7 +6610,7 @@ function registerDecisionsCommands(program2) {
|
|
|
6610
6610
|
}
|
|
6611
6611
|
|
|
6612
6612
|
// src/commands/demo.ts
|
|
6613
|
-
import {
|
|
6613
|
+
import { diffLines } from "diff";
|
|
6614
6614
|
|
|
6615
6615
|
// src/demo/sandbox.ts
|
|
6616
6616
|
import {
|
|
@@ -6745,16 +6745,10 @@ function cleanSandbox(run) {
|
|
|
6745
6745
|
}
|
|
6746
6746
|
|
|
6747
6747
|
// src/commands/demo.ts
|
|
6748
|
-
var intro = "SIMULATED TOUR \
|
|
6749
|
-
var handoff = "Sample files removed. Next:
|
|
6750
|
-
var captureNotice = "Passive
|
|
6751
|
-
var completionReceipt = [
|
|
6752
|
-
"Extracted a Decision with supporting evidence",
|
|
6753
|
-
"Adopted a Decision with your confirmation",
|
|
6754
|
-
"Surfaced a warning and allowed the edit",
|
|
6755
|
-
"Refused a conflicting write",
|
|
6756
|
-
"Applied the compliant implementation"
|
|
6757
|
-
];
|
|
6748
|
+
var intro = "SIMULATED TOUR \xB7 fictional Decisions \xB7 scripted verdicts";
|
|
6749
|
+
var handoff = "Sample files removed. Next: propose one real Decision for your approval.";
|
|
6750
|
+
var captureNotice = "Passive capture stays off in this session, including resumes.\nStart a new session to resume capture.";
|
|
6751
|
+
var completionReceipt = ["Extracted", "Adopted", "Warned", "Blocked", "Corrected"];
|
|
6758
6752
|
function resultFor2(run) {
|
|
6759
6753
|
const action = run.stage === "prepared" ? "start" : run.stage === "proposal" ? "confirm" : "resolve";
|
|
6760
6754
|
const done = run.stage === "completed" || run.stage === "skipped";
|
|
@@ -6794,46 +6788,57 @@ function consumeAcknowledgment(run, action, choice) {
|
|
|
6794
6788
|
return false;
|
|
6795
6789
|
}
|
|
6796
6790
|
}
|
|
6797
|
-
function narrateDecision(index) {
|
|
6791
|
+
function narrateDecision(index, details) {
|
|
6798
6792
|
const item = SAMPLE_DECISIONS[index];
|
|
6799
|
-
const status = index === 1 ? "proposed
|
|
6793
|
+
const status = index === 1 ? "proposed" : item.stage;
|
|
6800
6794
|
const source = index === 1 ? "Fictional authoring proposal" : item.source;
|
|
6801
6795
|
process.stderr.write(
|
|
6802
|
-
`
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
Rationale: ${item.rationale}
|
|
6807
|
-
Scope: ${item.files.join(", ")}
|
|
6808
|
-
Alternatives rejected: ${item.alternativesRejected.join("; ")}
|
|
6796
|
+
`${bold(`Decision [${status}]`)}
|
|
6797
|
+
${item.decision}
|
|
6798
|
+
Why: ${item.rationale}
|
|
6799
|
+
${index === 0 ? "Demo scope" : "File"}: ${item.files.join(", ")}
|
|
6809
6800
|
`
|
|
6810
6801
|
);
|
|
6811
|
-
if (
|
|
6812
|
-
const extracted = SAMPLE_DECISIONS[0];
|
|
6802
|
+
if (details) {
|
|
6813
6803
|
process.stderr.write(
|
|
6814
|
-
`Source
|
|
6815
|
-
|
|
6816
|
-
Scope basis: ${extracted.scopeBasis}
|
|
6804
|
+
`Source: ${source}
|
|
6805
|
+
Alternatives rejected: ${item.alternativesRejected.join("; ")}
|
|
6817
6806
|
`
|
|
6818
6807
|
);
|
|
6808
|
+
if (index === 0) process.stderr.write(`Scope basis: ${SAMPLE_DECISIONS[0].scopeBasis}
|
|
6809
|
+
`);
|
|
6819
6810
|
}
|
|
6820
6811
|
}
|
|
6821
|
-
function
|
|
6812
|
+
function narrateDiff(file, before, after) {
|
|
6813
|
+
process.stderr.write(`${bold(file)}
|
|
6814
|
+
`);
|
|
6815
|
+
for (const part of diffLines(before, after)) {
|
|
6816
|
+
const prefix = part.added ? "+" : part.removed ? "-" : " ";
|
|
6817
|
+
const lines = part.value.endsWith("\n") ? part.value.slice(0, -1) : part.value;
|
|
6818
|
+
for (const line of lines.split("\n")) {
|
|
6819
|
+
const text = `${prefix} ${line}
|
|
6820
|
+
`;
|
|
6821
|
+
process.stderr.write(
|
|
6822
|
+
part.added ? color(text, "green") : part.removed ? color(text, "red") : text
|
|
6823
|
+
);
|
|
6824
|
+
}
|
|
6825
|
+
}
|
|
6826
|
+
}
|
|
6827
|
+
function narrateBlockedAttempt(unchanged, details) {
|
|
6822
6828
|
process.stderr.write(`
|
|
6823
|
-
${bold(color("BLOCKED \u2014 file unchanged
|
|
6829
|
+
${bold(color("\xD7 BLOCKED \u2014 file unchanged", "red"))}
|
|
6824
6830
|
`);
|
|
6825
6831
|
process.stderr.write(
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
Outcome: this scenario refuses the proposed write.
|
|
6832
|
+
`${SAMPLE_DECISIONS[1].decision} [adopted]
|
|
6833
|
+
localStorage.setItem(\u2026) \u2500\u2500\xD7\u2500\u2500\u2192 orders.ts
|
|
6834
|
+
Bypasses repository validation.
|
|
6830
6835
|
`
|
|
6831
6836
|
);
|
|
6832
|
-
process.stderr.write(
|
|
6837
|
+
if (details) process.stderr.write(`Refused proposal:
|
|
6838
|
+
${BLOCKED_EDIT}`);
|
|
6833
6839
|
process.stderr.write(
|
|
6834
|
-
|
|
6835
|
-
${unchanged}
|
|
6836
|
-
Next: save through orders.save(...) to preserve repository validation.
|
|
6840
|
+
`${bold("orders.ts \xB7 before = after")}
|
|
6841
|
+
${unchanged}Next: shared repository \u2192 orders.save(order)
|
|
6837
6842
|
`
|
|
6838
6843
|
);
|
|
6839
6844
|
}
|
|
@@ -6841,20 +6846,20 @@ function narrateCompletion(run) {
|
|
|
6841
6846
|
process.stderr.write(`
|
|
6842
6847
|
${bold(color("WALKTHROUGH COMPLETE \u2014 simulated", "green"))}
|
|
6843
6848
|
`);
|
|
6844
|
-
process.stderr.write(`${completionReceipt.map((item) => `\u2713 ${item}`).join("\
|
|
6849
|
+
process.stderr.write(`${completionReceipt.map((item) => `\u2713 ${item}`).join(" \xB7 ")}
|
|
6845
6850
|
`);
|
|
6846
6851
|
process.stderr.write(`${handoff}
|
|
6847
6852
|
${run.terminal ? "" : `${captureNotice}
|
|
6848
6853
|
`}`);
|
|
6849
6854
|
}
|
|
6850
|
-
function advanceDemo(id, action, choice) {
|
|
6855
|
+
function advanceDemo(id, action, choice, details = false) {
|
|
6851
6856
|
return lockRun(id, (run) => {
|
|
6852
6857
|
if (action === "skip") {
|
|
6853
6858
|
cleanSandbox(run);
|
|
6854
6859
|
run.stage = "skipped";
|
|
6855
6860
|
saveRun(run);
|
|
6856
6861
|
finishOnboarding("skipped");
|
|
6857
|
-
process.stderr.write(`[prim] ${handoff}
|
|
6862
|
+
process.stderr.write(`[prim] Tour skipped. ${handoff}
|
|
6858
6863
|
`);
|
|
6859
6864
|
if (run.binding) process.stderr.write(`${captureNotice}
|
|
6860
6865
|
`);
|
|
@@ -6878,8 +6883,6 @@ function advanceDemo(id, action, choice) {
|
|
|
6878
6883
|
throw new Error("confirm the sample Decision before resolving");
|
|
6879
6884
|
}
|
|
6880
6885
|
try {
|
|
6881
|
-
process.stderr.write(`${bold(intro)}
|
|
6882
|
-
`);
|
|
6883
6886
|
if (!run.terminal && action === "start") process.stderr.write(`${captureNotice}
|
|
6884
6887
|
`);
|
|
6885
6888
|
if (run.stage === "completed") {
|
|
@@ -6894,29 +6897,41 @@ function advanceDemo(id, action, choice) {
|
|
|
6894
6897
|
saveRun(run);
|
|
6895
6898
|
}
|
|
6896
6899
|
if (run.stage === "proposal") {
|
|
6900
|
+
process.stderr.write(`${bold("Add order saving")}
|
|
6901
|
+
${intro}
|
|
6902
|
+
`);
|
|
6897
6903
|
process.stderr.write(
|
|
6898
6904
|
`
|
|
6899
|
-
${bold("
|
|
6900
|
-
|
|
6901
|
-
|
|
6905
|
+
${bold("1/4 \xB7 Extract")}
|
|
6906
|
+
Team conversation
|
|
6907
|
+
\u201C${SAMPLE_DECISIONS[0].evidence[0]}\u201D
|
|
6908
|
+
\u2193 scripted extraction
|
|
6902
6909
|
`
|
|
6903
6910
|
);
|
|
6904
|
-
process.stderr.write(
|
|
6905
|
-
|
|
6911
|
+
process.stderr.write(`${bold(color("\u2713 DECISION EXTRACTED", "green"))}
|
|
6912
|
+
`);
|
|
6913
|
+
narrateDecision(0, details);
|
|
6914
|
+
if (details) process.stderr.write(`
|
|
6915
|
+
Full source:
|
|
6906
6916
|
${SAMPLE_NOTE}
|
|
6907
6917
|
`);
|
|
6908
6918
|
process.stderr.write(`
|
|
6909
|
-
${bold(
|
|
6919
|
+
${bold("2/4 \xB7 Adopt")}
|
|
6910
6920
|
`);
|
|
6911
|
-
narrateDecision(
|
|
6912
|
-
process.stderr.write("
|
|
6913
|
-
process.stderr.write("\nNow explicitly author another sample Decision:\n");
|
|
6914
|
-
narrateDecision(1);
|
|
6915
|
-
process.stderr.write("Confirm this fictional Decision to adopt it, or skip the tour.\n");
|
|
6921
|
+
narrateDecision(1, details);
|
|
6922
|
+
process.stderr.write("Proposed \u2500\u2500 your approval \u2500\u2500\u2192 Adopted\n");
|
|
6916
6923
|
}
|
|
6917
6924
|
return {
|
|
6918
6925
|
...resultFor2(run),
|
|
6919
|
-
decisions: SAMPLE_DECISIONS.slice(0, run.stage === "proposal" ? 1 : 2)
|
|
6926
|
+
decisions: SAMPLE_DECISIONS.slice(0, run.stage === "proposal" ? 1 : 2),
|
|
6927
|
+
...run.stage === "proposal" ? {
|
|
6928
|
+
sourceNote: SAMPLE_NOTE,
|
|
6929
|
+
proposal: {
|
|
6930
|
+
...SAMPLE_DECISIONS[1],
|
|
6931
|
+
stage: "proposed",
|
|
6932
|
+
source: "Fictional authoring proposal"
|
|
6933
|
+
}
|
|
6934
|
+
} : {}
|
|
6920
6935
|
};
|
|
6921
6936
|
}
|
|
6922
6937
|
if (action === "confirm") {
|
|
@@ -6928,33 +6943,29 @@ ${bold(color("DECISION EXTRACTED \u2014 simulated", "green"))}
|
|
|
6928
6943
|
saveRun(run);
|
|
6929
6944
|
process.stderr.write(
|
|
6930
6945
|
`
|
|
6931
|
-
${bold(color("SAMPLE DECISION ADOPTED
|
|
6932
|
-
|
|
6933
|
-
Your confirmation changed this proposal into an adopted sample Decision.
|
|
6946
|
+
${bold(color("\u2713 SAMPLE DECISION ADOPTED", "green"))}
|
|
6947
|
+
Proposed \u2192 Adopted
|
|
6934
6948
|
`
|
|
6935
6949
|
);
|
|
6936
6950
|
}
|
|
6937
6951
|
const after2 = readSample(run, "service.ts");
|
|
6938
6952
|
const unchanged = readSample(run, "orders.ts");
|
|
6939
6953
|
process.stderr.write(`
|
|
6940
|
-
${bold(
|
|
6954
|
+
${bold("3/4 \xB7 Protect \xB7 simulated")}
|
|
6955
|
+
`);
|
|
6956
|
+
process.stderr.write(`${bold(color("! WARNING \u2014 edit allowed", "yellow"))}
|
|
6941
6957
|
`);
|
|
6942
6958
|
process.stderr.write(
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
Conflict: direct fetch bypasses consistent retries and request tracing.
|
|
6946
|
-
Outcome: this scenario surfaces the conflict and allows the edit.
|
|
6947
|
-
`
|
|
6948
|
-
);
|
|
6949
|
-
process.stderr.write(createPatch("service.ts", before2, after2));
|
|
6950
|
-
process.stderr.write(
|
|
6951
|
-
`Proof: service.ts ${before2 === after2 ? "already matches the shared client" : "changed, as shown above"}.
|
|
6952
|
-
Next: restore the shared HTTP client for consistent retries and tracing.
|
|
6959
|
+
`${SAMPLE_DECISIONS[0].decision} [provisional]
|
|
6960
|
+
Bypasses shared retries and tracing.
|
|
6953
6961
|
`
|
|
6954
6962
|
);
|
|
6955
|
-
|
|
6963
|
+
narrateDiff("service.ts \xB7 changed", before2, after2);
|
|
6964
|
+
narrateBlockedAttempt(unchanged, details);
|
|
6965
|
+
if (!run.terminal)
|
|
6966
|
+
process.stderr.write("\nChoose: shared repository \xB7 retry direct storage\n");
|
|
6956
6967
|
process.stderr.write(
|
|
6957
|
-
"\
|
|
6968
|
+
"\nScripted verdicts. Live gates vary; Claude may ask where other agents block.\n"
|
|
6958
6969
|
);
|
|
6959
6970
|
return {
|
|
6960
6971
|
...resultFor2(run),
|
|
@@ -6973,7 +6984,9 @@ Next: restore the shared HTTP client for consistent retries and tracing.
|
|
|
6973
6984
|
throw new Error("choose repository or local-storage");
|
|
6974
6985
|
if (choice === "local-storage") {
|
|
6975
6986
|
const unchanged = readSample(run, "orders.ts");
|
|
6976
|
-
|
|
6987
|
+
process.stderr.write(`${bold("3/4 \xB7 Retry \xB7 simulated")}
|
|
6988
|
+
`);
|
|
6989
|
+
narrateBlockedAttempt(unchanged, details);
|
|
6977
6990
|
return { ...resultFor2(run), evidence: { unchanged } };
|
|
6978
6991
|
}
|
|
6979
6992
|
const before = readSample(run, "service.ts");
|
|
@@ -6982,12 +6995,14 @@ Next: restore the shared HTTP client for consistent retries and tracing.
|
|
|
6982
6995
|
writeSample(run, "orders.ts", REPOSITORY_EDIT);
|
|
6983
6996
|
const after = readSample(run, "service.ts");
|
|
6984
6997
|
const orders = readSample(run, "orders.ts");
|
|
6985
|
-
process.stderr.write(
|
|
6986
|
-
|
|
6998
|
+
process.stderr.write(`
|
|
6999
|
+
${bold("4/4 \xB7 Correct \xB7 simulated")}
|
|
7000
|
+
`);
|
|
7001
|
+
narrateDiff("orders.ts", ordersBefore, orders);
|
|
7002
|
+
narrateDiff("service.ts", before, after);
|
|
6987
7003
|
process.stderr.write(
|
|
6988
|
-
`${bold(color("PASS \u2014
|
|
6989
|
-
|
|
6990
|
-
The requested change landed while preserving both sample Decisions.
|
|
7004
|
+
`${bold(color("\u2713 PASS \u2014 order saving added", "green"))}
|
|
7005
|
+
Both sample Decisions respected.
|
|
6991
7006
|
`
|
|
6992
7007
|
);
|
|
6993
7008
|
cleanSandbox(run);
|
|
@@ -7021,25 +7036,36 @@ function parseDemoAgent(value) {
|
|
|
7021
7036
|
return value;
|
|
7022
7037
|
throw new Error("expected --agent claude, codex, cursor, or hermes");
|
|
7023
7038
|
}
|
|
7024
|
-
function reportError(error) {
|
|
7039
|
+
function reportError(error, json = true) {
|
|
7025
7040
|
const message = error instanceof Error ? error.message : String(error);
|
|
7026
7041
|
process.stderr.write(`[prim] demo: ${message}
|
|
7027
7042
|
`);
|
|
7028
|
-
printJson({ simulated: true, stage: "error", message });
|
|
7043
|
+
if (json) printJson({ simulated: true, stage: "error", message });
|
|
7029
7044
|
process.exitCode = 1;
|
|
7030
7045
|
}
|
|
7031
7046
|
function registerDemoCommands(program2) {
|
|
7032
|
-
const demo = program2.command("demo").description("Try a fictional, local Decision and enforcement walkthrough").option("--agent <agent>", "calling agent; requires hook acknowledgment before samples").
|
|
7047
|
+
const demo = program2.command("demo").description("Try a fictional, local Decision and enforcement walkthrough").option("--agent <agent>", "calling agent; requires hook acknowledgment before samples").option(
|
|
7048
|
+
"--details",
|
|
7049
|
+
"show the full source and supporting detail in the interactive terminal tour"
|
|
7050
|
+
).action(async (options, command) => {
|
|
7051
|
+
let terminal = false;
|
|
7052
|
+
const output = (result) => {
|
|
7053
|
+
if (!terminal || !process.stdout.isTTY) printJson(result);
|
|
7054
|
+
};
|
|
7033
7055
|
try {
|
|
7034
7056
|
const agent = parseDemoAgent(options.agent);
|
|
7035
|
-
|
|
7057
|
+
terminal = !agent && !isNonInteractive(command.optsWithGlobals()) && Boolean(process.stdin.isTTY && process.stderr.isTTY) && !process.env.CLAUDECODE && !process.env.CODEX_THREAD_ID && !process.env.CURSOR_AGENT && !process.env.HERMES_INTERACTIVE;
|
|
7058
|
+
if (options.details && !terminal)
|
|
7059
|
+
throw new Error(
|
|
7060
|
+
"--details requires an interactive terminal; agents receive full detail in JSON"
|
|
7061
|
+
);
|
|
7036
7062
|
const recovery = pendingRuns().map(
|
|
7037
7063
|
(id) => lockRun(id, (run2) => ({ runId: id, skipAction: demoCommand(run2, "skip") }))
|
|
7038
7064
|
);
|
|
7039
7065
|
const run = prepareRun(agent, terminal);
|
|
7040
7066
|
if (!terminal) {
|
|
7041
7067
|
process.stderr.write(
|
|
7042
|
-
"[prim]
|
|
7068
|
+
"[prim] Tour ready. Run nextAction exactly, as a standalone command. Samples wait for trusted hooks.\n"
|
|
7043
7069
|
);
|
|
7044
7070
|
if (recovery.length)
|
|
7045
7071
|
process.stderr.write(
|
|
@@ -7048,19 +7074,19 @@ function registerDemoCommands(program2) {
|
|
|
7048
7074
|
printJson({ ...resultFor2(run), recoverableRuns: recovery });
|
|
7049
7075
|
return;
|
|
7050
7076
|
}
|
|
7051
|
-
advanceDemo(run.id, "start");
|
|
7052
|
-
if (!await askConfirmation("Adopt this
|
|
7053
|
-
|
|
7077
|
+
advanceDemo(run.id, "start", void 0, options.details);
|
|
7078
|
+
if (!await askConfirmation("Adopt this sample Decision?", process.stderr)) {
|
|
7079
|
+
output(advanceDemo(run.id, "skip"));
|
|
7054
7080
|
return;
|
|
7055
7081
|
}
|
|
7056
|
-
advanceDemo(run.id, "confirm");
|
|
7082
|
+
advanceDemo(run.id, "confirm", void 0, options.details);
|
|
7057
7083
|
if (await askConfirmation("Apply the shared repository correction?", process.stderr)) {
|
|
7058
|
-
|
|
7084
|
+
output(advanceDemo(run.id, "resolve", "repository", options.details));
|
|
7059
7085
|
} else {
|
|
7060
|
-
|
|
7086
|
+
output(advanceDemo(run.id, "skip"));
|
|
7061
7087
|
}
|
|
7062
7088
|
} catch (error) {
|
|
7063
|
-
reportError(error);
|
|
7089
|
+
reportError(error, !terminal || !process.stdout.isTTY);
|
|
7064
7090
|
}
|
|
7065
7091
|
});
|
|
7066
7092
|
for (const action of ["start", "confirm", "resolve", "skip"]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primitive.ai/prim",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.105",
|
|
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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"pre-commit"
|
|
25
25
|
],
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": "
|
|
27
|
+
"node": "^22.23.4 || ^24.22.1 || ^26.12.1"
|
|
28
28
|
},
|
|
29
29
|
"packageManager": "pnpm@9.15.9",
|
|
30
30
|
"bin": {
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"@types/diff": "^5.2.0",
|
|
77
77
|
"@types/node": "^25.5.0",
|
|
78
78
|
"@types/update-notifier": "^6.0.8",
|
|
79
|
-
"@vitest/coverage-v8": "^
|
|
79
|
+
"@vitest/coverage-v8": "^4.1.12",
|
|
80
80
|
"ajv": "8.20.0",
|
|
81
81
|
"json-schema-to-typescript": "15.0.4",
|
|
82
82
|
"tsup": "^8.0.0",
|
|
83
83
|
"typescript": "^5.5.0",
|
|
84
|
-
"vitest": "^
|
|
84
|
+
"vitest": "^4.1.12"
|
|
85
85
|
}
|
|
86
86
|
}
|