@holdpoint/cli 0.1.0-alpha.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/init.ts","../src/detect.ts","../src/commands/check.ts","../src/evolve/scanner.ts","../src/evolve/templates.ts","../src/evolve/dead-checker.ts","../src/commands/validate.ts","../src/commands/update.ts","../src/commands/build.ts","../src/commands/evolve.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { initCommand } from \"./commands/init.js\";\nimport { checkCommand } from \"./commands/check.js\";\nimport { validateCommand } from \"./commands/validate.js\";\nimport { updateCommand } from \"./commands/update.js\";\nimport { buildCommand } from \"./commands/build.js\";\nimport { evolveCommand } from \"./commands/evolve.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"holdpoint\")\n .description(\"Universal eval-guard for AI coding agents (alpha)\")\n .version(\"0.1.0-alpha.0\");\n\nprogram\n .command(\"init\")\n .description(\"Initialise Holdpoint in the current project\")\n .option(\"--stack <stack>\", \"Stack type: typescript | python | nextjs | fullstack\")\n .option(\"--agent <agent>\", \"Agent type: copilot | claude | cursor\")\n .action(initCommand);\n\nprogram\n .command(\"check\")\n .description(\"Run task checks from checks.yaml\")\n .option(\"--staged\", \"Only check against git-staged files\")\n .action(checkCommand);\n\nprogram\n .command(\"validate\")\n .description(\"Validate checks.yaml schema and print any errors\")\n .action(validateCommand);\n\nprogram\n .command(\"update\")\n .description(\"Regenerate engine files from current checks.yaml (preserves checks.yaml)\")\n .action(updateCommand);\n\nprogram\n .command(\"builder\")\n .description(\"Open the visual builder UI on localhost:4321\")\n .action(buildCommand);\n\nprogram\n .command(\"evolve\")\n .description(\"Scan project and propose (or apply) new checks to keep checks.yaml in sync\")\n .option(\"--apply\", \"Write proposed changes to checks.yaml and regenerate engine files\")\n .action(evolveCommand);\n\nprogram.parse();\n","import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { buildHookJson, buildCheckScript, buildConfigJson } from \"@holdpoint/engine-copilot\";\nimport { buildEngineJson as buildClaudeEngineJson } from \"@holdpoint/engine-claude\";\nimport { buildEngine as buildCursorEngine } from \"@holdpoint/engine-cursor\";\nimport { parseHoldpointYaml } from \"@holdpoint/yaml-core\";\nimport type { AgentType, StackType } from \"@holdpoint/types\";\nimport { detectAgent, detectStack } from \"../detect.js\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nfunction getTemplatePath(stack: StackType): string {\n const name = stack === \"unknown\" ? \"_base\" : stack;\n const candidates = [\n join(__dirname, \"templates\", `${name}.yaml`), // dist/templates/ (published package)\n join(__dirname, \"../../../templates\", `${name}.yaml`), // monorepo dev fallback\n join(process.cwd(), \"templates\", `${name}.yaml`), // cwd fallback\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n return \"\";\n}\n\nfunction getMasterPromptPath(): string {\n const candidates = [\n join(__dirname, \"templates/MASTER_PROMPT.md\"), // dist/templates/ (published package)\n join(__dirname, \"../../../templates/MASTER_PROMPT.md\"), // monorepo dev fallback\n join(process.cwd(), \"templates/MASTER_PROMPT.md\"), // cwd fallback\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n return \"\";\n}\n\nconst MINIMAL_CHECKS_YAML = `version: 1\ncontext:\n guides: {}\nconditions: []\nchecks:\n - id: lint\n label: \"Lint codebase\"\n cmd: \"echo 'Add your lint command here'\"\n\n - id: jsdoc\n label: \"JSDoc on changed public functions\"\n prompt: \"Ensure all changed public functions and exports have JSDoc comments.\"\n`;\n\nexport async function initCommand(options: { stack?: string; agent?: string }): Promise<void> {\n const spinner = ora(\"Initialising Holdpoint…\").start();\n\n const stack = (options.stack as StackType | undefined) ?? detectStack();\n const agent = (options.agent as AgentType | undefined) ?? detectAgent();\n\n spinner.text = `Detected stack: ${chalk.cyan(stack)}, agent: ${chalk.cyan(agent)}`;\n\n // 1. Read or create checks.yaml\n let yamlContent = MINIMAL_CHECKS_YAML;\n if (!existsSync(\"checks.yaml\")) {\n const templatePath = getTemplatePath(stack);\n if (templatePath) {\n yamlContent = readFileSync(templatePath, \"utf8\");\n }\n writeFileSync(\"checks.yaml\", yamlContent, \"utf8\");\n } else {\n yamlContent = readFileSync(\"checks.yaml\", \"utf8\");\n }\n\n const config = parseHoldpointYaml(yamlContent);\n\n // 2. Write checks.immutable.json — read by holdpoint-check.mjs at runtime\n const generatedDir = \".github/holdpoint/generated\";\n mkdirSync(generatedDir, { recursive: true });\n writeFileSync(`${generatedDir}/checks.immutable.json`, buildConfigJson(config), \"utf8\");\n\n // 3. Install engine files\n if (agent === \"copilot\" || agent === \"unknown\") {\n const hooksDir = \".github/hooks\";\n mkdirSync(hooksDir, { recursive: true });\n writeFileSync(join(hooksDir, \"holdpoint.json\"), buildHookJson(config), \"utf8\");\n writeFileSync(join(hooksDir, \"holdpoint-check.mjs\"), buildCheckScript(config), \"utf8\");\n }\n\n if (agent === \"claude\") {\n mkdirSync(\".claude\", { recursive: true });\n const settingsPath = \".claude/settings.json\";\n let existing: Record<string, unknown> = {};\n if (existsSync(settingsPath)) {\n try {\n existing = JSON.parse(readFileSync(settingsPath, \"utf8\")) as Record<string, unknown>;\n } catch {\n /* ignore */\n }\n }\n const holdpointHooks = JSON.parse(buildClaudeEngineJson(config)) as Record<string, unknown>;\n writeFileSync(\n settingsPath,\n JSON.stringify({ ...existing, hooks: holdpointHooks.hooks }, null, 2),\n \"utf8\",\n );\n }\n\n if (agent === \"cursor\") {\n const cursorRules = buildCursorEngine(config);\n const cursorPath = \".cursorrules\";\n if (existsSync(cursorPath)) {\n const existing = readFileSync(cursorPath, \"utf8\");\n if (!existing.includes(\"Holdpoint Rules\")) {\n writeFileSync(cursorPath, existing + \"\\n\" + cursorRules, \"utf8\");\n }\n } else {\n writeFileSync(cursorPath, cursorRules, \"utf8\");\n }\n }\n\n // 4. Create MASTER_PROMPT.md if not present\n if (!existsSync(\"MASTER_PROMPT.md\")) {\n const guidePath = getMasterPromptPath();\n if (guidePath) {\n copyFileSync(guidePath, \"MASTER_PROMPT.md\");\n } else {\n // Fallback: minimal prompt if template file is not bundled\n writeFileSync(\n \"MASTER_PROMPT.md\",\n \"# Holdpoint\\n\\nRun `npx holdpoint check` before marking any task complete.\\nSee `checks.yaml` for the full list of checks.\\n\",\n \"utf8\",\n );\n }\n }\n\n spinner.succeed(chalk.bold.green(\"Holdpoint initialised!\"));\n\n console.log(`\n${chalk.cyan(\"Next steps:\")}\n 1. Edit ${chalk.yellow(\"checks.yaml\")} to customise your eval checkpoints\n 2. Commit ${chalk.yellow(\"checks.yaml\")} and the generated engine files\n 3. Run ${chalk.yellow(\"npx holdpoint check\")} at any time to validate\n\n Visual builder: ${chalk.yellow(\"npx holdpoint builder\")} (opens localhost:4321)\n Stack: ${chalk.cyan(stack)} Agent: ${chalk.cyan(agent)}\n`);\n}\n","import { existsSync } from \"node:fs\";\nimport type { AgentType, StackType } from \"@holdpoint/types\";\n\nexport function detectAgent(): AgentType {\n // Copilot CLI: check for extensions dir or copilot binary in path\n if (existsSync(\".github/extensions\")) return \"copilot\";\n // Claude Code: check for .claude dir\n if (existsSync(\".claude\")) return \"claude\";\n // Cursor: check for .cursorrules\n if (existsSync(\".cursorrules\")) return \"cursor\";\n return \"unknown\";\n}\n\nexport function detectStack(): StackType {\n const hasNext =\n existsSync(\"next.config.ts\") || existsSync(\"next.config.js\") || existsSync(\"next.config.mjs\");\n const hasTsConfig = existsSync(\"tsconfig.json\");\n const hasPyproject =\n existsSync(\"pyproject.toml\") || existsSync(\"requirements.txt\") || existsSync(\"setup.py\");\n const hasPrisma = existsSync(\"prisma/schema.prisma\");\n const hasApi = existsSync(\"server\") || existsSync(\"api\") || existsSync(\"backend\");\n const hasGoMod = existsSync(\"go.mod\");\n\n if (hasNext && (hasPrisma || hasApi)) return \"fullstack\";\n if (hasNext) return \"nextjs\";\n if (hasTsConfig) return \"typescript\";\n if (hasPyproject) return \"python\";\n if (hasGoMod) return \"go\";\n return \"unknown\";\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { parseHoldpointYaml, matchesWhen } from \"@holdpoint/yaml-core\";\nimport { runDeterministicChecks } from \"@holdpoint/yaml-core/runner\";\nimport type { CheckResult } from \"@holdpoint/types\";\nimport { execSync } from \"node:child_process\";\nimport { scanProject } from \"../evolve/scanner.js\";\nimport { getTemplates } from \"../evolve/templates.js\";\nimport { detectStaleChecks, getRepoFiles } from \"../evolve/dead-checker.js\";\n\nfunction getStagedFiles(): string[] {\n try {\n const out = execSync(\"git diff --cached --name-only\", {\n encoding: \"utf8\",\n stdio: [\"pipe\", \"pipe\", \"ignore\"],\n });\n return out.trim().split(\"\\n\").filter(Boolean);\n } catch {\n return [];\n }\n}\n\nfunction getAllChangedFiles(): string[] {\n try {\n const out = execSync(\"git diff --name-only HEAD\", {\n encoding: \"utf8\",\n stdio: [\"pipe\", \"pipe\", \"ignore\"],\n });\n return out.trim().split(\"\\n\").filter(Boolean);\n } catch {\n return [];\n }\n}\n\nexport async function checkCommand(options: { staged?: boolean }): Promise<void> {\n if (!existsSync(\"checks.yaml\")) {\n console.error(chalk.red(\"No checks.yaml found. Run `holdpoint init` first.\"));\n process.exit(1);\n }\n\n const yamlContent = readFileSync(\"checks.yaml\", \"utf8\");\n let config;\n try {\n config = parseHoldpointYaml(yamlContent);\n } catch (err: unknown) {\n console.error(chalk.red(\"Invalid checks.yaml:\"), (err as Error).message);\n process.exit(1);\n }\n\n const changedFiles = options.staged ? getStagedFiles() : getAllChangedFiles();\n\n // Print project guides so the agent/human sees them before running checks\n const guides = Object.entries(config.context?.guides ?? {});\n if (guides.length > 0) {\n console.log(chalk.cyan(\"\\nProject guides:\"));\n for (const [key, text] of guides) {\n console.log(chalk.bold(` ${key}:`), chalk.dim(String(text).trim()));\n }\n console.log(\"\");\n }\n\n if (changedFiles.length === 0) {\n console.log(chalk.yellow(\"No changed files detected. Running all checks with no file filter.\"));\n }\n\n const taskCount = config.checks.filter((c) => c.cmd !== undefined).length;\n const spinner = ora(`Running ${taskCount} task(s)…`).start();\n const effectiveFiles = changedFiles.length > 0 ? changedFiles : [\"__all__\"];\n const results = runDeterministicChecks(config, effectiveFiles);\n\n // Built-in structural drift detection — hardcoded into holdpoint, not user-configurable.\n // Fires when structural indicator files changed (or when all checks run with no staged files).\n const runDrift = matchesWhen(\"structural\", effectiveFiles);\n if (runDrift) {\n const profile = scanProject();\n const existingIds = new Set(config.checks.map((c) => c.id));\n const templates = getTemplates(profile);\n const proposals = templates.filter((t) => t.trigger(profile) && !existingIds.has(t.id));\n const repoFiles = getRepoFiles(process.cwd());\n const staleChecks = detectStaleChecks(config, repoFiles);\n\n if (proposals.length > 0 || staleChecks.length > 0) {\n const lines: string[] = [];\n if (proposals.length > 0) {\n lines.push(`${proposals.length} new check(s) available for your project stack:`);\n for (const p of proposals) lines.push(` + ${p.label}`);\n }\n if (staleChecks.length > 0) {\n lines.push(`${staleChecks.length} stale check(s) no longer match your project:`);\n for (const s of staleChecks) lines.push(` - ${s.check.label}: ${s.reason}`);\n }\n lines.push(\"\\nRun: npx holdpoint evolve --apply\");\n results.push({\n check: { id: \"__holdpoint_evolve__\", label: \"Evolve checks with project structure\" },\n status: \"fail\",\n output: lines.join(\"\\n\"),\n });\n }\n }\n\n const passed = results.filter((r) => r.status === \"pass\");\n const failed = results.filter((r) => r.status === \"fail\");\n const skipped = results.filter((r) => r.status === \"skip\");\n\n spinner.stop();\n\n // Print results\n for (const result of results) {\n printResult(result);\n }\n\n // Summary\n console.log(\"\");\n console.log(\n [\n chalk.green(`✓ ${passed.length} passed`),\n failed.length > 0 ? chalk.red(`✗ ${failed.length} failed`) : \"\",\n skipped.length > 0 ? chalk.gray(`◌ ${skipped.length} skipped`) : \"\",\n ]\n .filter(Boolean)\n .join(\" \"),\n );\n\n // Prompt checks: show those whose when filter matches the changed files\n const promptChecks = config.checks.filter(\n (c) =>\n c.prompt !== undefined &&\n matchesWhen(c.when, changedFiles.length > 0 ? changedFiles : [\"__all__\"], config.patterns),\n );\n if (promptChecks.length > 0) {\n console.log(`\\n${chalk.cyan(\"Agent prompts to act on:\")}`);\n for (const c of promptChecks) {\n console.log(` ${chalk.yellow(\"□\")} [${c.label}] ${c.prompt ?? \"\"}`);\n }\n }\n\n if (failed.length > 0) {\n process.exit(1);\n }\n}\n\nfunction printResult(result: CheckResult): void {\n const icon =\n result.status === \"pass\"\n ? chalk.green(\"✓\")\n : result.status === \"fail\"\n ? chalk.red(\"✗\")\n : result.status === \"skip\"\n ? chalk.gray(\"◌\")\n : chalk.yellow(\"…\");\n\n const label = result.check.label;\n console.log(`${icon} ${label}`);\n\n if (result.status === \"fail\" && result.output) {\n const trimmed = result.output.trim().split(\"\\n\").slice(0, 10).join(\"\\n\");\n console.log(chalk.dim(trimmed.replace(/^/gm, \" \")));\n }\n if (result.status === \"skip\" && result.skipReason) {\n console.log(chalk.dim(` ${result.skipReason}`));\n }\n}\n","import { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { execSync } from \"node:child_process\";\n\nexport interface ProjectProfile {\n // Languages\n hasTypeScript: boolean;\n hasPython: boolean;\n hasGo: boolean;\n hasRust: boolean;\n hasJava: boolean;\n hasRuby: boolean;\n // Frameworks\n hasNext: boolean;\n hasReact: boolean;\n // Linting\n hasEslint: boolean;\n hasBiome: boolean;\n hasRuff: boolean;\n hasPrettier: boolean;\n // Testing\n hasVitest: boolean;\n hasJest: boolean;\n hasPytest: boolean;\n // DB\n hasPrisma: boolean;\n hasDrizzle: boolean;\n hasMigrations: boolean;\n hasAlembic: boolean;\n // Infra\n hasDocker: boolean;\n hasTerraform: boolean;\n hasKubernetes: boolean;\n // API\n hasOpenApi: boolean;\n // CI\n hasGithubActions: boolean;\n // Package manager\n packageManager: \"pnpm\" | \"yarn\" | \"bun\" | \"npm\";\n // Raw scripts from package.json\n scripts: Record<string, string>;\n // All dep names (deps + devDeps)\n deps: Set<string>;\n}\n\ntype PkgJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n scripts?: Record<string, string>;\n};\n\nfunction tryReadJson<T>(path: string): T | null {\n try {\n return JSON.parse(readFileSync(path, \"utf8\")) as T;\n } catch {\n return null;\n }\n}\n\nfunction tryReadText(path: string): string {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return \"\";\n }\n}\n\n/**\n * Walk a directory up to maxDepth levels, returning all file paths relative to root.\n * Excludes common build artifacts and dependency directories.\n */\nfunction walkDir(\n dir: string,\n root: string,\n depth: number,\n maxDepth: number,\n ignored: Set<string>,\n): string[] {\n if (depth > maxDepth) return [];\n let entries: string[] = [];\n try {\n entries = readdirSync(dir);\n } catch {\n return [];\n }\n const results: string[] = [];\n for (const entry of entries) {\n if (ignored.has(entry)) continue;\n const full = join(dir, entry);\n const rel = full.slice(root.length + 1);\n try {\n // Use stat-free heuristic: if it has an extension it's likely a file\n // If no extension and doesn't start with \".\", try as directory\n const hasExt = entry.includes(\".\");\n if (!hasExt || entry.startsWith(\".\")) {\n // Could be a dir — try recursing\n const children = walkDir(full, root, depth + 1, maxDepth, ignored);\n if (children.length > 0) {\n results.push(...children);\n } else if (hasExt) {\n results.push(rel);\n }\n } else {\n results.push(rel);\n }\n } catch {\n // skip\n }\n }\n return results;\n}\n\nconst WALK_IGNORED = new Set([\n \"node_modules\",\n \".git\",\n \"dist\",\n \"build\",\n \".next\",\n \".turbo\",\n \"__pycache__\",\n \".venv\",\n \"venv\",\n \".mypy_cache\",\n \"target\",\n \".cache\",\n \"coverage\",\n \".nyc_output\",\n]);\n\n/**\n * Returns a list of all files in the repo (relative paths from cwd).\n * Uses `git ls-files` when inside a git repo; falls back to directory walk.\n */\nexport function getRepoFiles(cwd: string): string[] {\n try {\n const out = execSync(\"git ls-files\", {\n cwd,\n encoding: \"utf8\",\n stdio: [\"pipe\", \"pipe\", \"ignore\"],\n });\n const files = out.trim().split(\"\\n\").filter(Boolean);\n if (files.length > 0) return files;\n } catch {\n // not a git repo or git not available\n }\n return walkDir(cwd, cwd, 0, 6, WALK_IGNORED);\n}\n\n/**\n * Returns true if the file path is a structural project indicator — i.e., a file\n * whose addition or modification may require new checks to be added to checks.yaml.\n * Mirrors the detection patterns used in `scanProject()`.\n */\nexport function isStructuralFile(file: string): boolean {\n const f = file.replace(/\\\\/g, \"/\");\n\n // JS / TS project structure\n if (f === \"package.json\") return true;\n if (/^tsconfig[^/]*\\.json$/.test(f)) return true;\n\n // Python\n if (/^requirements[^/]*\\.txt$/.test(f)) return true;\n if (f === \"pyproject.toml\") return true;\n if (f === \"Pipfile\") return true;\n if (f === \"setup.py\") return true;\n if (f === \"setup.cfg\") return true;\n if (f === \"pytest.ini\") return true;\n if (f === \"tox.ini\") return true;\n\n // Go\n if (f === \"go.mod\") return true;\n\n // Rust\n if (f === \"Cargo.toml\") return true;\n\n // Java / Kotlin\n if (f === \"pom.xml\") return true;\n if (/^build\\.gradle(\\.kts)?$/.test(f)) return true;\n\n // Ruby\n if (f === \"Gemfile\") return true;\n\n // Test frameworks\n if (/^vitest\\.config\\.[^/]+$/.test(f)) return true;\n if (/^jest\\.config\\.[^/]+$/.test(f)) return true;\n if (/^playwright\\.config\\.[^/]+$/.test(f)) return true;\n\n // Linters / formatters\n if (/^eslint\\.config\\.[^/]+$/.test(f)) return true;\n if (/^\\.eslintrc[^/]*$/.test(f)) return true;\n if (/^biome\\.jsonc?$/.test(f)) return true;\n if (/^prettier\\.config\\.[^/]+$/.test(f)) return true;\n if (/^\\.prettierrc[^/]*$/.test(f)) return true;\n\n // Next.js\n if (/^next\\.config\\.[^/]+$/.test(f)) return true;\n\n // Docker / infra\n if (/^Dockerfile[^/]*$/.test(f)) return true;\n if (/^docker-compose[^/]*\\.ya?ml$/.test(f)) return true;\n if (/[^/]*\\.tf$/.test(f)) return true;\n\n // Database\n if (f === \"prisma/schema.prisma\") return true;\n\n // OpenAPI\n if (/^(api\\/)?openapi\\.(yaml|yml|json)$/.test(f)) return true;\n\n // CI\n if (/^\\.github\\/workflows\\/[^/]+\\.ya?ml$/.test(f)) return true;\n if (/^\\.circleci\\/.+$/.test(f)) return true;\n if (f === \"Jenkinsfile\") return true;\n if (f === \".gitlab-ci.yml\") return true;\n if (f === \".travis.yml\") return true;\n\n return false;\n}\n\n/**\n * Scan the project at `cwd` and return a `ProjectProfile`.\n * All detection is pure filesystem reads — no shell commands executed.\n */\nexport function scanProject(cwd = process.cwd()): ProjectProfile {\n const exists = (p: string) => existsSync(join(cwd, p));\n\n // Package manager\n const packageManager: ProjectProfile[\"packageManager\"] = exists(\"pnpm-lock.yaml\")\n ? \"pnpm\"\n : exists(\"yarn.lock\")\n ? \"yarn\"\n : exists(\"bun.lockb\")\n ? \"bun\"\n : \"npm\";\n\n // package.json\n const pkg = tryReadJson<PkgJson>(join(cwd, \"package.json\"));\n const scripts = pkg?.scripts ?? {};\n const deps = new Set<string>([\n ...Object.keys(pkg?.dependencies ?? {}),\n ...Object.keys(pkg?.devDependencies ?? {}),\n ]);\n\n // Python manifest scanning\n const pyprojectText = tryReadText(join(cwd, \"pyproject.toml\"));\n const requirementsText = tryReadText(join(cwd, \"requirements.txt\"));\n const pipfileText = tryReadText(join(cwd, \"Pipfile\"));\n const allPyText = pyprojectText + requirementsText + pipfileText;\n\n const hasPytest =\n exists(\"pytest.ini\") ||\n exists(\"setup.cfg\") ||\n allPyText.includes(\"pytest\") ||\n allPyText.includes(\"[tool.pytest\");\n const hasRuff = allPyText.includes(\"ruff\") || deps.has(\"ruff\");\n const hasAlembic = allPyText.includes(\"alembic\") || deps.has(\"alembic\");\n\n // Root-level file listing (for Dockerfile variants and .tf files)\n let rootFiles: string[] = [];\n try {\n rootFiles = readdirSync(cwd);\n } catch {\n // ignore\n }\n\n const hasDocker =\n rootFiles.some((f) => f === \"Dockerfile\" || f.startsWith(\"Dockerfile.\")) ||\n exists(\"docker-compose.yml\") ||\n exists(\"docker-compose.yaml\") ||\n exists(\"docker-compose.dev.yml\");\n\n const hasTerraform =\n rootFiles.some((f) => f.endsWith(\".tf\")) || exists(\"terraform\") || exists(\"infra\");\n\n return {\n // Languages\n hasTypeScript: exists(\"tsconfig.json\") || deps.has(\"typescript\"),\n hasPython:\n Boolean(pyprojectText) ||\n Boolean(requirementsText) ||\n Boolean(pipfileText) ||\n exists(\"setup.py\"),\n hasGo: exists(\"go.mod\"),\n hasRust: exists(\"Cargo.toml\"),\n hasJava: exists(\"pom.xml\") || exists(\"build.gradle\") || exists(\"build.gradle.kts\"),\n hasRuby: exists(\"Gemfile\"),\n\n // Frameworks\n hasNext:\n exists(\"next.config.ts\") ||\n exists(\"next.config.js\") ||\n exists(\"next.config.mjs\") ||\n deps.has(\"next\"),\n hasReact: deps.has(\"react\"),\n\n // Linting\n hasEslint:\n exists(\"eslint.config.js\") ||\n exists(\"eslint.config.ts\") ||\n exists(\"eslint.config.mjs\") ||\n exists(\".eslintrc.js\") ||\n exists(\".eslintrc.json\") ||\n exists(\".eslintrc.yml\") ||\n exists(\".eslintrc.yaml\") ||\n deps.has(\"eslint\"),\n hasBiome: exists(\"biome.json\") || exists(\"biome.jsonc\") || deps.has(\"@biomejs/biome\"),\n hasRuff,\n hasPrettier:\n exists(\"prettier.config.js\") ||\n exists(\"prettier.config.ts\") ||\n exists(\"prettier.config.mjs\") ||\n exists(\".prettierrc\") ||\n exists(\".prettierrc.json\") ||\n deps.has(\"prettier\"),\n\n // Testing\n hasVitest: deps.has(\"vitest\") || Boolean(scripts[\"test\"]?.includes(\"vitest\")),\n hasJest: deps.has(\"jest\") || Boolean(scripts[\"test\"]?.includes(\"jest\")),\n hasPytest,\n\n // DB\n hasPrisma: exists(\"prisma/schema.prisma\") || deps.has(\"@prisma/client\"),\n hasDrizzle: deps.has(\"drizzle-orm\"),\n hasMigrations: exists(\"migrations\") || exists(\"db/migrations\") || exists(\"database/migrations\"),\n hasAlembic,\n\n // Infra\n hasDocker,\n hasTerraform,\n hasKubernetes: exists(\"k8s\") || exists(\"kubernetes\") || exists(\"helm\"),\n\n // API\n hasOpenApi:\n exists(\"openapi.yaml\") ||\n exists(\"openapi.yml\") ||\n exists(\"openapi.json\") ||\n exists(\"api/openapi.yaml\"),\n\n // CI\n hasGithubActions: exists(\".github/workflows\"),\n\n packageManager,\n scripts,\n deps,\n };\n}\n","import type { ConditionDef } from \"@holdpoint/types\";\nimport type { ProjectProfile } from \"./scanner.js\";\n\nexport interface EvolveTemplate {\n id: string;\n label: string;\n when?: string;\n cmd?: string;\n prompt?: string;\n conditionId?: string;\n /** Condition to add to checks.yaml alongside the check (only if conditionId is set) */\n condition?: Omit<ConditionDef, \"id\"> & { id: string };\n /** Returns true if this check is relevant to the given project profile */\n trigger: (p: ProjectProfile) => boolean;\n}\n\n/** Returns the correct run command for a package.json script, respecting the detected package manager. */\nfunction pmScript(profile: ProjectProfile, script: string, fallback: string): string {\n if (!profile.scripts[script]) return fallback;\n if (profile.packageManager === \"npm\") return `npm run ${script}`;\n return `${profile.packageManager} ${script}`;\n}\n\n/**\n * Returns all applicable check templates for the given project profile.\n * Caller should filter out templates whose IDs already exist in checks.yaml.\n */\nexport function getTemplates(profile: ProjectProfile): EvolveTemplate[] {\n return [\n // ── Universal checks (always proposed for any project) ──────────────────\n {\n id: \"git-commit\",\n label: \"Commit all changes before finishing\",\n cmd: 'git rev-parse --is-inside-work-tree 2>/dev/null || exit 0; [ -z \"$(git status --porcelain)\" ] && exit 0; git status --short; exit 1',\n trigger: () => true,\n },\n {\n id: \"changelog-update\",\n label: \"Add a CHANGELOG.md entry for this session\",\n prompt:\n \"Before committing, add an entry to CHANGELOG.md describing what was done. \" +\n \"Use Keep a Changelog format — add under ## [Unreleased] (create the file \" +\n \"and that section if absent). Group entries as Added, Changed, Fixed, or Removed. \" +\n \"Be concise but specific. The entry text will serve as the commit message.\",\n trigger: () => true,\n },\n {\n id: \"readme-sync\",\n label: \"Update README.md if user-facing changes were made\",\n prompt:\n \"If you added, changed, or removed user-facing functionality — CLI commands, \" +\n \"configuration options, public APIs, or significant new features — update \" +\n \"README.md to reflect those changes.\",\n trigger: () => true,\n },\n {\n id: \"no-todos\",\n label: \"No TODO/FIXME left in changed code\",\n prompt:\n \"Scan the files you changed for any TODO, FIXME, HACK, or XXX comments. \" +\n \"Either resolve them before finishing or convert them to GitHub issues. \" +\n \"Don't leave incomplete work silently behind.\",\n trigger: () => true,\n },\n\n // ── TypeScript / JavaScript ──────────────────────────────────────────────\n {\n id: \"typecheck\",\n label: \"TypeScript type check\",\n cmd: pmScript(profile, \"typecheck\", \"npx tsc --noEmit\"),\n trigger: (p) => p.hasTypeScript,\n },\n {\n id: \"lint\",\n label: \"Lint codebase\",\n cmd: profile.hasEslint\n ? pmScript(profile, \"lint\", \"npx eslint .\")\n : profile.hasBiome\n ? pmScript(profile, \"lint\", \"npx @biomejs/biome check .\")\n : pmScript(profile, \"lint\", \"echo 'No linter detected'\"),\n trigger: (p) => p.hasEslint || p.hasBiome,\n },\n {\n id: \"format-check\",\n label: \"Prettier — format check\",\n cmd: pmScript(profile, \"format:check\", \"npx prettier --check .\"),\n trigger: (p) => p.hasPrettier,\n },\n {\n id: \"test\",\n label: \"Unit tests\",\n cmd: profile.hasVitest\n ? pmScript(profile, \"test\", \"npx vitest run\")\n : pmScript(profile, \"test\", \"npx jest --passWithNoTests\"),\n trigger: (p) => p.hasVitest || p.hasJest,\n },\n {\n id: \"jsdoc\",\n label: \"JSDoc on changed public functions\",\n prompt:\n \"Ensure all changed public functions, classes, and module exports have \" +\n \"accurate JSDoc comments (description + @param + @returns where applicable).\",\n trigger: (p) => p.hasTypeScript || p.hasReact,\n },\n {\n id: \"build\",\n label: \"Production build passes\",\n cmd: pmScript(profile, \"build\", \"echo 'No build script detected'\"),\n trigger: (p) => Boolean(p.scripts[\"build\"]),\n },\n\n // ── Python ───────────────────────────────────────────────────────────────\n {\n id: \"python-lint\",\n label: \"Ruff — Python linting\",\n cmd: \"ruff check .\",\n when: \"python\",\n trigger: (p) => p.hasPython && p.hasRuff,\n },\n {\n id: \"python-test\",\n label: \"Pytest — Python unit tests\",\n cmd: \"pytest\",\n when: \"python\",\n trigger: (p) => p.hasPython && p.hasPytest,\n },\n\n // ── Go ───────────────────────────────────────────────────────────────────\n {\n id: \"go-test\",\n label: \"Go tests\",\n cmd: \"go test ./...\",\n when: \"go\",\n trigger: (p) => p.hasGo,\n },\n {\n id: \"go-vet\",\n label: \"Go vet\",\n cmd: \"go vet ./...\",\n when: \"go\",\n trigger: (p) => p.hasGo,\n },\n\n // ── Database ─────────────────────────────────────────────────────────────\n {\n id: \"db-migrations\",\n label: \"Database migration for schema changes\",\n when: \"database\",\n prompt:\n \"If schema or migration files changed, ensure the appropriate migration was \" +\n \"generated with your ORM tool (e.g. `prisma migrate dev`, `alembic revision`, \" +\n \"`rails db:migrate`) and committed alongside the schema change.\",\n trigger: (p) => p.hasPrisma || p.hasAlembic || p.hasMigrations || p.hasDrizzle,\n },\n {\n id: \"prisma-format\",\n label: \"Prisma schema format check\",\n when: \"prisma\",\n cmd: \"npx prisma format --check 2>/dev/null || npx prisma format\",\n conditionId: \"has-prisma\",\n condition: {\n id: \"has-prisma\",\n operator: \"file_exists\",\n path: \"prisma/schema.prisma\",\n },\n trigger: (p) => p.hasPrisma,\n },\n\n // ── OpenAPI ──────────────────────────────────────────────────────────────\n {\n id: \"openapi-sync\",\n label: \"OpenAPI spec updated for API changes\",\n when: \"backend\",\n conditionId: \"has-openapi\",\n condition: {\n id: \"has-openapi\",\n operator: \"file_exists\",\n path: \"openapi.yaml\",\n },\n prompt:\n \"If any API routes were added or changed, update openapi.yaml (or openapi.json) \" +\n \"to reflect the new endpoints, request/response shapes, and error codes.\",\n trigger: (p) => p.hasOpenApi,\n },\n\n // ── Infra ─────────────────────────────────────────────────────────────────\n {\n id: \"docker-build\",\n label: \"Docker build passes\",\n when: \"infra\",\n cmd: \"docker build . --quiet -t app:ci\",\n conditionId: \"has-dockerfile\",\n condition: {\n id: \"has-dockerfile\",\n operator: \"file_exists\",\n path: \"Dockerfile\",\n },\n trigger: (p) => p.hasDocker,\n },\n {\n id: \"terraform-validate\",\n label: \"Terraform validate\",\n when: \"infra\",\n cmd: \"terraform validate\",\n trigger: (p) => p.hasTerraform,\n },\n\n // ── Frontend ─────────────────────────────────────────────────────────────\n {\n id: \"i18n\",\n label: \"i18n — no hardcoded user-facing strings\",\n when: \"frontend\",\n prompt:\n \"Confirm all user-visible strings are wrapped in the project's i18n function \" +\n \"(e.g. `t()`, `useTranslation`, `<Trans>`) and that locale files are updated \" +\n \"for any new copy.\",\n trigger: (p) => p.hasNext && p.hasReact,\n },\n ];\n}\n","import { execSync } from \"node:child_process\";\nimport { readdirSync, existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { CheckDef, HoldpointConfig } from \"@holdpoint/types\";\n\nexport interface StaleCheck {\n check: CheckDef;\n reason: string;\n /** Path to use in a file_exists condition, if it can be inferred from the when: regex */\n suggestedConditionPath?: string;\n}\n\n/** Named scopes handled by matchesWhen() — these are never \"stale\" (intentionally broad) */\nconst NAMED_SCOPES = new Set([\n \"frontend\",\n \"backend\",\n \"socket\",\n \"visual\",\n \"python\",\n \"go\",\n \"rust\",\n \"java\",\n \"ruby\",\n \"database\",\n \"prisma\",\n \"testing\",\n \"infra\",\n \"ci\",\n \"docs\",\n \"structural\",\n]);\n\nconst WALK_IGNORED = new Set([\n \"node_modules\",\n \".git\",\n \"dist\",\n \"build\",\n \".next\",\n \".turbo\",\n \"__pycache__\",\n \".venv\",\n \"venv\",\n \".mypy_cache\",\n \"target\",\n \".cache\",\n \"coverage\",\n]);\n\nfunction walkDir(dir: string, root: string, depth: number, maxDepth: number): string[] {\n if (depth > maxDepth) return [];\n let entries: string[] = [];\n try {\n entries = readdirSync(dir);\n } catch {\n return [];\n }\n const results: string[] = [];\n for (const entry of entries) {\n if (WALK_IGNORED.has(entry) || entry.startsWith(\".\")) continue;\n const full = join(dir, entry);\n const rel = full.slice(root.length + 1);\n results.push(rel);\n // Try to recurse (will just return [] if it's a file, not a dir)\n const children = walkDir(full, root, depth + 1, maxDepth);\n results.push(...children);\n }\n return results;\n}\n\n/**\n * Returns a list of all files in the repo (relative paths from cwd).\n * Uses `git ls-files` when available; falls back to directory walk.\n */\nexport function getRepoFiles(cwd: string): string[] {\n try {\n const out = execSync(\"git ls-files\", {\n cwd,\n encoding: \"utf8\",\n stdio: [\"pipe\", \"pipe\", \"ignore\"],\n });\n const files = out.trim().split(\"\\n\").filter(Boolean);\n if (files.length > 0) return files;\n } catch {\n // not a git repo or git not available\n }\n return walkDir(cwd, cwd, 0, 6);\n}\n\n/**\n * Try to extract a simple path hint from a regex pattern, for use as a\n * `file_exists` condition path.\n * e.g. \"^prisma/\" → \"prisma\", \"^checks\\\\.yaml$\" → \"checks.yaml\"\n */\nfunction extractPathFromRegex(pattern: string): string | undefined {\n const cleaned = pattern\n .replace(/^\\^/, \"\")\n .replace(/\\$$/, \"\")\n .replace(/\\\\\\./g, \".\")\n .replace(/\\(\\?:/g, \"\")\n .replace(/\\)/g, \"\")\n .replace(/[|*+?[\\]{}()]/g, \"\");\n const candidate = cleaned.replace(/\\/$/, \"\").trim();\n if (candidate.length > 0 && /^[\\w\\-./]+$/.test(candidate)) return candidate;\n return undefined;\n}\n\n/**\n * Detect checks whose `when:` regex pattern matches zero files in the repo.\n * Named scope whens (frontend, backend, structural, etc.) are never flagged as stale.\n * User-defined named patterns (from config.patterns) are resolved to their regex before checking.\n * Checks that already have a conditionId are skipped (already guarded).\n */\nexport function detectStaleChecks(config: HoldpointConfig, repoFiles: string[]): StaleCheck[] {\n const stale: StaleCheck[] = [];\n const userPatterns = config.patterns ?? {};\n\n for (const check of config.checks) {\n if (!check.when) continue;\n if (NAMED_SCOPES.has(check.when)) continue;\n if (check.conditionId) continue; // already guarded by a condition\n\n // Resolve user-defined named patterns to their regex value\n const patternAlias = check.when in userPatterns ? check.when : undefined;\n const regexStr = patternAlias ? userPatterns[patternAlias]! : check.when;\n\n let re: RegExp;\n try {\n re = new RegExp(regexStr);\n } catch {\n stale.push({ check, reason: `Invalid regex: '${regexStr}'` });\n continue;\n }\n\n const matches = repoFiles.filter((f) => re.test(f));\n if (matches.length === 0) {\n const label = patternAlias\n ? `Pattern '${patternAlias}' (= '${regexStr}')`\n : `Regex '${regexStr}'`;\n const suggestedConditionPath = extractPathFromRegex(regexStr);\n // Verify the suggested path doesn't actually exist either\n const pathGone =\n !suggestedConditionPath || !existsSync(join(process.cwd(), suggestedConditionPath));\n if (pathGone) {\n stale.push({\n check,\n reason: `${label} matches 0 files in the repo`,\n ...(suggestedConditionPath ? { suggestedConditionPath } : {}),\n });\n }\n }\n }\n\n return stale;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport chalk from \"chalk\";\nimport { parseHoldpointYaml, validateConfig } from \"@holdpoint/yaml-core\";\n\nexport async function validateCommand(): Promise<void> {\n if (!existsSync(\"checks.yaml\")) {\n console.error(chalk.red(\"No checks.yaml found. Run `holdpoint init` first.\"));\n process.exit(1);\n }\n\n const text = readFileSync(\"checks.yaml\", \"utf8\");\n\n let config;\n try {\n config = parseHoldpointYaml(text);\n } catch (err: unknown) {\n console.error(chalk.red(\"Parse error:\"), (err as Error).message);\n process.exit(1);\n }\n\n const result = validateConfig(config);\n\n if (result.valid) {\n console.log(chalk.green(\"✓ checks.yaml is valid\"));\n console.log(\n chalk.dim(\n ` ${config.checks.filter((c) => c.cmd !== undefined).length} tasks, ${config.checks.filter((c) => c.prompt !== undefined).length} prompts, ${config.conditions.length} conditions`,\n ),\n );\n } else {\n console.error(chalk.red(\"✗ checks.yaml has errors:\"));\n for (const err of result.errors) {\n console.error(` ${chalk.yellow(err.path)}: ${err.message}`);\n }\n process.exit(1);\n }\n}\n","import { existsSync, readFileSync, writeFileSync, mkdirSync } from \"node:fs\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { parseHoldpointYaml } from \"@holdpoint/yaml-core\";\nimport { buildHookJson, buildCheckScript, buildConfigJson } from \"@holdpoint/engine-copilot\";\nimport { buildEngineJson as buildClaudeEngineJson } from \"@holdpoint/engine-claude\";\nimport { buildEngine as buildCursorEngine } from \"@holdpoint/engine-cursor\";\nimport { detectAgent } from \"../detect.js\";\nimport type { AgentType } from \"@holdpoint/types\";\n\nexport async function updateCommand(): Promise<void> {\n if (!existsSync(\"checks.yaml\")) {\n console.error(chalk.red(\"No checks.yaml found. Run `holdpoint init` first.\"));\n process.exit(1);\n }\n\n const spinner = ora(\"Updating Holdpoint engine files…\").start();\n const agent = detectAgent();\n const config = parseHoldpointYaml(readFileSync(\"checks.yaml\", \"utf8\"));\n\n // Always write checks.immutable.json — read by holdpoint-check.mjs at runtime\n const generatedDir = \".github/holdpoint/generated\";\n mkdirSync(generatedDir, { recursive: true });\n writeFileSync(`${generatedDir}/checks.immutable.json`, buildConfigJson(config), \"utf8\");\n\n if (agent === \"copilot\" || agent === \"unknown\") {\n const hooksDir = \".github/hooks\";\n mkdirSync(hooksDir, { recursive: true });\n writeFileSync(`${hooksDir}/holdpoint.json`, buildHookJson(config), \"utf8\");\n writeFileSync(`${hooksDir}/holdpoint-check.mjs`, buildCheckScript(config), \"utf8\");\n spinner.text = `Updated ${chalk.green(\".github/hooks/holdpoint.json\")} and ${chalk.green(\".github/hooks/holdpoint-check.mjs\")}`;\n }\n\n if (agent === \"claude\") {\n mkdirSync(\".claude\", { recursive: true });\n const settingsPath = \".claude/settings.json\";\n let existing: Record<string, unknown> = {};\n if (existsSync(settingsPath)) {\n try {\n existing = JSON.parse(readFileSync(settingsPath, \"utf8\")) as Record<string, unknown>;\n } catch {\n /* */\n }\n }\n const hooks = JSON.parse(buildClaudeEngineJson(config)) as Record<string, unknown>;\n writeFileSync(settingsPath, JSON.stringify({ ...existing, hooks: hooks.hooks }, null, 2));\n }\n\n if (agent === \"cursor\") {\n const cursorRules = buildCursorEngine(config);\n const cursorPath = \".cursorrules\";\n if (existsSync(cursorPath)) {\n const content = readFileSync(cursorPath, \"utf8\");\n const start = content.indexOf(\"# ─── Holdpoint Rules\");\n const end = content.indexOf(\"# ─── End Holdpoint Rules ───\");\n if (start !== -1 && end !== -1) {\n // Slice past the end-marker line (find its newline to avoid hardcoded offsets)\n const afterEnd = content.indexOf(\"\\n\", end);\n const updated =\n content.slice(0, start) +\n cursorRules +\n content.slice(afterEnd === -1 ? end : afterEnd + 1);\n writeFileSync(cursorPath, updated);\n } else {\n writeFileSync(cursorPath, content + \"\\n\" + cursorRules);\n }\n }\n }\n\n spinner.succeed(chalk.green(\"Engine files updated from current checks.yaml\"));\n}\n","import { createServer, type IncomingMessage, type ServerResponse } from \"node:http\";\nimport { createReadStream, existsSync } from \"node:fs\";\nimport { join, extname, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { execSync } from \"node:child_process\";\nimport chalk from \"chalk\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst MIME: Record<string, string> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript\",\n \".mjs\": \"text/javascript\",\n \".css\": \"text/css\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".ico\": \"image/x-icon\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".json\": \"application/json\",\n};\n\n/**\n * Serve a static file with the appropriate MIME type.\n */\nfunction serveFile(res: ServerResponse, filePath: string): void {\n const mime = MIME[extname(filePath)] ?? \"application/octet-stream\";\n res.writeHead(200, { \"Content-Type\": mime });\n createReadStream(filePath).pipe(res);\n}\n\n/**\n * Handle an incoming HTTP request: serve `/__holdpoint/initial-yaml` from the\n * user's `checks.yaml`, and all other paths as static files from `uiDir` with\n * a SPA fallback to `index.html`.\n */\nfunction handleRequest(req: IncomingMessage, res: ServerResponse, uiDir: string): void {\n const url = (req.url ?? \"/\").split(\"?\")[0] ?? \"/\";\n\n // Serve the user's checks.yaml for the builder UI to load\n if (url === \"/__holdpoint/initial-yaml\") {\n const checksPath = join(process.cwd(), \"checks.yaml\");\n if (existsSync(checksPath)) {\n res.writeHead(200, { \"Content-Type\": \"text/yaml; charset=utf-8\" });\n createReadStream(checksPath).pipe(res);\n } else {\n res.writeHead(404, { \"Content-Type\": \"text/plain\" });\n res.end(\"checks.yaml not found in current directory\");\n }\n return;\n }\n\n // Static files\n const candidate = join(uiDir, url === \"/\" ? \"index.html\" : url);\n const filePath = existsSync(candidate) ? candidate : join(uiDir, \"index.html\"); // SPA fallback\n serveFile(res, filePath);\n}\n\n/**\n * Start the Holdpoint visual builder on localhost:4321.\n *\n * Serves the pre-built React SPA from `dist/builder-ui/` (bundled into the CLI\n * package at publish time) and exposes a `/__holdpoint/initial-yaml` endpoint\n * that returns the user's `checks.yaml` so the builder can load it on startup.\n */\nexport async function buildCommand(): Promise<void> {\n const port = 4321;\n const uiDir = join(__dirname, \"builder-ui\");\n\n if (!existsSync(uiDir)) {\n console.error(chalk.red(\"✗ Builder UI not found.\\n\"));\n console.log(chalk.dim(\" This is unexpected for a published build of @holdpoint/cli.\"));\n console.log(chalk.dim(\" If you installed from source, rebuild with: pnpm turbo build\\n\"));\n process.exit(1);\n }\n\n const server = createServer((req, res) => handleRequest(req, res, uiDir));\n\n await new Promise<void>((resolve, reject) => {\n server.listen(port, () => {\n console.log(\n `\\n${chalk.green(\"✓\")} Holdpoint builder running at ${chalk.cyan(`http://localhost:${port}`)}`,\n );\n console.log(chalk.dim(\" Edit checks.yaml, then reload the page to see updates\"));\n console.log(chalk.dim(\" Press Ctrl+C to stop\\n\"));\n\n const openCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n try {\n execSync(`${openCmd} http://localhost:${port}`, { stdio: \"ignore\" });\n } catch {\n /* non-fatal */\n }\n });\n\n server.on(\"error\", reject);\n\n process.on(\"SIGINT\", () => {\n console.log(chalk.dim(\"\\n Stopping builder…\"));\n server.close(() => resolve());\n });\n });\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { parseHoldpointYaml, generateYaml } from \"@holdpoint/yaml-core\";\nimport type { HoldpointConfig, CheckDef, ConditionDef } from \"@holdpoint/types\";\nimport { scanProject } from \"../evolve/scanner.js\";\nimport { getRepoFiles, detectStaleChecks } from \"../evolve/dead-checker.js\";\nimport { getTemplates } from \"../evolve/templates.js\";\n\n// ── Helpers ───────────────────────────────────────────────────────────────────\n\n/**\n * Strip leading comment lines from a checks.yaml so we can re-prepend them\n * after re-serialising — preserves the documentation header.\n */\nfunction extractHeader(yaml: string): string {\n const lines = yaml.split(\"\\n\");\n const commentLines: string[] = [];\n for (const line of lines) {\n if (line.startsWith(\"#\") || (commentLines.length > 0 && line.trim() === \"\")) {\n commentLines.push(line);\n } else {\n break;\n }\n }\n // Trim trailing blank lines\n while (commentLines.length > 0 && commentLines[commentLines.length - 1]?.trim() === \"\") {\n commentLines.pop();\n }\n return commentLines.join(\"\\n\");\n}\n\nfunction withHeader(header: string, newYaml: string): string {\n if (!header) return newYaml;\n return header + \"\\n\\n\" + newYaml;\n}\n\n// ── The command ───────────────────────────────────────────────────────────────\n\nexport async function evolveCommand(options: { apply?: boolean }): Promise<void> {\n if (!existsSync(\"checks.yaml\")) {\n console.error(chalk.red(\"No checks.yaml found. Run `holdpoint init` first.\"));\n process.exit(1);\n }\n\n const spinner = ora(\"Scanning project profile…\").start();\n const cwd = process.cwd();\n\n // 1. Scan project\n const profile = scanProject(cwd);\n const repoFiles = getRepoFiles(cwd);\n\n // 2. Parse checks.yaml\n const yamlContent = readFileSync(\"checks.yaml\", \"utf8\");\n let config: HoldpointConfig;\n try {\n config = parseHoldpointYaml(yamlContent);\n } catch (err: unknown) {\n spinner.fail(chalk.red(\"Invalid checks.yaml:\") + \" \" + (err as Error).message);\n process.exit(1);\n }\n\n spinner.stop();\n\n // 3. Compute proposals — templates whose trigger matches AND id not already in config\n const existingIds = new Set(config.checks.map((c) => c.id));\n const existingConditionIds = new Set(config.conditions.map((c) => c.id));\n const allTemplates = getTemplates(profile);\n const proposals = allTemplates.filter((t) => t.trigger(profile) && !existingIds.has(t.id));\n\n // 4. Detect stale checks\n const staleChecks = detectStaleChecks(config, repoFiles);\n\n // ── Print report ─────────────────────────────────────────────────────────\n\n // Profile summary — show detected items\n console.log(chalk.bold(\"\\n📋 Project profile:\"));\n const traits: [string, boolean, string][] = [\n [\"TypeScript\", profile.hasTypeScript, \"tsconfig.json\"],\n [\"ESLint\", profile.hasEslint, \"eslint.config.*\"],\n [\"Biome\", profile.hasBiome, \"biome.json\"],\n [\"Ruff\", profile.hasRuff, \"pyproject.toml / ruff\"],\n [\"Prettier\", profile.hasPrettier, \".prettierrc\"],\n [\"Vitest\", profile.hasVitest, \"devDependencies\"],\n [\"Jest\", profile.hasJest, \"devDependencies\"],\n [\"Python\", profile.hasPython, \"pyproject.toml\"],\n [\"Pytest\", profile.hasPytest, \"pytest.ini\"],\n [\"Go\", profile.hasGo, \"go.mod\"],\n [\"Rust\", profile.hasRust, \"Cargo.toml\"],\n [\"Next.js\", profile.hasNext, \"next.config.*\"],\n [\"React\", profile.hasReact, \"dependencies\"],\n [\"Prisma\", profile.hasPrisma, \"prisma/schema.prisma\"],\n [\"Drizzle\", profile.hasDrizzle, \"drizzle-orm\"],\n [\"Migrations\", profile.hasMigrations, \"migrations/\"],\n [\"Docker\", profile.hasDocker, \"Dockerfile\"],\n [\"Terraform\", profile.hasTerraform, \"*.tf\"],\n [\"Kubernetes\", profile.hasKubernetes, \"k8s/\"],\n [\"OpenAPI\", profile.hasOpenApi, \"openapi.yaml\"],\n [\"GitHub Actions\", profile.hasGithubActions, \".github/workflows/\"],\n ];\n const detected = traits.filter(([, yes]) => yes);\n if (detected.length === 0) {\n console.log(chalk.dim(\" (empty project — only universal checks apply)\"));\n } else {\n for (const [name, , hint] of detected) {\n console.log(` ${chalk.green(\"✓\")} ${name.padEnd(18)} ${chalk.dim(hint)}`);\n }\n }\n\n // Stale checks\n if (staleChecks.length > 0) {\n console.log(chalk.bold(`\\n⚠️ Stale checks (${staleChecks.length}):`));\n for (const { check, reason, suggestedConditionPath } of staleChecks) {\n const fix = suggestedConditionPath\n ? chalk.dim(` → will wrap with conditionId: file_exists: ${suggestedConditionPath}`)\n : chalk.dim(\" → no path inferred; review manually\");\n console.log(` ${chalk.yellow(\"◌\")} ${chalk.bold(check.id)} ${chalk.dim(reason)}${fix}`);\n }\n }\n\n // Proposals\n if (proposals.length === 0 && staleChecks.length === 0) {\n console.log(chalk.green(\"\\n✓ checks.yaml is fully in sync with the project profile.\"));\n return;\n }\n\n if (proposals.length > 0) {\n console.log(chalk.bold(`\\n💡 Proposed additions (${proposals.length}):`));\n for (const t of proposals) {\n const scope = t.when ? chalk.cyan(` when: ${t.when}`) : \"\";\n const type = t.cmd ? chalk.dim(\"cmd\") : chalk.dim(\"prompt\");\n const preview = t.cmd\n ? chalk.dim(` ${t.cmd.slice(0, 80)}${t.cmd.length > 80 ? \"…\" : \"\"}`)\n : chalk.dim(` ${(t.prompt ?? \"\").slice(0, 80)}${(t.prompt?.length ?? 0) > 80 ? \"…\" : \"\"}`);\n console.log(` ${chalk.green(\"+\")} ${chalk.bold(t.id.padEnd(24))} [${type}]${scope}`);\n console.log(` ${preview}`);\n }\n }\n\n if (!options.apply) {\n console.log(\n chalk.red(`\\n✗ checks.yaml is out of sync with the project profile.`) +\n `\\n Run ${chalk.bold(\"npx holdpoint evolve --apply\")} to apply these changes.`,\n );\n process.exit(1);\n }\n\n // ── Apply ───────────────────────────────────────────────────────────────\n\n const applySpinner = ora(\"Applying changes to checks.yaml…\").start();\n\n // Build updated conditions list\n const newConditions = [...config.conditions];\n\n // Collect conditions needed by proposals\n for (const t of proposals) {\n if (t.condition && !existingConditionIds.has(t.condition.id)) {\n newConditions.push(t.condition as ConditionDef);\n existingConditionIds.add(t.condition.id);\n }\n }\n\n // Wrap stale checks with file_exists conditions\n const updatedChecks: CheckDef[] = config.checks.map((check) => {\n const stale = staleChecks.find((s) => s.check.id === check.id);\n if (!stale || !stale.suggestedConditionPath) return check;\n\n const condId = `has-${check.id}`;\n if (!existingConditionIds.has(condId)) {\n newConditions.push({\n id: condId,\n operator: \"file_exists\",\n path: stale.suggestedConditionPath,\n });\n existingConditionIds.add(condId);\n }\n return { ...check, conditionId: condId };\n });\n\n // Append proposed checks\n const newChecks: CheckDef[] = proposals.map((t) => ({\n id: t.id,\n label: t.label,\n ...(t.when ? { when: t.when } : {}),\n ...(t.cmd ? { cmd: t.cmd } : {}),\n ...(t.prompt ? { prompt: t.prompt } : {}),\n ...(t.conditionId ? { conditionId: t.conditionId } : {}),\n }));\n\n const updatedConfig: HoldpointConfig = {\n ...config,\n conditions: newConditions,\n checks: [...updatedChecks, ...newChecks],\n };\n\n const header = extractHeader(yamlContent);\n const newYaml = withHeader(header, generateYaml(updatedConfig));\n writeFileSync(\"checks.yaml\", newYaml, \"utf8\");\n\n // Regenerate engine files\n applySpinner.text = \"Running holdpoint update…\";\n try {\n execSync(\"npx holdpoint update\", { stdio: \"pipe\" });\n } catch {\n // holdpoint update failure is non-fatal — checks.yaml is already written\n applySpinner.warn(\n chalk.yellow(\"checks.yaml updated, but `holdpoint update` failed — run it manually.\"),\n );\n printAppliedSummary(proposals.length, staleChecks.length);\n return;\n }\n\n applySpinner.succeed(chalk.green(\"checks.yaml updated and engine files regenerated.\"));\n printAppliedSummary(proposals.length, staleChecks.length);\n}\n\nfunction printAppliedSummary(added: number, wrapped: number): void {\n const parts: string[] = [];\n if (added > 0) parts.push(chalk.green(`${added} check${added === 1 ? \"\" : \"s\"} added`));\n if (wrapped > 0)\n parts.push(chalk.yellow(`${wrapped} stale check${wrapped === 1 ? \"\" : \"s\"} wrapped`));\n if (parts.length > 0) console.log(\" \" + parts.join(\" · \"));\n console.log(\n chalk.dim(\"\\n Review checks.yaml, then commit: \") +\n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,QACG,QAAQ,SAAS,EACjB,YAAY,8CAA8C,EAC1D,OAAO,YAAY;AAEtB,QACG,QAAQ,QAAQ,EAChB,YAAY,4EAA4E,EACxF,OAAO,WAAW,mEAAmE,EACrF,OAAO,aAAa;AAEvB,QAAQ,MAAM;","names":["existsSync","existsSync","existsSync","readFileSync","chalk","ora","parseHoldpointYaml","execSync","existsSync","readFileSync","join","existsSync","join","execSync","readdirSync","existsSync","join","execSync","existsSync","chalk","readFileSync","parseHoldpointYaml","ora","existsSync","readFileSync","chalk","parseHoldpointYaml","existsSync","readFileSync","writeFileSync","mkdirSync","chalk","ora","parseHoldpointYaml","buildHookJson","buildCheckScript","buildConfigJson","buildClaudeEngineJson","buildCursorEngine","existsSync","chalk","ora","parseHoldpointYaml","readFileSync","mkdirSync","writeFileSync","buildConfigJson","buildHookJson","buildCheckScript","buildClaudeEngineJson","buildCursorEngine","existsSync","join","dirname","fileURLToPath","execSync","chalk","__dirname","existsSync","readFileSync","writeFileSync","execSync","chalk","ora","parseHoldpointYaml","existsSync","chalk","ora","readFileSync","parseHoldpointYaml","writeFileSync","execSync"]}
@@ -0,0 +1,309 @@
1
+ # Holdpoint — Eval Checkpoints
2
+
3
+ This project uses [Holdpoint](https://github.com/holdpoint-dev/holdpoint) to enforce
4
+ eval checkpoints. Before marking any task done, all checks must pass.
5
+
6
+ ---
7
+
8
+ ## The Rule
9
+
10
+ Before marking **any** task complete:
11
+
12
+ 1. Run `npx holdpoint check` — all tasks must exit 0.
13
+ 2. `holdpoint check` also prints every **prompt** check whose `when` matches the
14
+ files you changed. Read and act on each listed instruction before finishing.
15
+
16
+ ---
17
+
18
+ ## The Evolve Loop
19
+
20
+ `checks.yaml` is not static — it grows alongside the project automatically.
21
+
22
+ **`holdpoint-evolve` is a deterministic check** in `checks.yaml` that fires whenever you change a structural file (`package.json`, `pyproject.toml`, `go.mod`, `Dockerfile`, `tsconfig.json`, `vitest.config.*`, etc.). When it fires, `npx holdpoint evolve` runs and **exits 1 if `checks.yaml` is out of sync** — blocking task completion until you apply the proposals.
23
+
24
+ When blocked by `holdpoint-evolve`, run:
25
+
26
+ ```
27
+ npx holdpoint evolve --apply # scan, apply proposals, regenerate engine files
28
+ ```
29
+
30
+ Then commit:
31
+
32
+ ```
33
+ git add checks.yaml .github/holdpoint/generated/
34
+ git commit -m "chore: evolve holdpoint checks"
35
+ ```
36
+
37
+ `holdpoint evolve --apply` is idempotent — safe to re-run at any time. It only adds checks for tools/patterns detected in the project and wraps stale checks (whose `when:` pattern no longer matches any file) with `conditionId: file_exists` so they auto-skip instead of failing.
38
+
39
+ **What triggers evolution:**
40
+
41
+ - New dependency in `package.json` / `pyproject.toml` / `go.mod` / `Cargo.toml`
42
+ - New `Dockerfile`, `docker-compose.yml`, `*.tf`, `openapi.yaml`
43
+ - New test runner config (`vitest.config.*`, `jest.config.*`, `playwright.config.*`)
44
+ - New CI workflow in `.github/workflows/`
45
+ - New TypeScript setup (`tsconfig.json`)
46
+
47
+ **What does NOT trigger it:** `.ts` / `.py` / `.go` source files, docs, styles, tests — minor work proceeds without interruption.
48
+
49
+ ---
50
+
51
+ ## checks.yaml — Full Reference
52
+
53
+ `checks.yaml` at the project root is the single source of truth. Edit it to add,
54
+ remove, or change checkpoints.
55
+
56
+ After every edit, regenerate the engine files and commit everything together:
57
+
58
+ ```
59
+ npx holdpoint update
60
+ git add checks.yaml .github/holdpoint/generated/ .github/hooks/
61
+ git commit -m "chore: update holdpoint checks"
62
+ ```
63
+
64
+ ### Top-level structure
65
+
66
+ ```yaml
67
+ version: 1
68
+
69
+ context:
70
+ guides: # project notes shown when `holdpoint check` runs
71
+ setup: >
72
+ Use pnpm, not npm. Node 20+ required.
73
+
74
+ conditions: # gate checks on file/env state
75
+ - id: dist-built
76
+ operator: file_exists
77
+ path: dist/index.js
78
+
79
+ checks: # list of all checks — each has on/when + cmd (task) or prompt
80
+ - ...
81
+ ```
82
+
83
+ ---
84
+
85
+ ### Deterministic check
86
+
87
+ ```yaml
88
+ - id: lint # unique slug, kebab-case
89
+ label: "ESLint — all packages" # human-readable label shown in output
90
+ # on: before_done # lifecycle hook (default; only value today)
91
+ # when: frontend # file filter — omit to run on every task
92
+ cmd: "pnpm turbo lint" # shell command; must exit 0 to pass
93
+ conditionId: dist-built # optional: skip if condition is not met
94
+ ```
95
+
96
+ ### Prompt check
97
+
98
+ ```yaml
99
+ - id: migration-review
100
+ label: "Review DB migration"
101
+ when: "^prisma/migrations/" # only fires when migration files change
102
+ prompt: >
103
+ Open the new migration file. Confirm it is backward-compatible
104
+ and does not drop or truncate data without a fallback.
105
+ ```
106
+
107
+ ---
108
+
109
+ ### `on` — lifecycle hooks
110
+
111
+ `on` specifies _when in the agent lifecycle_ a check fires. Omit it to use the default.
112
+
113
+ | Value | Fires |
114
+ | ------------- | ---------------------------------- |
115
+ | `before_done` | Before the agent marks a task done |
116
+
117
+ ---
118
+
119
+ ### `when` — file filters
120
+
121
+ `when` is an optional file filter. If omitted the check runs on every task.
122
+
123
+ | Value | Fires when changed files match |
124
+ | ----------- | -------------------------------------------------------------------------------------------------- |
125
+ | _(absent)_ | Every task — no file filter applied |
126
+ | `frontend` | `**/*.tsx`, `**/*.jsx`, `**/*.css`, `**/*.scss`, `**/tailwind.config.*`, `apps/**` |
127
+ | `backend` | `**/api/**`, `**/server/**`, `**/routes/**`, `**/controllers/**`, `packages/*/src/**` |
128
+ | `socket` | `**/socket/**`, `**/ws/**`, `**/websocket/**` |
129
+ | `visual` | `**/*.stories.{ts,tsx}`, `**/__screenshots__/**`, `**/*.snap` |
130
+ | `python` | `**/*.py`, `**/*.pyi`, `**/requirements*.txt`, `**/pyproject.toml`, `**/setup.py`, `**/pytest.ini` |
131
+ | `go` | `**/*.go`, `**/go.mod`, `**/go.sum` |
132
+ | `rust` | `**/*.rs`, `**/Cargo.toml`, `**/Cargo.lock` |
133
+ | `java` | `**/*.java`, `**/*.kt`, `**/*.gradle`, `**/*.gradle.kts`, `**/pom.xml` |
134
+ | `ruby` | `**/*.rb`, `**/Gemfile`, `**/Gemfile.lock`, `**/Rakefile` |
135
+ | `database` | `**/*.sql`, `**/migrations/**`, `**/db/**`, `**/database/**`, `**/prisma/**`, `**/*.prisma` |
136
+ | `prisma` | `**/prisma/**`, `**/*.prisma` — focused subset of `database` for Prisma-specific checks |
137
+ | `testing` | `**/*.test.*`, `**/*.spec.*`, `**/__tests__/**`, `**/test/**`, `**/tests/**`, `**/spec/**` |
138
+ | `infra` | `**/Dockerfile*`, `**/docker-compose.*`, `**/*.tf`, `**/*.tfvars`, `**/k8s/**`, `**/kubernetes/**` |
139
+ | `ci` | `**/.github/workflows/**`, `**/.circleci/**`, `**/Jenkinsfile`, `**/.gitlab-ci.yml` |
140
+ | `docs` | `**/*.mdx`, `**/*.rst`, `**/docs/**`, `**/documentation/**` |
141
+ | `"^src/.*"` | Any JavaScript regex tested against each changed file path |
142
+
143
+ Regex example — fires only when files under `src/api/` change:
144
+
145
+ ```yaml
146
+ when: "^src/api/" # new RegExp(when).test(filePath)
147
+ ```
148
+
149
+ > **Note:** Named scopes use glob matching; plain strings are treated as JavaScript regexes.
150
+
151
+ ---
152
+
153
+ ### Conditions
154
+
155
+ Conditions let you skip a check when a prerequisite is not yet met (e.g. a build
156
+ artefact doesn't exist yet).
157
+
158
+ | Operator | What it checks |
159
+ | ----------------- | ------------------------------------------------- |
160
+ | `file_exists` | A file or directory exists at `path` |
161
+ | `file_contains` | The file at `path` contains the substring `value` |
162
+ | `env_var_set` | The environment variable named `value` is set |
163
+ | `shell_returns_0` | The shell command in `cmd` exits with code 0 |
164
+
165
+ ```yaml
166
+ conditions:
167
+ - id: packages-built
168
+ operator: file_exists
169
+ path: packages/yaml-core/dist/index.js
170
+
171
+ checks:
172
+ - id: validate-templates
173
+ label: "Templates parse against schema"
174
+ conditionId: packages-built # skipped (◌) when dist is absent
175
+ cmd: "node dist/validate.js templates/"
176
+ ```
177
+
178
+ ---
179
+
180
+ ### Context guides
181
+
182
+ `context.guides` is a freeform key → multiline-string map. Guides are printed
183
+ at the start of `holdpoint check` output as project-level reminders to whoever
184
+ (or whatever) is running the checks.
185
+
186
+ ```yaml
187
+ context:
188
+ guides:
189
+ setup: >
190
+ This project requires Node 20 and pnpm 9+.
191
+ Run `pnpm install` from the repo root before any other command.
192
+ architecture: >
193
+ API routes live in src/api/. Models live in src/models/.
194
+ Client code must never import from server modules.
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Adding a New Check
200
+
201
+ 1. Open `checks.yaml`.
202
+ 2. Add your entry under `checks:`.
203
+ 3. Run `npx holdpoint update`.
204
+ 4. Commit `checks.yaml` and the generated files.
205
+
206
+ **Add a task check (runs a shell command automatically):**
207
+
208
+ ```yaml
209
+ checks:
210
+ - id: vitest
211
+ label: "Vitest — unit tests"
212
+ cmd: "pnpm vitest run"
213
+ ```
214
+
215
+ **Add a scoped task (fires only on matching file changes):**
216
+
217
+ ```yaml
218
+ checks:
219
+ - id: openapi-sync
220
+ label: "OpenAPI types are up to date"
221
+ when: "^src/api/"
222
+ cmd: "pnpm generate:types && git diff --exit-code src/generated/"
223
+ ```
224
+
225
+ **Add an agent prompt checkpoint:**
226
+
227
+ ```yaml
228
+ checks:
229
+ - id: jsdoc
230
+ label: "JSDoc on changed public functions"
231
+ prompt: >
232
+ For every public function or export you modified, ensure there is an
233
+ accurate JSDoc comment: description, @param, and @returns.
234
+ ```
235
+
236
+ **Enforce changelog and git commit on every task (recommended):**
237
+
238
+ ```yaml
239
+ checks:
240
+ - id: changelog-update
241
+ label: "Add a CHANGELOG.md entry for this session"
242
+ prompt: >
243
+ Before committing, add an entry to CHANGELOG.md describing what was done.
244
+ Use Keep a Changelog format — add under ## [Unreleased] (create the file
245
+ and that section if absent). Group entries as Added, Changed, Fixed, or Removed.
246
+ Be concise but specific. The entry text will serve as the commit message.
247
+
248
+ - id: readme-sync
249
+ label: "Update README.md if user-facing changes were made"
250
+ prompt: >
251
+ If you added, changed, or removed user-facing functionality — CLI commands,
252
+ configuration options, public APIs, or significant new features — update
253
+ README.md to reflect those changes.
254
+
255
+ - id: git-commit
256
+ label: "Commit all changes before finishing"
257
+ cmd: 'git rev-parse --is-inside-work-tree 2>/dev/null || exit 0; [ -z "$(git status --porcelain)" ] && exit 0; git status --short; exit 1'
258
+ ```
259
+
260
+ When the `git-commit` check fails (uncommitted changes remain), the agent will also see
261
+ the `changelog-update` and `readme-sync` prompt reminders inline — ensuring it updates
262
+ the changelog, syncs docs, _then_ commits before it can mark the task done.
263
+
264
+ ---
265
+
266
+ ## `session_context_files`
267
+
268
+ `session_context_files` is an optional list of project files that Holdpoint injects
269
+ as context at the start of every Copilot session. Use it for files the agent should
270
+ always read before starting work.
271
+
272
+ ```yaml
273
+ session_context_files:
274
+ - MASTER_PROMPT.md
275
+ - AGENT_CONTEXT.md
276
+ ```
277
+
278
+ Files are resolved relative to the repo root and must stay inside it (traversal
279
+ paths like `../../etc/passwd` are rejected). If a file doesn't exist it is silently
280
+ skipped.
281
+
282
+ ---
283
+
284
+ ## Commands
285
+
286
+ | Command | What it does |
287
+ | ---------------------------------- | ------------------------------------------------------- |
288
+ | `npx holdpoint check` | Run checks against all files changed vs HEAD |
289
+ | `npx holdpoint check --staged` | Run checks against staged files only |
290
+ | `npx holdpoint evolve` | Scan project and show proposed additions to checks.yaml |
291
+ | `npx holdpoint evolve --apply` | Apply proposals and regenerate engine files |
292
+ | `npx holdpoint update` | Regenerate engine files from the current `checks.yaml` |
293
+ | `npx holdpoint validate` | Validate `checks.yaml` schema (no commands run) |
294
+ | `npx @holdpoint/cli@alpha builder` | Open the visual builder UI at localhost:4321 |
295
+
296
+ ---
297
+
298
+ ## Generated files (do not edit directly)
299
+
300
+ | File | Agent |
301
+ | --------------------------------------------------- | ------- |
302
+ | `.github/holdpoint/generated/checks.immutable.json` | all |
303
+ | `.github/hooks/holdpoint.json` | Copilot |
304
+ | `.github/hooks/holdpoint-check.mjs` | Copilot |
305
+ | `.claude/settings.json` | Claude |
306
+ | `.cursorrules` (Holdpoint section) | Cursor |
307
+
308
+ All generated files are overwritten by `npx holdpoint update`. Edit `checks.yaml`,
309
+ then run `update` — never edit the generated files directly.
@@ -0,0 +1,52 @@
1
+ version: 1
2
+
3
+ context:
4
+ guides: {}
5
+
6
+ conditions: []
7
+
8
+ checks:
9
+ - id: lint
10
+ label: "Lint codebase"
11
+ cmd: "pnpm lint --max-warnings 0"
12
+
13
+ - id: typecheck
14
+ label: "TypeScript type check"
15
+ cmd: "pnpm typecheck"
16
+
17
+ - id: jsdoc
18
+ label: "JSDoc on changed public functions"
19
+ prompt: >
20
+ Ensure all changed public functions, classes, and module exports have
21
+ accurate JSDoc comments (description + @param + @returns where applicable).
22
+
23
+ - id: changelog-update
24
+ label: "Add a CHANGELOG.md entry for this session"
25
+ prompt: >
26
+ Before committing, add an entry to CHANGELOG.md describing what was done.
27
+ Use Keep a Changelog format — add under ## [Unreleased] (create the file
28
+ and that section if absent). Group entries as Added, Changed, Fixed, or Removed.
29
+ Be concise but specific. The entry text will serve as the commit message.
30
+
31
+ - id: readme-sync
32
+ label: "Update README.md if user-facing changes were made"
33
+ prompt: >
34
+ If you added, changed, or removed user-facing functionality — CLI commands,
35
+ configuration options, public APIs, or significant new features — update
36
+ README.md to reflect those changes.
37
+
38
+ - id: no-todos
39
+ label: "No TODO/FIXME left in changed code"
40
+ prompt: >
41
+ Scan the files you changed for any TODO, FIXME, HACK, or XXX comments.
42
+ Either resolve them before finishing or convert them to tracked issues.
43
+ Don't leave incomplete work silently behind.
44
+
45
+ - id: holdpoint-evolve
46
+ label: "Evolve checks when project structure changes"
47
+ when: structural
48
+ cmd: "npx holdpoint evolve"
49
+
50
+ - id: git-commit
51
+ label: "Commit all changes before finishing"
52
+ cmd: 'git rev-parse --is-inside-work-tree 2>/dev/null || exit 0; [ -z "$(git status --porcelain)" ] && exit 0; git status --short; exit 1'