joycraft 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -113,6 +113,7 @@ consideration ([decision D6](docs/context/decision-log.md)).
113
113
  ```text
114
114
  We keep a wiki in <where>. Link it from the context map, and keep it up to date
115
115
  each time a feature is archived.
116
+ Do not commit, publish, or ask me for API keys.
116
117
  ```
117
118
 
118
119
  ### Settings
@@ -120,9 +121,11 @@ each time a feature is archived.
120
121
  Joycraft works with no settings. To change one, say what you want:
121
122
 
122
123
  ```text
123
- Keep Joycraft's briefs and specs in working/features.
124
- Whenever a feature is archived, run our wiki sync script.
125
- The page docs/context/auction-rules.md describes src/auction. Flag it when that code changes.
124
+ Change these Joycraft settings, and show me the change before you write it:
125
+ - Keep Joycraft's briefs and specs in working/features, and finished features in working/archive.
126
+ - Whenever a feature is archived, run our wiki sync script.
127
+ - The page docs/context/auction-rules.md describes src/auction. Flag it when that code changes.
128
+ Do not commit, publish, or ask me for API keys.
126
129
  ```
127
130
 
128
131
  The agent writes the change to `joycraft.yaml` at the project root, shows it to you
@@ -289,14 +292,20 @@ It sends the agent back with the spec or file name and the next step. A spec tha
289
292
  **Why you want it.** Use the gates for long sessions and for sessions that you do
290
293
  not watch. A prompt tells the agent what to do, but a prompt is not a guarantee.
291
294
  With the gates on, Claude Code runs the check each time the agent tries to stop. The
292
- agent cannot stop until the problem is gone.
295
+ agent cannot stop until the problem is gone. For a spec marked done with no accepted
296
+ review, the agent sets the spec back to `in-review` without asking you.
293
297
 
294
298
  **Before you turn them on.** An older project can have specs marked done with no
295
- accepted review. The check sends each one back for a review. To see them first, say:
299
+ accepted review. Turning on the gates runs the check first. The hook goes in only
300
+ after a clean check. The agent sets each of these specs back to
301
+ `in-review` itself, tells you what it changed, and checks again. It stops and asks
302
+ you only about a file that it cannot read. A look at the problems first is optional.
303
+ To see them, say:
296
304
 
297
305
  ```text
298
306
  Run Joycraft's gate check with `node .joycraft/runtime/gate.mjs check` and show me
299
- what it names. Change nothing yet.
307
+ what it names. Change nothing yet. For each spec it names, tell me what you recommend.
308
+ Do not commit, publish, or ask me for API keys.
300
309
  ```
301
310
 
302
311
  Do this also after you update an older project to 1.4.1 or later, because session
@@ -305,7 +314,9 @@ end now runs the same check.
305
314
  **Turn them on.** Say:
306
315
 
307
316
  ```text
308
- Turn on Joycraft's gates.
317
+ Turn on Joycraft's gates. Show me the change to .claude/settings.json on a page,
318
+ and write it only on my yes.
319
+ Do not commit, publish, or ask me for API keys.
309
320
  ```
310
321
 
311
322
  The agent shows you the change to `.claude/settings.json` on a page. It writes the
@@ -315,7 +326,8 @@ also offers the gates one time.
315
326
  **Turn them off.** Say:
316
327
 
317
328
  ```text
318
- Turn off Joycraft's gates.
329
+ Turn off Joycraft's gates. Remove only Joycraft's hook, and tell me what you removed.
330
+ Do not commit, publish, or ask me for API keys.
319
331
  ```
320
332
 
321
333
  The agent removes Joycraft's hook. Your own hooks stay. If you remove Joycraft from
@@ -396,7 +408,9 @@ always your choice.
396
408
  This is an instruction the agent follows, so it can forget. To check yourself, ask:
397
409
 
398
410
  ```text
399
- Check for a Joycraft update.
411
+ Check for a Joycraft update. If there is one, run
412
+ `npx joycraft@latest update . --plan --json`, show me what changes, and update on my yes.
413
+ Do not commit, publish, or ask me for API keys.
400
414
  ```
