joycraft 0.7.13 → 0.7.14

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.
Files changed (49) hide show
  1. package/README.md +25 -11
  2. package/dist/chunk-7BPB2IKY.js +255 -0
  3. package/dist/chunk-7BPB2IKY.js.map +1 -0
  4. package/dist/chunk-B73DPYYC.js +377 -0
  5. package/dist/chunk-B73DPYYC.js.map +1 -0
  6. package/dist/{chunk-EFHJI5KD.js → chunk-JYPBXPGD.js} +114 -112
  7. package/dist/chunk-JYPBXPGD.js.map +1 -0
  8. package/dist/{chunk-LKWD25KJ.js → chunk-KKDKC4FM.js} +8 -71
  9. package/dist/chunk-KKDKC4FM.js.map +1 -0
  10. package/dist/chunk-OMFGDJW4.js +97 -0
  11. package/dist/chunk-OMFGDJW4.js.map +1 -0
  12. package/dist/chunk-PR4QDKPL.js +3755 -0
  13. package/dist/chunk-PR4QDKPL.js.map +1 -0
  14. package/dist/chunk-Z5JFEGWG.js +563 -0
  15. package/dist/chunk-Z5JFEGWG.js.map +1 -0
  16. package/dist/cli.js +387 -54
  17. package/dist/cli.js.map +1 -1
  18. package/dist/index.d.ts +235 -1
  19. package/dist/index.js +691 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/init-S5JU5BHL.js +60 -0
  22. package/dist/init-S5JU5BHL.js.map +1 -0
  23. package/dist/{init-autofix-E7DSPUSC.js → init-autofix-WSKUT2HN.js} +4 -3
  24. package/dist/{init-autofix-E7DSPUSC.js.map → init-autofix-WSKUT2HN.js.map} +1 -1
  25. package/dist/install-manifest-EQHT4474.js +37 -0
  26. package/dist/joycraft-release.json +8 -0
  27. package/dist/release-artifact-4TL5L2ZY.js +14 -0
  28. package/dist/release-artifact-4TL5L2ZY.js.map +1 -0
  29. package/dist/release-resolver-P2H46QTU.js +293 -0
  30. package/dist/release-resolver-P2H46QTU.js.map +1 -0
  31. package/dist/update-HNTXCEKB.js +19 -0
  32. package/dist/update-HNTXCEKB.js.map +1 -0
  33. package/dist/update-check-YT765NE7.js +36 -0
  34. package/dist/update-check-YT765NE7.js.map +1 -0
  35. package/dist/upgrade-LZOND7OZ.js +28 -0
  36. package/dist/upgrade-LZOND7OZ.js.map +1 -0
  37. package/package.json +5 -2
  38. package/dist/chunk-EFHJI5KD.js.map +0 -1
  39. package/dist/chunk-J6GDQ55S.js +0 -91
  40. package/dist/chunk-J6GDQ55S.js.map +0 -1
  41. package/dist/chunk-LKWD25KJ.js.map +0 -1
  42. package/dist/chunk-Q2ZQ6RGD.js +0 -243
  43. package/dist/chunk-Q2ZQ6RGD.js.map +0 -1
  44. package/dist/init-YSFURLGT.js +0 -1330
  45. package/dist/init-YSFURLGT.js.map +0 -1
  46. package/dist/upgrade-PELFI26D.js +0 -650
  47. package/dist/upgrade-PELFI26D.js.map +0 -1
  48. package/dist/version-J7MOKNJR.js +0 -28
  49. /package/dist/{version-J7MOKNJR.js.map → install-manifest-EQHT4474.js.map} +0 -0
