joycraft 0.7.10 → 0.7.12

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.
@@ -0,0 +1 @@
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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js";
5
6
  import "./chunk-PBOICMDE.js";
6
7
 
7
8
  // src/cli.ts
@@ -16,7 +17,7 @@ var program = new Command();
16
17
  var suppressUpdateNudge = false;
17
18
  program.name("joycraft").description("Scaffold and upgrade AI development harnesses").version(pkg.version, "-v, --version");
18
19
  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) => {
19
- const { init } = await import("./init-OJTXCK42.js");
20
+ const { init } = await import("./init-J5Q6RX3K.js");
20
21
  try {
21
22
  await init(dir, { force: opts.force ?? false, gitignore: opts.gitignore });
22
23
  } catch (err) {
@@ -25,7 +26,7 @@ program.command("init").description("Scaffold the Joycraft harness into the curr
25
26
  }
26
27
  });
27
28
  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) => {
28
- const { upgrade } = await import("./upgrade-USXMQXG6.js");
29
+ const { upgrade } = await import("./upgrade-AHUSQZEQ.js");
29
30
  try {
30
31
  const result = await upgrade(dir, { yes: opts.yes ?? false, gitignore: opts.gitignore });
31
32
  suppressUpdateNudge = result.cliWasStale;
@@ -34,8 +35,19 @@ program.command("upgrade").description("Upgrade installed Joycraft templates and
34
35
  process.exit(1);
35
36
  }
36
37
  });
38
+ program.command("telemetry").description("Scan AI-harness transcripts into knowledge-layer read telemetry").argument("[dir]", "Target directory", ".").action(async (dir) => {
39
+ const { runTelemetryScan, formatTelemetrySummary } = await import("./telemetry-store-X7K5NYWD.js");
40
+ const { resolve } = await import("path");
41
+ try {
42
+ const result = await runTelemetryScan(resolve(dir));
43
+ console.log(formatTelemetrySummary(result));
44
+ } catch (err) {
45
+ console.error(err instanceof Error ? err.message : String(err));
46
+ process.exit(1);
47
+ }
48
+ });
37
49
  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) => {
38
- const { initAutofix } = await import("./init-autofix-LYKPMI4J.js");
50
+ const { initAutofix } = await import("./init-autofix-YCSDK5ZR.js");
39
51
  await initAutofix(dir, opts);
40
52
  });
