claude-launchpad 1.8.1 → 1.9.0
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/dist/{chunk-COGKNJJB.js → chunk-72VWDNAE.js} +2 -2
- package/dist/{chunk-H2E7QMF4.js → chunk-DYHPVA6O.js} +2 -2
- package/dist/{chunk-THDBKJAV.js → chunk-GA3IUQUM.js} +3 -3
- package/dist/{chunk-RDID5P4K.js → chunk-I4S4Q2IV.js} +2 -2
- package/dist/{chunk-IY3Z54UK.js → chunk-RCYLZUU6.js} +268 -124
- package/dist/chunk-RCYLZUU6.js.map +1 -0
- package/dist/cli.js +91 -20
- package/dist/cli.js.map +1 -1
- package/dist/commands/memory/server.js +3 -3
- package/dist/{context-BCTOCTZD.js → context-X7UP2ODK.js} +5 -5
- package/dist/{install-L23C4YWJ.js → install-XBCEI5QK.js} +33 -44
- package/dist/install-XBCEI5QK.js.map +1 -0
- package/dist/{pull-5KYLJ6TH.js → pull-VA62U3OP.js} +7 -7
- package/dist/{push-UOVLT5HO.js → push-C3M6Q4V7.js} +7 -7
- package/dist/{require-deps-T2QOGQQ3.js → require-deps-UBU5CYM5.js} +3 -3
- package/dist/{stats-GL7P24U7.js → stats-R4TWCPHW.js} +6 -6
- package/dist/{sync-clean-7RNYS7EH.js → sync-clean-P4S7V2JS.js} +3 -3
- package/dist/{sync-status-ULZCMBQJ.js → sync-status-TPYUF43G.js} +7 -7
- package/dist/{tui-UGBWF2WT.js → tui-FFLCUR7E.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-IY3Z54UK.js.map +0 -1
- package/dist/install-L23C4YWJ.js.map +0 -1
- /package/dist/{chunk-COGKNJJB.js.map → chunk-72VWDNAE.js.map} +0 -0
- /package/dist/{chunk-H2E7QMF4.js.map → chunk-DYHPVA6O.js.map} +0 -0
- /package/dist/{chunk-THDBKJAV.js.map → chunk-GA3IUQUM.js.map} +0 -0
- /package/dist/{chunk-RDID5P4K.js.map → chunk-I4S4Q2IV.js.map} +0 -0
- /package/dist/{context-BCTOCTZD.js.map → context-X7UP2ODK.js.map} +0 -0
- /package/dist/{pull-5KYLJ6TH.js.map → pull-VA62U3OP.js.map} +0 -0
- /package/dist/{push-UOVLT5HO.js.map → push-C3M6Q4V7.js.map} +0 -0
- /package/dist/{require-deps-T2QOGQQ3.js.map → require-deps-UBU5CYM5.js.map} +0 -0
- /package/dist/{stats-GL7P24U7.js.map → stats-R4TWCPHW.js.map} +0 -0
- /package/dist/{sync-clean-7RNYS7EH.js.map → sync-clean-P4S7V2JS.js.map} +0 -0
- /package/dist/{sync-status-ULZCMBQJ.js.map → sync-status-TPYUF43G.js.map} +0 -0
- /package/dist/{tui-UGBWF2WT.js.map → tui-FFLCUR7E.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/fs-utils.ts","../src/lib/settings.ts","../src/lib/output.ts","../src/commands/doctor/fixer.ts","../src/lib/sections.ts","../src/lib/detect.ts","../src/commands/init/generators/claudeignore.ts","../src/commands/init/generators/skill-enhance.ts","../src/lib/memory-placement.ts","../src/lib/stub-marker.ts","../src/commands/doctor/fixer-sprint.ts","../src/lib/hook-builder.ts","../src/lib/hook-scripts.ts","../src/commands/doctor/fixer-hooks.ts","../src/commands/doctor/fixer-memory.ts"],"sourcesContent":["import { readFile, access } from \"node:fs/promises\";\n\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readFileOrNull(path: string): Promise<string | null> {\n try {\n return await readFile(path, \"utf-8\");\n } catch {\n return null;\n }\n}\n\nexport async function readJsonOrNull<T>(path: string): Promise<T | null> {\n try {\n const content = await readFile(path, \"utf-8\");\n return JSON.parse(content) as T;\n } catch {\n return null;\n }\n}\n","import { readFile, writeFile, mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { log } from \"./output.js\";\n\nasync function readJsonFile(path: string): Promise<Record<string, unknown> | null> {\n let raw: string;\n try {\n raw = await readFile(path, \"utf-8\");\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === \"ENOENT\") return {};\n log.warnOnce(`read:${path}`, `Could not read ${path}: ${(err as Error).message}`);\n return null;\n }\n try {\n return JSON.parse(raw) as Record<string, unknown>;\n } catch (err) {\n log.warnOnce(`parse:${path}`, `${path} is not valid JSON: ${(err as Error).message}. Treating as unreadable to avoid clobbering it.`);\n return null;\n }\n}\n\nexport async function readSettingsJson(root: string): Promise<Record<string, unknown> | null> {\n return readJsonFile(join(root, \".claude\", \"settings.json\"));\n}\n\nexport async function writeSettingsJson(root: string, settings: Record<string, unknown>): Promise<void> {\n const dir = join(root, \".claude\");\n await mkdir(dir, { recursive: true });\n await writeFile(join(dir, \"settings.json\"), JSON.stringify(settings, null, 2) + \"\\n\");\n}\n\nexport async function readSettingsLocalJson(root: string): Promise<Record<string, unknown> | null> {\n return readJsonFile(join(root, \".claude\", \"settings.local.json\"));\n}\n\nexport async function writeSettingsLocalJson(root: string, settings: Record<string, unknown>): Promise<void> {\n const dir = join(root, \".claude\");\n await mkdir(dir, { recursive: true });\n await writeFile(join(dir, \"settings.local.json\"), JSON.stringify(settings, null, 2) + \"\\n\");\n}\n","import chalk from \"chalk\";\nimport type { Severity, AnalyzerResult, DiagnosticIssue } from \"../types/index.js\";\nimport { hasAutoFix } from \"../commands/doctor/fixer.js\";\n\n// ─── Colors ───\n\nexport const colors = {\n success: chalk.green,\n error: chalk.red,\n warn: chalk.yellow,\n info: chalk.cyan,\n dim: chalk.dim,\n bold: chalk.bold,\n score: (score: number): string => {\n if (score >= 80) return chalk.green.bold(`${score}%`);\n if (score >= 60) return chalk.yellow.bold(`${score}%`);\n return chalk.red.bold(`${score}%`);\n },\n severity: (sev: Severity): string => {\n const map: Record<Severity, (s: string) => string> = {\n critical: chalk.bgRed.white.bold,\n high: chalk.red.bold,\n medium: chalk.yellow,\n low: chalk.cyan,\n info: chalk.dim,\n };\n return map[sev](` ${sev.toUpperCase()} `);\n },\n} as const;\n\n// ─── Prefixed Output ───\n\nconst warnedKeys = new Set<string>();\n\nexport const log = {\n success: (msg: string): void => console.log(` ${chalk.green(\"✓\")} ${msg}`),\n error: (msg: string): void => console.log(` ${chalk.red(\"✗\")} ${msg}`),\n warn: (msg: string): void => console.log(` ${chalk.yellow(\"!\")} ${msg}`),\n warnOnce: (key: string, msg: string): void => {\n if (warnedKeys.has(key)) return;\n warnedKeys.add(key);\n console.log(` ${chalk.yellow(\"!\")} ${msg}`);\n },\n step: (msg: string): void => console.log(` ${chalk.cyan(\"→\")} ${msg}`),\n info: (msg: string): void => console.log(` ${chalk.dim(\"·\")} ${msg}`),\n blank: (): void => console.log(),\n} as const;\n\n// ─── Banner ───\n\nexport function printBanner(): void {\n log.blank();\n console.log(chalk.cyan.bold(\" Claude Launchpad\"));\n console.log(chalk.dim(\" Scaffold · Diagnose · Evaluate · Remember\"));\n log.blank();\n}\n\n// ─── Score Display ───\n\nexport function printScoreCard(label: string, score: number, max: number = 100): void {\n const pct = Math.round((score / max) * 100);\n const bar = renderBar(pct, 20);\n console.log(` ${chalk.bold(label.padEnd(22))} ${bar} ${colors.score(pct).padStart(12)}`);\n}\n\nfunction renderBar(pct: number, width: number): string {\n const filled = Math.round((pct / 100) * width);\n const empty = width - filled;\n const color = pct >= 80 ? chalk.green : pct >= 60 ? chalk.yellow : chalk.red;\n return color(\"━\".repeat(filled)) + chalk.dim(\"─\".repeat(empty));\n}\n\n// ─── Issues List (replaces table) ───\n\nexport function printIssue(severity: Severity, _analyzer: string, message: string): void {\n const sevLabel: Record<Severity, string> = {\n critical: chalk.bgRed.white.bold(\" CRIT \"),\n high: chalk.red.bold(\"HIGH\"),\n medium: chalk.yellow(\"MED \"),\n low: chalk.dim(\"LOW \"),\n info: chalk.dim(\"INFO\"),\n };\n console.log(` ${sevLabel[severity]} ${message}`);\n}\n\n// ─── Report Rendering (shared by doctor + watcher) ───\n\nexport function renderDoctorReport(results: ReadonlyArray<AnalyzerResult>, options?: { afterFix?: boolean }): {\n overallScore: number;\n actionableCount: number;\n} {\n const overallScore = Math.round(\n results.reduce((sum, r) => sum + r.score, 0) / results.length,\n );\n\n for (const result of results) {\n printScoreCard(result.name, result.score);\n }\n log.blank();\n printScoreCard(\"Overall\", overallScore);\n log.blank();\n\n const allIssues = results.flatMap((r) => r.issues);\n const actionable = allIssues.filter((i) => i.severity !== \"info\");\n\n if (actionable.length === 0) {\n log.success(\"No issues found. Your configuration looks solid.\");\n return { overallScore, actionableCount: 0 };\n }\n\n const sorted = [...actionable].sort((a, b) => {\n const order: Record<string, number> = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };\n return (order[a.severity] ?? 4) - (order[b.severity] ?? 4);\n });\n\n for (const issue of sorted) {\n printIssue(issue.severity, issue.analyzer, issue.message);\n }\n\n log.blank();\n if (options?.afterFix) {\n log.info(`${actionable.length} remaining issue(s) require manual intervention.`);\n } else {\n const fixable = actionable.filter((i) => hasAutoFix(i));\n if (fixable.length > 0) {\n log.info(`${actionable.length} issue(s). Run ${chalk.bold(\"--fix\")} to auto-repair or ${chalk.bold(\"--fix --dry-run\")} to preview.`);\n } else {\n log.info(`${actionable.length} issue(s) require manual intervention.`);\n }\n }\n return { overallScore, actionableCount: actionable.length };\n}\n","import { readFile, writeFile, mkdir, access } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { log } from \"../../lib/output.js\";\nimport {\n SESSION_START_CONTENT, BACKLOG_CONTENT, STOP_AND_SWARM_CONTENT,\n OFF_LIMITS_CONTENT, SKILL_AUTHORING_CONTENT,\n} from \"../../lib/sections.js\";\nimport { fileExists } from \"../../lib/fs-utils.js\";\nimport { detectProject } from \"../../lib/detect.js\";\nimport { generateClaudeignore } from \"../init/generators/claudeignore.js\";\nimport { generateEnhanceSkill } from \"../init/generators/skill-enhance.js\";\nimport { readSettingsJson, writeSettingsJson } from \"../../lib/settings.js\";\nimport { getMemoryPlacement } from \"../../lib/memory-placement.js\";\nimport { wrapStub } from \"../../lib/stub-marker.js\";\nimport {\n createWorktreeInclude, addSprintSizeHook, addSprintOpenHook, addSprintCompleteNudge,\n} from \"./fixer-sprint.js\";\nimport {\n addEnvProtectionHook, addAutoFormatHook, addForcePushProtection,\n addPostCompactHook, addSessionStartHook,\n} from \"./fixer-hooks.js\";\nimport {\n disableAutoMemory, addMemoryToolPermissions, addAllowedMcpServers, addMemoryToAllowedMcpServers,\n addSessionStartPullHook, addSessionEndPushHook, upgradeStaleSessionEndPushHook, removeStaleStopHook,\n} from \"./fixer-memory.js\";\nimport type { DiagnosticIssue, DetectedProject, MemoryPlacement } from \"../../types/index.js\";\n\ninterface FixResult {\n readonly fixed: number;\n readonly skipped: number;\n}\n\n/**\n * Auto-apply deterministic fixes for doctor issues.\n * Only applies fixes that are safe and unambiguous.\n */\nexport async function applyFixes(\n issues: ReadonlyArray<DiagnosticIssue>,\n projectRoot: string,\n): Promise<FixResult> {\n const detected = await detectProject(projectRoot);\n const hasMemoryIssues = issues.some((i) => i.analyzer === \"Memory\");\n const placement = hasMemoryIssues ? await getMemoryPlacement(projectRoot) : \"shared\";\n let fixed = 0;\n let skipped = 0;\n\n for (const issue of issues) {\n const applied = await tryFix(issue, projectRoot, detected, placement);\n if (applied) {\n fixed++;\n } else {\n skipped++;\n }\n }\n\n return { fixed, skipped };\n}\n\n// Fix lookup table: [analyzer, message substring] → fix function\ntype FixFn = (root: string, detected: DetectedProject, placement: MemoryPlacement) => Promise<boolean>;\n\nconst FIX_TABLE: ReadonlyArray<{ analyzer: string; match: string; fix: FixFn }> = [\n { analyzer: \"Hooks\", match: \"No hooks configured\", fix: async (root, detected) => {\n const a = await addEnvProtectionHook(root);\n const b = await addAutoFormatHook(root, detected);\n const c = await addForcePushProtection(root);\n const d = await addSessionStartHook(root);\n return a || b || c || d;\n }},\n { analyzer: \"Hooks\", match: \".env file protection\", fix: (root) => addEnvProtectionHook(root) },\n { analyzer: \"Hooks\", match: \"auto-format\", fix: (root, detected) => addAutoFormatHook(root, detected) },\n { analyzer: \"Hooks\", match: \"No PreToolUse\", fix: (root) => addEnvProtectionHook(root) },\n { analyzer: \"Quality\", match: \"Architecture\", fix: (root) => addClaudeMdSection(root, \"## Architecture\", wrapStub(\"<!-- TODO: Describe your codebase structure. Run `/lp-enhance` to auto-fill this. -->\")) },\n { analyzer: \"Quality\", match: \"Off-Limits\", fix: (root) => addClaudeMdSection(root, \"## Off-Limits\", wrapStub(OFF_LIMITS_CONTENT)) },\n { analyzer: \"Quality\", match: \"Commands\", fix: (root) => addClaudeMdSection(root, \"## Commands\", wrapStub(\"<!-- TODO: Add your dev/build/test commands -->\")) },\n { analyzer: \"Quality\", match: \"Stack\", fix: (root, detected) => {\n // Detected stack is real content; TODO fallback is a stub.\n if (detected.language) {\n const content = `- **Language**: ${detected.language}${detected.framework ? `\\n- **Framework**: ${detected.framework}` : \"\"}${detected.packageManager ? `\\n- **Package Manager**: ${detected.packageManager}` : \"\"}`;\n return addClaudeMdSection(root, \"## Stack\", content);\n }\n return addClaudeMdSection(root, \"## Stack\", wrapStub(\"<!-- TODO: Define your tech stack -->\"));\n }},\n { analyzer: \"Quality\", match: \"Session Start\", fix: (root) => addClaudeMdSection(root, \"## Session Start\", wrapStub(SESSION_START_CONTENT)) },\n { analyzer: \"Quality\", match: \"Backlog\", fix: (root) => addClaudeMdSection(root, \"## Backlog\", wrapStub(BACKLOG_CONTENT)) },\n { analyzer: \"Quality\", match: \"Stop-and-Swarm\", fix: (root) => addClaudeMdSection(root, \"## Stop-and-Swarm\", wrapStub(STOP_AND_SWARM_CONTENT)) },\n { analyzer: \"Rules\", match: \"No BACKLOG.md\", fix: (root) => createBacklogMd(root) },\n { analyzer: \"Rules\", match: \"No .claudeignore\", fix: (root, detected) => createClaudeignore(root, detected) },\n { analyzer: \"Rules\", match: \"No .claude/rules/\", fix: (root) => createStarterRules(root) },\n { analyzer: \"Hooks\", match: \"PostCompact\", fix: (root) => addPostCompactHook(root) },\n { analyzer: \"Permissions\", match: \"force-push\", fix: (root) => addForcePushProtection(root) },\n { analyzer: \"Permissions\", match: \"Credential files not blocked\", fix: (root) => addCredentialDenyRules(root) },\n { analyzer: \"Permissions\", match: \"Bypass permissions mode\", fix: (root) => addBypassDisable(root) },\n { analyzer: \"Permissions\", match: \"Filesystem sandbox enabled\", fix: (root) => removeSandboxSettings(root) },\n { analyzer: \"Permissions\", match: \".env is protected by hooks but not in .claudeignore\", fix: (root) => addEnvToClaudeignore(root) },\n { analyzer: \"Permissions\", match: \".worktreeinclude is missing or empty\", fix: (root) => createWorktreeInclude(root) },\n { analyzer: \"Hooks\", match: \"sprint-size-check\", fix: (root) => addSprintSizeHook(root) },\n { analyzer: \"Hooks\", match: \"sprint-open-check\", fix: (root) => addSprintOpenHook(root) },\n { analyzer: \"Hooks\", match: \"sprint-complete nudge\", fix: (root) => addSprintCompleteNudge(root) },\n { analyzer: \"Rules\", match: \"No skill authoring conventions\", fix: (root) => addSkillAuthoringConventions(root) },\n { analyzer: \"Rules\", match: \"No /lp-enhance skill\", fix: (root) => createEnhanceSkill(root) },\n { analyzer: \"Rules\", match: \"lp-enhance skill is outdated\", fix: (root) => updateEnhanceSkill(root) },\n { analyzer: \"Settings\", match: \"Deprecated includeCoAuthoredBy\", fix: (root) => migrateAttribution(root) },\n { analyzer: \"Hooks\", match: \"SessionStart\", fix: (root) => addSessionStartHook(root) },\n { analyzer: \"Memory\", match: \"Deprecated Stop hook\", fix: (root) => removeStaleStopHook(root) },\n { analyzer: \"Memory\", match: \"autoMemoryEnabled not disabled\", fix: (root, _det, placement) => disableAutoMemory(root, placement) },\n { analyzer: \"Memory\", match: \"MCP tool permission\", fix: (root, _det, placement) => addMemoryToolPermissions(root, placement) },\n { analyzer: \"MCP\", match: \"no allowedMcpServers\", fix: (root, _det, placement) => addAllowedMcpServers(root, placement) },\n { analyzer: \"Memory\", match: \"allowedMcpServers is set but does not include agentic-memory\", fix: (root) => addMemoryToAllowedMcpServers(root) },\n { analyzer: \"Memory\", match: \"SessionStart hook to auto-pull\", fix: (root, _det, placement) => addSessionStartPullHook(root, placement) },\n { analyzer: \"Memory\", match: \"SessionEnd hook to auto-push\", fix: (root, _det, placement) => addSessionEndPushHook(root, placement) },\n { analyzer: \"Memory\", match: \"SessionEnd push hook is not nohup-wrapped\", fix: (root) => upgradeStaleSessionEndPushHook(root) },\n { analyzer: \"Memory\", match: \"CLAUDE.md missing memory guidance\", fix: (root, _det, placement) => {\n const content = \"Use agentic-memory to persist knowledge across sessions:\\n- Memories are automatically injected at session start\\n- STORE IMMEDIATELY when: a dependency strategy changes, an architecture decision is made, a convention is established, a bug pattern is discovered, or a feature is killed/added\\n- Use memory_search before memory_store to check for duplicates\\n- NEVER store credentials, API keys, tokens, or secrets in memories\";\n const target = placement === \"local\" ? join(root, \".claude\", \"CLAUDE.md\") : undefined;\n return addClaudeMdSection(root, \"## Memory\", wrapStub(content), target);\n }},\n];\n\nexport function hasAutoFix(issue: DiagnosticIssue): boolean {\n return FIX_TABLE.some(\n (e) => e.analyzer === issue.analyzer && issue.message.includes(e.match),\n );\n}\n\nasync function tryFix(\n issue: DiagnosticIssue,\n root: string,\n detected: DetectedProject,\n placement: MemoryPlacement,\n): Promise<boolean> {\n const entry = FIX_TABLE.find(\n (e) => e.analyzer === issue.analyzer && issue.message.includes(e.match),\n );\n return entry ? entry.fix(root, detected, placement) : false;\n}\n\n// ─── Fix Implementations ───\n\nasync function migrateAttribution(root: string): Promise<boolean> {\n const settings = await readSettingsJson(root);\n if (settings === null) return false;\n if (settings.includeCoAuthoredBy === undefined) return false;\n\n const { includeCoAuthoredBy: _, ...rest } = settings;\n const updated = { ...rest, attribution: { commit: \"\", pr: \"\" } };\n await writeSettingsJson(root, updated);\n log.success(\"Migrated includeCoAuthoredBy → attribution object\");\n return true;\n}\n\nasync function addCredentialDenyRules(root: string): Promise<boolean> {\n const settings = await readSettingsJson(root);\n if (settings === null) return false;\n const permissions = (settings.permissions ?? {}) as Record<string, unknown>;\n const deny = (permissions.deny as string[] | undefined) ?? [];\n\n const toAdd = [\"Read(~/.ssh/*)\", \"Read(~/.aws/*)\", \"Read(~/.npmrc)\"];\n const missing = toAdd.filter((p) => !deny.includes(p));\n if (missing.length === 0) return false;\n\n const updated = { ...settings, permissions: { ...permissions, deny: [...deny, ...missing] } };\n await writeSettingsJson(root, updated);\n log.success(\"Added credential deny rules (SSH, AWS, npm)\");\n return true;\n}\n\nasync function addBypassDisable(root: string): Promise<boolean> {\n const settings = await readSettingsJson(root);\n if (settings === null) return false;\n if (settings.disableBypassPermissionsMode === \"disable\") return false;\n\n const updated = { ...settings, disableBypassPermissionsMode: \"disable\" };\n await writeSettingsJson(root, updated);\n log.success(\"Added disableBypassPermissionsMode: disable\");\n return true;\n}\n\nasync function removeSandboxSettings(root: string): Promise<boolean> {\n const settings = await readSettingsJson(root);\n if (settings === null) return false;\n if (settings.sandbox === undefined) return false;\n\n const { sandbox: _sandbox, ...rest } = settings;\n await writeSettingsJson(root, rest);\n log.success(\"Removed sandbox block from settings.json\");\n return true;\n}\n\n\nasync function addEnvToClaudeignore(root: string): Promise<boolean> {\n const ignorePath = join(root, \".claudeignore\");\n let content: string;\n try {\n content = await readFile(ignorePath, \"utf-8\");\n } catch {\n return false; // No .claudeignore to modify\n }\n\n const lines = content.split(\"\\n\").map((l) => l.trim());\n if (lines.some((l) => l === \".env\" || l === \".env.*\" || l === \".env*\")) return false;\n\n await writeFile(ignorePath, content.trimEnd() + \"\\n.env\\n.env.*\\n\");\n log.success(\"Added .env to .claudeignore\");\n return true;\n}\n\nasync function addClaudeMdSection(root: string, heading: string, content: string, targetPath?: string): Promise<boolean> {\n const claudeMdPath = targetPath ?? join(root, \"CLAUDE.md\");\n let existing: string;\n try {\n existing = await readFile(claudeMdPath, \"utf-8\");\n } catch {\n if (!targetPath) return false; // No root CLAUDE.md to add to\n // Create local .claude/CLAUDE.md\n await mkdir(join(root, \".claude\"), { recursive: true });\n existing = \"# Local Claude Config\\n\";\n }\n\n // Don't add if section already exists\n if (existing.includes(heading)) return false;\n\n // Append before Key Decisions if it exists, otherwise at end\n const keyDecisionsIdx = existing.indexOf(\"## Key Decisions\");\n const insertAt = keyDecisionsIdx > -1 ? keyDecisionsIdx : existing.length;\n\n const section = `\\n${heading}\\n${content}\\n\\n`;\n const updated = existing.slice(0, insertAt) + section + existing.slice(insertAt);\n\n await writeFile(claudeMdPath, updated);\n const label = targetPath ? \".claude/CLAUDE.md\" : \"CLAUDE.md\";\n log.success(`Added \"${heading}\" section to ${label}`);\n return true;\n}\n\nasync function createBacklogMd(root: string): Promise<boolean> {\n const backlogPath = join(root, \"BACKLOG.md\");\n try {\n await access(backlogPath);\n return false;\n } catch {\n // Create it\n }\n\n const name = root.split(\"/\").pop() ?? \"Project\";\n await writeFile(backlogPath, `# ${name} - Backlog\n\n> Features discussed but deferred. Pick up when relevant.\n> Priority: P0 = next sprint, P1 = soon, P2 = when relevant.\n`);\n log.success(\"Generated BACKLOG.md\");\n return true;\n}\n\nasync function createClaudeignore(root: string, detected: DetectedProject): Promise<boolean> {\n const ignorePath = join(root, \".claudeignore\");\n try {\n await access(ignorePath);\n return false; // Already exists\n } catch {\n // Create it\n }\n\n const content = generateClaudeignore(detected);\n await writeFile(ignorePath, content);\n log.success(\"Generated .claudeignore with language-specific ignore patterns\");\n return true;\n}\n\n\nconst SKILL_AUTHORING_SECTION = `\\n## Skill Authoring\\n\\n${SKILL_AUTHORING_CONTENT}\\n`;\n\nasync function createStarterRules(root: string): Promise<boolean> {\n const rulesDir = join(root, \".claude\", \"rules\");\n try {\n await access(rulesDir);\n return false; // Already exists\n } catch {\n // Create it\n }\n\n await mkdir(rulesDir, { recursive: true });\n\n await writeFile(\n join(rulesDir, \"conventions.md\"),\n `# Project Conventions\n\n- Use conventional commits (feat:, fix:, docs:, refactor:, test:, chore:)\n- Keep files under 400 lines, functions under 50 lines\n- Handle errors explicitly — no empty catch blocks\n- Validate input at system boundaries\n${SKILL_AUTHORING_SECTION}`,\n );\n\n log.success(\"Created .claude/rules/conventions.md with starter rules\");\n return true;\n}\n\nasync function addSkillAuthoringConventions(root: string): Promise<boolean> {\n const conventionsPath = join(root, \".claude\", \"rules\", \"conventions.md\");\n let content: string;\n try {\n content = await readFile(conventionsPath, \"utf-8\");\n } catch {\n // No conventions.md — createStarterRules will handle it\n return false;\n }\n\n if (/^##\\s+Skill\\s+Authoring/im.test(content)) return false;\n\n await writeFile(conventionsPath, content.trimEnd() + \"\\n\" + SKILL_AUTHORING_SECTION);\n log.success(\"Added Skill Authoring section to .claude/rules/conventions.md\");\n return true;\n}\n\nasync function createEnhanceSkill(root: string): Promise<boolean> {\n const skillDir = join(root, \".claude\", \"skills\", \"lp-enhance\");\n const skillPath = join(skillDir, \"SKILL.md\");\n const globalPath = join(homedir(), \".claude\", \"skills\", \"lp-enhance\", \"SKILL.md\");\n // Also check legacy commands/ location\n const legacyProject = join(root, \".claude\", \"commands\", \"lp-enhance.md\");\n const legacyGlobal = join(homedir(), \".claude\", \"commands\", \"lp-enhance.md\");\n\n if (await fileExists(skillPath) || await fileExists(globalPath)\n || await fileExists(legacyProject) || await fileExists(legacyGlobal)) return false;\n\n await mkdir(skillDir, { recursive: true });\n await writeFile(skillPath, generateEnhanceSkill());\n log.success(\"Generated /lp-enhance skill (.claude/skills/lp-enhance/)\");\n return true;\n}\n\nasync function updateEnhanceSkill(root: string): Promise<boolean> {\n // Update whichever location has the skill installed\n const projectPath = join(root, \".claude\", \"skills\", \"lp-enhance\", \"SKILL.md\");\n const globalPath = join(homedir(), \".claude\", \"skills\", \"lp-enhance\", \"SKILL.md\");\n\n const targetPath = await fileExists(projectPath) ? projectPath\n : await fileExists(globalPath) ? globalPath\n : null;\n\n if (!targetPath) return false;\n\n await writeFile(targetPath, generateEnhanceSkill());\n log.success(\"Updated /lp-enhance skill to latest version\");\n return true;\n}\n\n\n","/**\n * Shared CLAUDE.md section content used by both init generators and doctor fixer.\n * Single source of truth — prevents drift between init and --fix.\n */\n\nexport const SESSION_START_CONTENT =\n \"- ALWAYS read @TASKS.md first — it tracks progress across sessions\\n\" +\n \"- Check the Session Log at the bottom of TASKS.md for where we left off\\n\" +\n \"- Update TASKS.md as you complete work\";\n\nexport const BACKLOG_CONTENT =\n \"- When a feature is discussed but deferred, add it to BACKLOG.md immediately\\n\" +\n \"- Never leave future ideas only in TASKS.md or conversation — they get lost\\n\" +\n \"- BACKLOG.md is the single source of truth for parked features\";\n\nexport const STOP_AND_SWARM_CONTENT =\n \"Three failed iterations on the same problem = stop iterating alone.\\n\" +\n \"On the fourth attempt, spin up at least 3 parallel agents via the Agent tool, each investigating from a different angle:\\n\" +\n \"1. Root-cause debug agent\\n\" +\n \"2. Upstream library/docs research agent\\n\" +\n \"3. Alternative architecture agent\\n\" +\n \"Wait for all agents to return, synthesize their findings, then act.\\n\" +\n \"Don't keep guessing in circles — rotate perspectives.\";\n\nexport const OFF_LIMITS_CONTENT =\n \"- Never hardcode secrets — use environment variables\\n\" +\n \"- Never write to `.env` files\\n\" +\n \"- Never expose internal error details in API responses\";\n\nexport const SKILL_AUTHORING_CONTENT =\n \"When creating Claude Code skills (.claude/skills/*/SKILL.md):\\n\" +\n \"\\n\" +\n \"- Keep SKILL.md under 500 lines — move reference material to supporting files in the same directory\\n\" +\n \"- Front-load description (first 250 chars shown in listings) with TRIGGER when / DO NOT TRIGGER when clauses\\n\" +\n \"- Add allowed-tools in frontmatter to restrict tool access (e.g. Read, Glob, Grep for read-only skills)\\n\" +\n \"- Add argument-hint in frontmatter showing the expected input format (use $ARGUMENTS or $0, $1 for dynamic input)\\n\" +\n \"- Set disable-model-invocation: true for skills with side effects (deploy, send messages)\\n\" +\n \"- Structure as phases: Research, Plan, Execute, Verify with \\\"Done when:\\\" success criteria per phase\\n\" +\n \"- Handle edge cases and preconditions before execution\";\n","import { join, basename } from \"node:path\";\nimport { fileExists, readFileOrNull, readJsonOrNull } from \"./fs-utils.js\";\nimport type { DetectedProject } from \"../types/index.js\";\n\n/**\n * Detect project characteristics by scanning manifest files and directory structure.\n * Works with any stack — no hardcoded list of supported frameworks.\n */\nexport async function detectProject(root: string): Promise<DetectedProject> {\n const name = basename(root);\n\n const [pkgJson, goMod, pyProject, gemfile, cargo, pubspec, composerJson, pomXml, buildGradleGroovy, buildGradleKts, packageSwift, mixExs, csproj, lockfiles] = await Promise.all([\n readJsonOrNull<PackageJson>(join(root, \"package.json\")),\n fileExists(join(root, \"go.mod\")),\n readFileOrNull(join(root, \"pyproject.toml\")),\n fileExists(join(root, \"Gemfile\")),\n fileExists(join(root, \"Cargo.toml\")),\n fileExists(join(root, \"pubspec.yaml\")),\n readJsonOrNull<ComposerJson>(join(root, \"composer.json\")),\n fileExists(join(root, \"pom.xml\")),\n fileExists(join(root, \"build.gradle\")),\n fileExists(join(root, \"build.gradle.kts\")),\n fileExists(join(root, \"Package.swift\")),\n fileExists(join(root, \"mix.exs\")),\n globExists(root, \"*.csproj\"),\n detectLockfiles(root),\n ]);\n\n const buildGradle = buildGradleGroovy || buildGradleKts;\n\n const manifests: ManifestState = {\n pkgJson, goMod, pyProject, gemfile, cargo, pubspec,\n composerJson, pomXml, buildGradle, packageSwift, mixExs, csproj,\n };\n\n const language = detectLanguage(manifests);\n const framework = detectFramework(manifests);\n const packageManager = detectPackageManager(manifests, lockfiles);\n const scripts = detectScripts({ pkgJson, pyProject, goMod, gemfile, composerJson, language, packageManager });\n\n return {\n name,\n language,\n framework,\n packageManager,\n hasTests: scripts.testCommand !== null,\n hasLinter: scripts.lintCommand !== null,\n hasFormatter: scripts.formatCommand !== null,\n ...scripts,\n };\n}\n\n// ─── Language Detection ───\n\ninterface ManifestState {\n pkgJson: PackageJson | null;\n goMod: boolean;\n pyProject: string | null;\n gemfile: boolean;\n cargo: boolean;\n pubspec: boolean;\n composerJson: ComposerJson | null;\n pomXml: boolean;\n buildGradle: boolean;\n packageSwift: boolean;\n mixExs: boolean;\n csproj: boolean;\n}\n\nfunction detectLanguage(m: ManifestState): string | null {\n if (m.pkgJson?.devDependencies?.typescript || m.pkgJson?.dependencies?.typescript) return \"TypeScript\";\n if (m.pkgJson) return \"JavaScript\";\n if (m.goMod) return \"Go\";\n if (m.pyProject) return \"Python\";\n if (m.gemfile) return \"Ruby\";\n if (m.cargo) return \"Rust\";\n if (m.pubspec) return \"Dart\";\n if (m.composerJson) return \"PHP\";\n if (m.buildGradle) return \"Kotlin\";\n if (m.pomXml) return \"Java\";\n if (m.packageSwift) return \"Swift\";\n if (m.mixExs) return \"Elixir\";\n if (m.csproj) return \"C#\";\n return null;\n}\n\n// ─── Framework Detection ───\n\nfunction detectFramework(m: ManifestState): string | null {\n const deps = { ...m.pkgJson?.dependencies, ...m.pkgJson?.devDependencies };\n\n // JS/TS frameworks\n if (deps.next) return \"Next.js\";\n if (deps.nuxt) return \"Nuxt\";\n if (deps.svelte || deps[\"@sveltejs/kit\"]) return \"SvelteKit\";\n if (deps.astro) return \"Astro\";\n if (deps[\"@angular/core\"]) return \"Angular\";\n if (deps.remix || deps[\"@remix-run/react\"]) return \"Remix\";\n if (deps.vue) return \"Vue\";\n if (deps.react && !deps.next) return \"React\";\n if (deps.express) return \"Express\";\n if (deps.fastify) return \"Fastify\";\n if (deps.hono) return \"Hono\";\n if (deps.nestjs || deps[\"@nestjs/core\"]) return \"NestJS\";\n\n // Python frameworks\n if (m.pyProject) {\n if (m.pyProject.includes(\"fastapi\")) return \"FastAPI\";\n if (m.pyProject.includes(\"django\")) return \"Django\";\n if (m.pyProject.includes(\"flask\")) return \"Flask\";\n }\n\n // PHP frameworks\n if (m.composerJson) {\n const phpDeps = { ...m.composerJson.require, ...m.composerJson[\"require-dev\"] };\n if (phpDeps[\"laravel/framework\"]) return \"Laravel\";\n if (phpDeps[\"symfony/framework-bundle\"]) return \"Symfony\";\n }\n\n // Ruby\n if (m.gemfile) return \"Rails\";\n\n // JVM\n if (m.buildGradle) return \"Gradle\"; // Could be Spring Boot, Android, etc.\n if (m.pomXml) return \"Maven\";\n\n return null;\n}\n\n// ─── Package Manager Detection ───\n\ninterface DetectedLockfiles {\n pnpmLock: boolean;\n yarnLock: boolean;\n bunLock: boolean;\n npmLock: boolean;\n}\n\nasync function detectLockfiles(root: string): Promise<DetectedLockfiles> {\n const [pnpmLock, yarnLock, bunLock, npmLock] = await Promise.all([\n fileExists(join(root, \"pnpm-lock.yaml\")),\n fileExists(join(root, \"yarn.lock\")),\n fileExists(join(root, \"bun.lockb\")),\n fileExists(join(root, \"package-lock.json\")),\n ]);\n return { pnpmLock, yarnLock, bunLock, npmLock };\n}\n\nfunction detectPackageManager(\n m: Pick<ManifestState, \"pkgJson\" | \"goMod\" | \"pyProject\" | \"gemfile\" | \"cargo\" | \"composerJson\">,\n lockfiles: DetectedLockfiles,\n): string | null {\n if (m.pkgJson) {\n // Check packageManager field first (most explicit)\n const pm = m.pkgJson.packageManager;\n if (pm?.startsWith(\"pnpm\")) return \"pnpm\";\n if (pm?.startsWith(\"yarn\")) return \"yarn\";\n if (pm?.startsWith(\"bun\")) return \"bun\";\n if (pm?.startsWith(\"npm\")) return \"npm\";\n\n // Fall back to lockfile detection\n if (lockfiles.pnpmLock) return \"pnpm\";\n if (lockfiles.yarnLock) return \"yarn\";\n if (lockfiles.bunLock) return \"bun\";\n if (lockfiles.npmLock) return \"npm\";\n\n return \"npm\";\n }\n if (m.goMod) return \"go modules\";\n if (m.pyProject) {\n if (m.pyProject.includes(\"[tool.uv]\")) return \"uv\";\n if (m.pyProject.includes(\"[tool.poetry]\")) return \"poetry\";\n return \"pip\";\n }\n if (m.gemfile) return \"bundler\";\n if (m.cargo) return \"cargo\";\n if (m.composerJson) return \"composer\";\n return null;\n}\n\n// ─── Script Detection ───\n\ninterface DetectedScripts {\n formatCommand: string | null;\n lintCommand: string | null;\n testCommand: string | null;\n devCommand: string | null;\n buildCommand: string | null;\n}\n\n// Language → default scripts config\nconst LANGUAGE_SCRIPTS: Record<string, DetectedScripts> = {\n Go: { devCommand: \"go run .\", buildCommand: \"go build .\", testCommand: \"go test ./...\", lintCommand: \"golangci-lint run\", formatCommand: \"gofmt -w .\" },\n Ruby: { devCommand: \"bin/dev\", buildCommand: null, testCommand: \"bin/rails test\", lintCommand: \"bin/rubocop\", formatCommand: null },\n PHP: { devCommand: \"php artisan serve\", buildCommand: null, testCommand: \"php artisan test\", lintCommand: \"vendor/bin/phpstan analyse\", formatCommand: \"vendor/bin/pint\" },\n Rust: { devCommand: \"cargo run\", buildCommand: \"cargo build\", testCommand: \"cargo test\", lintCommand: \"cargo clippy\", formatCommand: \"cargo fmt\" },\n Java: { devCommand: null, buildCommand: \"mvn package\", testCommand: \"mvn test\", lintCommand: null, formatCommand: null },\n Kotlin: { devCommand: null, buildCommand: \"mvn package\", testCommand: \"mvn test\", lintCommand: null, formatCommand: null },\n Swift: { devCommand: null, buildCommand: \"swift build\", testCommand: \"swift test\", lintCommand: \"swiftlint\", formatCommand: \"swift-format format -r .\" },\n Elixir: { devCommand: \"mix phx.server\", buildCommand: \"mix compile\", testCommand: \"mix test\", lintCommand: \"mix credo\", formatCommand: \"mix format\" },\n \"C#\": { devCommand: \"dotnet run\", buildCommand: \"dotnet build\", testCommand: \"dotnet test\", lintCommand: null, formatCommand: \"dotnet format\" },\n};\n\nfunction detectScripts(m: {\n pkgJson: PackageJson | null;\n pyProject: string | null;\n goMod: boolean;\n gemfile: boolean;\n composerJson: ComposerJson | null;\n language: string | null;\n packageManager: string | null;\n}): DetectedScripts {\n // JS/TS: read from package.json scripts\n if (m.pkgJson) {\n const scripts = m.pkgJson.scripts ?? {};\n const run = pmRun(m.packageManager);\n return {\n devCommand: scripts.dev ? `${run} dev` : null,\n buildCommand: scripts.build ? `${run} build` : null,\n testCommand: scripts.test ? `${run} test` : null,\n lintCommand: scripts.lint ? `${run} lint` : null,\n formatCommand: scripts.format ? `${run} format` : null,\n };\n }\n\n // Python: runner depends on uv vs pip\n if (m.language === \"Python\") {\n const r = m.pyProject?.includes(\"[tool.uv]\") ? \"uv run\" : \"python -m\";\n return { devCommand: null, buildCommand: null, testCommand: `${r} pytest`, lintCommand: `${r} ruff check .`, formatCommand: `${r} ruff format .` };\n }\n\n // Everything else: lookup table\n if (m.language && LANGUAGE_SCRIPTS[m.language]) {\n return LANGUAGE_SCRIPTS[m.language];\n }\n\n return { devCommand: null, buildCommand: null, testCommand: null, lintCommand: null, formatCommand: null };\n}\n\nfunction pmRun(packageManager: string | null): string {\n if (packageManager === \"pnpm\") return \"pnpm\";\n if (packageManager === \"yarn\") return \"yarn\";\n if (packageManager === \"bun\") return \"bun\";\n return \"npm run\";\n}\n\n// ─── Utilities ───\n\ninterface PackageJson {\n name?: string;\n packageManager?: string;\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\ninterface ComposerJson {\n require?: Record<string, string>;\n \"require-dev\"?: Record<string, string>;\n}\n\nasync function globExists(dir: string, pattern: string): Promise<boolean> {\n const { readdir } = await import(\"node:fs/promises\");\n try {\n const entries = await readdir(dir);\n return entries.some((e) => e.endsWith(pattern.replace(\"*\", \"\")));\n } catch {\n return false;\n }\n}\n","import type { DetectedProject } from \"../../../types/index.js\";\n\n/**\n * Generate .claudeignore based on detected project type.\n * Prevents Claude from reading noise files that waste context.\n */\nexport function generateClaudeignore(detected: DetectedProject): string {\n const sections: string[] = [\"# Generated by claude-launchpad\"];\n\n // Universal ignores (every project)\n sections.push(`\n# Build output\ndist/\nbuild/\nout/\n\n# IDE & OS\n.vscode/\n.idea/\n*.swp\n*.swo\n.DS_Store\nThumbs.db\n\n# Test & coverage\ncoverage/\n\n# Environment (should never be read)\n.env\n.env.*\n!.env.example`);\n\n // Language-specific ignores\n const lang = detected.language;\n\n if (lang === \"TypeScript\" || lang === \"JavaScript\") {\n sections.push(`\n# Node\nnode_modules/\n.pnp/\n.yarn/\n.next/\n.nuxt/\n.output/\n.svelte-kit/\n.vercel/\n.turbo/\npnpm-lock.yaml\npackage-lock.json\nyarn.lock\nbun.lockb\n.nyc_output/\n__snapshots__/`);\n }\n\n if (lang === \"Python\") {\n sections.push(`\n# Python\n__pycache__/\n*.pyc\n*.pyo\n.venv/\nvenv/\n.mypy_cache/\n.ruff_cache/\n.pytest_cache/\n*.egg-info/`);\n }\n\n if (lang === \"Go\") {\n sections.push(`\n# Go\nbin/\nvendor/`);\n }\n\n if (lang === \"Rust\") {\n sections.push(`\n# Rust\ntarget/\nCargo.lock`);\n }\n\n if (lang === \"Ruby\") {\n sections.push(`\n# Ruby\nvendor/bundle/\n.bundle/\ntmp/\nlog/`);\n }\n\n if (lang === \"Java\" || lang === \"Kotlin\") {\n sections.push(`\n# JVM\ntarget/\nbuild/\n.gradle/\n*.class\n*.jar`);\n }\n\n if (lang === \"Dart\") {\n sections.push(`\n# Dart/Flutter\n.dart_tool/\n.packages\nbuild/`);\n }\n\n if (lang === \"PHP\") {\n sections.push(`\n# PHP\nvendor/\ncomposer.lock`);\n }\n\n if (lang === \"C#\") {\n sections.push(`\n# .NET\nbin/\nobj/\n*.dll`);\n }\n\n if (lang === \"Elixir\") {\n sections.push(`\n# Elixir\n_build/\ndeps/\n.elixir_ls/`);\n }\n\n if (lang === \"Swift\") {\n sections.push(`\n# Swift\n.build/\nDerivedData/\n*.xcuserdata`);\n }\n\n return sections.join(\"\\n\") + \"\\n\";\n}\n","/**\n * Skill schema version. Bump this when the skill content changes.\n * Doctor compares this against installed skills to detect stale versions.\n */\nexport const ENHANCE_SKILL_VERSION = 8;\n\n/**\n * Generates the /lp-enhance skill markdown content.\n * This skill runs inside the user's active Claude Code session\n * to analyze the codebase and improve CLAUDE.md.\n */\nexport function generateEnhanceSkill(): string {\n return [\n '---',\n 'name: lp-enhance',\n 'description: |',\n ' AI-improve your CLAUDE.md based on codebase analysis. Fills in architecture, conventions, guardrails, and suggests hooks and MCP servers.',\n ' TRIGGER when: user runs /lp-enhance, asks to \"improve CLAUDE.md\", \"fill in architecture\", or after major refactors.',\n ' DO NOT TRIGGER when: user is editing CLAUDE.md manually, doing normal coding, or running doctor/eval.',\n 'allowed-tools: Read, Glob, Grep, Edit, Write',\n 'argument-hint: (no arguments needed)',\n '---',\n '',\n `<!-- lp-enhance-version: ${ENHANCE_SKILL_VERSION} -->`,\n '',\n '# lp-enhance - AI-powered CLAUDE.md improver',\n '',\n 'Read CLAUDE.md and the project\\'s codebase, then update CLAUDE.md to fill in missing or incomplete sections.',\n '',\n '## Phase 1: Research',\n '',\n '1. Read CLAUDE.md (if it exists)',\n '2. Read .claude/CLAUDE.md (local config, if it exists)',\n '3. Read .claude/settings.json (hooks, permissions, MCP)',\n '4. Read .claude/settings.local.json (local settings, if it exists)',\n '5. Read .claude/rules/*.md (existing rules)',\n '6. Read .claudeignore (if it exists)',\n '7. Scan src/ directory structure (top-level dirs, key files)',\n '8. Read package.json / go.mod / pyproject.toml for stack detection',\n '9. Check for monorepo indicators (workspaces, nx.json, lerna.json)',\n '10. Check scenarios/ directory for existing eval scenarios',\n '',\n '**Done when:** you have a mental model of the stack, architecture, and existing config.',\n '',\n '## Phase 2: Plan',\n '',\n 'Count current CLAUDE.md actionable lines. Budget is 200 lines max. Plan which sections to add or improve:',\n '',\n '1. **## Stack** - detect language, framework, package manager',\n '2. **## Architecture** - 3-5 bullets describing codebase shape',\n '3. **## Conventions** - max 8 key patterns. Overflow to .claude/rules/conventions.md',\n '4. **## Off-Limits** - max 8 guardrails specific to this project',\n '5. **## Memory** - ONLY if agentic-memory is configured in settings.json. Max 6 bullets.',\n '6. **## Key Decisions** - only decisions that affect how Claude works in this codebase',\n '',\n '7. **Skill Authoring** - if .claude/rules/conventions.md lacks a Skill Authoring section, plan to add one',\n '',\n 'If any section would exceed 8 bullets, plan a .claude/rules/ file for the overflow.',\n '',\n '**Done when:** you know exactly what to add/change and the line count stays under 200.',\n '',\n '## Phase 3: Execute',\n '',\n 'Edit CLAUDE.md with the planned changes. Then:',\n '',\n '1. Create or update .claude/rules/ files for overflow content',\n '2. Generate path-scoped rules if the project has distinct areas (see below)',\n '3. Review .claudeignore and print suggestions (see below)',\n '4. Generate 2-3 custom eval scenarios in scenarios/custom/ (see below)',\n '5. Verify line count is under 200',\n '',\n '**Rules:**',\n '- Don\\'t remove existing content, only add or improve',\n '- Be specific to THIS project, not generic advice',\n '- Use bullet points, not paragraphs',\n '',\n '## Phase 4: Verify',\n '',\n '1. Run `claude-launchpad doctor` to check the score improved',\n '2. Print suggested hooks (exact JSON) for .claude/settings.json but don\\'t modify it',\n '3. Print suggested MCP servers if external services detected (Postgres, Redis, Stripe, etc.)',\n '4. If eval scenarios were generated, print: \"Run this in your terminal (not inside Claude Code): `claude-launchpad eval --scenarios scenarios/ --runs 1`\"',\n '',\n '**Done when:** doctor score is equal or higher, suggestions printed, eval scenarios created if applicable.',\n '',\n '## Path-scoped rules generation',\n '',\n 'Scan the project structure and generate focused .claude/rules/ files with paths: frontmatter. These load ONLY when Claude works on matching files, saving context tokens.',\n '',\n '**How to detect areas:**',\n '1. List top-level directories under src/ (or equivalent). Each distinct area (api, components, lib, tests) is a candidate.',\n '2. Check for monorepo indicators: workspaces in package.json, pnpm-workspace.yaml, nx.json, lerna.json. Each workspace is a candidate.',\n '3. Check for docs/, tests/, scripts/ as separate scopes.',\n '',\n '**For each detected area, create a rules file with this format:**',\n '',\n '---',\n 'paths: [\"src/api/**\"]',\n '---',\n '# API Rules',\n '- Validate all request input with zod schemas',\n '- Return typed error responses, never throw raw errors',\n '- Keep route handlers under 30 lines',\n '',\n '**Stack-specific patterns to include:**',\n '- Next.js app/: \"Use Server Components by default, add \\'use client\\' only when needed\"',\n '- API routes / src/api/: \"Validate input at boundaries, typed error responses\"',\n '- React components: \"Colocate components near usage, props interface above component\"',\n '- Tests: \"One assertion per test when possible, descriptive test names\"',\n '- Database / prisma/ / drizzle/: \"Never write raw SQL, use the ORM, migrations required\"',\n '- Docs: \"No em dashes, max 3 sentences per paragraph, code examples required\"',\n '',\n '**When NOT to generate:**',\n '- Small projects with < 5 source files (one conventions.md is enough)',\n '- Projects where all code is in one flat directory',\n '- If path-scoped rules already exist, don\\'t overwrite them',\n '',\n '**Monorepo handling:**',\n '- Each package gets its own rules file: .claude/rules/packages-<name>.md',\n '- Suggest claudeMdExcludes in settings.json to skip irrelevant package CLAUDE.md files',\n '',\n '## Skill authoring conventions',\n '',\n 'If .claude/rules/conventions.md exists but has no Skill Authoring section, add this:',\n '',\n '## Skill Authoring',\n '',\n 'When creating Claude Code skills (.claude/skills/*/SKILL.md):',\n '',\n '- Keep SKILL.md under 500 lines - move reference material to supporting files in the same directory',\n '- Front-load description (first 250 chars shown in listings) with TRIGGER when / DO NOT TRIGGER when clauses',\n '- Add allowed-tools in frontmatter to restrict tool access (e.g. Read, Glob, Grep for read-only skills)',\n '- Add argument-hint in frontmatter showing the expected input format (use $ARGUMENTS or $0, $1 for dynamic input)',\n '- Set disable-model-invocation: true for skills with side effects (deploy, send messages)',\n '- Structure as phases: Research, Plan, Execute, Verify with \"Done when:\" success criteria per phase',\n '- Handle edge cases and preconditions before execution',\n '',\n '## Hook review',\n '',\n 'Review .claude/settings.json hooks:',\n '- If you see project-specific patterns that deserve hooks, suggest them',\n '- If no PostCompact hook exists, suggest one that re-injects TASKS.md',\n '- If no SessionStart hook exists, suggest one that injects TASKS.md',\n '- DO NOT modify settings.json directly. Print exact JSON to add.',\n '',\n '## .claudeignore review',\n '',\n 'Read .claudeignore and check if the patterns make sense for the detected stack:',\n '',\n '**Always flag:**',\n '- Missing node_modules/ (JS/TS projects)',\n '- Missing __pycache__/ or .venv/ (Python projects)',\n '- Missing target/ (Rust/Java projects)',\n '- Missing .env / .env.* patterns',\n '- Missing lock files (pnpm-lock.yaml, package-lock.json, yarn.lock, etc.)',\n '- Missing coverage/ directory',\n '- Large generated files that waste context (*.min.js, *.map, migrations/)',\n '',\n '**Never flag:**',\n '- Patterns the user clearly added intentionally',\n '- Test fixtures or seed data (might be needed for context)',\n '',\n 'If .claudeignore is missing entirely, create one with sensible defaults for the detected stack.',\n 'If it exists but has gaps, print suggested additions. Do NOT modify it directly.',\n '',\n '## Eval scenario generation',\n '',\n 'After improving CLAUDE.md, generate 2-3 custom eval scenarios that test whether Claude follows the project\\'s specific rules. Write them as YAML files in scenarios/ at the project root.',\n '',\n '**Scenario YAML format:**',\n '```yaml',\n 'name: custom/scenario-name',\n 'description: What this scenario tests',\n 'setup:',\n ' files:',\n ' - path: src/example.ts',\n ' content: |',\n ' // Starter file that tempts Claude to break a rule',\n ' instructions: |',\n ' The specific rule from CLAUDE.md being tested.',\n 'prompt: \"A task that would tempt Claude to break the rule\"',\n 'checks:',\n ' - type: grep',\n ' pattern: \"expected_pattern\"',\n ' target: src/example.ts',\n ' expect: present',\n ' points: 5',\n ' label: What this check verifies',\n ' - type: file-exists',\n ' target: path/to/expected/file',\n ' expect: present',\n ' points: 5',\n ' label: What this check verifies',\n 'passingScore: 7',\n 'runs: 3',\n '```',\n '',\n '**How to choose scenarios:**',\n '1. Pick the 2-3 most important rules from ## Off-Limits and ## Conventions',\n '2. Design a task that naturally tempts Claude to break each rule',\n '3. Write checks that verify compliance (grep for patterns, file-exists for structure)',\n '',\n '**Check types available:** `grep` (pattern in file), `file-exists` (present/absent), `max-lines` (file length)',\n '',\n '**Examples of good custom scenarios:**',\n '- Off-limits says \"never use any\" → task asks to build types, check for no `any` keyword',\n '- Convention says \"max 400 lines per file\" → task asks to generate a large module, check line count',\n '- Off-limits says \"no raw SQL\" → task asks to add a query, check for ORM usage',\n '',\n '**Skip if:** scenarios/ already has 3+ YAML files, or CLAUDE.md has no project-specific rules worth testing.',\n '',\n '## Other advanced configuration',\n '',\n '- If you detect a monorepo, suggest claudeMdExcludes in settings.json',\n ].join('\\n');\n}\n","import { select } from \"@inquirer/prompts\";\nimport { readSettingsJson, readSettingsLocalJson, writeSettingsLocalJson } from \"./settings.js\";\nimport type { MemoryPlacement } from \"../types/index.js\";\n\nfunction hasMemoryPermissions(settings: Record<string, unknown>): boolean {\n const permissions = settings.permissions as Record<string, unknown> | undefined;\n const allow = (permissions?.allow as string[] | undefined) ?? [];\n return allow.some((p) => p.includes(\"agentic-memory\"));\n}\n\nexport async function getMemoryPlacement(root: string, skipPrompt = false): Promise<MemoryPlacement> {\n const local = (await readSettingsLocalJson(root)) ?? {};\n const persisted = local.memoryPlacement;\n if (persisted === \"shared\" || persisted === \"local\") {\n return persisted;\n }\n\n // Backfill: infer from where agentic-memory permissions already live\n if (hasMemoryPermissions(local)) {\n await writeSettingsLocalJson(root, { ...local, memoryPlacement: \"local\" });\n return \"local\";\n }\n const shared = (await readSettingsJson(root)) ?? {};\n if (hasMemoryPermissions(shared)) {\n await writeSettingsLocalJson(root, { ...local, memoryPlacement: \"shared\" });\n return \"shared\";\n }\n\n if (skipPrompt) return \"shared\";\n\n const choice = await select<MemoryPlacement>({\n message: \"Where should memory config go?\",\n choices: [\n { value: \"shared\", name: \"Shared (team sees it) — CLAUDE.md + settings.json\" },\n { value: \"local\", name: \"Local (only you) — .claude/CLAUDE.md + settings.local.json\" },\n ],\n });\n\n await writeSettingsLocalJson(root, { ...local, memoryPlacement: choice });\n return choice;\n}\n","/**\n * LP-STUB markers wrap AI-recommended boilerplate injected by `doctor --fix`.\n * The intent analyzer treats a marked section as \"not satisfied\" so the user\n * sees the flag until they replace the stub with real content (or delete the markers).\n */\n\nexport const LP_STUB_OPEN = \"<!-- LP-STUB: ai-recommended -->\";\nexport const LP_STUB_CLOSE = \"<!-- /LP-STUB -->\";\n\nexport function wrapStub(content: string): string {\n return `${LP_STUB_OPEN}\\n${content}\\n${LP_STUB_CLOSE}`;\n}\n\nexport function hasStubMarker(text: string): boolean {\n return text.includes(LP_STUB_OPEN);\n}\n","import { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { log } from \"../../lib/output.js\";\nimport { addHookToSettings } from \"../../lib/hook-builder.js\";\nimport { writeSprintHygieneScripts } from \"../../lib/hook-scripts.js\";\n\nconst WORKTREE_INCLUDE_TEMPLATE = `# Files copied into git worktrees that Claude Code creates for subagents.\n# Listed files must be gitignored — that's the point: keep secrets out of\n# commits while letting worktree subagents inherit local env so dev servers,\n# tests, and integration runs work the same as the main tree.\n# Anything needed by \\`pnpm dev\\`, \\`pnpm test\\`, etc. that's NOT committed\n# should land here.\n\n.env.local\n.env\n`;\n\nexport async function createWorktreeInclude(root: string): Promise<boolean> {\n await writeFile(join(root, \".worktreeinclude\"), WORKTREE_INCLUDE_TEMPLATE);\n log.success(\"Generated .worktreeinclude (worktree subagents inherit .env.local / .env)\");\n return true;\n}\n\nexport async function addSprintSizeHook(root: string): Promise<boolean> {\n await writeSprintHygieneScripts(root);\n return addHookToSettings(root, \"SessionStart\", \"sprint-size-check.sh\", {\n matcher: \"startup|resume\",\n hooks: [{ type: \"command\", command: \"bash .claude/hooks/sprint-size-check.sh TASKS.md 2>/dev/null; exit 0\" }],\n }, \"Added sprint-size-check hook (warns on microsprint/oversized sprints)\");\n}\n\nexport async function addSprintOpenHook(root: string): Promise<boolean> {\n await writeSprintHygieneScripts(root);\n return addHookToSettings(root, \"PreToolUse\", \"sprint-open-check.sh\", {\n matcher: \"Bash\",\n hooks: [{ type: \"command\", command: \"bash .claude/hooks/sprint-open-check.sh 2>/dev/null; exit 0\" }],\n }, \"Added sprint-open-check hook (warns on new sprint without BACKLOG cleanup)\");\n}\n\nexport async function addSprintCompleteNudge(root: string): Promise<boolean> {\n return addHookToSettings(root, \"PostToolUse\", \"Sprint complete\", {\n matcher: \"Edit|Write\",\n hooks: [{\n type: \"command\",\n command: \"echo \\\"$TOOL_INPUT_FILE_PATH\\\" | grep -q TASKS.md || exit 0; section=$(sed -n '/^## Current/,/^## /p' TASKS.md 2>/dev/null); [ -z \\\"$section\\\" ] && exit 0; unchecked=$(echo \\\"$section\\\" | grep -cF '- [ ]' || true); checked=$(echo \\\"$section\\\" | grep -cF '- [x]' || true); [ \\\"$unchecked\\\" -eq 0 ] && [ \\\"$checked\\\" -gt 0 ] && echo 'Sprint complete — all current tasks done. Consider a quick quality check before committing: scan for dead code, debug artifacts, TODO hacks, and convention violations. Run tests if available. Skip if trivial.'; exit 0\",\n }],\n }, \"Added sprint-complete nudge hook\");\n}\n","import { readSettingsJson, writeSettingsJson } from \"./settings.js\";\nimport { log } from \"./output.js\";\n\nexport interface HookCommand {\n readonly type: \"command\";\n readonly command: string;\n readonly timeout?: number;\n}\n\nexport interface HookEntry {\n readonly matcher?: string;\n readonly hooks: ReadonlyArray<HookCommand>;\n}\n\nexport interface AddHookOptions {\n readonly event: string;\n readonly dedupKeyword: string;\n readonly entry: HookEntry;\n readonly prepend?: boolean;\n}\n\nexport interface AddHookResult {\n readonly hooks: Record<string, unknown[]>;\n readonly added: boolean;\n}\n\nexport function addOrUpdateHook(\n existingHooks: Record<string, unknown[]> | undefined,\n options: AddHookOptions,\n): AddHookResult {\n const hookList = (existingHooks?.[options.event] ?? []) as Record<string, unknown>[];\n\n const alreadyHas = hookList.some((group) => {\n const nested = group.hooks as Record<string, unknown>[] | undefined;\n return nested?.some((h) => String(h.command ?? \"\").includes(options.dedupKeyword));\n });\n\n if (alreadyHas) {\n return { hooks: (existingHooks ?? {}) as Record<string, unknown[]>, added: false };\n }\n\n const newEntry = options.entry as unknown as Record<string, unknown>;\n const updated = options.prepend ? [newEntry, ...hookList] : [...hookList, newEntry];\n return {\n hooks: { ...(existingHooks ?? {}), [options.event]: updated },\n added: true,\n };\n}\n\nexport async function addHookToSettings(\n root: string,\n event: string,\n dedupKeyword: string,\n entry: HookEntry,\n successMsg: string,\n): Promise<boolean> {\n const settings = await readSettingsJson(root);\n if (settings === null) return false;\n const existingHooks = settings.hooks as Record<string, unknown[]> | undefined;\n\n const result = addOrUpdateHook(existingHooks, { event, dedupKeyword, entry });\n if (!result.added) return false;\n\n await writeSettingsJson(root, { ...settings, hooks: result.hooks });\n log.success(successMsg);\n return true;\n}\n","import { writeFile, mkdir, chmod } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport const SPRINT_SIZE_CHECK = `#!/usr/bin/env bash\n# Warns when the current sprint is too small (<3) or too large (>7).\n# Sweet spot is 3-6 work packages per sprint. Non-blocking (always exits 0).\n\nset -u\ntasks=\"\\${1:-TASKS.md}\"\n[ -f \"$tasks\" ] || exit 0\n\nsection=$(sed -n '/^## Current/,/^## /p' \"$tasks\" 2>/dev/null)\n[ -z \"$section\" ] && exit 0\n\nunchecked=$(echo \"$section\" | grep -cF -e '- [ ]' || true)\nchecked=$(echo \"$section\" | grep -cF -e '- [x]' || true)\ntotal=$((unchecked + checked))\n\nif [ \"$total\" -eq 0 ]; then\n echo \"NOTE: Current sprint has no work packages yet. Pull 3-6 from BACKLOG.md to start.\"\n exit 0\nfi\n\nif [ \"$unchecked\" -eq 0 ]; then exit 0; fi\n\nif [ \"$unchecked\" -lt 3 ]; then\n echo \"NOTE: Current sprint has $unchecked open work package(s) — that's a microsprint. Pull from BACKLOG.md (aim 3-6).\"\n exit 0\nfi\n\nif [ \"$unchecked\" -gt 7 ]; then\n echo \"NOTE: Current sprint has $unchecked open work packages — oversized. Move some back to BACKLOG.md (aim 3-6).\"\n exit 0\nfi\n\nexit 0\n`;\n\nexport const SPRINT_OPEN_CHECK = `#!/usr/bin/env bash\n# Warns when TASKS.md opens a new sprint block but BACKLOG.md has no staged\n# deletions, i.e. the \"remove pulled WPs from BACKLOG in the same edit\" rule\n# from CLAUDE.md was skipped. Non-blocking (always exits 0).\n\nset -u\ncmd=\"\\${TOOL_INPUT_COMMAND:-}\"\n\n# Only act on \\`git commit\\`, word-boundary match.\necho \"$cmd\" | grep -qE '(^|[^a-zA-Z0-9_-])git[[:space:]]+commit([[:space:]]|$)' || exit 0\n\n# Nothing staged\ngit diff --cached --quiet 2>/dev/null && exit 0\n\n# TASKS.md not staged\ngit diff --cached --name-only --diff-filter=ACM 2>/dev/null | grep -q '^TASKS\\\\.md$' || exit 0\n\n# Does the staged TASKS.md diff ADD a new \\`## Current\\` block?\nnew_sprint=$(git diff --cached TASKS.md 2>/dev/null | grep -cE '^\\\\+## Current')\n[ \"$new_sprint\" -eq 0 ] && exit 0\n\n# If a new sprint was opened, BACKLOG.md should have net deletions.\nbacklog_deletions=$(git diff --cached BACKLOG.md 2>/dev/null | grep -cE '^-[^-]')\nif [ \"$backlog_deletions\" -eq 0 ]; then\n echo \"\"\n echo \"WARNING: sprint-open hygiene\"\n echo \"\"\n echo \"TASKS.md stages a new '## Current' block, but BACKLOG.md has no\"\n echo \"staged deletions. When a WP is pulled from BACKLOG.md into a sprint,\"\n echo \"remove it from BACKLOG.md in the same edit. Overlap = drift.\"\n echo \"\"\n echo \"If you opened a fresh-scope sprint with no BACKLOG pulls, ignore\"\n echo \"this. Otherwise scrub BACKLOG.md before committing.\"\n echo \"\"\nfi\n\nexit 0\n`;\n\nexport interface InstalledScripts {\n readonly sizePath: string;\n readonly openPath: string;\n}\n\nexport async function writeSprintHygieneScripts(root: string): Promise<InstalledScripts> {\n const hooksDir = join(root, \".claude\", \"hooks\");\n await mkdir(hooksDir, { recursive: true });\n const sizePath = join(hooksDir, \"sprint-size-check.sh\");\n const openPath = join(hooksDir, \"sprint-open-check.sh\");\n await writeFile(sizePath, SPRINT_SIZE_CHECK);\n await writeFile(openPath, SPRINT_OPEN_CHECK);\n await chmod(sizePath, 0o755);\n await chmod(openPath, 0o755);\n return { sizePath, openPath };\n}\n","import { addHookToSettings } from \"../../lib/hook-builder.js\";\nimport type { DetectedProject } from \"../../types/index.js\";\n\nconst FORMATTERS: Record<string, { extensions: string[]; command: string }> = {\n TypeScript: { extensions: [\"ts\", \"tsx\"], command: \"npx prettier --write\" },\n JavaScript: { extensions: [\"js\", \"jsx\"], command: \"npx prettier --write\" },\n Python: { extensions: [\"py\"], command: \"ruff format\" },\n Go: { extensions: [\"go\"], command: \"gofmt -w\" },\n Rust: { extensions: [\"rs\"], command: \"rustfmt\" },\n Ruby: { extensions: [\"rb\"], command: \"rubocop -A\" },\n PHP: { extensions: [\"php\"], command: \"vendor/bin/pint\" },\n};\n\nexport async function addEnvProtectionHook(root: string): Promise<boolean> {\n return addHookToSettings(root, \"PreToolUse\", \".env\", {\n matcher: \"Read|Write|Edit\",\n hooks: [{\n type: \"command\",\n command: \"echo \\\"$TOOL_INPUT_FILE_PATH\\\" | grep -qE '\\\\.(env|env\\\\..*)$' && ! echo \\\"$TOOL_INPUT_FILE_PATH\\\" | grep -q '.env.example' && echo 'BLOCKED: .env files contain secrets' && exit 1; exit 0\",\n }],\n }, \"Added .env file protection hook (PreToolUse)\");\n}\n\nexport async function addAutoFormatHook(root: string, detected: DetectedProject): Promise<boolean> {\n if (!detected.language) return false;\n const config = detected.language ? FORMATTERS[detected.language] : null;\n if (!config) return false;\n\n const extChecks = config.extensions.map((ext) => `[ \"$ext\" = \"${ext}\" ]`).join(\" || \");\n return addHookToSettings(root, \"PostToolUse\", \"format\", {\n matcher: \"Write|Edit\",\n hooks: [{\n type: \"command\",\n command: `ext=\\${TOOL_INPUT_FILE_PATH##*.}; (${extChecks}) && ${config.command} \"$TOOL_INPUT_FILE_PATH\" 2>/dev/null; exit 0`,\n }],\n }, `Added auto-format hook (PostToolUse → ${config.command})`);\n}\n\nexport async function addForcePushProtection(root: string): Promise<boolean> {\n return addHookToSettings(root, \"PreToolUse\", \"force\", {\n matcher: \"Bash\",\n hooks: [{\n type: \"command\",\n command: \"echo \\\"$TOOL_INPUT_COMMAND\\\" | grep -qE 'push.*--force|push.*-f' && echo 'WARNING: Force push detected — this can destroy remote history' && exit 1; exit 0\",\n }],\n }, \"Added force-push protection hook (PreToolUse → Bash)\");\n}\n\nexport async function addPostCompactHook(root: string): Promise<boolean> {\n return addHookToSettings(root, \"PostCompact\", \"TASKS.md\", {\n matcher: \"\",\n hooks: [{ type: \"command\", command: \"cat TASKS.md 2>/dev/null; exit 0\" }],\n }, \"Added PostCompact hook (re-injects TASKS.md after compaction)\");\n}\n\nexport async function addSessionStartHook(root: string): Promise<boolean> {\n return addHookToSettings(root, \"SessionStart\", \"TASKS.md\", {\n matcher: \"startup|resume\",\n hooks: [{ type: \"command\", command: \"cat TASKS.md 2>/dev/null; exit 0\" }],\n }, \"Added SessionStart hook (injects TASKS.md at startup)\");\n}\n","import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { log } from \"../../lib/output.js\";\nimport { readSettingsJson, writeSettingsJson, readSettingsLocalJson, writeSettingsLocalJson } from \"../../lib/settings.js\";\nimport { addOrUpdateHook, type HookEntry } from \"../../lib/hook-builder.js\";\nimport type { MemoryPlacement } from \"../../types/index.js\";\n\n// ─── Shared Hook Helper (placement-aware) ───\n\nasync function addPlacementHook(\n root: string,\n placement: MemoryPlacement,\n event: string,\n dedupKeyword: string,\n entry: Record<string, unknown>,\n prepend: boolean,\n successMsg: string,\n): Promise<boolean> {\n const read = placement === \"local\" ? readSettingsLocalJson : readSettingsJson;\n const write = placement === \"local\" ? writeSettingsLocalJson : writeSettingsJson;\n const settings = await read(root);\n if (settings === null) return false;\n const existingHooks = settings.hooks as Record<string, unknown[]> | undefined;\n\n const result = addOrUpdateHook(existingHooks, {\n event,\n dedupKeyword,\n entry: entry as unknown as HookEntry,\n prepend,\n });\n if (!result.added) return false;\n\n await write(root, { ...settings, hooks: result.hooks });\n log.success(successMsg);\n return true;\n}\n\n// ─── Memory Fix Functions ───\n\nexport async function disableAutoMemory(root: string, placement: MemoryPlacement): Promise<boolean> {\n const read = placement === \"local\" ? readSettingsLocalJson : readSettingsJson;\n const write = placement === \"local\" ? writeSettingsLocalJson : writeSettingsJson;\n const settings = await read(root);\n if (settings === null) return false;\n if (settings.autoMemoryEnabled === false) return false;\n\n const updated = { ...settings, autoMemoryEnabled: false };\n await write(root, updated);\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n log.success(`Set autoMemoryEnabled: false in ${target}`);\n return true;\n}\n\nexport async function addMemoryToolPermissions(root: string, placement: MemoryPlacement): Promise<boolean> {\n const read = placement === \"local\" ? readSettingsLocalJson : readSettingsJson;\n const write = placement === \"local\" ? writeSettingsLocalJson : writeSettingsJson;\n const settings = await read(root);\n if (settings === null) return false;\n const permissions = (settings.permissions ?? {}) as Record<string, unknown>;\n const allow = (permissions.allow as string[] | undefined) ?? [];\n\n const tools = [\n \"mcp__agentic-memory__memory_store\",\n \"mcp__agentic-memory__memory_search\",\n \"mcp__agentic-memory__memory_recent\",\n \"mcp__agentic-memory__memory_forget\",\n \"mcp__agentic-memory__memory_relate\",\n \"mcp__agentic-memory__memory_stats\",\n \"mcp__agentic-memory__memory_update\",\n ];\n\n const missing = tools.filter((t) => !allow.includes(t));\n if (missing.length === 0) return false;\n\n const updated = { ...settings, permissions: { ...permissions, allow: [...allow, ...missing] } };\n await write(root, updated);\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n log.success(`Added agentic-memory MCP tool permissions to ${target}`);\n return true;\n}\n\nexport async function addSessionStartPullHook(root: string, placement: MemoryPlacement): Promise<boolean> {\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n return addPlacementHook(root, placement, \"SessionStart\", \"memory pull\", {\n matcher: \"startup\",\n hooks: [{ type: \"command\", command: \"claude-launchpad memory pull -y 2>/dev/null; exit 0\" }],\n }, true, `Added SessionStart hook for memory sync to ${target}`);\n}\n\nexport async function addSessionEndPushHook(root: string, placement: MemoryPlacement): Promise<boolean> {\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n return addPlacementHook(root, placement, \"SessionEnd\", \"memory push\", {\n hooks: [{ type: \"command\", command: \"nohup claude-launchpad memory push -y </dev/null >/dev/null 2>&1 & exit 0\" }],\n }, false, `Added SessionEnd hook for memory sync to ${target}`);\n}\n\nexport async function upgradeStaleSessionEndPushHook(root: string): Promise<boolean> {\n let changedAny = false;\n for (const placement of [\"shared\", \"local\"] as const) {\n const read = placement === \"local\" ? readSettingsLocalJson : readSettingsJson;\n const write = placement === \"local\" ? writeSettingsLocalJson : writeSettingsJson;\n const settings = await read(root);\n if (settings === null) continue;\n const hooks = settings.hooks as Record<string, unknown[]> | undefined;\n const sessionEnd = hooks?.SessionEnd as Record<string, unknown>[] | undefined;\n if (!sessionEnd) continue;\n\n let changed = false;\n const upgraded = sessionEnd.map((group) => {\n const inner = group.hooks as Record<string, unknown>[] | undefined;\n if (!inner) return group;\n const rewritten = inner.map((h) => {\n const cmd = typeof h.command === \"string\" ? h.command : \"\";\n if (!cmd.includes(\"memory push\") || cmd.includes(\"nohup\")) return h;\n changed = true;\n return { ...h, command: \"nohup claude-launchpad memory push -y </dev/null >/dev/null 2>&1 & exit 0\" };\n });\n return { ...group, hooks: rewritten };\n });\n if (!changed) continue;\n\n const updated = { ...settings, hooks: { ...hooks, SessionEnd: upgraded } };\n await write(root, updated);\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n log.success(`Upgraded SessionEnd push hook in ${target} (now nohup-wrapped)`);\n changedAny = true;\n }\n return changedAny;\n}\n\nexport async function removeStaleStopHook(root: string): Promise<boolean> {\n const settings = await readSettingsJson(root);\n if (settings === null) return false;\n const hooks = settings.hooks as Record<string, unknown[]> | undefined;\n if (!hooks?.Stop) return false;\n\n const stopHooks = hooks.Stop as Record<string, unknown>[];\n const filtered = stopHooks.filter((h) => {\n const innerHooks = h.hooks as Record<string, unknown>[] | undefined;\n return !innerHooks?.some(\n (ih) => typeof ih.command === \"string\" && (ih.command as string).includes(\"memory extract\"),\n );\n });\n\n if (filtered.length === stopHooks.length) return false;\n\n const updated = filtered.length === 0\n ? (({ Stop: _, ...rest }) => rest)(hooks as Record<string, unknown>)\n : { ...hooks, Stop: filtered };\n const updatedSettings = { ...settings, hooks: updated };\n await writeSettingsJson(root, updatedSettings);\n log.success(\"Removed deprecated Stop hook (memory extract)\");\n return true;\n}\n\n// ─── MCP Fix Functions ───\n\n/**\n * Prepend agentic-memory to allowedMcpServers when the allowlist is present but excludes it.\n * Only touches whichever placement already holds the allowlist — does not create one.\n */\nexport async function addMemoryToAllowedMcpServers(root: string): Promise<boolean> {\n let changed = false;\n for (const placement of [\"shared\", \"local\"] as const) {\n const read = placement === \"local\" ? readSettingsLocalJson : readSettingsJson;\n const write = placement === \"local\" ? writeSettingsLocalJson : writeSettingsJson;\n const settings = await read(root);\n if (settings === null) continue;\n const existing = settings.allowedMcpServers as unknown;\n if (!Array.isArray(existing)) continue;\n\n const list = existing as Array<{ serverName?: unknown }>;\n const hasMemory = list.some((e) => e && typeof e === \"object\" && e.serverName === \"agentic-memory\");\n if (hasMemory) continue;\n\n const updated = {\n ...settings,\n allowedMcpServers: [{ serverName: \"agentic-memory\" }, ...list],\n };\n await write(root, updated);\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n log.success(`Added agentic-memory to allowedMcpServers in ${target}`);\n changed = true;\n }\n return changed;\n}\n\nexport async function addAllowedMcpServers(root: string, placement: MemoryPlacement): Promise<boolean> {\n const read = placement === \"local\" ? readSettingsLocalJson : readSettingsJson;\n const write = placement === \"local\" ? writeSettingsLocalJson : writeSettingsJson;\n const settings = await read(root);\n if (settings === null) return false;\n if (settings.allowedMcpServers) return false;\n const other = placement === \"local\" ? await readSettingsJson(root) : await readSettingsLocalJson(root);\n if (other === null) return false;\n if (other.allowedMcpServers) return false;\n\n const serverNames = new Set<string>();\n const settingsServers = settings.mcpServers as Record<string, unknown> | undefined;\n if (settingsServers && typeof settingsServers === \"object\") {\n for (const name of Object.keys(settingsServers)) serverNames.add(name);\n }\n const mcpJsonPath = join(root, \".mcp.json\");\n try {\n const mcpJson = JSON.parse(await readFile(mcpJsonPath, \"utf-8\")) as Record<string, unknown>;\n const mcpServers = mcpJson.mcpServers as Record<string, unknown> | undefined;\n if (mcpServers && typeof mcpServers === \"object\") {\n for (const name of Object.keys(mcpServers)) serverNames.add(name);\n }\n } catch { /* no .mcp.json */ }\n\n if (serverNames.size === 0) return false;\n\n const updatedSettings = {\n ...settings,\n allowedMcpServers: [...serverNames].map((name) => ({ serverName: name })),\n };\n await write(root, updatedSettings);\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n log.success(`Added allowedMcpServers from configured servers to ${target}`);\n return true;\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,UAAU,cAAc;A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ACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA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,qBAAqB,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,IAAI,IAAI;AAC5F;","names":["readFile","writeFile","mkdir","join","readFile","writeFile","mkdir","access","join","writeFile","join","join","writeFile","join","readFile","join","join","readFile","join","readFile","writeFile","mkdir","access","readFile","join","mkdir","writeFile"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
readSyncConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-72VWDNAE.js";
|
|
5
5
|
import {
|
|
6
6
|
BACKLOG_CONTENT,
|
|
7
7
|
ENHANCE_SKILL_VERSION,
|
|
@@ -19,8 +19,9 @@ import {
|
|
|
19
19
|
printBanner,
|
|
20
20
|
printScoreCard,
|
|
21
21
|
readFileOrNull,
|
|
22
|
-
renderDoctorReport
|
|
23
|
-
|
|
22
|
+
renderDoctorReport,
|
|
23
|
+
writeSprintHygieneScripts
|
|
24
|
+
} from "./chunk-RCYLZUU6.js";
|
|
24
25
|
|
|
25
26
|
// src/cli.ts
|
|
26
27
|
import { Command as Command5 } from "commander";
|
|
@@ -128,7 +129,14 @@ function generateSettings(detected) {
|
|
|
128
129
|
matcher: "Edit|Write",
|
|
129
130
|
hooks: [{
|
|
130
131
|
type: "command",
|
|
131
|
-
command: `echo "$TOOL_INPUT_FILE_PATH" | grep -q TASKS.md || exit 0; section=$(sed -n '/^## Current
|
|
132
|
+
command: `echo "$TOOL_INPUT_FILE_PATH" | grep -q TASKS.md || exit 0; section=$(sed -n '/^## Current/,/^## /p' TASKS.md 2>/dev/null); [ -z "$section" ] && exit 0; unchecked=$(echo "$section" | grep -cF '- [ ]' || true); checked=$(echo "$section" | grep -cF '- [x]' || true); [ "$unchecked" -eq 0 ] && [ "$checked" -gt 0 ] && echo 'Sprint complete \u2014 all current tasks done. Consider a quick quality check before committing: scan for dead code, debug artifacts, TODO hacks, and convention violations. Run tests if available. Skip if trivial.'; exit 0`
|
|
133
|
+
}]
|
|
134
|
+
});
|
|
135
|
+
preToolUse.push({
|
|
136
|
+
matcher: "Bash",
|
|
137
|
+
hooks: [{
|
|
138
|
+
type: "command",
|
|
139
|
+
command: "bash .claude/hooks/sprint-open-check.sh 2>/dev/null; exit 0"
|
|
132
140
|
}]
|
|
133
141
|
});
|
|
134
142
|
const sessionStart = [{
|
|
@@ -137,6 +145,12 @@ function generateSettings(detected) {
|
|
|
137
145
|
type: "command",
|
|
138
146
|
command: "cat TASKS.md 2>/dev/null; exit 0"
|
|
139
147
|
}]
|
|
148
|
+
}, {
|
|
149
|
+
matcher: "startup|resume",
|
|
150
|
+
hooks: [{
|
|
151
|
+
type: "command",
|
|
152
|
+
command: "bash .claude/hooks/sprint-size-check.sh TASKS.md 2>/dev/null; exit 0"
|
|
153
|
+
}]
|
|
140
154
|
}];
|
|
141
155
|
const postCompact = [{
|
|
142
156
|
matcher: "",
|
|
@@ -307,6 +321,7 @@ async function scaffold(root, options, detected, skipPrompts) {
|
|
|
307
321
|
writes.push(writeFile(rulesPath, rulesContent));
|
|
308
322
|
}
|
|
309
323
|
await Promise.all(writes);
|
|
324
|
+
await writeSprintHygieneScripts(root);
|
|
310
325
|
log.success("Generated CLAUDE.md");
|
|
311
326
|
log.success("Generated TASKS.md");
|
|
312
327
|
if (!hasBacklog) log.success("Generated BACKLOG.md");
|
|
@@ -314,6 +329,7 @@ async function scaffold(root, options, detected, skipPrompts) {
|
|
|
314
329
|
if (!hasClaudeGitignore) log.success("Generated .claude/.gitignore");
|
|
315
330
|
if (!hasClaudeignore) log.success("Generated .claudeignore");
|
|
316
331
|
if (!hasRules) log.success("Generated .claude/rules/conventions.md");
|
|
332
|
+
log.success("Generated .claude/hooks/sprint-{size,open}-check.sh");
|
|
317
333
|
await createEnhanceSkillPrompt(root, skipPrompts);
|
|
318
334
|
log.blank();
|
|
319
335
|
log.success("Done! Run `claude` to start.");
|
|
@@ -406,7 +422,7 @@ var RULES_DIR = "rules";
|
|
|
406
422
|
async function parseClaudeConfig(projectRoot) {
|
|
407
423
|
const root = resolve(projectRoot);
|
|
408
424
|
const claudeDir = join2(root, CLAUDE_DIR);
|
|
409
|
-
const [claudeMd, localClaudeMd, settings, localSettings, hooks, rules, mcpServers, skills, claudeignore] = await Promise.all([
|
|
425
|
+
const [claudeMd, localClaudeMd, settings, localSettings, hooks, rules, mcpServers, skills, claudeignore, worktreeInclude, gitWorktreesActive] = await Promise.all([
|
|
410
426
|
readClaudeMd(root),
|
|
411
427
|
readFileOrNull(join2(claudeDir, CLAUDE_MD)),
|
|
412
428
|
readSettings(claudeDir),
|
|
@@ -415,7 +431,9 @@ async function parseClaudeConfig(projectRoot) {
|
|
|
415
431
|
readRules(claudeDir),
|
|
416
432
|
readMcpServers(claudeDir, root),
|
|
417
433
|
readSkills(claudeDir),
|
|
418
|
-
readFileOrNull(join2(root, ".claudeignore"))
|
|
434
|
+
readFileOrNull(join2(root, ".claudeignore")),
|
|
435
|
+
readFileOrNull(join2(root, ".worktreeinclude")),
|
|
436
|
+
detectGitWorktrees(root)
|
|
419
437
|
]);
|
|
420
438
|
const instructionCount = claudeMd ? countInstructions(claudeMd) : 0;
|
|
421
439
|
return {
|
|
@@ -431,9 +449,20 @@ async function parseClaudeConfig(projectRoot) {
|
|
|
431
449
|
mcpServers,
|
|
432
450
|
skills,
|
|
433
451
|
claudeignorePath: claudeignore !== null ? join2(root, ".claudeignore") : null,
|
|
434
|
-
claudeignoreContent: claudeignore
|
|
452
|
+
claudeignoreContent: claudeignore,
|
|
453
|
+
worktreeIncludePath: worktreeInclude !== null ? join2(root, ".worktreeinclude") : null,
|
|
454
|
+
worktreeIncludeContent: worktreeInclude,
|
|
455
|
+
gitWorktreesActive
|
|
435
456
|
};
|
|
436
457
|
}
|
|
458
|
+
async function detectGitWorktrees(root) {
|
|
459
|
+
try {
|
|
460
|
+
const entries = await readdir(join2(root, ".git", "worktrees"));
|
|
461
|
+
return entries.length > 0;
|
|
462
|
+
} catch {
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
437
466
|
async function readClaudeMd(root) {
|
|
438
467
|
return readFileOrNull(join2(root, CLAUDE_MD));
|
|
439
468
|
}
|
|
@@ -789,6 +818,33 @@ async function analyzeHooks(config) {
|
|
|
789
818
|
fix: "Add a SessionStart hook that injects TASKS.md at startup"
|
|
790
819
|
});
|
|
791
820
|
}
|
|
821
|
+
const usesTasksMd = hooks.some((h) => h.command?.includes("TASKS.md"));
|
|
822
|
+
if (usesTasksMd) {
|
|
823
|
+
if (!hooks.some((h) => h.command?.includes("sprint-size-check.sh"))) {
|
|
824
|
+
issues.push({
|
|
825
|
+
analyzer: "Hooks",
|
|
826
|
+
severity: "low",
|
|
827
|
+
message: "No sprint-size-check hook \u2014 sprints aren't enforced for size (sweet spot 3-6 work packages)",
|
|
828
|
+
fix: "Add SessionStart hook calling .claude/hooks/sprint-size-check.sh"
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
if (!hooks.some((h) => h.command?.includes("sprint-open-check.sh"))) {
|
|
832
|
+
issues.push({
|
|
833
|
+
analyzer: "Hooks",
|
|
834
|
+
severity: "low",
|
|
835
|
+
message: "No sprint-open-check hook \u2014 opening a new sprint without removing pulled WPs from BACKLOG silently drifts",
|
|
836
|
+
fix: "Add PreToolUse Bash hook calling .claude/hooks/sprint-open-check.sh"
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
if (!hooks.some((h) => h.command?.includes("Sprint complete"))) {
|
|
840
|
+
issues.push({
|
|
841
|
+
analyzer: "Hooks",
|
|
842
|
+
severity: "low",
|
|
843
|
+
message: "No sprint-complete nudge \u2014 finishing all sprint tasks goes unnoticed",
|
|
844
|
+
fix: "Add PostToolUse hook that nudges when all current-sprint checkboxes flip to [x]"
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
}
|
|
792
848
|
const score = Math.max(0, 100 - issues.length * 15);
|
|
793
849
|
return { name: "Hooks", issues, score };
|
|
794
850
|
}
|
|
@@ -1009,6 +1065,21 @@ async function analyzePermissions(config) {
|
|
|
1009
1065
|
});
|
|
1010
1066
|
}
|
|
1011
1067
|
}
|
|
1068
|
+
if (config.gitWorktreesActive) {
|
|
1069
|
+
const content = config.worktreeIncludeContent;
|
|
1070
|
+
const hasEntries = content !== null && content.split("\n").some((l) => {
|
|
1071
|
+
const trimmed = l.trim();
|
|
1072
|
+
return trimmed.length > 0 && !trimmed.startsWith("#");
|
|
1073
|
+
});
|
|
1074
|
+
if (!hasEntries) {
|
|
1075
|
+
issues.push({
|
|
1076
|
+
analyzer: "Permissions",
|
|
1077
|
+
severity: "medium",
|
|
1078
|
+
message: "Git worktrees in use but .worktreeinclude is missing or empty \u2014 subagent worktrees won't inherit gitignored .env files and tests fail silently",
|
|
1079
|
+
fix: "Create .worktreeinclude listing files (one per line) to copy into worktrees, e.g. .env.local"
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1012
1083
|
const score = Math.max(0, 100 - issues.length * 15);
|
|
1013
1084
|
return { name: "Permissions", issues, score };
|
|
1014
1085
|
}
|
|
@@ -2400,14 +2471,14 @@ function createMemoryCommand() {
|
|
|
2400
2471
|
log.error("Knowledge base not set up yet. Run `claude-launchpad memory` first.");
|
|
2401
2472
|
return;
|
|
2402
2473
|
}
|
|
2403
|
-
const { requireMemoryDeps } = await import("./require-deps-
|
|
2474
|
+
const { requireMemoryDeps } = await import("./require-deps-UBU5CYM5.js");
|
|
2404
2475
|
await requireMemoryDeps();
|
|
2405
|
-
const { startTui } = await import("./tui-
|
|
2476
|
+
const { startTui } = await import("./tui-FFLCUR7E.js");
|
|
2406
2477
|
await startTui();
|
|
2407
2478
|
return;
|
|
2408
2479
|
}
|
|
2409
2480
|
if (!isMemoryInstalled()) {
|
|
2410
|
-
const { detectExistingSetup } = await import("./install-
|
|
2481
|
+
const { detectExistingSetup } = await import("./install-XBCEI5QK.js");
|
|
2411
2482
|
const existing = detectExistingSetup(process.cwd());
|
|
2412
2483
|
const mcpMissing = existing !== null && !isMemoryMcpRegistered(process.cwd());
|
|
2413
2484
|
if (existing) {
|
|
@@ -2434,24 +2505,24 @@ function createMemoryCommand() {
|
|
|
2434
2505
|
log.info("Skipped.");
|
|
2435
2506
|
return;
|
|
2436
2507
|
}
|
|
2437
|
-
const { runInstall } = await import("./install-
|
|
2508
|
+
const { runInstall } = await import("./install-XBCEI5QK.js");
|
|
2438
2509
|
await runInstall({});
|
|
2439
2510
|
} else {
|
|
2440
|
-
const { requireMemoryDeps } = await import("./require-deps-
|
|
2511
|
+
const { requireMemoryDeps } = await import("./require-deps-UBU5CYM5.js");
|
|
2441
2512
|
await requireMemoryDeps();
|
|
2442
|
-
const { runStats } = await import("./stats-
|
|
2513
|
+
const { runStats } = await import("./stats-R4TWCPHW.js");
|
|
2443
2514
|
await runStats({});
|
|
2444
2515
|
}
|
|
2445
2516
|
});
|
|
2446
2517
|
memory.addCommand(
|
|
2447
2518
|
new Command4("install").description("Install (or re-install) the knowledge base for this project").option("--db-path <path>", "Override the default data directory").action(async (opts) => {
|
|
2448
|
-
const { runInstall } = await import("./install-
|
|
2519
|
+
const { runInstall } = await import("./install-XBCEI5QK.js");
|
|
2449
2520
|
await runInstall(opts.dbPath ? { dbPath: opts.dbPath } : {});
|
|
2450
2521
|
})
|
|
2451
2522
|
);
|
|
2452
2523
|
memory.addCommand(
|
|
2453
2524
|
new Command4("context").description("Load session context (hook handler)").option("--json", "JSON output").action(async (opts) => {
|
|
2454
|
-
const { runContext } = await import("./context-
|
|
2525
|
+
const { runContext } = await import("./context-X7UP2ODK.js");
|
|
2455
2526
|
await runContext(opts);
|
|
2456
2527
|
}).helpCommand(false),
|
|
2457
2528
|
{ hidden: true }
|
|
@@ -2466,7 +2537,7 @@ function createMemoryCommand() {
|
|
|
2466
2537
|
memory.addCommand(
|
|
2467
2538
|
new Command4("push").description("Push current project's memories to GitHub Gist").option("--all", "Push all projects").option("-y, --yes", "Skip confirmation prompt").action(async (opts) => {
|
|
2468
2539
|
await handleSyncErrors(async () => {
|
|
2469
|
-
const { runPush } = await import("./push-
|
|
2540
|
+
const { runPush } = await import("./push-C3M6Q4V7.js");
|
|
2470
2541
|
await runPush(opts);
|
|
2471
2542
|
});
|
|
2472
2543
|
})
|
|
@@ -2474,7 +2545,7 @@ function createMemoryCommand() {
|
|
|
2474
2545
|
memory.addCommand(
|
|
2475
2546
|
new Command4("pull").description("Pull current project's memories from GitHub Gist").option("--all", "Pull all projects").option("-y, --yes", "Non-interactive (accepted for symmetry with push; pull never prompts)").action(async (opts) => {
|
|
2476
2547
|
await handleSyncErrors(async () => {
|
|
2477
|
-
const { runPull } = await import("./pull-
|
|
2548
|
+
const { runPull } = await import("./pull-VA62U3OP.js");
|
|
2478
2549
|
await runPull(opts);
|
|
2479
2550
|
});
|
|
2480
2551
|
})
|
|
@@ -2483,7 +2554,7 @@ function createMemoryCommand() {
|
|
|
2483
2554
|
sync.addCommand(
|
|
2484
2555
|
new Command4("status").description("Show local vs remote memory counts per project").action(async () => {
|
|
2485
2556
|
await handleSyncErrors(async () => {
|
|
2486
|
-
const { runSyncStatus } = await import("./sync-status-
|
|
2557
|
+
const { runSyncStatus } = await import("./sync-status-TPYUF43G.js");
|
|
2487
2558
|
await runSyncStatus();
|
|
2488
2559
|
});
|
|
2489
2560
|
})
|
|
@@ -2491,7 +2562,7 @@ function createMemoryCommand() {
|
|
|
2491
2562
|
sync.addCommand(
|
|
2492
2563
|
new Command4("clean").description("Remove a project from the sync gist").argument("<project>", "Project slug to remove").option("-y, --yes", "Skip confirmation prompt").action(async (project, opts) => {
|
|
2493
2564
|
await handleSyncErrors(async () => {
|
|
2494
|
-
const { runSyncClean } = await import("./sync-clean-
|
|
2565
|
+
const { runSyncClean } = await import("./sync-clean-P4S7V2JS.js");
|
|
2495
2566
|
await runSyncClean(project, opts);
|
|
2496
2567
|
});
|
|
2497
2568
|
})
|
|
@@ -2501,7 +2572,7 @@ function createMemoryCommand() {
|
|
|
2501
2572
|
}
|
|
2502
2573
|
|
|
2503
2574
|
// src/cli.ts
|
|
2504
|
-
var program = new Command5().name("claude-launchpad").description("CLI toolkit that makes Claude Code setups measurably good").version("1.
|
|
2575
|
+
var program = new Command5().name("claude-launchpad").description("CLI toolkit that makes Claude Code setups measurably good").version("1.9.0", "-v, --version").action(async () => {
|
|
2505
2576
|
const hasConfig = await fileExists(join9(process.cwd(), "CLAUDE.md")) || await fileExists(join9(process.cwd(), ".claude", "settings.json"));
|
|
2506
2577
|
if (hasConfig) {
|
|
2507
2578
|
await program.commands.find((c) => c.name() === "doctor")?.parseAsync([], { from: "user" });
|