@primitive.ai/prim 0.1.0-alpha.104 → 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 +4 -1
- package/SKILL.md +31 -22
- package/dist/hook-runtime/index.js +111 -85
- package/dist/index.js +112 -86
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,10 @@ The tour follows one order-saving task and ends with a receipt of the demonstrat
|
|
|
52
52
|
lifecycle, then offers one real project Decision for your individual approval.
|
|
53
53
|
Use `prim setup --skip-demo` to skip and remember that choice, or
|
|
54
54
|
`prim demo --agent <claude|codex|cursor|hermes>` to replay.
|
|
55
|
-
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.
|
|
56
59
|
|
|
57
60
|
The agent tour waits for trusted hooks before showing samples and excludes
|
|
58
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
|
|
@@ -43220,16 +43220,10 @@ function cleanSandbox(run) {
|
|
|
43220
43220
|
}
|
|
43221
43221
|
|
|
43222
43222
|
// src/commands/demo.ts
|
|
43223
|
-
var intro = "SIMULATED TOUR \
|
|
43224
|
-
var handoff = "Sample files removed. Next:
|
|
43225
|
-
var captureNotice = "Passive
|
|
43226
|
-
var completionReceipt = [
|
|
43227
|
-
"Extracted a Decision with supporting evidence",
|
|
43228
|
-
"Adopted a Decision with your confirmation",
|
|
43229
|
-
"Surfaced a warning and allowed the edit",
|
|
43230
|
-
"Refused a conflicting write",
|
|
43231
|
-
"Applied the compliant implementation"
|
|
43232
|
-
];
|
|
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"];
|
|
43233
43227
|
function resultFor2(run) {
|
|
43234
43228
|
const action = run.stage === "prepared" ? "start" : run.stage === "proposal" ? "confirm" : "resolve";
|
|
43235
43229
|
const done = run.stage === "completed" || run.stage === "skipped";
|
|
@@ -43269,46 +43263,57 @@ function consumeAcknowledgment(run, action, choice) {
|
|
|
43269
43263
|
return false;
|
|
43270
43264
|
}
|
|
43271
43265
|
}
|
|
43272
|
-
function narrateDecision(index) {
|
|
43266
|
+
function narrateDecision(index, details) {
|
|
43273
43267
|
const item = SAMPLE_DECISIONS[index];
|
|
43274
|
-
const status = index === 1 ? "proposed
|
|
43268
|
+
const status = index === 1 ? "proposed" : item.stage;
|
|
43275
43269
|
const source = index === 1 ? "Fictional authoring proposal" : item.source;
|
|
43276
43270
|
process.stderr.write(
|
|
43277
|
-
`
|
|
43278
|
-
|
|
43279
|
-
|
|
43280
|
-
|
|
43281
|
-
Rationale: ${item.rationale}
|
|
43282
|
-
Scope: ${item.files.join(", ")}
|
|
43283
|
-
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(", ")}
|
|
43284
43275
|
`
|
|
43285
43276
|
);
|
|
43286
|
-
if (
|
|
43287
|
-
const extracted = SAMPLE_DECISIONS[0];
|
|
43277
|
+
if (details) {
|
|
43288
43278
|
process.stderr.write(
|
|
43289
|
-
`Source
|
|
43290
|
-
|
|
43291
|
-
Scope basis: ${extracted.scopeBasis}
|
|
43279
|
+
`Source: ${source}
|
|
43280
|
+
Alternatives rejected: ${item.alternativesRejected.join("; ")}
|
|
43292
43281
|
`
|
|
43293
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
|
+
}
|
|
43294
43300
|
}
|
|
43295
43301
|
}
|
|
43296
|
-
function narrateBlockedAttempt(unchanged) {
|
|
43302
|
+
function narrateBlockedAttempt(unchanged, details) {
|
|
43297
43303
|
process.stderr.write(`
|
|
43298
|
-
${bold(color("BLOCKED \u2014 file unchanged
|
|
43304
|
+
${bold(color("\xD7 BLOCKED \u2014 file unchanged", "red"))}
|
|
43299
43305
|
`);
|
|
43300
43306
|
process.stderr.write(
|
|
43301
|
-
|
|
43302
|
-
|
|
43303
|
-
|
|
43304
|
-
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.
|
|
43305
43310
|
`
|
|
43306
43311
|
);
|
|
43307
|
-
process.stderr.write(
|
|
43312
|
+
if (details) process.stderr.write(`Refused proposal:
|
|
43313
|
+
${BLOCKED_EDIT}`);
|
|
43308
43314
|
process.stderr.write(
|
|
43309
|
-
|
|
43310
|
-
${unchanged}
|
|
43311
|
-
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)
|
|
43312
43317
|
`
|
|
43313
43318
|
);
|
|
43314
43319
|
}
|
|
@@ -43316,20 +43321,20 @@ function narrateCompletion(run) {
|
|
|
43316
43321
|
process.stderr.write(`
|
|
43317
43322
|
${bold(color("WALKTHROUGH COMPLETE \u2014 simulated", "green"))}
|
|
43318
43323
|
`);
|
|
43319
|
-
process.stderr.write(`${completionReceipt.map((item) => `\u2713 ${item}`).join("\
|
|
43324
|
+
process.stderr.write(`${completionReceipt.map((item) => `\u2713 ${item}`).join(" \xB7 ")}
|
|
43320
43325
|
`);
|
|
43321
43326
|
process.stderr.write(`${handoff}
|
|
43322
43327
|
${run.terminal ? "" : `${captureNotice}
|
|
43323
43328
|
`}`);
|
|
43324
43329
|
}
|
|
43325
|
-
function advanceDemo(id, action, choice) {
|
|
43330
|
+
function advanceDemo(id, action, choice, details = false) {
|
|
43326
43331
|
return lockRun(id, (run) => {
|
|
43327
43332
|
if (action === "skip") {
|
|
43328
43333
|
cleanSandbox(run);
|
|
43329
43334
|
run.stage = "skipped";
|
|
43330
43335
|
saveRun(run);
|
|
43331
43336
|
finishOnboarding("skipped");
|
|
43332
|
-
process.stderr.write(`[prim] ${handoff}
|
|
43337
|
+
process.stderr.write(`[prim] Tour skipped. ${handoff}
|
|
43333
43338
|
`);
|
|
43334
43339
|
if (run.binding) process.stderr.write(`${captureNotice}
|
|
43335
43340
|
`);
|
|
@@ -43353,8 +43358,6 @@ function advanceDemo(id, action, choice) {
|
|
|
43353
43358
|
throw new Error("confirm the sample Decision before resolving");
|
|
43354
43359
|
}
|
|
43355
43360
|
try {
|
|
43356
|
-
process.stderr.write(`${bold(intro)}
|
|
43357
|
-
`);
|
|
43358
43361
|
if (!run.terminal && action === "start") process.stderr.write(`${captureNotice}
|
|
43359
43362
|
`);
|
|
43360
43363
|
if (run.stage === "completed") {
|
|
@@ -43369,29 +43372,41 @@ function advanceDemo(id, action, choice) {
|
|
|
43369
43372
|
saveRun(run);
|
|
43370
43373
|
}
|
|
43371
43374
|
if (run.stage === "proposal") {
|
|
43375
|
+
process.stderr.write(`${bold("Add order saving")}
|
|
43376
|
+
${intro}
|
|
43377
|
+
`);
|
|
43372
43378
|
process.stderr.write(
|
|
43373
43379
|
`
|
|
43374
|
-
${bold("
|
|
43375
|
-
|
|
43376
|
-
|
|
43380
|
+
${bold("1/4 \xB7 Extract")}
|
|
43381
|
+
Team conversation
|
|
43382
|
+
\u201C${SAMPLE_DECISIONS[0].evidence[0]}\u201D
|
|
43383
|
+
\u2193 scripted extraction
|
|
43377
43384
|
`
|
|
43378
43385
|
);
|
|
43379
|
-
process.stderr.write(
|
|
43380
|
-
|
|
43386
|
+
process.stderr.write(`${bold(color("\u2713 DECISION EXTRACTED", "green"))}
|
|
43387
|
+
`);
|
|
43388
|
+
narrateDecision(0, details);
|
|
43389
|
+
if (details) process.stderr.write(`
|
|
43390
|
+
Full source:
|
|
43381
43391
|
${SAMPLE_NOTE}
|
|
43382
43392
|
`);
|
|
43383
43393
|
process.stderr.write(`
|
|
43384
|
-
${bold(
|
|
43394
|
+
${bold("2/4 \xB7 Adopt")}
|
|
43385
43395
|
`);
|
|
43386
|
-
narrateDecision(
|
|
43387
|
-
process.stderr.write("
|
|
43388
|
-
process.stderr.write("\nNow explicitly author another sample Decision:\n");
|
|
43389
|
-
narrateDecision(1);
|
|
43390
|
-
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");
|
|
43391
43398
|
}
|
|
43392
43399
|
return {
|
|
43393
43400
|
...resultFor2(run),
|
|
43394
|
-
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
|
+
} : {}
|
|
43395
43410
|
};
|
|
43396
43411
|
}
|
|
43397
43412
|
if (action === "confirm") {
|
|
@@ -43403,33 +43418,29 @@ ${bold(color("DECISION EXTRACTED \u2014 simulated", "green"))}
|
|
|
43403
43418
|
saveRun(run);
|
|
43404
43419
|
process.stderr.write(
|
|
43405
43420
|
`
|
|
43406
|
-
${bold(color("SAMPLE DECISION ADOPTED
|
|
43407
|
-
|
|
43408
|
-
Your confirmation changed this proposal into an adopted sample Decision.
|
|
43421
|
+
${bold(color("\u2713 SAMPLE DECISION ADOPTED", "green"))}
|
|
43422
|
+
Proposed \u2192 Adopted
|
|
43409
43423
|
`
|
|
43410
43424
|
);
|
|
43411
43425
|
}
|
|
43412
43426
|
const after2 = readSample(run, "service.ts");
|
|
43413
43427
|
const unchanged = readSample(run, "orders.ts");
|
|
43414
43428
|
process.stderr.write(`
|
|
43415
|
-
${bold(
|
|
43429
|
+
${bold("3/4 \xB7 Protect \xB7 simulated")}
|
|
43430
|
+
`);
|
|
43431
|
+
process.stderr.write(`${bold(color("! WARNING \u2014 edit allowed", "yellow"))}
|
|
43416
43432
|
`);
|
|
43417
43433
|
process.stderr.write(
|
|
43418
|
-
|
|
43419
|
-
|
|
43420
|
-
Conflict: direct fetch bypasses consistent retries and request tracing.
|
|
43421
|
-
Outcome: this scenario surfaces the conflict and allows the edit.
|
|
43422
|
-
`
|
|
43423
|
-
);
|
|
43424
|
-
process.stderr.write(createPatch("service.ts", before2, after2));
|
|
43425
|
-
process.stderr.write(
|
|
43426
|
-
`Proof: service.ts ${before2 === after2 ? "already matches the shared client" : "changed, as shown above"}.
|
|
43427
|
-
Next: restore the shared HTTP client for consistent retries and tracing.
|
|
43434
|
+
`${SAMPLE_DECISIONS[0].decision} [provisional]
|
|
43435
|
+
Bypasses shared retries and tracing.
|
|
43428
43436
|
`
|
|
43429
43437
|
);
|
|
43430
|
-
|
|
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");
|
|
43431
43442
|
process.stderr.write(
|
|
43432
|
-
"\
|
|
43443
|
+
"\nScripted verdicts. Live gates vary; Claude may ask where other agents block.\n"
|
|
43433
43444
|
);
|
|
43434
43445
|
return {
|
|
43435
43446
|
...resultFor2(run),
|
|
@@ -43448,7 +43459,9 @@ Next: restore the shared HTTP client for consistent retries and tracing.
|
|
|
43448
43459
|
throw new Error("choose repository or local-storage");
|
|
43449
43460
|
if (choice === "local-storage") {
|
|
43450
43461
|
const unchanged = readSample(run, "orders.ts");
|
|
43451
|
-
|
|
43462
|
+
process.stderr.write(`${bold("3/4 \xB7 Retry \xB7 simulated")}
|
|
43463
|
+
`);
|
|
43464
|
+
narrateBlockedAttempt(unchanged, details);
|
|
43452
43465
|
return { ...resultFor2(run), evidence: { unchanged } };
|
|
43453
43466
|
}
|
|
43454
43467
|
const before = readSample(run, "service.ts");
|
|
@@ -43457,12 +43470,14 @@ Next: restore the shared HTTP client for consistent retries and tracing.
|
|
|
43457
43470
|
writeSample(run, "orders.ts", REPOSITORY_EDIT);
|
|
43458
43471
|
const after = readSample(run, "service.ts");
|
|
43459
43472
|
const orders = readSample(run, "orders.ts");
|
|
43460
|
-
process.stderr.write(
|
|
43461
|
-
|
|
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);
|
|
43462
43478
|
process.stderr.write(
|
|
43463
|
-
`${bold(color("PASS \u2014
|
|
43464
|
-
|
|
43465
|
-
The requested change landed while preserving both sample Decisions.
|
|
43479
|
+
`${bold(color("\u2713 PASS \u2014 order saving added", "green"))}
|
|
43480
|
+
Both sample Decisions respected.
|
|
43466
43481
|
`
|
|
43467
43482
|
);
|
|
43468
43483
|
cleanSandbox(run);
|
|
@@ -43496,25 +43511,36 @@ function parseDemoAgent(value) {
|
|
|
43496
43511
|
return value;
|
|
43497
43512
|
throw new Error("expected --agent claude, codex, cursor, or hermes");
|
|
43498
43513
|
}
|
|
43499
|
-
function reportError(error) {
|
|
43514
|
+
function reportError(error, json = true) {
|
|
43500
43515
|
const message = error instanceof Error ? error.message : String(error);
|
|
43501
43516
|
process.stderr.write(`[prim] demo: ${message}
|
|
43502
43517
|
`);
|
|
43503
|
-
printJson({ simulated: true, stage: "error", message });
|
|
43518
|
+
if (json) printJson({ simulated: true, stage: "error", message });
|
|
43504
43519
|
process.exitCode = 1;
|
|
43505
43520
|
}
|
|
43506
43521
|
function registerDemoCommands(program3) {
|
|
43507
|
-
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
|
+
};
|
|
43508
43530
|
try {
|
|
43509
43531
|
const agent = parseDemoAgent(options.agent);
|
|
43510
|
-
|
|
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
|
+
);
|
|
43511
43537
|
const recovery = pendingRuns().map(
|
|
43512
43538
|
(id) => lockRun(id, (run2) => ({ runId: id, skipAction: demoCommand(run2, "skip") }))
|
|
43513
43539
|
);
|
|
43514
43540
|
const run = prepareRun(agent, terminal);
|
|
43515
43541
|
if (!terminal) {
|
|
43516
43542
|
process.stderr.write(
|
|
43517
|
-
"[prim]
|
|
43543
|
+
"[prim] Tour ready. Run nextAction exactly, as a standalone command. Samples wait for trusted hooks.\n"
|
|
43518
43544
|
);
|
|
43519
43545
|
if (recovery.length)
|
|
43520
43546
|
process.stderr.write(
|
|
@@ -43523,19 +43549,19 @@ function registerDemoCommands(program3) {
|
|
|
43523
43549
|
printJson({ ...resultFor2(run), recoverableRuns: recovery });
|
|
43524
43550
|
return;
|
|
43525
43551
|
}
|
|
43526
|
-
advanceDemo(run.id, "start");
|
|
43527
|
-
if (!await askConfirmation("Adopt this
|
|
43528
|
-
|
|
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"));
|
|
43529
43555
|
return;
|
|
43530
43556
|
}
|
|
43531
|
-
advanceDemo(run.id, "confirm");
|
|
43557
|
+
advanceDemo(run.id, "confirm", void 0, options.details);
|
|
43532
43558
|
if (await askConfirmation("Apply the shared repository correction?", process.stderr)) {
|
|
43533
|
-
|
|
43559
|
+
output(advanceDemo(run.id, "resolve", "repository", options.details));
|
|
43534
43560
|
} else {
|
|
43535
|
-
|
|
43561
|
+
output(advanceDemo(run.id, "skip"));
|
|
43536
43562
|
}
|
|
43537
43563
|
} catch (error) {
|
|
43538
|
-
reportError(error);
|
|
43564
|
+
reportError(error, !terminal || !process.stdout.isTTY);
|
|
43539
43565
|
}
|
|
43540
43566
|
});
|
|
43541
43567
|
for (const action of ["start", "confirm", "resolve", "skip"]) {
|
package/dist/index.js
CHANGED
|
@@ -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