joycraft 0.7.14 → 0.7.16

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.
@@ -10,7 +10,7 @@ import {
10
10
  PI_SKILLS,
11
11
  SKILLS,
12
12
  TEMPLATES
13
- } from "./chunk-JYPBXPGD.js";
13
+ } from "./chunk-35RQLGKM.js";
14
14
  import {
15
15
  resolveUpdatePath
16
16
  } from "./chunk-OMFGDJW4.js";
@@ -345,18 +345,27 @@ function generateHookScript() {
345
345
  # Joycraft Safeguard \u2014 PreToolUse hook
346
346
  # Blocks dangerous Bash commands. Exit 2 = block the action.
347
347
  # Edit deny-patterns.txt to customize what's blocked.
348
+ #
349
+ # Claude Code passes no arguments: the hook payload arrives as JSON on stdin
350
+ # ({"tool_name":"Bash","tool_input":{"command":"..."},...}). The reason for a
351
+ # block goes to stderr, which is what the model sees on exit 2.
348
352
 
349
- TOOL_NAME="$1"
350
- # Read the full tool input from stdin
351
353
  INPUT=$(cat)
352
354
 
353
- # Only check Bash commands
354
- if [ "$TOOL_NAME" != "Bash" ]; then
355
- exit 0
355
+ if command -v jq >/dev/null 2>&1; then
356
+ TOOL_NAME=$(printf '%s' "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
357
+ COMMAND=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // .command // empty' 2>/dev/null)
358
+ else
359
+ # Fallback without jq: tolerate spaces around the colon and escaped quotes.
360
+ TOOL_NAME=$(printf '%s' "$INPUT" | grep -o '"tool_name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/^"tool_name"[[:space:]]*:[[:space:]]*"//;s/"$//')
361
+ COMMAND=$(printf '%s' "$INPUT" | grep -o '"command"[[:space:]]*:[[:space:]]*"\\([^"\\\\]\\|\\\\.\\)*"' | head -1 | sed 's/^"command"[[:space:]]*:[[:space:]]*"//;s/"$//;s/\\\\"/"/g;s/\\\\\\\\/\\\\/g')
356
362
  fi
357
363
 
358
- # Extract the command from the JSON input
359
- COMMAND=$(echo "$INPUT" | grep -o '"command":"[^"]*"' | head -1 | sed 's/"command":"//;s/"$//')
364
+ # Only check Bash commands (the settings matcher already limits this hook to
365
+ # Bash; a payload that names another tool is passed through untouched).
366
+ if [ -n "$TOOL_NAME" ] && [ "$TOOL_NAME" != "Bash" ]; then
367
+ exit 0
368
+ fi
360
369
 
361
370
  if [ -z "$COMMAND" ]; then
362
371
  exit 0
@@ -373,9 +382,9 @@ while IFS= read -r pattern || [ -n "$pattern" ]; do
373
382
  [ -z "$pattern" ] && continue
374
383
  [[ "$pattern" == \\#* ]] && continue
375
384
 
376
- if echo "$COMMAND" | grep -qEi "$pattern"; then
377
- echo "Blocked by Joycraft Safeguard: command matches deny pattern '$pattern'"
378
- echo "Edit .claude/hooks/joycraft/deny-patterns.txt to modify blocked patterns."
385
+ if printf '%s' "$COMMAND" | grep -qEi "$pattern"; then
386
+ echo "Blocked by Joycraft Safeguard: command matches deny pattern '$pattern'" >&2
387
+ echo "Edit .claude/hooks/joycraft/deny-patterns.txt to modify blocked patterns." >&2
379
388
  exit 2
380
389
  fi
381
390
  done < "$PATTERNS_FILE"
@@ -487,6 +496,15 @@ try {
487
496
  `;
488
497
  }
489
498
 
499
+ // src/model-profile.ts
500
+ var MODEL_PROFILE_TEMPLATE_KEY = "reference/model-profile-claude-fable-5-1.md";
501
+ var MODEL_PROFILE_PATH = `docs/templates/${MODEL_PROFILE_TEMPLATE_KEY}`;
502
+ var MODEL_PROFILE_HARNESSES = Object.freeze(["claude", "pi", "omp"]);
503
+ var MODEL_PROFILE_CONTEXT_MAP_ROW = `| \`${MODEL_PROFILE_PATH}\` | Working with Claude Fable 5.1 \u2014 finishing whole tasks, scope, progress updates, prose |`;
504
+ function selectsModelProfile(harnesses) {
505
+ return harnesses.some((harness) => MODEL_PROFILE_HARNESSES.includes(harness));
506
+ }
507
+
490
508
  // src/bundle-inventory.ts
491
509
  var vendor = (path, harness, content, options = {}) => ({
492
510
  path,
@@ -516,6 +534,19 @@ var patch = (path, harness, ownedKey, ownedRegion) => ({
516
534
  ...ownedKey ? { ownedKey } : {},
517
535
  ...ownedRegion ? { ownedRegion } : {}
518
536
  });
537
+ var TEMPLATE_HARNESS_GATES = {
538
+ // D6: keyed to the model, not the harness. The list lives in model-profile.ts
539
+ // so the memory-file pointer row is gated on exactly the same harnesses.
540
+ [MODEL_PROFILE_TEMPLATE_KEY]: MODEL_PROFILE_HARNESSES
541
+ };
542
+ function templateEntries(templates, selected2, gates = TEMPLATE_HARNESS_GATES) {
543
+ return Object.entries(templates).flatMap(([path, content]) => {
544
+ const gate = Object.prototype.hasOwnProperty.call(gates, path) ? gates[path] : void 0;
545
+ if (!gate) return [vendor(`docs/templates/${path}`, "shared", content)];
546
+ const owner = HARNESSES.find((harness) => gate.includes(harness) && selected2.includes(harness));
547
+ return owner ? [vendor(`docs/templates/${path}`, owner, content)] : [];
548
+ });
549
+ }
519
550
  function mapVendorFiles(harness, root, files, options = void 0) {
520
551
  return Object.entries(files).map(([name, content]) => {
521
552
  const relative = name.endsWith(".md") && root.endsWith("/skills") ? `${name.slice(0, -3)}/SKILL.md` : name;
@@ -526,7 +557,7 @@ function getBundleInventory(selection = HARNESSES) {
526
557
  const selected2 = sanitizeHarnesses(selection) ?? [...HARNESSES];
527
558
  const wants = (harness) => selected2.includes(harness);
528
559
  const entries = [
529
- ...Object.entries(TEMPLATES).map(([path, content]) => vendor(`docs/templates/${path}`, "shared", content)),
560
+ ...templateEntries(TEMPLATES, selected2),
530
561
  createOnce("CLAUDE.md"),
531
562
  createOnce("AGENTS.md"),
532
563
  vendor("docs/.joycraft/check.mjs", "shared", CHECKER_SOURCE, { executable: true, mode: 493 })
@@ -2188,6 +2219,7 @@ var KNOWN_DESCRIPTIONS = {
2188
2219
  "docs/discoveries/": "Session surprises worth remembering",
2189
2220
  "docs/templates/": "Bundled output and reference templates",
2190
2221
  "docs/backlog/": "Deferred work, one file per item",
2222
+ "docs/intent/": "Intent inbox \u2014 incoming work before a feature slug exists",
2191
2223
  "docs/research/": "Research notes and findings"
2192
2224
  };
2193
2225
  function listDirs(dir) {
@@ -2375,13 +2407,71 @@ This project uses [Joycraft](https://github.com/maksutovic/joycraft) for AI deve
2375
2407
 
2376
2408
  Run \`/joycraft-tune\` to see where your project stands and what to improve next.${invocationNote}`;
2377
2409
  }
2378
- function generateContextMapSection() {
2410
+ var CONTEXT_MAP_TABLE_HEADER = "| Document | Read it when\u2026 |\n|----------|---------------|";
2411
+ function generateContextMapSection(modelProfilePointer = false) {
2412
+ const row = modelProfilePointer ? `
2413
+ ${MODEL_PROFILE_CONTEXT_MAP_ROW}` : "";
2379
2414
  return `## Context Map
2380
2415
 
2381
2416
  Keep this file lean \u2014 link out, don't inline. Long-form reference docs live in \`docs/context/reference/\`; this table points to what to read on demand.
2382
2417
 
2383
- | Document | Read it when\u2026 |
2384
- |----------|---------------|`;
2418
+ ${CONTEXT_MAP_TABLE_HEADER}${row}`;
2419
+ }
2420
+ function sourceLines(content) {
2421
+ const lines = [];
2422
+ let offset = 0;
2423
+ while (offset < content.length) {
2424
+ const newline = content.indexOf("\n", offset);
2425
+ const end = newline === -1 ? content.length : newline + 1;
2426
+ const raw = content.slice(offset, newline === -1 ? content.length : newline);
2427
+ lines.push({ text: raw.replace(/\r$/, ""), start: offset, end });
2428
+ offset = end;
2429
+ }
2430
+ return lines;
2431
+ }
2432
+ function insertAfterLine(content, line, block, newline) {
2433
+ if (content[line.end - 1] === "\n") {
2434
+ return content.slice(0, line.end) + block + newline + content.slice(line.end);
2435
+ }
2436
+ return content + newline + block;
2437
+ }
2438
+ function insertModelProfilePointer(content) {
2439
+ if (content.includes(MODEL_PROFILE_PATH)) return content;
2440
+ const newline = content.includes("\r\n") ? "\r\n" : "\n";
2441
+ const lines = sourceLines(content);
2442
+ const header = lines.findIndex((line) => line.text.startsWith("## ") && /context\s*map/i.test(line.text));
2443
+ if (header === -1) {
2444
+ const section = generateContextMapSection(true).replace(/\n/g, newline);
2445
+ if (content === "") return section + newline;
2446
+ const base = content.endsWith("\n") ? content : content + newline;
2447
+ return base + newline + section + newline;
2448
+ }
2449
+ let sectionEnd = lines.length;
2450
+ for (let index = header + 1; index < lines.length; index++) {
2451
+ if (lines[index].text.startsWith("## ")) {
2452
+ sectionEnd = index;
2453
+ break;
2454
+ }
2455
+ }
2456
+ const isTableLine = (index) => lines[index].text.trim().startsWith("|");
2457
+ let tableStart = -1;
2458
+ for (let index = header + 1; index < sectionEnd; index++) {
2459
+ if (isTableLine(index)) {
2460
+ tableStart = index;
2461
+ break;
2462
+ }
2463
+ }
2464
+ if (tableStart !== -1) {
2465
+ let last = tableStart;
2466
+ while (last + 1 < sectionEnd && isTableLine(last + 1)) last++;
2467
+ return insertAfterLine(content, lines[last], MODEL_PROFILE_CONTEXT_MAP_ROW, newline);
2468
+ }
2469
+ let lastContent = header;
2470
+ for (let index = header + 1; index < sectionEnd; index++) {
2471
+ if (lines[index].text.trim() !== "") lastContent = index;
2472
+ }
2473
+ const table = ["", ...CONTEXT_MAP_TABLE_HEADER.split("\n"), MODEL_PROFILE_CONTEXT_MAP_ROW].join(newline);
2474
+ return insertAfterLine(content, lines[lastContent], table, newline);
2385
2475
  }
2386
2476
  function generateAreasSection() {
2387
2477
  return `## Areas
@@ -2432,7 +2522,7 @@ function generateCLAUDEMd(projectName2, stack, existingSkills = [], opts) {
2432
2522
  "",
2433
2523
  generateGotchasSection(),
2434
2524
  "",
2435
- generateContextMapSection(),
2525
+ generateContextMapSection(opts?.modelProfilePointer === true),
2436
2526
  "",
2437
2527
  generateGettingStartedSection(opts?.multiTool ?? false),
2438
2528
  ""
@@ -2491,7 +2581,7 @@ function generateKeyFilesSection2() {
2491
2581
  |------|---------|
2492
2582
  | _TODO_ | _Add key files_ |`;
2493
2583
  }
2494
- function generateAgentsMd(projectName2, stack, privateProfile = false, executionProfile, identity, projectDir) {
2584
+ function generateAgentsMd(projectName2, stack, privateProfile = false, executionProfile, identity, projectDir, modelProfilePointer = false) {
2495
2585
  const frameworkNote = stack.framework ? ` (${stack.framework})` : "";
2496
2586
  const langLabel = stack.language === "unknown" ? "" : ` | **Stack:** ${stack.language}${frameworkNote}`;
2497
2587
  const lines = [
@@ -2513,6 +2603,9 @@ function generateAgentsMd(projectName2, stack, privateProfile = false, execution
2513
2603
  generateDevelopmentSection(stack),
2514
2604
  ""
2515
2605
  ];
2606
+ if (modelProfilePointer) {
2607
+ lines.push(generateContextMapSection(true), "");
2608
+ }
2516
2609
  const identitySection = generateProductIdentitySection(identity);
2517
2610
  if (identitySection) {
2518
2611
  lines.push(identitySection, "");
@@ -2651,6 +2744,38 @@ focused without losing the thread.
2651
2744
  - Promote an item by turning it into a Feature Brief under
2652
2745
  \`docs/features/<slug>/\` when you're ready to build it.
2653
2746
  `;
2747
+ var INTENT_README = `# Intent inbox
2748
+
2749
+ An intent is a short note that describes a need before anyone commits to
2750
+ building it: a customer bug, a product idea, a ticket from another system, or
2751
+ an alert. Put intents here, one file per intent. Nothing needs to decide on a
2752
+ feature name first.
2753
+
2754
+ - One file per intent: \`docs/intent/YYYY-MM-DD-<short-name>.md\`.
2755
+ - Use the shape in \`docs/templates/INTENT_TEMPLATE.md\`: Author, Status,
2756
+ \`source\`, Problem, Proposed outcome, Affected users and systems,
2757
+ Constraints, Open questions.
2758
+ - A new intent starts with \`Status: untriaged\`. Joycraft skills update that
2759
+ line when they triage or consume the intent. The file stays here afterwards.
2760
+ - \`source:\` records where the intent came from, for example \`human\`,
2761
+ \`interview\`, \`linear:<id>\`, or \`alert:<name>\`. It is free text.
2762
+
2763
+ ## How intents map to Joycraft artifacts
2764
+
2765
+ Anthropic's AI-native development playbook names a chain of artifacts. Joycraft
2766
+ already has most of them under its own names. Nothing is renamed. Use the
2767
+ Joycraft names below.
2768
+
2769
+ | Playbook term | Joycraft artifact | Where it lives |
2770
+ |---------------|-------------------|----------------|
2771
+ | intent | intent | \`docs/intent/<name>.md\` |
2772
+ | spec | brief | \`docs/features/<slug>/brief.md\` |
2773
+ | plan | design + atomic specs | \`docs/features/<slug>/design.md\` and \`docs/features/<slug>/specs/\` |
2774
+
2775
+ An intent becomes a brief through \`/joycraft-new-feature\`, or a bugfix spec
2776
+ through \`/joycraft-bugfix\`. The brief, design, and specs keep their current
2777
+ names and folders.
2778
+ `;
2654
2779
  var CLAUDE_SETTINGS = ".claude/settings.json";
2655
2780
  var TS_CONFIG = "tsconfig.json";
2656
2781
  var KNOWN_GENERATED_DOCUMENTS = /* @__PURE__ */ new Set(["CLAUDE.md", "AGENTS.md"]);
@@ -2663,6 +2788,13 @@ function regularFile(root, relative) {
2663
2788
  return false;
2664
2789
  }
2665
2790
  }
2791
+ function isDirectory(root, relative) {
2792
+ try {
2793
+ return lstatSync2(join9(root, ...relative.split("/"))).isDirectory();
2794
+ } catch {
2795
+ return false;
2796
+ }
2797
+ }
2666
2798
  function existingPath(root, relative) {
2667
2799
  try {
2668
2800
  lstatSync2(join9(root, ...relative.split("/")));
@@ -2689,12 +2821,20 @@ function existingClaudeSkills(root, selected2) {
2689
2821
  return [];
2690
2822
  }
2691
2823
  }
2824
+ function sharesAgentsMd(harnesses) {
2825
+ return harnesses.some((harness) => harness !== "claude");
2826
+ }
2827
+ function memoryFilePath(harnesses) {
2828
+ return sharesAgentsMd(harnesses) ? "AGENTS.md" : "CLAUDE.md";
2829
+ }
2692
2830
  function generatorContent(root, path, harnesses, profile, stack, existingSkills, executionProfile) {
2693
- const multiTool = harnesses.some((harness) => harness !== "claude");
2831
+ const multiTool = sharesAgentsMd(harnesses);
2832
+ const modelProfilePointer = selectsModelProfile(harnesses);
2694
2833
  if (path === "CLAUDE.md") {
2695
2834
  return multiTool ? generateClaudeMdPointer() : generateCLAUDEMd(projectName(root), stack, existingSkills, {
2696
2835
  privateProfile: profile === "private",
2697
- projectDir: root
2836
+ projectDir: root,
2837
+ modelProfilePointer
2698
2838
  });
2699
2839
  }
2700
2840
  if (path === "AGENTS.md") {
@@ -2702,7 +2842,8 @@ function generatorContent(root, path, harnesses, profile, stack, existingSkills,
2702
2842
  privateProfile: profile === "private",
2703
2843
  multiTool: true,
2704
2844
  executionProfile,
2705
- projectDir: root
2845
+ projectDir: root,
2846
+ modelProfilePointer
2706
2847
  }) : generateAgentsMd(projectName(root), stack, profile === "private", executionProfile, void 0, root);
2707
2848
  }
2708
2849
  return void 0;
@@ -2775,6 +2916,20 @@ function freshBacklogEntry(input) {
2775
2916
  content: BACKLOG_README
2776
2917
  };
2777
2918
  }
2919
+ function freshIntentEntry(input) {
2920
+ if (!input.freshInstall) return void 0;
2921
+ if (existingPath(input.root, "docs/intent") && !isDirectory(input.root, "docs/intent")) return void 0;
2922
+ if (existingPath(input.root, "docs/intent/README.md")) return void 0;
2923
+ return {
2924
+ path: "docs/intent/README.md",
2925
+ harness: "shared",
2926
+ kind: "create-once",
2927
+ ownership: "managed",
2928
+ active: true,
2929
+ installable: true,
2930
+ content: INTENT_README
2931
+ };
2932
+ }
2778
2933
  function parseSettings(raw) {
2779
2934
  try {
2780
2935
  const parsed = JSON.parse(raw);
@@ -2967,6 +3122,29 @@ function tsconfigPatch(input, diagnostics) {
2967
3122
  reason: "Exclude the installed Pi runtime from the project TypeScript program while preserving the existing tsconfig bytes."
2968
3123
  };
2969
3124
  }
3125
+ function contextMapPointerPatch(input, entries, diagnostics) {
3126
+ if (!selectsModelProfile(input.harnesses)) return void 0;
3127
+ const memory = memoryFilePath(input.harnesses);
3128
+ if (!regularFile(input.root, memory)) return void 0;
3129
+ if (entries.some((entry) => entry.path === memory && entry.content !== void 0)) return void 0;
3130
+ let raw;
3131
+ try {
3132
+ raw = readFileSync7(join9(input.root, memory), "utf8");
3133
+ } catch {
3134
+ diagnostics.push(`${memory} could not be read; add the model profile row to its Context Map manually.`);
3135
+ return void 0;
3136
+ }
3137
+ const next = insertModelProfilePointer(raw);
3138
+ if (next === raw) return void 0;
3139
+ return {
3140
+ path: memory,
3141
+ kind: "write",
3142
+ content: next,
3143
+ currentPresent: true,
3144
+ rawPrecondition: rawFileHash(raw),
3145
+ reason: "Add one Context Map row pointing at the Claude Fable 5.1 model profile; every other byte is preserved."
3146
+ };
3147
+ }
2970
3148
  function materializeFreshInstallInventory(input) {
2971
3149
  const diagnostics = [];
2972
3150
  const existingSkills = existingClaudeSkills(input.root, input.harnesses);
@@ -2974,13 +3152,15 @@ function materializeFreshInstallInventory(input) {
2974
3152
  const known = new Set(entries.map((entry) => entry.path));
2975
3153
  const backlog = freshBacklogEntry(input);
2976
3154
  if (backlog && !known.has(backlog.path)) entries.push(backlog);
3155
+ const intent = freshIntentEntry(input);
3156
+ if (intent && !known.has(intent.path)) entries.push(intent);
2977
3157
  const settings = freshSettingsEntry(input);
2978
3158
  if (settings && !known.has(settings.path)) entries.push(settings);
2979
3159
  const directories = [];
2980
3160
  if (input.freshInstall) {
2981
- for (const relative of ["docs/context", "docs/backlog"]) {
3161
+ for (const relative of ["docs/context", "docs/backlog", "docs/intent"]) {
2982
3162
  if (!existingPath(input.root, relative)) directories.push(relative);
2983
- else if (!regularFile(input.root, relative)) {
3163
+ else {
2984
3164
  try {
2985
3165
  if (!lstatSync2(join9(input.root, ...relative.split("/"))).isDirectory()) {
2986
3166
  diagnostics.push(`${relative} exists but is not a directory; preserving it.`);
@@ -2991,7 +3171,11 @@ function materializeFreshInstallInventory(input) {
2991
3171
  }
2992
3172
  }
2993
3173
  }
2994
- const patchOperations = [settingsPatch(input, diagnostics), tsconfigPatch(input, diagnostics)].filter((operation) => operation !== void 0);
3174
+ const patchOperations = [
3175
+ settingsPatch(input, diagnostics),
3176
+ tsconfigPatch(input, diagnostics),
3177
+ contextMapPointerPatch(input, entries, diagnostics)
3178
+ ].filter((operation) => operation !== void 0);
2995
3179
  return {
2996
3180
  entries,
2997
3181
  setup: { directories, existingSkills, patchOperations },
@@ -3192,9 +3376,12 @@ function legacyHarnesses(root) {
3192
3376
  }
3193
3377
  return void 0;
3194
3378
  }
3379
+ function harnessTreeEntry(entry, harness) {
3380
+ return entry.harness === harness && entry.content !== void 0 && !entry.path.startsWith("docs/templates/");
3381
+ }
3195
3382
  function recognizedHarnesses(root) {
3196
3383
  const inventory = getBundleInventory(HARNESSES);
3197
- return HARNESSES.filter((harness) => inventory.some((entry) => entry.harness === harness && entry.content !== void 0 && regularFile2(root, entry.path)));
3384
+ return HARNESSES.filter((harness) => inventory.some((entry) => harnessTreeEntry(entry, harness) && regularFile2(root, entry.path)));
3198
3385
  }
3199
3386
  function legacyMigrationOperations(root, localSettings) {
3200
3387
  const sources = [STATE_PATH, LEGACY_CLAUDE_STATE_PATH, LEGACY_VERSION_FILE];
@@ -3392,7 +3579,7 @@ function profileBookkeepingActions(root, profile) {
3392
3579
  function selectedHarnessIgnoreWarning(root, harnesses) {
3393
3580
  const warnings = [];
3394
3581
  for (const harness of harnesses) {
3395
- const candidate = getBundleInventory([harness]).find((entry) => entry.harness === harness && entry.content !== void 0)?.path;
3582
+ const candidate = getBundleInventory([harness]).find((entry) => harnessTreeEntry(entry, harness))?.path;
3396
3583
  if (!candidate) continue;
3397
3584
  const top = candidate.split("/")[0];
3398
3585
  let localBroadIgnore = false;
@@ -3752,4 +3939,4 @@ export {
3752
3939
  update,
3753
3940
  formatUpdateOutcome
3754
3941
  };
3755
- //# sourceMappingURL=chunk-PR4QDKPL.js.map
3942
+ //# sourceMappingURL=chunk-GTP7Z52K.js.map