41
53
  program.command("check-version").description("Check if a newer version of Joycraft is available").action(async () => {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { dirname, join } from 'path';\nimport { PRIVATE_DIRS_DISPLAY } from './gitignore.js';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));\n\nconst GITIGNORE_OPTION_DESC = `Gitignore profile: 'shared' (commit skills) or 'private' (gitignore ${PRIVATE_DIRS_DISPLAY})`;\n\nconst program = new Command();\n\n// Set by the upgrade action when the stale-CLI guard already delegated to (or\n// pointed the user at) the latest version — the postAction nudge would only\n// contradict the upgrade that just ran.\nlet suppressUpdateNudge = false;\n\nprogram\n .name('joycraft')\n .description('Scaffold and upgrade AI development harnesses')\n .version(pkg.version, '-v, --version');\n\nprogram\n .command('init')\n .description('Scaffold the Joycraft harness into the current project')\n .argument('[dir]', 'Target directory', '.')\n .option('--force', 'Overwrite existing files')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .action(async (dir: string, opts: { force?: boolean; gitignore?: string }) => {\n const { init } = await import('./init.js');\n try {\n await init(dir, { force: opts.force ?? false, gitignore: opts.gitignore });\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('upgrade')\n .description('Upgrade installed Joycraft templates and skills to latest')\n .argument('[dir]', 'Target directory', '.')\n .option('--yes', 'Auto-accept all updates')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .action(async (dir: string, opts: { yes?: boolean; gitignore?: string }) => {\n const { upgrade } = await import('./upgrade.js');\n try {\n const result = await upgrade(dir, { yes: opts.yes ?? false, gitignore: opts.gitignore });\n suppressUpdateNudge = result.cliWasStale;\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('init-autofix')\n .description('Set up the Level 5 auto-fix loop with holdout scenarios')\n .argument('[dir]', 'Target directory', '.')\n .option('--scenarios-repo <name>', 'Name for scenarios repo')\n .option('--app-id <id>', 'GitHub App ID for Joycraft Autofix')\n .option('--force', 'Overwrite existing workflow files')\n .option('--dry-run', 'Show what would be created without creating it')\n .action(async (dir: string, opts: { scenariosRepo?: string; appId?: string; force?: boolean; dryRun?: boolean }) => {\n const { initAutofix } = await import('./init-autofix.js');\n await initAutofix(dir, opts);\n });\n\nprogram\n .command('check-version')\n .description('Check if a newer version of Joycraft is available')\n .action(async () => {\n try {\n const { readFileSync, existsSync } = await import('node:fs');\n const { join } = await import('node:path');\n const { STATE_PATH, LEGACY_VERSION_FILE, LEGACY_CLAUDE_STATE_PATH } = await import('./version.js');\n // Prefer the current state; fall back through the legacy locations for\n // projects not yet upgraded (upgrade relocates them): the interim\n // .claude/.joycraft/state.json, then the original repo-root file.\n const candidates = [STATE_PATH, LEGACY_CLAUDE_STATE_PATH, LEGACY_VERSION_FILE];\n const statePath =\n candidates.map((p) => join(process.cwd(), p)).find((p) => existsSync(p)) ??\n join(process.cwd(), STATE_PATH);\n const data = JSON.parse(readFileSync(statePath, 'utf-8'));\n const res = await fetch('https://registry.npmjs.org/joycraft/latest', { signal: AbortSignal.timeout(3000) });\n if (res.ok) {\n const latest = ((await res.json()) as { version: string }).version;\n if (data.version !== latest) {\n console.log(`Joycraft ${latest} available (you have ${data.version}). Run: npx joycraft@latest upgrade`);\n }\n }\n } catch {\n // Silent — don't block session start\n }\n });\n\n// Start update check immediately so it runs in parallel with the command\nconst updateCheckPromise = (async (): Promise<string | null> => {\n try {\n const res = await fetch('https://registry.npmjs.org/joycraft/latest', {\n signal: AbortSignal.timeout(3000)\n });\n if (res.ok) {\n const latest = ((await res.json()) as { version: string }).version;\n if (latest !== pkg.version) {\n return `\\nJoycraft ${latest} available (you have ${pkg.version}). Run: npx joycraft@latest upgrade`;\n }\n }\n } catch {\n // Silent — don't block or error on network issues\n }\n return null;\n})();\n\n// Print update nudge after every command\nprogram.hook('postAction', async () => {\n if (suppressUpdateNudge) return;\n const message = await updateCheckPromise;\n if (message) {\n console.log(message);\n }\n});\n\n// Show help when no arguments provided\nif (process.argv.length <= 2) {\n program.outputHelp();\n process.exit(0);\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAG9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,IAAM,MAAM,KAAK,MAAM,aAAa,KAAK,WAAW,MAAM,cAAc,GAAG,OAAO,CAAC;AAEnF,IAAM,wBAAwB,uEAAuE,oBAAoB;AAEzH,IAAM,UAAU,IAAI,QAAQ;AAK5B,IAAI,sBAAsB;AAE1B,QACG,KAAK,UAAU,EACf,YAAY,+CAA+C,EAC3D,QAAQ,IAAI,SAAS,eAAe;AAEvC,QACG,QAAQ,MAAM,EACd,YAAY,wDAAwD,EACpE,SAAS,SAAS,oBAAoB,GAAG,EACzC,OAAO,WAAW,0BAA0B,EAC5C,OAAO,yBAAyB,qBAAqB,EACrD,OAAO,OAAO,KAAa,SAAkD;AAC5E,QAAM,EAAE,KAAK,IAAI,MAAM,OAAO,oBAAW;AACzC,MAAI;AACF,UAAM,KAAK,KAAK,EAAE,OAAO,KAAK,SAAS,OAAO,WAAW,KAAK,UAAU,CAAC;AAAA,EAC3E,SAAS,KAAK;AACZ,YA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,CAAC,MAAMA,MAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC,KACvEA,MAAK,QAAQ,IAAI,GAAG,UAAU;AAChC,UAAM,OAAO,KAAK,MAAMD,cAAa,WAAW,OAAO,CAAC;AACxD,UAAM,MAAM,MAAM,MAAM,8CAA8C,EAAE,QAAQ,YAAY,QAAQ,GAAI,EAAE,CAAC;AAC3G,QAAI,IAAI,IAAI;AACV,YAAM,UAAW,MAAM,IAAI,KAAK,GAA2B;AAC3D,UAAI,KAAK,YAAY,QAAQ;AAC3B,gBAAQ,IAAI,YAAY,MAAM,wBAAwB,KAAK,OAAO,qCAAqC;AAAA,MACzG;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACF,CAAC;AAGH,IAAM,sBAAsB,YAAoC;AAC9D,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,8CAA8C;AAAA,MACpE,QAAQ,YAAY,QAAQ,GAAI;AAAA,IAClC,CAAC;AACD,QAAI,IAAI,IAAI;AACV,YAAM,UAAW,MAAM,IAAI,KAAK,GAA2B;AAC3D,UAAI,WAAW,IAAI,SAAS;AAC1B,eAAO;AAAA,WAAc,MAAM,wBAAwB,IAAI,OAAO;AAAA,MAChE;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT,GAAG;AAGH,QAAQ,KAAK,cAAc,YAAY;AACrC,MAAI,oBAAqB;AACzB,QAAM,UAAU,MAAM;AACtB,MAAI,SAAS;AACX,YAAQ,IAAI,OAAO;AAAA,EACrB;AACF,CAAC;AAGD,IAAI,QAAQ,KAAK,UAAU,GAAG;AAC5B,UAAQ,WAAW;AACnB,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,MAAM;","names":["readFileSync","join"]}
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { dirname, join } from 'path';\nimport { PRIVATE_DIRS_DISPLAY } from './gitignore.js';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));\n\nconst GITIGNORE_OPTION_DESC = `Gitignore profile: 'shared' (commit skills) or 'private' (gitignore ${PRIVATE_DIRS_DISPLAY})`;\n\nconst program = new Command();\n\n// Set by the upgrade action when the stale-CLI guard already delegated to (or\n// pointed the user at) the latest version — the postAction nudge would only\n// contradict the upgrade that just ran.\nlet suppressUpdateNudge = false;\n\nprogram\n .name('joycraft')\n .description('Scaffold and upgrade AI development harnesses')\n .version(pkg.version, '-v, --version');\n\nprogram\n .command('init')\n .description('Scaffold the Joycraft harness into the current project')\n .argument('[dir]', 'Target directory', '.')\n .option('--force', 'Overwrite existing files')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .action(async (dir: string, opts: { force?: boolean; gitignore?: string }) => {\n const { init } = await import('./init.js');\n try {\n await init(dir, { force: opts.force ?? false, gitignore: opts.gitignore });\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('upgrade')\n .description('Upgrade installed Joycraft templates and skills to latest')\n .argument('[dir]', 'Target directory', '.')\n .option('--yes', 'Auto-accept all updates')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .action(async (dir: string, opts: { yes?: boolean; gitignore?: string }) => {\n const { upgrade } = await import('./upgrade.js');\n try {\n const result = await upgrade(dir, { yes: opts.yes ?? false, gitignore: opts.gitignore });\n suppressUpdateNudge = result.cliWasStale;\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('telemetry')\n .description('Scan AI-harness transcripts into knowledge-layer read telemetry')\n .argument('[dir]', 'Target directory', '.')\n .action(async (dir: string) => {\n const { runTelemetryScan, formatTelemetrySummary } = await import('./telemetry-store.js');\n const { resolve } = await import('node:path');\n try {\n const result = await runTelemetryScan(resolve(dir));\n console.log(formatTelemetrySummary(result));\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('init-autofix')\n .description('Set up the Level 5 auto-fix loop with holdout scenarios')\n .argument('[dir]', 'Target directory', '.')\n .option('--scenarios-repo <name>', 'Name for scenarios repo')\n .option('--app-id <id>', 'GitHub App ID for Joycraft Autofix')\n .option('--force', 'Overwrite existing workflow files')\n .option('--dry-run', 'Show what would be created without creating it')\n .action(async (dir: string, opts: { scenariosRepo?: string; appId?: string; force?: boolean; dryRun?: boolean }) => {\n const { initAutofix } = await import('./init-autofix.js');\n await initAutofix(dir, opts);\n });\n\nprogram\n .command('check-version')\n .description('Check if a newer version of Joycraft is available')\n .action(async () => {\n try {\n const { readFileSync, existsSync } = await import('node:fs');\n const { join } = await import('node:path');\n const { STATE_PATH, LEGACY_VERSION_FILE, LEGACY_CLAUDE_STATE_PATH } = await import('./version.js');\n // Prefer the current state; fall back through the legacy locations for\n // projects not yet upgraded (upgrade relocates them): the interim\n // .claude/.joycraft/state.json, then the original repo-root file.\n const candidates = [STATE_PATH, LEGACY_CLAUDE_STATE_PATH, LEGACY_VERSION_FILE];\n const statePath =\n candidates.map((p) => join(process.cwd(), p)).find((p) => existsSync(p)) ??\n join(process.cwd(), STATE_PATH);\n const data = JSON.parse(readFileSync(statePath, 'utf-8'));\n const res = await fetch('https://registry.npmjs.org/joycraft/latest', { signal: AbortSignal.timeout(3000) });\n if (res.ok) {\n const latest = ((await res.json()) as { version: string }).version;\n if (data.version !== latest) {\n console.log(`Joycraft ${latest} available (you have ${data.version}). Run: npx joycraft@latest upgrade`);\n }\n }\n } catch {\n // Silent — don't block session start\n }\n });\n\n// Start update check immediately so it runs in parallel with the command\nconst updateCheckPromise = (async (): Promise<string | null> => {\n try {\n const res = await fetch('https://registry.npmjs.org/joycraft/latest', {\n signal: AbortSignal.timeout(3000)\n });\n if (res.ok) {\n const latest = ((await res.json()) as { version: string }).version;\n if (latest !== pkg.version) {\n return `\\nJoycraft ${latest} available (you have ${pkg.version}). Run: npx joycraft@latest upgrade`;\n }\n }\n } catch {\n // Silent — don't block or error on network issues\n }\n return null;\n})();\n\n// Print update nudge after every command\nprogram.hook('postAction', async () => {\n if (suppressUpdateNudge) return;\n const message = await updateCheckPromise;\n if (message) {\n console.log(message);\n }\n});\n\n// Show help when no arguments provided\nif (process.argv.length <= 2) {\n program.outputHelp();\n process.exit(0);\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAG9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,IAAM,MAAM,KAAK,MAAM,aAAa,KAAK,WAAW,MAAM,cAAc,GAAG,OAAO,CAAC;AAEnF,IAAM,wBAAwB,uEAAuE,oBAAoB;AAEzH,IAAM,UAAU,IAAI,QAAQ;AAK5B,IAAI,sBAAsB;AAE1B,QACG,KAAK,UAAU,EACf,YAAY,+CAA+C,EAC3D,QAAQ,IAAI,SAAS,eAAe;AAEvC,QACG,QAAQ,MAAM,EACd,YAAY,wDAAwD,EACpE,SAAS,SAAS,oBAAoB,GAAG,EACzC,OAAO,WAAW,0BAA0B,EAC5C,OAAO,yBAAyB,qBAAqB,EACrD,OAAO,OAAO,KAAa,SAAkD;AAC5E,QAAM,EAAE,KAAK,IAAI,MAAM,OAAO,oBAAW;AACzC,MAAI;AACF,UAAM,KAAK,KAAK,EAAE,OAAO,KAAK,SAAS,OAAO,WAAW,KAAK,UAAU,CAAC;AAAA,EAC3E,SAAS,KAAK;AACZ,YAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAC9D,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,QACG,QAAQ,SAAS,EACjB,YAAY,2DAA2D,EACvE,SAAS,SAAS,oBAAoB,GAAG,EACzC,O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OAAO;AAAA,EACrB;AACF,CAAC;AAGD,IAAI,QAAQ,KAAK,UAAU,GAAG;AAC5B,UAAQ,WAAW;AACnB,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,MAAM;","names":["readFileSync","join"]}
@@ -3,14 +3,16 @@ import {
3
3
  applyGitattributes,
4
4
  getPackageVersion,
5
5
  renderExecutionProfileSection,
6
+ renderFolderMap,
6
7
  resolveExecutionProfile
7
- } from "./chunk-ONGWPA4M.js";
8
+ } from "./chunk-Q2ZQ6RGD.js";
8
9
  import {
9
10
  PRIVATE_DIRS_DISPLAY,
10
11
  PRIVATE_UNTRACK_COMMAND,
11
12
  applyGitignoreProfile,
12
13
  resolveGitignoreProfile
13
- } from "./chunk-RRMO5FBO.js";
14
+ } from "./chunk-BZW5DR3O.js";
15
+ import "./chunk-OAC5CVHJ.js";
14
16
  import {
15
17
  CODEX_SKILLS,
16
18
  COPILOT_SKILLS,
@@ -20,7 +22,7 @@ import {
20
22
  PI_SKILLS,
21
23
  SKILLS,
22
24
  TEMPLATES
23
- } from "./chunk-VU7KVQNL.js";
25
+ } from "./chunk-DSVGHVYM.js";
24
26
  import {
25
27
  DEFAULT_GITIGNORE_PROFILE,
26
28
  STATE_PATH,
@@ -315,6 +317,31 @@ async function detectStack(dir) {
315
317
  // src/improve-claude-md.ts
316
318
  import { existsSync as existsSync2 } from "fs";
317
319
  import { join as join2 } from "path";
320
+ function nonEmptyLines(items) {
321
+ return (items ?? []).map((s) => s.trim()).filter((s) => s.length > 0);
322
+ }
323
+ function glossaryEntries(glossary) {
324
+ return Object.entries(glossary ?? []).map(([term, def]) => [term.trim(), def.trim()]).filter(([term, def]) => term.length > 0 && def.length > 0);
325
+ }
326
+ function generateProductIdentitySection(identity) {
327
+ if (!identity) return null;
328
+ const values = nonEmptyLines(identity.values);
329
+ const taste = nonEmptyLines(identity.taste);
330
+ const glossary = glossaryEntries(identity.glossary);
331
+ if (values.length === 0 && taste.length === 0 && glossary.length === 0) return null;
332
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
333
+ const parts = ["## Product Identity", "", `_Added ${today} \u2014 review at next optimize run_`];
334
+ if (values.length > 0) {
335
+ parts.push("", "### Values", "", ...values.map((v) => `- ${v}`));
336
+ }
337
+ if (glossary.length > 0) {
338
+ parts.push("", "### Glossary", "", ...glossary.map(([term, def]) => `- **${term}** \u2014 ${def}`));
339
+ }
340
+ if (taste.length > 0) {
341
+ parts.push("", "### Taste", "", ...taste.map((t) => `- ${t}`));
342
+ }
343
+ return parts.join("\n");
344
+ }
318
345
  var PRIVATE_SETUP_NOTE_MARKER = "After cloning, run";
319
346
  function generatePrivateSetupNote() {
320
347
  return `> **Private setup:** The harness dirs (\`.claude/\`, \`.agents/\`, \`.pi/\`) are gitignored in this repo, so they aren't committed. ${PRIVATE_SETUP_NOTE_MARKER} \`npx joycraft init\` to regenerate the skill files locally \u2014 it only creates missing files and leaves your committed \`CLAUDE.md\`, \`AGENTS.md\`, and \`docs/\` untouched (use \`--force\` only if you deliberately want to regenerate them).`;
@@ -384,7 +411,12 @@ _How \`/joycraft-implement\` wraps up after each spec. \`joycraft-decompose\` re
384
411
 
385
412
  **Deferred work \u2192 \`docs/backlog/\`.** Ideas and follow-ups you surface mid-sprint but can't take on now go to \`docs/backlog/\` (one file per item) so the current spec stays focused without losing the thread. Promote an entry to a Feature Brief under \`docs/features/<slug>/\` when you're ready to build it.`;
386
413
  }
387
- function generateArchitectureSection() {
414
+ function generateArchitectureSection(projectDir) {
415
+ if (projectDir) {
416
+ return `## Architecture
417
+
418
+ ${renderFolderMap(projectDir)}`;
419
+ }
388
420
  return `## Architecture
389
421
 
390
422
  _TODO: Add a brief description of your project's architecture and key directories._`;
@@ -470,7 +502,7 @@ function generateCLAUDEMd(projectName, stack, existingSkills = [], opts) {
470
502
  lines.push(
471
503
  generateWorkflowSection(stack),
472
504
  "",
473
- generateArchitectureSection(),
505
+ generateArchitectureSection(opts?.projectDir),
474
506
  "",
475
507
  generateKeyFilesSection(),
476
508
  "",
@@ -481,6 +513,10 @@ function generateCLAUDEMd(projectName, stack, existingSkills = [], opts) {
481
513
  generateGettingStartedSection(opts?.multiTool ?? false),
482
514
  ""
483
515
  );
516
+ const identitySection = generateProductIdentitySection(opts?.identity);
517
+ if (identitySection) {
518
+ lines.push(identitySection, "");
519
+ }
484
520
  if (opts?.executionProfile) {
485
521
  lines.push(renderExecutionProfileSection(opts.executionProfile), "");
486
522
  }
@@ -514,7 +550,12 @@ ${generateCommandsBlock2(stack)}
514
550
 
515
551
  **Deferred work \u2192 \`docs/backlog/\`.** Ideas and follow-ups surfaced mid-sprint that can't be taken on now go to \`docs/backlog/\` (one file per item) so the current spec stays focused. Promote an entry to a Feature Brief under \`docs/features/<slug>/\` when ready to build it.`;
516
552
  }
517
- function generateArchitectureSection2() {
553
+ function generateArchitectureSection2(projectDir) {
554
+ if (projectDir) {
555
+ return `## Architecture
556
+
557
+ ${renderFolderMap(projectDir)}`;
558
+ }
518
559
  return `## Architecture
519
560
 
520
561
  _TODO: Add a compact directory tree and one-paragraph summary._`;
@@ -526,7 +567,7 @@ function generateKeyFilesSection2() {
526
567
  |------|---------|
527
568
  | _TODO_ | _Add key files_ |`;
528
569
  }
529
- function generateAgentsMd(projectName, stack, privateProfile = false, executionProfile) {
570
+ function generateAgentsMd(projectName, stack, privateProfile = false, executionProfile, identity, projectDir) {
530
571
  const frameworkNote = stack.framework ? ` (${stack.framework})` : "";
531
572
  const langLabel = stack.language === "unknown" ? "" : ` | **Stack:** ${stack.language}${frameworkNote}`;
532
573
  const lines = [
@@ -541,13 +582,17 @@ function generateAgentsMd(projectName, stack, privateProfile = false, executionP
541
582
  generateBoundariesSection(),
542
583
  generateExternalApiSafetySection(),
543
584
  "",
544
- generateArchitectureSection2(),
585
+ generateArchitectureSection2(projectDir),
545
586
  "",
546
587
  generateKeyFilesSection2(),
547
588
  "",
548
589
  generateDevelopmentSection(stack),
549
590
  ""
550
591
  ];
592
+ const identitySection = generateProductIdentitySection(identity);
593
+ if (identitySection) {
594
+ lines.push(identitySection, "");
595
+ }
551
596
  if (executionProfile) {
552
597
  lines.push(renderExecutionProfileSection(executionProfile), "");
553
598
  }
@@ -816,6 +861,62 @@ function ensurePiExcludedFromTsconfig(targetDir) {
816
861
  return { status: "added", path };
817
862
  }
818
863
 
864
+ // src/auto-memory.ts
865
+ import { createInterface } from "readline";
866
+ var AUTO_MEMORY_KEY = "autoMemoryEnabled";
867
+ function parseAutoMemoryAnswer(answer) {
868
+ const normalized = answer.trim().toLowerCase();
869
+ if (normalized === "") return false;
870
+ if (normalized === "y" || normalized === "yes") return true;
871
+ if (normalized === "n" || normalized === "no") return false;
872
+ return null;
873
+ }
874
+ function promptAutoMemory() {
875
+ console.log("\nJoycraft keeps project facts in one home: your repo.");
876
+ console.log(
877
+ " Claude Code auto-memory is a second, per-machine home for the same facts."
878
+ );
879
+ console.log(
880
+ ` Disabling it for this project writes "${AUTO_MEMORY_KEY}": false to .claude/settings.json.`
881
+ );
882
+ console.log(" Your other projects are unaffected.");
883
+ const input = process.stdin;
884
+ if (input.readableEnded === true || input.destroyed === true) {
885
+ return Promise.resolve(false);
886
+ }
887
+ return new Promise((resolve2) => {
888
+ const rl = createInterface({ input, output: process.stdout });
889
+ let settled = false;
890
+ const done = (value) => {
891
+ if (settled) return;
892
+ settled = true;
893
+ rl.close();
894
+ resolve2(value);
895
+ };
896
+ rl.once("close", () => done(false));
897
+ const ask = (attempt) => {
898
+ rl.question("Disable auto-memory for this project? [y/N]: ", (answer) => {
899
+ const parsed = parseAutoMemoryAnswer(answer);
900
+ if (parsed !== null) {
901
+ done(parsed);
902
+ return;
903
+ }
904
+ if (attempt >= 4) {
905
+ done(false);
906
+ return;
907
+ }
908
+ console.log(`Unrecognized answer '${answer.trim()}' \u2014 type 'y' or 'n', or press Enter for no change.`);
909
+ ask(attempt + 1);
910
+ });
911
+ };
912
+ ask(0);
913
+ });
914
+ }
915
+ async function resolveAutoMemoryOffer(interactive) {
916
+ if (!interactive) return false;
917
+ return promptAutoMemory();
918
+ }
919
+
819
920
  // src/init.ts
820
921
  var BACKLOG_README = `# Backlog
821
922
 
@@ -863,6 +964,7 @@ async function init(dir, opts) {
863
964
  interactive: process.stdin.isTTY === true,
864
965
  promptIntro: "\nHow should Joycraft files be tracked in git?"
865
966
  });
967
+ const disableAutoMemory = wants("claude") ? await resolveAutoMemoryOffer(process.stdin.isTTY === true) : false;
866
968
  ensureDir(join5(targetDir, "docs", "context"));
867
969
  ensureDir(join5(targetDir, "docs", "backlog"));
868
970
  writeFile(join5(targetDir, "docs", "backlog", "README.md"), BACKLOG_README, opts.force, result);
@@ -953,7 +1055,8 @@ async function init(dir, opts) {
953
1055
  } else {
954
1056
  const projectName = basename(targetDir);
955
1057
  const content = multiTool ? generateClaudeMdPointer() : generateCLAUDEMd(projectName, stack, existingSkills, {
956
- privateProfile: gitignoreProfile === "private"
1058
+ privateProfile: gitignoreProfile === "private",
1059
+ projectDir: targetDir
957
1060
  });
958
1061
  writeFileSync3(claudeMdPath, content, "utf-8");
959
1062
  result.created.push(claudeMdPath);
@@ -966,8 +1069,9 @@ async function init(dir, opts) {
966
1069
  const content = multiTool ? generateCLAUDEMd(projectName, stack, existingSkills, {
967
1070
  privateProfile: gitignoreProfile === "private",
968
1071
  multiTool: true,
969
- executionProfile
970
- }) : generateAgentsMd(projectName, stack, gitignoreProfile === "private", executionProfile);
1072
+ executionProfile,
1073
+ projectDir: targetDir
1074
+ }) : generateAgentsMd(projectName, stack, gitignoreProfile === "private", executionProfile, void 0, targetDir);
971
1075
  writeFileSync3(agentsMdPath, content, "utf-8");
972
1076
  result.created.push(agentsMdPath);
973
1077
  }
@@ -1066,6 +1170,11 @@ try {
1066
1170
  if (envMissing) {
1067
1171
  env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS = "1";
1068
1172
  }
1173
+ const autoMemoryMissing = !(AUTO_MEMORY_KEY in settings);
1174
+ const writeAutoMemory = disableAutoMemory && autoMemoryMissing;
1175
+ if (writeAutoMemory) {
1176
+ settings[AUTO_MEMORY_KEY] = false;
1177
+ }
1069
1178
  if (!hasJoycraftHook) {
1070
1179
  sessionStartHooks.push({
1071
1180
  matcher: "",
@@ -1075,7 +1184,7 @@ try {
1075
1184
  }]
1076
1185
  });
1077
1186
  }
1078
- if (!hasJoycraftHook || envMissing) {
1187
+ if (!hasJoycraftHook || envMissing || writeAutoMemory) {
1079
1188
  writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
1080
1189
  if (!result.created.includes(settingsPath)) result.created.push(settingsPath);
1081
1190
  }
@@ -1195,4 +1304,4 @@ function printSummary(result, stack, existingSkills = [], isPi = false, gitignor
1195
1304
  export {
1196
1305
  init
1197
1306
  };
1198
- //# sourceMappingURL=init-OJTXCK42.js.map
1307
+ //# sourceMappingURL=init-J5Q6RX3K.js.map