401
415
 
402
416
  ## Hosts
package/dist/cli.js CHANGED
@@ -1428,8 +1428,25 @@ function recoverLegacy(dir) {
1428
1428
  }
1429
1429
 
1430
1430
  // src/rollback.ts
1431
+ import { spawnSync } from "child_process";
1431
1432
  import { copyFileSync as copyFileSync3, existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync4, rmdirSync as rmdirSync2, rmSync as rmSync3, statSync } from "fs";
1432
1433
  import { dirname as dirname4, join as join4, relative, resolve as resolve3, sep as sep3 } from "path";
1434
+ var SETTINGS = ".claude/settings.json";
1435
+ var RUNTIME = ".joycraft/runtime/";
1436
+ var GATE = `${RUNTIME}gate.mjs`;
1437
+ var GATE_HOOK_COMMAND = 'node "$CLAUDE_PROJECT_DIR"/.joycraft/runtime/gate.mjs check --root "$CLAUDE_PROJECT_DIR"';
1438
+ function gateHookIn(root) {
1439
+ const file = join4(root, SETTINGS);
1440
+ if (!existsSync4(file)) return false;
1441
+ let data;
1442
+ try {
1443
+ data = JSON.parse(readFileSync4(file, "utf8").replace(/^\uFEFF/, ""));
1444
+ } catch {
1445
+ return false;
1446
+ }
1447
+ const stop = data?.hooks?.Stop;
1448
+ return Array.isArray(stop) && stop.some((group) => Array.isArray(group?.hooks) && group.hooks.some((hook) => hook?.type === "command" && hook.command === GATE_HOOK_COMMAND));
1449
+ }
1433
1450
  function inside3(root, path) {
1434
1451
  const full = resolve3(root, path);
1435
1452
  if (full !== root && !full.startsWith(root + sep3)) throw new Error(`Path escapes the project: ${path}`);
@@ -1473,12 +1490,14 @@ function planRollback(dir, stamp2, { force = false } = {}) {
1473
1490
  if (existsSync4(inside3(root, from)) && !removing.has(from)) blocked.push(from);
1474
1491
  else restore.push(from);
1475
1492
  }
1476
- return { root, backup, restore, remove, edited, blocked };
1493
+ const gateHook = !record.settingsBackup && remove.some((path) => path.startsWith(RUNTIME)) && gateHookIn(root);
1494
+ return { root, backup, restore, remove, edited, blocked, gateHook };
1477
1495
  }
1478
1496
  function formatRollback(plan) {
1479
1497
  return [
1480
1498
  `Roll back to before ${plan.backup}:`,
1481
1499
  ` restore ${plan.restore.length} 0.7 file(s) \xB7 remove ${plan.remove.length} 1.0 file(s)`,
1500
+ ...plan.gateHook ? [` remove Joycraft's gate Stop hook from ${SETTINGS}; rollback removes runtime files it needs`] : [],
1482
1501
  ...plan.edited.map((path) => ` kept, edited after the migration (use --force to remove): ${path}`),
1483
1502
  ...plan.blocked.map((path) => ` not restored, a file is already there: ${path}`),
1484
1503
  ` The backup stays in ${plan.backup}.`
@@ -1496,6 +1515,10 @@ function prune(root, path) {
1496
1515
  function applyRollback(plan) {
1497
1516
  const { root } = plan;
1498
1517
  const record = JSON.parse(readFileSync4(join4(root, plan.backup, MIGRATION_RECORD), "utf8"));
1518
+ if (plan.gateHook && existsSync4(join4(root, GATE))) {
1519
+ const off = spawnSync(process.execPath, [join4(root, GATE), "hook", "--off", "--root", root], { cwd: root, encoding: "utf8" });
1520
+ if (off.status !== 0) throw new Error(`Could not remove Joycraft's gate Stop hook from ${SETTINGS}; nothing was rolled back. ${off.stderr.trim()}`);
1521
+ }
1499
1522
  for (const path of plan.remove) {
1500
1523
  rmSync3(inside3(root, path), { force: true });
1501
1524
  prune(root, path);