joycraft 0.7.7 → 0.7.8
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 +58 -319
- package/dist/{chunk-VSBOHF5Z.js → chunk-NYBX6MOT.js} +53 -46
- package/dist/chunk-NYBX6MOT.js.map +1 -0
- package/dist/{chunk-Q7TCWFTF.js → chunk-ONGWPA4M.js} +7 -2
- package/dist/chunk-ONGWPA4M.js.map +1 -0
- package/dist/{chunk-MADJOL4S.js → chunk-PBOICMDE.js} +32 -4
- package/dist/chunk-PBOICMDE.js.map +1 -0
- package/dist/{chunk-GLHRP5OB.js → chunk-RRMO5FBO.js} +2 -2
- package/dist/cli.js +6 -6
- package/dist/{init-P676ZJ4V.js → init-XX3MY75H.js} +5 -5
- package/dist/{init-autofix-V42FDZBV.js → init-autofix-K5VZEKO2.js} +3 -3
- package/dist/{upgrade-XMMV42TF.js → upgrade-WVKG2UHF.js} +5 -5
- package/dist/{version-I5I772X6.js → version-B2CCAEMC.js} +4 -2
- package/package.json +1 -1
- package/dist/chunk-MADJOL4S.js.map +0 -1
- package/dist/chunk-Q7TCWFTF.js.map +0 -1
- package/dist/chunk-VSBOHF5Z.js.map +0 -1
- /package/dist/{chunk-GLHRP5OB.js.map → chunk-RRMO5FBO.js.map} +0 -0
- /package/dist/{init-P676ZJ4V.js.map → init-XX3MY75H.js.map} +0 -0
- /package/dist/{init-autofix-V42FDZBV.js.map → init-autofix-K5VZEKO2.js.map} +0 -0
- /package/dist/{upgrade-XMMV42TF.js.map → upgrade-WVKG2UHF.js.map} +0 -0
- /package/dist/{version-I5I772X6.js.map → version-B2CCAEMC.js.map} +0 -0
|
@@ -39,7 +39,12 @@ function ensureExecutionProfileSection(existing, profile) {
|
|
|
39
39
|
}
|
|
40
40
|
function ask(question) {
|
|
41
41
|
return new Promise((resolve) => {
|
|
42
|
-
const
|
|
42
|
+
const input = process.stdin;
|
|
43
|
+
if (input.readableEnded === true || input.destroyed === true) {
|
|
44
|
+
resolve("");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const rl = createInterface({ input, output: process.stdout });
|
|
43
48
|
let settled = false;
|
|
44
49
|
const done = (value) => {
|
|
45
50
|
if (settled) return;
|
|
@@ -130,4 +135,4 @@ export {
|
|
|
130
135
|
applyGitattributes,
|
|
131
136
|
getPackageVersion
|
|
132
137
|
};
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
138
|
+
//# sourceMappingURL=chunk-ONGWPA4M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/execution-profile.ts","../src/gitattributes.ts","../src/package-version.ts"],"sourcesContent":["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":";;;AAAA,SAAS,uBAAuB;AAoBzB,IAAM,yBAAyB;AAE/B,IAAM,0BAA0B;AAGhC,IAAM,4BAA4B;AAQlC,IAAM,kBAAkB;AAuBxB,SAAS,wBAAwB,WAAiD;AACvF,SAAO;AAAA,IACL,SAAS,UAAU,IAAI,CAAC,aAAa;AAAA,MACnC;AAAA,MACA,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,MAChB,OAAO;AAAA,MACP,QAAQ;AAAA,IACV,EAAE;AAAA,EACJ;AACF;AAEA,SAAS,GAAG,OAAwB;AAClC,SAAO,QAAQ,QAAQ;AACzB;AAGO,SAAS,oBAAoB,SAA0B;AAC5D,SAAO,QAAQ,SAAS,sBAAsB;AAChD;AAMO,SAAS,8BAA8B,SAAmC;AAC/E,QAAM,QAAkB,CAAC,2BAA2B,IAAI,sBAAsB;AAC9E,aAAW,KAAK,QAAQ,SAAS;AAC/B,UAAM;AAAA,MACJ,KAAK,EAAE,OAAO,uBAAuB,GAAG,EAA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AAO;AACnE,gBAAc,mBAAmB,UAAU,MAAM,MAAM,KAAK,IAAI,IAAI,MAAM,OAAO;AACjF,SAAO;AACT;;;AC3CA,SAAS,gBAAAA,qBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,QAAAC,aAAY;AAE9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAEjD,SAAS,oBAA4B;AAC1C,QAAM,UAAUA,MAAK,WAAW,MAAM,cAAc;AACpD,QAAM,MAAMD,cAAa,SAAS,OAAO;AACzC,QAAM,MAAM,KAAK,MAAM,GAAG;AAC1B,MAAI,OAAO,IAAI,YAAY,YAAY,IAAI,QAAQ,WAAW,GAAG;AAC/D,UAAM,IAAI,MAAM,4BAA4B,OAAO,6BAA6B;AAAA,EAClF;AACA,SAAO,IAAI;AACb;","names":["readFileSync","join"]}
|
|
@@ -96,7 +96,10 @@ function readVersion(dir) {
|
|
|
96
96
|
version: parsed.version,
|
|
97
97
|
files: parsed.files,
|
|
98
98
|
...profile ? { gitignoreProfile: profile } : {},
|
|
99
|
-
...harnesses ? { harnesses } : {}
|
|
99
|
+
...harnesses ? { harnesses } : {},
|
|
100
|
+
// Only a real boolean counts; anything else is treated as absent
|
|
101
|
+
// (and absent means true at every call site).
|
|
102
|
+
...typeof parsed.autoOpen === "boolean" ? { autoOpen: parsed.autoOpen } : {}
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
105
|
return null;
|
|
@@ -104,11 +107,30 @@ function readVersion(dir) {
|
|
|
104
107
|
return null;
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
|
-
function writeVersion(dir, version, files, gitignoreProfile, harnesses) {
|
|
110
|
+
function writeVersion(dir, version, files, gitignoreProfile, harnesses, autoOpen) {
|
|
108
111
|
const filePath = join(dir, STATE_PATH);
|
|
109
112
|
const existing = readVersion(dir);
|
|
110
113
|
const profile = gitignoreProfile ?? existing?.gitignoreProfile;
|
|
111
114
|
const selectedHarnesses = harnesses ?? existing?.harnesses;
|
|
115
|
+
const openSetting = autoOpen ?? existing?.autoOpen;
|
|
116
|
+
let unknownKeys = {};
|
|
117
|
+
if (existsSync(filePath)) {
|
|
118
|
+
try {
|
|
119
|
+
const raw = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
120
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
121
|
+
const {
|
|
122
|
+
version: _v,
|
|
123
|
+
files: _f,
|
|
124
|
+
gitignoreProfile: _g,
|
|
125
|
+
harnesses: _h,
|
|
126
|
+
autoOpen: _a,
|
|
127
|
+
...rest
|
|
128
|
+
} = raw;
|
|
129
|
+
unknownKeys = rest;
|
|
130
|
+
}
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
}
|
|
112
134
|
const truncated = {};
|
|
113
135
|
for (const [path, hash] of Object.entries(files)) {
|
|
114
136
|
truncated[path] = truncateHash(hash);
|
|
@@ -117,11 +139,16 @@ function writeVersion(dir, version, files, gitignoreProfile, harnesses) {
|
|
|
117
139
|
version,
|
|
118
140
|
files: truncated,
|
|
119
141
|
...profile ? { gitignoreProfile: profile } : {},
|
|
120
|
-
...selectedHarnesses ? { harnesses: selectedHarnesses } : {}
|
|
142
|
+
...selectedHarnesses ? { harnesses: selectedHarnesses } : {},
|
|
143
|
+
...openSetting !== void 0 ? { autoOpen: openSetting } : {},
|
|
144
|
+
...unknownKeys
|
|
121
145
|
};
|
|
122
146
|
mkdirSync(dirname(filePath), { recursive: true });
|
|
123
147
|
writeFileSync(filePath, JSON.stringify(data, null, 2) + "\n", "utf-8");
|
|
124
148
|
}
|
|
149
|
+
function getAutoOpen(dir) {
|
|
150
|
+
return readVersion(dir)?.autoOpen ?? true;
|
|
151
|
+
}
|
|
125
152
|
function getLevel(dir) {
|
|
126
153
|
const hasAutofix = existsSync(join(dir, ".github", "workflows", "autofix.yml"));
|
|
127
154
|
if (!hasAutofix) return 4;
|
|
@@ -144,6 +171,7 @@ export {
|
|
|
144
171
|
truncateHash,
|
|
145
172
|
readVersion,
|
|
146
173
|
writeVersion,
|
|
174
|
+
getAutoOpen,
|
|
147
175
|
getLevel
|
|
148
176
|
};
|
|
149
|
-
//# sourceMappingURL=chunk-
|
|
177
|
+
//# sourceMappingURL=chunk-PBOICMDE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 *\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'] 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};\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;AAazB,IAAM,YAAY,CAAC,UAAU,SAAS,MAAM,SAAS;AAI5D,IAAM,iBAA0C;AAAA,EAC9C,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,SAAS;AACX;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;AAG7B,MAAI,OAAO,WAAW,KAAK,OAAO,CAAC,MAAM,OAAO;AAC9C,WAAO,CAAC,GAAG,SAAS;AAAA,EACtB;AAEA,QAAM,WAAsB,CAAC;AAC7B,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,UAAU,KAAK,EAAG,QAAO;AAC9B,QAAI,CAAC,SAAS,SAAS,KAAK,EAAG,UAAS,KAAK,KAAK;AAAA,EACpD;AACA,SAAO;AACT;AAOA,eAAe,kBAAsC;AACnD,QAAM,KAAK,gBAAgB,EAAE,OAA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I,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,cAAU,IAAI,IAAI,aAAa,IAAI;AAAA,EACrC;AACA,QAAM,OAAoB;AAAA,IACxB;AAAA,IACA,OAAO;AAAA,IACP,GAAI,UAAU,EAAE,kBAAkB,QAAQ,IAAI,CAAC;AAAA,IAC/C,GAAI,oBAAoB,EAAE,WAAW,kBAAkB,IAAI,CAAC;AAAA,IAC5D,GAAI,gBAAgB,SAAY,EAAE,UAAU,YAAY,IAAI,CAAC;AAAA,IAC7D,GAAG;AAAA,EACL;AACA,YAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAChD,gBAAc,UAAU,KAAK,UAAU,MAAM,MAAM,CAAC,IAAI,MAAM,OAAO;AACvE;AAOO,SAAS,YAAY,KAAsB;AAChD,SAAO,YAAY,GAAG,GAAG,YAAY;AACvC;AAMO,SAAS,SAAS,KAAqB;AAC5C,QAAM,aAAa,WAAW,KAAK,KAAK,WAAW,aAAa,aAAa,CAAC;AAC9E,MAAI,CAAC,WAAY,QAAO;AACxB,QAAM,eAAe,KAAK,KAAK,WAAW;AAC1C,MAAI,CAAC,WAAW,YAAY,EAAG,QAAO;AACtC,QAAM,UAAU,aAAa,cAAc,OAAO;AAClD,SAAO,QAAQ,SAAS,wBAAwB,IAAI,IAAI;AAC1D;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
DEFAULT_GITIGNORE_PROFILE,
|
|
4
4
|
STATE_PATH,
|
|
5
5
|
parseGitignoreProfile
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PBOICMDE.js";
|
|
7
7
|
|
|
8
8
|
// src/gitignore.ts
|
|
9
9
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -84,4 +84,4 @@ export {
|
|
|
84
84
|
validateGitignoreFlag,
|
|
85
85
|
resolveGitignoreProfile
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-RRMO5FBO.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
PRIVATE_DIRS_DISPLAY
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-RRMO5FBO.js";
|
|
5
|
+
import "./chunk-PBOICMDE.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import { Command } from "commander";
|
|
@@ -15,7 +15,7 @@ var GITIGNORE_OPTION_DESC = `Gitignore profile: 'shared' (commit skills) or 'pri
|
|
|
15
15
|
var program = new Command();
|
|
16
16
|
program.name("joycraft").description("Scaffold and upgrade AI development harnesses").version(pkg.version, "-v, --version");
|
|
17
17
|
program.command("init").description("Scaffold the Joycraft harness into the current project").argument("[dir]", "Target directory", ".").option("--force", "Overwrite existing files").option("--gitignore <profile>", GITIGNORE_OPTION_DESC).action(async (dir, opts) => {
|
|
18
|
-
const { init } = await import("./init-
|
|
18
|
+
const { init } = await import("./init-XX3MY75H.js");
|
|
19
19
|
try {
|
|
20
20
|
await init(dir, { force: opts.force ?? false, gitignore: opts.gitignore });
|
|
21
21
|
} catch (err) {
|
|
@@ -24,7 +24,7 @@ program.command("init").description("Scaffold the Joycraft harness into the curr
|
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
program.command("upgrade").description("Upgrade installed Joycraft templates and skills to latest").argument("[dir]", "Target directory", ".").option("--yes", "Auto-accept all updates").option("--gitignore <profile>", GITIGNORE_OPTION_DESC).action(async (dir, opts) => {
|
|
27
|
-
const { upgrade } = await import("./upgrade-
|
|
27
|
+
const { upgrade } = await import("./upgrade-WVKG2UHF.js");
|
|
28
28
|
try {
|
|
29
29
|
await upgrade(dir, { yes: opts.yes ?? false, gitignore: opts.gitignore });
|
|
30
30
|
} catch (err) {
|
|
@@ -33,14 +33,14 @@ program.command("upgrade").description("Upgrade installed Joycraft templates and
|
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
program.command("init-autofix").description("Set up the Level 5 auto-fix loop with holdout scenarios").argument("[dir]", "Target directory", ".").option("--scenarios-repo <name>", "Name for scenarios repo").option("--app-id <id>", "GitHub App ID for Joycraft Autofix").option("--force", "Overwrite existing workflow files").option("--dry-run", "Show what would be created without creating it").action(async (dir, opts) => {
|
|
36
|
-
const { initAutofix } = await import("./init-autofix-
|
|
36
|
+
const { initAutofix } = await import("./init-autofix-K5VZEKO2.js");
|
|
37
37
|
await initAutofix(dir, opts);
|
|
38
38
|
});
|
|
39
39
|
program.command("check-version").description("Check if a newer version of Joycraft is available").action(async () => {
|
|
40
40
|
try {
|
|
41
41
|
const { readFileSync: readFileSync2, existsSync } = await import("fs");
|
|
42
42
|
const { join: join2 } = await import("path");
|
|
43
|
-
const { STATE_PATH, LEGACY_VERSION_FILE, LEGACY_CLAUDE_STATE_PATH } = await import("./version-
|
|
43
|
+
const { STATE_PATH, LEGACY_VERSION_FILE, LEGACY_CLAUDE_STATE_PATH } = await import("./version-B2CCAEMC.js");
|
|
44
44
|
const candidates = [STATE_PATH, LEGACY_CLAUDE_STATE_PATH, LEGACY_VERSION_FILE];
|
|
45
45
|
const statePath = candidates.map((p) => join2(process.cwd(), p)).find((p) => existsSync(p)) ?? join2(process.cwd(), STATE_PATH);
|
|
46
46
|
const data = JSON.parse(readFileSync2(statePath, "utf-8"));
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
getPackageVersion,
|
|
5
5
|
renderExecutionProfileSection,
|
|
6
6
|
resolveExecutionProfile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ONGWPA4M.js";
|
|
8
8
|
import {
|
|
9
9
|
PRIVATE_DIRS_DISPLAY,
|
|
10
10
|
PRIVATE_UNTRACK_COMMAND,
|
|
11
11
|
applyGitignoreProfile,
|
|
12
12
|
resolveGitignoreProfile
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RRMO5FBO.js";
|
|
14
14
|
import {
|
|
15
15
|
CODEX_SKILLS,
|
|
16
16
|
COPILOT_SKILLS,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
PI_SKILLS,
|
|
21
21
|
SKILLS,
|
|
22
22
|
TEMPLATES
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-NYBX6MOT.js";
|
|
24
24
|
import {
|
|
25
25
|
DEFAULT_GITIGNORE_PROFILE,
|
|
26
26
|
STATE_PATH,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
readVersion,
|
|
29
29
|
resolveHarnesses,
|
|
30
30
|
writeVersion
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-PBOICMDE.js";
|
|
32
32
|
|
|
33
33
|
// src/init.ts
|
|
34
34
|
import { mkdirSync as mkdirSync2, existsSync as existsSync5, writeFileSync as writeFileSync3, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync, chmodSync } from "fs";
|
|
@@ -1195,4 +1195,4 @@ function printSummary(result, stack, existingSkills = [], isPi = false, gitignor
|
|
|
1195
1195
|
export {
|
|
1196
1196
|
init
|
|
1197
1197
|
};
|
|
1198
|
-
//# sourceMappingURL=init-
|
|
1198
|
+
//# sourceMappingURL=init-XX3MY75H.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
TEMPLATES
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NYBX6MOT.js";
|
|
5
5
|
import {
|
|
6
6
|
LEGACY_VERSION_FILE,
|
|
7
7
|
STATE_PATH
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PBOICMDE.js";
|
|
9
9
|
|
|
10
10
|
// src/init-autofix.ts
|
|
11
11
|
import { mkdirSync, existsSync, writeFileSync } from "fs";
|
|
@@ -118,4 +118,4 @@ function printSummary(result, dryRun, scenariosRepo) {
|
|
|
118
118
|
export {
|
|
119
119
|
initAutofix
|
|
120
120
|
};
|
|
121
|
-
//# sourceMappingURL=init-autofix-
|
|
121
|
+
//# sourceMappingURL=init-autofix-K5VZEKO2.js.map
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
defaultExecutionProfile,
|
|
5
5
|
ensureExecutionProfileSection,
|
|
6
6
|
getPackageVersion
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ONGWPA4M.js";
|
|
8
8
|
import {
|
|
9
9
|
PRIVATE_PROFILE_IGNORES,
|
|
10
10
|
PRIVATE_UNTRACK_COMMAND,
|
|
11
11
|
applyGitignoreProfile,
|
|
12
12
|
resolveGitignoreProfile,
|
|
13
13
|
validateGitignoreFlag
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-RRMO5FBO.js";
|
|
15
15
|
import {
|
|
16
16
|
CODEX_SKILLS,
|
|
17
17
|
COPILOT_SKILLS,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
PI_SKILLS,
|
|
22
22
|
SKILLS,
|
|
23
23
|
TEMPLATES
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-NYBX6MOT.js";
|
|
25
25
|
import {
|
|
26
26
|
HARNESSES,
|
|
27
27
|
LEGACY_CLAUDE_STATE_PATH,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
sanitizeHarnesses,
|
|
33
33
|
truncateHash,
|
|
34
34
|
writeVersion
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-PBOICMDE.js";
|
|
36
36
|
|
|
37
37
|
// src/upgrade.ts
|
|
38
38
|
import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync as mkdirSync2, rmSync as rmSync2, rmdirSync, chmodSync } from "fs";
|
|
@@ -617,4 +617,4 @@ Upgrade complete: ${parts.join(", ")}.`);
|
|
|
617
617
|
export {
|
|
618
618
|
upgrade
|
|
619
619
|
};
|
|
620
|
-
//# sourceMappingURL=upgrade-
|
|
620
|
+
//# sourceMappingURL=upgrade-WVKG2UHF.js.map
|
|
@@ -4,18 +4,20 @@ import {
|
|
|
4
4
|
LEGACY_CLAUDE_STATE_PATH,
|
|
5
5
|
LEGACY_VERSION_FILE,
|
|
6
6
|
STATE_PATH,
|
|
7
|
+
getAutoOpen,
|
|
7
8
|
getLevel,
|
|
8
9
|
hashContent,
|
|
9
10
|
parseGitignoreProfile,
|
|
10
11
|
readVersion,
|
|
11
12
|
truncateHash,
|
|
12
13
|
writeVersion
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-PBOICMDE.js";
|
|
14
15
|
export {
|
|
15
16
|
DEFAULT_GITIGNORE_PROFILE,
|
|
16
17
|
LEGACY_CLAUDE_STATE_PATH,
|
|
17
18
|
LEGACY_VERSION_FILE,
|
|
18
19
|
STATE_PATH,
|
|
20
|
+
getAutoOpen,
|
|
19
21
|
getLevel,
|
|
20
22
|
hashContent,
|
|
21
23
|
parseGitignoreProfile,
|
|
@@ -23,4 +25,4 @@ export {
|
|
|
23
25
|
truncateHash,
|
|
24
26
|
writeVersion
|
|
25
27
|
};
|
|
26
|
-
//# sourceMappingURL=version-
|
|
28
|
+
//# sourceMappingURL=version-B2CCAEMC.js.map
|
package/package.json
CHANGED
|
@@ -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\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 };\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): void {\n const filePath = join(dir, STATE_PATH);\n // An omitted profile/harness-list means \"no new decision\", not \"clear it\":\n // preserve whatever is already persisted so call sites that only refresh\n // 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 // 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 };\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, JSON.stringify(data, null, 2) + '\\n', 'utf-8');\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 *\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'] 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};\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;AAazB,IAA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","../src/package-version.ts"],"sourcesContent":["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 rl = createInterface({ input: process.stdin, 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 miss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