{"version":3,"sources":["../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","../src/cli.ts","../src/commands/run-command.ts","../src/core/scanner.ts","../src/adapters/claude-code.ts","../src/core/parser.ts","../src/detectors/token-estimator.ts","../src/adapters/codex.ts","../src/adapters/cursor.ts","../src/adapters/dispatch.ts","../src/analyzers/budget.ts","../src/detectors/config-overlap.ts","../src/utils/text.ts","../src/detectors/duplicate.ts","../src/analyzers/dead-rules.ts","../src/detectors/contradiction.ts","../src/detectors/stale-refs.ts","../src/detectors/scope-classifier.ts","../src/analyzers/structure.ts","../src/core/scorer.ts","../src/core/reporter.ts","../src/commands/budget-command.ts","../src/i18n/en.json","../src/i18n/zh-TW.json","../src/i18n/index.ts","../src/fixers/line-remover.ts","../src/fixers/remove-dead.ts","../src/fixers/remove-stale.ts","../src/fixers/deduplicate.ts","../src/fixers/structure-suggestions.ts","../src/utils/skill-version.ts","../src/verifiers/candidates.ts","../src/verifiers/policy.ts","../src/verifiers/verdicts.ts","../src/commands/install-command.ts","../src/commands/deadrules-command.ts","../src/commands/structure-command.ts","../src/commands/ci-command.ts","../src/reporters/sarif.ts","../src/commands/init-ci-command.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n  typeof document === \"undefined\" \n    ? new URL(`file:${__filename}`).href \n    : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n      ? document.currentScript.src \n      : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport { runAll } from \"./commands/run-command.js\";\nimport { runBudget } from \"./commands/budget-command.js\";\nimport { runDeadRules } from \"./commands/deadrules-command.js\";\nimport { runStructure } from \"./commands/structure-command.js\";\nimport { runCi } from \"./commands/ci-command.js\";\nimport { runInitCi } from \"./commands/init-ci-command.js\";\nimport { runInstall } from \"./commands/install-command.js\";\nimport { initLocale } from \"./i18n/index.js\";\nimport { CURRENT_VERSION } from \"./utils/skill-version.js\";\nimport type { FailOn } from \"./commands/ci-command.js\";\n\nconst program = new Command();\n\nprogram\n  .enablePositionalOptions()\n  .name(\"instrlint\")\n  .description(\n    \"Lint and optimize your CLAUDE.md / AGENTS.md — find dead rules, token waste, and structural issues\",\n  )\n  .version(CURRENT_VERSION)\n  .option(\n    \"--format <type>\",\n    \"output format (terminal|json|markdown)\",\n    \"terminal\",\n  )\n  .option(\"--lang <locale>\", \"output language (en|zh-TW)\", \"en\")\n  .option(\"--tool <name>\", \"force tool detection (claude-code|codex|cursor)\")\n  .option(\"--fix\", \"auto-fix safe issues (dead rules, stale refs, dupes)\")\n  .option(\"--force\", \"skip git clean check when using --fix\")\n  .option(\n    \"--emit-candidates <path>\",\n    \"write low-confidence findings as candidates JSON for host LLM verification\",\n  )\n  .option(\n    \"--apply-verdicts <path>\",\n    \"apply host LLM verdicts from JSON file to the report\",\n  )\n  .option(\n    \"--skip-report\",\n    \"suppress terminal output (use with --emit-candidates)\",\n  )\n  .action(async function (this: Command) {\n    const opts = this.opts<{\n      format: string;\n      lang?: string;\n      tool?: string;\n      fix?: boolean;\n      force?: boolean;\n      emitCandidates?: string;\n      applyVerdicts?: string;\n      skipReport?: boolean;\n    }>();\n    const result = await runAll(opts);\n    if (result.exitCode !== 0) process.exit(result.exitCode);\n  });\n\nprogram\n  .command(\"budget\")\n  .description(\"Token budget analysis only\")\n  .option(\n    \"--format <type>\",\n    \"output format (terminal|json|markdown)\",\n    \"terminal\",\n  )\n  .option(\"--lang <locale>\", \"output language (en|zh-TW)\")\n  .option(\"--tool <name>\", \"force tool detection (claude-code|codex|cursor)\")\n  .action(async function (this: Command) {\n    const opts = this.opts<{ format: string; lang?: string; tool?: string }>();\n    const lang = opts.lang ?? this.parent?.opts<{ lang?: string }>()?.lang;\n    const result = await runBudget({\n      ...opts,\n      ...(lang !== undefined && { lang }),\n    });\n    if (result.exitCode !== 0) process.exit(result.exitCode);\n  });\n\nprogram\n  .command(\"deadrules\")\n  .description(\"Dead rule detection only\")\n  .option(\"--format <type>\", \"output format (terminal|json)\", \"terminal\")\n  .option(\"--lang <locale>\", \"output language (en|zh-TW)\")\n  .option(\"--tool <name>\", \"force tool detection (claude-code|codex|cursor)\")\n  .action(async function (this: Command) {\n    const opts = this.opts<{ format: string; lang?: string; tool?: string }>();\n    const lang = opts.lang ?? this.parent?.opts<{ lang?: string }>()?.lang;\n    const result = await runDeadRules({\n      ...opts,\n      ...(lang !== undefined && { lang }),\n    });\n    if (result.exitCode !== 0) process.exit(result.exitCode);\n  });\n\nprogram\n  .command(\"structure\")\n  .description(\"Structural analysis only\")\n  .option(\"--format <type>\", \"output format (terminal|json)\", \"terminal\")\n  .option(\"--lang <locale>\", \"output language (en|zh-TW)\")\n  .option(\"--tool <name>\", \"force tool detection (claude-code|codex|cursor)\")\n  .action(async function (this: Command) {\n    const opts = this.opts<{ format: string; lang?: string; tool?: string }>();\n    const lang = opts.lang ?? this.parent?.opts<{ lang?: string }>()?.lang;\n    const result = await runStructure({\n      ...opts,\n      ...(lang !== undefined && { lang }),\n    });\n    if (result.exitCode !== 0) process.exit(result.exitCode);\n  });\n\nprogram\n  .command(\"ci\")\n  .description(\n    \"CI mode: run full analysis and exit 1 if findings exceed threshold\",\n  )\n  .option(\n    \"--fail-on <level>\",\n    \"failure threshold (critical|warning|info)\",\n    \"critical\",\n  )\n  .option(\"--format <type>\", \"output format (json|markdown|sarif)\", \"json\")\n  .option(\"--output <file>\", \"write output to file instead of stdout\")\n  .option(\"--tool <name>\", \"force tool detection (claude-code|codex|cursor)\")\n  .action(async function (this: Command) {\n    const opts = this.opts<{\n      failOn: string;\n      format: string;\n      output?: string;\n      tool?: string;\n    }>();\n    const lang = this.parent?.opts<{ lang?: string }>()?.lang;\n    initLocale(lang);\n    const result = await runCi({\n      failOn: opts.failOn as FailOn,\n      format: opts.format,\n      ...(opts.output !== undefined && { output: opts.output }),\n      ...(opts.tool !== undefined && { tool: opts.tool }),\n      ...(lang !== undefined && { lang }),\n    });\n    if (result.exitCode !== 0) process.exit(result.exitCode);\n  });\n\nprogram\n  .command(\"init-ci\")\n  .description(\"Generate CI configuration for instrlint\")\n  .option(\"--github\", \"Generate GitHub Actions workflow\")\n  .option(\"--gitlab\", \"Generate GitLab CI snippet (prints to stdout)\")\n  .option(\"--force\", \"overwrite existing files\")\n  .action(function (this: Command) {\n    const opts = this.opts<{\n      github?: boolean;\n      gitlab?: boolean;\n      force?: boolean;\n    }>();\n    const result = runInitCi(opts);\n    if (result.exitCode !== 0) process.exit(result.exitCode);\n  });\n\nprogram\n  .command(\"install\")\n  .description(\"Install instrlint as a skill\")\n  .option(\"--claude-code\", \"Install as Claude Code skill\")\n  .option(\"--codex\", \"Install as Codex skill\")\n  .option(\"--project\", \"Install into current project (instead of global)\")\n  .option(\"--force\", \"overwrite existing skill file\")\n  .action(function (this: Command) {\n    const opts = this.opts<{\n      claudeCode?: boolean;\n      codex?: boolean;\n      project?: boolean;\n      force?: boolean;\n    }>();\n    const result = runInstall(opts);\n    if (result.exitCode !== 0) process.exit(result.exitCode);\n  });\n\nprogram.parse();\n","import { execSync } from \"child_process\";\nimport { writeFileSync } from \"fs\";\nimport { createInterface } from \"readline\";\nimport { basename, resolve, relative } from \"path\";\nimport chalk from \"chalk\";\nimport { scanProject } from \"../core/scanner.js\";\nimport { loadProject } from \"../adapters/dispatch.js\";\nimport { ensureInitialized } from \"../detectors/token-estimator.js\";\nimport { analyzeBudget } from \"../analyzers/budget.js\";\nimport { analyzeDeadRules } from \"../analyzers/dead-rules.js\";\nimport { analyzeStructure } from \"../analyzers/structure.js\";\nimport { calculateScore, buildActionPlan } from \"../core/scorer.js\";\nimport {\n  printCombinedTerminal,\n  reportJson,\n  reportMarkdown,\n} from \"../core/reporter.js\";\nimport { removeDeadRules } from \"../fixers/remove-dead.js\";\nimport { removeStaleRefs } from \"../fixers/remove-stale.js\";\nimport { deduplicateRules } from \"../fixers/deduplicate.js\";\nimport {\n  buildStructureSuggestions,\n  printStructureSuggestions,\n  markdownStructureSuggestions,\n} from \"../fixers/structure-suggestions.js\";\nimport { t, plural, initLocale, getLocale } from \"../i18n/index.js\";\nimport { checkSkillUpdate } from \"../utils/skill-version.js\";\nimport {\n  buildCandidates,\n  applyVerdicts,\n  loadVerdictsFile,\n} from \"../verifiers/index.js\";\nimport type { ApplyVerdictsResult } from \"../verifiers/index.js\";\nimport { runInstall } from \"./install-command.js\";\nimport type { HealthReport } from \"../types.js\";\n\n// ─── Git helpers ───────────────────────────────────────────────────────────────\n\nfunction isGitClean(cwd: string): boolean {\n  try {\n    const out = execSync(\"git status --porcelain\", { cwd, encoding: \"utf8\" });\n    return out.trim().length === 0;\n  } catch {\n    // Not a git repo or git unavailable — proceed without blocking\n    return true;\n  }\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\ninterface RunCommandOpts {\n  format: string;\n  tool?: string;\n  lang?: string;\n  fix?: boolean;\n  force?: boolean;\n  projectRoot?: string;\n  emitCandidates?: string;\n  applyVerdicts?: string;\n  skipReport?: boolean;\n}\n\ninterface RunCommandResult {\n  exitCode: number;\n  errorMessage?: string;\n}\n\n// ─── Core logic ───────────────────────────────────────────────────────────────\n\nexport async function runAll(\n  opts: RunCommandOpts,\n  output: { log: typeof console.log; error: typeof console.error } = console,\n): Promise<RunCommandResult> {\n  initLocale(opts.lang);\n  await ensureInitialized();\n\n  const projectRoot = opts.projectRoot ?? process.cwd();\n  const scan = scanProject(projectRoot, opts.tool);\n\n  if (scan.tool === \"unknown\") {\n    output.error(t(\"error.unknownTool\"));\n    return { exitCode: 1, errorMessage: \"unknown tool\" };\n  }\n\n  if (scan.rootFilePath === null) {\n    output.error(t(\"error.missingRootFile\", { tool: scan.tool }));\n    return { exitCode: 1, errorMessage: \"missing root file\" };\n  }\n\n  // --fix and --emit-candidates are mutually exclusive\n  if (opts.fix && opts.emitCandidates) {\n    output.error(\"--fix and --emit-candidates cannot be used together\");\n    return {\n      exitCode: 1,\n      errorMessage: \"--fix and --emit-candidates conflict\",\n    };\n  }\n\n  // --fix: require clean working tree unless --force is set\n  if (opts.fix && !opts.force && !isGitClean(projectRoot)) {\n    output.error(t(\"error.dirtyWorkingTree\"));\n    return { exitCode: 1, errorMessage: \"dirty working tree\" };\n  }\n\n  // --emit-candidates: validate output path stays within project root\n  if (opts.emitCandidates) {\n    const resolved = resolve(opts.emitCandidates);\n    const rel = relative(projectRoot, resolved);\n    if (rel.startsWith(\"..\")) {\n      output.error(\n        `--emit-candidates path must be within the project directory: ${opts.emitCandidates}`,\n      );\n      return {\n        exitCode: 1,\n        errorMessage: \"emit-candidates path outside project\",\n      };\n    }\n  }\n\n  const instructions = loadProject(projectRoot, scan.tool);\n\n  const { findings: budgetFindings, summary } = analyzeBudget(instructions);\n  const { findings: deadRuleFindings } = analyzeDeadRules(\n    instructions,\n    projectRoot,\n  );\n  const { findings: structureFindings } = analyzeStructure(\n    instructions,\n    projectRoot,\n  );\n\n  let allFindings = [\n    ...budgetFindings,\n    ...deadRuleFindings,\n    ...structureFindings,\n  ];\n\n  // ── Emit candidates for host LLM verification ────────────────────────────────\n  if (opts.emitCandidates) {\n    const candidatesFile = buildCandidates(\n      allFindings,\n      instructions,\n      projectRoot,\n      getLocale(),\n    );\n    writeFileSync(opts.emitCandidates, JSON.stringify(candidatesFile, null, 2));\n    if (opts.skipReport) return { exitCode: 0 };\n  }\n\n  // ── Apply host LLM verdicts ──────────────────────────────────────────────────\n  let rejectedByVerification: number | undefined;\n  if (opts.applyVerdicts) {\n    try {\n      const verdictsFile = loadVerdictsFile(opts.applyVerdicts);\n      const result: ApplyVerdictsResult = applyVerdicts(\n        allFindings,\n        verdictsFile,\n      );\n      allFindings = result.findings;\n      rejectedByVerification =\n        result.rejectedCount > 0 ? result.rejectedCount : undefined;\n    } catch (err) {\n      output.error(err instanceof Error ? err.message : String(err));\n      return { exitCode: 1, errorMessage: \"failed to apply verdicts\" };\n    }\n  }\n\n  const { score, grade } = calculateScore(allFindings, summary);\n  const actionPlan = buildActionPlan(allFindings);\n\n  const report: HealthReport = {\n    project: basename(projectRoot),\n    tool: instructions.tool,\n    score,\n    grade,\n    locale: getLocale(),\n    tokenMethod: summary.tokenMethod,\n    findings: allFindings,\n    budget: summary,\n    actionPlan,\n    ...(rejectedByVerification !== undefined ? { rejectedByVerification } : {}),\n  };\n\n  // ── Apply fixes ──────────────────────────────────────────────────────────────\n  if (opts.fix) {\n    // Build suggestions BEFORE modifying files, so line numbers are still accurate\n    const suggestions = buildStructureSuggestions(allFindings);\n\n    const deadFixed = removeDeadRules(allFindings);\n    const staleFixed = removeStaleRefs(allFindings);\n    const dupeFixed = deduplicateRules(allFindings);\n    const total = deadFixed + staleFixed + dupeFixed;\n\n    if (total === 0) {\n      output.log(chalk.green(`  ${t(\"status.noAutoFixable\")}`));\n    } else {\n      output.log(\"\");\n      output.log(chalk.bold.white(`  ${t(\"label.fixSummary\")}`));\n      output.log(chalk.gray(\"  ─\".repeat(30)));\n      if (deadFixed > 0)\n        output.log(\n          `  ${chalk.yellow(\"⚠\")}  ${t(\"fix.removedDeadRules\", { count: String(deadFixed), s: plural(deadFixed) })}`,\n        );\n      if (staleFixed > 0)\n        output.log(\n          `  ${chalk.yellow(\"⚠\")}  ${t(\"fix.removedStaleRefs\", { count: String(staleFixed), s: plural(staleFixed) })}`,\n        );\n      if (dupeFixed > 0)\n        output.log(\n          `  ${chalk.yellow(\"⚠\")}  ${t(\"fix.removedDuplicates\", { count: String(dupeFixed), s: plural(dupeFixed) })}`,\n        );\n      output.log(chalk.gray(\"  ─\".repeat(30)));\n      output.log(\n        chalk.green(\n          `  ${t(\"status.fixedIssues\", { count: String(total), s: plural(total) })}`,\n        ),\n      );\n      output.log(\"\");\n    }\n\n    // Print actionable suggestions for non-auto-fixable structure findings\n    printStructureSuggestions(suggestions, projectRoot, output);\n\n    return { exitCode: 0 };\n  }\n\n  // ── Skill update notice ──────────────────────────────────────────────────────\n  const skillUpdate = checkSkillUpdate(projectRoot);\n\n  // ── Format output ────────────────────────────────────────────────────────────\n  if (opts.format === \"json\") {\n    output.log(reportJson(report));\n    return { exitCode: 0 };\n  }\n\n  if (opts.format === \"markdown\") {\n    const mdSuggestions = buildStructureSuggestions(allFindings);\n    const mdExtra = markdownStructureSuggestions(mdSuggestions, projectRoot);\n    const updateSection = skillUpdate\n      ? [\n          \"\",\n          `> ⚠️ **${t(\"install.outdatedTitle\")}** (${t(\"install.outdatedVersions\", { installed: skillUpdate.installedVersion, current: skillUpdate.currentVersion })})`,\n          `> \\`${t(\"install.updateCmd\", { flag: skillUpdate.isProject ? \"--claude-code --project\" : \"--claude-code\" })}\\``,\n        ]\n      : [];\n    output.log(reportMarkdown(report, [...mdExtra, ...updateSection]));\n    return { exitCode: 0 };\n  }\n\n  printCombinedTerminal(report, output);\n\n  if (skillUpdate && process.stdout.isTTY) {\n    output.log(\"\");\n    output.log(\n      `  ${chalk.yellow(\"⚠\")}  ${chalk.bold(t(\"install.outdatedTitle\"))} (${t(\"install.outdatedVersions\", { installed: skillUpdate.installedVersion, current: skillUpdate.currentVersion })})`,\n    );\n    const confirmed = await promptYesNo(`  ${t(\"install.updatePrompt\")}`);\n    if (confirmed) {\n      const installResult = runInstall(\n        {\n          claudeCode: true,\n          project: skillUpdate.isProject,\n          force: true,\n          projectRoot,\n        },\n        output,\n      );\n      if (installResult.exitCode !== 0) {\n        output.error?.(\n          `Update failed: ${installResult.errorMessage ?? \"unknown error\"}`,\n        );\n      }\n    }\n    output.log(\"\");\n  }\n\n  return { exitCode: 0 };\n}\n\nfunction promptYesNo(question: string): Promise<boolean> {\n  return new Promise((resolve) => {\n    const rl = createInterface({\n      input: process.stdin,\n      output: process.stdout,\n    });\n    rl.question(`${question} ${chalk.gray(\"[Y/n]\")} `, (answer) => {\n      rl.close();\n      const trimmed = answer.trim().toLowerCase();\n      resolve(trimmed === \"\" || trimmed === \"y\");\n    });\n  });\n}\n","import { existsSync } from \"fs\";\nimport { join } from \"path\";\nimport type { ToolType } from \"../types.js\";\n\ntype ScanConfidence = \"high\" | \"low\" | \"ambiguous\";\n\ninterface ScanResult {\n  tool: ToolType;\n  /** Absolute path to the root instruction file (e.g. CLAUDE.md or AGENTS.md) */\n  rootFilePath: string | null;\n  /** Absolute path to the config directory (e.g. .claude/, .agents/) */\n  configDir: string | null;\n  confidence: ScanConfidence;\n}\n\ninterface Detection {\n  tool: ToolType;\n  rootFilePath: string | null;\n  configDir: string | null;\n}\n\nfunction detectAll(projectRoot: string): Detection[] {\n  const detections: Detection[] = [];\n\n  // Claude Code: .claude/ directory\n  const claudeDir = join(projectRoot, \".claude\");\n  if (existsSync(claudeDir)) {\n    const rootInDir = join(claudeDir, \"CLAUDE.md\");\n    const rootAtRoot = join(projectRoot, \"CLAUDE.md\");\n    detections.push({\n      tool: \"claude-code\",\n      rootFilePath: existsSync(rootInDir)\n        ? rootInDir\n        : existsSync(rootAtRoot)\n          ? rootAtRoot\n          : null,\n      configDir: claudeDir,\n    });\n  }\n\n  // Codex: .agents/ directory\n  const agentsDir = join(projectRoot, \".agents\");\n  if (existsSync(agentsDir)) {\n    const agentsMd = join(projectRoot, \"AGENTS.md\");\n    detections.push({\n      tool: \"codex\",\n      rootFilePath: existsSync(agentsMd) ? agentsMd : null,\n      configDir: agentsDir,\n    });\n  }\n\n  // Codex: .codex/ directory (alternative)\n  const codexDir = join(projectRoot, \".codex\");\n  if (existsSync(codexDir) && !detections.some((d) => d.tool === \"codex\")) {\n    const agentsMd = join(projectRoot, \"AGENTS.md\");\n    detections.push({\n      tool: \"codex\",\n      rootFilePath: existsSync(agentsMd) ? agentsMd : null,\n      configDir: codexDir,\n    });\n  }\n\n  // Cursor: .cursor/ directory or .cursorrules file\n  const cursorDir = join(projectRoot, \".cursor\");\n  const cursorRules = join(projectRoot, \".cursorrules\");\n  if (existsSync(cursorDir) || existsSync(cursorRules)) {\n    detections.push({\n      tool: \"cursor\",\n      rootFilePath: existsSync(cursorRules) ? cursorRules : null,\n      configDir: existsSync(cursorDir) ? cursorDir : null,\n    });\n  }\n\n  return detections;\n}\n\nfunction detectByRootFile(projectRoot: string): Detection | null {\n  const claudeMd = join(projectRoot, \"CLAUDE.md\");\n  if (existsSync(claudeMd)) {\n    return { tool: \"claude-code\", rootFilePath: claudeMd, configDir: null };\n  }\n\n  const agentsMd = join(projectRoot, \"AGENTS.md\");\n  if (existsSync(agentsMd)) {\n    return { tool: \"codex\", rootFilePath: agentsMd, configDir: null };\n  }\n\n  return null;\n}\n\nexport function scanProject(\n  projectRoot: string,\n  forceTool?: string,\n): ScanResult {\n  if (!existsSync(projectRoot)) {\n    throw new Error(`Project root does not exist: ${projectRoot}`);\n  }\n\n  // --tool flag overrides everything\n  if (forceTool != null) {\n    const valid: ToolType[] = [\"claude-code\", \"codex\", \"cursor\"];\n    if (!valid.includes(forceTool as ToolType)) {\n      throw new Error(\n        `Invalid tool: \"${forceTool}\". Must be one of: ${valid.join(\", \")}`,\n      );\n    }\n    const tool = forceTool as ToolType;\n    // Still try to find the root file for this tool\n    const detections = detectAll(projectRoot);\n    const match = detections.find((d) => d.tool === tool);\n    return {\n      tool,\n      rootFilePath: match?.rootFilePath ?? null,\n      configDir: match?.configDir ?? null,\n      confidence: \"high\",\n    };\n  }\n\n  const detections = detectAll(projectRoot);\n\n  if (detections.length === 0) {\n    // Fall back to checking for bare root files\n    const byFile = detectByRootFile(projectRoot);\n    if (byFile != null) {\n      return { ...byFile, confidence: \"low\" };\n    }\n    return {\n      tool: \"unknown\",\n      rootFilePath: null,\n      configDir: null,\n      confidence: \"low\",\n    };\n  }\n\n  if (detections.length === 1) {\n    const d = detections[0]!;\n    return {\n      tool: d.tool,\n      rootFilePath: d.rootFilePath,\n      configDir: d.configDir,\n      confidence: \"high\",\n    };\n  }\n\n  // Multiple detections — use the first match, mark ambiguous\n  const first = detections[0]!;\n  return {\n    tool: first.tool,\n    rootFilePath: first.rootFilePath,\n    configDir: first.configDir,\n    confidence: \"ambiguous\",\n  };\n}\n","import { existsSync, readdirSync, readFileSync, statSync } from \"fs\";\nimport { join, relative } from \"path\";\nimport { parseInstructionFile, parseYamlFrontmatter } from \"../core/parser.js\";\nimport {\n  countTokens,\n  estimateMcpTokens,\n} from \"../detectors/token-estimator.js\";\nimport type {\n  InstructionFile,\n  McpServerConfig,\n  ParsedInstructions,\n  RuleFile,\n  SkillFile,\n} from \"../types.js\";\n\n// ─── Helpers ───────────────────────────────────────────────────────────────\n\nfunction withTokens(file: InstructionFile): InstructionFile {\n  const raw = (() => {\n    try {\n      return readFileSync(file.path, \"utf8\");\n    } catch {\n      return \"\";\n    }\n  })();\n  const { count, method } = countTokens(raw);\n  return { ...file, tokenCount: count, tokenMethod: method };\n}\n\nfunction safeParseFile(filePath: string): InstructionFile | null {\n  try {\n    const file = parseInstructionFile(filePath);\n    return withTokens(file);\n  } catch {\n    process.stderr.write(\n      `[instrlint] Warning: could not read ${filePath}, skipping\\n`,\n    );\n    return null;\n  }\n}\n\n// ─── Root file discovery ───────────────────────────────────────────────────\n\nfunction findRootFile(projectRoot: string): string | null {\n  const candidates = [\n    join(projectRoot, \"CLAUDE.md\"),\n    join(projectRoot, \".claude\", \"CLAUDE.md\"),\n  ];\n  return candidates.find(existsSync) ?? null;\n}\n\n// ─── Rules ────────────────────────────────────────────────────────────────\n\nfunction loadRules(projectRoot: string): RuleFile[] {\n  const rulesDir = join(projectRoot, \".claude\", \"rules\");\n  if (!existsSync(rulesDir)) return [];\n\n  const rules: RuleFile[] = [];\n  let entries: string[] = [];\n  try {\n    entries = readdirSync(rulesDir).filter((f) => f.endsWith(\".md\"));\n  } catch {\n    return [];\n  }\n\n  for (const filename of entries) {\n    const filePath = join(rulesDir, filename);\n    try {\n      const raw = readFileSync(filePath, \"utf8\");\n      const { paths, globs, body } = parseYamlFrontmatter(raw);\n      const baseFile = parseInstructionFile(filePath);\n      const { count, method } = countTokens(body);\n      rules.push({\n        ...baseFile,\n        tokenCount: count,\n        tokenMethod: method,\n        ...(paths != null ? { paths } : {}),\n        ...(globs != null ? { globs } : {}),\n      });\n    } catch {\n      process.stderr.write(\n        `[instrlint] Warning: could not parse rule ${filePath}, skipping\\n`,\n      );\n    }\n  }\n\n  return rules;\n}\n\n// ─── Skills ───────────────────────────────────────────────────────────────\n\nfunction loadSkills(projectRoot: string): SkillFile[] {\n  const skillsDir = join(projectRoot, \".claude\", \"skills\");\n  if (!existsSync(skillsDir)) return [];\n\n  const skills: SkillFile[] = [];\n  let entries: string[] = [];\n  try {\n    entries = readdirSync(skillsDir);\n  } catch {\n    return [];\n  }\n\n  for (const skillName of entries) {\n    const skillFile = join(skillsDir, skillName, \"SKILL.md\");\n    if (!existsSync(skillFile)) continue;\n\n    const parsed = safeParseFile(skillFile);\n    if (parsed != null) {\n      skills.push({ ...parsed, skillName });\n    }\n  }\n\n  return skills;\n}\n\n// ─── Sub-directory CLAUDE.md files ────────────────────────────────────────\n\nconst SKIP_DIRS = new Set([\n  \"node_modules\",\n  \"dist\",\n  \".git\",\n  \".claude\",\n  \".turbo\",\n  \"coverage\",\n  \"tests\",\n  \"test\",\n  \"__tests__\",\n  \"spec\",\n]);\n\nfunction findSubClaudeFiles(\n  dir: string,\n  projectRoot: string,\n  depth = 0,\n): InstructionFile[] {\n  if (depth > 10) return []; // guard against infinite recursion\n  const results: InstructionFile[] = [];\n\n  let entries: string[] = [];\n  try {\n    entries = readdirSync(dir);\n  } catch {\n    return [];\n  }\n\n  for (const entry of entries) {\n    if (SKIP_DIRS.has(entry)) continue;\n    const full = join(dir, entry);\n\n    try {\n      const stat = statSync(full);\n      if (stat.isDirectory()) {\n        results.push(...findSubClaudeFiles(full, projectRoot, depth + 1));\n      } else if (entry === \"CLAUDE.md\") {\n        // Skip the project root CLAUDE.md itself\n        if (relative(projectRoot, full) === \"CLAUDE.md\") continue;\n        const parsed = safeParseFile(full);\n        if (parsed != null) results.push(parsed);\n      }\n    } catch {\n      // skip inaccessible entries\n    }\n  }\n\n  return results;\n}\n\n// ─── MCP servers ──────────────────────────────────────────────────────────\n\ninterface McpServerEntry {\n  command?: string;\n  args?: string[];\n  tools?: unknown[];\n}\n\nfunction parseMcpServers(projectRoot: string): McpServerConfig[] {\n  const candidates = [\n    join(projectRoot, \".claude\", \"settings.json\"),\n    join(projectRoot, \".claude\", \"settings.local.json\"),\n  ];\n\n  const servers: McpServerConfig[] = [];\n\n  for (const settingsPath of candidates) {\n    if (!existsSync(settingsPath)) continue;\n    try {\n      const raw = readFileSync(settingsPath, \"utf8\");\n      const parsed: unknown = JSON.parse(raw);\n      if (\n        parsed == null ||\n        typeof parsed !== \"object\" ||\n        !(\"mcpServers\" in parsed)\n      ) {\n        continue;\n      }\n      const mcpServers = (\n        parsed as { mcpServers: Record<string, McpServerEntry> }\n      ).mcpServers;\n      for (const [name, entry] of Object.entries(mcpServers)) {\n        const toolCount = Array.isArray(entry.tools)\n          ? entry.tools.length\n          : undefined;\n        const config: McpServerConfig = {\n          name,\n          estimatedTokens: 0,\n          ...(toolCount !== undefined ? { toolCount } : {}),\n        };\n        const { count } = estimateMcpTokens(config);\n        servers.push({ ...config, estimatedTokens: count });\n      }\n    } catch {\n      process.stderr.write(\n        `[instrlint] Warning: could not parse MCP config in ${settingsPath}, skipping\\n`,\n      );\n    }\n  }\n\n  return servers;\n}\n\n// ─── Public API ────────────────────────────────────────────────────────────\n\nexport function loadClaudeCodeProject(projectRoot: string): ParsedInstructions {\n  // Root file\n  const rootFilePath = findRootFile(projectRoot);\n  const rootFile: InstructionFile =\n    rootFilePath != null\n      ? (safeParseFile(rootFilePath) ?? emptyFile(rootFilePath))\n      : emptyFile(join(projectRoot, \"CLAUDE.md\"));\n\n  // Rule files\n  const rules = loadRules(projectRoot);\n\n  // Skill files\n  const skills = loadSkills(projectRoot);\n\n  // Sub-directory CLAUDE.md files (skip root)\n  const subFiles = findSubClaudeFiles(projectRoot, projectRoot);\n\n  // MCP servers\n  const mcpServers = parseMcpServers(projectRoot);\n\n  return {\n    tool: \"claude-code\",\n    rootFile,\n    rules,\n    skills,\n    subFiles,\n    mcpServers,\n  };\n}\n\nfunction emptyFile(path: string): InstructionFile {\n  return {\n    path,\n    lines: [],\n    lineCount: 0,\n    tokenCount: 0,\n    tokenMethod: \"estimated\",\n  };\n}\n","import { readFileSync } from \"fs\";\nimport type { InstructionFile, ParsedLine } from \"../types.js\";\n\n// ─── Keyword dictionary ────────────────────────────────────────────────────\n\nconst KNOWN_KEYWORDS = new Set([\n  \"typescript\",\n  \"javascript\",\n  \"eslint\",\n  \"prettier\",\n  \"biome\",\n  \"react\",\n  \"vue\",\n  \"svelte\",\n  \"angular\",\n  \"next\",\n  \"nextjs\",\n  \"nuxt\",\n  \"jest\",\n  \"vitest\",\n  \"mocha\",\n  \"jasmine\",\n  \"playwright\",\n  \"cypress\",\n  \"postgresql\",\n  \"postgres\",\n  \"mysql\",\n  \"sqlite\",\n  \"mongodb\",\n  \"redis\",\n  \"docker\",\n  \"kubernetes\",\n  \"k8s\",\n  \"terraform\",\n  \"git\",\n  \"github\",\n  \"gitlab\",\n  \"npm\",\n  \"pnpm\",\n  \"yarn\",\n  \"bun\",\n  \"node\",\n  \"nodejs\",\n  \"deno\",\n  \"webpack\",\n  \"vite\",\n  \"esbuild\",\n  \"tsup\",\n  \"rollup\",\n  \"zod\",\n  \"prisma\",\n  \"drizzle\",\n  \"openai\",\n  \"anthropic\",\n  \"claude\",\n  \"commitlint\",\n  \"husky\",\n  \"lint-staged\",\n]);\n\nconst KEYWORD_REGEX = new RegExp(\n  `\\\\b(${[...KNOWN_KEYWORDS].join(\"|\")})\\\\b`,\n  \"gi\",\n);\n\n// ─── Path extraction ───────────────────────────────────────────────────────\n\n// Matches path-like strings: starts with src/, tests/, ./, ../, or contains /\n// but NOT URLs (http:// https://)\nconst PATH_REGEX =\n  /(?<!\\w)(?:\\.{1,2}\\/|(?:src|tests?|dist|lib|docs?|config|scripts?|packages?)\\/)[^\\s,;`'\")\\]>]+/g;\n\n// Matches @file references: @path/to/file.md (or .txt, .json, .yaml, .yml)\n// Negative lookbehind: not after word char (avoids emails like user@example.com)\n// Capture group 1: the path, WITHOUT the leading @\nconst AT_REF_REGEX =\n  /(?<![a-zA-Z0-9_])@((?:\\.\\.?\\/)?[\\w./-]+\\.(?:md|txt|json|yaml|yml))\\b/g;\n\n// ─── Rule classification signals ──────────────────────────────────────────\n\nconst RULE_IMPERATIVE_WORDS =\n  /\\b(must|should|never|always|prefer|avoid|ensure|require|forbid|use|do not|don't)\\b|必須|應該|應當|永遠|總是|禁止|不要|不可|不得|避免|請使用|優先使用|請勿/i;\n\nconst RULE_NEGATION_PATTERN = /\\b(not|don't|do not)\\s+\\w+/i;\n\n// Strong imperatives for non-list lines (must match at sentence start or be prominent)\nconst STRONG_IMPERATIVE = /\\b(must|shall|always|never)\\b/i;\n\n// ─── YAML frontmatter parsing ──────────────────────────────────────────────\n\ninterface FrontmatterResult {\n  paths?: string[];\n  globs?: string[];\n  body: string;\n}\n\nexport function parseYamlFrontmatter(content: string): FrontmatterResult {\n  const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/m.exec(content);\n  if (match == null) {\n    return { body: content };\n  }\n\n  const yaml = match[1] ?? \"\";\n  const body = match[2] ?? \"\";\n\n  const paths = extractYamlStringArray(yaml, \"paths\");\n  const globs = extractYamlStringArray(yaml, \"globs\");\n\n  return {\n    ...(paths != null ? { paths } : {}),\n    ...(globs != null ? { globs } : {}),\n    body,\n  };\n}\n\nfunction extractYamlStringArray(\n  yaml: string,\n  key: string,\n): string[] | undefined {\n  // Match \"key:\\n  - value\\n  - value\" style\n  const blockMatch = new RegExp(\n    `^${key}:\\\\s*\\\\n((?:\\\\s+-\\\\s+.+\\\\n?)*)`,\n    \"m\",\n  ).exec(yaml);\n  if (blockMatch != null) {\n    return (blockMatch[1] ?? \"\")\n      .split(\"\\n\")\n      .map((l) =>\n        l\n          .replace(/^\\s+-\\s+/, \"\")\n          .replace(/[\"']/g, \"\")\n          .trim(),\n      )\n      .filter((l) => l.length > 0);\n  }\n\n  // Match \"key: [value, value]\" inline style\n  const inlineMatch = new RegExp(`^${key}:\\\\s*\\\\[(.+)\\\\]`, \"m\").exec(yaml);\n  if (inlineMatch != null) {\n    return (inlineMatch[1] ?? \"\")\n      .split(\",\")\n      .map((s) => s.replace(/[\"']/g, \"\").trim())\n      .filter((s) => s.length > 0);\n  }\n\n  return undefined;\n}\n\n// ─── Line classifier ───────────────────────────────────────────────────────\n\nfunction classifyLine(\n  text: string,\n  inCodeBlock: boolean,\n  inHtmlComment: boolean,\n): ParsedLine[\"type\"] {\n  if (inCodeBlock) return \"code\";\n  if (inHtmlComment) return \"comment\";\n\n  const trimmed = text.trim();\n\n  if (trimmed.length === 0) return \"blank\";\n  if (/^#{1,6}\\s/.test(trimmed)) return \"heading\";\n  if (trimmed.startsWith(\"```\")) return \"code\";\n\n  // Inline HTML comment (whole line)\n  if (/^<!--[\\s\\S]*-->$/.test(trimmed)) return \"comment\";\n  // Opening HTML comment\n  if (trimmed.startsWith(\"<!--\")) return \"comment\";\n\n  if (isRule(trimmed)) return \"rule\";\n  return \"other\";\n}\n\nfunction isRule(text: string): boolean {\n  const isList = text.startsWith(\"- \");\n  const body = isList ? text.slice(2) : text;\n\n  if (isList) {\n    if (RULE_IMPERATIVE_WORDS.test(body)) return true;\n    if (RULE_NEGATION_PATTERN.test(body)) return true;\n  } else {\n    // Non-list lines: require strong imperative AND sentence-like structure\n    if (STRONG_IMPERATIVE.test(body) && /^[A-Z]/.test(body)) return true;\n    // Also catch imperative sentences starting with a verb (capitalised)\n    if (RULE_IMPERATIVE_WORDS.test(body) && /^[A-Z][a-z]/.test(body))\n      return true;\n    // CJK lines: classify as rule if they start with a CJK character and contain an imperative word\n    if (\n      RULE_IMPERATIVE_WORDS.test(body) &&\n      /^[\\u4e00-\\u9fff\\u3400-\\u4dbf]/.test(body)\n    )\n      return true;\n  }\n\n  return false;\n}\n\nfunction extractKeywords(text: string): string[] {\n  const matches = text.matchAll(KEYWORD_REGEX);\n  const found = new Set<string>();\n  for (const m of matches) {\n    found.add(m[0].toLowerCase());\n  }\n  return [...found];\n}\n\nfunction extractPaths(text: string): string[] {\n  const found: string[] = [];\n\n  // Existing path patterns (src/, tests/, ./, ../, etc.)\n  for (const m of text.matchAll(PATH_REGEX)) {\n    const cleaned = m[0].replace(/[.,;)>\\]'\"]+$/, \"\");\n    if (cleaned.length > 1) found.push(cleaned);\n  }\n\n  // @file references: strip the @ and keep just the path\n  for (const m of text.matchAll(AT_REF_REGEX)) {\n    const cleaned = (m[1] ?? \"\").replace(/[.,;)>\\]'\"]+$/, \"\");\n    if (cleaned.length > 0) found.push(cleaned);\n  }\n\n  return [...new Set(found)];\n}\n\n// ─── Public API ────────────────────────────────────────────────────────────\n\nexport function parseInstructionFile(filePath: string): InstructionFile {\n  const raw = readFileSync(filePath, \"utf8\");\n  const rawLines = raw.split(/\\r?\\n/);\n\n  // Strip the single trailing empty string produced by a final newline.\n  // Most text files end with \\n, which splits into [..., ''] — this is not a real line.\n  if (rawLines.length > 0 && rawLines[rawLines.length - 1] === \"\") {\n    rawLines.pop();\n  }\n\n  let inCodeBlock = false;\n  let inHtmlComment = false;\n  const lines: ParsedLine[] = [];\n\n  for (let i = 0; i < rawLines.length; i++) {\n    const text = rawLines[i] ?? \"\";\n    const trimmed = text.trim();\n\n    // Classify using current state (before updating)\n    const type = classifyLine(text, inCodeBlock, inHtmlComment);\n\n    // Update code block state AFTER classifying the fence line itself\n    if (!inHtmlComment && trimmed.startsWith(\"```\")) {\n      inCodeBlock = !inCodeBlock;\n    }\n\n    // Update HTML comment state AFTER classifying the current line:\n    // - opening line (<!-- ... without -->): set true after this line\n    // - closing line (contains -->): set false after this line\n    // - lines inside: state remains true\n    if (!inCodeBlock) {\n      if (inHtmlComment) {\n        if (trimmed.includes(\"-->\")) inHtmlComment = false;\n      } else if (trimmed.startsWith(\"<!--\") && !trimmed.includes(\"-->\")) {\n        inHtmlComment = true;\n      }\n    }\n\n    lines.push({\n      lineNumber: i + 1,\n      text,\n      type,\n      keywords: extractKeywords(text),\n      referencedPaths: extractPaths(text),\n    });\n  }\n\n  return {\n    path: filePath,\n    lines,\n    lineCount: lines.length,\n    // tokenCount and tokenMethod will be filled by the adapter/estimator\n    tokenCount: 0,\n    tokenMethod: \"estimated\",\n  };\n}\n","import type { McpServerConfig, TokenMethod } from \"../types.js\";\n\n// ─── Tiktoken singleton ────────────────────────────────────────────────────\n\ninterface TiktokenEncoder {\n  encode(text: string): ArrayLike<number>;\n}\n\nlet encoder: TiktokenEncoder | null = null;\n\n// Single shared Promise — all callers await the same resolution.\n// Setting initialized = true before the await was a race: ensureInitialized()\n// would see the flag and return while encoder was still null.\nconst initPromise: Promise<void> = (async () => {\n  try {\n    const { getEncoding } = await import(\"js-tiktoken\");\n    encoder = getEncoding(\"cl100k_base\");\n  } catch {\n    process.stderr.write(\n      \"[instrlint] Warning: js-tiktoken failed to load — falling back to character estimation\\n\",\n    );\n    encoder = null;\n  }\n})();\n\nexport async function ensureInitialized(): Promise<void> {\n  await initPromise;\n}\n\n// ─── CJK character detection ───────────────────────────────────────────────\n\nconst CJK_REGEX = /[\\u3000-\\u9fff\\uac00-\\ud7af\\uf900-\\ufaff]/g;\n\nfunction cjkRatio(text: string): number {\n  if (text.length === 0) return 0;\n  const matches = text.match(CJK_REGEX);\n  return (matches?.length ?? 0) / text.length;\n}\n\n// ─── Public API ────────────────────────────────────────────────────────────\n\ninterface TokenCount {\n  count: number;\n  method: TokenMethod;\n}\n\nexport function countTokens(text: string): TokenCount {\n  if (text.length === 0) return { count: 0, method: \"measured\" };\n\n  if (encoder != null) {\n    try {\n      return { count: encoder.encode(text).length, method: \"measured\" };\n    } catch {\n      // Fall through to estimation\n    }\n  }\n\n  return estimateFallback(text);\n}\n\nexport function estimateFallback(text: string): TokenCount {\n  const ratio = cjkRatio(text);\n  const charsPerToken = 4 * (1 - ratio) + 2 * ratio;\n  return {\n    count: Math.ceil(text.length / charsPerToken),\n    method: \"estimated\",\n  };\n}\n\nexport function estimateMcpTokens(config: McpServerConfig): {\n  count: number;\n  method: \"estimated\";\n} {\n  if (config.toolCount != null) {\n    return { count: config.toolCount * 400, method: \"estimated\" };\n  }\n  // Default: assume a small server (~2500 tokens)\n  return { count: 2500, method: \"estimated\" };\n}\n","import { existsSync, readdirSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { parseInstructionFile } from \"../core/parser.js\";\nimport {\n  countTokens,\n  estimateMcpTokens,\n} from \"../detectors/token-estimator.js\";\nimport type {\n  InstructionFile,\n  McpServerConfig,\n  ParsedInstructions,\n  SkillFile,\n} from \"../types.js\";\n\n// ─── Helpers ───────────────────────────────────────────────────────────────\n\nfunction safeParseFile(filePath: string): InstructionFile | null {\n  try {\n    const raw = readFileSync(filePath, \"utf8\");\n    const file = parseInstructionFile(filePath);\n    const { count, method } = countTokens(raw);\n    return { ...file, tokenCount: count, tokenMethod: method };\n  } catch {\n    process.stderr.write(\n      `[instrlint] Warning: could not read ${filePath}, skipping\\n`,\n    );\n    return null;\n  }\n}\n\nfunction emptyFile(path: string): InstructionFile {\n  return {\n    path,\n    lines: [],\n    lineCount: 0,\n    tokenCount: 0,\n    tokenMethod: \"estimated\",\n  };\n}\n\n// ─── Skills ───────────────────────────────────────────────────────────────\n\nfunction loadSkills(projectRoot: string): SkillFile[] {\n  const skillsDir = join(projectRoot, \".agents\", \"skills\");\n  if (!existsSync(skillsDir)) return [];\n\n  const skills: SkillFile[] = [];\n  let entries: string[] = [];\n  try {\n    entries = readdirSync(skillsDir);\n  } catch {\n    return [];\n  }\n\n  for (const skillName of entries) {\n    const skillFile = join(skillsDir, skillName, \"SKILL.md\");\n    if (!existsSync(skillFile)) continue;\n    const parsed = safeParseFile(skillFile);\n    if (parsed != null) {\n      skills.push({ ...parsed, skillName });\n    }\n  }\n\n  return skills;\n}\n\n// ─── MCP servers from .codex/config.toml ─────────────────────────────────\n\n/**\n * Minimal TOML parser targeting only [mcp_servers.<name>] sections.\n * Handles simple key = \"value\" and key = [\"array\"] under those sections.\n */\nfunction parseMcpFromToml(toml: string): McpServerConfig[] {\n  const servers: McpServerConfig[] = [];\n  const sectionRe = /^\\[mcp_servers\\.([^\\]]+)\\]/;\n  const keyValueRe = /^(\\w+)\\s*=\\s*(.+)$/;\n\n  let currentName: string | null = null;\n  let currentTools: string[] | undefined;\n\n  const flush = () => {\n    if (currentName != null) {\n      const config: McpServerConfig = {\n        name: currentName,\n        estimatedTokens: 0,\n        ...(currentTools !== undefined ? { toolCount: currentTools.length } : {}),\n      };\n      const { count } = estimateMcpTokens(config);\n      servers.push({ ...config, estimatedTokens: count });\n    }\n    currentName = null;\n    currentTools = undefined;\n  };\n\n  for (const line of toml.split(\"\\n\")) {\n    const trimmed = line.trim();\n    if (trimmed.startsWith(\"#\") || trimmed === \"\") continue;\n\n    const sectionMatch = sectionRe.exec(trimmed);\n    if (sectionMatch != null) {\n      flush();\n      currentName = sectionMatch[1]!;\n      continue;\n    }\n\n    if (currentName == null) continue;\n\n    const kvMatch = keyValueRe.exec(trimmed);\n    if (kvMatch == null) continue;\n\n    const key = kvMatch[1]!;\n    const raw = kvMatch[2]!.trim();\n\n    if (key === \"tools\") {\n      // Parse inline array: [\"tool1\", \"tool2\"]\n      const items = raw.match(/\"([^\"]+)\"/g);\n      currentTools = items != null ? items.map((s) => s.slice(1, -1)) : [];\n    }\n  }\n\n  flush();\n  return servers;\n}\n\nfunction loadMcpServers(projectRoot: string): McpServerConfig[] {\n  const tomlPath = join(projectRoot, \".codex\", \"config.toml\");\n  if (!existsSync(tomlPath)) return [];\n\n  try {\n    const raw = readFileSync(tomlPath, \"utf8\");\n    return parseMcpFromToml(raw);\n  } catch {\n    process.stderr.write(\n      `[instrlint] Warning: could not parse MCP config in ${tomlPath}, skipping\\n`,\n    );\n    return [];\n  }\n}\n\n// ─── Public API ────────────────────────────────────────────────────────────\n\nexport function loadCodexProject(projectRoot: string): ParsedInstructions {\n  const rootFilePath = join(projectRoot, \"AGENTS.md\");\n  const rootFile: InstructionFile = existsSync(rootFilePath)\n    ? (safeParseFile(rootFilePath) ?? emptyFile(rootFilePath))\n    : emptyFile(rootFilePath);\n\n  const skills = loadSkills(projectRoot);\n  const mcpServers = loadMcpServers(projectRoot);\n\n  return {\n    tool: \"codex\",\n    rootFile,\n    rules: [],\n    skills,\n    subFiles: [],\n    mcpServers,\n  };\n}\n","import { existsSync, readdirSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { parseInstructionFile, parseYamlFrontmatter } from \"../core/parser.js\";\nimport {\n  countTokens,\n  estimateMcpTokens,\n} from \"../detectors/token-estimator.js\";\nimport type {\n  InstructionFile,\n  McpServerConfig,\n  ParsedInstructions,\n  RuleFile,\n} from \"../types.js\";\n\n// ─── Helpers ───────────────────────────────────────────────────────────────\n\nfunction safeParseFile(filePath: string): InstructionFile | null {\n  try {\n    const raw = readFileSync(filePath, \"utf8\");\n    const file = parseInstructionFile(filePath);\n    const { count, method } = countTokens(raw);\n    return { ...file, tokenCount: count, tokenMethod: method };\n  } catch {\n    process.stderr.write(\n      `[instrlint] Warning: could not read ${filePath}, skipping\\n`,\n    );\n    return null;\n  }\n}\n\nfunction emptyFile(path: string): InstructionFile {\n  return {\n    path,\n    lines: [],\n    lineCount: 0,\n    tokenCount: 0,\n    tokenMethod: \"estimated\",\n  };\n}\n\n// ─── Root file ─────────────────────────────────────────────────────────────\n\nfunction findRootFile(projectRoot: string): string | null {\n  const cursorRules = join(projectRoot, \".cursorrules\");\n  if (existsSync(cursorRules)) return cursorRules;\n  return null;\n}\n\n// ─── Rules from .cursor/rules/*.md ────────────────────────────────────────\n\nfunction loadRules(projectRoot: string): RuleFile[] {\n  const rulesDir = join(projectRoot, \".cursor\", \"rules\");\n  if (!existsSync(rulesDir)) return [];\n\n  const rules: RuleFile[] = [];\n  let entries: string[] = [];\n  try {\n    entries = readdirSync(rulesDir).filter((f) => f.endsWith(\".md\"));\n  } catch {\n    return [];\n  }\n\n  for (const filename of entries) {\n    const filePath = join(rulesDir, filename);\n    try {\n      const raw = readFileSync(filePath, \"utf8\");\n      // Cursor uses globs: in frontmatter (not paths:)\n      const { globs, body } = parseYamlFrontmatter(raw);\n      const baseFile = parseInstructionFile(filePath);\n      const { count, method } = countTokens(body);\n      rules.push({\n        ...baseFile,\n        tokenCount: count,\n        tokenMethod: method,\n        ...(globs != null ? { globs } : {}),\n      });\n    } catch {\n      process.stderr.write(\n        `[instrlint] Warning: could not parse rule ${filePath}, skipping\\n`,\n      );\n    }\n  }\n\n  return rules;\n}\n\n// ─── MCP servers from .cursor/mcp.json ────────────────────────────────────\n\ninterface CursorMcpEntry {\n  command?: string;\n  args?: string[];\n  tools?: unknown[];\n}\n\nfunction loadMcpServers(projectRoot: string): McpServerConfig[] {\n  const mcpPath = join(projectRoot, \".cursor\", \"mcp.json\");\n  if (!existsSync(mcpPath)) return [];\n\n  try {\n    const raw = readFileSync(mcpPath, \"utf8\");\n    const parsed: unknown = JSON.parse(raw);\n    if (\n      parsed == null ||\n      typeof parsed !== \"object\" ||\n      !(\"mcpServers\" in parsed)\n    ) {\n      return [];\n    }\n    const mcpServers = (\n      parsed as { mcpServers: Record<string, CursorMcpEntry> }\n    ).mcpServers;\n    return Object.entries(mcpServers).map(([name, entry]) => {\n      const toolCount = Array.isArray(entry.tools) ? entry.tools.length : undefined;\n      const config: McpServerConfig = {\n        name,\n        estimatedTokens: 0,\n        ...(toolCount !== undefined ? { toolCount } : {}),\n      };\n      const { count } = estimateMcpTokens(config);\n      return { ...config, estimatedTokens: count };\n    });\n  } catch {\n    process.stderr.write(\n      `[instrlint] Warning: could not parse MCP config in ${mcpPath}, skipping\\n`,\n    );\n    return [];\n  }\n}\n\n// ─── Public API ────────────────────────────────────────────────────────────\n\nexport function loadCursorProject(projectRoot: string): ParsedInstructions {\n  const rootFilePath = findRootFile(projectRoot);\n  const rootFile: InstructionFile =\n    rootFilePath != null\n      ? (safeParseFile(rootFilePath) ?? emptyFile(rootFilePath))\n      : emptyFile(join(projectRoot, \".cursorrules\"));\n\n  const rules = loadRules(projectRoot);\n  const mcpServers = loadMcpServers(projectRoot);\n\n  return {\n    tool: \"cursor\",\n    rootFile,\n    rules,\n    skills: [],\n    subFiles: [],\n    mcpServers,\n  };\n}\n","import { loadClaudeCodeProject } from \"./claude-code.js\";\nimport { loadCodexProject } from \"./codex.js\";\nimport { loadCursorProject } from \"./cursor.js\";\nimport type { ParsedInstructions, ToolType } from \"../types.js\";\n\nexport function loadProject(\n  projectRoot: string,\n  tool: ToolType,\n): ParsedInstructions {\n  switch (tool) {\n    case \"claude-code\":\n      return loadClaudeCodeProject(projectRoot);\n    case \"codex\":\n      return loadCodexProject(projectRoot);\n    case \"cursor\":\n      return loadCursorProject(projectRoot);\n    default:\n      return loadClaudeCodeProject(projectRoot);\n  }\n}\n","import type {\n  BudgetSummary,\n  FileTokenEntry,\n  Finding,\n  ParsedInstructions,\n  TokenMethod,\n} from \"../types.js\";\n\nconst CONTEXT_WINDOW = 200_000;\nconst SYSTEM_PROMPT_TOKENS = 12_000;\nconst WARN_LINE_THRESHOLD = 200;\nconst CRITICAL_LINE_THRESHOLD = 400;\nconst WARN_BASELINE_PCT = 0.25; // 25% = 50K\nconst MCP_INFO_THRESHOLD = 10_000;\n\nfunction sumTokens(\n  items: Array<{ tokenCount: number; tokenMethod: TokenMethod }>,\n): { tokens: number; method: TokenMethod } {\n  if (items.length === 0) return { tokens: 0, method: \"measured\" };\n  const tokens = items.reduce((acc, f) => acc + f.tokenCount, 0);\n  const method: TokenMethod = items.every((f) => f.tokenMethod === \"measured\")\n    ? \"measured\"\n    : \"estimated\";\n  return { tokens, method };\n}\n\ninterface BudgetResult {\n  findings: Finding[];\n  summary: BudgetSummary;\n}\n\nexport function analyzeBudget(instructions: ParsedInstructions): BudgetResult {\n  const findings: Finding[] = [];\n\n  // ── Root file ────────────────────────────────────────────────────────────\n  const rootFileTokens = instructions.rootFile.tokenCount;\n  const rootFileMethod = instructions.rootFile.tokenMethod;\n  const rootLines = instructions.rootFile.lineCount;\n\n  if (rootLines > CRITICAL_LINE_THRESHOLD) {\n    findings.push({\n      severity: \"critical\",\n      category: \"budget\",\n      file: instructions.rootFile.path,\n      messageKey: \"budget.rootFileCritical\",\n      messageParams: { lines: String(rootLines) },\n      suggestion: `Root instruction file is ${rootLines} lines — agent compliance drops significantly above 200 lines`,\n      autoFixable: false,\n    });\n  } else if (rootLines > WARN_LINE_THRESHOLD) {\n    findings.push({\n      severity: \"warning\",\n      category: \"budget\",\n      file: instructions.rootFile.path,\n      messageKey: \"budget.rootFileWarning\",\n      messageParams: { lines: String(rootLines) },\n      suggestion: `Root instruction file is ${rootLines} lines (recommended: < 200)`,\n      autoFixable: false,\n    });\n  }\n\n  // ── Rules ─────────────────────────────────────────────────────────────────\n  const { tokens: rulesTokens, method: rulesMethod } = sumTokens(\n    instructions.rules,\n  );\n\n  // ── Skills ────────────────────────────────────────────────────────────────\n  const { tokens: skillsTokens, method: skillsMethod } = sumTokens(\n    instructions.skills,\n  );\n\n  // ── Sub-files ─────────────────────────────────────────────────────────────\n  const { tokens: subFilesTokens, method: subFilesMethod } = sumTokens(\n    instructions.subFiles,\n  );\n\n  // ── MCP servers ───────────────────────────────────────────────────────────\n  const mcpTokens = instructions.mcpServers.reduce(\n    (acc, s) => acc + s.estimatedTokens,\n    0,\n  );\n\n  for (const server of instructions.mcpServers) {\n    if (server.estimatedTokens > MCP_INFO_THRESHOLD) {\n      findings.push({\n        severity: \"info\",\n        category: \"budget\",\n        file: \".claude/settings.json\",\n        messageKey: \"budget.mcpLargeServer\",\n        messageParams: {\n          name: server.name,\n          tokens: server.estimatedTokens.toLocaleString(\"en\"),\n        },\n        suggestion: `MCP server '${server.name}' consumes ~${server.estimatedTokens.toLocaleString(\"en\")} tokens`,\n        autoFixable: false,\n      });\n    }\n  }\n\n  // ── Totals ────────────────────────────────────────────────────────────────\n  const totalBaseline =\n    SYSTEM_PROMPT_TOKENS +\n    rootFileTokens +\n    rulesTokens +\n    skillsTokens +\n    subFilesTokens +\n    mcpTokens;\n\n  const availableTokens = CONTEXT_WINDOW - totalBaseline;\n\n  const pct = totalBaseline / CONTEXT_WINDOW;\n  if (pct > WARN_BASELINE_PCT) {\n    findings.push({\n      severity: \"warning\",\n      category: \"budget\",\n      file: instructions.rootFile.path,\n      messageKey: \"budget.baselineHigh\",\n      messageParams: { pct: Math.round(pct * 100).toString() },\n      suggestion: `Baseline context consumption is ${Math.round(pct * 100)}% of window`,\n      autoFixable: false,\n    });\n  }\n\n  // Overall method: measured only if all file groups are measured\n  const tokenMethod: TokenMethod = [\n    rootFileMethod,\n    rulesMethod,\n    skillsMethod,\n    subFilesMethod,\n  ].every((m) => m === \"measured\")\n    ? \"measured\"\n    : \"estimated\";\n\n  // File breakdown\n  const fileBreakdown: FileTokenEntry[] = [\n    {\n      path: instructions.rootFile.path,\n      tokenCount: rootFileTokens,\n      tokenMethod: rootFileMethod,\n    },\n    ...instructions.rules.map((r) => ({\n      path: r.path,\n      tokenCount: r.tokenCount,\n      tokenMethod: r.tokenMethod,\n    })),\n    ...instructions.skills.map((s) => ({\n      path: s.path,\n      tokenCount: s.tokenCount,\n      tokenMethod: s.tokenMethod,\n    })),\n    ...instructions.subFiles.map((f) => ({\n      path: f.path,\n      tokenCount: f.tokenCount,\n      tokenMethod: f.tokenMethod,\n    })),\n  ];\n\n  const summary: BudgetSummary = {\n    systemPromptTokens: SYSTEM_PROMPT_TOKENS,\n    rootFileTokens,\n    rootFileLines: rootLines,\n    rootFileMethod,\n    rulesTokens,\n    rulesMethod,\n    skillsTokens,\n    skillsMethod,\n    subFilesTokens,\n    subFilesMethod,\n    mcpTokens,\n    totalBaseline,\n    availableTokens,\n    fileBreakdown,\n    tokenMethod,\n  };\n\n  return { findings, summary };\n}\n","import { readFileSync, existsSync, readdirSync } from \"fs\";\nimport { join } from \"path\";\nimport type { Finding, ParsedInstructions, ParsedLine } from \"../types.js\";\n\n// ─── Config reading helpers ───────────────────────────────────────────────────\n\nfunction readJsonFile(projectRoot: string, filename: string): unknown | null {\n  try {\n    const content = readFileSync(join(projectRoot, filename), \"utf8\");\n    return JSON.parse(content);\n  } catch {\n    return null;\n  }\n}\n\nfunction readTextFile(projectRoot: string, filename: string): string | null {\n  try {\n    return readFileSync(join(projectRoot, filename), \"utf8\");\n  } catch {\n    return null;\n  }\n}\n\nfunction checkEditorConfig(projectRoot: string, key: string): boolean {\n  const content = readTextFile(projectRoot, \".editorconfig\");\n  if (!content) return false;\n  return new RegExp(`^${key}\\\\s*=\\\\s*.+`, \"m\").test(content);\n}\n\nfunction checkPrettierConfig(projectRoot: string, field: string): boolean {\n  // Try .prettierrc and .prettierrc.json\n  for (const filename of [\".prettierrc\", \".prettierrc.json\"]) {\n    const parsed = readJsonFile(projectRoot, filename);\n    if (parsed !== null && typeof parsed === \"object\" && parsed !== null) {\n      if (field in (parsed as Record<string, unknown>)) return true;\n    }\n  }\n  return false;\n}\n\nfunction getPrettierField(projectRoot: string, field: string): unknown {\n  for (const filename of [\".prettierrc\", \".prettierrc.json\"]) {\n    const parsed = readJsonFile(projectRoot, filename);\n    if (parsed !== null && typeof parsed === \"object\") {\n      const obj = parsed as Record<string, unknown>;\n      if (field in obj) return obj[field];\n    }\n  }\n  return undefined;\n}\n\n// ─── C# helpers ──────────────────────────────────────────────────────────────\n\nfunction readCsprojContent(projectRoot: string): string | null {\n  // Directory.Build.props takes precedence (applies to all projects in tree)\n  const buildProps = readTextFile(projectRoot, \"Directory.Build.props\");\n  if (buildProps) return buildProps;\n  try {\n    const files = readdirSync(projectRoot);\n    for (const f of files) {\n      if (f.endsWith(\".csproj\") || f.endsWith(\".fsproj\")) {\n        const content = readTextFile(projectRoot, f);\n        if (content) return content;\n      }\n    }\n  } catch {\n    // directory not readable\n  }\n  return null;\n}\n\n/** Check if a .csproj / Directory.Build.props contains <Tag>value</Tag> (case-insensitive). */\nfunction checkCsprojProperty(\n  projectRoot: string,\n  tag: string,\n  value: string,\n): boolean {\n  const content = readCsprojContent(projectRoot);\n  if (!content) return false;\n  return new RegExp(`<${tag}>\\\\s*${value}\\\\s*</${tag}>`, \"i\").test(content);\n}\n\n/** Check if .editorconfig contains a line matching the given regex. */\nfunction checkEditorConfigPattern(\n  projectRoot: string,\n  pattern: RegExp,\n): boolean {\n  const content = readTextFile(projectRoot, \".editorconfig\");\n  if (!content) return false;\n  return pattern.test(content);\n}\n\nfunction checkEslintRule(projectRoot: string, ruleName: string): boolean {\n  const parsed = readJsonFile(projectRoot, \".eslintrc.json\");\n  if (!parsed || typeof parsed !== \"object\") return false;\n  const rules = (parsed as Record<string, unknown>)[\"rules\"];\n  if (!rules || typeof rules !== \"object\") return false;\n  const val = (rules as Record<string, unknown>)[ruleName];\n  if (val === undefined) return false;\n  if (val === \"off\" || val === 0) return false;\n  if (Array.isArray(val) && (val[0] === \"off\" || val[0] === 0)) return false;\n  return true;\n}\n\n// ─── Overlap patterns ─────────────────────────────────────────────────────────\n\ninterface OverlapPattern {\n  id: string;\n  rulePattern: RegExp;\n  configCheck: (projectRoot: string) => boolean;\n  configName: string;\n}\n\nconst PATTERNS: OverlapPattern[] = [\n  {\n    id: \"ts-strict\",\n    rulePattern: /\\b(typescript|ts)\\b.*\\bstrict\\b|\\bstrict\\s*(mode|typing)/i,\n    configCheck: (root) => {\n      const tsconfig = readJsonFile(root, \"tsconfig.json\");\n      if (!tsconfig || typeof tsconfig !== \"object\") return false;\n      const opts = (tsconfig as Record<string, unknown>)[\"compilerOptions\"];\n      if (!opts || typeof opts !== \"object\") return false;\n      return (opts as Record<string, unknown>)[\"strict\"] === true;\n    },\n    configName: \"tsconfig.json (compilerOptions.strict: true)\",\n  },\n  {\n    id: \"indent-spaces\",\n    rulePattern: /\\b(2|two|4|four)\\s*(-?\\s*)space\\s*indent/i,\n    configCheck: (root) =>\n      checkEditorConfig(root, \"indent_size\") ||\n      checkPrettierConfig(root, \"tabWidth\"),\n    configName: \".editorconfig / .prettierrc (indentation)\",\n  },\n  {\n    id: \"import-order\",\n    rulePattern: /import\\s*(order|sort)|sort\\s*import/i,\n    configCheck: (root) => {\n      const pkg = readJsonFile(root, \"package.json\");\n      if (!pkg || typeof pkg !== \"object\") return false;\n      const devDeps = (pkg as Record<string, unknown>)[\"devDependencies\"];\n      const hasPlugin =\n        devDeps &&\n        typeof devDeps === \"object\" &&\n        \"eslint-plugin-import\" in devDeps;\n      return hasPlugin === true && checkEslintRule(root, \"import/order\");\n    },\n    configName: \"eslint-plugin-import (import/order)\",\n  },\n  {\n    id: \"conventional-commit\",\n    rulePattern: /conventional\\s*commit/i,\n    configCheck: (root) => {\n      // Check commitlint key in package.json\n      const pkg = readJsonFile(root, \"package.json\");\n      if (pkg && typeof pkg === \"object\" && \"commitlint\" in (pkg as object))\n        return true;\n      // Check commitlint config files\n      const configFiles = [\n        \"commitlint.config.js\",\n        \"commitlint.config.cjs\",\n        \"commitlint.config.ts\",\n        \".commitlintrc\",\n        \".commitlintrc.json\",\n        \".commitlintrc.yaml\",\n        \".commitlintrc.yml\",\n      ];\n      return configFiles.some((f) => existsSync(join(root, f)));\n    },\n    configName: \"commitlint config\",\n  },\n  {\n    id: \"semicolons\",\n    rulePattern: /\\b(semicolons?|always\\s*use\\s*;|semi\\s*colon)/i,\n    configCheck: (root) => checkPrettierConfig(root, \"semi\"),\n    configName: \".prettierrc (semi)\",\n  },\n  {\n    id: \"single-quote\",\n    rulePattern: /single\\s*quotes?|prefer\\s*'|use\\s*'/i,\n    configCheck: (root) => getPrettierField(root, \"singleQuote\") === true,\n    configName: \".prettierrc (singleQuote: true)\",\n  },\n  {\n    id: \"trailing-comma\",\n    rulePattern: /trailing\\s*comma/i,\n    configCheck: (root) => checkPrettierConfig(root, \"trailingComma\"),\n    configName: \".prettierrc (trailingComma)\",\n  },\n  {\n    id: \"max-line-length\",\n    rulePattern:\n      /\\b(max|maximum)\\s*(line\\s*)?(length|width|chars?)\\b|\\bprint\\s*width\\b/i,\n    configCheck: (root) => checkPrettierConfig(root, \"printWidth\"),\n    configName: \".prettierrc (printWidth)\",\n  },\n  {\n    id: \"no-console\",\n    rulePattern: /\\b(no|avoid|remove)\\b.*\\bconsole\\.(log|warn|error)/i,\n    configCheck: (root) => checkEslintRule(root, \"no-console\"),\n    configName: \"eslint (no-console)\",\n  },\n  {\n    id: \"no-unused-vars\",\n    rulePattern: /\\b(no|remove|avoid)\\s*(unused|dead)\\s*(var|variable|import)/i,\n    configCheck: (root) => {\n      const tsconfig = readJsonFile(root, \"tsconfig.json\");\n      if (tsconfig && typeof tsconfig === \"object\") {\n        const opts = (tsconfig as Record<string, unknown>)[\"compilerOptions\"];\n        if (opts && typeof opts === \"object\") {\n          const o = opts as Record<string, unknown>;\n          if (o[\"noUnusedLocals\"] === true || o[\"noUnusedParameters\"] === true)\n            return true;\n        }\n      }\n      return (\n        checkEslintRule(root, \"no-unused-vars\") ||\n        checkEslintRule(root, \"@typescript-eslint/no-unused-vars\")\n      );\n    },\n    configName: \"tsconfig / eslint (no-unused-vars)\",\n  },\n  {\n    id: \"test-framework\",\n    rulePattern: /\\b(use|prefer)\\s*(jest|vitest|mocha|jasmine)\\b/i,\n    configCheck: (root) => {\n      const configs = [\n        \"vitest.config.ts\",\n        \"vitest.config.js\",\n        \"jest.config.ts\",\n        \"jest.config.js\",\n        \"jest.config.cjs\",\n        \".mocharc.js\",\n        \".mocharc.json\",\n        \".mocharc.yaml\",\n      ];\n      if (configs.some((f) => existsSync(join(root, f)))) return true;\n      const pkg = readJsonFile(root, \"package.json\");\n      if (!pkg || typeof pkg !== \"object\") return false;\n      const devDeps = (pkg as Record<string, unknown>)[\"devDependencies\"] ?? {};\n      return [\"jest\", \"vitest\", \"mocha\", \"jasmine\"].some(\n        (fw) => typeof devDeps === \"object\" && fw in (devDeps as object),\n      );\n    },\n    configName: \"test framework config file\",\n  },\n  {\n    id: \"formatter\",\n    rulePattern: /\\b(format|prettier|biome)\\s*(code|files|on\\s*save)/i,\n    configCheck: (root) => {\n      const prettierFiles = [\n        \".prettierrc\",\n        \".prettierrc.json\",\n        \".prettierrc.yaml\",\n        \".prettierrc.yml\",\n      ];\n      if (prettierFiles.some((f) => existsSync(join(root, f)))) return true;\n      return existsSync(join(root, \"biome.json\"));\n    },\n    configName: \"prettier / biome config file\",\n  },\n  {\n    id: \"end-of-line\",\n    rulePattern: /\\b(line\\s*ending|eol|crlf|lf)\\b/i,\n    configCheck: (root) =>\n      checkEditorConfig(root, \"end_of_line\") ||\n      checkPrettierConfig(root, \"endOfLine\"),\n    configName: \".editorconfig / .prettierrc (endOfLine)\",\n  },\n  {\n    id: \"tab-width\",\n    rulePattern: /\\btab\\s*(width|size)\\b/i,\n    configCheck: (root) =>\n      checkEditorConfig(root, \"tab_width\") ||\n      checkEditorConfig(root, \"indent_size\") ||\n      checkPrettierConfig(root, \"tabWidth\"),\n    configName: \".editorconfig / .prettierrc (tabWidth)\",\n  },\n  {\n    id: \"no-default-export\",\n    rulePattern: /\\b(no|avoid|prefer\\s*named)\\s*(default\\s*export)/i,\n    configCheck: (root) =>\n      checkEslintRule(root, \"import/no-default-export\") ||\n      checkEslintRule(root, \"no-restricted-exports\"),\n    configName: \"eslint-plugin-import (no-default-export)\",\n  },\n\n  // ─── C# patterns ─────────────────────────────────────────────────────────\n\n  {\n    id: \"csharp-nullable\",\n    rulePattern:\n      /\\b(nullable\\s*reference\\s*type|#nullable\\s*enable|enable\\s*nullable|null\\s*reference\\s*exception)\\b/i,\n    configCheck: (root) =>\n      checkCsprojProperty(root, \"Nullable\", \"enable\") ||\n      checkCsprojProperty(root, \"Nullable\", \"annotations\") ||\n      checkCsprojProperty(root, \"Nullable\", \"warnings\"),\n    configName: \".csproj (<Nullable>enable</Nullable>)\",\n  },\n  {\n    id: \"csharp-implicit-usings\",\n    rulePattern: /\\b(global\\s*usings?|implicit\\s*usings?)\\b/i,\n    configCheck: (root) =>\n      checkCsprojProperty(root, \"ImplicitUsings\", \"enable\"),\n    configName: \".csproj (<ImplicitUsings>enable</ImplicitUsings>)\",\n  },\n  {\n    id: \"csharp-test-framework\",\n    rulePattern: /\\b(xunit|nunit|mstest|microsoft\\.testing\\.framework)\\b/i,\n    configCheck: (root) => {\n      const content = readCsprojContent(root);\n      if (!content) return false;\n      return /PackageReference\\s+Include=\"(xunit|NUnit|MSTest|Microsoft\\.Testing)/i.test(\n        content,\n      );\n    },\n    configName: \".csproj (PackageReference xUnit / NUnit / MSTest)\",\n  },\n  {\n    id: \"csharp-formatter\",\n    rulePattern: /\\bdotnet\\s*format\\b/i,\n    configCheck: (root) =>\n      checkEditorConfigPattern(root, /^\\[.*\\.cs\\]/m) &&\n      checkEditorConfigPattern(root, /^csharp_/m),\n    configName: \".editorconfig ([*.cs] csharp_style_* settings)\",\n  },\n  {\n    id: \"csharp-naming\",\n    rulePattern:\n      /\\bdotnet_naming\\b|PascalCase\\s+for\\s+(all\\s+)?(public|class|method|property|type)\\b/i,\n    configCheck: (root) =>\n      checkEditorConfigPattern(root, /^dotnet_naming_rule\\./m),\n    configName: \".editorconfig (dotnet_naming_rule.*)\",\n  },\n  {\n    id: \"csharp-unused\",\n    rulePattern:\n      /\\b(IDE0059|CS0168|CS0219|dead\\s*code|unused.*IDE|roslyn.*unused)\\b/i,\n    configCheck: (root) =>\n      checkEditorConfigPattern(\n        root,\n        /^dotnet_diagnostic\\.(IDE0059|CS0168|CS0219)/m,\n      ),\n    configName: \".editorconfig (dotnet_diagnostic.IDE0059 / CS0168)\",\n  },\n];\n\n// ─── Detector ─────────────────────────────────────────────────────────────────\n\nfunction collectRuleLines(\n  instructions: ParsedInstructions,\n): Array<{ line: ParsedLine; file: string }> {\n  const result: Array<{ line: ParsedLine; file: string }> = [];\n  for (const l of instructions.rootFile.lines) {\n    if (l.type === \"rule\")\n      result.push({ line: l, file: instructions.rootFile.path });\n  }\n  for (const sub of instructions.subFiles) {\n    for (const l of sub.lines) {\n      if (l.type === \"rule\") result.push({ line: l, file: sub.path });\n    }\n  }\n  for (const rule of instructions.rules) {\n    for (const l of rule.lines) {\n      if (l.type === \"rule\") result.push({ line: l, file: rule.path });\n    }\n  }\n  return result;\n}\n\nexport function detectConfigOverlaps(\n  instructions: ParsedInstructions,\n  projectRoot: string,\n): Finding[] {\n  const findings: Finding[] = [];\n  const ruleLines = collectRuleLines(instructions);\n\n  for (const { line, file } of ruleLines) {\n    for (const pattern of PATTERNS) {\n      if (\n        pattern.rulePattern.test(line.text) &&\n        pattern.configCheck(projectRoot)\n      ) {\n        const ruleText = line.text.trim();\n        const short =\n          ruleText.length > 60 ? ruleText.slice(0, 60) + \"…\" : ruleText;\n        findings.push({\n          severity: \"warning\",\n          category: \"dead-rule\",\n          file,\n          line: line.lineNumber,\n          messageKey: \"deadRule.configOverlap\",\n          messageParams: {\n            rule: ruleText.slice(0, 80),\n            config: pattern.configName,\n          },\n          suggestion: `Rule \"${short}\" is already enforced by ${pattern.configName}`,\n          autoFixable: true,\n        });\n        break; // one pattern match per line is enough\n      }\n    }\n  }\n\n  return findings;\n}\n","const STOP_WORDS = new Set([\n  // English grammatical function words\n  \"the\",\n  \"a\",\n  \"an\",\n  \"is\",\n  \"are\",\n  \"to\",\n  \"for\",\n  \"and\",\n  \"or\",\n  \"in\",\n  \"of\",\n  \"with\",\n  \"that\",\n  \"this\",\n  // Chinese filler bigrams (grammatical / no topic content)\n  \"的時\",\n  \"時候\",\n  \"一個\",\n  \"所有\",\n  \"每個\",\n]);\n\n// Matches a contiguous run of CJK Unified Ideographs (BMP + Extension A)\nconst CJK_RUN = /[\\u4e00-\\u9fff\\u3400-\\u4dbf]+/g;\nconst ASCII_WORD = /[a-z0-9]+/g;\n\nexport function tokenizeWords(text: string): string[] {\n  const words: string[] = [];\n  const lower = text.toLowerCase();\n\n  // English alphanumeric tokens — same behaviour as before (length > 1)\n  for (const m of lower.matchAll(ASCII_WORD)) {\n    if (m[0].length > 1) words.push(m[0]);\n  }\n\n  // CJK char-bigrams: slide a 2-char window over each contiguous CJK run.\n  // Single-char runs are skipped (analogous to the length > 1 filter for ASCII).\n  for (const m of text.matchAll(CJK_RUN)) {\n    const run = m[0];\n    if (run.length < 2) continue;\n    for (let i = 0; i < run.length - 1; i++) {\n      words.push(run.slice(i, i + 2));\n    }\n  }\n\n  return words;\n}\n\nexport function removeStopWords(words: string[]): string[] {\n  return words.filter((w) => !STOP_WORDS.has(w));\n}\n\nexport function jaccardSimilarity(setA: string[], setB: string[]): number {\n  if (setA.length === 0 && setB.length === 0) return 0;\n  const a = new Set(setA);\n  const b = new Set(setB);\n  let intersection = 0;\n  for (const word of a) {\n    if (b.has(word)) intersection++;\n  }\n  const union = new Set([...a, ...b]).size;\n  return union === 0 ? 0 : intersection / union;\n}\n","import type { Finding, ParsedInstructions, ParsedLine } from '../types.js';\nimport { jaccardSimilarity, removeStopWords, tokenizeWords } from '../utils/text.js';\n\nconst SIMILARITY_THRESHOLD = 0.7;\nconst MIN_WORDS_AFTER_STOP = 4;\n\ninterface RuleLine {\n  line: ParsedLine;\n  file: string;\n  words: string[];\n}\n\nfunction collectRuleLines(instructions: ParsedInstructions): RuleLine[] {\n  const result: RuleLine[] = [];\n\n  const add = (lines: ParsedLine[], file: string) => {\n    for (const l of lines) {\n      if (l.type !== 'rule') continue;\n      const words = removeStopWords(tokenizeWords(l.text));\n      if (words.length < MIN_WORDS_AFTER_STOP) continue;\n      result.push({ line: l, file, words });\n    }\n  };\n\n  add(instructions.rootFile.lines, instructions.rootFile.path);\n  for (const sub of instructions.subFiles) add(sub.lines, sub.path);\n  for (const rule of instructions.rules) add(rule.lines, rule.path);\n\n  return result;\n}\n\nexport function detectDuplicates(instructions: ParsedInstructions): Finding[] {\n  const findings: Finding[] = [];\n  const ruleLines = collectRuleLines(instructions);\n  const reported = new Set<string>();\n\n  for (let i = 0; i < ruleLines.length; i++) {\n    for (let j = i + 1; j < ruleLines.length; j++) {\n      const a = ruleLines[i]!;\n      const b = ruleLines[j]!;\n      const pairKey = `${a.file}:${a.line.lineNumber}|${b.file}:${b.line.lineNumber}`;\n      if (reported.has(pairKey)) continue;\n\n      const sim = jaccardSimilarity(a.words, b.words);\n      if (sim < SIMILARITY_THRESHOLD) continue;\n\n      reported.add(pairKey);\n\n      const isExact = sim >= 1.0;\n      const simPct = `${Math.round(sim * 100)}`;\n\n      findings.push({\n        severity: isExact ? 'warning' : 'info',\n        category: 'duplicate',\n        file: b.file,\n        line: b.line.lineNumber,\n        messageKey: isExact ? 'deadRule.exactDuplicate' : 'deadRule.nearDuplicate',\n        messageParams: {\n          otherFile: a.file,\n          otherLine: String(a.line.lineNumber),\n          similarity: simPct,\n        },\n        suggestion: isExact\n          ? `Exact duplicate of line ${a.line.lineNumber} in ${a.file}`\n          : `Very similar to line ${a.line.lineNumber} in ${a.file} (${simPct}% similar)`,\n        autoFixable: isExact,\n      });\n    }\n  }\n\n  return findings;\n}\n","import { detectConfigOverlaps } from \"../detectors/config-overlap.js\";\nimport { detectDuplicates } from \"../detectors/duplicate.js\";\nimport type { Finding, ParsedInstructions } from \"../types.js\";\n\ninterface DeadRulesResult {\n  findings: Finding[];\n}\n\nexport function analyzeDeadRules(\n  instructions: ParsedInstructions,\n  projectRoot: string,\n): DeadRulesResult {\n  return {\n    findings: [\n      ...detectConfigOverlaps(instructions, projectRoot),\n      ...detectDuplicates(instructions),\n    ],\n  };\n}\n","import { removeStopWords, tokenizeWords } from \"../utils/text.js\";\nimport type {\n  Finding,\n  InstructionFile,\n  ParsedInstructions,\n  ParsedLine,\n} from \"../types.js\";\n\n// ─── Negation detection ────────────────────────────────────────────────────────\n\nconst NEGATION_WORDS = [\"never\", \"don't\", \"avoid\", \"forbid\"];\n\n// CJK negation words that negate the whole clause they appear in\nconst CJK_NEGATIONS = [\"禁止\", \"不要\", \"不可\", \"不得\", \"避免\", \"請勿\", \"勿\"];\n\n// Matches CJK-only strings (no ASCII)\nconst CJK_ONLY_RE = /^[\\u4e00-\\u9fff\\u3400-\\u4dbf]+$/;\n\n/**\n * Returns true if `word` is negated within a single sentence of `text`.\n * Checks each sentence independently to avoid cross-sentence false positives.\n *\n * Possessive forms (\"not Claude's …\") are excluded: when the word immediately\n * follows \"not\" but is itself in possessive form, the negation targets the\n * whole noun phrase, not the word itself.\n */\nfunction isNegated(text: string, word: string): boolean {\n  // Split into sentences — supports both English (.!?) and Chinese (。！？) punctuation\n  const sentences = text.split(/[.!?。！？]+\\s*/);\n  const escapedWord = word.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n  const wordPresent = new RegExp(`\\\\b${escapedWord}\\\\b`, \"i\");\n\n  for (const sentence of sentences) {\n    if (!wordPresent.test(sentence)) continue;\n    const lower = sentence.toLowerCase();\n\n    for (const neg of NEGATION_WORDS) {\n      // Window of 1: negation must be within 1 intervening word of the target.\n      // Exclude possessive: \"never Claude's X\" negates the NP, not \"Claude\".\n      const pattern = new RegExp(\n        `\\\\b${neg}\\\\b(?:\\\\s+\\\\w+){0,1}\\\\s+\\\\b${escapedWord}\\\\b(?!['\\\\u2019]s\\\\b)`,\n        \"i\",\n      );\n      if (pattern.test(lower)) return true;\n    }\n\n    // \"do not\" / \"not\" before word (within 1 token), same possessive exclusion\n    const notPattern = new RegExp(\n      `\\\\b(?:do\\\\s+)?not\\\\b(?:\\\\s+\\\\w+){0,1}\\\\s+\\\\b${escapedWord}\\\\b(?!['\\\\u2019]s\\\\b)`,\n      \"i\",\n    );\n    if (notPattern.test(lower)) return true;\n  }\n\n  // CJK path: whole-sentence negation.\n  // Chinese imperatives (禁止/不要/…) typically appear sentence-initially and\n  // negate the entire clause — no word-boundary or window needed.\n  if (CJK_ONLY_RE.test(word)) {\n    for (const sentence of sentences) {\n      if (!sentence.includes(word)) continue;\n      for (const neg of CJK_NEGATIONS) {\n        if (sentence.includes(neg)) return true;\n      }\n    }\n  }\n\n  return false;\n}\n\n// ─── Helpers ───────────────────────────────────────────────────────────────────\n\n/**\n * Extra stop words specific to contradiction detection.\n * These are polarity markers and generic imperatives/modals that appear across\n * many rule lines and would generate false-positive shared-word matches.\n */\nconst POLARITY_STOP_WORDS = new Set([\n  // Polarity / negation markers (meta-level, not domain content)\n  \"never\",\n  \"always\",\n  \"avoid\",\n  \"not\",\n  // Generic imperative verbs (describe HOW to comply, not WHAT topic)\n  \"use\",\n  \"ensure\",\n  \"require\",\n  \"prefer\",\n  \"follow\",\n  \"keep\",\n  \"calls\",\n  \"run\",\n  \"runs\",\n  // Common modals and auxiliaries\n  \"must\",\n  \"should\",\n  \"can\",\n  \"will\",\n  \"may\",\n  // Generic quantifiers\n  \"all\",\n  \"every\",\n  \"each\",\n  \"any\",\n  // Pronouns and copulas — appear in any sentence regardless of topic;\n  // their negation carries no semantic domain information\n  \"it\",\n  \"its\",\n  \"be\",\n  \"by\",\n  \"own\",\n  \"on\",\n  // Chinese polarity / imperative bigrams (analogues of English never/always/use/must)\n  \"永遠\",\n  \"總是\",\n  \"禁止\",\n  \"不要\",\n  \"不可\",\n  \"不得\",\n  \"避免\",\n  \"請勿\",\n  \"必須\",\n  \"應該\",\n  \"應當\",\n  // Chinese generic verb bigrams (HOW to comply, not WHAT topic)\n  \"使用\",\n  \"採用\",\n  \"執行\",\n  \"進行\",\n  \"可以\",\n  \"需要\",\n]);\n\ninterface AnnotatedLine {\n  line: ParsedLine;\n  words: string[];\n  file: string;\n}\n\nfunction collectRuleLines(instructions: ParsedInstructions): AnnotatedLine[] {\n  const sources: InstructionFile[] = [\n    instructions.rootFile,\n    ...instructions.subFiles,\n    ...instructions.rules,\n  ];\n\n  const annotated: AnnotatedLine[] = [];\n  for (const file of sources) {\n    for (const line of file.lines) {\n      if (line.type !== \"rule\") continue;\n      const words = removeStopWords(tokenizeWords(line.text)).filter(\n        (w) => !POLARITY_STOP_WORDS.has(w),\n      );\n      if (words.length < 3) continue;\n      annotated.push({ line, words, file: file.path });\n    }\n  }\n  return annotated;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\nexport function detectContradictions(\n  instructions: ParsedInstructions,\n): Finding[] {\n  const lines = collectRuleLines(instructions);\n  const findings: Finding[] = [];\n  const reportedPairs = new Set<string>();\n\n  for (let i = 0; i < lines.length; i++) {\n    for (let j = i + 1; j < lines.length; j++) {\n      const a = lines[i]!;\n      const b = lines[j]!;\n\n      // Find unique shared content words (Set-based to avoid duplicate counting)\n      const setA = new Set(a.words);\n      const setB = new Set(b.words);\n      const shared = [...setB].filter((w) => setA.has(w));\n\n      if (shared.length < 3) continue;\n\n      // Check if any shared word has opposite polarity in the two lines\n      const hasContradiction = shared.some(\n        (word) => isNegated(a.line.text, word) !== isNegated(b.line.text, word),\n      );\n\n      if (!hasContradiction) continue;\n\n      const pairKey = `${a.file}:${a.line.lineNumber}|${b.file}:${b.line.lineNumber}`;\n      if (reportedPairs.has(pairKey)) continue;\n      reportedPairs.add(pairKey);\n\n      const snippet =\n        a.line.text.length > 60\n          ? `${a.line.text.slice(0, 60)}...`\n          : a.line.text;\n\n      findings.push({\n        severity: \"critical\",\n        category: \"contradiction\",\n        file: b.file,\n        line: b.line.lineNumber,\n        messageKey: \"structure.contradiction\",\n        messageParams: {\n          snippet,\n          lineA: String(a.line.lineNumber),\n          lineB: String(b.line.lineNumber),\n          fileA: a.file,\n        },\n        suggestion: `Contradicting rules: \"${snippet}\" (${a.file} line ${a.line.lineNumber}) conflicts with line ${b.line.lineNumber}.`,\n        autoFixable: false,\n      });\n    }\n  }\n\n  return findings;\n}\n","import { existsSync } from 'fs';\nimport { join } from 'path';\nimport type { Finding, InstructionFile, ParsedInstructions, ParsedLine } from '../types.js';\n\n// ─── Helpers ───────────────────────────────────────────────────────────────────\n\ninterface AnnotatedLine {\n  line: ParsedLine;\n  file: string;\n}\n\nfunction collectLines(instructions: ParsedInstructions): AnnotatedLine[] {\n  const sources: InstructionFile[] = [\n    instructions.rootFile,\n    ...instructions.subFiles,\n    ...instructions.rules,\n  ];\n\n  const result: AnnotatedLine[] = [];\n  for (const file of sources) {\n    for (const line of file.lines) {\n      if (line.type === 'blank' || line.type === 'code') continue;\n      if (line.referencedPaths.length === 0) continue;\n      result.push({ line, file: file.path });\n    }\n  }\n  return result;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\nexport function detectStaleRefs(\n  instructions: ParsedInstructions,\n  projectRoot: string,\n): Finding[] {\n  const findings: Finding[] = [];\n\n  for (const { line, file } of collectLines(instructions)) {\n    for (const refPath of line.referencedPaths) {\n      // Skip directory refs (trailing slash) and glob patterns\n      if (refPath.endsWith('/') || refPath.includes('*')) continue;\n\n      const absolutePath = join(projectRoot, refPath);\n      if (!existsSync(absolutePath)) {\n        findings.push({\n          severity: 'warning',\n          category: 'stale-ref',\n          file,\n          line: line.lineNumber,\n          messageKey: 'structure.staleRef',\n          messageParams: { path: refPath },\n          suggestion: `Stale reference: \"${refPath}\" does not exist.`,\n          autoFixable: true,\n        });\n      }\n    }\n  }\n\n  return findings;\n}\n","import type { Finding, ParsedInstructions } from \"../types.js\";\n\n// ─── Patterns ─────────────────────────────────────────────────────────────────\n\n/** Rule references a specific source directory → suggest a path-scoped rule file */\nconst PATH_REF_PATTERN = /\\b(?:src|tests?|lib|dist)\\//i;\n\n/** Rule forbids a git workflow action → suggest a git hook instead */\nconst HOOK_PATTERN =\n  /\\b(?:never|don't|do\\s+not|forbid)\\b(?:\\s+\\w+){0,3}\\s+\\b(?:commit|push|merge|rebase|tag|checkout|amend)\\b/i;\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\nexport function classifyScope(instructions: ParsedInstructions): Finding[] {\n  const findings: Finding[] = [];\n  const rootFile = instructions.rootFile;\n\n  for (const line of rootFile.lines) {\n    if (line.type !== \"rule\") continue;\n\n    if (HOOK_PATTERN.test(line.text)) {\n      const snippet =\n        line.text.length > 60 ? `${line.text.slice(0, 60)}...` : line.text;\n      findings.push({\n        severity: \"info\",\n        category: \"structure\",\n        file: rootFile.path,\n        line: line.lineNumber,\n        messageKey: \"structure.scopeHook\",\n        messageParams: { line: String(line.lineNumber), snippet },\n        suggestion: `Rule at line ${line.lineNumber} could be a git hook: \"${snippet}\"`,\n        autoFixable: false,\n      });\n      // Don't also emit path-scoped suggestion for the same line\n      continue;\n    }\n\n    if (PATH_REF_PATTERN.test(line.text)) {\n      const snippet =\n        line.text.length > 60 ? `${line.text.slice(0, 60)}...` : line.text;\n      findings.push({\n        severity: \"info\",\n        category: \"structure\",\n        file: rootFile.path,\n        line: line.lineNumber,\n        messageKey: \"structure.scopePathScoped\",\n        messageParams: { line: String(line.lineNumber), snippet },\n        suggestion: `Rule at line ${line.lineNumber} references a specific path — consider a path-scoped rule file: \"${snippet}\"`,\n        autoFixable: false,\n      });\n    }\n  }\n\n  return findings;\n}\n","import { detectContradictions } from \"../detectors/contradiction.js\";\nimport { detectStaleRefs } from \"../detectors/stale-refs.js\";\nimport { classifyScope } from \"../detectors/scope-classifier.js\";\nimport type { Finding, ParsedInstructions } from \"../types.js\";\n\ninterface StructureResult {\n  findings: Finding[];\n}\n\nexport function analyzeStructure(\n  instructions: ParsedInstructions,\n  projectRoot: string,\n): StructureResult {\n  return {\n    findings: [\n      ...detectContradictions(instructions),\n      ...detectStaleRefs(instructions, projectRoot),\n      ...classifyScope(instructions),\n    ],\n  };\n}\n","import type { ActionItem, BudgetSummary, Finding } from \"../types.js\";\n\ntype Grade = \"A\" | \"B\" | \"C\" | \"D\" | \"F\";\n\nconst CONTEXT_WINDOW = 200_000;\n\n// ─── Scoring weights ───────────────────────────────────────────────────────────\n\nconst CRITICAL_DEDUCTION = 10;\nconst WARNING_DEDUCTION = 5;\nconst INFO_DEDUCTION = 1;\n\nconst MAX_CRITICAL_DEDUCTION = 40;\nconst MAX_WARNING_DEDUCTION = 30;\nconst MAX_INFO_DEDUCTION = 10;\nconst MAX_ROOT_FILE_PENALTY = 30;\nconst MAX_BUDGET_DEDUCTION = 30;\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\nexport function gradeFromScore(score: number): Grade {\n  if (score >= 90) return \"A\";\n  if (score >= 80) return \"B\";\n  if (score >= 70) return \"C\";\n  if (score >= 60) return \"D\";\n  return \"F\";\n}\n\nexport function calculateScore(\n  findings: Finding[],\n  budget: BudgetSummary,\n): { score: number; grade: Grade } {\n  const criticals = findings.filter((f) => f.severity === \"critical\").length;\n  const warnings = findings.filter((f) => f.severity === \"warning\").length;\n  const infos = findings.filter((f) => f.severity === \"info\").length;\n\n  const criticalDeduction = Math.min(\n    criticals * CRITICAL_DEDUCTION,\n    MAX_CRITICAL_DEDUCTION,\n  );\n  const warningDeduction = Math.min(\n    warnings * WARNING_DEDUCTION,\n    MAX_WARNING_DEDUCTION,\n  );\n  const infoDeduction = Math.min(infos * INFO_DEDUCTION, MAX_INFO_DEDUCTION);\n\n  // Root file length penalty — proportional beyond each threshold\n  // 201-300: -5, 301-400: -8, 401-500: -10, 501-600: -15, 601-700: -20, ...\n  const rootLines = budget.rootFileLines;\n  let rootFilePenalty = 0;\n  if (rootLines > 400) {\n    rootFilePenalty = 10 + Math.floor((rootLines - 400) / 100) * 5;\n  } else if (rootLines > 200) {\n    rootFilePenalty = 5 + Math.floor((rootLines - 200) / 100) * 3;\n  }\n  rootFilePenalty = Math.min(rootFilePenalty, MAX_ROOT_FILE_PENALTY);\n\n  // Budget penalty — continuous beyond 25% of context window\n  // 25%: -5, 50%: -15, 75%: -25, capped at 30\n  const baselinePct = budget.totalBaseline / CONTEXT_WINDOW;\n  let budgetDeduction = 0;\n  if (baselinePct > 0.25) {\n    budgetDeduction = 5 + Math.floor((baselinePct - 0.25) * 40);\n  }\n  budgetDeduction = Math.min(budgetDeduction, MAX_BUDGET_DEDUCTION);\n\n  const score = Math.max(\n    0,\n    100 -\n      criticalDeduction -\n      warningDeduction -\n      infoDeduction -\n      rootFilePenalty -\n      budgetDeduction,\n  );\n  return { score, grade: gradeFromScore(score) };\n}\n\nexport function buildActionPlan(findings: Finding[]): ActionItem[] {\n  const priorityOf = (f: Finding): number => {\n    if (f.severity === \"critical\") return 1;\n    if (f.severity === \"warning\") return 2;\n    return 3;\n  };\n\n  const seen = new Set<string>();\n  return findings\n    .filter((f) => {\n      if (seen.has(f.suggestion)) return false;\n      seen.add(f.suggestion);\n      return true;\n    })\n    .map((f) => ({\n      priority: priorityOf(f),\n      description: f.suggestion,\n      category: f.category,\n    }))\n    .sort((a, b) => a.priority - b.priority);\n}\n","import chalk from \"chalk\";\nimport type { BudgetSummary, Finding, HealthReport } from \"../types.js\";\nimport { bar } from \"../commands/budget-command.js\";\nimport { t, plural, getLocale } from \"../i18n/index.js\";\n\n// ─── Visual helpers ───────────────────────────────────────────────────────────\n\nconst BOX_W = 50;\nconst ANSI_RE = /\\x1b\\[[0-9;]*m/g;\n\nfunction visLen(s: string): number {\n  return s.replace(ANSI_RE, \"\").length;\n}\n\nfunction padR(s: string, w: number): string {\n  return s + \" \".repeat(Math.max(0, w - visLen(s)));\n}\n\nfunction gradeColor(grade: string): (s: string) => string {\n  if (grade === \"A\") return chalk.green;\n  if (grade === \"B\") return chalk.cyan;\n  if (grade === \"C\") return chalk.yellow;\n  if (grade === \"D\") return chalk.magenta;\n  return chalk.red;\n}\n\nfunction gradeBadge(grade: string): string {\n  // Light backgrounds (A/B/C) need dark text; dark backgrounds (D/F) need white text\n  if (grade === \"A\") return chalk.bgGreen(chalk.bold.black(` ${grade} `));\n  if (grade === \"B\") return chalk.bgCyan(chalk.bold.black(` ${grade} `));\n  if (grade === \"C\") return chalk.bgYellow(chalk.bold.black(` ${grade} `));\n  if (grade === \"D\") return chalk.bgMagenta(chalk.bold.white(` ${grade} `));\n  return chalk.bgRed(chalk.bold.white(` ${grade} `));\n}\n\nfunction scoreBar(score: number, grade: string, width = 30): string {\n  const filled = Math.round((score / 100) * width);\n  const empty = width - filled;\n  return gradeColor(grade)(\"█\".repeat(filled)) + chalk.gray(\"░\".repeat(empty));\n}\n\nfunction sectionHeader(title: string, width = BOX_W): string {\n  const inner = ` ${title} `;\n  const remaining = Math.max(0, width - 2 - inner.length);\n  return chalk.gray(`  ──${chalk.bold.white(inner)}${\"─\".repeat(remaining)}──`);\n}\n\n// ─── Compact helpers ───────────────────────────────────────────────────────────\n\nfunction printCompactBudget(\n  summary: BudgetSummary,\n  output: { log: typeof console.log },\n): void {\n  const total = summary.totalBaseline;\n  const window = total + summary.availableTokens;\n  const fraction = total / window;\n  const fmt = new Intl.NumberFormat(getLocale());\n  const usedPrefix = summary.tokenMethod === \"estimated\" ? \"~\" : \"\";\n  const budgetLine = t(\"compact.budgetLine\", {\n    used: `${usedPrefix}${fmt.format(total)}`,\n    window: fmt.format(window),\n    pct: String(Math.round(fraction * 100)),\n  });\n  output.log(`  ${chalk.yellow(budgetLine)}  ${bar(fraction, 14)}`);\n}\n\nconst SEVERITY_ORDER: Record<string, number> = {\n  critical: 0,\n  warning: 1,\n  info: 2,\n};\n\nfunction printFindingsTable(\n  findings: Finding[],\n  output: { log: typeof console.log },\n): void {\n  const categories: Array<{ key: string; label: string }> = [\n    { key: \"contradiction\", label: t(\"compact.contradictions\") },\n    { key: \"budget\", label: t(\"compact.budget\") },\n    { key: \"dead-rule\", label: t(\"compact.deadRules\") },\n    { key: \"duplicate\", label: t(\"compact.duplicates\") },\n    { key: \"stale-ref\", label: t(\"compact.staleRefs\") },\n    { key: \"structure\", label: t(\"compact.structure\") },\n  ];\n\n  const rows = categories\n    .map(({ key, label }) => {\n      const group = findings.filter((f) => f.category === key);\n      return {\n        label,\n        critical: group.filter((f) => f.severity === \"critical\").length,\n        warning: group.filter((f) => f.severity === \"warning\").length,\n        info: group.filter((f) => f.severity === \"info\").length,\n      };\n    })\n    .filter((r) => r.critical + r.warning + r.info > 0);\n\n  if (rows.length === 0) return;\n\n  output.log(sectionHeader(t(\"label.findings\")));\n  for (const row of rows) {\n    const parts: string[] = [];\n    if (row.critical > 0) parts.push(chalk.red(`✖ ${row.critical}`));\n    if (row.warning > 0) parts.push(chalk.yellow(`⚠ ${row.warning}`));\n    if (row.info > 0) parts.push(chalk.blue(`ℹ ${row.info}`));\n    output.log(\n      `  ${chalk.whiteBright(row.label.padEnd(18))}${parts.join(\"  \")}`,\n    );\n  }\n}\n\nfunction printTopIssues(\n  findings: Finding[],\n  output: { log: typeof console.log },\n): void {\n  if (findings.length === 0) return;\n\n  const sorted = [...findings].sort(\n    (a, b) =>\n      (SEVERITY_ORDER[a.severity] ?? 3) - (SEVERITY_ORDER[b.severity] ?? 3),\n  );\n  const top = sorted.slice(0, 5);\n\n  output.log(\"\");\n  output.log(sectionHeader(t(\"label.topIssues\")));\n  for (let i = 0; i < top.length; i++) {\n    const f = top[i]!;\n    const icon =\n      f.severity === \"critical\"\n        ? chalk.red(\"✖\")\n        : f.severity === \"warning\"\n          ? chalk.yellow(\"⚠\")\n          : chalk.blue(\"ℹ\");\n    const msg = t(f.messageKey, f.messageParams);\n    const truncated = msg.length > 68 ? `${msg.slice(0, 68)}…` : msg;\n    const verifyBadge =\n      f.verification?.verdict === \"confirmed\"\n        ? chalk.green(` ✓ ${t(\"verification.confirmed\")}`)\n        : f.verification?.verdict === \"uncertain\"\n          ? chalk.yellow(` ❓ ${t(\"verification.uncertain\")}`)\n          : \"\";\n    output.log(\n      `  ${chalk.white(`${i + 1}.`)} ${icon}  ${truncated}${verifyBadge}`,\n    );\n  }\n  if (sorted.length > 5) {\n    output.log(\n      chalk.white(\n        `     ${t(\"compact.andMore\", { count: String(sorted.length - 5) })}`,\n      ),\n    );\n  }\n}\n\n// ─── Terminal reporter ─────────────────────────────────────────────────────────\n\nexport function printCombinedTerminal(\n  report: HealthReport,\n  output: { log: typeof console.log } = console,\n): void {\n  const { project, tool, score, grade, tokenMethod } = report;\n  const border = \"─\".repeat(BOX_W);\n\n  // ─── Header box ─────────────────────────────────────────────────────────────\n  output.log(\"\");\n  const B = chalk.green; // box border colour — use consistently\n  output.log(B(`  ╭${border}╮`));\n  const line1 = `  ${chalk.bold.white(\"instrlint\")}  ${B(\"─\")}  ${chalk.cyan(project)}`;\n  output.log(`  ${B(\"│\")}${padR(line1, BOX_W)}${B(\"│\")}`);\n  const line2 = `  ${chalk.white(tool)}  ${B(\"·\")}  ${chalk.white(tokenMethod)}`;\n  output.log(`  ${B(\"│\")}${padR(line2, BOX_W)}${B(\"│\")}`);\n  output.log(B(`  ├${border}┤`));\n  const scoreLine = `  ${scoreBar(score, grade)}  ${chalk.bold.white(String(score))}/100  ${gradeBadge(grade)}`;\n  output.log(`  ${B(\"│\")}${padR(scoreLine, BOX_W)}${B(\"│\")}`);\n  output.log(B(`  ╰${border}╯`));\n\n  // ─── Budget ─────────────────────────────────────────────────────────────────\n  output.log(\"\");\n  output.log(sectionHeader(t(\"label.budget\")));\n  printCompactBudget(report.budget, output);\n\n  // ─── Findings ───────────────────────────────────────────────────────────────\n  if (report.findings.length > 0) {\n    output.log(\"\");\n    printFindingsTable(report.findings, output);\n    printTopIssues(report.findings, output);\n  }\n\n  // ─── Footer ─────────────────────────────────────────────────────────────────\n  output.log(\"\");\n  if (report.findings.length === 0) {\n    output.log(chalk.green(`  ${t(\"status.perfectScore\")}`));\n  } else {\n    const criticals = report.findings.filter(\n      (f) => f.severity === \"critical\",\n    ).length;\n    const warnings = report.findings.filter(\n      (f) => f.severity === \"warning\",\n    ).length;\n    const infos = report.findings.filter((f) => f.severity === \"info\").length;\n    const parts: string[] = [];\n    if (criticals > 0)\n      parts.push(\n        chalk.red(t(\"severity.critical\", { count: String(criticals) })),\n      );\n    if (warnings > 0)\n      parts.push(\n        chalk.yellow(\n          t(\"severity.warnings\", {\n            count: String(warnings),\n            s: plural(warnings),\n          }),\n        ),\n      );\n    if (infos > 0)\n      parts.push(\n        chalk.blue(\n          t(\"severity.suggestions\", { count: String(infos), s: plural(infos) }),\n        ),\n      );\n    const summary = parts.join(chalk.gray(\" · \"));\n    const summaryVisible = summary.replace(ANSI_RE, \"\");\n    const pad = Math.max(0, BOX_W - 2 - summaryVisible.length);\n    output.log(\n      chalk.gray(`  ──`) + ` ${summary} ` + chalk.gray(\"─\".repeat(pad)),\n    );\n  }\n  if (report.rejectedByVerification) {\n    output.log(\n      chalk.gray(\n        `  ${t(\"verification.filteredCount\", { count: String(report.rejectedByVerification), s: plural(report.rejectedByVerification) })}`,\n      ),\n    );\n  }\n  output.log(\"\");\n}\n\n// ─── JSON reporter ─────────────────────────────────────────────────────────────\n\nexport function reportJson(report: HealthReport): string {\n  return JSON.stringify(report, null, 2);\n}\n\n// ─── Markdown reporter ─────────────────────────────────────────────────────────\n\nfunction mdSeverityIcon(f: Finding): string {\n  if (f.severity === \"critical\") return \"🔴\";\n  if (f.severity === \"warning\") return \"🟡\";\n  return \"ℹ️\";\n}\n\nfunction mdBar(fraction: number, width = 20): string {\n  const filled = Math.round(Math.min(1, Math.max(0, fraction)) * width);\n  const empty = width - filled;\n  return \"`\" + \"█\".repeat(filled) + \"░\".repeat(empty) + \"`\";\n}\n\nfunction mdFormatTokens(\n  count: number,\n  method: \"measured\" | \"estimated\",\n): string {\n  const fmt = new Intl.NumberFormat(getLocale());\n  return method === \"estimated\" ? `~${fmt.format(count)}` : fmt.format(count);\n}\n\nexport function reportMarkdown(\n  report: HealthReport,\n  extraSections: string[] = [],\n): string {\n  const { project, tool, score, grade, findings, budget } = report;\n  const criticals = findings.filter((f) => f.severity === \"critical\").length;\n  const warnings = findings.filter((f) => f.severity === \"warning\").length;\n  const infos = findings.filter((f) => f.severity === \"info\").length;\n  const gradeEmoji =\n    grade === \"A\"\n      ? \"🟢\"\n      : grade === \"B\"\n        ? \"🔵\"\n        : grade === \"C\"\n          ? \"🟡\"\n          : grade === \"D\"\n            ? \"🟠\"\n            : \"🔴\";\n\n  const lines: string[] = [\n    `# ${t(\"markdown.title\", { project })}`,\n    \"\",\n    `${gradeEmoji} **${score}/100 (${grade})** ${mdBar(score / 100, 25)} · \\`${tool}\\``,\n    \"\",\n    t(\"markdown.summary\"),\n    \"\",\n    `| ${t(\"markdown.severity\")} | ${t(\"markdown.count\")} |`,\n    \"|----------|-------|\",\n    `| ${t(\"markdown.critical\")} | ${criticals} |`,\n    `| ${t(\"markdown.warning\")} | ${warnings} |`,\n    `| ${t(\"markdown.info\")} | ${infos} |`,\n    ...(report.rejectedByVerification\n      ? [\n          `| ${t(\"verification.filteredCount\", { count: String(report.rejectedByVerification), s: plural(report.rejectedByVerification) })} | |`,\n        ]\n      : []),\n    \"\",\n  ];\n\n  // ── Budget breakdown ─────────────────────────────────────────────────────\n  const window = budget.totalBaseline + budget.availableTokens;\n  const budgetRows: Array<{\n    labelKey: string;\n    tokens: number;\n    method: \"measured\" | \"estimated\";\n  }> = [\n    {\n      labelKey: \"label.systemPrompt\",\n      tokens: budget.systemPromptTokens,\n      method: \"estimated\" as const,\n    },\n    {\n      labelKey: \"label.rootFile\",\n      tokens: budget.rootFileTokens,\n      method: budget.rootFileMethod,\n    },\n    {\n      labelKey: \"label.ruleFiles\",\n      tokens: budget.rulesTokens,\n      method: budget.rulesMethod,\n    },\n    {\n      labelKey: \"label.skillFiles\",\n      tokens: budget.skillsTokens,\n      method: budget.skillsMethod,\n    },\n    {\n      labelKey: \"label.subDirFiles\",\n      tokens: budget.subFilesTokens,\n      method: budget.subFilesMethod,\n    },\n    {\n      labelKey: \"label.mcpServers\",\n      tokens: budget.mcpTokens,\n      method: \"estimated\" as const,\n    },\n  ].filter((r) => r.tokens > 0);\n\n  lines.push(`## ${t(\"label.tokenBudget\")}`, \"\");\n  lines.push(\n    `| ${t(\"markdown.budgetCategory\")} | ${t(\"markdown.budgetTokens\")} | % | |`,\n    \"|------|--------|---|---|\",\n  );\n  for (const row of budgetRows) {\n    const pctVal = Math.round((row.tokens / window) * 100);\n    lines.push(\n      `| ${t(row.labelKey)} | ${mdFormatTokens(row.tokens, row.method)} | ${pctVal}% | ${mdBar(row.tokens / window, 12)} |`,\n    );\n  }\n  const baselinePct = Math.round((budget.totalBaseline / window) * 100);\n  lines.push(\n    `| **${t(\"label.baselineTotal\")}** | **${mdFormatTokens(budget.totalBaseline, budget.tokenMethod)}** | **${baselinePct}%** | ${mdBar(budget.totalBaseline / window, 12)} |`,\n  );\n  lines.push(\n    `| ${t(\"label.available\")} | ${mdFormatTokens(budget.availableTokens, \"estimated\")} | ${100 - baselinePct}% | |`,\n  );\n  lines.push(\"\");\n\n  // Findings grouped by category\n  const categories: Array<{\n    labelKey: string;\n    filter: (f: Finding) => boolean;\n  }> = [\n    {\n      labelKey: \"markdown.contradictions\",\n      filter: (f) => f.category === \"contradiction\",\n    },\n    {\n      labelKey: \"markdown.staleReferences\",\n      filter: (f) => f.category === \"stale-ref\",\n    },\n    {\n      labelKey: \"markdown.deadRules\",\n      filter: (f) => f.category === \"dead-rule\",\n    },\n    {\n      labelKey: \"markdown.duplicateRules\",\n      filter: (f) => f.category === \"duplicate\",\n    },\n    {\n      labelKey: \"markdown.budgetIssues\",\n      filter: (f) => f.category === \"budget\",\n    },\n    {\n      labelKey: \"markdown.refactoringOpportunities\",\n      filter: (f) => f.category === \"structure\",\n    },\n  ];\n\n  for (const { labelKey, filter } of categories) {\n    const group = findings.filter(filter);\n    if (group.length === 0) continue;\n    lines.push(`## ${t(labelKey)}`, \"\");\n    for (const f of group) {\n      const loc =\n        f.line != null\n          ? ` ${t(\"markdown.lineRef\", { line: String(f.line) })}`\n          : \"\";\n      const verifyBadge =\n        f.verification?.verdict === \"confirmed\"\n          ? ` ✓ *${t(\"verification.confirmed\")}*: ${f.verification.reason}`\n          : f.verification?.verdict === \"uncertain\"\n            ? ` ❓ *${t(\"verification.uncertain\")}*: ${f.verification.reason}`\n            : \"\";\n      lines.push(\n        `- ${mdSeverityIcon(f)} ${t(f.messageKey, f.messageParams)}${loc}${verifyBadge}`,\n      );\n    }\n    lines.push(\"\");\n  }\n\n  // Action plan\n  if (report.actionPlan.length > 0) {\n    lines.push(t(\"markdown.actionPlan\"), \"\");\n    for (let i = 0; i < Math.min(report.actionPlan.length, 10); i++) {\n      const item = report.actionPlan[i]!;\n      lines.push(`${i + 1}. ${item.description}`);\n    }\n    lines.push(\"\");\n  }\n\n  // Extra sections (e.g. actionable structure suggestions)\n  if (extraSections.length > 0) {\n    lines.push(...extraSections);\n  }\n\n  lines.push(\"---\", t(\"markdown.attribution\"));\n  return lines.join(\"\\n\");\n}\n","import chalk from \"chalk\";\nimport { scanProject } from \"../core/scanner.js\";\nimport { loadProject } from \"../adapters/dispatch.js\";\nimport { ensureInitialized } from \"../detectors/token-estimator.js\";\nimport { analyzeBudget } from \"../analyzers/budget.js\";\nimport { t, initLocale, getLocale } from \"../i18n/index.js\";\nimport type { BudgetSummary, Finding, TokenMethod } from \"../types.js\";\n\n// ─── Formatting helpers ────────────────────────────────────────────────────\n\nfunction getFmt(): Intl.NumberFormat {\n  return new Intl.NumberFormat(getLocale());\n}\n\nexport function formatTokens(count: number, method: TokenMethod): string {\n  const formatted = getFmt().format(count);\n  if (method === \"measured\") return t(\"tokens.measured\", { count: formatted });\n  return t(\"tokens.estimated\", { count: formatted });\n}\n\nexport function bar(fraction: number, width = 24): string {\n  const filled = Math.round(Math.min(1, Math.max(0, fraction)) * width);\n  const empty = width - filled;\n  return chalk.cyan(\"█\".repeat(filled)) + chalk.gray(\"░\".repeat(empty));\n}\n\nexport function pct(fraction: number): string {\n  return `${Math.round(fraction * 100)}%`;\n}\n\n// ─── Budget terminal output ────────────────────────────────────────────────\n\nexport function printBudgetTerminal(\n  summary: BudgetSummary,\n  findings: Finding[],\n  output: { log: typeof console.log } = console,\n): void {\n  const total = summary.totalBaseline;\n  const window = total + summary.availableTokens;\n\n  output.log(\"\");\n  output.log(chalk.bold.white(`  ${t(\"label.tokenBudget\")}`));\n  output.log(chalk.gray(\"  ─\".repeat(30)));\n\n  const rows: Array<{ labelKey: string; tokens: number; method: TokenMethod }> =\n    [\n      {\n        labelKey: \"label.systemPrompt\",\n        tokens: summary.systemPromptTokens,\n        method: \"estimated\",\n      },\n      {\n        labelKey: \"label.rootFile\",\n        tokens: summary.rootFileTokens,\n        method: summary.rootFileMethod,\n      },\n      {\n        labelKey: \"label.ruleFiles\",\n        tokens: summary.rulesTokens,\n        method: summary.rulesMethod,\n      },\n      {\n        labelKey: \"label.skillFiles\",\n        tokens: summary.skillsTokens,\n        method: summary.skillsMethod,\n      },\n      {\n        labelKey: \"label.subDirFiles\",\n        tokens: summary.subFilesTokens,\n        method: summary.subFilesMethod,\n      },\n      {\n        labelKey: \"label.mcpServers\",\n        tokens: summary.mcpTokens,\n        method: \"estimated\",\n      },\n    ];\n\n  for (const row of rows) {\n    if (row.tokens === 0) continue;\n    const fraction = row.tokens / window;\n    const label = t(row.labelKey).padEnd(14);\n    const tokenStr = formatTokens(row.tokens, row.method).padStart(28);\n    output.log(\n      `  ${chalk.white(label)} ${bar(fraction)}  ${chalk.yellow(tokenStr)}`,\n    );\n  }\n\n  output.log(chalk.gray(\"  ─\".repeat(30)));\n\n  const baselineFraction = total / window;\n  const baselineStr = formatTokens(total, summary.tokenMethod).padStart(28);\n  output.log(\n    `  ${t(\"label.baselineTotal\").padEnd(14)} ${bar(baselineFraction)}  ${chalk.bold.yellow(baselineStr)}  ${chalk.gray(pct(baselineFraction))}`,\n  );\n\n  const availStr = formatTokens(summary.availableTokens, \"estimated\").padStart(\n    28,\n  );\n  output.log(\n    `  ${t(\"label.available\").padEnd(14)} ${\"\".padEnd(26)}  ${chalk.green(availStr)}`,\n  );\n  output.log(\"\");\n\n  if (findings.length === 0) {\n    output.log(chalk.green(`  ${t(\"status.noBudgetIssues\")}`));\n  } else {\n    for (const f of findings) {\n      const icon =\n        f.severity === \"critical\"\n          ? chalk.red(\"  ✖\")\n          : f.severity === \"warning\"\n            ? chalk.yellow(\"  ⚠\")\n            : chalk.blue(\"  ℹ\");\n      output.log(`${icon}  ${t(f.messageKey, f.messageParams)}`);\n    }\n  }\n  output.log(\"\");\n}\n\n// ─── Core run logic (testable) ─────────────────────────────────────────────\n\ninterface BudgetCommandOpts {\n  format: string;\n  tool?: string;\n  lang?: string;\n  projectRoot?: string;\n}\n\ninterface BudgetCommandResult {\n  exitCode: number;\n  errorMessage?: string;\n}\n\nexport async function runBudget(\n  opts: BudgetCommandOpts,\n  output: { log: typeof console.log; error: typeof console.error } = console,\n): Promise<BudgetCommandResult> {\n  initLocale(opts.lang);\n  await ensureInitialized();\n\n  const projectRoot = opts.projectRoot ?? process.cwd();\n  const scan = scanProject(projectRoot, opts.tool);\n\n  if (scan.tool === \"unknown\") {\n    output.error(t(\"error.unknownTool\"));\n    return { exitCode: 1, errorMessage: \"unknown tool\" };\n  }\n\n  if (scan.rootFilePath === null) {\n    output.error(t(\"error.missingRootFile\", { tool: scan.tool }));\n    return { exitCode: 1, errorMessage: \"missing root file\" };\n  }\n\n  const instructions = loadProject(projectRoot, scan.tool);\n  const { findings, summary } = analyzeBudget(instructions);\n\n  if (opts.format === \"json\") {\n    output.log(JSON.stringify({ findings, summary }, null, 2));\n    return { exitCode: 0 };\n  }\n\n  printBudgetTerminal(summary, findings, output);\n  return { exitCode: 0 };\n}\n","{\n  \"label.tokenBudget\": \"TOKEN BUDGET\",\n  \"label.deadRules\": \"DEAD RULES\",\n  \"label.structure\": \"STRUCTURE\",\n  \"label.actionPlan\": \"ACTION PLAN\",\n  \"label.fixSummary\": \"FIX SUMMARY\",\n  \"label.systemPrompt\": \"System prompt\",\n  \"label.rootFile\": \"Root file\",\n  \"label.ruleFiles\": \"Rule files\",\n  \"label.skillFiles\": \"Skill files\",\n  \"label.subDirFiles\": \"Sub-dir files\",\n  \"label.mcpServers\": \"MCP servers\",\n  \"label.baselineTotal\": \"Baseline total\",\n  \"label.available\": \"Available\",\n  \"label.redundantByConfig\": \"Redundant (enforced by config)\",\n  \"label.duplicates\": \"Duplicates\",\n  \"label.contradictions\": \"Contradictions\",\n  \"label.staleReferences\": \"Stale References\",\n  \"label.refactoringOpportunities\": \"Refactoring Opportunities\",\n  \"label.tool\": \"Tool:\",\n  \"label.score\": \"Score:\",\n\n  \"status.noBudgetIssues\": \"✓ No budget issues found\",\n  \"status.noDeadRules\": \"✓ No dead rules found\",\n  \"status.noStructuralIssues\": \"✓ No structural issues found\",\n  \"status.noAutoFixable\": \"✓ No auto-fixable issues found\",\n  \"status.perfectScore\": \"✓ Perfect score — no issues found\",\n  \"status.fixedIssues\": \"✓ Fixed {{count}} issue{{s}} — run `git diff` to review changes\",\n\n  \"error.unknownTool\": \"No agent instruction files found. Run this command in a project that uses Claude Code, Codex, or Cursor.\",\n  \"error.missingRootFile\": \"Found {{tool}} configuration but no root instruction file.\",\n  \"error.dirtyWorkingTree\": \"Working tree is dirty. Commit or stash your changes before running --fix, or use --force to skip this check.\",\n\n  \"fix.removedDeadRules\": \"Removed {{count}} redundant rule{{s}}\",\n  \"fix.removedStaleRefs\": \"Removed {{count}} stale reference{{s}}\",\n  \"fix.removedDuplicates\": \"Removed {{count}} exact duplicate{{s}}\",\n\n  \"summary.redundantRules\": \"{{count}} redundant rule{{s}}\",\n  \"summary.duplicates\": \"{{count}} duplicate{{s}}\",\n  \"summary.contradictions\": \"{{count}} contradiction{{s}}\",\n  \"summary.staleRefs\": \"{{count}} stale ref{{s}}\",\n  \"summary.refactoringSuggestions\": \"{{count}} refactoring suggestion{{s}}\",\n  \"summary.found\": \"{{parts}} found\",\n\n  \"tokens.measured\": \"{{count}} tokens\",\n  \"tokens.estimated\": \"~{{count}} tokens (estimated)\",\n\n  \"actionPlan.andMore\": \"… and {{count}} more\",\n\n  \"severity.critical\": \"{{count}} critical\",\n  \"severity.warnings\": \"{{count}} warning{{s}}\",\n  \"severity.suggestions\": \"{{count}} suggestion{{s}}\",\n\n  \"budget.rootFileCritical\": \"Root instruction file is {{lines}} lines — agent compliance drops significantly above 200 lines\",\n  \"budget.rootFileWarning\": \"Root instruction file is {{lines}} lines (recommended: < 200)\",\n  \"budget.mcpLargeServer\": \"MCP server '{{name}}' consumes ~{{tokens}} tokens\",\n  \"budget.baselineHigh\": \"Baseline context consumption is {{pct}}% of window\",\n\n  \"deadRule.configOverlap\": \"Rule \\\"{{rule}}\\\" is already enforced by {{config}}\",\n  \"deadRule.exactDuplicate\": \"Exact duplicate of line {{otherLine}} in {{otherFile}}\",\n  \"deadRule.nearDuplicate\": \"Very similar to line {{otherLine}} in {{otherFile}} ({{similarity}}% similar)\",\n\n  \"structure.contradiction\": \"Contradicting rules: \\\"{{snippet}}\\\" ({{fileA}} line {{lineA}}) conflicts with line {{lineB}}.\",\n  \"structure.staleRef\": \"Stale reference: \\\"{{path}}\\\" does not exist.\",\n  \"structure.scopeHook\": \"Rule at line {{line}} could be a git hook: \\\"{{snippet}}\\\"\",\n  \"structure.scopePathScoped\": \"Rule at line {{line}} references a specific path — consider a path-scoped rule file: \\\"{{snippet}}\\\"\",\n\n  \"label.budget\": \"BUDGET\",\n  \"label.findings\": \"FINDINGS\",\n  \"label.topIssues\": \"TOP ISSUES\",\n  \"label.category\": \"Category\",\n\n  \"compact.budgetLine\": \"{{used}} / {{window}} tokens ({{pct}}%)\",\n  \"compact.andMore\": \"… and {{count}} more (run instrlint <command> for details)\",\n  \"compact.budget\": \"Budget\",\n  \"compact.deadRules\": \"Dead rules\",\n  \"compact.duplicates\": \"Duplicates\",\n  \"compact.contradictions\": \"Contradictions\",\n  \"compact.staleRefs\": \"Stale refs\",\n  \"compact.structure\": \"Structure\",\n\n  \"markdown.title\": \"instrlint Health Report — {{project}}\",\n  \"markdown.scoreLine\": \"**Score: {{score}}/100 ({{grade}})** · Tool: `{{tool}}`\",\n  \"markdown.summary\": \"## Summary\",\n  \"markdown.severity\": \"Severity\",\n  \"markdown.count\": \"Count\",\n  \"markdown.critical\": \"🔴 Critical\",\n  \"markdown.warning\": \"🟡 Warning\",\n  \"markdown.info\": \"ℹ️ Info\",\n  \"markdown.contradictions\": \"Contradictions\",\n  \"markdown.staleReferences\": \"Stale References\",\n  \"markdown.deadRules\": \"Dead Rules\",\n  \"markdown.duplicateRules\": \"Duplicates\",\n  \"markdown.budgetIssues\": \"Budget Issues\",\n  \"markdown.refactoringOpportunities\": \"Refactoring Opportunities\",\n  \"markdown.lineRef\": \"(line {{line}})\",\n  \"markdown.budgetCategory\": \"Category\",\n  \"markdown.budgetTokens\": \"Tokens\",\n  \"markdown.actionPlan\": \"## Action Plan\",\n  \"markdown.attribution\": \"*Generated by [instrlint](https://github.com/jed1978/instrlint)*\",\n\n  \"ci.passed\": \"✓ instrlint passed  score={{score}} grade={{grade}}\",\n  \"ci.failed\": \"✖ instrlint failed  score={{score}} grade={{grade}}\",\n  \"ci.writtenTo\": \"→ written to {{file}}\",\n\n  \"initCi.created\": \"✓ Created {{path}}\",\n  \"initCi.alreadyExists\": \"{{path}} already exists. Use --force to overwrite.\",\n\n  \"install.installed\": \"✓ Installed to {{path}}\\n  → Restart Claude Code to activate /instrlint\",\n  \"install.alreadyExists\": \"{{path}} already exists. Use --force to overwrite.\",\n  \"install.unknownTarget\": \"Specify --claude-code or --codex\",\n  \"install.outdatedTitle\": \"instrlint skill is outdated\",\n  \"install.outdatedVersions\": \"installed: {{installed}} → current: {{current}}\",\n  \"install.updateCmd\": \"npx instrlint install {{flag}} --force\",\n  \"install.updatePrompt\": \"Update skill now?\",\n\n  \"verification.confirmed\": \"LLM confirmed\",\n  \"verification.uncertain\": \"LLM uncertain\",\n  \"verification.filteredCount\": \"⊘ {{count}} false positive{{s}} filtered by LLM\",\n\n  \"fix.manualActions\": \"MANUAL ACTIONS NEEDED\",\n  \"fix.hookCreate\": \"Add to .claude/settings.json:\",\n  \"fix.hookWarning\": \"⚠ Hook executes shell commands — review carefully before adding\",\n  \"fix.pathScopedCreate\": \"Create {{path}}:\",\n  \"fix.thenRemoveLine\": \"Then remove line {{line}} from {{file}}\"\n}\n","{\n  \"label.tokenBudget\": \"TOKEN 預算\",\n  \"label.deadRules\": \"冗餘規則\",\n  \"label.structure\": \"結構分析\",\n  \"label.actionPlan\": \"行動計畫\",\n  \"label.fixSummary\": \"修復摘要\",\n  \"label.systemPrompt\": \"系統提示\",\n  \"label.rootFile\": \"根指令檔\",\n  \"label.ruleFiles\": \"規則檔\",\n  \"label.skillFiles\": \"技能檔\",\n  \"label.subDirFiles\": \"子目錄檔\",\n  \"label.mcpServers\": \"MCP 伺服器\",\n  \"label.baselineTotal\": \"初始總量\",\n  \"label.available\": \"可用\",\n  \"label.redundantByConfig\": \"冗餘（已由配置強制執行）\",\n  \"label.duplicates\": \"重複項目\",\n  \"label.contradictions\": \"規則矛盾\",\n  \"label.staleReferences\": \"過時參照\",\n  \"label.refactoringOpportunities\": \"重構建議\",\n  \"label.tool\": \"工具：\",\n  \"label.score\": \"分數：\",\n\n  \"status.noBudgetIssues\": \"✓ 無 Token 預算問題\",\n  \"status.noDeadRules\": \"✓ 無冗餘規則\",\n  \"status.noStructuralIssues\": \"✓ 無結構性問題\",\n  \"status.noAutoFixable\": \"✓ 無可自動修復的問題\",\n  \"status.perfectScore\": \"✓ 滿分 — 無任何問題\",\n  \"status.fixedIssues\": \"✓ 已修復 {{count}} 個問題 — 執行 `git diff` 查看變更\",\n\n  \"error.unknownTool\": \"找不到代理指令檔。請在使用 Claude Code、Codex 或 Cursor 的專案中執行此指令。\",\n  \"error.missingRootFile\": \"找到 {{tool}} 配置，但找不到根指令檔。\",\n  \"error.dirtyWorkingTree\": \"工作目錄有未提交的變更。請先提交或儲藏變更再執行 --fix，或使用 --force 跳過此檢查。\",\n\n  \"fix.removedDeadRules\": \"已移除 {{count}} 個冗餘規則\",\n  \"fix.removedStaleRefs\": \"已移除 {{count}} 個過時參照\",\n  \"fix.removedDuplicates\": \"已移除 {{count}} 個重複項目\",\n\n  \"summary.redundantRules\": \"{{count}} 個冗餘規則\",\n  \"summary.duplicates\": \"{{count}} 個重複項目\",\n  \"summary.contradictions\": \"{{count}} 個規則矛盾\",\n  \"summary.staleRefs\": \"{{count}} 個過時參照\",\n  \"summary.refactoringSuggestions\": \"{{count}} 個重構建議\",\n  \"summary.found\": \"發現 {{parts}}\",\n\n  \"tokens.measured\": \"{{count}} tokens\",\n  \"tokens.estimated\": \"~{{count}} tokens（估計值）\",\n\n  \"actionPlan.andMore\": \"… 還有 {{count}} 個\",\n\n  \"severity.critical\": \"{{count}} 個嚴重問題\",\n  \"severity.warnings\": \"{{count}} 個警告\",\n  \"severity.suggestions\": \"{{count}} 個建議\",\n\n  \"budget.rootFileCritical\": \"根指令檔有 {{lines}} 行 — 超過 200 行後代理遵循率顯著下降\",\n  \"budget.rootFileWarning\": \"根指令檔有 {{lines}} 行（建議：< 200 行）\",\n  \"budget.mcpLargeServer\": \"MCP 伺服器「{{name}}」消耗約 {{tokens}} tokens\",\n  \"budget.baselineHigh\": \"基線情境消耗佔視窗 {{pct}}%\",\n\n  \"deadRule.configOverlap\": \"規則「{{rule}}」已由 {{config}} 強制執行\",\n  \"deadRule.exactDuplicate\": \"與 {{otherFile}} 第 {{otherLine}} 行完全重複\",\n  \"deadRule.nearDuplicate\": \"與 {{otherFile}} 第 {{otherLine}} 行高度相似（{{similarity}}% 相似度）\",\n\n  \"structure.contradiction\": \"規則矛盾：「{{snippet}}」（{{fileA}} 第 {{lineA}} 行）與第 {{lineB}} 行衝突。\",\n  \"structure.staleRef\": \"過時參照：「{{path}}」不存在。\",\n  \"structure.scopeHook\": \"第 {{line}} 行的規則適合做成 git hook：「{{snippet}}」\",\n  \"structure.scopePathScoped\": \"第 {{line}} 行的規則參照了特定路徑 — 建議建立路徑範圍的規則檔：「{{snippet}}」\",\n\n  \"label.budget\": \"預算\",\n  \"label.findings\": \"問題總覽\",\n  \"label.topIssues\": \"首要問題\",\n  \"label.category\": \"Category\",\n\n  \"compact.budgetLine\": \"{{used}} / {{window}} tokens ({{pct}}%)\",\n  \"compact.andMore\": \"… 還有 {{count}} 個（執行 instrlint <command> 查看詳情）\",\n  \"compact.budget\": \"Budget\",\n  \"compact.deadRules\": \"Dead rules\",\n  \"compact.duplicates\": \"Duplicates\",\n  \"compact.contradictions\": \"Contradictions\",\n  \"compact.staleRefs\": \"Stale refs\",\n  \"compact.structure\": \"Structure\",\n\n  \"markdown.title\": \"instrlint 健康報告 — {{project}}\",\n  \"markdown.scoreLine\": \"**分數：{{score}}/100 ({{grade}})** · 工具：`{{tool}}`\",\n  \"markdown.summary\": \"## 摘要\",\n  \"markdown.severity\": \"嚴重程度\",\n  \"markdown.count\": \"數量\",\n  \"markdown.critical\": \"🔴 嚴重\",\n  \"markdown.warning\": \"🟡 警告\",\n  \"markdown.info\": \"ℹ️ 資訊\",\n  \"markdown.contradictions\": \"規則矛盾\",\n  \"markdown.staleReferences\": \"過時參照\",\n  \"markdown.deadRules\": \"冗餘規則\",\n  \"markdown.duplicateRules\": \"重複項目\",\n  \"markdown.budgetIssues\": \"Token 預算問題\",\n  \"markdown.refactoringOpportunities\": \"重構建議\",\n  \"markdown.lineRef\": \"（第 {{line}} 行）\",\n  \"markdown.budgetCategory\": \"類別\",\n  \"markdown.budgetTokens\": \"Token 數\",\n  \"markdown.actionPlan\": \"## 行動計畫\",\n  \"markdown.attribution\": \"*由 [instrlint](https://github.com/jed1978/instrlint) 生成*\",\n\n  \"ci.passed\": \"✓ instrlint 通過  分數={{score}} 等級={{grade}}\",\n  \"ci.failed\": \"✖ instrlint 未通過  分數={{score}} 等級={{grade}}\",\n  \"ci.writtenTo\": \"→ 已寫入 {{file}}\",\n\n  \"initCi.created\": \"✓ 已建立 {{path}}\",\n  \"initCi.alreadyExists\": \"{{path}} 已存在。使用 --force 覆蓋。\",\n\n  \"install.installed\": \"✓ 已安裝至 {{path}}\\n  → 重新啟動 Claude Code 後即可使用 /instrlint\",\n  \"install.alreadyExists\": \"{{path}} 已存在。使用 --force 覆蓋。\",\n  \"install.unknownTarget\": \"請指定 --claude-code 或 --codex\",\n  \"install.outdatedTitle\": \"instrlint skill 版本過舊\",\n  \"install.outdatedVersions\": \"已安裝：{{installed}} → 最新：{{current}}\",\n  \"install.updateCmd\": \"npx instrlint install {{flag}} --force\",\n  \"install.updatePrompt\": \"是否立即更新？\",\n\n  \"verification.confirmed\": \"LLM 已確認\",\n  \"verification.uncertain\": \"LLM 不確定\",\n  \"verification.filteredCount\": \"⊘ 已過濾 {{count}} 個{{s}} false positive（由 LLM 判斷）\",\n\n  \"fix.manualActions\": \"需要手動操作\",\n  \"fix.hookCreate\": \"加入 .claude/settings.json：\",\n  \"fix.hookWarning\": \"⚠ Hook 會執行 shell command，請仔細確認後再加入\",\n  \"fix.pathScopedCreate\": \"建立 {{path}}：\",\n  \"fix.thenRemoveLine\": \"搬移後請從 {{file}} 第 {{line}} 行刪除原規則\"\n}\n","import enMessages from \"./en.json\";\nimport zhTWMessages from \"./zh-TW.json\";\n\ntype Locale = \"en\" | \"zh-TW\";\n\nconst LOCALE_MAP: Record<Locale, Record<string, string>> = {\n  en: enMessages as Record<string, string>,\n  \"zh-TW\": zhTWMessages as Record<string, string>,\n};\n\nlet _locale: Locale = \"en\";\nlet _messages: Record<string, string> = LOCALE_MAP[\"en\"];\n\n/** Detect locale from environment / system, falling back to 'en'. */\nexport function detectLocale(): Locale {\n  const env = process.env[\"INSTRLINT_LANG\"];\n  if (env === \"zh-TW\" || env === \"en\") return env;\n  try {\n    const sys = Intl.DateTimeFormat().resolvedOptions().locale;\n    // Any zh-* locale (zh-CN, zh-HK, etc.) maps to zh-TW — it's the only CJK locale we support\n    if (sys.startsWith(\"zh\")) return \"zh-TW\";\n  } catch {\n    // ignore\n  }\n  return \"en\";\n}\n\n/**\n * Set the active locale. Call once at CLI startup with the --lang value.\n * Falls back to detectLocale() if lang is unrecognised or omitted.\n */\nexport function initLocale(lang?: string): void {\n  const valid: Locale[] = [\"en\", \"zh-TW\"];\n  const resolved: Locale = valid.includes(lang as Locale)\n    ? (lang as Locale)\n    : detectLocale();\n  _locale = resolved;\n  _messages = LOCALE_MAP[resolved];\n}\n\n/** Return current active locale. */\nexport function getLocale(): Locale {\n  return _locale;\n}\n\n/**\n * Look up a translation key and interpolate {{param}} placeholders.\n * Returns the key itself when no translation is found.\n */\nexport function t(key: string, params?: Record<string, string>): string {\n  const template = _messages[key] ?? key;\n  if (!params) return template;\n  return template.replace(\n    /\\{\\{(\\w+)\\}\\}/g,\n    (_, k: string) => params[k] ?? `{{${k}}}`,\n  );\n}\n\n/** Plural suffix helper: returns 's' for count !== 1, '' otherwise. */\nexport function plural(count: number): string {\n  return count === 1 ? \"\" : \"s\";\n}\n","import { readFileSync, writeFileSync } from 'fs';\nimport type { Finding, FindingCategory } from '../types.js';\n\n/**\n * Removes lines from files based on findings of the specified categories.\n * Only removes lines where `autoFixable === true` and `line` is set.\n * Processes removals from bottom to top within each file to avoid line-offset shifts.\n *\n * @returns total number of lines removed across all files\n */\nexport function removeLines(findings: Finding[], categories: FindingCategory[]): number {\n  const catSet = new Set<FindingCategory>(categories);\n  const fixable = findings.filter(\n    (f) => catSet.has(f.category) && f.autoFixable && f.line != null,\n  );\n\n  // Group by file path\n  const byFile = new Map<string, number[]>();\n  for (const f of fixable) {\n    const arr = byFile.get(f.file) ?? [];\n    arr.push(f.line!);\n    byFile.set(f.file, arr);\n  }\n\n  let totalFixed = 0;\n\n  for (const [filePath, lineNumbers] of byFile) {\n    // Deduplicate and sort descending so we remove from the bottom up\n    const uniqueSorted = [...new Set(lineNumbers)].sort((a, b) => b - a);\n\n    const content = readFileSync(filePath, 'utf8');\n    // Preserve trailing newline behaviour: if file ends with \\n, the last element after split is ''\n    const lines = content.split('\\n');\n\n    for (const lineNum of uniqueSorted) {\n      const idx = lineNum - 1; // convert 1-based to 0-indexed\n      if (idx >= 0 && idx < lines.length) {\n        lines.splice(idx, 1);\n      }\n    }\n\n    writeFileSync(filePath, lines.join('\\n'));\n    totalFixed += uniqueSorted.length;\n  }\n\n  return totalFixed;\n}\n","import { removeLines } from './line-remover.js';\nimport type { Finding } from '../types.js';\n\n/**\n * Removes rules that are provably redundant — already enforced by project config.\n * Only removes lines flagged as `category: 'dead-rule'` and `autoFixable: true`.\n *\n * @returns number of lines removed\n */\nexport function removeDeadRules(findings: Finding[]): number {\n  return removeLines(findings, ['dead-rule']);\n}\n","import { removeLines } from './line-remover.js';\nimport type { Finding } from '../types.js';\n\n/**\n * Removes lines that contain references to non-existent files.\n * Only removes lines flagged as `category: 'stale-ref'` and `autoFixable: true`.\n *\n * @returns number of lines removed\n */\nexport function removeStaleRefs(findings: Finding[]): number {\n  return removeLines(findings, ['stale-ref']);\n}\n","import { removeLines } from './line-remover.js';\nimport type { Finding } from '../types.js';\n\n/**\n * Removes exact duplicate rule lines (keeps the first occurrence, removes later ones).\n * Only removes lines flagged as `category: 'duplicate'` and `autoFixable: true`.\n * Near-duplicates (autoFixable: false) are left untouched.\n *\n * @returns number of lines removed\n */\nexport function deduplicateRules(findings: Finding[]): number {\n  return removeLines(findings, ['duplicate']);\n}\n","import { readFileSync } from \"fs\";\nimport { relative } from \"path\";\nimport chalk from \"chalk\";\nimport { t } from \"../i18n/index.js\";\nimport type { Finding } from \"../types.js\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\ninterface StructureSuggestion {\n  finding: Finding;\n  /** Full rule text from the source file (falls back to snippet) */\n  ruleText: string;\n  type: \"hook\" | \"path-scoped\";\n  /** For path-scoped: the extracted directory name (e.g. 'src') */\n  pathDir?: string;\n}\n\n// ─── File helpers ─────────────────────────────────────────────────────────────\n\nfunction readFileLine(filePath: string, lineNumber: number): string {\n  try {\n    const content = readFileSync(filePath, \"utf8\");\n    return content.split(\"\\n\")[lineNumber - 1]?.trim() ?? \"\";\n  } catch {\n    return \"\";\n  }\n}\n\n// ─── Path extraction ──────────────────────────────────────────────────────────\n\nconst PATH_DIR_RE = /\\b(src|tests?|lib|dist)\\//i;\n\nfunction extractPathDir(text: string): string | undefined {\n  const m = PATH_DIR_RE.exec(text);\n  return m?.[1]?.toLowerCase();\n}\n\n// ─── Code generators ──────────────────────────────────────────────────────────\n\nexport function buildHookSnippet(ruleText: string): string {\n  const comment = ruleText.length > 80 ? `${ruleText.slice(0, 80)}…` : ruleText;\n  return JSON.stringify(\n    {\n      hooks: {\n        PreToolUse: [\n          {\n            matcher: \"Bash\",\n            hooks: [\n              {\n                type: \"command\",\n                command: `# TODO: implement enforcement of:\\n# ${comment}`,\n              },\n            ],\n          },\n        ],\n      },\n    },\n    null,\n    2,\n  );\n}\n\nexport function buildPathScopedFile(\n  pathDir: string,\n  ruleText: string,\n): { filePath: string; content: string } {\n  const filePath = `.claude/rules/${pathDir}.md`;\n  const content = `---\\nglobs:\\n  - \"${pathDir}/**\"\\n---\\n\\n${ruleText}\\n`;\n  return { filePath, content };\n}\n\n// ─── Builder ──────────────────────────────────────────────────────────────────\n\nexport function buildStructureSuggestions(\n  findings: Finding[],\n): StructureSuggestion[] {\n  const suggestions: StructureSuggestion[] = [];\n\n  for (const finding of findings) {\n    if (finding.category !== \"structure\") continue;\n    if (\n      finding.messageKey !== \"structure.scopeHook\" &&\n      finding.messageKey !== \"structure.scopePathScoped\"\n    ) {\n      continue;\n    }\n\n    const ruleText =\n      finding.line != null && finding.line > 0\n        ? readFileLine(finding.file, finding.line) ||\n          (finding.messageParams?.snippet ?? \"\")\n        : (finding.messageParams?.snippet ?? \"\");\n\n    if (finding.messageKey === \"structure.scopeHook\") {\n      suggestions.push({ finding, ruleText, type: \"hook\" });\n    } else {\n      const pathDir =\n        extractPathDir(ruleText) ||\n        extractPathDir(finding.messageParams?.snippet ?? \"\") ||\n        \"src\";\n      suggestions.push({ finding, ruleText, type: \"path-scoped\", pathDir });\n    }\n  }\n\n  return suggestions;\n}\n\n// ─── Terminal renderer ────────────────────────────────────────────────────────\n\nfunction terminalCodeBlock(\n  code: string,\n  output: { log: typeof console.log },\n): void {\n  const lines = code.split(\"\\n\");\n  output.log(chalk.gray(\"  ┌\" + \"─\".repeat(62)));\n  for (const line of lines) {\n    output.log(`  ${chalk.gray(\"│\")} ${chalk.white(line)}`);\n  }\n  output.log(chalk.gray(\"  └\" + \"─\".repeat(62)));\n}\n\nexport function printStructureSuggestions(\n  suggestions: StructureSuggestion[],\n  projectRoot: string,\n  output: { log: typeof console.log },\n): void {\n  if (suggestions.length === 0) return;\n\n  output.log(\"\");\n  output.log(chalk.bold.white(`  ${t(\"fix.manualActions\")}`));\n  output.log(chalk.gray(\"  ─\".repeat(30)));\n\n  for (const s of suggestions) {\n    const relFile = relative(projectRoot, s.finding.file);\n    const lineNum = s.finding.line ?? 0;\n\n    output.log(\"\");\n    output.log(\n      `  ${chalk.blue(\"ℹ\")}  ${chalk.white(t(s.finding.messageKey, s.finding.messageParams))}`,\n    );\n    output.log(\"\");\n\n    if (s.type === \"hook\") {\n      output.log(`  ${chalk.cyan(t(\"fix.hookCreate\"))}`);\n      terminalCodeBlock(buildHookSnippet(s.ruleText), output);\n      output.log(`  ${chalk.yellow(t(\"fix.hookWarning\"))}`);\n      if (lineNum > 0) {\n        output.log(\n          `  ${chalk.gray(t(\"fix.thenRemoveLine\", { line: String(lineNum), file: relFile }))}`,\n        );\n      }\n    } else {\n      const dir = s.pathDir ?? \"src\";\n      const { filePath, content } = buildPathScopedFile(dir, s.ruleText);\n      output.log(\n        `  ${chalk.cyan(t(\"fix.pathScopedCreate\", { path: filePath }))}`,\n      );\n      terminalCodeBlock(content, output);\n      if (lineNum > 0) {\n        output.log(\n          `  ${chalk.gray(t(\"fix.thenRemoveLine\", { line: String(lineNum), file: relFile }))}`,\n        );\n      }\n    }\n  }\n\n  output.log(\"\");\n}\n\n// ─── Markdown renderer ────────────────────────────────────────────────────────\n\nexport function markdownStructureSuggestions(\n  suggestions: StructureSuggestion[],\n  projectRoot: string,\n): string[] {\n  if (suggestions.length === 0) return [];\n\n  const lines: string[] = [`## ${t(\"fix.manualActions\")}`, \"\"];\n\n  for (const s of suggestions) {\n    const relFile = relative(projectRoot, s.finding.file);\n    const lineNum = s.finding.line ?? 0;\n    const icon =\n      s.finding.severity === \"critical\"\n        ? \"🔴\"\n        : s.finding.severity === \"warning\"\n          ? \"🟡\"\n          : \"ℹ️\";\n\n    lines.push(\n      `### ${icon} ${t(s.finding.messageKey, s.finding.messageParams)}`,\n      \"\",\n    );\n\n    if (s.type === \"hook\") {\n      lines.push(\n        t(\"fix.hookCreate\"),\n        \"\",\n        \"```json\",\n        buildHookSnippet(s.ruleText),\n        \"```\",\n        \"\",\n      );\n      lines.push(`> ${t(\"fix.hookWarning\")}`, \"\");\n      if (lineNum > 0) {\n        lines.push(\n          `_${t(\"fix.thenRemoveLine\", { line: String(lineNum), file: relFile })}_`,\n          \"\",\n        );\n      }\n    } else {\n      const dir = s.pathDir ?? \"src\";\n      const { filePath, content } = buildPathScopedFile(dir, s.ruleText);\n      lines.push(t(\"fix.pathScopedCreate\", { path: filePath }), \"\");\n      lines.push(\"```markdown\", content, \"```\", \"\");\n      if (lineNum > 0) {\n        lines.push(\n          `_${t(\"fix.thenRemoveLine\", { line: String(lineNum), file: relFile })}_`,\n          \"\",\n        );\n      }\n    }\n  }\n\n  return lines;\n}\n","import { existsSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { homedir } from \"os\";\nimport { fileURLToPath } from \"url\";\n\nfunction readPackageVersion(): string {\n  const thisFile = fileURLToPath(import.meta.url);\n  // bundled: dist/cli.js → 2 levels up = package root\n  // dev/test: src/utils/skill-version.ts → 3 levels up = package root\n  for (const levels of [2, 3]) {\n    const pkgPath = join(thisFile, ...Array(levels).fill(\"..\"), \"package.json\");\n    if (existsSync(pkgPath)) {\n      const raw: unknown = JSON.parse(readFileSync(pkgPath, \"utf8\"));\n      if (\n        typeof raw === \"object\" &&\n        raw !== null &&\n        \"version\" in raw &&\n        typeof (raw as { version: unknown }).version === \"string\"\n      ) {\n        return (raw as { version: string }).version;\n      }\n    }\n  }\n  return \"0.0.0\";\n}\n\nexport const CURRENT_VERSION: string = readPackageVersion();\n\nconst VERSION_RE = /^instrlint-version:\\s*(.+)$/m;\n\nfunction extractVersion(content: string): string | null {\n  const m = VERSION_RE.exec(content);\n  return m ? m[1]!.trim() : null;\n}\n\nfunction readInstalledVersion(path: string): string | null {\n  if (!existsSync(path)) return null;\n  try {\n    return extractVersion(readFileSync(path, \"utf8\"));\n  } catch {\n    return null;\n  }\n}\n\ninterface SkillUpdateInfo {\n  installedVersion: string;\n  currentVersion: string;\n  installPath: string;\n  isProject: boolean;\n}\n\nexport function checkSkillUpdate(\n  projectRoot: string,\n  globalRoot?: string,\n): SkillUpdateInfo | null {\n  const resolvedGlobal = globalRoot ?? homedir();\n  const candidates: Array<{ path: string; isProject: boolean }> = [\n    {\n      path: join(projectRoot, \".claude\", \"commands\", \"instrlint.md\"),\n      isProject: true,\n    },\n    {\n      path: join(resolvedGlobal, \".claude\", \"commands\", \"instrlint.md\"),\n      isProject: false,\n    },\n  ];\n\n  for (const { path, isProject } of candidates) {\n    const installed = readInstalledVersion(path);\n    if (installed !== null && installed !== CURRENT_VERSION) {\n      return {\n        installedVersion: installed,\n        currentVersion: CURRENT_VERSION,\n        installPath: path,\n        isProject,\n      };\n    }\n  }\n  return null;\n}\n\nexport function injectVersion(content: string, version: string): string {\n  // Replace existing instrlint-version line (idempotent)\n  if (/^instrlint-version:/m.test(content)) {\n    return content.replace(\n      /^instrlint-version:.*$/m,\n      `instrlint-version: ${version}`,\n    );\n  }\n  // Insert before closing --- of frontmatter\n  const updated = content.replace(\n    /^(---\\n[\\s\\S]*?)(---)$/m,\n    `$1instrlint-version: ${version}\\n$2`,\n  );\n  if (updated === content) {\n    throw new Error(\"injectVersion: no YAML frontmatter found in skill file\");\n  }\n  return updated;\n}\n","import { createHash } from \"crypto\";\nimport { relative } from \"path\";\nimport type { Finding, ParsedInstructions, InstructionFile } from \"../types.js\";\nimport type {\n  Candidate,\n  CandidatesFile,\n  CandidateContext,\n  RuleRef,\n} from \"./schema.js\";\nimport { shouldVerify } from \"./policy.js\";\n\n// ─── Line lookup ──────────────────────────────────────────────────────────────\n\nfunction findLineText(\n  parsed: ParsedInstructions,\n  filePath: string,\n  lineNumber: number,\n): string {\n  const sources: InstructionFile[] = [\n    parsed.rootFile,\n    ...parsed.subFiles,\n    ...parsed.rules,\n  ];\n  const file = sources.find((f) => f.path === filePath);\n  if (!file) return \"\";\n  const line = file.lines.find((l) => l.lineNumber === lineNumber);\n  return line?.text.trim() ?? \"\";\n}\n\nfunction ruleRef(\n  parsed: ParsedInstructions,\n  filePath: string,\n  lineNumber: number,\n  projectRoot: string,\n): RuleRef {\n  return {\n    file: toRelative(filePath, projectRoot),\n    line: lineNumber,\n    text: findLineText(parsed, filePath, lineNumber),\n  };\n}\n\n// ─── Context builders ─────────────────────────────────────────────────────────\n\nfunction buildContext(\n  finding: Finding,\n  parsed: ParsedInstructions,\n  projectRoot: string,\n): CandidateContext | null {\n  if (finding.category === \"contradiction\") {\n    const { fileA, lineA } = finding.messageParams ?? {};\n    if (!fileA || !lineA) return null;\n    return {\n      type: \"contradiction\",\n      ruleA: ruleRef(parsed, fileA, Number(lineA), projectRoot),\n      ruleB: ruleRef(parsed, finding.file, finding.line ?? 0, projectRoot),\n    };\n  }\n\n  if (finding.category === \"duplicate\") {\n    const { otherFile, otherLine } = finding.messageParams ?? {};\n    if (!otherFile || !otherLine) return null;\n    return {\n      type: \"duplicate\",\n      ruleA: ruleRef(parsed, otherFile, Number(otherLine), projectRoot),\n      ruleB: ruleRef(parsed, finding.file, finding.line ?? 0, projectRoot),\n    };\n  }\n\n  if (finding.category === \"structure\") {\n    return {\n      type: \"structure\",\n      rule: ruleRef(parsed, finding.file, finding.line ?? 0, projectRoot),\n      suggestion: finding.suggestion,\n    };\n  }\n\n  return null;\n}\n\n// ─── Stable ID ────────────────────────────────────────────────────────────────\n\n/**\n * Hash over category + file + line so the same finding always gets the same ID\n * across instrlint runs, enabling verdict caching by the host agent.\n */\nexport function hashFinding(finding: Finding): string {\n  const key = `${finding.category}:${finding.file}:${finding.line ?? 0}:${finding.messageKey}`;\n  return createHash(\"sha256\").update(key).digest(\"hex\").slice(0, 12);\n}\n\n// ─── Question text ────────────────────────────────────────────────────────────\n\nconst QUESTIONS: Record<string, Record<string, string>> = {\n  contradiction: {\n    en: 'Do rules A and B actually contradict each other in practice? A real contradiction means a developer following both rules would be forced to violate one of them. Respond with JSON only: {\"verdict\":\"confirmed\"|\"rejected\"|\"uncertain\",\"reason\":\"<≤20 words>\"}',\n    \"zh-TW\":\n      '規則 A 和規則 B 在實際開發中真的相互矛盾嗎？真正的矛盾是指：同時遵守兩條規則在某些情境下是不可能的。僅用 JSON 回答：{\"verdict\":\"confirmed\"|\"rejected\"|\"uncertain\",\"reason\":\"<20 字以內>\"}',\n  },\n  duplicate: {\n    en: 'Are rules A and B true semantic duplicates — do they say the same thing in different words, such that keeping both adds no value? Respond with JSON only: {\"verdict\":\"confirmed\"|\"rejected\"|\"uncertain\",\"reason\":\"<≤20 words>\"}',\n    \"zh-TW\":\n      '規則 A 和規則 B 在語意上真的是重複的嗎——用不同的措辭說同一件事，保留兩條毫無額外價值？僅用 JSON 回答：{\"verdict\":\"confirmed\"|\"rejected\"|\"uncertain\",\"reason\":\"<20 字以內>\"}',\n  },\n  structure: {\n    en: 'Is this structural suggestion accurate? Should this rule truly move to a git hook or path-scoped rule file, or is it an architectural principle / general guidance that belongs in CLAUDE.md? Respond with JSON only: {\"verdict\":\"confirmed\"|\"rejected\"|\"uncertain\",\"reason\":\"<≤20 words>\"}',\n    \"zh-TW\":\n      '這條結構建議是否準確？這條規則真的更適合移到 git hook 或 path-scoped rule file 中，還是它是架構說明 / 一般原則，應留在 CLAUDE.md 中？僅用 JSON 回答：{\"verdict\":\"confirmed\"|\"rejected\"|\"uncertain\",\"reason\":\"<20 字以內>\"}',\n  },\n};\n\nfunction questionFor(category: string, locale: string): string {\n  const lang = locale === \"zh-TW\" ? \"zh-TW\" : \"en\";\n  const question = QUESTIONS[category]?.[lang] ?? QUESTIONS[category]?.[\"en\"];\n  if (!question) {\n    process.stderr.write(\n      `[instrlint] Warning: no verification question for category \"${category}\", skipping\\n`,\n    );\n    return \"\";\n  }\n  return question;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/** Normalize an absolute path to project-relative for safe serialization. */\nfunction toRelative(filePath: string, projectRoot: string): string {\n  const rel = relative(projectRoot, filePath);\n  // If the path escaped the project root, keep as-is (safety: don't strip info)\n  return rel.startsWith(\"..\") ? filePath : rel;\n}\n\n/** Return a copy of the finding with all file paths made project-relative. */\nfunction normalizeFilePaths(finding: Finding, projectRoot: string): Finding {\n  const normalized: Finding = {\n    ...finding,\n    file: toRelative(finding.file, projectRoot),\n  };\n  if (normalized.messageParams) {\n    const params = { ...normalized.messageParams };\n    if (params[\"fileA\"])\n      params[\"fileA\"] = toRelative(params[\"fileA\"], projectRoot);\n    if (params[\"otherFile\"])\n      params[\"otherFile\"] = toRelative(params[\"otherFile\"], projectRoot);\n    normalized.messageParams = params;\n  }\n  return normalized;\n}\n\nexport function buildCandidates(\n  findings: Finding[],\n  parsed: ParsedInstructions,\n  projectRoot: string,\n  locale: string,\n): CandidatesFile {\n  const candidates: Candidate[] = [];\n\n  for (const finding of findings) {\n    if (!shouldVerify(finding)) continue;\n    const context = buildContext(finding, parsed, projectRoot);\n    if (!context) continue;\n\n    candidates.push({\n      id: hashFinding(finding),\n      category: finding.category,\n      question: questionFor(finding.category, locale),\n      context,\n      originalFinding: normalizeFilePaths(finding, projectRoot),\n    });\n  }\n\n  return {\n    version: 1,\n    generatedAt: new Date().toISOString(),\n    projectRoot,\n    candidates,\n  };\n}\n","import type { Finding } from \"../types.js\";\n\n/**\n * Returns true for findings that benefit from LLM verification — those with\n * high false-positive rates from the deterministic detectors.\n *\n * High-confidence findings are excluded because they use deterministic checks\n * (filesystem existence, exact config field matching) where LLM review adds\n * no value and would waste the user's session tokens.\n */\nexport function shouldVerify(finding: Finding): boolean {\n  // Exact filesystem check — deterministic, skip verification\n  if (finding.category === \"stale-ref\") return false;\n\n  // Math-based budget checks — deterministic, skip\n  if (finding.category === \"budget\") return false;\n\n  // Structure suggestions are informational, not findings to confirm\n  if (finding.category === \"structure\") return true;\n\n  // Config-overlap dead rules use hard-coded patterns — conservative by design,\n  // but auto-fixable ones are safe; non-auto-fixable may have false positives\n  if (finding.category === \"dead-rule\") return !finding.autoFixable;\n\n  // Contradictions have high false-positive rate — always verify\n  if (finding.category === \"contradiction\") return true;\n\n  // Near-duplicates (warning) are ambiguous; exact dupes (info + autoFixable)\n  // are deterministic and don't need LLM review\n  if (finding.category === \"duplicate\") {\n    return finding.severity === \"warning\" && !finding.autoFixable;\n  }\n\n  return false;\n}\n","import { readFileSync } from \"fs\";\nimport type { Finding } from \"../types.js\";\nimport type { VerdictsFile } from \"./schema.js\";\nimport { hashFinding } from \"./candidates.js\";\n\n/**\n * Reads verdicts.json written by the host agent and merges verdicts back into\n * the findings array.\n *\n * - `rejected` findings are removed entirely (they were false positives).\n * - `confirmed` and `uncertain` findings get a `verification` field attached.\n * - Findings with no matching verdict are returned unchanged.\n * - Unknown IDs in verdicts are silently ignored (forward-compatible).\n */\nexport interface ApplyVerdictsResult {\n  findings: Finding[];\n  rejectedCount: number;\n}\n\nexport function applyVerdicts(\n  findings: Finding[],\n  verdictsFile: VerdictsFile,\n): ApplyVerdictsResult {\n  const verdictMap = new Map(verdictsFile.verdicts.map((v) => [v.id, v]));\n\n  const withVerdicts = findings.map((f): Finding => {\n    const verdict = verdictMap.get(hashFinding(f));\n    if (!verdict) return f;\n    return {\n      ...f,\n      verification: { verdict: verdict.verdict, reason: verdict.reason },\n    };\n  });\n\n  const kept = withVerdicts.filter(\n    (f) => f.verification?.verdict !== \"rejected\",\n  );\n  const rejectedCount = withVerdicts.length - kept.length;\n\n  return { findings: kept, rejectedCount };\n}\n\n/**\n * Loads and parses a verdicts.json file from disk.\n * Throws with a descriptive message if the file is missing or malformed.\n */\nexport function loadVerdictsFile(filePath: string): VerdictsFile {\n  let raw: string;\n  try {\n    raw = readFileSync(filePath, \"utf8\");\n  } catch {\n    throw new Error(\n      `Cannot read verdicts file: ${filePath}\\nRun instrlint --emit-candidates first, then ask the host LLM to write verdicts.`,\n    );\n  }\n\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(raw) as unknown;\n  } catch {\n    throw new Error(`verdicts.json is not valid JSON: ${filePath}`);\n  }\n\n  const obj = parsed as Record<string, unknown>;\n\n  if (\n    typeof parsed !== \"object\" ||\n    parsed === null ||\n    obj[\"version\"] !== 1 ||\n    !Array.isArray(obj[\"verdicts\"])\n  ) {\n    throw new Error(\n      `verdicts.json has unexpected format (expected {version:1, verdicts:[...]}): ${filePath}`,\n    );\n  }\n\n  const VALID_VERDICTS = new Set([\"confirmed\", \"rejected\", \"uncertain\"]);\n  const MAX_REASON_LENGTH = 500;\n\n  for (const v of obj[\"verdicts\"] as unknown[]) {\n    if (typeof v !== \"object\" || v === null) {\n      throw new Error(`verdicts.json: each verdict must be an object`);\n    }\n    const item = v as Record<string, unknown>;\n    if (typeof item[\"id\"] !== \"string\" || item[\"id\"].length === 0) {\n      throw new Error(`verdicts.json: verdict missing string \"id\"`);\n    }\n    if (!VALID_VERDICTS.has(item[\"verdict\"] as string)) {\n      throw new Error(\n        `verdicts.json: invalid verdict \"${item[\"verdict\"]}\" for id \"${item[\"id\"]}\" (must be confirmed|rejected|uncertain)`,\n      );\n    }\n    if (typeof item[\"reason\"] !== \"string\") {\n      throw new Error(\n        `verdicts.json: verdict \"${item[\"id\"]}\" missing string \"reason\"`,\n      );\n    }\n    if ((item[\"reason\"] as string).length > MAX_REASON_LENGTH) {\n      throw new Error(\n        `verdicts.json: verdict \"${item[\"id\"]}\" reason exceeds ${MAX_REASON_LENGTH} characters`,\n      );\n    }\n  }\n\n  return parsed as VerdictsFile;\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { homedir } from \"os\";\nimport { fileURLToPath } from \"url\";\nimport { t } from \"../i18n/index.js\";\nimport { injectVersion, CURRENT_VERSION } from \"../utils/skill-version.js\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\ninterface InstallCommandOpts {\n  claudeCode?: boolean;\n  codex?: boolean;\n  project?: boolean;\n  force?: boolean;\n  projectRoot?: string;\n}\n\ninterface InstallCommandResult {\n  exitCode: number;\n  errorMessage?: string;\n}\n\n// ─── File resolution ──────────────────────────────────────────────────────────\n\nfunction resolveSkillFile(): string {\n  const thisFile = fileURLToPath(import.meta.url);\n  const levelCandidates = [2, 3];\n\n  // tsup bundles into dist/cli.js (2 levels up = package root).\n  // In dev/test, file is at src/commands/install-command.ts (3 levels up = package root).\n  // Try both, use whichever has the skills directory.\n  for (const levels of levelCandidates) {\n    const parts = Array(levels).fill(\"..\");\n    const candidate = join(\n      thisFile,\n      ...parts,\n      \"skills\",\n      \"instrlint\",\n      \"SKILL.md\",\n    );\n    if (existsSync(candidate)) return candidate;\n  }\n\n  // Fallback: return the first candidate's path so the error message shows a useful path\n  return join(\n    thisFile,\n    ...Array(levelCandidates[0]).fill(\"..\"),\n    \"skills\",\n    \"instrlint\",\n    \"SKILL.md\",\n  );\n}\n\nfunction readSkillContent(): string {\n  const skillPath = resolveSkillFile();\n  try {\n    const raw = readFileSync(skillPath, \"utf8\");\n    return injectVersion(raw, CURRENT_VERSION);\n  } catch {\n    throw new Error(\n      `Could not read skill file at ${skillPath}. Make sure the package is properly installed.`,\n    );\n  }\n}\n\n// ─── Install targets ──────────────────────────────────────────────────────────\n\nfunction installClaudeCode(\n  content: string,\n  projectRoot: string,\n  isProject: boolean,\n  force: boolean,\n  output: { log: typeof console.log; error: typeof console.error },\n): InstallCommandResult {\n  const targetDir = isProject\n    ? join(projectRoot, \".claude\", \"commands\")\n    : join(homedir(), \".claude\", \"commands\");\n\n  const targetPath = join(targetDir, \"instrlint.md\");\n\n  if (existsSync(targetPath) && !force) {\n    output.error(t(\"install.alreadyExists\", { path: targetPath }));\n    return { exitCode: 1, errorMessage: \"file already exists\" };\n  }\n\n  mkdirSync(targetDir, { recursive: true });\n  writeFileSync(targetPath, content, \"utf8\");\n  output.log(t(\"install.installed\", { path: targetPath }));\n  return { exitCode: 0 };\n}\n\nfunction installCodex(\n  content: string,\n  projectRoot: string,\n  force: boolean,\n  output: { log: typeof console.log; error: typeof console.error },\n): InstallCommandResult {\n  const targetDir = join(projectRoot, \".agents\", \"skills\", \"instrlint\");\n  const targetPath = join(targetDir, \"SKILL.md\");\n\n  if (existsSync(targetPath) && !force) {\n    output.error(t(\"install.alreadyExists\", { path: targetPath }));\n    return { exitCode: 1, errorMessage: \"file already exists\" };\n  }\n\n  mkdirSync(targetDir, { recursive: true });\n  writeFileSync(targetPath, content, \"utf8\");\n  output.log(t(\"install.installed\", { path: targetPath }));\n  return { exitCode: 0 };\n}\n\n// ─── Core logic ───────────────────────────────────────────────────────────────\n\nexport function runInstall(\n  opts: InstallCommandOpts,\n  output: { log: typeof console.log; error: typeof console.error } = console,\n): InstallCommandResult {\n  const projectRoot = opts.projectRoot ?? process.cwd();\n  const force = opts.force ?? false;\n\n  let content: string;\n  try {\n    content = readSkillContent();\n  } catch (err) {\n    output.error(String(err));\n    return { exitCode: 1, errorMessage: String(err) };\n  }\n\n  if (opts.claudeCode) {\n    return installClaudeCode(\n      content,\n      projectRoot,\n      opts.project ?? false,\n      force,\n      output,\n    );\n  }\n\n  if (opts.codex) {\n    return installCodex(content, projectRoot, force, output);\n  }\n\n  output.error(t(\"install.unknownTarget\"));\n  return { exitCode: 1, errorMessage: \"no target specified\" };\n}\n","import chalk from \"chalk\";\nimport { analyzeDeadRules } from \"../analyzers/dead-rules.js\";\nimport { loadProject } from \"../adapters/dispatch.js\";\nimport { ensureInitialized } from \"../detectors/token-estimator.js\";\nimport { scanProject } from \"../core/scanner.js\";\nimport { t, plural, initLocale, getLocale } from \"../i18n/index.js\";\nimport type { Finding } from \"../types.js\";\n\n// ─── Terminal output ──────────────────────────────────────────────────────────\n\nexport function printDeadRulesTerminal(\n  findings: Finding[],\n  output: { log: typeof console.log } = console,\n): void {\n  const overlaps = findings.filter((f) => f.category === \"dead-rule\");\n  const duplicates = findings.filter((f) => f.category === \"duplicate\");\n\n  output.log(\"\");\n  output.log(chalk.bold.white(`  ${t(\"label.deadRules\")}`));\n  output.log(chalk.gray(\"  ─\".repeat(30)));\n\n  if (overlaps.length > 0) {\n    output.log(chalk.bold(`  ${t(\"label.redundantByConfig\")}`));\n    for (const f of overlaps) {\n      output.log(`  ${chalk.yellow(\"⚠\")}  ${t(f.messageKey, f.messageParams)}`);\n    }\n    output.log(\"\");\n  }\n\n  if (duplicates.length > 0) {\n    output.log(chalk.bold(`  ${t(\"label.duplicates\")}`));\n    for (const f of duplicates) {\n      const icon =\n        f.severity === \"warning\" ? chalk.yellow(\"⚠\") : chalk.blue(\"ℹ\");\n      output.log(`  ${icon}  ${t(f.messageKey, f.messageParams)}`);\n    }\n    output.log(\"\");\n  }\n\n  output.log(chalk.gray(\"  ─\".repeat(30)));\n\n  if (findings.length === 0) {\n    output.log(chalk.green(`  ${t(\"status.noDeadRules\")}`));\n  } else {\n    const sep = getLocale() === \"zh-TW\" ? \"、\" : \", \";\n    const parts: string[] = [];\n    if (overlaps.length > 0)\n      parts.push(\n        t(\"summary.redundantRules\", {\n          count: String(overlaps.length),\n          s: plural(overlaps.length),\n        }),\n      );\n    if (duplicates.length > 0)\n      parts.push(\n        t(\"summary.duplicates\", {\n          count: String(duplicates.length),\n          s: plural(duplicates.length),\n        }),\n      );\n    output.log(\n      chalk.yellow(`  ${t(\"summary.found\", { parts: parts.join(sep) })}`),\n    );\n  }\n  output.log(\"\");\n}\n\n// ─── Core run logic ───────────────────────────────────────────────────────────\n\ninterface DeadRulesCommandOpts {\n  format: string;\n  tool?: string;\n  lang?: string;\n  projectRoot?: string;\n}\n\ninterface DeadRulesCommandResult {\n  exitCode: number;\n  errorMessage?: string;\n}\n\nexport async function runDeadRules(\n  opts: DeadRulesCommandOpts,\n  output: { log: typeof console.log; error: typeof console.error } = console,\n): Promise<DeadRulesCommandResult> {\n  initLocale(opts.lang);\n  await ensureInitialized();\n\n  const projectRoot = opts.projectRoot ?? process.cwd();\n  const scan = scanProject(projectRoot, opts.tool);\n\n  if (scan.tool === \"unknown\") {\n    output.error(t(\"error.unknownTool\"));\n    return { exitCode: 1, errorMessage: \"unknown tool\" };\n  }\n\n  if (scan.rootFilePath === null) {\n    output.error(t(\"error.missingRootFile\", { tool: scan.tool }));\n    return { exitCode: 1, errorMessage: \"missing root file\" };\n  }\n\n  const instructions = loadProject(projectRoot, scan.tool);\n  const { findings } = analyzeDeadRules(instructions, projectRoot);\n\n  if (opts.format === \"json\") {\n    output.log(JSON.stringify({ findings }, null, 2));\n    return { exitCode: 0 };\n  }\n\n  printDeadRulesTerminal(findings, output);\n  return { exitCode: 0 };\n}\n","import chalk from \"chalk\";\nimport { analyzeStructure } from \"../analyzers/structure.js\";\nimport { loadProject } from \"../adapters/dispatch.js\";\nimport { ensureInitialized } from \"../detectors/token-estimator.js\";\nimport { scanProject } from \"../core/scanner.js\";\nimport { t, plural, initLocale, getLocale } from \"../i18n/index.js\";\nimport type { Finding } from \"../types.js\";\n\n// ─── Terminal output ──────────────────────────────────────────────────────────\n\nfunction printStructureTerminal(\n  findings: Finding[],\n  output: { log: typeof console.log } = console,\n): void {\n  const contradictions = findings.filter((f) => f.category === \"contradiction\");\n  const staleRefs = findings.filter((f) => f.category === \"stale-ref\");\n  const scoped = findings.filter((f) => f.category === \"structure\");\n\n  output.log(\"\");\n  output.log(chalk.bold.white(`  ${t(\"label.structure\")}`));\n  output.log(chalk.gray(\"  ─\".repeat(30)));\n\n  if (contradictions.length > 0) {\n    output.log(chalk.bold(`  ${t(\"label.contradictions\")}`));\n    for (const f of contradictions) {\n      output.log(`  ${chalk.red(\"✖\")}  ${t(f.messageKey, f.messageParams)}`);\n    }\n    output.log(\"\");\n  }\n\n  if (staleRefs.length > 0) {\n    output.log(chalk.bold(`  ${t(\"label.staleReferences\")}`));\n    for (const f of staleRefs) {\n      output.log(`  ${chalk.yellow(\"⚠\")}  ${t(f.messageKey, f.messageParams)}`);\n    }\n    output.log(\"\");\n  }\n\n  if (scoped.length > 0) {\n    output.log(chalk.bold(`  ${t(\"label.refactoringOpportunities\")}`));\n    for (const f of scoped) {\n      output.log(`  ${chalk.blue(\"ℹ\")}  ${t(f.messageKey, f.messageParams)}`);\n    }\n    output.log(\"\");\n  }\n\n  output.log(chalk.gray(\"  ─\".repeat(30)));\n\n  if (findings.length === 0) {\n    output.log(chalk.green(`  ${t(\"status.noStructuralIssues\")}`));\n  } else {\n    const sep = getLocale() === \"zh-TW\" ? \"、\" : \", \";\n    const parts: string[] = [];\n    if (contradictions.length > 0)\n      parts.push(\n        t(\"summary.contradictions\", {\n          count: String(contradictions.length),\n          s: plural(contradictions.length),\n        }),\n      );\n    if (staleRefs.length > 0)\n      parts.push(\n        t(\"summary.staleRefs\", {\n          count: String(staleRefs.length),\n          s: plural(staleRefs.length),\n        }),\n      );\n    if (scoped.length > 0)\n      parts.push(\n        t(\"summary.refactoringSuggestions\", {\n          count: String(scoped.length),\n          s: plural(scoped.length),\n        }),\n      );\n    output.log(\n      chalk.yellow(`  ${t(\"summary.found\", { parts: parts.join(sep) })}`),\n    );\n  }\n  output.log(\"\");\n}\n\n// ─── Core run logic ───────────────────────────────────────────────────────────\n\ninterface StructureCommandOpts {\n  format: string;\n  tool?: string;\n  lang?: string;\n  projectRoot?: string;\n}\n\ninterface StructureCommandResult {\n  exitCode: number;\n  errorMessage?: string;\n}\n\nexport async function runStructure(\n  opts: StructureCommandOpts,\n  output: { log: typeof console.log; error: typeof console.error } = console,\n): Promise<StructureCommandResult> {\n  initLocale(opts.lang);\n  await ensureInitialized();\n\n  const projectRoot = opts.projectRoot ?? process.cwd();\n  const scan = scanProject(projectRoot, opts.tool);\n\n  if (scan.tool === \"unknown\") {\n    output.error(t(\"error.unknownTool\"));\n    return { exitCode: 1, errorMessage: \"unknown tool\" };\n  }\n\n  if (scan.rootFilePath === null) {\n    output.error(t(\"error.missingRootFile\", { tool: scan.tool }));\n    return { exitCode: 1, errorMessage: \"missing root file\" };\n  }\n\n  const instructions = loadProject(projectRoot, scan.tool);\n  const { findings } = analyzeStructure(instructions, projectRoot);\n\n  if (opts.format === \"json\") {\n    output.log(JSON.stringify({ findings }, null, 2));\n    return { exitCode: 0 };\n  }\n\n  printStructureTerminal(findings, output);\n  return { exitCode: 0 };\n}\n","import { writeFileSync } from \"fs\";\nimport { basename } from \"path\";\nimport { scanProject } from \"../core/scanner.js\";\nimport { loadProject } from \"../adapters/dispatch.js\";\nimport { ensureInitialized } from \"../detectors/token-estimator.js\";\nimport { analyzeBudget } from \"../analyzers/budget.js\";\nimport { analyzeDeadRules } from \"../analyzers/dead-rules.js\";\nimport { analyzeStructure } from \"../analyzers/structure.js\";\nimport { calculateScore, buildActionPlan } from \"../core/scorer.js\";\nimport { reportJson, reportMarkdown } from \"../core/reporter.js\";\nimport { reportSarif } from \"../reporters/sarif.js\";\nimport { t, initLocale, getLocale } from \"../i18n/index.js\";\nimport type { Finding, HealthReport } from \"../types.js\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\nexport type FailOn = \"critical\" | \"warning\" | \"info\";\n\ninterface CiCommandOpts {\n  format?: string;\n  tool?: string;\n  lang?: string;\n  failOn?: FailOn;\n  output?: string;\n  projectRoot?: string;\n}\n\ninterface CiCommandResult {\n  exitCode: number;\n  errorMessage?: string;\n}\n\n// ─── Threshold helpers ────────────────────────────────────────────────────────\n\nfunction shouldFail(findings: Finding[], failOn: FailOn): boolean {\n  if (failOn === \"info\") return findings.length > 0;\n  if (failOn === \"warning\")\n    return findings.some(\n      (f) => f.severity === \"critical\" || f.severity === \"warning\",\n    );\n  // default: critical\n  return findings.some((f) => f.severity === \"critical\");\n}\n\n// ─── Core logic ───────────────────────────────────────────────────────────────\n\nexport async function runCi(\n  opts: CiCommandOpts,\n  output: { log: typeof console.log; error: typeof console.error } = console,\n): Promise<CiCommandResult> {\n  initLocale(opts.lang);\n  await ensureInitialized();\n\n  const projectRoot = opts.projectRoot ?? process.cwd();\n  const failOn: FailOn = opts.failOn ?? \"critical\";\n  const format = opts.format ?? \"terminal\";\n\n  const scan = scanProject(projectRoot, opts.tool);\n\n  if (scan.tool === \"unknown\") {\n    output.error(t(\"error.unknownTool\"));\n    return { exitCode: 1, errorMessage: \"unknown tool\" };\n  }\n\n  if (scan.rootFilePath === null) {\n    output.error(t(\"error.missingRootFile\", { tool: scan.tool }));\n    return { exitCode: 1, errorMessage: \"missing root file\" };\n  }\n\n  const instructions = loadProject(projectRoot, scan.tool);\n\n  const { findings: budgetFindings, summary } = analyzeBudget(instructions);\n  const { findings: deadRuleFindings } = analyzeDeadRules(\n    instructions,\n    projectRoot,\n  );\n  const { findings: structureFindings } = analyzeStructure(\n    instructions,\n    projectRoot,\n  );\n\n  const allFindings = [\n    ...budgetFindings,\n    ...deadRuleFindings,\n    ...structureFindings,\n  ];\n  const { score, grade } = calculateScore(allFindings, summary);\n  const actionPlan = buildActionPlan(allFindings);\n\n  const report: HealthReport = {\n    project: basename(projectRoot),\n    tool: instructions.tool,\n    score,\n    grade,\n    locale: getLocale(),\n    tokenMethod: summary.tokenMethod,\n    findings: allFindings,\n    budget: summary,\n    actionPlan,\n  };\n\n  // ── Format output ─────────────────────────────────────────────────────────\n  let formatted: string;\n  if (format === \"sarif\") {\n    formatted = reportSarif(report);\n  } else if (format === \"json\") {\n    formatted = reportJson(report);\n  } else if (format === \"markdown\") {\n    formatted = reportMarkdown(report);\n  } else {\n    formatted = reportJson(report);\n  }\n\n  if (opts.output != null) {\n    writeFileSync(opts.output, formatted, \"utf8\");\n    const pass = !shouldFail(allFindings, failOn);\n    const statusKey = pass ? \"ci.passed\" : \"ci.failed\";\n    output.error(\n      `${t(statusKey, { score: String(score), grade })}  ${t(\"ci.writtenTo\", { file: opts.output })}`,\n    );\n  } else {\n    output.log(formatted);\n  }\n\n  const failed = shouldFail(allFindings, failOn);\n  return { exitCode: failed ? 1 : 0 };\n}\n","import type { Finding, HealthReport } from \"../types.js\";\n\n// ─── SARIF v2.1.0 types ────────────────────────────────────────────────────\n\ninterface SarifArtifactLocation {\n  uri: string;\n  uriBaseId?: string;\n}\n\ninterface SarifRegion {\n  startLine: number;\n}\n\ninterface SarifPhysicalLocation {\n  artifactLocation: SarifArtifactLocation;\n  region?: SarifRegion;\n}\n\ninterface SarifLocation {\n  physicalLocation: SarifPhysicalLocation;\n}\n\ninterface SarifMessage {\n  text: string;\n}\n\ninterface SarifResult {\n  ruleId: string;\n  level: \"error\" | \"warning\" | \"note\";\n  message: SarifMessage;\n  locations: SarifLocation[];\n}\n\ninterface SarifRule {\n  id: string;\n  name: string;\n  shortDescription: SarifMessage;\n}\n\ninterface SarifDriver {\n  name: string;\n  version: string;\n  informationUri: string;\n  rules: SarifRule[];\n}\n\ninterface SarifTool {\n  driver: SarifDriver;\n}\n\ninterface SarifRun {\n  tool: SarifTool;\n  results: SarifResult[];\n}\n\ninterface SarifLog {\n  $schema: string;\n  version: \"2.1.0\";\n  runs: SarifRun[];\n}\n\n// ─── Helpers ───────────────────────────────────────────────────────────────\n\nfunction severityToLevel(\n  severity: Finding[\"severity\"],\n): \"error\" | \"warning\" | \"note\" {\n  if (severity === \"critical\") return \"error\";\n  if (severity === \"warning\") return \"warning\";\n  return \"note\";\n}\n\nfunction findingToRuleId(f: Finding): string {\n  return `instrlint/${f.category}/${f.messageKey.replace(/\\./g, \"/\")}`;\n}\n\nfunction buildRules(findings: Finding[]): SarifRule[] {\n  const seen = new Set<string>();\n  const rules: SarifRule[] = [];\n  for (const f of findings) {\n    const id = findingToRuleId(f);\n    if (seen.has(id)) continue;\n    seen.add(id);\n    rules.push({\n      id,\n      name: f.messageKey,\n      shortDescription: { text: `${f.category}: ${f.messageKey}` },\n    });\n  }\n  return rules;\n}\n\n// ─── Public API ────────────────────────────────────────────────────────────\n\nexport function reportSarif(report: HealthReport): string {\n  const rules = buildRules(report.findings);\n\n  const results: SarifResult[] = report.findings.map((f) => ({\n    ruleId: findingToRuleId(f),\n    level: severityToLevel(f.severity),\n    message: { text: f.suggestion },\n    locations: [\n      {\n        physicalLocation: {\n          artifactLocation: {\n            uri: f.file.replace(/\\\\/g, \"/\"),\n            uriBaseId: \"%SRCROOT%\",\n          },\n          ...(f.line != null ? { region: { startLine: f.line } } : {}),\n        },\n      },\n    ],\n  }));\n\n  const log: SarifLog = {\n    $schema:\n      \"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json\",\n    version: \"2.1.0\",\n    runs: [\n      {\n        tool: {\n          driver: {\n            name: \"instrlint\",\n            version: \"0.1.0\",\n            informationUri: \"https://github.com/jed1978/instrlint\",\n            rules,\n          },\n        },\n        results,\n      },\n    ],\n  };\n\n  return JSON.stringify(log, null, 2);\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { t } from \"../i18n/index.js\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\ninterface InitCiCommandOpts {\n  github?: boolean;\n  gitlab?: boolean;\n  force?: boolean;\n  projectRoot?: string;\n}\n\ninterface InitCiCommandResult {\n  exitCode: number;\n  errorMessage?: string;\n}\n\n// ─── GitHub Actions workflow template ────────────────────────────────────────\n\nfunction githubWorkflow(): string {\n  return `name: instrlint\n\non:\n  push:\n    paths:\n      - 'CLAUDE.md'\n      - '.claude/**'\n      - 'AGENTS.md'\n      - '.agents/**'\n      - '.cursorrules'\n      - '.cursor/**'\n  pull_request:\n    paths:\n      - 'CLAUDE.md'\n      - '.claude/**'\n      - 'AGENTS.md'\n      - '.agents/**'\n      - '.cursorrules'\n      - '.cursor/**'\n\njobs:\n  instrlint:\n    name: Lint instruction files\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      security-events: write\n\n    steps:\n      - uses: actions/checkout@v4\n\n      - uses: actions/setup-node@v4\n        with:\n          node-version: '20'\n\n      - name: Run instrlint\n        run: npx instrlint@latest ci --fail-on warning --format sarif --output instrlint.sarif\n\n      - name: Upload SARIF\n        if: always()\n        uses: github/codeql-action/upload-sarif@v3\n        with:\n          sarif_file: instrlint.sarif\n          category: instrlint\n`;\n}\n\n// ─── GitLab CI snippet template ───────────────────────────────────────────────\n\nfunction gitlabSnippet(): string {\n  return `# Add this to your .gitlab-ci.yml\ninstrlint:\n  image: node:20\n  stage: test\n  rules:\n    - changes:\n        - CLAUDE.md\n        - .claude/**/*\n        - AGENTS.md\n        - .agents/**/*\n        - .cursorrules\n        - .cursor/**/*\n  script:\n    - npx instrlint@latest ci --fail-on warning --format json\n  allow_failure: false\n`;\n}\n\n// ─── Core logic ───────────────────────────────────────────────────────────────\n\nexport function runInitCi(\n  opts: InitCiCommandOpts,\n  output: { log: typeof console.log; error: typeof console.error } = console,\n): InitCiCommandResult {\n  const projectRoot = opts.projectRoot ?? process.cwd();\n\n  if (opts.github) {\n    const workflowDir = join(projectRoot, \".github\", \"workflows\");\n    const workflowPath = join(workflowDir, \"instrlint.yml\");\n\n    if (existsSync(workflowPath) && !opts.force) {\n      output.error(t(\"initCi.alreadyExists\", { path: workflowPath }));\n      return { exitCode: 1, errorMessage: \"file already exists\" };\n    }\n\n    mkdirSync(workflowDir, { recursive: true });\n    writeFileSync(workflowPath, githubWorkflow(), \"utf8\");\n    output.log(t(\"initCi.created\", { path: workflowPath }));\n    return { exitCode: 0 };\n  }\n\n  if (opts.gitlab) {\n    output.log(gitlabSnippet());\n    return { exitCode: 0 };\n  }\n\n  output.error(\"init-ci: specify --github or --gitlab\");\n  return { exitCode: 1, errorMessage: \"no target specified\" };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ACX9D,uBAAwB;;;ACDxB,2BAAyB;AACzB,IAAAA,cAA8B;AAC9B,sBAAgC;AAChC,IAAAC,gBAA4C;AAC5C,IAAAC,gBAAkB;;;ACJlB,gBAA2B;AAC3B,kBAAqB;AAoBrB,SAAS,UAAU,aAAkC;AACnD,QAAM,aAA0B,CAAC;AAGjC,QAAM,gBAAY,kBAAK,aAAa,SAAS;AAC7C,UAAI,sBAAW,SAAS,GAA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QACG,QAAQ,SAAS,EACjB,YAAY,8BAA8B,EAC1C,OAAO,iBAAiB,8BAA8B,EACtD,OAAO,WAAW,wBAAwB,EAC1C,OAAO,aAAa,kDAAkD,EACtE,OAAO,WAAW,+BAA+B,EACjD,OAAO,WAAyB;AAC/B,QAAM,OAAO,KAAK,KAKf;AACH,QAAM,SAAS,WAAW,IAAI;AAC9B,MAAI,OAAO,aAAa,EAAG,SAAQ,KAAK,OAAO,QAAQ;AACzD,CAAC;AAEH,QAAQ,MAAM;","names":["import_fs","import_path","import_chalk","detections","import_fs","import_path","import_fs","import_fs","import_path","safeParseFile","emptyFile","loadSkills","import_fs","import_path","safeParseFile","emptyFile","findRootFile","loadRules","loadMcpServers","pct","import_fs","import_path","collectRuleLines","collectRuleLines","import_fs","import_path","CONTEXT_WINDOW","import_chalk","chalk","chalk","import_fs","import_fs","import_path","import_chalk","chalk","import_fs","import_path","import_path","import_fs","import_fs","import_path","import_os","import_url","chalk","resolve","import_chalk","chalk","import_chalk","chalk","import_fs","import_path","import_fs","import_path"]}