@@ -1,91 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- TELEMETRY_PATH
4
- } from "./chunk-K4AI6FKB.js";
5
- import {
6
- DEFAULT_GITIGNORE_PROFILE,
7
- STATE_PATH,
8
- parseGitignoreProfile
9
- } from "./chunk-LKWD25KJ.js";
10
-
11
- // src/gitignore.ts
12
- import { existsSync, readFileSync, writeFileSync } from "fs";
13
- import { join } from "path";
14
- import { createInterface } from "readline";
15
- var PRIVATE_PROFILE_IGNORES = [".claude/", ".agents/", ".pi/", ".github/skills/joycraft-*/", ".omp/"];
16
- var PRIVATE_DIRS_DISPLAY = PRIVATE_PROFILE_IGNORES.join(", ");
17
- var PRIVATE_UNTRACK_COMMAND = `git rm -r --cached ${PRIVATE_PROFILE_IGNORES.map((d) => d.replace(/\/$/, "")).join(" ")}`;
18
- function ensureGitignoreEntries(targetDir, entries) {
19
- const gitignorePath = join(targetDir, ".gitignore");
20
- const current = existsSync(gitignorePath) ? readFileSync(gitignorePath, "utf-8") : "";
21
- const present = new Set(current.split("\n").map((l) => l.trim()));
22
- const missing = entries.filter((e) => !present.has(e.trim()));
23
- if (missing.length === 0) return [];
24
- const sep = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
25
- writeFileSync(gitignorePath, current + sep + missing.join("\n") + "\n", "utf-8");
26
- return missing;
27
- }
28
- function applyGitignoreProfile(targetDir, profile) {
29
- const machineOwned = [STATE_PATH, TELEMETRY_PATH];
30
- if (profile === "private") {
31
- return ensureGitignoreEntries(targetDir, [...PRIVATE_PROFILE_IGNORES, ...machineOwned]);
32
- }
33
- return ensureGitignoreEntries(targetDir, machineOwned);
34
- }
35
- function validateGitignoreFlag(flag) {
36
- const parsed = parseGitignoreProfile(flag);
37
- if (!parsed) {
38
- throw new Error(`Unknown gitignore profile '${flag}'. Use 'shared' or 'private'.`);
39
- }
40
- return parsed;
41
- }
42
- async function promptGitignoreProfile(intro) {
43
- const rl = createInterface({ input: process.stdin, output: process.stdout });
44
- console.log(intro);
45
- console.log(" shared \u2014 commit skills so your team gets the same workflow (default)");
46
- console.log(` private \u2014 gitignore ${PRIVATE_DIRS_DISPLAY}; track only CLAUDE.md, AGENTS.md, docs/`);
47
- return new Promise((resolve) => {
48
- const ask = () => {
49
- rl.question(`Profile [shared/private] (${DEFAULT_GITIGNORE_PROFILE}): `, (answer) => {
50
- if (answer.trim() === "") {
51
- rl.close();
52
- resolve(DEFAULT_GITIGNORE_PROFILE);
53
- return;
54
- }
55
- const parsed = parseGitignoreProfile(answer);
56
- if (parsed) {
57
- rl.close();
58
- resolve(parsed);
59
- return;
60
- }
61
- console.log(
62
- `Unrecognized answer '${answer.trim()}' \u2014 type 'shared' or 'private', or press Enter for ${DEFAULT_GITIGNORE_PROFILE}.`
63
- );
64
- ask();
65
- });
66
- };
67
- ask();
68
- });
69
- }
70
- async function resolveGitignoreProfile(opts) {
71
- if (opts.flag !== void 0) {
72
- return { profile: validateGitignoreFlag(opts.flag), decided: true };
73
- }
74
- if (opts.persisted) {
75
- return { profile: opts.persisted, decided: true };
76
- }
77
- if (opts.interactive) {
78
- return { profile: await promptGitignoreProfile(opts.promptIntro), decided: true };
79
- }
80
- return { profile: DEFAULT_GITIGNORE_PROFILE, decided: false };
81
- }
82
-
83
- export {
84
- PRIVATE_PROFILE_IGNORES,
85
- PRIVATE_DIRS_DISPLAY,
86
- PRIVATE_UNTRACK_COMMAND,
87
- applyGitignoreProfile,
88
- validateGitignoreFlag,
89
- resolveGitignoreProfile
90
- };
91
- //# sourceMappingURL=chunk-J6GDQ55S.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/gitignore.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { createInterface } from 'node:readline';\nimport {\n STATE_PATH,\n parseGitignoreProfile,\n DEFAULT_GITIGNORE_PROFILE,\n type GitignoreProfile,\n} from './version.js';\nimport { TELEMETRY_PATH } from './telemetry-store.js';\n\n/**\n * The harness directories the `private` profile gitignores. Tracking only\n * CLAUDE.md, AGENTS.md, and docs/ means everything under these dirs stays\n * local. `.claude/` already covers the hidden state file.\n *\n * `.github/skills/joycraft-*` is gitignored, NOT `.github/` or\n * `.github/skills/` — `.github/` holds Actions workflows, issue templates,\n * and other non-harness config, and `.github/skills/` may contain the\n * user's own non-Joycraft Copilot skills.\n *\n * `.omp/` gets no such narrowing: unlike `.github/`, it has no non-harness\n * tenancy — Joycraft writes only `.omp/skills/` there and nothing else — so\n * the whole dir is ignored, matching `.claude/`, `.agents/`, and `.pi/`.\n *\n * Single source of truth: every user-facing string that names these dirs\n * (prompts, summaries, the untrack hint, CLI help) derives from this list via\n * the constants below, so adding a harness dir can't leave stale messages.\n */\nexport const PRIVATE_PROFILE_IGNORES = ['.claude/', '.agents/', '.pi/', '.github/skills/joycraft-*/', '.omp/'];\n\n/** Human-readable list of the private-profile dirs, for prompts and summaries. */\nexport const PRIVATE_DIRS_DISPLAY = PRIVATE_PROFILE_IGNORES.join(', ');\n\n/** Copy-pasteable command to untrack already-committed harness files. */\nexport const PRIVATE_UNTRACK_COMMAND = `git rm -r --cached ${PRIVATE_PROFILE_IGNORES.map((d) => d.replace(/\\/$/, '')).join(' ')}`;\n\n/**\n * Append-only, create-if-absent, idempotent .gitignore writer.\n *\n * Mirrors the \"append over modify when touching user files\" principle: it never\n * rewrites, reorders, or removes existing lines — it only appends the entries\n * not already present (matched exactly, after trimming). One read + at most one\n * write per call. Returns the entries actually added (empty when everything was\n * already present).\n */\nexport function ensureGitignoreEntries(targetDir: string, entries: string[]): string[] {\n const gitignorePath = join(targetDir, '.gitignore');\n const current = existsSync(gitignorePath) ? readFileSync(gitignorePath, 'utf-8') : '';\n const present = new Set(current.split('\\n').map((l) => l.trim()));\n const missing = entries.filter((e) => !present.has(e.trim()));\n if (missing.length === 0) return [];\n\n // Append on their own lines, tolerating a file that may or may not end in \\n.\n const sep = current.length > 0 && !current.endsWith('\\n') ? '\\n' : '';\n writeFileSync(gitignorePath, current + sep + missing.join('\\n') + '\\n', 'utf-8');\n return missing;\n}\n\n/** Single-entry convenience wrapper around ensureGitignoreEntries. */\nexport function ensureGitignoreEntry(targetDir: string, line: string): boolean {\n return ensureGitignoreEntries(targetDir, [line]).length > 0;\n}\n\n/**\n * Apply a gitignore profile's entries to the project's .gitignore.\n *\n * The hidden upgrade-state file (`STATE_PATH`) is tool-managed, regenerated on\n * every init/upgrade, and must never be committed — under BOTH profiles. It now\n * lives at `docs/.joycraft/state.json`; since `docs/` is always tracked, the\n * state entry is no longer covered transitively by any harness-dir ignore, so\n * both profiles list it explicitly.\n *\n * - `shared` — ignore only the hidden state file (commit the harness dirs).\n * - `private` — ignore the .claude/, .agents/, .pi/, .github/skills/joycraft-*, .omp/ trees AND the state file.\n *\n * Append-only and idempotent (via ensureGitignoreEntries), so re-running\n * init/upgrade never duplicates entries. Returns the list of lines actually\n * added this call.\n */\nexport function applyGitignoreProfile(targetDir: string, profile: GitignoreProfile): string[] {\n // Machine-owned files under docs/.joycraft/ — since docs/ is always tracked,\n // both profiles must list them explicitly (telemetry.json additionally holds\n // per-machine work patterns that must never publish).\n const machineOwned = [STATE_PATH, TELEMETRY_PATH];\n if (profile === 'private') {\n return ensureGitignoreEntries(targetDir, [...PRIVATE_PROFILE_IGNORES, ...machineOwned]);\n }\n // `shared`: only the machine-owned files, matching long-standing behavior.\n return ensureGitignoreEntries(targetDir, machineOwned);\n}\n\n/** A resolved profile plus how it was arrived at. */\nexport interface ResolvedGitignoreProfile {\n profile: GitignoreProfile;\n /**\n * True when the profile is an actual decision: a --gitignore flag, a\n * persisted choice, or an interactive answer. False when it is the\n * non-interactive fallback default — callers must NOT persist a fallback,\n * or the one-time prompt would be permanently suppressed for the project.\n */\n decided: boolean;\n}\n\n/** Validate a raw --gitignore flag value. Throws the user-facing error on unknown values. */\nexport function validateGitignoreFlag(flag: string): GitignoreProfile {\n const parsed = parseGitignoreProfile(flag);\n if (!parsed) {\n throw new Error(`Unknown gitignore profile '${flag}'. Use 'shared' or 'private'.`);\n }\n return parsed;\n}\n\n/**\n * Prompt for a gitignore profile. An empty answer takes the default; an\n * unrecognized answer re-asks instead of being silently coerced — a typo must\n * not get persisted as a permanent choice.\n */\nasync function promptGitignoreProfile(intro: string): Promise<GitignoreProfile> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n console.log(intro);\n console.log(' shared — commit skills so your team gets the same workflow (default)');\n console.log(` private — gitignore ${PRIVATE_DIRS_DISPLAY}; track only CLAUDE.md, AGENTS.md, docs/`);\n return new Promise((resolve) => {\n const ask = (): void => {\n rl.question(`Profile [shared/private] (${DEFAULT_GITIGNORE_PROFILE}): `, (answer) => {\n if (answer.trim() === '') {\n rl.close();\n resolve(DEFAULT_GITIGNORE_PROFILE);\n return;\n }\n const parsed = parseGitignoreProfile(answer);\n if (parsed) {\n rl.close();\n resolve(parsed);\n return;\n }\n console.log(\n `Unrecognized answer '${answer.trim()}' — type 'shared' or 'private', or press Enter for ${DEFAULT_GITIGNORE_PROFILE}.`\n );\n ask();\n });\n };\n ask();\n });\n}\n\n/**\n * Resolve the gitignore profile by precedence — the single resolver shared by\n * init and upgrade so the two commands can never drift:\n * 1. --gitignore flag (validated; throws on unknown value)\n * 2. profile persisted in state.json (re-init / upgrade keep the prior choice)\n * 3. interactive prompt (the caller decides when prompting is allowed)\n * 4. fallback default `shared`, reported with decided=false\n */\nexport async function resolveGitignoreProfile(opts: {\n /** Raw --gitignore value from the CLI, if provided. */\n flag?: string;\n /** Profile previously persisted in state.json, if any. */\n persisted?: GitignoreProfile;\n /** Whether prompting is allowed (TTY, and the command permits interaction). */\n interactive: boolean;\n /** First line printed above the prompt; init and upgrade word it differently. */\n promptIntro: string;\n}): Promise<ResolvedGitignoreProfile> {\n if (opts.flag !== undefined) {\n return { profile: validateGitignoreFlag(opts.flag), decided: true };\n }\n if (opts.persisted) {\n return { profile: opts.persisted, decided: true };\n }\n if (opts.interactive) {\n return { profile: await promptGitignoreProfile(opts.promptIntro), decided: true };\n }\n return { profile: DEFAULT_GITIGNORE_PROFILE, decided: false };\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,YAAY;AACrB,SAAS,uBAAuB;AA2BzB,IAAM,0BAA0B,CAAC,YAAY,YAAY,QAAQ,8BAA8B,OAAO;AAGtG,IAAM,uBAAuB,wBAAwB,KAAK,IAAI;AAG9D,IAAM,0BAA0B,sBAAsB,wBAAwB,IAAI,CAAC,MAAM,EAAE,QAAQ,OAAO,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC;AAWxH,SAAS,uBAAuB,WAAmB,SAA6B;AACrF,QAAM,gBAAgB,KAAK,WAAW,YAAY;AAClD,QAAM,UAAU,WAAW,aAAa,IAAI,aAAa,eAAe,OAAO,IAAI;AACnF,QAAM,UAAU,IAAI,IAAI,QAAQ,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAChE,QAAM,UAAU,QAAQ,OAAO,CAAC,MAAM,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AA,MACN,CAAC;AAAA,IACH;AACA,QAAI;AAAA,EACN,CAAC;AACH;AAUA,eAAsB,wBAAwB,MASR;AACpC,MAAI,KAAK,SAAS,QAAW;AAC3B,WAAO,EAAE,SAAS,sBAAsB,KAAK,IAAI,GAAG,SAAS,KAAK;AAAA,EACpE;AACA,MAAI,KAAK,WAAW;AAClB,WAAO,EAAE,SAAS,KAAK,WAAW,SAAS,KAAK;AAAA,EAClD;AACA,MAAI,KAAK,aAAa;AACpB,WAAO,EAAE,SAAS,MAAM,uBAAuB,KAAK,WAAW,GAAG,SAAS,KAAK;AAAA,EAClF;AACA,SAAO,EAAE,SAAS,2BAA2B,SAAS,MAAM;AAC9D;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/version.ts","../src/harness.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { sanitizeHarnesses, type Harness } from './harness.js';\n\n/**\n * Project-relative path to Joycraft's upgrade-state file.\n *\n * Hidden inside `docs/` — the one directory `init` always creates regardless of\n * which harnesses are selected — so a single-harness install carries no\n * foreign-harness footprint (a Codex-only project has no `.claude/`, etc.). The\n * state is Joycraft's own bookkeeping (version, file hashes, gitignore profile),\n * not a harness artifact, so it lives in a harness-neutral home. Never at the\n * repo root, never committed (init/upgrade gitignore it).\n *\n * Two legacy locations are migrated on upgrade: the original repo-root\n * `.joycraft-version` (see LEGACY_VERSION_FILE) and the later\n * `.claude/.joycraft/state.json` (see LEGACY_CLAUDE_STATE_PATH).\n */\nexport const STATE_PATH = join('docs', '.joycraft', 'state.json');\n\n/** The original repo-root state path. Kept only so `upgrade` can migrate it. */\nexport const LEGACY_VERSION_FILE = '.joycraft-version';\n\n/**\n * The interim `.claude/`-nested state path, used before state moved to a\n * harness-neutral `docs/` home. Kept only so `upgrade` can migrate it (and so a\n * Codex/Pi-only re-init stops leaving a stray `.claude/` behind).\n */\nexport const LEGACY_CLAUDE_STATE_PATH = join('.claude', '.joycraft', 'state.json');\n\n/**\n * Length we truncate stored hashes to. Full SHA-256 is 64 hex chars; 16 hex\n * (64 bits) is ample to detect customization across ~100 managed files and\n * shrinks the state ~4×. Compare truncated-on-both-sides (see upgrade.ts).\n */\nconst HASH_LENGTH = 16;\n\n/**\n * How much of the Joycraft harness is tracked in git.\n * - `shared` — commit skills/agents/pi so teammates get the workflow (default).\n * - `private` — gitignore .claude/, .agents/, .pi/; track only CLAUDE.md,\n * AGENTS.md, and docs/.\n */\nexport type GitignoreProfile = 'shared' | 'private';\n\nexport const DEFAULT_GITIGNORE_PROFILE: GitignoreProfile = 'shared';\n\n/**\n * Narrow an arbitrary value to a GitignoreProfile, or null if unrecognized.\n * Strings are normalized (trim + lowercase) here so every call site — flag,\n * prompt, persisted state — gets the same case-insensitivity for free.\n */\nexport function parseGitignoreProfile(value: unknown): GitignoreProfile | null {\n const v = typeof value === 'string' ? value.trim().toLowerCase() : value;\n return v === 'shared' || v === 'private' ? v : null;\n}\n\nexport interface VersionInfo {\n version: string;\n files: Record<string, string>;\n /**\n * The gitignore profile chosen at init/upgrade. Absent on state written by\n * Joycraft versions before this field existed — treat absent as `shared`.\n */\n gitignoreProfile?: GitignoreProfile;\n /**\n * The harnesses installed at init (claude/codex/pi). `upgrade` reads this so\n * it only refreshes the harnesses the project actually uses. Absent on state\n * written before harness selection existed — callers treat absent as \"all\n * three\" for backward compatibility.\n */\n harnesses?: Harness[];\n /**\n * Whether gate skills auto-open rendered HTML artifacts (`open`/`xdg-open`).\n * Absent means true — auto-open was unconditional before this field existed.\n * Persisted here (not a new file) per D12; tune offers the toggle.\n */\n autoOpen?: boolean;\n}\n\nexport function hashContent(content: string): string {\n return createHash('sha256').update(content).digest('hex');\n}\n\n/** Truncate a (full) content hash to the stored length. Idempotent for already-short input. */\nexport function truncateHash(hash: string): string {\n return hash.slice(0, HASH_LENGTH);\n}\n\nexport function readVersion(dir: string): VersionInfo | null {\n const filePath = join(dir, STATE_PATH);\n if (!existsSync(filePath)) return null;\n try {\n const raw = readFileSync(filePath, 'utf-8');\n const parsed = JSON.parse(raw);\n if (typeof parsed.version === 'string' && typeof parsed.files === 'object') {\n // Sanitize the profile: ignore unknown/legacy values rather than\n // returning them (absent or bogus → undefined, callers default to shared).\n const profile = parseGitignoreProfile(parsed.gitignoreProfile);\n // Sanitize harnesses similarly: drop unknown tokens; null (not an array)\n // means \"no recorded selection\" → callers default to all available.\n const harnesses = sanitizeHarnesses(parsed.harnesses);\n return {\n version: parsed.version,\n files: parsed.files,\n ...(profile ? { gitignoreProfile: profile } : {}),\n ...(harnesses ? { harnesses } : {}),\n // Only a real boolean counts; anything else is treated as absent\n // (and absent means true at every call site).\n ...(typeof parsed.autoOpen === 'boolean' ? { autoOpen: parsed.autoOpen } : {}),\n };\n }\n return null;\n } catch {\n return null;\n }\n}\n\nexport function writeVersion(\n dir: string,\n version: string,\n files: Record<string, string>,\n gitignoreProfile?: GitignoreProfile,\n harnesses?: Harness[],\n autoOpen?: boolean\n): void {\n const filePath = join(dir, STATE_PATH);\n // An omitted profile/harness-list/autoOpen means \"no new decision\", not\n // \"clear it\": preserve whatever is already persisted so call sites that only\n // refresh version/hashes can never silently strip a saved choice.\n const existing = readVersion(dir);\n const profile = gitignoreProfile ?? existing?.gitignoreProfile;\n const selectedHarnesses = harnesses ?? existing?.harnesses;\n const openSetting = autoOpen ?? existing?.autoOpen;\n // Unknown keys survive rewrites (D12): a newer Joycraft may have stamped\n // fields this version doesn't know about. Known keys are stripped from the\n // raw pass-through so the sanitized values above stay authoritative.\n let unknownKeys: Record<string, unknown> = {};\n if (existsSync(filePath)) {\n try {\n const raw = JSON.parse(readFileSync(filePath, 'utf-8'));\n if (raw && typeof raw === 'object' && !Array.isArray(raw)) {\n const {\n version: _v,\n files: _f,\n gitignoreProfile: _g,\n harnesses: _h,\n autoOpen: _a,\n ...rest\n } = raw as Record<string, unknown>;\n unknownKeys = rest;\n }\n } catch {\n // Unreadable state is rewritten from scratch — same as readVersion's null.\n }\n }\n // Store truncated hashes — single source of truth for the on-disk shape.\n const truncated: Record<string, string> = {};\n for (const [path, hash] of Object.entries(files)) {\n truncated[path] = truncateHash(hash);\n }\n const data: VersionInfo = {\n version,\n files: truncated,\n ...(profile ? { gitignoreProfile: profile } : {}),\n ...(selectedHarnesses ? { harnesses: selectedHarnesses } : {}),\n ...(openSetting !== undefined ? { autoOpen: openSetting } : {}),\n ...unknownKeys,\n };\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, JSON.stringify(data, null, 2) + '\\n', 'utf-8');\n}\n\n/**\n * The persisted auto-open setting for gate HTML renders. Missing state file or\n * missing/invalid key both mean true — auto-open was unconditional before the\n * setting existed, and that stays the default.\n */\nexport function getAutoOpen(dir: string): boolean {\n return readVersion(dir)?.autoOpen ?? true;\n}\n\n/**\n * Detect the current Joycraft harness level for a project directory.\n * Returns 5 if Level 5 artifacts (autofix workflow + External Validation) are present, 4 otherwise.\n */\nexport function getLevel(dir: string): number {\n const hasAutofix = existsSync(join(dir, '.github', 'workflows', 'autofix.yml'));\n if (!hasAutofix) return 4;\n const claudeMdPath = join(dir, 'CLAUDE.md');\n if (!existsSync(claudeMdPath)) return 4;\n const content = readFileSync(claudeMdPath, 'utf-8');\n return content.includes('## External Validation') ? 5 : 4;\n}\n","import { createInterface } from 'node:readline';\n\n/**\n * The AI coding harnesses Joycraft can install into a project. Each maps to a\n * config dir:\n * - claude → .claude/ (Claude Code)\n * - codex → .agents/ (OpenAI Codex)\n * - pi → .pi/ (Pi)\n * - copilot → .github/ (GitHub Copilot)\n * - omp → .omp/ (Oh My Pi)\n *\n * Single source of truth: the menu, the parser, and the install gates in\n * init.ts all derive from this list so a new harness can't leave a path stale.\n */\nexport const HARNESSES = ['claude', 'codex', 'pi', 'copilot', 'omp'] as const;\nexport type Harness = (typeof HARNESSES)[number];\n\n/** Human-readable one-liner per harness, shown in the interactive menu. */\nconst HARNESS_LABELS: Record<Harness, string> = {\n claude: 'Claude Code (.claude/)',\n codex: 'OpenAI Codex (.agents/)',\n pi: 'Pi (.pi/)',\n copilot: 'GitHub Copilot (.github/)',\n omp: 'Oh My Pi (.omp/)',\n};\n\nfunction isHarness(value: string): value is Harness {\n return (HARNESSES as readonly string[]).includes(value);\n}\n\n/**\n * Sanitize an arbitrary value (e.g. parsed from state.json) into a harness list,\n * dropping anything unrecognized rather than rejecting the whole list — old or\n * hand-edited state must degrade gracefully. Returns null when the input isn't\n * an array at all (caller treats null as \"no recorded selection\"). Order follows\n * the canonical HARNESSES order and is deduped.\n */\nexport function sanitizeHarnesses(value: unknown): Harness[] | null {\n if (!Array.isArray(value)) return null;\n const present = new Set(\n value.filter((v): v is string => typeof v === 'string').map((v) => v.trim().toLowerCase())\n );\n return HARNESSES.filter((h) => present.has(h));\n}\n\n/**\n * Parse a comma/space-separated answer into a deduped, validated harness list.\n * Returns null when any token is unrecognized so the caller can re-ask rather\n * than silently dropping a typo. An empty answer yields an empty array (the\n * \"install nothing\" case the caller handles explicitly).\n */\nexport function parseHarnessSelection(answer: string): Harness[] | null {\n const tokens = answer\n .split(/[,\\s]+/)\n .map((t) => t.trim().toLowerCase())\n .filter((t) => t.length > 0);\n\n // \"all\" is a convenience alias for every harness.\n if (tokens.length === 1 && tokens[0] === 'all') {\n return [...HARNESSES];\n }\n\n const selected: Harness[] = [];\n for (const token of tokens) {\n if (!isHarness(token)) return null;\n if (!selected.includes(token)) selected.push(token);\n }\n return selected;\n}\n\n/**\n * Interactive multi-select for which harnesses to install. An empty answer is a\n * deliberate \"none\" — the caller prints the run-again message and bails. An\n * unrecognized token re-asks instead of being coerced.\n */\nasync function promptHarnesses(): Promise<Harness[]> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n console.log('\\nWhich AI harnesses should Joycraft install?');\n for (const h of HARNESSES) {\n console.log(` ${h.padEnd(7)} — ${HARNESS_LABELS[h]}`);\n }\n return new Promise((resolve) => {\n const ask = (): void => {\n rl.question('Harnesses [comma-separated, or \"all\"] (none): ', (answer) => {\n const parsed = parseHarnessSelection(answer);\n if (parsed !== null) {\n rl.close();\n resolve(parsed);\n return;\n }\n console.log(\n `Unrecognized harness in '${answer.trim()}' — choose from ${HARNESSES.join(', ')} (comma-separated), or leave empty for none.`\n );\n ask();\n });\n };\n ask();\n });\n}\n\n/**\n * Resolve which harnesses to install:\n * - interactive (TTY): show the multi-select menu; honor an empty \"none\"\n * - non-interactive: install all available harnesses, preserving long-standing init behavior\n * for scripted/CI runs that can't answer a prompt.\n */\nexport async function resolveHarnesses(interactive: boolean): Promise<Harness[]> {\n if (interactive) {\n return promptHarnesses();\n }\n return [...HARNESSES];\n}\n"],"mappings":";;;AAAA,SAAS,cAAc,eAAe,YAAY,iBAAiB;AACnE,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;;;ACF3B,SAAS,uBAAuB;AAczB,IAAM,YAAY,CAAC,UAAU,SAAS,MAAM,WAAW,KAAK;AAInE,IAAM,iBAA0C;AAAA,EAC9C,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,KAAK;AACP;AAEA,SAAS,UAAU,OAAiC;AAClD,SAAQ,UAAgC,SAAS,KAAK;AACxD;AASO,SAAS,kBAAkB,OAAkC;AAClE,MAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO;AAClC,QAAM,UAAU,IAAI;AAAA,IAClB,MAAM,OAAO,CAAC,MAAmB,OAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC;AAAA,EAC3F;AACA,SAAO,UAAU,OAAO,CAAC,MAAM,QAAQ,IAAI,CAAC,CAAC;AAC/C;AAQO,SAAS,sBAAsB,QAAkC;AACtE,QAAM,SAAS,OACZ,MAAM,QAAQ,EACd,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EACjC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC;AAG7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irSync } from "fs";
5
- import { join } from "path";
6
- var FOLDER_MAP_OPEN = "<!-- joycraft:folder-map -->";
7
- var FOLDER_MAP_CLOSE = "<!-- /joycraft:folder-map -->";
8
- var FOLDER_MAP_PLACEHOLDER = "_TODO: one line on what lives here_";
9
- var MAX_ROWS = 30;
10
- var SKIPPED_DIRS = /* @__PURE__ */ new Set([
11
- "node_modules",
12
- "dist",
13
- "build",
14
- "out",
15
- "coverage",
16
- "target",
17
- "vendor",
18
- "__pycache__",
19
- "venv",
20
- ".venv",
21
- "tmp",
22
- "temp"
23
- ]);
24
- var KEY_PARENTS = /* @__PURE__ */ new Set(["src", "docs"]);
25
- var KNOWN_DESCRIPTIONS = {
26
- "src/": "Source code",
27
- "docs/": "Documentation",
28
- "tests/": "Test suite",
29
- "test/": "Test suite",
30
- "scripts/": "Maintenance and build scripts",
31
- "templates/": "Templates",
32
- "public/": "Static assets served as-is",
33
- "assets/": "Static assets",
34
- "examples/": "Usage examples",
35
- "packages/": "Monorepo packages",
36
- "apps/": "Monorepo applications",
37
- "config/": "Configuration",
38
- "docs/context/": "Knowledge layer \u2014 operational fact-docs and reference",
39
- "docs/features/": "Per-feature briefs, designs, and atomic specs",
40
- "docs/discoveries/": "Session surprises worth remembering",
41
- "docs/templates/": "Bundled output and reference templates",
42
- "docs/backlog/": "Deferred work, one file per item",
43
- "docs/research/": "Research notes and findings"
44
- };
45
- function listDirs(dir) {
46
- try {
47
- return readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".") && !SKIPPED_DIRS.has(e.name)).map((e) => e.name).sort();
48
- } catch {
49
- return [];
50
- }
51
- }
52
- function walkFolders(dir) {
53
- const tops = listDirs(dir);
54
- const folders = tops.map((top) => `${top}/`);
55
- for (const top of tops) {
56
- if (KEY_PARENTS.has(top)) {
57
- for (const sub of listDirs(join(dir, top))) {
58
- folders.push(`${top}/${sub}/`);
59
- }
60
- }
61
- }
62
- const capped = folders.length > MAX_ROWS;
63
- return { folders: capped ? folders.slice(0, MAX_ROWS) : folders, capped };
64
- }
65
- function parseRows(block) {
66
- const rows = /* @__PURE__ */ new Map();
67
- for (const line of block.split("\n")) {
68
- const match = line.match(/^\| `([^`]+)` \| (.*) \|$/);
69
- if (match) rows.set(match[1], match[2]);
70
- }
71
- return rows;
72
- }
73
- function renderFolderMap(dir, existingBlock) {
74
- const { folders, capped } = walkFolders(dir);
75
- const previous = existingBlock ? parseRows(existingBlock) : /* @__PURE__ */ new Map();
76
- const lines = [FOLDER_MAP_OPEN, "| Folder | What lives here |", "|--------|-----------------|"];
77
- for (const folder of folders) {
78
- const description = previous.get(folder) ?? KNOWN_DESCRIPTIONS[folder] ?? FOLDER_MAP_PLACEHOLDER;
79
- lines.push(`| \`${folder}\` | ${description} |`);
80
- }
81
- if (capped) {
82
- lines.push("", `_Capped at ${MAX_ROWS} rows \u2014 this tree is past root-map scale; use the growth path below._`);
83
- }
84
- lines.push(
85
- "",
86
- "Past multi-team scale, replace this root map with nested per-directory instruction files (`joycraft-collaborative-setup`) \u2014 never a bigger tree.",
87
- FOLDER_MAP_CLOSE
88
- );
89
- return lines.join("\n");
90
- }
91
- var BLOCK_RE = new RegExp(`${FOLDER_MAP_OPEN}[\\s\\S]*?${FOLDER_MAP_CLOSE}`);
92
- function ensureFolderMapSection(markdown, dir) {
93
- const existingBlock = markdown.match(BLOCK_RE)?.[0];
94
- if (existingBlock) {
95
- return markdown.replace(BLOCK_RE, renderFolderMap(dir, existingBlock));
96
- }
97
- if (/^## .*architecture/im.test(markdown)) return markdown;
98
- return `${markdown.trimEnd()}
99
-
100
- ## Architecture
101
-
102
- ${renderFolderMap(dir)}
103
- `;
104
- }
105
-
106
- // src/execution-profile.ts
107
- import { createInterface } from "readline";
108
- var EXECUTION_PROFILE_OPEN = "<!-- joycraft:execution-profile -->";
109
- var EXECUTION_PROFILE_CLOSE = "<!-- /joycraft:execution-profile -->";
110
- var EXECUTION_PROFILE_HEADING = "## Execution Profile";
111
- var SESSION_DEFAULT = "session default";
112
- function defaultExecutionProfile(harnesses) {
113
- return {
114
- entries: harnesses.map((harness) => ({
115
- harness,
116
- swarmDecompose: false,
117
- swarmImplement: false,
118
- model: SESSION_DEFAULT,
119
- effort: SESSION_DEFAULT
120
- }))
121
- };
122
- }
123
- function yn(value) {
124
- return value ? "yes" : "no";
125
- }
126
- function hasExecutionProfile(content) {
127
- return content.includes(EXECUTION_PROFILE_OPEN);
128
- }
129
- function renderExecutionProfileSection(profile) {
130
- const lines = [EXECUTION_PROFILE_HEADING, "", EXECUTION_PROFILE_OPEN];
131
- for (const e of profile.entries) {
132
- lines.push(
133
- `- ${e.harness}: Swarms: decompose ${yn(e.swarmDecompose)} \xB7 implement ${yn(e.swarmImplement)} \xB7 model ${e.model} \xB7 effort ${e.effort}`
134
- );
135
- }
136
- lines.push(EXECUTION_PROFILE_CLOSE);
137
- return lines.join("\n");
138
- }
139
- function ensureExecutionProfileSection(existing, profile) {
140
- if (!profile || hasExecutionProfile(existing)) return existing;
141
- return existing.trimEnd() + "\n\n" + renderExecutionProfileSection(profile) + "\n";
142
- }
143
- function ask(question) {
144
- return new Promise((resolve) => {
145
- const input = process.stdin;
146
- if (input.readableEnded === true || input.destroyed === true) {
147
- resolve("");
148
- return;
149
- }
150
- const rl = createInterface({ input, output: process.stdout });
151
- let settled = false;
152
- const done = (value) => {
153
- if (settled) return;
154
- settled = true;
155
- rl.close();
156
- resolve(value);
157
- };
158
- rl.once("close", () => done(""));
159
- try {
160
- rl.question(question, (answer) => done(answer.trim()));
161
- } catch {
162
- done("");
163
- }
164
- });
165
- }
166
- async function askYesNo(question) {
167
- for (let attempt = 0; attempt < 5; attempt++) {
168
- const answer = (await ask(`${question} [y/N]: `)).toLowerCase();
169
- if (answer === "" || answer === "n" || answer === "no") return false;
170
- if (answer === "y" || answer === "yes") return true;
171
- console.log("Please answer 'y' or 'n'.");
172
- }
173
- return false;
174
- }
175
- async function promptExecutionProfileInteractive(harnesses) {
176
- console.log("\nExecution profile \u2014 how should agents run on this project?");
177
- console.log(" (Recorded in AGENTS.md as data. Press Enter to accept the default.)");
178
- const entries = [];
179
- for (const harness of harnesses) {
180
- console.log(`
181
- ${harness}:`);
182
- const swarmDecompose = await askYesNo(" Use swarms for decompose?");
183
- const swarmImplement = await askYesNo(" Use swarms for implement?");
184
- const model = await ask(` Model (${SESSION_DEFAULT}): `) || SESSION_DEFAULT;
185
- const effort = await ask(` Effort (${SESSION_DEFAULT}): `) || SESSION_DEFAULT;
186
- entries.push({ harness, swarmDecompose, swarmImplement, model, effort });
187
- }
188
- return { entries };
189
- }
190
- async function resolveExecutionProfile(harnesses, interactive) {
191
- if (harnesses.length === 0) return { entries: [] };
192
- if (interactive) return promptExecutionProfileInteractive(harnesses);
193
- return defaultExecutionProfile(harnesses);
194
- }
195
-
196
- // src/gitattributes.ts
197
- import { existsSync, readFileSync, writeFileSync } from "fs";
198
- import { join as join2 } from "path";
199
- var GITATTRIBUTES_COMMENT = "# Joycraft: collapse generated workflow docs in PR review (expand with one click)";
200
- var GITATTRIBUTES_ENTRIES = [
201
- "docs/features/** linguist-generated=true",
202
- "docs/bugfixes/** linguist-generated=true",
203
- "docs/discoveries/** linguist-generated=true",
204
- "docs/templates/** linguist-generated=true"
205
- ];
206
- function applyGitattributes(targetDir) {
207
- const gitattributesPath = join2(targetDir, ".gitattributes");
208
- const current = existsSync(gitattributesPath) ? readFileSync(gitattributesPath, "utf-8") : "";
209
- const present = new Set(current.split("\n").map((l) => l.trim()));
210
- const missing = GITATTRIBUTES_ENTRIES.filter((e) => !present.has(e.trim()));
211
- if (missing.length === 0) return [];
212
- const lines = present.has(GITATTRIBUTES_COMMENT) ? missing : [GITATTRIBUTES_COMMENT, ...missing];
213
- const sep = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
214
- writeFileSync(gitattributesPath, current + sep + lines.join("\n") + "\n", "utf-8");
215
- return missing;
216
- }
217
-
218
- // src/package-version.ts
219
- import { readFileSync as readFileSync2 } from "fs";
220
- import { fileURLToPath } from "url";
221
- import { dirname, join as join3 } from "path";
222
- var __dirname = dirname(fileURLToPath(import.meta.url));
223
- function getPackageVersion() {
224
- const pkgPath = join3(__dirname, "..", "package.json");
225
- const raw = readFileSync2(pkgPath, "utf-8");
226
- const pkg = JSON.parse(raw);
227
- if (typeof pkg.version !== "string" || pkg.version.length === 0) {
228
- throw new Error(`Joycraft package.json at ${pkgPath} is missing a version field`);
229
- }
230
- return pkg.version;
231
- }
232
-
233
- export {
234
- renderFolderMap,
235
- ensureFolderMapSection,
236
- defaultExecutionProfile,
237
- renderExecutionProfileSection,
238
- ensureExecutionProfileSection,
239
- resolveExecutionProfile,
240
- applyGitattributes,
241
- getPackageVersion
242
- };
243
- //# sourceMappingURL=chunk-Q2ZQ6RGD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/folder-map.ts","../src/execution-profile.ts","../src/gitattributes.ts","../src/package-version.ts"],"sourcesContent":["// Check-shaped folder map (D6).\n//\n// The generated architecture section is derived from the real filesystem\n// instead of a hand-maintained tree: a pure walk emits top-level folders (plus\n// key subfolders) with one-line descriptions inside sentinel markers, so init\n// and upgrade can regenerate structure while preserving human wording, and\n// tune can diff the doc against the tree and report drift instead of letting a\n// stale map mislead an agent.\n\nimport { readdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport const FOLDER_MAP_OPEN = '<!-- joycraft:folder-map -->';\nexport const FOLDER_MAP_CLOSE = '<!-- /joycraft:folder-map -->';\nexport const FOLDER_MAP_PLACEHOLDER = '_TODO: one line on what lives here_';\n\n/** Row cap — past this scale the answer is nested instruction files, not a bigger map. */\nconst MAX_ROWS = 30;\n\n/** Dirs that are dependency, build-output, VCS, or cache noise — never mapped. */\nconst SKIPPED_DIRS = new Set([\n 'node_modules', 'dist', 'build', 'out', 'coverage', 'target', 'vendor',\n '__pycache__', 'venv', '.venv', 'tmp', 'temp',\n]);\n\n/** Top-level dirs whose immediate subfolders are worth a row of their own. */\nconst KEY_PARENTS = new Set(['src', 'docs']);\n\n/** Descriptions the generator can actually know — everything else gets the placeholder. */\nconst KNOWN_DESCRIPTIONS: Record<string, string> = {\n 'src/': 'Source code',\n 'docs/': 'Documentation',\n 'tests/': 'Test suite',\n 'test/': 'Test suite',\n 'scripts/': 'Maintenance and build scripts',\n 'templates/': 'Templates',\n 'public/': 'Static assets served as-is',\n 'assets/': 'Static assets',\n 'examples/': 'Usage examples',\n 'packages/': 'Monorepo packages',\n 'apps/': 'Monorepo applications',\n 'config/': 'Configuration',\n 'docs/context/': 'Knowledge layer — operational fact-docs and reference',\n 'docs/features/': 'Per-feature briefs, designs, and atomic specs',\n 'docs/discoveries/': 'Session surprises worth remembering',\n 'docs/templates/': 'Bundled output and reference templates',\n 'docs/backlog/': 'Deferred work, one file per item',\n 'docs/research/': 'Research notes and findings',\n};\n\nfunction listDirs(dir: string): string[] {\n try {\n return readdirSync(dir, { withFileTypes: true })\n .filter((e) => e.isDirectory() && !e.name.startsWith('.') && !SKIPPED_DIRS.has(e.name))\n .map((e) => e.name)\n .sort();\n } catch {\n return [];\n }\n}\n\n/** Folder paths (POSIX, trailing slash) the map covers, deterministic for a given tree. */\nexport function walkFolders(dir: string): { folders: string[]; capped: boolean } {\n // Top-level folders first, then key subfolders — so a cap cuts depth, never breadth.\n const tops = listDirs(dir);\n const folders = tops.map((top) => `${top}/`);\n for (const top of tops) {\n if (KEY_PARENTS.has(top)) {\n for (const sub of listDirs(join(dir, top))) {\n folders.push(`${top}/${sub}/`);\n }\n }\n }\n const capped = folders.length > MAX_ROWS;\n return { folders: capped ? folders.slice(0, MAX_ROWS) : folders, capped };\n}\n\nfunction parseRows(block: string): Map<string, string> {\n const rows = new Map<string, string>();\n for (const line of block.split('\\n')) {\n const match = line.match(/^\\| `([^`]+)` \\| (.*) \\|$/);\n if (match) rows.set(match[1], match[2]);\n }\n return rows;\n}\n\n/**\n * The sentinel-delimited map block. When `existingBlock` is given, human\n * descriptions for surviving folders are preserved — the machine owns\n * structure, the human owns wording.\n */\nexport function renderFolderMap(dir: string, existingBlock?: string): string {\n const { folders, capped } = walkFolders(dir);\n const previous = existingBlock ? parseRows(existingBlock) : new Map<string, string>();\n\n const lines = [FOLDER_MAP_OPEN, '| Folder | What lives here |', '|--------|-----------------|'];\n for (const folder of folders) {\n const description = previous.get(folder) ?? KNOWN_DESCRIPTIONS[folder] ?? FOLDER_MAP_PLACEHOLDER;\n lines.push(`| \\`${folder}\\` | ${description} |`);\n }\n if (capped) {\n lines.push('', `_Capped at ${MAX_ROWS} rows — this tree is past root-map scale; use the growth path below._`);\n }\n lines.push(\n '',\n 'Past multi-team scale, replace this root map with nested per-directory instruction files (`joycraft-collaborative-setup`) — never a bigger tree.',\n FOLDER_MAP_CLOSE,\n );\n return lines.join('\\n');\n}\n\nconst BLOCK_RE = new RegExp(`${FOLDER_MAP_OPEN}[\\\\s\\\\S]*?${FOLDER_MAP_CLOSE}`);\n\n/**\n * Regenerate the map block in place (preserving human wording), or append an\n * `## Architecture` section carrying it when the document has none. A\n * hand-written architecture section without markers is user prose — untouched.\n */\nexport function ensureFolderMapSection(markdown: string, dir: string): string {\n const existingBlock = markdown.match(BLOCK_RE)?.[0];\n if (existingBlock) {\n return markdown.replace(BLOCK_RE, renderFolderMap(dir, existingBlock));\n }\n if (/^## .*architecture/im.test(markdown)) return markdown;\n return `${markdown.trimEnd()}\\n\\n## Architecture\\n\\n${renderFolderMap(dir)}\\n`;\n}\n\n/**\n * Structure-only drift between the document's map block and the real tree —\n * description wording (including unfilled placeholders) never counts as drift.\n * Null when the document carries no map block.\n */\nexport function diffFolderMap(markdown: string, dir: string): { added: string[]; removed: string[] } | null {\n const block = markdown.match(BLOCK_RE)?.[0];\n if (!block) return null;\n const documented = new Set(parseRows(block).keys());\n const actual = new Set(walkFolders(dir).folders);\n return {\n added: [...actual].filter((f) => !documented.has(f)),\n removed: [...documented].filter((f) => !actual.has(f)),\n };\n}\n","import { createInterface } from 'node:readline';\nimport type { Harness } from './harness.js';\n\n/**\n * The per-project **Execution Profile** (decision D6 of the succinct-gates\n * feature): which harness agents may fan out into swarms, and which model +\n * effort those agents should run at.\n *\n * It lives in exactly one home — a sentinel-delimited `## Execution Profile`\n * section in AGENTS.md. No state.json mirror: the profile is team-shared data\n * the human owns and hand-edits, and two homes for one fact violate ONE_HOME.\n *\n * It is **data only**. Nothing here recommends a model, ranks tiers, or routes\n * a stage to an agent — opinionated defaults stay in the backlogged\n * model-tiering feature (`docs/backlog/2026-07-20-model-tiering.md`, D7).\n * That is also why model and effort are free text: model names age faster than\n * Joycraft releases, so an enum here would be wrong within a minor version.\n */\n\n/** Opening sentinel — the only machine contract; everything inside is user-owned. */\nexport const EXECUTION_PROFILE_OPEN = '<!-- joycraft:execution-profile -->';\n/** Closing sentinel. */\nexport const EXECUTION_PROFILE_CLOSE = '<!-- /joycraft:execution-profile -->';\n\n/** The markdown heading the section is written under. */\nexport const EXECUTION_PROFILE_HEADING = '## Execution Profile';\n\n/**\n * The value written for model/effort when nobody was asked (non-interactive\n * init). Deliberately not a model name — it tells downstream skills \"use\n * whatever the session is already running\", which is the only answer that\n * can't go stale.\n */\nexport const SESSION_DEFAULT = 'session default';\n\nexport interface ExecutionProfileEntry {\n harness: Harness;\n /** Fan out to a swarm of subagents during `/joycraft-decompose`? */\n swarmDecompose: boolean;\n /** Fan out to a swarm of subagents during `/joycraft-implement`? */\n swarmImplement: boolean;\n /** Free-text model name, or SESSION_DEFAULT. Never validated against a list. */\n model: string;\n /** Free-text reasoning effort, or SESSION_DEFAULT. */\n effort: string;\n}\n\nexport interface ExecutionProfile {\n entries: ExecutionProfileEntry[];\n}\n\n/**\n * The profile written when nobody could be asked: skipping is first-class, so\n * the section is still written — with explicit \"no\" answers — rather than being\n * omitted. Downstream skills then read an explicit answer, never an absence.\n */\nexport function defaultExecutionProfile(harnesses: readonly Harness[]): ExecutionProfile {\n return {\n entries: harnesses.map((harness) => ({\n harness,\n swarmDecompose: false,\n swarmImplement: false,\n model: SESSION_DEFAULT,\n effort: SESSION_DEFAULT,\n })),\n };\n}\n\nfunction yn(value: boolean): string {\n return value ? 'yes' : 'no';\n}\n\n/** True when the document already carries a profile region (matched on the sentinel, not the heading). */\nexport function hasExecutionProfile(content: string): boolean {\n return content.includes(EXECUTION_PROFILE_OPEN);\n}\n\n/**\n * Render the section. One line per selected harness, so a single-harness\n * project never sees rows it didn't ask for.\n */\nexport function renderExecutionProfileSection(profile: ExecutionProfile): string {\n const lines: string[] = [EXECUTION_PROFILE_HEADING, '', EXECUTION_PROFILE_OPEN];\n for (const e of profile.entries) {\n lines.push(\n `- ${e.harness}: Swarms: decompose ${yn(e.swarmDecompose)} · implement ${yn(e.swarmImplement)} · model ${e.model} · effort ${e.effort}`\n );\n }\n lines.push(EXECUTION_PROFILE_CLOSE);\n return lines.join('\\n');\n}\n\n/**\n * Insert the section into an existing document when absent; return the document\n * untouched when a profile is already there. The sentinels make the region\n * opaque — a hand-edit inside them (even a malformed one) is preserved verbatim,\n * because the content is the user's data, not our schema (D7).\n */\nexport function ensureExecutionProfileSection(\n existing: string,\n profile: ExecutionProfile | undefined\n): string {\n if (!profile || hasExecutionProfile(existing)) return existing;\n return existing.trimEnd() + '\\n\\n' + renderExecutionProfileSection(profile) + '\\n';\n}\n\n/**\n * Ask one question, following the one-interface-per-prompt idiom the rest of\n * the CLI uses (`harness.ts`, `gitignore.ts`): open readline, ask, close.\n *\n * EOF matters more here than for those one-shot prompts, because this\n * interview asks several questions in a row: a stdin that runs out mid-way\n * (piped input, a redirect, Ctrl-D) must degrade every remaining question to\n * its stated default rather than hang or throw. Configuration questions never\n * abort an init.\n */\nfunction ask(question: string): Promise<string> {\n return new Promise((resolve) => {\n const input = process.stdin;\n // A stream that already ended emits no further 'close' on a *new* readline\n // interface, so the close-guard below never fires and the question hangs\n // forever. Detect the spent stream up front instead: this is the path a\n // short piped answer list takes once it runs out, and every remaining\n // question must degrade to its default rather than block the init.\n if (input.readableEnded === true || input.destroyed === true) {\n resolve('');\n return;\n }\n const rl = createInterface({ input, output: process.stdout });\n let settled = false;\n const done = (value: string): void => {\n if (settled) return;\n settled = true;\n rl.close();\n resolve(value);\n };\n rl.once('close', () => done(''));\n try {\n rl.question(question, (answer) => done(answer.trim()));\n } catch {\n done('');\n }\n });\n}\n\nasync function askYesNo(question: string): Promise<boolean> {\n for (let attempt = 0; attempt < 5; attempt++) {\n const answer = (await ask(`${question} [y/N]: `)).toLowerCase();\n if (answer === '' || answer === 'n' || answer === 'no') return false;\n if (answer === 'y' || answer === 'yes') return true;\n console.log(\"Please answer 'y' or 'n'.\");\n }\n // Repeated unparseable input (or a closed stream): take the default rather\n // than looping forever.\n return false;\n}\n\n/**\n * Interactive capture, one small block per selected harness. Follows the\n * harness-selection idiom in `harness.ts`: same readline interface, empty\n * answer means the stated default, unrecognized input re-asks.\n */\nasync function promptExecutionProfileInteractive(\n harnesses: readonly Harness[]\n): Promise<ExecutionProfile> {\n console.log('\\nExecution profile — how should agents run on this project?');\n console.log(' (Recorded in AGENTS.md as data. Press Enter to accept the default.)');\n const entries: ExecutionProfileEntry[] = [];\n for (const harness of harnesses) {\n console.log(`\\n ${harness}:`);\n const swarmDecompose = await askYesNo(' Use swarms for decompose?');\n const swarmImplement = await askYesNo(' Use swarms for implement?');\n const model = (await ask(` Model (${SESSION_DEFAULT}): `)) || SESSION_DEFAULT;\n const effort = (await ask(` Effort (${SESSION_DEFAULT}): `)) || SESSION_DEFAULT;\n entries.push({ harness, swarmDecompose, swarmImplement, model, effort });\n }\n return { entries };\n}\n\n/**\n * Resolve the profile for an init run:\n * - interactive (TTY): ask per selected harness\n * - non-interactive: the explicit-no default — never blocks a scripted run\n */\nexport async function resolveExecutionProfile(\n harnesses: readonly Harness[],\n interactive: boolean\n): Promise<ExecutionProfile> {\n if (harnesses.length === 0) return { entries: [] };\n if (interactive) return promptExecutionProfileInteractive(harnesses);\n return defaultExecutionProfile(harnesses);\n}\n","import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Paths Joycraft marks `linguist-generated=true` so GitHub collapses them in\n * PR review and drops them from diff stats. These are workflow exhaust —\n * briefs, specs, discoveries, installed templates — historical artifacts by\n * the time a PR is opened (the spec was reviewed conversationally when it was\n * written). Reviewers can still expand any of them with one click.\n *\n * Deliberately NOT listed (durable knowledge that deserves review eyes):\n * CLAUDE.md, AGENTS.md, docs/context/ (steers every future agent run), and\n * docs/backlog/ (human-authored idea capture).\n */\nexport const GITATTRIBUTES_COMMENT =\n '# Joycraft: collapse generated workflow docs in PR review (expand with one click)';\n\nexport const GITATTRIBUTES_ENTRIES = [\n 'docs/features/** linguist-generated=true',\n 'docs/bugfixes/** linguist-generated=true',\n 'docs/discoveries/** linguist-generated=true',\n 'docs/templates/** linguist-generated=true',\n];\n\n/**\n * Append-only, create-if-absent, idempotent .gitattributes writer — the same\n * contract as ensureGitignoreEntries: never rewrites, reorders, or removes\n * existing lines; only appends entries not already present (matched exactly,\n * after trimming). The comment header is only added when at least one entry\n * is missing, so a fully-applied file is never touched. Returns the entries\n * actually added (empty when everything was already present).\n */\nexport function applyGitattributes(targetDir: string): string[] {\n const gitattributesPath = join(targetDir, '.gitattributes');\n const current = existsSync(gitattributesPath) ? readFileSync(gitattributesPath, 'utf-8') : '';\n const present = new Set(current.split('\\n').map((l) => l.trim()));\n const missing = GITATTRIBUTES_ENTRIES.filter((e) => !present.has(e.trim()));\n if (missing.length === 0) return [];\n\n const lines = present.has(GITATTRIBUTES_COMMENT) ? missing : [GITATTRIBUTES_COMMENT, ...missing];\n const sep = current.length > 0 && !current.endsWith('\\n') ? '\\n' : '';\n writeFileSync(gitattributesPath, current + sep + lines.join('\\n') + '\\n', 'utf-8');\n return missing;\n}\n","import { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport function getPackageVersion(): string {\n const pkgPath = join(__dirname, '..', 'package.json');\n const raw = readFileSync(pkgPath, 'utf-8');\n const pkg = JSON.parse(raw) as { version?: unknown };\n if (typeof pkg.version !== 'string' || pkg.version.length === 0) {\n throw new Error(`Joycraft package.json at ${pkgPath} is missing a version field`);\n }\n return pkg.version;\n}\n"],"mappings":";;;AASA,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AAEd,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,yBAAyB;AAGtC,IAAM,WAAW;AAGjB,IAAM,eAAe,oBAAI,IAAI;AAAA,EAC3B;AAAA,EAAgB;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAO;AAAA,EAAY;AAAA,EAAU;AAAA,EAC9D;AAAA,EAAe;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAO;AACzC,CAAC;AAGD,IAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,MAAM,CAAC;AAG3C,IAAM,qBAA6C;AAAA,EACjD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,kBAAkB;AACpB;AAEA,SAAS,SAAS,KAAuB;AACvC,MAAI;AACF,WAAO,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,EAC5C,OAAO,CAAC,MAAM,EAAE,YAAY,KAAK,CAAC,EAAE,KAAK,WAAW,GAAG,KAAK,CAAC,aAAa,IAAI,EAAE,IAAI,CAAC,EACrF,IAAI,CAAC,MAAM,EAAE,IAAI,EACjB,KAAK;AAAA,EACV,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAGO,SAAS,YAAY,KAAqD;AAE/E,QAAM,OAAO,SAAS,GAAG;AACzB,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