@forge-ts/cli 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/commands/audit.ts","../src/output.ts","../src/commands/build.ts","../src/logger.ts","../src/commands/bypass.ts","../src/commands/check.ts","../src/commands/docs-dev.ts","../src/commands/init-docs.ts","../src/commands/init-hooks.ts","../src/commands/lock.ts","../src/commands/prepublish.ts","../src/commands/test.ts","../src/commands/unlock.ts"],"sourcesContent":["/**\n * @forge-ts/cli — Command-line interface for the forge-ts toolchain.\n *\n * Usage:\n * forge-ts check [--cwd <dir>] [--strict] [--verbose]\n * forge-ts test [--cwd <dir>]\n * forge-ts build [--cwd <dir>] [--skip-api] [--skip-gen]\n * forge-ts docs init [--target <ssg>] [--out-dir <dir>] [--force]\n * forge-ts docs dev [--target <ssg>] [--port <port>]\n * forge-ts lock [--cwd <dir>]\n * forge-ts unlock --reason=\"...\" [--cwd <dir>]\n * forge-ts bypass --reason=\"...\" [--rule E009]\n * forge-ts bypass --status\n * forge-ts audit [--limit N] [--type <eventType>]\n * forge-ts init hooks [--cwd <dir>] [--force]\n * forge-ts prepublish [--cwd <dir>] [--strict]\n *\n * @packageDocumentation\n * @public\n */\n\nimport { createRequire } from \"node:module\";\nimport { defineCommand, runMain } from \"citty\";\nimport { auditCommand } from \"./commands/audit.js\";\nimport { buildCommand } from \"./commands/build.js\";\nimport { bypassCommand } from \"./commands/bypass.js\";\nimport { checkCommand } from \"./commands/check.js\";\nimport { docsDevCommand } from \"./commands/docs-dev.js\";\nimport { initDocsCommand } from \"./commands/init-docs.js\";\nimport { initHooksCommand } from \"./commands/init-hooks.js\";\nimport { lockCommand } from \"./commands/lock.js\";\nimport { prepublishCommand } from \"./commands/prepublish.js\";\nimport { testCommand } from \"./commands/test.js\";\nimport { unlockCommand } from \"./commands/unlock.js\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\") as { version: string };\n\nexport { type AuditResult, auditCommand } from \"./commands/audit.js\";\nexport { type BuildResult, type BuildStep, buildCommand } from \"./commands/build.js\";\nexport {\n\ttype BypassCreateResult,\n\ttype BypassStatusResult,\n\tbypassCommand,\n\trunBypassCreate,\n\trunBypassStatus,\n} from \"./commands/bypass.js\";\nexport {\n\ttype CheckFileError,\n\ttype CheckFileGroup,\n\ttype CheckFileWarning,\n\ttype CheckPage,\n\ttype CheckResult,\n\ttype CheckRuleCount,\n\ttype CheckTriage,\n\tcheckCommand,\n} from \"./commands/check.js\";\nexport { docsDevCommand, runDocsDev } from \"./commands/docs-dev.js\";\nexport {\n\ttype InitDocsResult,\n\tinitDocsCommand,\n} from \"./commands/init-docs.js\";\nexport {\n\ttype HookManager,\n\ttype InitHooksResult,\n\tinitHooksCommand,\n\trunInitHooks,\n} from \"./commands/init-hooks.js\";\nexport { type LockResult, lockCommand, runLock } from \"./commands/lock.js\";\nexport {\n\ttype PrepublishResult,\n\tprepublishCommand,\n\trunPrepublish,\n} from \"./commands/prepublish.js\";\nexport { type TestFailure, type TestResult, testCommand } from \"./commands/test.js\";\nexport { runUnlock, type UnlockResult, unlockCommand } from \"./commands/unlock.js\";\nexport { createLogger, type Logger } from \"./logger.js\";\nexport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype ForgeCliWarning,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"./output.js\";\n\n/**\n * The `docs` parent command with `init` and `dev` subcommands.\n *\n * @example\n * ```typescript\n * // forge-ts docs init --target mintlify\n * // forge-ts docs dev\n * ```\n * @public\n */\nconst docsCommand = defineCommand({\n\tmeta: {\n\t\tname: \"docs\",\n\t\tdescription: \"Documentation site management\",\n\t},\n\tsubCommands: {\n\t\tinit: initDocsCommand,\n\t\tdev: docsDevCommand,\n\t},\n});\n\n/**\n * The `init` parent command with `docs` and `hooks` subcommands.\n *\n * @example\n * ```typescript\n * // forge-ts init docs --target mintlify\n * // forge-ts init hooks\n * ```\n * @public\n */\nconst initCommand = defineCommand({\n\tmeta: {\n\t\tname: \"init\",\n\t\tdescription: \"Scaffold project artefacts\",\n\t},\n\tsubCommands: {\n\t\tdocs: initDocsCommand,\n\t\thooks: initHooksCommand,\n\t},\n});\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: \"forge-ts\",\n\t\tversion: pkg.version,\n\t\tdescription: \"Universal TypeScript Documentation Compiler\",\n\t},\n\tsubCommands: {\n\t\tcheck: checkCommand,\n\t\ttest: testCommand,\n\t\tbuild: buildCommand,\n\t\tdocs: docsCommand,\n\t\tinit: initCommand,\n\t\tlock: lockCommand,\n\t\tunlock: unlockCommand,\n\t\tbypass: bypassCommand,\n\t\taudit: auditCommand,\n\t\tprepublish: prepublishCommand,\n\t},\n});\n\nrunMain(main);\n","/**\n * CLI command for reading the forge-ts audit trail.\n *\n * Reads `.forge-audit.jsonl` from the project root and displays events\n * in human-readable or LAFS JSON format.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\ttype AuditEvent,\n\ttype AuditEventType,\n\tformatAuditEvent,\n\treadAuditLog,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Arguments for the `audit` command.\n *\n * @internal\n */\nexport interface AuditArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Maximum number of events to display (default: 20). */\n\tlimit?: number;\n\t/** Filter events by type. */\n\ttype?: AuditEventType;\n}\n\n/**\n * Typed result for the `audit` command.\n *\n * @public\n */\nexport interface AuditResult {\n\t/** Whether the audit log was read successfully. */\n\tsuccess: boolean;\n\t/** Number of events returned. */\n\tcount: number;\n\t/** The audit events, newest first. */\n\tevents: AuditEvent[];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Reads the audit log and returns a typed command output.\n *\n * @param args - CLI arguments for the audit command.\n * @returns A typed `CommandOutput<AuditResult>`.\n * @example\n * ```typescript\n * import { runAudit } from \"@forge-ts/cli/commands/audit\";\n * const output = await runAudit({ cwd: process.cwd(), limit: 10 });\n * console.log(output.data.count); // number of events returned\n * ```\n * @public\n */\nexport function runAudit(args: AuditArgs): CommandOutput<AuditResult> {\n\tconst rootDir = args.cwd ?? process.cwd();\n\tconst limit = args.limit ?? 20;\n\n\tconst events = readAuditLog(rootDir, {\n\t\tlimit,\n\t\teventType: args.type,\n\t});\n\n\tconst data: AuditResult = {\n\t\tsuccess: true,\n\t\tcount: events.length,\n\t\tevents,\n\t};\n\n\treturn {\n\t\toperation: \"audit\",\n\t\tsuccess: true,\n\t\tdata,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an AuditResult as human-readable text.\n *\n * @param data - The audit result to format.\n * @returns Formatted multi-line string.\n * @internal\n */\nfunction formatAuditHuman(data: AuditResult): string {\n\tif (data.count === 0) {\n\t\treturn \"forge-ts audit: no events found.\";\n\t}\n\n\tconst lines: string[] = [];\n\tlines.push(`forge-ts audit: ${data.count} event(s)\\n`);\n\n\tfor (const event of data.events) {\n\t\tlines.push(` ${formatAuditEvent(event)}`);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/** Valid event types for the --type filter. */\nconst VALID_EVENT_TYPES: string[] = [\n\t\"config.lock\",\n\t\"config.unlock\",\n\t\"config.drift\",\n\t\"bypass.create\",\n\t\"bypass.expire\",\n\t\"rule.change\",\n];\n\n/**\n * Citty command definition for `forge-ts audit`.\n *\n * @public\n */\nexport const auditCommand = defineCommand({\n\tmeta: {\n\t\tname: \"audit\",\n\t\tdescription: \"Display the forge-ts audit trail\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tlimit: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Maximum events to display (default: 20)\",\n\t\t},\n\t\ttype: {\n\t\t\ttype: \"string\",\n\t\t\tdescription:\n\t\t\t\t\"Filter by event type (config.lock, config.unlock, config.drift, bypass.create, bypass.expire, rule.change)\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\trun({ args }) {\n\t\t// Validate --type if provided\n\t\tconst eventType = args.type as AuditEventType | undefined;\n\t\tif (eventType && !VALID_EVENT_TYPES.includes(eventType)) {\n\t\t\tconsole.error(\n\t\t\t\t`Error: invalid event type \"${eventType}\". Valid types: ${VALID_EVENT_TYPES.join(\", \")}`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst output = runAudit({\n\t\t\tcwd: args.cwd,\n\t\t\tlimit: args.limit ? Number.parseInt(args.limit, 10) : undefined,\n\t\t\ttype: eventType,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatAuditHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * Central output layer for forge-ts CLI.\n *\n * Wraps all command results in LAFS envelopes for agent-first output, while\n * preserving human-readable formatting for TTY consumers.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport {\n\tcreateEnvelope,\n\ttype MVILevel,\n\tresolveFlags,\n\ttype UnifiedFlagInput,\n} from \"@cleocode/lafs-protocol\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/** Typed result from a forge-ts command. */\nexport interface CommandOutput<T> {\n\t/** Name of the command that produced this output (e.g., \"check\", \"build\"). */\n\toperation: string;\n\t/** Whether the command completed successfully. */\n\tsuccess: boolean;\n\t/** Strongly-typed command-specific result payload. */\n\tdata: T;\n\t/** Structured errors produced by the command, if any. */\n\terrors?: ForgeCliError[];\n\t/** Structured warnings produced by the command, if any. */\n\twarnings?: ForgeCliWarning[];\n\t/** Wall-clock duration of the command in milliseconds. */\n\tduration?: number;\n}\n\n/** Structured error for CLI commands. */\nexport interface ForgeCliError {\n\t/** Machine-readable error code (e.g., \"E004\"). */\n\tcode: string;\n\t/** Human-readable error description. */\n\tmessage: string;\n\t/** Absolute path to the source file containing the error, if applicable. */\n\tfilePath?: string;\n\t/** 1-based line number of the error, if applicable. */\n\tline?: number;\n\t/** 0-based column number of the error, if applicable. */\n\tcolumn?: number;\n}\n\n/** Structured warning for CLI commands. */\nexport interface ForgeCliWarning {\n\t/** Machine-readable warning code. */\n\tcode: string;\n\t/** Human-readable warning description. */\n\tmessage: string;\n\t/** Absolute path to the source file containing the warning, if applicable. */\n\tfilePath?: string;\n\t/** 1-based line number of the warning, if applicable. */\n\tline?: number;\n\t/** 0-based column number of the warning, if applicable. */\n\tcolumn?: number;\n}\n\n/** Output format flags passed through from citty args. */\nexport interface OutputFlags {\n\t/** Emit output as a LAFS JSON envelope instead of human-readable text. */\n\tjson?: boolean;\n\t/** Emit output as formatted human-readable text. */\n\thuman?: boolean;\n\t/** Suppress all output regardless of format. */\n\tquiet?: boolean;\n\t/** MVI verbosity level: \"minimal\", \"standard\", or \"full\". */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// emitResult\n// ---------------------------------------------------------------------------\n\n/**\n * Wraps a command result in a LAFS envelope and emits it.\n *\n * Output format is determined by LAFS flag resolution:\n * - TTY terminals default to human-readable output.\n * - Non-TTY (piped, CI, agents) defaults to JSON.\n * - Explicit `--json` or `--human` flags always take precedence.\n *\n * On failure, the full result is included alongside the error so agents\n * get actionable data (e.g., suggestedFix) in a single response.\n *\n * @param output - Typed result from the command.\n * @param flags - Output format flags from citty args.\n * @param humanFormatter - Produces a human-readable string for TTY consumers.\n * @example\n * ```typescript\n * import { emitResult } from \"@forge-ts/cli/output\";\n * emitResult(output, { human: true }, (data) => `Done: ${data.summary.duration}ms`);\n * ```\n * @internal\n */\nexport function emitResult<T>(\n\toutput: CommandOutput<T>,\n\tflags: OutputFlags,\n\thumanFormatter: (data: T, output: CommandOutput<T>) => string,\n): void {\n\tconst flagInput: UnifiedFlagInput = {\n\t\tjson: flags.json,\n\t\thuman: flags.human,\n\t\tquiet: flags.quiet,\n\t\tmvi: flags.mvi,\n\t\t// LAFS 1.8.0: TTY detection drives the default format.\n\t\t// Terminals get human output, pipes/agents get JSON.\n\t\ttty: process.stdout.isTTY ?? false,\n\t};\n\n\tconst resolved = resolveFlags(flagInput);\n\tconst format = resolved.format.format;\n\tconst quiet = resolved.format.quiet;\n\n\tif (quiet) {\n\t\treturn;\n\t}\n\n\tconst meta = {\n\t\toperation: `forge-ts.${output.operation}`,\n\t\trequestId: randomUUID(),\n\t\ttransport: \"cli\" as const,\n\t\tmvi: (flags.mvi as MVILevel) ?? \"full\",\n\t};\n\n\t// Include warnings in the result so agents see them in the JSON envelope.\n\t// Config warnings (unknown keys, invalid rules) go to stderr for TTY\n\t// consumers but agents in non-TTY contexts only see the JSON envelope.\n\tconst resultData = output.data as Record<string, unknown>;\n\tif (output.warnings && output.warnings.length > 0) {\n\t\tresultData._warnings = output.warnings.map((w) => ({\n\t\t\tcode: w.code,\n\t\t\tmessage: w.message,\n\t\t}));\n\t}\n\n\t// LAFS 1.8.0: result is included on error envelopes so agents get\n\t// actionable data (byFile, suggestedFix) alongside error metadata.\n\tconst envelope = output.success\n\t\t? createEnvelope({\n\t\t\t\tsuccess: true,\n\t\t\t\tresult: resultData,\n\t\t\t\tmeta,\n\t\t\t})\n\t\t: createEnvelope({\n\t\t\t\tsuccess: false,\n\t\t\t\tresult: resultData,\n\t\t\t\terror: {\n\t\t\t\t\tcode: output.errors?.[0]?.code ?? \"FORGE_CHECK_FAILED\",\n\t\t\t\t\tmessage: output.errors?.[0]?.message ?? \"Check failed — see result for actionable fixes\",\n\t\t\t\t\tcategory: \"VALIDATION\",\n\t\t\t\t\tretryable: true,\n\t\t\t\t\tretryAfterMs: null,\n\t\t\t\t},\n\t\t\t\tmeta,\n\t\t\t});\n\n\tif (format === \"json\") {\n\t\tprocess.stdout.write(`${JSON.stringify(envelope, null, 2)}\\n`);\n\t} else {\n\t\tconst formatted = humanFormatter(output.data, output);\n\t\tif (formatted) {\n\t\t\tconsole.log(formatted);\n\t\t}\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// resolveExitCode\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the LAFS-compliant exit code for a command output.\n *\n * @param output - Typed result from the command.\n * @returns `0` on success, `1` on validation/check failure.\n * @internal\n */\nexport function resolveExitCode(output: CommandOutput<unknown>): number {\n\tif (output.success) return 0;\n\treturn 1;\n}\n","import { generateApi } from \"@forge-ts/api\";\nimport { loadConfig } from \"@forge-ts/core\";\nimport { generate } from \"@forge-ts/gen\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\n\n/**\n * Arguments for the `build` command.\n * @internal\n */\nexport interface BuildArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Skip API generation even if enabled in config. */\n\tskipApi?: boolean;\n\t/** Skip doc generation even if enabled in config. */\n\tskipGen?: boolean;\n\t/**\n\t * Overwrite stub pages even if they already exist on disk.\n\t * Normally stub pages (concepts, guides, faq, contributing, changelog)\n\t * are only created on the first build to preserve manual edits.\n\t * Use this to reset stubs to their scaffolding state.\n\t */\n\tforceStubs?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n/**\n * A single step in the build pipeline.\n * @public\n */\nexport interface BuildStep {\n\t/** Internal step name, e.g. \"api\" or \"gen\". */\n\tname: string;\n\t/** Outcome of this step. */\n\tstatus: \"success\" | \"skipped\" | \"failed\";\n\t/** Path to the primary output file produced by this step, if applicable. */\n\toutputPath?: string;\n\t/** Wall-clock duration of this step in milliseconds. */\n\tduration?: number;\n\t/** Errors produced by this step when status is \"failed\". */\n\terrors?: ForgeCliError[];\n}\n\n/**\n * Typed result for the `build` command.\n * @public\n */\nexport interface BuildResult {\n\t/** Whether the build succeeded. */\n\tsuccess: boolean;\n\t/** Aggregate pipeline counts — always present. */\n\tsummary: {\n\t\t/** Total number of pipeline steps. */\n\t\tsteps: number;\n\t\t/** Steps that completed successfully. */\n\t\tsucceeded: number;\n\t\t/** Steps that failed. */\n\t\tfailed: number;\n\t\t/** Wall-clock duration in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Per-step details. */\n\tsteps: BuildStep[];\n\t/** Files written during the build — present at standard and full MVI levels. */\n\tgeneratedFiles?: string[];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the full build pipeline and returns a typed command output.\n *\n * @param args - CLI arguments for the build command.\n * @returns A typed `CommandOutput<BuildResult>`.\n * @example\n * ```typescript\n * import { runBuild } from \"@forge-ts/cli/commands/build\";\n * const output = await runBuild({ cwd: process.cwd() });\n * console.log(output.success); // true if all steps succeeded\n * ```\n * @public\n */\nexport async function runBuild(args: BuildArgs): Promise<CommandOutput<BuildResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst buildStart = Date.now();\n\tconst mviLevel = args.mvi ?? \"standard\";\n\n\tconst steps: BuildStep[] = [];\n\tconst allErrors: ForgeCliError[] = [];\n\tconst generatedFiles: string[] = [];\n\tlet success = true;\n\n\tif (config.api.enabled && !args.skipApi) {\n\t\tconst result = await generateApi(config);\n\t\tif (!result.success) {\n\t\t\tconst errors: ForgeCliError[] = result.errors.map((e) => ({\n\t\t\t\tcode: e.code,\n\t\t\t\tmessage: e.message,\n\t\t\t\tfilePath: e.filePath,\n\t\t\t\tline: e.line,\n\t\t\t\tcolumn: e.column,\n\t\t\t}));\n\t\t\tallErrors.push(...errors);\n\t\t\tsuccess = false;\n\t\t\tsteps.push({\n\t\t\t\tname: \"api\",\n\t\t\t\tstatus: \"failed\",\n\t\t\t\toutputPath: config.api.openapiPath,\n\t\t\t\tduration: result.duration,\n\t\t\t\terrors,\n\t\t\t});\n\t\t} else {\n\t\t\tsteps.push({\n\t\t\t\tname: \"api\",\n\t\t\t\tstatus: \"success\",\n\t\t\t\toutputPath: config.api.openapiPath,\n\t\t\t\tduration: result.duration,\n\t\t\t});\n\t\t\tgeneratedFiles.push(config.api.openapiPath);\n\t\t}\n\t} else if (!config.api.enabled || args.skipApi) {\n\t\tsteps.push({ name: \"api\", status: \"skipped\" });\n\t}\n\n\tif (config.gen.enabled && !args.skipGen) {\n\t\tconst result = await generate(config, { forceStubs: args.forceStubs });\n\t\tif (!result.success) {\n\t\t\tconst errors: ForgeCliError[] = result.errors.map((e) => ({\n\t\t\t\tcode: e.code,\n\t\t\t\tmessage: e.message,\n\t\t\t\tfilePath: e.filePath,\n\t\t\t\tline: e.line,\n\t\t\t\tcolumn: e.column,\n\t\t\t}));\n\t\t\tallErrors.push(...errors);\n\t\t\tsuccess = false;\n\t\t\tsteps.push({\n\t\t\t\tname: \"gen\",\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tduration: result.duration,\n\t\t\t\terrors,\n\t\t\t});\n\t\t} else {\n\t\t\tsteps.push({\n\t\t\t\tname: \"gen\",\n\t\t\t\tstatus: \"success\",\n\t\t\t\tduration: result.duration,\n\t\t\t});\n\t\t\tif (result.writtenFiles) {\n\t\t\t\tgeneratedFiles.push(...result.writtenFiles);\n\t\t\t}\n\t\t}\n\t} else if (!config.gen.enabled || args.skipGen) {\n\t\tsteps.push({ name: \"gen\", status: \"skipped\" });\n\t}\n\n\tconst totalMs = Date.now() - buildStart;\n\n\tconst succeededCount = steps.filter((s) => s.status === \"success\").length;\n\tconst failedCount = steps.filter((s) => s.status === \"failed\").length;\n\n\tconst data: BuildResult = {\n\t\tsuccess,\n\t\tsummary: {\n\t\t\tsteps: steps.length,\n\t\t\tsucceeded: succeededCount,\n\t\t\tfailed: failedCount,\n\t\t\tduration: totalMs,\n\t\t},\n\t\tsteps,\n\t};\n\n\tif (mviLevel !== \"minimal\") {\n\t\tdata.generatedFiles = generatedFiles;\n\t}\n\n\tconst cliWarnings = config._configWarnings?.map((msg) => ({\n\t\tcode: \"CONFIG_WARNING\",\n\t\tmessage: msg,\n\t\tfilePath: \"\",\n\t\tline: 0,\n\t\tcolumn: 0,\n\t}));\n\n\treturn {\n\t\toperation: \"build\",\n\t\tsuccess,\n\t\tdata,\n\t\terrors: allErrors,\n\t\twarnings: cliWarnings,\n\t\tduration: totalMs,\n\t};\n}\n\n/**\n * Citty command definition for `forge-ts build`.\n * @public\n */\nexport const buildCommand = defineCommand({\n\tmeta: {\n\t\tname: \"build\",\n\t\tdescription: \"Generate API reference and documentation\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\t\"skip-api\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip OpenAPI generation\",\n\t\t\tdefault: false,\n\t\t},\n\t\t\"skip-gen\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip doc generation\",\n\t\t\tdefault: false,\n\t\t},\n\t\t\"force-stubs\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Overwrite stub pages even if they exist (reset to scaffolding)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runBuild({\n\t\t\tcwd: args.cwd,\n\t\t\tskipApi: args[\"skip-api\"],\n\t\t\tskipGen: args[\"skip-gen\"],\n\t\t\tforceStubs: args[\"force-stubs\"],\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data) => {\n\t\t\tconst logger = createLogger();\n\t\t\tfor (const step of data.steps) {\n\t\t\t\tif (step.status === \"failed\") {\n\t\t\t\t\tfor (const err of step.errors ?? []) {\n\t\t\t\t\t\tlogger.error(`[${step.name}] ${err.message}`);\n\t\t\t\t\t}\n\t\t\t\t} else if (step.status === \"success\") {\n\t\t\t\t\tconst detail =\n\t\t\t\t\t\tstep.name === \"api\" && step.outputPath != null\n\t\t\t\t\t\t\t? `Generated OpenAPI spec \\u2192 ${step.outputPath}`\n\t\t\t\t\t\t\t: `Step complete`;\n\t\t\t\t\tlogger.step(step.name.toUpperCase(), detail, step.duration);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (output.success) {\n\t\t\t\treturn ` Done in ${data.summary.duration}ms`;\n\t\t\t}\n\t\t\treturn \"\";\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * Simple TTY-aware logger for forge-ts CLI output.\n *\n * Uses ANSI escape codes directly — no external colour library.\n *\n * @packageDocumentation\n * @internal\n */\n\n// ---------------------------------------------------------------------------\n// ANSI constants\n// ---------------------------------------------------------------------------\n\nconst GREEN = \"\\x1b[32m\";\nconst YELLOW = \"\\x1b[33m\";\nconst RED = \"\\x1b[31m\";\nconst BOLD = \"\\x1b[1m\";\nconst RESET = \"\\x1b[0m\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * A minimal structured logger used throughout the CLI commands.\n * @internal\n */\nexport interface Logger {\n\t/** Print an informational message. */\n\tinfo(msg: string): void;\n\t/** Print a success message (green ✓ prefix when colours are on). */\n\tsuccess(msg: string): void;\n\t/** Print a warning message (yellow prefix when colours are on). */\n\twarn(msg: string): void;\n\t/** Print an error message (red ✗ prefix when colours are on). */\n\terror(msg: string): void;\n\t/**\n\t * Print a build-step line.\n\t *\n\t * @param label - Short category label (e.g. \"API\", \"Gen\").\n\t * @param detail - Description of what was produced.\n\t * @param duration - Optional wall-clock time in milliseconds.\n\t */\n\tstep(label: string, detail: string, duration?: number): void;\n}\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a {@link Logger} instance.\n *\n * @param options - Optional configuration.\n * @param options.colors - Emit ANSI colour codes. Defaults to `process.stdout.isTTY`.\n * @returns A configured logger.\n * @internal\n */\nexport function createLogger(options?: { colors?: boolean }): Logger {\n\tconst useColors = options?.colors ?? process.stdout.isTTY ?? false;\n\n\tfunction colorize(text: string, code: string): string {\n\t\treturn useColors ? `${code}${text}${RESET}` : text;\n\t}\n\n\tfunction bold(text: string): string {\n\t\treturn useColors ? `${BOLD}${text}${RESET}` : text;\n\t}\n\n\treturn {\n\t\tinfo(msg: string): void {\n\t\t\tconsole.log(msg);\n\t\t},\n\n\t\tsuccess(msg: string): void {\n\t\t\tconst prefix = colorize(\"✓\", GREEN);\n\t\t\tconsole.log(`${prefix} ${msg}`);\n\t\t},\n\n\t\twarn(msg: string): void {\n\t\t\tconst prefix = colorize(\"warn\", YELLOW);\n\t\t\tconsole.warn(`${bold(prefix)} ${msg}`);\n\t\t},\n\n\t\terror(msg: string): void {\n\t\t\tconst prefix = colorize(\"error\", RED);\n\t\t\tconsole.error(`${bold(prefix)} ${msg}`);\n\t\t},\n\n\t\tstep(label: string, detail: string, duration?: number): void {\n\t\t\tconst check = colorize(\"✓\", GREEN);\n\t\t\tconst durationStr = duration !== undefined ? ` (${duration}ms)` : \"\";\n\t\t\tconsole.log(` ${check} ${bold(label)}: ${detail}${durationStr}`);\n\t\t},\n\t};\n}\n","/**\n * `forge-ts bypass` command — create or inspect temporary rule bypasses.\n *\n * Bypasses allow agents to temporarily override locked rules with a limited\n * daily budget. Each bypass requires a mandatory `--reason` flag and expires\n * after a configurable duration.\n *\n * Usage:\n * forge-ts bypass --reason=\"hotfix for release\" [--rule E009]\n * forge-ts bypass --status\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\ttype BypassRecord,\n\tcreateBypass,\n\texpireOldBypasses,\n\tgetActiveBypasses,\n\tgetRemainingBudget,\n\tloadConfig,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `bypass` command when creating a bypass.\n * @public\n */\nexport interface BypassCreateResult {\n\t/** Whether the bypass was successfully created. */\n\tsuccess: boolean;\n\t/** The bypass record that was created. */\n\tbypass: BypassRecord;\n\t/** Number of remaining bypass slots for today after creation. */\n\tremainingBudget: number;\n\t/** The configured daily budget. */\n\tdailyBudget: number;\n}\n\n/**\n * Typed result for the `bypass --status` command.\n * @public\n */\nexport interface BypassStatusResult {\n\t/** Always true for status queries. */\n\tsuccess: boolean;\n\t/** Active (non-expired) bypass records. */\n\tactiveBypasses: BypassRecord[];\n\t/** Number of remaining bypass slots for today. */\n\tremainingBudget: number;\n\t/** The configured daily budget. */\n\tdailyBudget: number;\n\t/** Number of expired bypasses that were cleaned up. */\n\texpiredRemoved: number;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the bypass creation: creates a new bypass record with budget enforcement.\n *\n * @param args - CLI arguments for the bypass command.\n * @returns A typed `CommandOutput<BypassCreateResult>`.\n * @example\n * ```typescript\n * import { runBypassCreate } from \"@forge-ts/cli/commands/bypass\";\n * const output = await runBypassCreate({\n * cwd: process.cwd(),\n * reason: \"hotfix for release\",\n * rule: \"E009\",\n * });\n * console.log(output.data.remainingBudget);\n * ```\n * @public\n */\nexport async function runBypassCreate(args: {\n\tcwd?: string;\n\treason: string;\n\trule?: string;\n}): Promise<CommandOutput<BypassCreateResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\t// Clean up expired bypasses first\n\texpireOldBypasses(rootDir);\n\n\ttry {\n\t\tconst bypass = createBypass(rootDir, args.reason, args.rule, config.bypass);\n\t\tconst remainingBudget = getRemainingBudget(rootDir, config.bypass);\n\n\t\treturn {\n\t\t\toperation: \"bypass\",\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\tsuccess: true,\n\t\t\t\tbypass,\n\t\t\t\tremainingBudget,\n\t\t\t\tdailyBudget: config.bypass.dailyBudget,\n\t\t\t},\n\t\t\tduration: 0,\n\t\t};\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\treturn {\n\t\t\toperation: \"bypass\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\tbypass: {} as BypassRecord,\n\t\t\t\tremainingBudget: 0,\n\t\t\t\tdailyBudget: config.bypass.dailyBudget,\n\t\t\t},\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_BYPASS_BUDGET_EXHAUSTED\",\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t],\n\t\t\tduration: 0,\n\t\t};\n\t}\n}\n\n/**\n * Runs the bypass status query: shows active bypasses and remaining budget.\n *\n * @param args - CLI arguments for the bypass status command.\n * @returns A typed `CommandOutput<BypassStatusResult>`.\n * @example\n * ```typescript\n * import { runBypassStatus } from \"@forge-ts/cli/commands/bypass\";\n * const output = await runBypassStatus({ cwd: process.cwd() });\n * console.log(output.data.activeBypasses.length);\n * ```\n * @public\n */\nexport async function runBypassStatus(args: {\n\tcwd?: string;\n}): Promise<CommandOutput<BypassStatusResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\t// Clean up expired bypasses first\n\tconst expiredRemoved = expireOldBypasses(rootDir);\n\tconst activeBypasses = getActiveBypasses(rootDir);\n\tconst remainingBudget = getRemainingBudget(rootDir, config.bypass);\n\n\treturn {\n\t\toperation: \"bypass\",\n\t\tsuccess: true,\n\t\tdata: {\n\t\t\tsuccess: true,\n\t\t\tactiveBypasses,\n\t\t\tremainingBudget,\n\t\t\tdailyBudget: config.bypass.dailyBudget,\n\t\t\texpiredRemoved,\n\t\t},\n\t\tduration: 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatters\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a BypassCreateResult as human-readable text.\n * @internal\n */\nfunction formatBypassCreateHuman(result: BypassCreateResult): string {\n\tconst lines: string[] = [];\n\n\tif (!result.success) {\n\t\tlines.push(\"forge-ts bypass: FAILED\\n\");\n\t\tlines.push(\" Daily bypass budget exhausted.\");\n\t\tlines.push(` Budget: 0/${result.dailyBudget} remaining`);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\"forge-ts bypass: created\\n\");\n\tlines.push(` ID: ${result.bypass.id}`);\n\tlines.push(` Rule: ${result.bypass.rule}`);\n\tlines.push(` Reason: ${result.bypass.reason}`);\n\tlines.push(` Expires: ${result.bypass.expiresAt}`);\n\tlines.push(` User: ${result.bypass.user}`);\n\tlines.push(`\\n Budget: ${result.remainingBudget}/${result.dailyBudget} remaining today`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Formats a BypassStatusResult as human-readable text.\n * @internal\n */\nfunction formatBypassStatusHuman(result: BypassStatusResult): string {\n\tconst lines: string[] = [];\n\n\tlines.push(\"forge-ts bypass: status\\n\");\n\tlines.push(` Budget: ${result.remainingBudget}/${result.dailyBudget} remaining today`);\n\n\tif (result.expiredRemoved > 0) {\n\t\tlines.push(` Cleaned up ${result.expiredRemoved} expired bypass(es)`);\n\t}\n\n\tif (result.activeBypasses.length === 0) {\n\t\tlines.push(\"\\n No active bypasses.\");\n\t} else {\n\t\tlines.push(`\\n Active bypasses (${result.activeBypasses.length}):`);\n\t\tfor (const b of result.activeBypasses) {\n\t\t\tlines.push(` - [${b.rule}] ${b.reason} (expires ${b.expiresAt})`);\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts bypass`.\n * @public\n */\nexport const bypassCommand = defineCommand({\n\tmeta: {\n\t\tname: \"bypass\",\n\t\tdescription: \"Create or inspect temporary rule bypasses\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\treason: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Mandatory justification for bypassing rules\",\n\t\t},\n\t\trule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: 'Specific rule code to bypass (e.g., \"E009\"). Defaults to \"all\"',\n\t\t},\n\t\tstatus: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Show active bypasses and remaining budget\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\t// --status mode: show active bypasses\n\t\tif (args.status) {\n\t\t\tconst output = await runBypassStatus({ cwd: args.cwd });\n\t\t\temitResult(output, flags, (data) => formatBypassStatusHuman(data));\n\t\t\tprocess.exit(resolveExitCode(output));\n\t\t\treturn;\n\t\t}\n\n\t\t// Create mode: --reason is required\n\t\tif (!args.reason) {\n\t\t\tconsole.error(\n\t\t\t\t\"[forge-ts] error: --reason is required. Provide a justification for the bypass.\",\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst output = await runBypassCreate({\n\t\t\tcwd: args.cwd,\n\t\t\treason: args.reason,\n\t\t\trule: args.rule,\n\t\t});\n\n\t\temitResult(output, flags, (data) => formatBypassCreateHuman(data));\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","import { type ForgeError, type ForgeWarning, loadConfig } from \"@forge-ts/core\";\nimport { enforce } from \"@forge-ts/enforcer\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n/**\n * Arguments for the `check` command.\n * @internal\n */\nexport interface CheckArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Exit with non-zero code on warnings as well as errors. */\n\tstrict?: boolean;\n\t/** Include symbol signatures alongside diagnostics. */\n\tverbose?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n\t/** Filter errors to a specific rule code (e.g., \"E001\"). */\n\trule?: string;\n\t/** Filter errors to a specific file path (substring match). */\n\tfile?: string;\n\t/** Maximum number of file groups to return in byFile (default: 20). */\n\tlimit?: number;\n\t/** Offset into the byFile list for pagination (default: 0). */\n\toffset?: number;\n}\n\n/**\n * A single error entry within a file group.\n * @public\n */\nexport interface CheckFileError {\n\t/** Machine-readable error code. */\n\tcode: string;\n\t/** Symbol name that needs fixing. */\n\tsymbol: string;\n\t/** Symbol kind (function, class, interface, etc.). */\n\tkind: string;\n\t/** 1-based line number of the error. */\n\tline: number;\n\t/** Human-readable description. */\n\tmessage: string;\n\t/** Exact TSDoc block to add (present at full MVI or with --rule/--file filters). */\n\tsuggestedFix?: string;\n\t/** Recommended agent action. */\n\tagentAction?: string;\n}\n\n/**\n * A single warning entry within a file group.\n * @public\n */\nexport interface CheckFileWarning {\n\t/** Machine-readable warning code. */\n\tcode: string;\n\t/** Symbol name that generated the warning. */\n\tsymbol: string;\n\t/** Symbol kind (function, class, interface, etc.). */\n\tkind: string;\n\t/** 1-based line number of the warning. */\n\tline: number;\n\t/** Human-readable description. */\n\tmessage: string;\n}\n\n/**\n * Errors and warnings grouped by file.\n * @public\n */\nexport interface CheckFileGroup {\n\t/** Absolute path to the source file. */\n\tfile: string;\n\t/** Errors in this file. */\n\terrors: CheckFileError[];\n\t/** Warnings in this file. */\n\twarnings: CheckFileWarning[];\n}\n\n/**\n * Error breakdown by rule code, sorted by count descending.\n * @public\n */\nexport interface CheckRuleCount {\n\t/** Machine-readable rule code (e.g., \"E001\"). */\n\tcode: string;\n\t/** Human-readable rule name (e.g., \"require-summary\"). */\n\trule: string;\n\t/** Number of violations. */\n\tcount: number;\n\t/** Number of unique files affected by this rule. */\n\tfiles: number;\n}\n\n/**\n * Triage data for prioritizing fixes.\n * Always present when the check has errors, bounded in size (~9 rules + top 20 files).\n * @public\n */\nexport interface CheckTriage {\n\t/** Error counts by rule, sorted descending. */\n\tbyRule: CheckRuleCount[];\n\t/** Top files by error count (max 20). */\n\ttopFiles: Array<{ file: string; errors: number; warnings: number }>;\n\t/** Suggested fix order: rules sorted by fewest files affected first (quick wins). */\n\tfixOrder: Array<{ code: string; rule: string; count: number; files: number }>;\n}\n\n/**\n * Pagination metadata for byFile results.\n * @public\n */\nexport interface CheckPage {\n\t/** Current offset. */\n\toffset: number;\n\t/** Page size. */\n\tlimit: number;\n\t/** Whether more results exist beyond this page. */\n\thasMore: boolean;\n\t/** Total number of file groups (after filters). */\n\ttotal: number;\n}\n\n/**\n * Typed result for the `check` command.\n * @public\n */\nexport interface CheckResult {\n\t/** Whether the check passed without errors. */\n\tsuccess: boolean;\n\t/** Aggregate counts — always present regardless of MVI level. */\n\tsummary: {\n\t\t/** Total number of errors. */\n\t\terrors: number;\n\t\t/** Total number of warnings. */\n\t\twarnings: number;\n\t\t/** Number of unique files with diagnostics. */\n\t\tfiles: number;\n\t\t/** Number of exported symbols checked. */\n\t\tsymbols: number;\n\t\t/** Wall-clock duration in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Triage data for prioritizing fixes — present when errors > 0 (except minimal). */\n\ttriage?: CheckTriage;\n\t/** Per-file breakdown — present at standard and full MVI levels, paginated. */\n\tbyFile?: CheckFileGroup[];\n\t/** Pagination metadata when byFile is paginated. */\n\tpage?: CheckPage;\n\t/** Active filters applied to this result. */\n\tfilters?: { rule?: string; file?: string };\n\t/** CLI command hint for the agent to run next. */\n\tnextCommand?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Rule code → name mapping\n// ---------------------------------------------------------------------------\n\nconst RULE_NAMES: Record<string, string> = {\n\tE001: \"require-summary\",\n\tE002: \"require-param\",\n\tE003: \"require-returns\",\n\tE004: \"require-example\",\n\tE005: \"require-package-doc\",\n\tE006: \"require-class-member-doc\",\n\tE007: \"require-interface-member-doc\",\n\tE008: \"require-link-target\",\n\tW004: \"deprecated-cross-import\",\n};\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Computes triage data from the full (unfiltered) error/warning set.\n * Bounded output: max 9 rules + top 20 files.\n * @internal\n */\nfunction computeTriage(errors: ForgeError[], warnings: ForgeWarning[]): CheckTriage {\n\t// byRule: count per code with file count\n\tconst ruleMap = new Map<string, { count: number; files: Set<string> }>();\n\tfor (const e of errors) {\n\t\tconst entry = ruleMap.get(e.code) ?? { count: 0, files: new Set<string>() };\n\t\tentry.count++;\n\t\tentry.files.add(e.filePath);\n\t\truleMap.set(e.code, entry);\n\t}\n\tfor (const w of warnings) {\n\t\tconst entry = ruleMap.get(w.code) ?? { count: 0, files: new Set<string>() };\n\t\tentry.count++;\n\t\tentry.files.add(w.filePath);\n\t\truleMap.set(w.code, entry);\n\t}\n\n\tconst byRule: CheckRuleCount[] = Array.from(ruleMap.entries())\n\t\t.map(([code, { count, files }]) => ({\n\t\t\tcode,\n\t\t\trule: RULE_NAMES[code] ?? code,\n\t\t\tcount,\n\t\t\tfiles: files.size,\n\t\t}))\n\t\t.sort((a, b) => b.count - a.count);\n\n\t// topFiles: count errors/warnings per file, top 20\n\tconst fileMap = new Map<string, { errors: number; warnings: number }>();\n\tfor (const e of errors) {\n\t\tconst entry = fileMap.get(e.filePath) ?? { errors: 0, warnings: 0 };\n\t\tentry.errors++;\n\t\tfileMap.set(e.filePath, entry);\n\t}\n\tfor (const w of warnings) {\n\t\tconst entry = fileMap.get(w.filePath) ?? { errors: 0, warnings: 0 };\n\t\tentry.warnings++;\n\t\tfileMap.set(w.filePath, entry);\n\t}\n\tconst topFiles = Array.from(fileMap.entries())\n\t\t.map(([file, counts]) => ({ file, ...counts }))\n\t\t.sort((a, b) => b.errors - a.errors || a.file.localeCompare(b.file))\n\t\t.slice(0, 20);\n\n\t// fixOrder: rules sorted by fewest files (quick wins first)\n\tconst fixOrder = [...byRule].sort((a, b) => a.files - b.files || b.count - a.count);\n\n\treturn { byRule, topFiles, fixOrder };\n}\n\n/**\n * Filters errors/warnings by rule code and/or file path substring.\n * @internal\n */\nfunction applyFilters(\n\terrors: ForgeError[],\n\twarnings: ForgeWarning[],\n\tfilters: { rule?: string; file?: string },\n): { errors: ForgeError[]; warnings: ForgeWarning[] } {\n\tlet filteredErrors = errors;\n\tlet filteredWarnings = warnings;\n\n\tif (filters.rule) {\n\t\tconst r = filters.rule.toUpperCase();\n\t\tfilteredErrors = filteredErrors.filter((e) => e.code === r);\n\t\tfilteredWarnings = filteredWarnings.filter((w) => w.code === r);\n\t}\n\tif (filters.file) {\n\t\tconst f = filters.file;\n\t\tfilteredErrors = filteredErrors.filter((e) => e.filePath.includes(f));\n\t\tfilteredWarnings = filteredWarnings.filter((w) => w.filePath.includes(f));\n\t}\n\n\treturn { errors: filteredErrors, warnings: filteredWarnings };\n}\n\n/**\n * Groups errors and warnings by file path.\n * @internal\n */\nfunction groupByFile(\n\terrors: ForgeError[],\n\twarnings: ForgeWarning[],\n\tincludeFix: boolean,\n): CheckFileGroup[] {\n\tconst fileMap = new Map<string, CheckFileGroup>();\n\n\tfor (const e of errors) {\n\t\tconst fp = e.filePath ?? \"\";\n\t\tif (!fileMap.has(fp)) {\n\t\t\tfileMap.set(fp, { file: fp, errors: [], warnings: [] });\n\t\t}\n\t\tconst entry: CheckFileError = {\n\t\t\tcode: e.code,\n\t\t\tsymbol: e.symbolName ?? \"\",\n\t\t\tkind: e.symbolKind ?? \"\",\n\t\t\tline: e.line,\n\t\t\tmessage: e.message,\n\t\t};\n\t\tif (includeFix && e.suggestedFix !== undefined) {\n\t\t\tentry.suggestedFix = e.suggestedFix;\n\t\t\tentry.agentAction = \"retry_modified\";\n\t\t}\n\t\tfileMap.get(fp)?.errors.push(entry);\n\t}\n\n\tfor (const w of warnings) {\n\t\tconst fp = w.filePath ?? \"\";\n\t\tif (!fileMap.has(fp)) {\n\t\t\tfileMap.set(fp, { file: fp, errors: [], warnings: [] });\n\t\t}\n\t\tfileMap.get(fp)?.warnings.push({\n\t\t\tcode: w.code,\n\t\t\tsymbol: \"\",\n\t\t\tkind: \"\",\n\t\t\tline: w.line,\n\t\t\tmessage: w.message,\n\t\t});\n\t}\n\n\t// Deterministic sort: most errors first, then lexicographic path\n\treturn Array.from(fileMap.values()).sort(\n\t\t(a, b) => b.errors.length - a.errors.length || a.file.localeCompare(b.file),\n\t);\n}\n\n/**\n * Computes the next CLI command hint for the agent.\n * @internal\n */\nfunction computeNextCommand(\n\ttriage: CheckTriage,\n\tfilters: { rule?: string; file?: string },\n\tpage: CheckPage | undefined,\n\thasFilters: boolean,\n): string {\n\t// If paginated and has more, suggest next page\n\tif (page?.hasMore) {\n\t\tconst parts = [\"forge-ts check --mvi full\"];\n\t\tif (filters.rule) parts.push(`--rule ${filters.rule}`);\n\t\tif (filters.file) parts.push(`--file \"${filters.file}\"`);\n\t\tparts.push(`--limit ${page.limit} --offset ${page.offset + page.limit}`);\n\t\treturn parts.join(\" \");\n\t}\n\n\t// If no filters yet, suggest drilling into the quickest-win rule\n\tif (!hasFilters && triage.fixOrder.length > 0) {\n\t\tconst quickWin = triage.fixOrder[0];\n\t\treturn `forge-ts check --rule ${quickWin.code} --mvi full`;\n\t}\n\n\t// If filtered by rule, suggest re-checking after fixes\n\treturn \"forge-ts check --mvi minimal\";\n}\n\n/**\n * Builds a CheckResult with triage, filtering, pagination, and MVI differentiation.\n * @internal\n */\nfunction buildCheckResult(\n\trawErrors: ForgeError[],\n\trawWarnings: ForgeWarning[],\n\texportedSymbolCount: number,\n\tduration: number,\n\tsuccess: boolean,\n\tmviLevel: string,\n\tfilters: { rule?: string; file?: string },\n\tlimit: number,\n\toffset: number,\n): CheckResult {\n\tconst uniqueFiles = new Set([\n\t\t...rawErrors.map((e) => e.filePath),\n\t\t...rawWarnings.map((w) => w.filePath),\n\t]);\n\n\tconst summary = {\n\t\terrors: rawErrors.length,\n\t\twarnings: rawWarnings.length,\n\t\tfiles: uniqueFiles.size,\n\t\tsymbols: exportedSymbolCount,\n\t\tduration,\n\t};\n\n\tif (mviLevel === \"minimal\") {\n\t\treturn { success, summary };\n\t}\n\n\t// Triage: always computed from FULL unfiltered data (bounded by rule count + top 20)\n\tconst triage =\n\t\trawErrors.length > 0 || rawWarnings.length > 0\n\t\t\t? computeTriage(rawErrors, rawWarnings)\n\t\t\t: undefined;\n\n\t// Apply filters\n\tconst hasFilters = !!(filters.rule || filters.file);\n\tconst { errors: filteredErrors, warnings: filteredWarnings } = hasFilters\n\t\t? applyFilters(rawErrors, rawWarnings, filters)\n\t\t: { errors: rawErrors, warnings: rawWarnings };\n\n\t// Include suggestedFix at full MVI or when filters are active (targeted drill-down)\n\tconst includeFix = mviLevel === \"full\" || hasFilters;\n\n\t// Group and paginate\n\tconst allGroups = groupByFile(filteredErrors, filteredWarnings, includeFix);\n\tconst total = allGroups.length;\n\tconst pagedGroups = allGroups.slice(offset, offset + limit);\n\tconst hasMore = offset + limit < total;\n\n\tconst page: CheckPage = { offset, limit, hasMore, total };\n\n\tconst nextCommand = triage ? computeNextCommand(triage, filters, page, hasFilters) : undefined;\n\n\tconst result: CheckResult = {\n\t\tsuccess,\n\t\tsummary,\n\t\ttriage,\n\t\tbyFile: pagedGroups,\n\t\tpage,\n\t\tnextCommand,\n\t};\n\n\tif (hasFilters) {\n\t\tresult.filters = {\n\t\t\trule: filters.rule || undefined,\n\t\t\tfile: filters.file || undefined,\n\t\t};\n\t}\n\n\treturn result;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the TSDoc enforcement pass and returns a typed command output.\n *\n * @param args - CLI arguments for the check command.\n * @returns A typed `CommandOutput<CheckResult>`.\n * @example\n * ```typescript\n * import { runCheck } from \"@forge-ts/cli/commands/check\";\n * const output = await runCheck({ cwd: process.cwd() });\n * console.log(output.data.summary.errors); // number of TSDoc errors found\n * ```\n * @public\n */\nexport async function runCheck(args: CheckArgs): Promise<CommandOutput<CheckResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tif (args.strict !== undefined) {\n\t\tconfig.enforce.strict = args.strict;\n\t}\n\n\tconst result = await enforce(config);\n\t// Default to \"standard\" MVI — gives triage + paginated overview.\n\t// Agents drill into specific rules/files with --mvi full.\n\tconst mviLevel = args.mvi ?? \"standard\";\n\tconst limit = args.limit ?? 20;\n\tconst offset = args.offset ?? 0;\n\tconst filters = { rule: args.rule, file: args.file };\n\n\tconst exportedSymbolCount = result.symbols.filter((s) => s.exported).length;\n\n\tconst data = buildCheckResult(\n\t\tresult.errors,\n\t\tresult.warnings,\n\t\texportedSymbolCount,\n\t\tresult.duration,\n\t\tresult.success,\n\t\tmviLevel,\n\t\tfilters,\n\t\tlimit,\n\t\toffset,\n\t);\n\n\t// Populate top-level errors so the LAFS envelope error code is actionable.\n\tconst cliErrors = result.success\n\t\t? undefined\n\t\t: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_CHECK_FAILED\",\n\t\t\t\t\tmessage: `TSDoc coverage check failed: ${result.errors.length} error(s), ${result.warnings.length} warning(s) across ${data.summary.files} file(s)`,\n\t\t\t\t},\n\t\t\t];\n\n\t// Surface config warnings so agents see them in the JSON envelope\n\tconst cliWarnings = config._configWarnings?.map((msg) => ({\n\t\tcode: \"CONFIG_WARNING\",\n\t\tmessage: msg,\n\t\tfilePath: \"\",\n\t\tline: 0,\n\t\tcolumn: 0,\n\t}));\n\n\treturn {\n\t\toperation: \"check\",\n\t\tsuccess: result.success,\n\t\tdata,\n\t\terrors: cliErrors,\n\t\twarnings: cliWarnings,\n\t\tduration: result.duration,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a CheckResult as human-readable, actionable text.\n * @internal\n */\nfunction formatCheckHuman(result: CheckResult): string {\n\tconst lines: string[] = [];\n\n\tif (result.success) {\n\t\tlines.push(\n\t\t\t`forge-ts check: OK (${result.summary.symbols} symbol(s) checked, ${result.summary.duration}ms)`,\n\t\t);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\"forge-ts check: FAILED\\n\");\n\tlines.push(\n\t\t` ${result.summary.errors} error(s), ${result.summary.warnings} warning(s) across ${result.summary.files} file(s) (${result.summary.symbols} symbols checked)\\n`,\n\t);\n\n\t// Triage: rule breakdown\n\tif (result.triage) {\n\t\tlines.push(\" Rules:\");\n\t\tfor (const r of result.triage.byRule) {\n\t\t\tlines.push(` ${r.code} ${r.rule}: ${r.count} violation(s) in ${r.files} file(s)`);\n\t\t}\n\t\tlines.push(\"\");\n\n\t\tif (result.triage.fixOrder.length > 0) {\n\t\t\tconst qw = result.triage.fixOrder[0];\n\t\t\tlines.push(\n\t\t\t\t` Quick win: fix ${qw.code} (${qw.rule}) — ${qw.count} issue(s) in ${qw.files} file(s)`,\n\t\t\t);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\t// Active filters\n\tif (result.filters) {\n\t\tconst parts = [];\n\t\tif (result.filters.rule) parts.push(`rule=${result.filters.rule}`);\n\t\tif (result.filters.file) parts.push(`file=${result.filters.file}`);\n\t\tlines.push(` Filtered: ${parts.join(\", \")}`);\n\t\tlines.push(\"\");\n\t}\n\n\t// Per-file errors\n\tif (result.byFile && result.byFile.length > 0) {\n\t\tfor (const group of result.byFile) {\n\t\t\tif (group.errors.length > 0) {\n\t\t\t\tlines.push(` ${group.file} (${group.errors.length} error(s)):`);\n\t\t\t\tfor (const err of group.errors) {\n\t\t\t\t\tconst symbolPart = err.symbol\n\t\t\t\t\t\t? `${err.symbol} (${err.kind}:${err.line})`\n\t\t\t\t\t\t: `line ${err.line}`;\n\t\t\t\t\tlines.push(` ${err.code} ${symbolPart} — ${err.message}`);\n\t\t\t\t\tif (err.suggestedFix) {\n\t\t\t\t\t\tfor (const fixLine of err.suggestedFix.split(\"\\n\")) {\n\t\t\t\t\t\t\tlines.push(` ${fixLine}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (group.warnings.length > 0) {\n\t\t\t\tlines.push(` ${group.file} (${group.warnings.length} warning(s)):`);\n\t\t\t\tfor (const w of group.warnings) {\n\t\t\t\t\tlines.push(` ${w.code} line ${w.line} — ${w.message}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Pagination footer\n\tif (result.page?.hasMore) {\n\t\tlines.push(\n\t\t\t`\\n Showing ${result.page.offset + 1}-${result.page.offset + (result.byFile?.length ?? 0)} of ${result.page.total} file(s). Use --offset ${result.page.offset + result.page.limit} to see more.`,\n\t\t);\n\t}\n\n\t// Next command hint\n\tif (result.nextCommand) {\n\t\tlines.push(`\\n Next: ${result.nextCommand}`);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Citty command definition for `forge-ts check`.\n * @public\n */\nexport const checkCommand = defineCommand({\n\tmeta: {\n\t\tname: \"check\",\n\t\tdescription: \"Lint TSDoc coverage on exported symbols\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tstrict: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Treat warnings as errors\",\n\t\t\tdefault: false,\n\t\t},\n\t\tverbose: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Show detailed output\",\n\t\t\tdefault: false,\n\t\t},\n\t\trule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Filter by rule code (e.g., E001, W004)\",\n\t\t},\n\t\tfile: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Filter by file path (substring match)\",\n\t\t},\n\t\tlimit: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Max file groups in output (default: 20)\",\n\t\t},\n\t\toffset: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Skip N file groups for pagination (default: 0)\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runCheck({\n\t\t\tcwd: args.cwd,\n\t\t\tstrict: args.strict,\n\t\t\tverbose: args.verbose,\n\t\t\tmvi: args.mvi,\n\t\t\trule: args.rule,\n\t\t\tfile: args.file,\n\t\t\tlimit: args.limit ? parseInt(args.limit, 10) : undefined,\n\t\t\toffset: args.offset ? parseInt(args.offset, 10) : undefined,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatCheckHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * The `forge-ts docs dev` command — starts a local doc preview server.\n *\n * Reads the ssgTarget from forge-ts config, looks up the adapter,\n * and spawns the correct dev server automatically.\n *\n * @packageDocumentation\n * @public\n */\n\nimport { spawn } from \"node:child_process\";\nimport { resolve } from \"node:path\";\nimport { loadConfig } from \"@forge-ts/core\";\nimport { DEFAULT_TARGET, getAdapter, type SSGTarget } from \"@forge-ts/gen\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\n\n/**\n * Starts the local dev server for the configured SSG target.\n *\n * Reads `gen.ssgTarget` from the forge-ts config, resolves the adapter,\n * and spawns the platform's dev server in the output directory.\n *\n * @param args - Command arguments.\n * @returns A promise that resolves when the server exits.\n *\n * @example\n * ```typescript\n * import { runDocsDev } from \"@forge-ts/cli\";\n * await runDocsDev({ cwd: \"./my-project\" });\n * ```\n * @public\n */\nexport async function runDocsDev(args: {\n\t/** Project root directory. */\n\tcwd?: string;\n\t/** Override the SSG target from config. */\n\ttarget?: string;\n\t/** Port to run the dev server on. */\n\tport?: string;\n}): Promise<void> {\n\tconst logger = createLogger();\n\tconst config = await loadConfig(args.cwd);\n\tconst target = (args.target ?? config.gen.ssgTarget ?? DEFAULT_TARGET) as SSGTarget;\n\tconst adapter = getAdapter(target);\n\tconst outDir = resolve(config.outDir);\n\tconst devCmd = adapter.getDevCommand(outDir);\n\n\tlogger.info(`Starting ${devCmd.label}...`);\n\tlogger.info(` Target: ${target}`);\n\tlogger.info(` Directory: ${outDir}`);\n\tlogger.info(` URL: ${devCmd.url}`);\n\tlogger.info(\"\");\n\n\tconst spawnArgs = [...devCmd.args];\n\tif (args.port) {\n\t\tspawnArgs.push(\"--port\", args.port);\n\t}\n\n\tconst proc = spawn(devCmd.bin, spawnArgs, {\n\t\tcwd: devCmd.cwd,\n\t\tstdio: \"inherit\",\n\t\tshell: true,\n\t});\n\n\treturn new Promise<void>((_resolve, reject) => {\n\t\tproc.on(\"close\", (code) => {\n\t\t\tif (code === 0) {\n\t\t\t\t_resolve();\n\t\t\t} else {\n\t\t\t\treject(new Error(`${devCmd.label} exited with code ${code}`));\n\t\t\t}\n\t\t});\n\t\tproc.on(\"error\", reject);\n\t});\n}\n\n/**\n * Citty command definition for `forge-ts docs dev`.\n *\n * @example\n * ```typescript\n * import { docsDevCommand } from \"@forge-ts/cli\";\n * ```\n * @public\n */\nexport const docsDevCommand = defineCommand({\n\tmeta: {\n\t\tname: \"dev\",\n\t\tdescription: \"Start a local doc preview server\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\ttarget: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SSG target override (reads from config by default)\",\n\t\t},\n\t\tport: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Port for the dev server\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tawait runDocsDev(args);\n\t},\n});\n","import { existsSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { loadConfig } from \"@forge-ts/core\";\nimport {\n\ttype AdapterContext,\n\tDEFAULT_TARGET,\n\tgetAdapter,\n\tgetAvailableTargets,\n\ttype SSGTarget,\n} from \"@forge-ts/gen\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Result of the `init docs` command.\n *\n * @example\n * ```typescript\n * import { runInitDocs } from \"@forge-ts/cli/commands/init-docs\";\n * const output = await runInitDocs({ target: \"mintlify\" });\n * console.log(output.data.summary.filesCreated); // number of files written\n * ```\n * @public\n */\nexport interface InitDocsResult {\n\t/** Whether the scaffold succeeded. */\n\tsuccess: boolean;\n\t/** The SSG target that was scaffolded. */\n\ttarget: SSGTarget;\n\t/** Summary of what was created. */\n\tsummary: {\n\t\t/** Number of files written to disk. */\n\t\tfilesCreated: number;\n\t\t/** Number of npm dependencies declared by the adapter. */\n\t\tdependencies: number;\n\t\t/** Number of package.json scripts declared by the adapter. */\n\t\tscripts: number;\n\t};\n\t/** Relative paths of all files created. */\n\tfiles: string[];\n\t/** Post-scaffold instructions for the user. */\n\tinstructions: string[];\n}\n\n/**\n * Arguments for the `init docs` command.\n * @internal\n */\nexport interface InitDocsArgs {\n\t/** SSG target to scaffold. Defaults to {@link DEFAULT_TARGET}. */\n\ttarget?: string;\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Output directory for the doc site (default: outDir from config or ./docs). */\n\toutDir?: string;\n\t/** Overwrite an existing scaffold without prompting. */\n\tforce?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Scaffolds a documentation site for the target SSG platform.\n *\n * Resolves the target from args, validates it, checks for an existing\n * scaffold, calls the adapter's `scaffold()` method, and writes all files\n * produced by the manifest to `outDir`.\n *\n * @param args - CLI arguments for the init docs command.\n * @returns A typed `CommandOutput<InitDocsResult>`.\n * @example\n * ```typescript\n * import { runInitDocs } from \"@forge-ts/cli/commands/init-docs\";\n * const output = await runInitDocs({ target: \"mintlify\", cwd: process.cwd() });\n * console.log(output.data.files); // list of created file paths\n * ```\n * @public\n */\nexport async function runInitDocs(args: InitDocsArgs): Promise<CommandOutput<InitDocsResult>> {\n\tconst start = Date.now();\n\n\t// 1. Resolve target\n\tconst rawTarget = args.target ?? DEFAULT_TARGET;\n\tconst available = getAvailableTargets();\n\tif (!available.includes(rawTarget as SSGTarget)) {\n\t\tconst err: ForgeCliError = {\n\t\t\tcode: \"INIT_UNKNOWN_TARGET\",\n\t\t\tmessage: `Unknown SSG target \"${rawTarget}\". Available targets: ${available.join(\", \")}`,\n\t\t};\n\t\treturn {\n\t\t\toperation: \"init.docs\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\ttarget: DEFAULT_TARGET,\n\t\t\t\tsummary: { filesCreated: 0, dependencies: 0, scripts: 0 },\n\t\t\t\tfiles: [],\n\t\t\t\tinstructions: [],\n\t\t\t},\n\t\t\terrors: [err],\n\t\t\tduration: Date.now() - start,\n\t\t};\n\t}\n\n\tconst target = rawTarget as SSGTarget;\n\tconst adapter = getAdapter(target);\n\n\t// 2. Load config to resolve outDir\n\tconst config = await loadConfig(args.cwd);\n\tconst outDir = args.outDir ? resolve(args.outDir) : config.outDir;\n\n\t// 3. Safety check: detect existing scaffold\n\tconst alreadyExists = await adapter.detectExisting(outDir);\n\tif (alreadyExists && !args.force) {\n\t\tconst err: ForgeCliError = {\n\t\t\tcode: \"INIT_ALREADY_EXISTS\",\n\t\t\tmessage: `Docs already scaffolded for ${target}. Use --force to overwrite.`,\n\t\t};\n\t\treturn {\n\t\t\toperation: \"init.docs\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\ttarget,\n\t\t\t\tsummary: { filesCreated: 0, dependencies: 0, scripts: 0 },\n\t\t\t\tfiles: [],\n\t\t\t\tinstructions: [],\n\t\t\t},\n\t\t\terrors: [err],\n\t\t\tduration: Date.now() - start,\n\t\t};\n\t}\n\n\t// 4. Check for cross-target collision (any other adapter already scaffolded)\n\tconst warnings: Array<{ code: string; message: string }> = [];\n\tfor (const otherTarget of available) {\n\t\tif (otherTarget === target) continue;\n\t\tconst otherAdapter = getAdapter(otherTarget as SSGTarget);\n\t\tconst otherExists = await otherAdapter.detectExisting(outDir);\n\t\tif (otherExists) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"INIT_TARGET_MISMATCH\",\n\t\t\t\tmessage: `Existing scaffold detected for ${otherTarget} but scaffolding for ${target}. Remove conflicting files to avoid issues.`,\n\t\t\t});\n\t\t}\n\t}\n\n\t// 5. Build AdapterContext — use an empty pages/symbols array for init\n\tconst projectName = config.rootDir.split(\"/\").pop() ?? \"Project\";\n\tconst context: AdapterContext = {\n\t\tconfig,\n\t\tprojectName,\n\t\tpages: [],\n\t\tsymbols: [],\n\t\toutDir,\n\t};\n\n\t// 6. Call adapter.scaffold() to get the ScaffoldManifest\n\tconst manifest = adapter.scaffold(context);\n\n\t// 7. Write all files from the manifest\n\tconst writtenFiles: string[] = [];\n\tfor (const file of manifest.files) {\n\t\tconst filePath = join(outDir, file.path);\n\t\tconst fileDir = filePath.substring(0, filePath.lastIndexOf(\"/\"));\n\t\tawait mkdir(fileDir, { recursive: true });\n\t\tawait writeFile(filePath, file.content, \"utf8\");\n\t\twrittenFiles.push(file.path);\n\t}\n\n\t// 8. Write tsdoc.json to project root (extends @forge-ts/tsdoc-config preset)\n\tif (config.tsdoc.writeConfig) {\n\t\tconst tsdocPath = join(config.rootDir, \"tsdoc.json\");\n\t\tif (existsSync(tsdocPath)) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"INIT_TSDOC_EXISTS\",\n\t\t\t\tmessage: \"tsdoc.json already exists — skipping. Remove it and re-run to regenerate.\",\n\t\t\t});\n\t\t} else {\n\t\t\tconst tsdocContent = JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\t$schema: \"https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json\",\n\t\t\t\t\textends: [\"@forge-ts/tsdoc-config/tsdoc.json\"],\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t\"\\t\",\n\t\t\t);\n\t\t\tawait mkdir(config.rootDir, { recursive: true });\n\t\t\tawait writeFile(tsdocPath, `${tsdocContent}\\n`, \"utf8\");\n\t\t\twrittenFiles.push(\"tsdoc.json\");\n\t\t}\n\t}\n\n\tconst depCount =\n\t\tObject.keys(manifest.dependencies).length + Object.keys(manifest.devDependencies).length;\n\tconst scriptCount = Object.keys(manifest.scripts).length;\n\n\tconst data: InitDocsResult = {\n\t\tsuccess: true,\n\t\ttarget,\n\t\tsummary: {\n\t\t\tfilesCreated: writtenFiles.length,\n\t\t\tdependencies: depCount,\n\t\t\tscripts: scriptCount,\n\t\t},\n\t\tfiles: writtenFiles,\n\t\tinstructions: manifest.instructions,\n\t};\n\n\treturn {\n\t\toperation: \"init.docs\",\n\t\tsuccess: true,\n\t\tdata,\n\t\twarnings:\n\t\t\twarnings.length > 0\n\t\t\t\t? warnings.map((w) => ({\n\t\t\t\t\t\tcode: w.code,\n\t\t\t\t\t\tmessage: w.message,\n\t\t\t\t\t\tfilePath: \"\",\n\t\t\t\t\t\tline: 0,\n\t\t\t\t\t\tcolumn: 0,\n\t\t\t\t\t}))\n\t\t\t\t: undefined,\n\t\tduration: Date.now() - start,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an InitDocsResult as human-readable text.\n * @internal\n */\nfunction formatInitDocsHuman(result: InitDocsResult): string {\n\tconst lines: string[] = [];\n\n\tif (!result.success) {\n\t\treturn \"\";\n\t}\n\n\tconst targetName = result.target.charAt(0).toUpperCase() + result.target.slice(1);\n\tlines.push(`\\n Scaffolding ${targetName} documentation site...\\n`);\n\n\tconst MAX_INLINE = 5;\n\tconst shown = result.files.slice(0, MAX_INLINE);\n\tconst remaining = result.files.length - shown.length;\n\n\tfor (const file of shown) {\n\t\tlines.push(` \\u2713 Created ${file}`);\n\t}\n\n\tif (remaining > 0) {\n\t\tlines.push(` ... (${remaining} more file${remaining !== 1 ? \"s\" : \"\"})`);\n\t}\n\n\tif (result.instructions.length > 0) {\n\t\tlines.push(\"\\n Next steps:\");\n\t\tresult.instructions.forEach((inst, idx) => {\n\t\t\tlines.push(` ${idx + 1}. ${inst}`);\n\t\t});\n\t}\n\n\tlines.push(\n\t\t`\\n ${result.summary.filesCreated} file${result.summary.filesCreated !== 1 ? \"s\" : \"\"} created for ${targetName} doc site.`,\n\t);\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command definition\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts init docs`.\n *\n * Scaffolds a complete documentation site for the target SSG platform.\n * Use `--json` for LAFS JSON envelope output (agent/CI-friendly).\n *\n * @example\n * ```typescript\n * import { initDocsCommand } from \"@forge-ts/cli/commands/init-docs\";\n * // Registered automatically as a subcommand of `forge-ts init`\n * ```\n * @public\n */\nexport const initDocsCommand = defineCommand({\n\tmeta: {\n\t\tname: \"init\",\n\t\tdescription: \"Scaffold a documentation site\",\n\t},\n\targs: {\n\t\ttarget: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: `SSG target: ${getAvailableTargets().join(\", \")} (default: ${DEFAULT_TARGET})`,\n\t\t},\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\t\"out-dir\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Output directory for doc site (default: ./docs)\",\n\t\t},\n\t\tforce: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Overwrite existing scaffold\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runInitDocs({\n\t\t\ttarget: args.target,\n\t\t\tcwd: args.cwd,\n\t\t\toutDir: args[\"out-dir\"],\n\t\t\tforce: args.force,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\tconst logger = createLogger();\n\t\t\t\tconst msg = cmd.errors?.[0]?.message ?? \"Scaffold failed\";\n\t\t\t\tlogger.error(msg);\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t\treturn formatInitDocsHuman(data);\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n\n// ---------------------------------------------------------------------------\n// Parent \"init\" command that exposes `forge-ts init docs`\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts init`.\n *\n * Exposes subcommands for scaffolding project artefacts.\n *\n * @example\n * ```typescript\n * import { initCommand } from \"@forge-ts/cli/commands/init-docs\";\n * // Registered automatically as a subcommand of `forge-ts`\n * ```\n * @public\n */\nexport const initCommand = defineCommand({\n\tmeta: {\n\t\tname: \"init\",\n\t\tdescription: \"Scaffold project artefacts\",\n\t},\n\tsubCommands: {\n\t\tdocs: initDocsCommand,\n\t},\n});\n","/**\n * `forge-ts init hooks` command — scaffolds git hook integration.\n *\n * Detects husky or lefthook in the project and generates appropriate\n * pre-commit hook files that run `forge-ts check` on each commit.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliWarning,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Detected hook manager in the project.\n * @public\n */\nexport type HookManager = \"husky\" | \"lefthook\" | \"none\";\n\n/**\n * Result of the `init hooks` command.\n *\n * @example\n * ```typescript\n * import { runInitHooks } from \"@forge-ts/cli/commands/init-hooks\";\n * const output = await runInitHooks({ cwd: process.cwd() });\n * console.log(output.data.hookManager); // \"husky\" | \"lefthook\" | \"none\"\n * ```\n * @public\n */\nexport interface InitHooksResult {\n\t/** Whether the hook scaffolding succeeded. */\n\tsuccess: boolean;\n\t/** The detected or chosen hook manager. */\n\thookManager: HookManager;\n\t/** Summary of what was created. */\n\tsummary: {\n\t\t/** Number of files written or updated. */\n\t\tfilesWritten: number;\n\t\t/** Number of files skipped (already existed). */\n\t\tfilesSkipped: number;\n\t};\n\t/** Relative paths of all files written. */\n\tfiles: string[];\n\t/** Post-scaffold instructions for the user. */\n\tinstructions: string[];\n}\n\n/**\n * Arguments for the `init hooks` command.\n * @internal\n */\nexport interface InitHooksArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Force overwrite existing hook files. */\n\tforce?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Detection helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Detects which hook manager is present in the project.\n *\n * Checks for:\n * - husky: `.husky/` directory or `husky` in package.json devDependencies\n * - lefthook: `lefthook.yml` or `lefthook` in package.json devDependencies\n *\n * @param rootDir - Absolute path to the project root.\n * @returns The detected hook manager, or \"none\" if neither is found.\n * @public\n */\nexport function detectHookManager(rootDir: string): HookManager {\n\t// Check for husky\n\tconst huskyDir = join(rootDir, \".husky\");\n\tif (existsSync(huskyDir)) {\n\t\treturn \"husky\";\n\t}\n\n\t// Check for lefthook\n\tconst lefthookYml = join(rootDir, \"lefthook.yml\");\n\tif (existsSync(lefthookYml)) {\n\t\treturn \"lefthook\";\n\t}\n\n\t// Check package.json devDependencies\n\tconst pkgJsonPath = join(rootDir, \"package.json\");\n\tif (existsSync(pkgJsonPath)) {\n\t\ttry {\n\t\t\tconst raw = readFileSync(pkgJsonPath, \"utf8\");\n\t\t\tconst pkg = JSON.parse(raw) as {\n\t\t\t\tdevDependencies?: Record<string, string>;\n\t\t\t\tdependencies?: Record<string, string>;\n\t\t\t};\n\t\t\tconst allDeps = { ...pkg.dependencies, ...pkg.devDependencies };\n\t\t\tif (\"husky\" in allDeps) return \"husky\";\n\t\t\tif (\"lefthook\" in allDeps) return \"lefthook\";\n\t\t} catch {\n\t\t\t// Ignore parse errors\n\t\t}\n\t}\n\n\treturn \"none\";\n}\n\n// ---------------------------------------------------------------------------\n// Hook content generators\n// ---------------------------------------------------------------------------\n\nconst HUSKY_PRE_COMMIT = `#!/usr/bin/env sh\n. \"$(dirname -- \"$0\")/_/husky.sh\"\n\nnpx forge-ts check\n`;\n\nconst LEFTHOOK_BLOCK = `pre-commit:\n commands:\n forge-ts-check:\n run: npx forge-ts check\n`;\n\n/**\n * Generates the husky pre-commit hook file content.\n * @internal\n */\nexport function generateHuskyHook(): string {\n\treturn HUSKY_PRE_COMMIT;\n}\n\n/**\n * Generates the lefthook pre-commit block.\n * @internal\n */\nexport function generateLefthookBlock(): string {\n\treturn LEFTHOOK_BLOCK;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Scaffolds git hook integration for the project.\n *\n * Detects the hook manager (husky or lefthook), generates appropriate\n * hook files, and reports what was written.\n *\n * @param args - CLI arguments for the init hooks command.\n * @returns A typed `CommandOutput<InitHooksResult>`.\n * @example\n * ```typescript\n * import { runInitHooks } from \"@forge-ts/cli/commands/init-hooks\";\n * const output = await runInitHooks({ cwd: \"/my/project\" });\n * console.log(output.data.files); // [\".husky/pre-commit\"]\n * ```\n * @public\n */\nexport async function runInitHooks(args: InitHooksArgs): Promise<CommandOutput<InitHooksResult>> {\n\tconst start = Date.now();\n\tconst rootDir = args.cwd ?? process.cwd();\n\n\tconst hookManager = detectHookManager(rootDir);\n\tconst writtenFiles: string[] = [];\n\tconst skippedFiles: string[] = [];\n\tconst warnings: ForgeCliWarning[] = [];\n\tconst instructions: string[] = [];\n\n\tif (hookManager === \"husky\" || hookManager === \"none\") {\n\t\t// Write husky pre-commit hook\n\t\tconst huskyDir = join(rootDir, \".husky\");\n\t\tconst hookPath = join(huskyDir, \"pre-commit\");\n\t\tconst relativePath = \".husky/pre-commit\";\n\n\t\tif (existsSync(hookPath) && !args.force) {\n\t\t\t// Check if our command is already in the file\n\t\t\tconst existing = await readFile(hookPath, \"utf8\");\n\t\t\tif (existing.includes(\"forge-ts check\")) {\n\t\t\t\tskippedFiles.push(relativePath);\n\t\t\t\twarnings.push({\n\t\t\t\t\tcode: \"HOOKS_ALREADY_EXISTS\",\n\t\t\t\t\tmessage: `${relativePath} already contains forge-ts check — skipping. Use --force to overwrite.`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Append to existing hook\n\t\t\t\tconst appended = `${existing.trimEnd()}\\n\\nnpx forge-ts check\\n`;\n\t\t\t\tawait writeFile(hookPath, appended, { mode: 0o755 });\n\t\t\t\twrittenFiles.push(relativePath);\n\t\t\t}\n\t\t} else {\n\t\t\tawait mkdir(huskyDir, { recursive: true });\n\t\t\tawait writeFile(hookPath, HUSKY_PRE_COMMIT, { mode: 0o755 });\n\t\t\twrittenFiles.push(relativePath);\n\t\t}\n\n\t\tif (hookManager === \"none\") {\n\t\t\tinstructions.push(\n\t\t\t\t\"No hook manager detected. Wrote .husky/pre-commit as a starting point.\",\n\t\t\t\t\"Install husky to activate: npx husky-init && npm install (or pnpm dlx husky-init && pnpm install)\",\n\t\t\t);\n\t\t} else {\n\t\t\tinstructions.push(\"Husky pre-commit hook configured to run forge-ts check.\");\n\t\t}\n\t} else if (hookManager === \"lefthook\") {\n\t\tconst lefthookPath = join(rootDir, \"lefthook.yml\");\n\t\tconst relativePath = \"lefthook.yml\";\n\n\t\tif (existsSync(lefthookPath)) {\n\t\t\tconst existing = await readFile(lefthookPath, \"utf8\");\n\t\t\tif (existing.includes(\"forge-ts check\") && !args.force) {\n\t\t\t\tskippedFiles.push(relativePath);\n\t\t\t\twarnings.push({\n\t\t\t\t\tcode: \"HOOKS_ALREADY_EXISTS\",\n\t\t\t\t\tmessage: `${relativePath} already contains forge-ts check — skipping. Use --force to overwrite.`,\n\t\t\t\t});\n\t\t\t} else if (existing.includes(\"pre-commit:\") && !args.force) {\n\t\t\t\t// Append our command under the existing pre-commit section\n\t\t\t\tconst appended = `${existing.trimEnd()}\\n forge-ts-check:\\n run: npx forge-ts check\\n`;\n\t\t\t\tawait writeFile(lefthookPath, appended, \"utf8\");\n\t\t\t\twrittenFiles.push(relativePath);\n\t\t\t} else {\n\t\t\t\t// Append the full block\n\t\t\t\tconst appended = `${existing.trimEnd()}\\n\\n${LEFTHOOK_BLOCK}`;\n\t\t\t\tawait writeFile(lefthookPath, appended, \"utf8\");\n\t\t\t\twrittenFiles.push(relativePath);\n\t\t\t}\n\t\t} else {\n\t\t\tawait writeFile(lefthookPath, LEFTHOOK_BLOCK, \"utf8\");\n\t\t\twrittenFiles.push(relativePath);\n\t\t}\n\n\t\tinstructions.push(\"Lefthook pre-commit hook configured to run forge-ts check.\");\n\t}\n\n\tconst data: InitHooksResult = {\n\t\tsuccess: true,\n\t\thookManager,\n\t\tsummary: {\n\t\t\tfilesWritten: writtenFiles.length,\n\t\t\tfilesSkipped: skippedFiles.length,\n\t\t},\n\t\tfiles: writtenFiles,\n\t\tinstructions,\n\t};\n\n\treturn {\n\t\toperation: \"init.hooks\",\n\t\tsuccess: true,\n\t\tdata,\n\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\tduration: Date.now() - start,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an InitHooksResult as human-readable text.\n * @internal\n */\nfunction formatInitHooksHuman(result: InitHooksResult): string {\n\tconst lines: string[] = [];\n\n\tconst managerName = result.hookManager === \"none\" ? \"husky (default)\" : result.hookManager;\n\tlines.push(`\\n Configuring git hooks (${managerName})...\\n`);\n\n\tfor (const file of result.files) {\n\t\tlines.push(` \\u2713 ${file}`);\n\t}\n\n\tif (result.summary.filesSkipped > 0) {\n\t\tlines.push(` (${result.summary.filesSkipped} file(s) skipped — already configured)`);\n\t}\n\n\tif (result.instructions.length > 0) {\n\t\tlines.push(\"\\n Next steps:\");\n\t\tfor (const [idx, inst] of result.instructions.entries()) {\n\t\t\tlines.push(` ${idx + 1}. ${inst}`);\n\t\t}\n\t}\n\n\tlines.push(`\\n ${result.summary.filesWritten} file(s) written.`);\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command definition\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts init hooks`.\n *\n * Scaffolds git hook integration for the project by detecting the\n * hook manager (husky or lefthook) and generating pre-commit hooks.\n *\n * @example\n * ```typescript\n * import { initHooksCommand } from \"@forge-ts/cli/commands/init-hooks\";\n * // Registered as a subcommand of `forge-ts init`\n * ```\n * @public\n */\nexport const initHooksCommand = defineCommand({\n\tmeta: {\n\t\tname: \"hooks\",\n\t\tdescription: \"Scaffold git hook integration (husky/lefthook)\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tforce: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Overwrite existing hook files\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runInitHooks({\n\t\t\tcwd: args.cwd,\n\t\t\tforce: args.force,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\tconst logger = createLogger();\n\t\t\t\tconst msg = cmd.errors?.[0]?.message ?? \"Hook scaffolding failed\";\n\t\t\t\tlogger.error(msg);\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t\treturn formatInitHooksHuman(data);\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts lock` command — snapshots the current config and creates `.forge-lock.json`.\n *\n * This prevents LLM agents from silently weakening project settings.\n * Once locked, any attempt to weaken rule severities or disable guards\n * will cause `forge-ts check` to fail until `forge-ts unlock --reason=...`\n * is run.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\tappendAuditEvent,\n\tcreateLockManifest,\n\tloadConfig,\n\treadLockFile,\n\twriteLockFile,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `lock` command.\n * @public\n */\nexport interface LockResult {\n\t/** Whether the lock was successfully created. */\n\tsuccess: boolean;\n\t/** Path to the lock file that was written. */\n\tlockFile: string;\n\t/** ISO-8601 timestamp when the lock was created. */\n\tlockedAt: string;\n\t/** Identifier of who created the lock. */\n\tlockedBy: string;\n\t/** Summary of what was locked. */\n\tlocked: {\n\t\t/** Number of enforce rules captured. */\n\t\trules: number;\n\t\t/** Whether tsconfig guard settings were captured. */\n\t\ttsconfig: boolean;\n\t\t/** Whether biome guard settings were captured. */\n\t\tbiome: boolean;\n\t};\n\t/** Whether a previous lock file was overwritten. */\n\toverwrote: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the lock command: reads current config and creates `.forge-lock.json`.\n *\n * @param args - CLI arguments for the lock command.\n * @returns A typed `CommandOutput<LockResult>`.\n * @example\n * ```typescript\n * import { runLock } from \"@forge-ts/cli/commands/lock\";\n * const output = await runLock({ cwd: process.cwd() });\n * console.log(output.data.locked.rules); // number of rules locked\n * ```\n * @public\n */\nexport async function runLock(args: { cwd?: string }): Promise<CommandOutput<LockResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\tconst existingLock = readLockFile(rootDir);\n\tconst manifest = createLockManifest(config);\n\twriteLockFile(rootDir, manifest);\n\n\tappendAuditEvent(rootDir, {\n\t\ttimestamp: manifest.lockedAt,\n\t\tevent: \"config.lock\",\n\t\tuser: manifest.lockedBy,\n\t\tdetails: {\n\t\t\trules: Object.keys(manifest.config.rules).length,\n\t\t\ttsconfig: manifest.config.tsconfig !== undefined,\n\t\t\tbiome: manifest.config.biome !== undefined,\n\t\t\toverwrote: existingLock !== null,\n\t\t},\n\t});\n\n\tconst lockFile = `${rootDir}/.forge-lock.json`;\n\tconst data: LockResult = {\n\t\tsuccess: true,\n\t\tlockFile,\n\t\tlockedAt: manifest.lockedAt,\n\t\tlockedBy: manifest.lockedBy,\n\t\tlocked: {\n\t\t\trules: Object.keys(manifest.config.rules).length,\n\t\t\ttsconfig: manifest.config.tsconfig !== undefined,\n\t\t\tbiome: manifest.config.biome !== undefined,\n\t\t},\n\t\toverwrote: existingLock !== null,\n\t};\n\n\treturn {\n\t\toperation: \"lock\",\n\t\tsuccess: true,\n\t\tdata,\n\t\tduration: 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a LockResult as human-readable text.\n * @internal\n */\nfunction formatLockHuman(result: LockResult): string {\n\tconst lines: string[] = [];\n\n\tif (result.overwrote) {\n\t\tlines.push(\"forge-ts lock: updated existing lock\\n\");\n\t} else {\n\t\tlines.push(\"forge-ts lock: created .forge-lock.json\\n\");\n\t}\n\n\tlines.push(` Locked ${result.locked.rules} enforce rule(s)`);\n\tif (result.locked.tsconfig) {\n\t\tlines.push(\" Locked tsconfig guard settings\");\n\t}\n\tif (result.locked.biome) {\n\t\tlines.push(\" Locked biome guard settings\");\n\t}\n\tlines.push(`\\n Locked by: ${result.lockedBy}`);\n\tlines.push(` Locked at: ${result.lockedAt}`);\n\tlines.push(`\\n To modify locked settings, run: forge-ts unlock --reason=\"...\"`);\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts lock`.\n * @public\n */\nexport const lockCommand = defineCommand({\n\tmeta: {\n\t\tname: \"lock\",\n\t\tdescription: \"Lock current config to prevent silent weakening\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runLock({ cwd: args.cwd });\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatLockHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts prepublish` command — safety gate for npm publish.\n *\n * Runs `forge-ts check` then `forge-ts build` in sequence. If check fails,\n * the build step is skipped and the command exits non-zero. This is designed\n * to be wired into package.json as `\"prepublishOnly\": \"forge-ts prepublish\"`.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\nimport { runBuild } from \"./build.js\";\nimport { runCheck } from \"./check.js\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `prepublish` command.\n *\n * @example\n * ```typescript\n * import { runPrepublish } from \"@forge-ts/cli/commands/prepublish\";\n * const output = await runPrepublish({ cwd: process.cwd() });\n * console.log(output.data.check.success); // true if check passed\n * console.log(output.data.build?.success); // true if build passed\n * ```\n * @public\n */\nexport interface PrepublishResult {\n\t/** Whether both check and build passed. */\n\tsuccess: boolean;\n\t/** Summary of the prepublish pipeline. */\n\tsummary: {\n\t\t/** Number of pipeline steps run. */\n\t\tsteps: number;\n\t\t/** Number of steps that passed. */\n\t\tpassed: number;\n\t\t/** Number of steps that failed. */\n\t\tfailed: number;\n\t\t/** Wall-clock duration of the entire pipeline in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Result of the check step. */\n\tcheck: {\n\t\t/** Whether the check passed. */\n\t\tsuccess: boolean;\n\t\t/** Error count from the check. */\n\t\terrors: number;\n\t\t/** Warning count from the check. */\n\t\twarnings: number;\n\t\t/** Duration of the check step in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Result of the build step (absent if check failed and build was skipped). */\n\tbuild?: {\n\t\t/** Whether the build passed. */\n\t\tsuccess: boolean;\n\t\t/** Number of build pipeline steps. */\n\t\tsteps: number;\n\t\t/** Number of build steps that succeeded. */\n\t\tsucceeded: number;\n\t\t/** Number of build steps that failed. */\n\t\tfailed: number;\n\t\t/** Duration of the build step in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** If check failed, the reason build was skipped. */\n\tskippedReason?: string;\n}\n\n/**\n * Arguments for the `prepublish` command.\n * @internal\n */\nexport interface PrepublishArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Treat warnings as errors during the check step. */\n\tstrict?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the prepublish safety gate: check then build.\n *\n * If the check step fails, the build step is skipped entirely.\n * Both steps use the same project root (cwd).\n *\n * @param args - CLI arguments for the prepublish command.\n * @returns A typed `CommandOutput<PrepublishResult>`.\n * @example\n * ```typescript\n * import { runPrepublish } from \"@forge-ts/cli/commands/prepublish\";\n * const output = await runPrepublish({ cwd: process.cwd() });\n * if (!output.success) process.exit(1);\n * ```\n * @public\n */\nexport async function runPrepublish(\n\targs: PrepublishArgs,\n): Promise<CommandOutput<PrepublishResult>> {\n\tconst start = Date.now();\n\tconst allErrors: ForgeCliError[] = [];\n\n\t// Step 1: Run check\n\tconst checkOutput = await runCheck({\n\t\tcwd: args.cwd,\n\t\tstrict: args.strict,\n\t\tmvi: args.mvi,\n\t});\n\tconst checkDuration = checkOutput.duration ?? 0;\n\n\tif (!checkOutput.success) {\n\t\t// Check failed — skip build\n\t\tconst data: PrepublishResult = {\n\t\t\tsuccess: false,\n\t\t\tsummary: {\n\t\t\t\tsteps: 1,\n\t\t\t\tpassed: 0,\n\t\t\t\tfailed: 1,\n\t\t\t\tduration: Date.now() - start,\n\t\t\t},\n\t\t\tcheck: {\n\t\t\t\tsuccess: false,\n\t\t\t\terrors: checkOutput.data.summary.errors,\n\t\t\t\twarnings: checkOutput.data.summary.warnings,\n\t\t\t\tduration: checkDuration,\n\t\t\t},\n\t\t\tskippedReason: \"Check failed — build step skipped.\",\n\t\t};\n\n\t\tif (checkOutput.errors) {\n\t\t\tallErrors.push(...checkOutput.errors);\n\t\t}\n\n\t\treturn {\n\t\t\toperation: \"prepublish\",\n\t\t\tsuccess: false,\n\t\t\tdata,\n\t\t\terrors: allErrors.length > 0 ? allErrors : undefined,\n\t\t\tduration: Date.now() - start,\n\t\t};\n\t}\n\n\t// Step 2: Run build\n\tconst buildOutput = await runBuild({\n\t\tcwd: args.cwd,\n\t\tmvi: args.mvi,\n\t});\n\tconst buildDuration = buildOutput.duration ?? 0;\n\n\tconst buildSuccess = buildOutput.success;\n\tconst overallSuccess = buildSuccess;\n\n\tif (buildOutput.errors) {\n\t\tallErrors.push(...buildOutput.errors);\n\t}\n\n\tconst data: PrepublishResult = {\n\t\tsuccess: overallSuccess,\n\t\tsummary: {\n\t\t\tsteps: 2,\n\t\t\tpassed: (checkOutput.success ? 1 : 0) + (buildSuccess ? 1 : 0),\n\t\t\tfailed: (checkOutput.success ? 0 : 1) + (buildSuccess ? 0 : 1),\n\t\t\tduration: Date.now() - start,\n\t\t},\n\t\tcheck: {\n\t\t\tsuccess: checkOutput.success,\n\t\t\terrors: checkOutput.data.summary.errors,\n\t\t\twarnings: checkOutput.data.summary.warnings,\n\t\t\tduration: checkDuration,\n\t\t},\n\t\tbuild: {\n\t\t\tsuccess: buildSuccess,\n\t\t\tsteps: buildOutput.data.summary.steps,\n\t\t\tsucceeded: buildOutput.data.summary.succeeded,\n\t\t\tfailed: buildOutput.data.summary.failed,\n\t\t\tduration: buildDuration,\n\t\t},\n\t};\n\n\treturn {\n\t\toperation: \"prepublish\",\n\t\tsuccess: overallSuccess,\n\t\tdata,\n\t\terrors: allErrors.length > 0 ? allErrors : undefined,\n\t\tduration: Date.now() - start,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a PrepublishResult as human-readable text.\n * @internal\n */\nfunction formatPrepublishHuman(result: PrepublishResult): string {\n\tconst lines: string[] = [];\n\n\tlines.push(`\\n forge-ts prepublish: ${result.success ? \"PASSED\" : \"FAILED\"}\\n`);\n\n\t// Check step\n\tconst checkIcon = result.check.success ? \"\\u2713\" : \"\\u2717\";\n\tlines.push(\n\t\t` ${checkIcon} check: ${result.check.errors} error(s), ${result.check.warnings} warning(s) (${result.check.duration}ms)`,\n\t);\n\n\t// Build step\n\tif (result.build) {\n\t\tconst buildIcon = result.build.success ? \"\\u2713\" : \"\\u2717\";\n\t\tlines.push(\n\t\t\t` ${buildIcon} build: ${result.build.succeeded}/${result.build.steps} steps succeeded (${result.build.duration}ms)`,\n\t\t);\n\t} else if (result.skippedReason) {\n\t\tlines.push(` - build: skipped (${result.skippedReason})`);\n\t}\n\n\tlines.push(\n\t\t`\\n ${result.summary.passed}/${result.summary.steps} steps passed in ${result.summary.duration}ms`,\n\t);\n\n\tif (!result.success) {\n\t\tlines.push(\"\\n Publish blocked. Fix the above issues and re-run forge-ts prepublish.\");\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command definition\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts prepublish`.\n *\n * Runs check then build as a publish safety gate. Add to package.json as:\n * `\"prepublishOnly\": \"forge-ts prepublish\"`\n *\n * @example\n * ```typescript\n * import { prepublishCommand } from \"@forge-ts/cli/commands/prepublish\";\n * // Registered as `forge-ts prepublish`\n * ```\n * @public\n */\nexport const prepublishCommand = defineCommand({\n\tmeta: {\n\t\tname: \"prepublish\",\n\t\tdescription: \"Safety gate: check + build before npm publish\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tstrict: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Treat warnings as errors during check\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runPrepublish({\n\t\t\tcwd: args.cwd,\n\t\t\tstrict: args.strict,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\tconst logger = createLogger();\n\t\t\t\tlogger.error(\"Prepublish gate failed\");\n\t\t\t}\n\t\t\treturn formatPrepublishHuman(data);\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","import { loadConfig } from \"@forge-ts/core\";\nimport { doctest } from \"@forge-ts/doctest\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n/**\n * Arguments for the `test` command.\n * @internal\n */\nexport interface TestArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n/**\n * A single test failure entry, included at standard and full MVI levels.\n * @public\n */\nexport interface TestFailure {\n\t/** Symbol name where the doctest failed. */\n\tsymbol: string;\n\t/** Absolute path to the source file. */\n\tfile: string;\n\t/** 1-based line number of the failing example. */\n\tline: number;\n\t/** Human-readable failure message. */\n\tmessage: string;\n}\n\n/**\n * Typed result for the `test` command.\n * @public\n */\nexport interface TestResult {\n\t/** Whether all doctests passed. */\n\tsuccess: boolean;\n\t/** Aggregate counts — always present regardless of MVI level. */\n\tsummary: {\n\t\t/** Number of passing doctests. */\n\t\tpassed: number;\n\t\t/** Number of failing doctests. */\n\t\tfailed: number;\n\t\t/** Total doctests run. */\n\t\ttotal: number;\n\t\t/** Wall-clock duration in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Per-failure details — present at standard and full MVI levels. */\n\tfailures?: TestFailure[];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the doctest pipeline and returns a typed command output.\n *\n * @param args - CLI arguments for the test command.\n * @returns A typed `CommandOutput<TestResult>`.\n * @example\n * ```typescript\n * import { runTest } from \"@forge-ts/cli/commands/test\";\n * const output = await runTest({ cwd: process.cwd() });\n * console.log(output.data.summary.passed); // number of passing doctests\n * ```\n * @public\n */\nexport async function runTest(args: TestArgs): Promise<CommandOutput<TestResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst result = await doctest(config);\n\tconst mviLevel = args.mvi ?? \"standard\";\n\n\tconst failCount = result.errors.length;\n\tconst totalSymbols = result.symbols.length;\n\tconst passCount = totalSymbols - failCount > 0 ? totalSymbols - failCount : 0;\n\n\tconst summary = {\n\t\tpassed: passCount,\n\t\tfailed: failCount,\n\t\ttotal: totalSymbols,\n\t\tduration: result.duration,\n\t};\n\n\tconst data: TestResult = { success: result.success, summary };\n\n\tif (mviLevel !== \"minimal\") {\n\t\tdata.failures = result.errors.map((e) => ({\n\t\t\tsymbol: e.symbolName ?? \"\",\n\t\t\tfile: e.filePath ?? \"\",\n\t\t\tline: e.line,\n\t\t\tmessage: e.message,\n\t\t}));\n\t}\n\n\t// Populate top-level errors so the LAFS envelope error code is actionable.\n\tconst cliErrors = result.success\n\t\t? undefined\n\t\t: result.errors.map((e) => ({\n\t\t\t\tcode: e.code,\n\t\t\t\tmessage: e.message,\n\t\t\t}));\n\n\tconst cliWarnings = config._configWarnings?.map((msg) => ({\n\t\tcode: \"CONFIG_WARNING\",\n\t\tmessage: msg,\n\t\tfilePath: \"\",\n\t\tline: 0,\n\t\tcolumn: 0,\n\t}));\n\n\treturn {\n\t\toperation: \"test\",\n\t\tsuccess: result.success,\n\t\tdata,\n\t\terrors: cliErrors,\n\t\twarnings: cliWarnings,\n\t\tduration: result.duration,\n\t};\n}\n\n/**\n * Citty command definition for `forge-ts test`.\n * @public\n */\nexport const testCommand = defineCommand({\n\tmeta: {\n\t\tname: \"test\",\n\t\tdescription: \"Run @example blocks as doctests\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runTest({ cwd: args.cwd, mvi: args.mvi });\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data) => {\n\t\t\tif (output.success) {\n\t\t\t\treturn `forge-ts test: all doctests passed. (${data.summary.duration}ms)`;\n\t\t\t}\n\t\t\tconst lines: string[] = [];\n\t\t\tfor (const f of data.failures ?? []) {\n\t\t\t\tlines.push(f.message);\n\t\t\t}\n\t\t\tlines.push(`forge-ts test: ${data.summary.failed} failure(s). (${data.summary.duration}ms)`);\n\t\t\treturn lines.join(\"\\n\");\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts unlock` command — removes `.forge-lock.json` with a mandatory reason.\n *\n * The `--reason` flag is required to provide an audit trail explaining why\n * the config lock is being removed. This discourages silent weakening\n * of project settings by LLM agents.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\tappendAuditEvent,\n\tgetCurrentUser,\n\tloadConfig,\n\treadLockFile,\n\tremoveLockFile,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `unlock` command.\n * @public\n */\nexport interface UnlockResult {\n\t/** Whether the unlock was successful. */\n\tsuccess: boolean;\n\t/** The reason provided for unlocking. */\n\treason: string;\n\t/** Who originally locked the config, if known. */\n\tpreviousLockedBy: string | null;\n\t/** When the config was originally locked, if known. */\n\tpreviousLockedAt: string | null;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the unlock command: removes `.forge-lock.json` with a mandatory reason.\n *\n * @param args - CLI arguments for the unlock command.\n * @returns A typed `CommandOutput<UnlockResult>`.\n * @example\n * ```typescript\n * import { runUnlock } from \"@forge-ts/cli/commands/unlock\";\n * const output = await runUnlock({ cwd: process.cwd(), reason: \"Relaxing rules for migration\" });\n * console.log(output.data.success); // true\n * ```\n * @public\n */\nexport async function runUnlock(args: {\n\tcwd?: string;\n\treason: string;\n}): Promise<CommandOutput<UnlockResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\tconst existingLock = readLockFile(rootDir);\n\n\tif (!existingLock) {\n\t\treturn {\n\t\t\toperation: \"unlock\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\treason: args.reason,\n\t\t\t\tpreviousLockedBy: null,\n\t\t\t\tpreviousLockedAt: null,\n\t\t\t},\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_NO_LOCK\",\n\t\t\t\t\tmessage: \"No .forge-lock.json found. Nothing to unlock.\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tduration: 0,\n\t\t};\n\t}\n\n\tconst removed = removeLockFile(rootDir);\n\n\tif (!removed) {\n\t\treturn {\n\t\t\toperation: \"unlock\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\treason: args.reason,\n\t\t\t\tpreviousLockedBy: existingLock.lockedBy,\n\t\t\t\tpreviousLockedAt: existingLock.lockedAt,\n\t\t\t},\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_UNLOCK_FAILED\",\n\t\t\t\t\tmessage: \"Failed to remove .forge-lock.json. Check file permissions.\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tduration: 0,\n\t\t};\n\t}\n\n\tappendAuditEvent(rootDir, {\n\t\ttimestamp: new Date().toISOString(),\n\t\tevent: \"config.unlock\",\n\t\tuser: getCurrentUser(),\n\t\treason: args.reason,\n\t\tdetails: {\n\t\t\tpreviousLockedBy: existingLock.lockedBy,\n\t\t\tpreviousLockedAt: existingLock.lockedAt,\n\t\t},\n\t});\n\n\treturn {\n\t\toperation: \"unlock\",\n\t\tsuccess: true,\n\t\tdata: {\n\t\t\tsuccess: true,\n\t\t\treason: args.reason,\n\t\t\tpreviousLockedBy: existingLock.lockedBy,\n\t\t\tpreviousLockedAt: existingLock.lockedAt,\n\t\t},\n\t\tduration: 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an UnlockResult as human-readable text.\n * @internal\n */\nfunction formatUnlockHuman(result: UnlockResult): string {\n\tconst lines: string[] = [];\n\n\tif (!result.success) {\n\t\tlines.push(\"forge-ts unlock: FAILED\\n\");\n\t\tlines.push(\" No .forge-lock.json found. Nothing to unlock.\");\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\"forge-ts unlock: removed .forge-lock.json\\n\");\n\tlines.push(` Reason: ${result.reason}`);\n\tif (result.previousLockedBy) {\n\t\tlines.push(` Previously locked by: ${result.previousLockedBy}`);\n\t}\n\tif (result.previousLockedAt) {\n\t\tlines.push(` Previously locked at: ${result.previousLockedAt}`);\n\t}\n\tlines.push(\"\\n Config settings can now be modified freely.\");\n\tlines.push(\" Run `forge-ts lock` to re-lock after changes.\");\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts unlock`.\n * @public\n */\nexport const unlockCommand = defineCommand({\n\tmeta: {\n\t\tname: \"unlock\",\n\t\tdescription: \"Remove config lock (requires --reason)\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\treason: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Mandatory reason for unlocking (audit trail)\",\n\t\t\trequired: true,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (!args.reason) {\n\t\t\tconsole.error(\n\t\t\t\t\"[forge-ts] error: --reason is required. Provide a reason for unlocking the config.\",\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst output = await runUnlock({\n\t\t\tcwd: args.cwd,\n\t\t\treason: args.reason,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatUnlockHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n"],"mappings":";;;AAqBA,SAAS,qBAAqB;AAC9B,SAAS,iBAAAA,iBAAe,eAAe;;;ACZvC;AAAA,EAGC;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;;;ACN9B,SAAS,kBAAkB;AAC3B;AAAA,EACC;AAAA,EAEA;AAAA,OAEM;AAuFA,SAAS,WACf,QACA,OACA,gBACO;AACP,QAAM,YAA8B;AAAA,IACnC,MAAM,MAAM;AAAA,IACZ,OAAO,MAAM;AAAA,IACb,OAAO,MAAM;AAAA,IACb,KAAK,MAAM;AAAA;AAAA;AAAA,IAGX,KAAK,QAAQ,OAAO,SAAS;AAAA,EAC9B;AAEA,QAAM,WAAW,aAAa,SAAS;AACvC,QAAM,SAAS,SAAS,OAAO;AAC/B,QAAM,QAAQ,SAAS,OAAO;AAE9B,MAAI,OAAO;AACV;AAAA,EACD;AAEA,QAAM,OAAO;AAAA,IACZ,WAAW,YAAY,OAAO,SAAS;AAAA,IACvC,WAAW,WAAW;AAAA,IACtB,WAAW;AAAA,IACX,KAAM,MAAM,OAAoB;AAAA,EACjC;AAKA,QAAM,aAAa,OAAO;AAC1B,MAAI,OAA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Q,KAAK,CAAC;AAAA,IACf;AAEA,UAAM,SAAS,MAAM,UAAU;AAAA,MAC9B,KAAK,KAAK;AAAA,MACV,QAAQ,KAAK;AAAA,IACd,CAAC;AAED,UAAM,QAAqB;AAAA,MAC1B,MAAM,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,MACZ,OAAO,KAAK;AAAA,IACb;AAEA,eAAW,QAAQ,OAAO,CAAC,SAAS,kBAAkB,IAAI,CAAC;AAE3D,YAAQ,KAAK,gBAAgB,MAAM,CAAC;AAAA,EACrC;AACD,CAAC;;;Ab9LD,IAAMC,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,MAAMA,SAAQ,iBAAiB;AA4DrC,IAAM,cAAcC,gBAAc;AAAA,EACjC,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACZ,MAAM;AAAA,IACN,KAAK;AAAA,EACN;AACD,CAAC;AAYD,IAAMC,eAAcD,gBAAc;AAAA,EACjC,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACZ,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AACD,CAAC;AAED,IAAM,OAAOA,gBAAc;AAAA,EAC1B,MAAM;AAAA,IACL,MAAM;AAAA,IACN,SAAS,IAAI;AAAA,IACb,aAAa;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACZ,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAMC;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY;AAAA,EACb;AACD,CAAC;AAED,QAAQ,IAAI;","names":["defineCommand","defineCommand","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","output","loadConfig","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","resolve","loadConfig","DEFAULT_TARGET","getAdapter","defineCommand","DEFAULT_TARGET","getAdapter","loadConfig","resolve","defineCommand","existsSync","mkdir","writeFile","join","defineCommand","join","existsSync","pkg","join","existsSync","writeFile","mkdir","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","defineCommand","data","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","appendAuditEvent","loadConfig","readLockFile","defineCommand","loadConfig","readLockFile","appendAuditEvent","defineCommand","require","defineCommand","initCommand"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/audit.ts","../src/commands/build.ts","../src/commands/bypass.ts","../src/commands/check.ts","../src/commands/doctor.ts","../src/commands/docs-dev.ts","../src/commands/init-docs.ts","../src/commands/init-hooks.ts","../src/commands/lock.ts","../src/commands/prepublish.ts","../src/commands/test.ts","../src/commands/unlock.ts"],"sourcesContent":["/**\n * @forge-ts/cli — Command-line interface for the forge-ts toolchain.\n *\n * Usage:\n * forge-ts check [--cwd <dir>] [--strict] [--verbose]\n * forge-ts test [--cwd <dir>]\n * forge-ts build [--cwd <dir>] [--skip-api] [--skip-gen]\n * forge-ts docs init [--target <ssg>] [--out-dir <dir>] [--force]\n * forge-ts docs dev [--target <ssg>] [--port <port>]\n * forge-ts lock [--cwd <dir>]\n * forge-ts unlock --reason=\"...\" [--cwd <dir>]\n * forge-ts bypass --reason=\"...\" [--rule E009]\n * forge-ts bypass --status\n * forge-ts audit [--limit N] [--type <eventType>]\n * forge-ts init [--cwd <dir>] (full project setup)\n * forge-ts init docs [--target <ssg>] (scaffold doc site)\n * forge-ts init hooks [--cwd <dir>] [--force] (scaffold pre-commit hooks)\n * forge-ts prepublish [--cwd <dir>] [--strict]\n * forge-ts doctor [--cwd <dir>] [--fix]\n *\n * @packageDocumentation\n * @public\n */\n\nimport { createRequire } from \"node:module\";\nimport { defineCommand, runMain } from \"citty\";\nimport { auditCommand } from \"./commands/audit.js\";\nimport { buildCommand } from \"./commands/build.js\";\nimport { bypassCommand } from \"./commands/bypass.js\";\nimport { checkCommand } from \"./commands/check.js\";\nimport { doctorCommand } from \"./commands/doctor.js\";\nimport { docsDevCommand } from \"./commands/docs-dev.js\";\nimport { initDocsCommand } from \"./commands/init-docs.js\";\nimport { initHooksCommand } from \"./commands/init-hooks.js\";\nimport { initProjectCommand } from \"./commands/init-project.js\";\nimport { lockCommand } from \"./commands/lock.js\";\nimport { prepublishCommand } from \"./commands/prepublish.js\";\nimport { testCommand } from \"./commands/test.js\";\nimport { unlockCommand } from \"./commands/unlock.js\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\") as { version: string };\n\nexport { type AuditResult, auditCommand } from \"./commands/audit.js\";\nexport { type BuildResult, type BuildStep, buildCommand } from \"./commands/build.js\";\nexport {\n\ttype BypassCreateResult,\n\ttype BypassStatusResult,\n\tbypassCommand,\n\trunBypassCreate,\n\trunBypassStatus,\n} from \"./commands/bypass.js\";\nexport {\n\ttype CheckFileError,\n\ttype CheckFileGroup,\n\ttype CheckFileWarning,\n\ttype CheckPage,\n\ttype CheckResult,\n\ttype CheckRuleCount,\n\ttype CheckTriage,\n\tcheckCommand,\n} from \"./commands/check.js\";\nexport {\n\ttype DoctorCheckResult,\n\ttype DoctorCheckStatus,\n\ttype DoctorResult,\n\tdoctorCommand,\n\trunDoctor,\n} from \"./commands/doctor.js\";\nexport { docsDevCommand, runDocsDev } from \"./commands/docs-dev.js\";\nexport {\n\ttype InitDocsResult,\n\tinitDocsCommand,\n} from \"./commands/init-docs.js\";\nexport {\n\ttype HookManager,\n\ttype InitHooksResult,\n\tinitHooksCommand,\n\trunInitHooks,\n} from \"./commands/init-hooks.js\";\nexport {\n\ttype InitProjectEnvironment,\n\ttype InitProjectResult,\n\tinitProjectCommand,\n\trunInitProject,\n} from \"./commands/init-project.js\";\nexport { type LockResult, lockCommand, runLock } from \"./commands/lock.js\";\nexport {\n\ttype PrepublishResult,\n\tprepublishCommand,\n\trunPrepublish,\n} from \"./commands/prepublish.js\";\nexport { type TestFailure, type TestResult, testCommand } from \"./commands/test.js\";\nexport { runUnlock, type UnlockResult, unlockCommand } from \"./commands/unlock.js\";\nexport { createLogger, type Logger } from \"./logger.js\";\nexport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype ForgeCliWarning,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"./output.js\";\n\n/**\n * The `docs` parent command with `init` and `dev` subcommands.\n *\n * @example\n * ```typescript\n * // forge-ts docs init --target mintlify\n * // forge-ts docs dev\n * ```\n * @public\n */\nconst docsCommand = defineCommand({\n\tmeta: {\n\t\tname: \"docs\",\n\t\tdescription: \"Documentation site management\",\n\t},\n\tsubCommands: {\n\t\tinit: initDocsCommand,\n\t\tdev: docsDevCommand,\n\t},\n});\n\n/**\n * The `init` parent command with `docs` and `hooks` subcommands.\n *\n * When called bare (`forge-ts init`), runs the full project setup.\n * When called with a subcommand (`forge-ts init docs` or `forge-ts init hooks`),\n * dispatches to that subcommand instead.\n *\n * @remarks\n * citty runs the parent's `run` handler after a subcommand completes, so we\n * check `rawArgs` to detect whether a subcommand was dispatched and skip the\n * default project-setup logic in that case.\n *\n * @example\n * ```typescript\n * // forge-ts init -> full project setup\n * // forge-ts init docs --target mintlify -> scaffold doc site\n * // forge-ts init hooks -> scaffold pre-commit hooks\n * ```\n * @public\n */\nconst initCommand = defineCommand({\n\tmeta: {\n\t\tname: \"init\",\n\t\tdescription: \"Full project setup (bare) or scaffold artefacts (with subcommand)\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tsubCommands: {\n\t\tdocs: initDocsCommand,\n\t\thooks: initHooksCommand,\n\t\tsetup: initProjectCommand,\n\t},\n\tasync run({ rawArgs, args }) {\n\t\t// If a subcommand was dispatched, citty already ran it.\n\t\tconst subCommandNames = new Set([\"docs\", \"hooks\", \"setup\"]);\n\t\tconst hasSubCommand = rawArgs.some((arg) => subCommandNames.has(arg));\n\t\tif (hasSubCommand) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bare `forge-ts init` (no subcommand) — run full project setup\n\t\tconst { runInitProject } = await import(\"./commands/init-project.js\");\n\t\tconst { emitResult, resolveExitCode } = await import(\"./output.js\");\n\t\tconst { createLogger } = await import(\"./logger.js\");\n\n\t\tconst output = await runInitProject({\n\t\t\tcwd: args.cwd,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\tconst logger = createLogger();\n\t\t\t\tconst msg = cmd.errors?.[0]?.message ?? \"Init failed\";\n\t\t\t\tlogger.error(msg);\n\t\t\t\treturn \"\";\n\t\t\t}\n\n\t\t\t// Use the same format as init-project command\n\t\t\tconst lines: string[] = [];\n\n\t\t\tlines.push(\"\\nforge-ts init: project setup complete\\n\");\n\n\t\t\tif (data.created.length > 0) {\n\t\t\t\tlines.push(\" Created:\");\n\t\t\t\tfor (const file of data.created) {\n\t\t\t\t\tlines.push(` ${file}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (data.skipped.length > 0) {\n\t\t\t\tlines.push(\"\");\n\t\t\t\tlines.push(\" Already exists (skipped):\");\n\t\t\t\tfor (const file of data.skipped) {\n\t\t\t\t\tlines.push(` ${file}`);\n\t\t\t\t}\n\t\t\t} else if (data.created.length > 0) {\n\t\t\t\tlines.push(\"\");\n\t\t\t\tlines.push(\" Already exists (skipped):\");\n\t\t\t\tlines.push(\" (none)\");\n\t\t\t}\n\n\t\t\tif (data.warnings.length > 0) {\n\t\t\t\tlines.push(\"\");\n\t\t\t\tlines.push(\" Warnings:\");\n\t\t\t\tfor (const warning of data.warnings) {\n\t\t\t\t\tlines.push(` ${warning}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst env = data.environment;\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\" Environment:\");\n\t\t\tlines.push(` TypeScript: ${env.typescriptVersion ?? \"not detected\"}`);\n\t\t\tlines.push(` Biome: ${env.biomeDetected ? \"detected\" : \"not detected\"}`);\n\n\t\t\tconst hookLabel =\n\t\t\t\tenv.hookManager === \"none\" ? \"not detected\" : `${env.hookManager} detected`;\n\t\t\tlines.push(` Git hooks: ${hookLabel}`);\n\n\t\t\tif (env.monorepo) {\n\t\t\t\tlines.push(\n\t\t\t\t\t` Monorepo: ${env.monorepoType === \"pnpm\" ? \"pnpm workspaces\" : \"npm/yarn workspaces\"}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlines.push(\" Monorepo: no\");\n\t\t\t}\n\n\t\t\tif (data.nextSteps.length > 0) {\n\t\t\t\tlines.push(\"\");\n\t\t\t\tlines.push(\" Next steps:\");\n\t\t\t\tfor (const [idx, step] of data.nextSteps.entries()) {\n\t\t\t\t\tlines.push(` ${idx + 1}. ${step}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn lines.join(\"\\n\");\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: \"forge-ts\",\n\t\tversion: pkg.version,\n\t\tdescription: \"Universal TypeScript Documentation Compiler\",\n\t},\n\tsubCommands: {\n\t\tcheck: checkCommand,\n\t\ttest: testCommand,\n\t\tbuild: buildCommand,\n\t\tdocs: docsCommand,\n\t\tinit: initCommand,\n\t\tlock: lockCommand,\n\t\tunlock: unlockCommand,\n\t\tbypass: bypassCommand,\n\t\taudit: auditCommand,\n\t\tprepublish: prepublishCommand,\n\t\tdoctor: doctorCommand,\n\t},\n});\n\nrunMain(main);\n","/**\n * CLI command for reading the forge-ts audit trail.\n *\n * Reads `.forge-audit.jsonl` from the project root and displays events\n * in human-readable or LAFS JSON format.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\ttype AuditEvent,\n\ttype AuditEventType,\n\tformatAuditEvent,\n\treadAuditLog,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Arguments for the `audit` command.\n *\n * @internal\n */\nexport interface AuditArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Maximum number of events to display (default: 20). */\n\tlimit?: number;\n\t/** Filter events by type. */\n\ttype?: AuditEventType;\n}\n\n/**\n * Typed result for the `audit` command.\n *\n * @public\n */\nexport interface AuditResult {\n\t/** Whether the audit log was read successfully. */\n\tsuccess: boolean;\n\t/** Number of events returned. */\n\tcount: number;\n\t/** The audit events, newest first. */\n\tevents: AuditEvent[];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Reads the audit log and returns a typed command output.\n *\n * @param args - CLI arguments for the audit command.\n * @returns A typed `CommandOutput<AuditResult>`.\n * @example\n * ```typescript\n * import { runAudit } from \"@forge-ts/cli/commands/audit\";\n * const output = await runAudit({ cwd: process.cwd(), limit: 10 });\n * console.log(output.data.count); // number of events returned\n * ```\n * @public\n */\nexport function runAudit(args: AuditArgs): CommandOutput<AuditResult> {\n\tconst rootDir = args.cwd ?? process.cwd();\n\tconst limit = args.limit ?? 20;\n\n\tconst events = readAuditLog(rootDir, {\n\t\tlimit,\n\t\teventType: args.type,\n\t});\n\n\tconst data: AuditResult = {\n\t\tsuccess: true,\n\t\tcount: events.length,\n\t\tevents,\n\t};\n\n\treturn {\n\t\toperation: \"audit\",\n\t\tsuccess: true,\n\t\tdata,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an AuditResult as human-readable text.\n *\n * @param data - The audit result to format.\n * @returns Formatted multi-line string.\n * @internal\n */\nfunction formatAuditHuman(data: AuditResult): string {\n\tif (data.count === 0) {\n\t\treturn \"forge-ts audit: no events found.\";\n\t}\n\n\tconst lines: string[] = [];\n\tlines.push(`forge-ts audit: ${data.count} event(s)\\n`);\n\n\tfor (const event of data.events) {\n\t\tlines.push(` ${formatAuditEvent(event)}`);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/** Valid event types for the --type filter. */\nconst VALID_EVENT_TYPES: string[] = [\n\t\"config.lock\",\n\t\"config.unlock\",\n\t\"config.drift\",\n\t\"bypass.create\",\n\t\"bypass.expire\",\n\t\"rule.change\",\n];\n\n/**\n * Citty command definition for `forge-ts audit`.\n *\n * @public\n */\nexport const auditCommand = defineCommand({\n\tmeta: {\n\t\tname: \"audit\",\n\t\tdescription: \"Display the forge-ts audit trail\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tlimit: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Maximum events to display (default: 20)\",\n\t\t},\n\t\ttype: {\n\t\t\ttype: \"string\",\n\t\t\tdescription:\n\t\t\t\t\"Filter by event type (config.lock, config.unlock, config.drift, bypass.create, bypass.expire, rule.change)\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\trun({ args }) {\n\t\t// Validate --type if provided\n\t\tconst eventType = args.type as AuditEventType | undefined;\n\t\tif (eventType && !VALID_EVENT_TYPES.includes(eventType)) {\n\t\t\tconsole.error(\n\t\t\t\t`Error: invalid event type \"${eventType}\". Valid types: ${VALID_EVENT_TYPES.join(\", \")}`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst output = runAudit({\n\t\t\tcwd: args.cwd,\n\t\t\tlimit: args.limit ? Number.parseInt(args.limit, 10) : undefined,\n\t\t\ttype: eventType,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatAuditHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","import { generateApi } from \"@forge-ts/api\";\nimport { loadConfig } from \"@forge-ts/core\";\nimport { generate } from \"@forge-ts/gen\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\n\n/**\n * Arguments for the `build` command.\n * @internal\n */\nexport interface BuildArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Skip API generation even if enabled in config. */\n\tskipApi?: boolean;\n\t/** Skip doc generation even if enabled in config. */\n\tskipGen?: boolean;\n\t/**\n\t * Overwrite stub pages even if they already exist on disk.\n\t * Normally stub pages (concepts, guides, faq, contributing, changelog)\n\t * are only created on the first build to preserve manual edits.\n\t * Use this to reset stubs to their scaffolding state.\n\t */\n\tforceStubs?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n/**\n * A single step in the build pipeline.\n * @public\n */\nexport interface BuildStep {\n\t/** Internal step name, e.g. \"api\" or \"gen\". */\n\tname: string;\n\t/** Outcome of this step. */\n\tstatus: \"success\" | \"skipped\" | \"failed\";\n\t/** Path to the primary output file produced by this step, if applicable. */\n\toutputPath?: string;\n\t/** Wall-clock duration of this step in milliseconds. */\n\tduration?: number;\n\t/** Errors produced by this step when status is \"failed\". */\n\terrors?: ForgeCliError[];\n}\n\n/**\n * Typed result for the `build` command.\n * @public\n */\nexport interface BuildResult {\n\t/** Whether the build succeeded. */\n\tsuccess: boolean;\n\t/** Aggregate pipeline counts — always present. */\n\tsummary: {\n\t\t/** Total number of pipeline steps. */\n\t\tsteps: number;\n\t\t/** Steps that completed successfully. */\n\t\tsucceeded: number;\n\t\t/** Steps that failed. */\n\t\tfailed: number;\n\t\t/** Wall-clock duration in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Per-step details. */\n\tsteps: BuildStep[];\n\t/** Files written during the build — present at standard and full MVI levels. */\n\tgeneratedFiles?: string[];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the full build pipeline and returns a typed command output.\n *\n * @param args - CLI arguments for the build command.\n * @returns A typed `CommandOutput<BuildResult>`.\n * @example\n * ```typescript\n * import { runBuild } from \"@forge-ts/cli/commands/build\";\n * const output = await runBuild({ cwd: process.cwd() });\n * console.log(output.success); // true if all steps succeeded\n * ```\n * @public\n */\nexport async function runBuild(args: BuildArgs): Promise<CommandOutput<BuildResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst buildStart = Date.now();\n\tconst mviLevel = args.mvi ?? \"standard\";\n\n\tconst steps: BuildStep[] = [];\n\tconst allErrors: ForgeCliError[] = [];\n\tconst generatedFiles: string[] = [];\n\tlet success = true;\n\n\tif (config.api.enabled && !args.skipApi) {\n\t\tconst result = await generateApi(config);\n\t\tif (!result.success) {\n\t\t\tconst errors: ForgeCliError[] = result.errors.map((e) => ({\n\t\t\t\tcode: e.code,\n\t\t\t\tmessage: e.message,\n\t\t\t\tfilePath: e.filePath,\n\t\t\t\tline: e.line,\n\t\t\t\tcolumn: e.column,\n\t\t\t}));\n\t\t\tallErrors.push(...errors);\n\t\t\tsuccess = false;\n\t\t\tsteps.push({\n\t\t\t\tname: \"api\",\n\t\t\t\tstatus: \"failed\",\n\t\t\t\toutputPath: config.api.openapiPath,\n\t\t\t\tduration: result.duration,\n\t\t\t\terrors,\n\t\t\t});\n\t\t} else {\n\t\t\tsteps.push({\n\t\t\t\tname: \"api\",\n\t\t\t\tstatus: \"success\",\n\t\t\t\toutputPath: config.api.openapiPath,\n\t\t\t\tduration: result.duration,\n\t\t\t});\n\t\t\tgeneratedFiles.push(config.api.openapiPath);\n\t\t}\n\t} else if (!config.api.enabled || args.skipApi) {\n\t\tsteps.push({ name: \"api\", status: \"skipped\" });\n\t}\n\n\tif (config.gen.enabled && !args.skipGen) {\n\t\tconst result = await generate(config, { forceStubs: args.forceStubs });\n\t\tif (!result.success) {\n\t\t\tconst errors: ForgeCliError[] = result.errors.map((e) => ({\n\t\t\t\tcode: e.code,\n\t\t\t\tmessage: e.message,\n\t\t\t\tfilePath: e.filePath,\n\t\t\t\tline: e.line,\n\t\t\t\tcolumn: e.column,\n\t\t\t}));\n\t\t\tallErrors.push(...errors);\n\t\t\tsuccess = false;\n\t\t\tsteps.push({\n\t\t\t\tname: \"gen\",\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tduration: result.duration,\n\t\t\t\terrors,\n\t\t\t});\n\t\t} else {\n\t\t\tsteps.push({\n\t\t\t\tname: \"gen\",\n\t\t\t\tstatus: \"success\",\n\t\t\t\tduration: result.duration,\n\t\t\t});\n\t\t\tif (result.writtenFiles) {\n\t\t\t\tgeneratedFiles.push(...result.writtenFiles);\n\t\t\t}\n\t\t}\n\t} else if (!config.gen.enabled || args.skipGen) {\n\t\tsteps.push({ name: \"gen\", status: \"skipped\" });\n\t}\n\n\tconst totalMs = Date.now() - buildStart;\n\n\tconst succeededCount = steps.filter((s) => s.status === \"success\").length;\n\tconst failedCount = steps.filter((s) => s.status === \"failed\").length;\n\n\tconst data: BuildResult = {\n\t\tsuccess,\n\t\tsummary: {\n\t\t\tsteps: steps.length,\n\t\t\tsucceeded: succeededCount,\n\t\t\tfailed: failedCount,\n\t\t\tduration: totalMs,\n\t\t},\n\t\tsteps,\n\t};\n\n\tif (mviLevel !== \"minimal\") {\n\t\tdata.generatedFiles = generatedFiles;\n\t}\n\n\tconst cliWarnings = config._configWarnings?.map((msg) => ({\n\t\tcode: \"CONFIG_WARNING\",\n\t\tmessage: msg,\n\t\tfilePath: \"\",\n\t\tline: 0,\n\t\tcolumn: 0,\n\t}));\n\n\treturn {\n\t\toperation: \"build\",\n\t\tsuccess,\n\t\tdata,\n\t\terrors: allErrors,\n\t\twarnings: cliWarnings,\n\t\tduration: totalMs,\n\t};\n}\n\n/**\n * Citty command definition for `forge-ts build`.\n * @public\n */\nexport const buildCommand = defineCommand({\n\tmeta: {\n\t\tname: \"build\",\n\t\tdescription: \"Generate API reference and documentation\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\t\"skip-api\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip OpenAPI generation\",\n\t\t\tdefault: false,\n\t\t},\n\t\t\"skip-gen\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip doc generation\",\n\t\t\tdefault: false,\n\t\t},\n\t\t\"force-stubs\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Overwrite stub pages even if they exist (reset to scaffolding)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runBuild({\n\t\t\tcwd: args.cwd,\n\t\t\tskipApi: args[\"skip-api\"],\n\t\t\tskipGen: args[\"skip-gen\"],\n\t\t\tforceStubs: args[\"force-stubs\"],\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data) => {\n\t\t\tconst logger = createLogger();\n\t\t\tfor (const step of data.steps) {\n\t\t\t\tif (step.status === \"failed\") {\n\t\t\t\t\tfor (const err of step.errors ?? []) {\n\t\t\t\t\t\tlogger.error(`[${step.name}] ${err.message}`);\n\t\t\t\t\t}\n\t\t\t\t} else if (step.status === \"success\") {\n\t\t\t\t\tconst detail =\n\t\t\t\t\t\tstep.name === \"api\" && step.outputPath != null\n\t\t\t\t\t\t\t? `Generated OpenAPI spec \\u2192 ${step.outputPath}`\n\t\t\t\t\t\t\t: `Step complete`;\n\t\t\t\t\tlogger.step(step.name.toUpperCase(), detail, step.duration);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (output.success) {\n\t\t\t\treturn ` Done in ${data.summary.duration}ms`;\n\t\t\t}\n\t\t\treturn \"\";\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts bypass` command — create or inspect temporary rule bypasses.\n *\n * Bypasses allow agents to temporarily override locked rules with a limited\n * daily budget. Each bypass requires a mandatory `--reason` flag and expires\n * after a configurable duration.\n *\n * Usage:\n * forge-ts bypass --reason=\"hotfix for release\" [--rule E009]\n * forge-ts bypass --status\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\ttype BypassRecord,\n\tcreateBypass,\n\texpireOldBypasses,\n\tgetActiveBypasses,\n\tgetRemainingBudget,\n\tloadConfig,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `bypass` command when creating a bypass.\n * @public\n */\nexport interface BypassCreateResult {\n\t/** Whether the bypass was successfully created. */\n\tsuccess: boolean;\n\t/** The bypass record that was created. */\n\tbypass: BypassRecord;\n\t/** Number of remaining bypass slots for today after creation. */\n\tremainingBudget: number;\n\t/** The configured daily budget. */\n\tdailyBudget: number;\n}\n\n/**\n * Typed result for the `bypass --status` command.\n * @public\n */\nexport interface BypassStatusResult {\n\t/** Always true for status queries. */\n\tsuccess: boolean;\n\t/** Active (non-expired) bypass records. */\n\tactiveBypasses: BypassRecord[];\n\t/** Number of remaining bypass slots for today. */\n\tremainingBudget: number;\n\t/** The configured daily budget. */\n\tdailyBudget: number;\n\t/** Number of expired bypasses that were cleaned up. */\n\texpiredRemoved: number;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the bypass creation: creates a new bypass record with budget enforcement.\n *\n * @param args - CLI arguments for the bypass command.\n * @returns A typed `CommandOutput<BypassCreateResult>`.\n * @example\n * ```typescript\n * import { runBypassCreate } from \"@forge-ts/cli/commands/bypass\";\n * const output = await runBypassCreate({\n * cwd: process.cwd(),\n * reason: \"hotfix for release\",\n * rule: \"E009\",\n * });\n * console.log(output.data.remainingBudget);\n * ```\n * @public\n */\nexport async function runBypassCreate(args: {\n\tcwd?: string;\n\treason: string;\n\trule?: string;\n}): Promise<CommandOutput<BypassCreateResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\t// Clean up expired bypasses first\n\texpireOldBypasses(rootDir);\n\n\ttry {\n\t\tconst bypass = createBypass(rootDir, args.reason, args.rule, config.bypass);\n\t\tconst remainingBudget = getRemainingBudget(rootDir, config.bypass);\n\n\t\treturn {\n\t\t\toperation: \"bypass\",\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\tsuccess: true,\n\t\t\t\tbypass,\n\t\t\t\tremainingBudget,\n\t\t\t\tdailyBudget: config.bypass.dailyBudget,\n\t\t\t},\n\t\t\tduration: 0,\n\t\t};\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\treturn {\n\t\t\toperation: \"bypass\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\tbypass: {} as BypassRecord,\n\t\t\t\tremainingBudget: 0,\n\t\t\t\tdailyBudget: config.bypass.dailyBudget,\n\t\t\t},\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_BYPASS_BUDGET_EXHAUSTED\",\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t],\n\t\t\tduration: 0,\n\t\t};\n\t}\n}\n\n/**\n * Runs the bypass status query: shows active bypasses and remaining budget.\n *\n * @param args - CLI arguments for the bypass status command.\n * @returns A typed `CommandOutput<BypassStatusResult>`.\n * @example\n * ```typescript\n * import { runBypassStatus } from \"@forge-ts/cli/commands/bypass\";\n * const output = await runBypassStatus({ cwd: process.cwd() });\n * console.log(output.data.activeBypasses.length);\n * ```\n * @public\n */\nexport async function runBypassStatus(args: {\n\tcwd?: string;\n}): Promise<CommandOutput<BypassStatusResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\t// Clean up expired bypasses first\n\tconst expiredRemoved = expireOldBypasses(rootDir);\n\tconst activeBypasses = getActiveBypasses(rootDir);\n\tconst remainingBudget = getRemainingBudget(rootDir, config.bypass);\n\n\treturn {\n\t\toperation: \"bypass\",\n\t\tsuccess: true,\n\t\tdata: {\n\t\t\tsuccess: true,\n\t\t\tactiveBypasses,\n\t\t\tremainingBudget,\n\t\t\tdailyBudget: config.bypass.dailyBudget,\n\t\t\texpiredRemoved,\n\t\t},\n\t\tduration: 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatters\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a BypassCreateResult as human-readable text.\n * @internal\n */\nfunction formatBypassCreateHuman(result: BypassCreateResult): string {\n\tconst lines: string[] = [];\n\n\tif (!result.success) {\n\t\tlines.push(\"forge-ts bypass: FAILED\\n\");\n\t\tlines.push(\" Daily bypass budget exhausted.\");\n\t\tlines.push(` Budget: 0/${result.dailyBudget} remaining`);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\"forge-ts bypass: created\\n\");\n\tlines.push(` ID: ${result.bypass.id}`);\n\tlines.push(` Rule: ${result.bypass.rule}`);\n\tlines.push(` Reason: ${result.bypass.reason}`);\n\tlines.push(` Expires: ${result.bypass.expiresAt}`);\n\tlines.push(` User: ${result.bypass.user}`);\n\tlines.push(`\\n Budget: ${result.remainingBudget}/${result.dailyBudget} remaining today`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Formats a BypassStatusResult as human-readable text.\n * @internal\n */\nfunction formatBypassStatusHuman(result: BypassStatusResult): string {\n\tconst lines: string[] = [];\n\n\tlines.push(\"forge-ts bypass: status\\n\");\n\tlines.push(` Budget: ${result.remainingBudget}/${result.dailyBudget} remaining today`);\n\n\tif (result.expiredRemoved > 0) {\n\t\tlines.push(` Cleaned up ${result.expiredRemoved} expired bypass(es)`);\n\t}\n\n\tif (result.activeBypasses.length === 0) {\n\t\tlines.push(\"\\n No active bypasses.\");\n\t} else {\n\t\tlines.push(`\\n Active bypasses (${result.activeBypasses.length}):`);\n\t\tfor (const b of result.activeBypasses) {\n\t\t\tlines.push(` - [${b.rule}] ${b.reason} (expires ${b.expiresAt})`);\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts bypass`.\n * @public\n */\nexport const bypassCommand = defineCommand({\n\tmeta: {\n\t\tname: \"bypass\",\n\t\tdescription: \"Create or inspect temporary rule bypasses\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\treason: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Mandatory justification for bypassing rules\",\n\t\t},\n\t\trule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: 'Specific rule code to bypass (e.g., \"E009\"). Defaults to \"all\"',\n\t\t},\n\t\tstatus: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Show active bypasses and remaining budget\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\t// --status mode: show active bypasses\n\t\tif (args.status) {\n\t\t\tconst output = await runBypassStatus({ cwd: args.cwd });\n\t\t\temitResult(output, flags, (data) => formatBypassStatusHuman(data));\n\t\t\tprocess.exit(resolveExitCode(output));\n\t\t\treturn;\n\t\t}\n\n\t\t// Create mode: --reason is required\n\t\tif (!args.reason) {\n\t\t\tconsole.error(\n\t\t\t\t\"[forge-ts] error: --reason is required. Provide a justification for the bypass.\",\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst output = await runBypassCreate({\n\t\t\tcwd: args.cwd,\n\t\t\treason: args.reason,\n\t\t\trule: args.rule,\n\t\t});\n\n\t\temitResult(output, flags, (data) => formatBypassCreateHuman(data));\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","import { type ForgeError, type ForgeWarning, loadConfig } from \"@forge-ts/core\";\nimport { enforce } from \"@forge-ts/enforcer\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n/**\n * Arguments for the `check` command.\n * @internal\n */\nexport interface CheckArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Exit with non-zero code on warnings as well as errors. */\n\tstrict?: boolean;\n\t/** Include symbol signatures alongside diagnostics. */\n\tverbose?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n\t/** Filter errors to a specific rule code (e.g., \"E001\"). */\n\trule?: string;\n\t/** Filter errors to a specific file path (substring match). */\n\tfile?: string;\n\t/** Maximum number of file groups to return in byFile (default: 20). */\n\tlimit?: number;\n\t/** Offset into the byFile list for pagination (default: 0). */\n\toffset?: number;\n}\n\n/**\n * A single error entry within a file group.\n * @public\n */\nexport interface CheckFileError {\n\t/** Machine-readable error code. */\n\tcode: string;\n\t/** Symbol name that needs fixing. */\n\tsymbol: string;\n\t/** Symbol kind (function, class, interface, etc.). */\n\tkind: string;\n\t/** 1-based line number of the error. */\n\tline: number;\n\t/** Human-readable description. */\n\tmessage: string;\n\t/** Exact TSDoc block to add (present at full MVI or with --rule/--file filters). */\n\tsuggestedFix?: string;\n\t/** Recommended agent action. */\n\tagentAction?: string;\n}\n\n/**\n * A single warning entry within a file group.\n * @public\n */\nexport interface CheckFileWarning {\n\t/** Machine-readable warning code. */\n\tcode: string;\n\t/** Symbol name that generated the warning. */\n\tsymbol: string;\n\t/** Symbol kind (function, class, interface, etc.). */\n\tkind: string;\n\t/** 1-based line number of the warning. */\n\tline: number;\n\t/** Human-readable description. */\n\tmessage: string;\n}\n\n/**\n * Errors and warnings grouped by file.\n * @public\n */\nexport interface CheckFileGroup {\n\t/** Absolute path to the source file. */\n\tfile: string;\n\t/** Errors in this file. */\n\terrors: CheckFileError[];\n\t/** Warnings in this file. */\n\twarnings: CheckFileWarning[];\n}\n\n/**\n * Error breakdown by rule code, sorted by count descending.\n * @public\n */\nexport interface CheckRuleCount {\n\t/** Machine-readable rule code (e.g., \"E001\"). */\n\tcode: string;\n\t/** Human-readable rule name (e.g., \"require-summary\"). */\n\trule: string;\n\t/** Number of violations. */\n\tcount: number;\n\t/** Number of unique files affected by this rule. */\n\tfiles: number;\n}\n\n/**\n * Triage data for prioritizing fixes.\n * Always present when the check has errors, bounded in size (~9 rules + top 20 files).\n * @public\n */\nexport interface CheckTriage {\n\t/** Error counts by rule, sorted descending. */\n\tbyRule: CheckRuleCount[];\n\t/** Top files by error count (max 20). */\n\ttopFiles: Array<{ file: string; errors: number; warnings: number }>;\n\t/** Suggested fix order: rules sorted by fewest files affected first (quick wins). */\n\tfixOrder: Array<{ code: string; rule: string; count: number; files: number }>;\n}\n\n/**\n * Pagination metadata for byFile results.\n * @public\n */\nexport interface CheckPage {\n\t/** Current offset. */\n\toffset: number;\n\t/** Page size. */\n\tlimit: number;\n\t/** Whether more results exist beyond this page. */\n\thasMore: boolean;\n\t/** Total number of file groups (after filters). */\n\ttotal: number;\n}\n\n/**\n * Typed result for the `check` command.\n * @public\n */\nexport interface CheckResult {\n\t/** Whether the check passed without errors. */\n\tsuccess: boolean;\n\t/** Aggregate counts — always present regardless of MVI level. */\n\tsummary: {\n\t\t/** Total number of errors. */\n\t\terrors: number;\n\t\t/** Total number of warnings. */\n\t\twarnings: number;\n\t\t/** Number of unique files with diagnostics. */\n\t\tfiles: number;\n\t\t/** Number of exported symbols checked. */\n\t\tsymbols: number;\n\t\t/** Wall-clock duration in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Triage data for prioritizing fixes — present when errors > 0 (except minimal). */\n\ttriage?: CheckTriage;\n\t/** Per-file breakdown — present at standard and full MVI levels, paginated. */\n\tbyFile?: CheckFileGroup[];\n\t/** Pagination metadata when byFile is paginated. */\n\tpage?: CheckPage;\n\t/** Active filters applied to this result. */\n\tfilters?: { rule?: string; file?: string };\n\t/** CLI command hint for the agent to run next. */\n\tnextCommand?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Rule code → name mapping\n// ---------------------------------------------------------------------------\n\nconst RULE_NAMES: Record<string, string> = {\n\tE001: \"require-summary\",\n\tE002: \"require-param\",\n\tE003: \"require-returns\",\n\tE004: \"require-example\",\n\tE005: \"require-package-doc\",\n\tE006: \"require-class-member-doc\",\n\tE007: \"require-interface-member-doc\",\n\tE008: \"require-link-target\",\n\tW004: \"deprecated-cross-import\",\n};\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Computes triage data from the full (unfiltered) error/warning set.\n * Bounded output: max 9 rules + top 20 files.\n * @internal\n */\nfunction computeTriage(errors: ForgeError[], warnings: ForgeWarning[]): CheckTriage {\n\t// byRule: count per code with file count\n\tconst ruleMap = new Map<string, { count: number; files: Set<string> }>();\n\tfor (const e of errors) {\n\t\tconst entry = ruleMap.get(e.code) ?? { count: 0, files: new Set<string>() };\n\t\tentry.count++;\n\t\tentry.files.add(e.filePath);\n\t\truleMap.set(e.code, entry);\n\t}\n\tfor (const w of warnings) {\n\t\tconst entry = ruleMap.get(w.code) ?? { count: 0, files: new Set<string>() };\n\t\tentry.count++;\n\t\tentry.files.add(w.filePath);\n\t\truleMap.set(w.code, entry);\n\t}\n\n\tconst byRule: CheckRuleCount[] = Array.from(ruleMap.entries())\n\t\t.map(([code, { count, files }]) => ({\n\t\t\tcode,\n\t\t\trule: RULE_NAMES[code] ?? code,\n\t\t\tcount,\n\t\t\tfiles: files.size,\n\t\t}))\n\t\t.sort((a, b) => b.count - a.count);\n\n\t// topFiles: count errors/warnings per file, top 20\n\tconst fileMap = new Map<string, { errors: number; warnings: number }>();\n\tfor (const e of errors) {\n\t\tconst entry = fileMap.get(e.filePath) ?? { errors: 0, warnings: 0 };\n\t\tentry.errors++;\n\t\tfileMap.set(e.filePath, entry);\n\t}\n\tfor (const w of warnings) {\n\t\tconst entry = fileMap.get(w.filePath) ?? { errors: 0, warnings: 0 };\n\t\tentry.warnings++;\n\t\tfileMap.set(w.filePath, entry);\n\t}\n\tconst topFiles = Array.from(fileMap.entries())\n\t\t.map(([file, counts]) => ({ file, ...counts }))\n\t\t.sort((a, b) => b.errors - a.errors || a.file.localeCompare(b.file))\n\t\t.slice(0, 20);\n\n\t// fixOrder: rules sorted by fewest files (quick wins first)\n\tconst fixOrder = [...byRule].sort((a, b) => a.files - b.files || b.count - a.count);\n\n\treturn { byRule, topFiles, fixOrder };\n}\n\n/**\n * Filters errors/warnings by rule code and/or file path substring.\n * @internal\n */\nfunction applyFilters(\n\terrors: ForgeError[],\n\twarnings: ForgeWarning[],\n\tfilters: { rule?: string; file?: string },\n): { errors: ForgeError[]; warnings: ForgeWarning[] } {\n\tlet filteredErrors = errors;\n\tlet filteredWarnings = warnings;\n\n\tif (filters.rule) {\n\t\tconst r = filters.rule.toUpperCase();\n\t\tfilteredErrors = filteredErrors.filter((e) => e.code === r);\n\t\tfilteredWarnings = filteredWarnings.filter((w) => w.code === r);\n\t}\n\tif (filters.file) {\n\t\tconst f = filters.file;\n\t\tfilteredErrors = filteredErrors.filter((e) => e.filePath.includes(f));\n\t\tfilteredWarnings = filteredWarnings.filter((w) => w.filePath.includes(f));\n\t}\n\n\treturn { errors: filteredErrors, warnings: filteredWarnings };\n}\n\n/**\n * Groups errors and warnings by file path.\n * @internal\n */\nfunction groupByFile(\n\terrors: ForgeError[],\n\twarnings: ForgeWarning[],\n\tincludeFix: boolean,\n): CheckFileGroup[] {\n\tconst fileMap = new Map<string, CheckFileGroup>();\n\n\tfor (const e of errors) {\n\t\tconst fp = e.filePath ?? \"\";\n\t\tif (!fileMap.has(fp)) {\n\t\t\tfileMap.set(fp, { file: fp, errors: [], warnings: [] });\n\t\t}\n\t\tconst entry: CheckFileError = {\n\t\t\tcode: e.code,\n\t\t\tsymbol: e.symbolName ?? \"\",\n\t\t\tkind: e.symbolKind ?? \"\",\n\t\t\tline: e.line,\n\t\t\tmessage: e.message,\n\t\t};\n\t\tif (includeFix && e.suggestedFix !== undefined) {\n\t\t\tentry.suggestedFix = e.suggestedFix;\n\t\t\tentry.agentAction = \"retry_modified\";\n\t\t}\n\t\tfileMap.get(fp)?.errors.push(entry);\n\t}\n\n\tfor (const w of warnings) {\n\t\tconst fp = w.filePath ?? \"\";\n\t\tif (!fileMap.has(fp)) {\n\t\t\tfileMap.set(fp, { file: fp, errors: [], warnings: [] });\n\t\t}\n\t\tfileMap.get(fp)?.warnings.push({\n\t\t\tcode: w.code,\n\t\t\tsymbol: \"\",\n\t\t\tkind: \"\",\n\t\t\tline: w.line,\n\t\t\tmessage: w.message,\n\t\t});\n\t}\n\n\t// Deterministic sort: most errors first, then lexicographic path\n\treturn Array.from(fileMap.values()).sort(\n\t\t(a, b) => b.errors.length - a.errors.length || a.file.localeCompare(b.file),\n\t);\n}\n\n/**\n * Computes the next CLI command hint for the agent.\n * @internal\n */\nfunction computeNextCommand(\n\ttriage: CheckTriage,\n\tfilters: { rule?: string; file?: string },\n\tpage: CheckPage | undefined,\n\thasFilters: boolean,\n): string {\n\t// If paginated and has more, suggest next page\n\tif (page?.hasMore) {\n\t\tconst parts = [\"forge-ts check --mvi full\"];\n\t\tif (filters.rule) parts.push(`--rule ${filters.rule}`);\n\t\tif (filters.file) parts.push(`--file \"${filters.file}\"`);\n\t\tparts.push(`--limit ${page.limit} --offset ${page.offset + page.limit}`);\n\t\treturn parts.join(\" \");\n\t}\n\n\t// If no filters yet, suggest drilling into the quickest-win rule\n\tif (!hasFilters && triage.fixOrder.length > 0) {\n\t\tconst quickWin = triage.fixOrder[0];\n\t\treturn `forge-ts check --rule ${quickWin.code} --mvi full`;\n\t}\n\n\t// If filtered by rule, suggest re-checking after fixes\n\treturn \"forge-ts check --mvi minimal\";\n}\n\n/**\n * Builds a CheckResult with triage, filtering, pagination, and MVI differentiation.\n * @internal\n */\nfunction buildCheckResult(\n\trawErrors: ForgeError[],\n\trawWarnings: ForgeWarning[],\n\texportedSymbolCount: number,\n\tduration: number,\n\tsuccess: boolean,\n\tmviLevel: string,\n\tfilters: { rule?: string; file?: string },\n\tlimit: number,\n\toffset: number,\n): CheckResult {\n\tconst uniqueFiles = new Set([\n\t\t...rawErrors.map((e) => e.filePath),\n\t\t...rawWarnings.map((w) => w.filePath),\n\t]);\n\n\tconst summary = {\n\t\terrors: rawErrors.length,\n\t\twarnings: rawWarnings.length,\n\t\tfiles: uniqueFiles.size,\n\t\tsymbols: exportedSymbolCount,\n\t\tduration,\n\t};\n\n\tif (mviLevel === \"minimal\") {\n\t\treturn { success, summary };\n\t}\n\n\t// Triage: always computed from FULL unfiltered data (bounded by rule count + top 20)\n\tconst triage =\n\t\trawErrors.length > 0 || rawWarnings.length > 0\n\t\t\t? computeTriage(rawErrors, rawWarnings)\n\t\t\t: undefined;\n\n\t// Apply filters\n\tconst hasFilters = !!(filters.rule || filters.file);\n\tconst { errors: filteredErrors, warnings: filteredWarnings } = hasFilters\n\t\t? applyFilters(rawErrors, rawWarnings, filters)\n\t\t: { errors: rawErrors, warnings: rawWarnings };\n\n\t// Include suggestedFix at full MVI or when filters are active (targeted drill-down)\n\tconst includeFix = mviLevel === \"full\" || hasFilters;\n\n\t// Group and paginate\n\tconst allGroups = groupByFile(filteredErrors, filteredWarnings, includeFix);\n\tconst total = allGroups.length;\n\tconst pagedGroups = allGroups.slice(offset, offset + limit);\n\tconst hasMore = offset + limit < total;\n\n\tconst page: CheckPage = { offset, limit, hasMore, total };\n\n\tconst nextCommand = triage ? computeNextCommand(triage, filters, page, hasFilters) : undefined;\n\n\tconst result: CheckResult = {\n\t\tsuccess,\n\t\tsummary,\n\t\ttriage,\n\t\tbyFile: pagedGroups,\n\t\tpage,\n\t\tnextCommand,\n\t};\n\n\tif (hasFilters) {\n\t\tresult.filters = {\n\t\t\trule: filters.rule || undefined,\n\t\t\tfile: filters.file || undefined,\n\t\t};\n\t}\n\n\treturn result;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the TSDoc enforcement pass and returns a typed command output.\n *\n * @param args - CLI arguments for the check command.\n * @returns A typed `CommandOutput<CheckResult>`.\n * @example\n * ```typescript\n * import { runCheck } from \"@forge-ts/cli/commands/check\";\n * const output = await runCheck({ cwd: process.cwd() });\n * console.log(output.data.summary.errors); // number of TSDoc errors found\n * ```\n * @public\n */\nexport async function runCheck(args: CheckArgs): Promise<CommandOutput<CheckResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tif (args.strict !== undefined) {\n\t\tconfig.enforce.strict = args.strict;\n\t}\n\n\tconst result = await enforce(config);\n\t// Default to \"standard\" MVI — gives triage + paginated overview.\n\t// Agents drill into specific rules/files with --mvi full.\n\tconst mviLevel = args.mvi ?? \"standard\";\n\tconst limit = args.limit ?? 20;\n\tconst offset = args.offset ?? 0;\n\tconst filters = { rule: args.rule, file: args.file };\n\n\tconst exportedSymbolCount = result.symbols.filter((s) => s.exported).length;\n\n\tconst data = buildCheckResult(\n\t\tresult.errors,\n\t\tresult.warnings,\n\t\texportedSymbolCount,\n\t\tresult.duration,\n\t\tresult.success,\n\t\tmviLevel,\n\t\tfilters,\n\t\tlimit,\n\t\toffset,\n\t);\n\n\t// Populate top-level errors so the LAFS envelope error code is actionable.\n\tconst cliErrors = result.success\n\t\t? undefined\n\t\t: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_CHECK_FAILED\",\n\t\t\t\t\tmessage: `TSDoc coverage check failed: ${result.errors.length} error(s), ${result.warnings.length} warning(s) across ${data.summary.files} file(s)`,\n\t\t\t\t},\n\t\t\t];\n\n\t// Surface config warnings so agents see them in the JSON envelope\n\tconst cliWarnings = config._configWarnings?.map((msg) => ({\n\t\tcode: \"CONFIG_WARNING\",\n\t\tmessage: msg,\n\t\tfilePath: \"\",\n\t\tline: 0,\n\t\tcolumn: 0,\n\t}));\n\n\treturn {\n\t\toperation: \"check\",\n\t\tsuccess: result.success,\n\t\tdata,\n\t\terrors: cliErrors,\n\t\twarnings: cliWarnings,\n\t\tduration: result.duration,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a CheckResult as human-readable, actionable text.\n * @internal\n */\nfunction formatCheckHuman(result: CheckResult): string {\n\tconst lines: string[] = [];\n\n\tif (result.success) {\n\t\tlines.push(\n\t\t\t`forge-ts check: OK (${result.summary.symbols} symbol(s) checked, ${result.summary.duration}ms)`,\n\t\t);\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\"forge-ts check: FAILED\\n\");\n\tlines.push(\n\t\t` ${result.summary.errors} error(s), ${result.summary.warnings} warning(s) across ${result.summary.files} file(s) (${result.summary.symbols} symbols checked)\\n`,\n\t);\n\n\t// Triage: rule breakdown\n\tif (result.triage) {\n\t\tlines.push(\" Rules:\");\n\t\tfor (const r of result.triage.byRule) {\n\t\t\tlines.push(` ${r.code} ${r.rule}: ${r.count} violation(s) in ${r.files} file(s)`);\n\t\t}\n\t\tlines.push(\"\");\n\n\t\tif (result.triage.fixOrder.length > 0) {\n\t\t\tconst qw = result.triage.fixOrder[0];\n\t\t\tlines.push(\n\t\t\t\t` Quick win: fix ${qw.code} (${qw.rule}) — ${qw.count} issue(s) in ${qw.files} file(s)`,\n\t\t\t);\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\t// Active filters\n\tif (result.filters) {\n\t\tconst parts = [];\n\t\tif (result.filters.rule) parts.push(`rule=${result.filters.rule}`);\n\t\tif (result.filters.file) parts.push(`file=${result.filters.file}`);\n\t\tlines.push(` Filtered: ${parts.join(\", \")}`);\n\t\tlines.push(\"\");\n\t}\n\n\t// Per-file errors\n\tif (result.byFile && result.byFile.length > 0) {\n\t\tfor (const group of result.byFile) {\n\t\t\tif (group.errors.length > 0) {\n\t\t\t\tlines.push(` ${group.file} (${group.errors.length} error(s)):`);\n\t\t\t\tfor (const err of group.errors) {\n\t\t\t\t\tconst symbolPart = err.symbol\n\t\t\t\t\t\t? `${err.symbol} (${err.kind}:${err.line})`\n\t\t\t\t\t\t: `line ${err.line}`;\n\t\t\t\t\tlines.push(` ${err.code} ${symbolPart} — ${err.message}`);\n\t\t\t\t\tif (err.suggestedFix) {\n\t\t\t\t\t\tfor (const fixLine of err.suggestedFix.split(\"\\n\")) {\n\t\t\t\t\t\t\tlines.push(` ${fixLine}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (group.warnings.length > 0) {\n\t\t\t\tlines.push(` ${group.file} (${group.warnings.length} warning(s)):`);\n\t\t\t\tfor (const w of group.warnings) {\n\t\t\t\t\tlines.push(` ${w.code} line ${w.line} — ${w.message}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Pagination footer\n\tif (result.page?.hasMore) {\n\t\tlines.push(\n\t\t\t`\\n Showing ${result.page.offset + 1}-${result.page.offset + (result.byFile?.length ?? 0)} of ${result.page.total} file(s). Use --offset ${result.page.offset + result.page.limit} to see more.`,\n\t\t);\n\t}\n\n\t// Next command hint\n\tif (result.nextCommand) {\n\t\tlines.push(`\\n Next: ${result.nextCommand}`);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Citty command definition for `forge-ts check`.\n * @public\n */\nexport const checkCommand = defineCommand({\n\tmeta: {\n\t\tname: \"check\",\n\t\tdescription: \"Lint TSDoc coverage on exported symbols\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tstrict: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Treat warnings as errors\",\n\t\t\tdefault: false,\n\t\t},\n\t\tverbose: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Show detailed output\",\n\t\t\tdefault: false,\n\t\t},\n\t\trule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Filter by rule code (e.g., E001, W004)\",\n\t\t},\n\t\tfile: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Filter by file path (substring match)\",\n\t\t},\n\t\tlimit: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Max file groups in output (default: 20)\",\n\t\t},\n\t\toffset: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Skip N file groups for pagination (default: 0)\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runCheck({\n\t\t\tcwd: args.cwd,\n\t\t\tstrict: args.strict,\n\t\t\tverbose: args.verbose,\n\t\t\tmvi: args.mvi,\n\t\t\trule: args.rule,\n\t\t\tfile: args.file,\n\t\t\tlimit: args.limit ? parseInt(args.limit, 10) : undefined,\n\t\t\toffset: args.offset ? parseInt(args.offset, 10) : undefined,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatCheckHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts doctor` command — project integrity check and repair.\n *\n * Validates that all forge-ts configuration files, dependencies, and\n * guard settings are correctly set up. Optionally auto-fixes resolvable\n * issues with `--fix`.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Status of a single doctor check.\n * @public\n */\nexport type DoctorCheckStatus = \"pass\" | \"warn\" | \"error\" | \"info\";\n\n/**\n * Result of a single doctor check.\n *\n * @public\n */\nexport interface DoctorCheckResult {\n\t/** Name of the check. */\n\tname: string;\n\t/** Status of the check. */\n\tstatus: DoctorCheckStatus;\n\t/** Human-readable message. */\n\tmessage: string;\n\t/** Whether this issue can be auto-fixed with --fix. */\n\tfixable: boolean;\n}\n\n/**\n * Result of the `doctor` command.\n *\n * @example\n * ```typescript\n * import { runDoctor } from \"@forge-ts/cli/commands/doctor\";\n * const output = await runDoctor({ cwd: process.cwd() });\n * console.log(output.data.summary.passed); // number of passed checks\n * ```\n * @public\n */\nexport interface DoctorResult {\n\t/** Whether all checks passed without errors. */\n\tsuccess: boolean;\n\t/** Individual check results. */\n\tchecks: DoctorCheckResult[];\n\t/** Summary counts. */\n\tsummary: {\n\t\tpassed: number;\n\t\twarnings: number;\n\t\terrors: number;\n\t\tinfo: number;\n\t};\n\t/** Files that were fixed (only populated when --fix is used). */\n\tfixed: string[];\n}\n\n/**\n * Arguments for the `doctor` command.\n * @internal\n */\nexport interface DoctorArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Auto-fix resolvable issues. */\n\tfix?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Safely reads and parses a JSON file.\n * @internal\n */\nfunction readJsonSafe<T>(filePath: string): T | null {\n\tif (!existsSync(filePath)) {\n\t\treturn null;\n\t}\n\ttry {\n\t\tconst raw = readFileSync(filePath, \"utf8\");\n\t\treturn JSON.parse(raw) as T;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Default forge-ts.config.ts content for --fix generation.\n * @internal\n */\nconst DEFAULT_CONFIG_CONTENT = `import { defineConfig } from \"@forge-ts/core\";\n\nexport default defineConfig({\n rootDir: \".\",\n tsconfig: \"tsconfig.json\",\n outDir: \"docs/generated\",\n enforce: {\n enabled: true,\n minVisibility: \"public\",\n strict: false,\n },\n gen: {\n enabled: true,\n formats: [\"mdx\"],\n llmsTxt: true,\n readmeSync: false,\n ssgTarget: \"mintlify\",\n },\n});\n`;\n\n/**\n * Default tsdoc.json content for --fix generation.\n * @internal\n */\nconst DEFAULT_TSDOC_CONTENT = JSON.stringify(\n\t{\n\t\t$schema:\n\t\t\t\"https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json\",\n\t\textends: [\"@forge-ts/tsdoc-config/tsdoc.json\"],\n\t},\n\tnull,\n\t\"\\t\",\n);\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the doctor integrity check flow.\n *\n * Checks:\n * 1. forge-ts.config.ts — exists and loadable\n * 2. tsdoc.json — exists and extends @forge-ts/tsdoc-config\n * 3. @forge-ts/tsdoc-config — installed in node_modules\n * 4. TypeScript — installed\n * 5. tsconfig.json — exists and has strict mode\n * 6. biome.json — exists (informational)\n * 7. .forge-lock.json — exists, valid, matches config\n * 8. .forge-audit.jsonl — exists and event count\n * 9. .forge-bypass.json — exists and active bypasses\n * 10. Git hooks — forge-ts check in pre-commit\n *\n * @param args - CLI arguments for the doctor command.\n * @returns A typed `CommandOutput<DoctorResult>`.\n * @example\n * ```typescript\n * import { runDoctor } from \"@forge-ts/cli/commands/doctor\";\n * const output = await runDoctor({ cwd: process.cwd(), fix: false });\n * console.log(output.data.summary); // { passed: 7, warnings: 2, errors: 1, info: 0 }\n * ```\n * @public\n */\nexport async function runDoctor(\n\targs: DoctorArgs,\n): Promise<CommandOutput<DoctorResult>> {\n\tconst start = Date.now();\n\tconst rootDir = args.cwd ?? process.cwd();\n\tconst fix = args.fix ?? false;\n\n\tconst checks: DoctorCheckResult[] = [];\n\tconst fixed: string[] = [];\n\n\t// -----------------------------------------------------------------------\n\t// Check 1: forge-ts.config.ts\n\t// -----------------------------------------------------------------------\n\n\tconst configPath = join(rootDir, \"forge-ts.config.ts\");\n\tconst configJsPath = join(rootDir, \"forge-ts.config.js\");\n\tif (existsSync(configPath) || existsSync(configJsPath)) {\n\t\tconst which = existsSync(configPath)\n\t\t\t? \"forge-ts.config.ts\"\n\t\t\t: \"forge-ts.config.js\";\n\t\tchecks.push({\n\t\t\tname: \"forge-ts.config\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: `${which} — found`,\n\t\t\tfixable: false,\n\t\t});\n\t} else if (fix) {\n\t\tawait mkdir(rootDir, { recursive: true });\n\t\tawait writeFile(configPath, DEFAULT_CONFIG_CONTENT, \"utf8\");\n\t\tfixed.push(\"forge-ts.config.ts\");\n\t\tchecks.push({\n\t\t\tname: \"forge-ts.config\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: \"forge-ts.config.ts — created by --fix\",\n\t\t\tfixable: true,\n\t\t});\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \"forge-ts.config\",\n\t\t\tstatus: \"error\",\n\t\t\tmessage:\n\t\t\t\t\"forge-ts.config.ts — MISSING (run forge-ts init or forge-ts doctor --fix)\",\n\t\t\tfixable: true,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 2: tsdoc.json\n\t// -----------------------------------------------------------------------\n\n\tconst tsdocPath = join(rootDir, \"tsdoc.json\");\n\tif (existsSync(tsdocPath)) {\n\t\tconst tsdoc = readJsonSafe<{\n\t\t\textends?: string[];\n\t\t}>(tsdocPath);\n\t\tif (\n\t\t\ttsdoc?.extends &&\n\t\t\ttsdoc.extends.includes(\"@forge-ts/tsdoc-config/tsdoc.json\")\n\t\t) {\n\t\t\tchecks.push({\n\t\t\t\tname: \"tsdoc.json\",\n\t\t\t\tstatus: \"pass\",\n\t\t\t\tmessage: \"tsdoc.json — extends @forge-ts/tsdoc-config\",\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t} else {\n\t\t\tchecks.push({\n\t\t\t\tname: \"tsdoc.json\",\n\t\t\t\tstatus: \"warn\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"tsdoc.json — does not extend @forge-ts/tsdoc-config\",\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t}\n\t} else if (fix) {\n\t\tawait writeFile(tsdocPath, `${DEFAULT_TSDOC_CONTENT}\\n`, \"utf8\");\n\t\tfixed.push(\"tsdoc.json\");\n\t\tchecks.push({\n\t\t\tname: \"tsdoc.json\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: \"tsdoc.json — created by --fix\",\n\t\t\tfixable: true,\n\t\t});\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \"tsdoc.json\",\n\t\t\tstatus: \"error\",\n\t\t\tmessage:\n\t\t\t\t\"tsdoc.json — MISSING (run forge-ts init or forge-ts doctor --fix)\",\n\t\t\tfixable: true,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 3: @forge-ts/tsdoc-config installed\n\t// -----------------------------------------------------------------------\n\n\tconst tsdocConfigModulePath = join(\n\t\trootDir,\n\t\t\"node_modules\",\n\t\t\"@forge-ts\",\n\t\t\"tsdoc-config\",\n\t\t\"package.json\",\n\t);\n\tif (existsSync(tsdocConfigModulePath)) {\n\t\tconst tsdocPkg = readJsonSafe<{ version?: string }>(\n\t\t\ttsdocConfigModulePath,\n\t\t);\n\t\tconst version = tsdocPkg?.version ?? \"unknown\";\n\t\tchecks.push({\n\t\t\tname: \"@forge-ts/tsdoc-config\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: `@forge-ts/tsdoc-config — installed (${version})`,\n\t\t\tfixable: false,\n\t\t});\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \"@forge-ts/tsdoc-config\",\n\t\t\tstatus: \"warn\",\n\t\t\tmessage:\n\t\t\t\t\"@forge-ts/tsdoc-config — MISSING (run npm install @forge-ts/tsdoc-config)\",\n\t\t\tfixable: false,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 4: TypeScript installed\n\t// -----------------------------------------------------------------------\n\n\tconst tsPkgPath = join(\n\t\trootDir,\n\t\t\"node_modules\",\n\t\t\"typescript\",\n\t\t\"package.json\",\n\t);\n\tif (existsSync(tsPkgPath)) {\n\t\tconst tsPkg = readJsonSafe<{ version?: string }>(tsPkgPath);\n\t\tconst version = tsPkg?.version ?? \"unknown\";\n\t\tchecks.push({\n\t\t\tname: \"TypeScript\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: `TypeScript — ${version}`,\n\t\t\tfixable: false,\n\t\t});\n\t} else {\n\t\t// Check package.json deps as fallback\n\t\tconst pkgPath = join(rootDir, \"package.json\");\n\t\tconst pkg = readJsonSafe<{\n\t\t\tdependencies?: Record<string, string>;\n\t\t\tdevDependencies?: Record<string, string>;\n\t\t}>(pkgPath);\n\t\tconst allDeps = {\n\t\t\t...pkg?.dependencies,\n\t\t\t...pkg?.devDependencies,\n\t\t};\n\t\tif (\"typescript\" in allDeps) {\n\t\t\tchecks.push({\n\t\t\t\tname: \"TypeScript\",\n\t\t\t\tstatus: \"warn\",\n\t\t\t\tmessage: `TypeScript — in package.json (${allDeps.typescript}) but not in node_modules`,\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t} else {\n\t\t\tchecks.push({\n\t\t\t\tname: \"TypeScript\",\n\t\t\t\tstatus: \"error\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"TypeScript — MISSING (run npm install -D typescript)\",\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t}\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 5: tsconfig.json\n\t// -----------------------------------------------------------------------\n\n\tconst tsconfigPath = join(rootDir, \"tsconfig.json\");\n\tif (existsSync(tsconfigPath)) {\n\t\tconst tsconfig = readJsonSafe<{\n\t\t\tcompilerOptions?: {\n\t\t\t\tstrict?: boolean;\n\t\t\t\tstrictNullChecks?: boolean;\n\t\t\t\tnoImplicitAny?: boolean;\n\t\t\t};\n\t\t}>(tsconfigPath);\n\t\tif (tsconfig?.compilerOptions?.strict === true) {\n\t\t\tchecks.push({\n\t\t\t\tname: \"tsconfig.json\",\n\t\t\t\tstatus: \"pass\",\n\t\t\t\tmessage: \"tsconfig.json — strict mode enabled\",\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t} else {\n\t\t\t// strict is not true — report missing flags\n\t\t\tconst missingFlags: string[] = [\"strict\"];\n\t\t\tif (!tsconfig?.compilerOptions?.strictNullChecks) {\n\t\t\t\tmissingFlags.push(\"strictNullChecks\");\n\t\t\t}\n\t\t\tif (!tsconfig?.compilerOptions?.noImplicitAny) {\n\t\t\t\tmissingFlags.push(\"noImplicitAny\");\n\t\t\t}\n\t\t\tchecks.push({\n\t\t\t\tname: \"tsconfig.json\",\n\t\t\t\tstatus: \"warn\",\n\t\t\t\tmessage: `tsconfig.json — strict mode not fully enabled (missing ${missingFlags.join(\", \")})`,\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \"tsconfig.json\",\n\t\t\tstatus: \"warn\",\n\t\t\tmessage: \"tsconfig.json — not found\",\n\t\t\tfixable: false,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 6: biome.json\n\t// -----------------------------------------------------------------------\n\n\tconst biomePath = join(rootDir, \"biome.json\");\n\tconst biomecPath = join(rootDir, \"biome.jsonc\");\n\tif (existsSync(biomePath) || existsSync(biomecPath)) {\n\t\tchecks.push({\n\t\t\tname: \"biome.json\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: \"biome.json — found\",\n\t\t\tfixable: false,\n\t\t});\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \"biome.json\",\n\t\t\tstatus: \"info\",\n\t\t\tmessage: \"biome.json — not found (optional)\",\n\t\t\tfixable: false,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 7: .forge-lock.json\n\t// -----------------------------------------------------------------------\n\n\tconst lockPath = join(rootDir, \".forge-lock.json\");\n\tif (existsSync(lockPath)) {\n\t\tconst lock = readJsonSafe<{\n\t\t\tlockedAt?: string;\n\t\t\tlockedBy?: string;\n\t\t\tconfig?: { rules?: Record<string, string> };\n\t\t}>(lockPath);\n\t\tif (lock?.lockedAt) {\n\t\t\tchecks.push({\n\t\t\t\tname: \".forge-lock.json\",\n\t\t\t\tstatus: \"pass\",\n\t\t\t\tmessage: `.forge-lock.json — locked at ${lock.lockedAt}`,\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t} else {\n\t\t\tchecks.push({\n\t\t\t\tname: \".forge-lock.json\",\n\t\t\t\tstatus: \"warn\",\n\t\t\t\tmessage:\n\t\t\t\t\t\".forge-lock.json — invalid format (run forge-ts lock to regenerate)\",\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \".forge-lock.json\",\n\t\t\tstatus: \"warn\",\n\t\t\tmessage:\n\t\t\t\t\".forge-lock.json — not locked (run forge-ts lock)\",\n\t\t\tfixable: false,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 8: .forge-audit.jsonl\n\t// -----------------------------------------------------------------------\n\n\tconst auditPath = join(rootDir, \".forge-audit.jsonl\");\n\tif (existsSync(auditPath)) {\n\t\ttry {\n\t\t\tconst raw = readFileSync(auditPath, \"utf8\");\n\t\t\tconst lines = raw\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.filter((line) => line.trim().length > 0);\n\t\t\tchecks.push({\n\t\t\t\tname: \".forge-audit.jsonl\",\n\t\t\t\tstatus: \"info\",\n\t\t\t\tmessage: `.forge-audit.jsonl — ${lines.length} event${lines.length !== 1 ? \"s\" : \"\"}`,\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t} catch {\n\t\t\tchecks.push({\n\t\t\t\tname: \".forge-audit.jsonl\",\n\t\t\t\tstatus: \"warn\",\n\t\t\t\tmessage: \".forge-audit.jsonl — exists but unreadable\",\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \".forge-audit.jsonl\",\n\t\t\tstatus: \"info\",\n\t\t\tmessage: \".forge-audit.jsonl — no audit trail\",\n\t\t\tfixable: false,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 9: .forge-bypass.json\n\t// -----------------------------------------------------------------------\n\n\tconst bypassPath = join(rootDir, \".forge-bypass.json\");\n\tif (existsSync(bypassPath)) {\n\t\tconst records = readJsonSafe<\n\t\t\tArray<{ expiresAt?: string }>\n\t\t>(bypassPath);\n\t\tif (records && Array.isArray(records)) {\n\t\t\tconst now = new Date();\n\t\t\tconst active = records.filter(\n\t\t\t\t(r) => r.expiresAt && new Date(r.expiresAt) > now,\n\t\t\t);\n\t\t\tconst expired = records.length - active.length;\n\t\t\tif (active.length > 0) {\n\t\t\t\tchecks.push({\n\t\t\t\t\tname: \".forge-bypass.json\",\n\t\t\t\t\tstatus: \"info\",\n\t\t\t\t\tmessage: `.forge-bypass.json — ${active.length} active bypass${active.length !== 1 ? \"es\" : \"\"}`,\n\t\t\t\t\tfixable: false,\n\t\t\t\t});\n\t\t\t} else if (expired > 0) {\n\t\t\t\tchecks.push({\n\t\t\t\t\tname: \".forge-bypass.json\",\n\t\t\t\t\tstatus: \"info\",\n\t\t\t\t\tmessage: `.forge-bypass.json — ${expired} expired bypass${expired !== 1 ? \"es\" : \"\"} (run cleanup)`,\n\t\t\t\t\tfixable: false,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tchecks.push({\n\t\t\t\t\tname: \".forge-bypass.json\",\n\t\t\t\t\tstatus: \"pass\",\n\t\t\t\t\tmessage: \".forge-bypass.json — no active bypasses\",\n\t\t\t\t\tfixable: false,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tchecks.push({\n\t\t\t\tname: \".forge-bypass.json\",\n\t\t\t\tstatus: \"warn\",\n\t\t\t\tmessage: \".forge-bypass.json — invalid format\",\n\t\t\t\tfixable: false,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \".forge-bypass.json\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: \".forge-bypass.json — no active bypasses\",\n\t\t\tfixable: false,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Check 10: Git hooks\n\t// -----------------------------------------------------------------------\n\n\tconst huskyPreCommit = join(rootDir, \".husky\", \"pre-commit\");\n\tconst lefthookYml = join(rootDir, \"lefthook.yml\");\n\n\tlet hookConfigured = false;\n\tlet hookLocation = \"\";\n\n\tif (existsSync(huskyPreCommit)) {\n\t\ttry {\n\t\t\tconst content = readFileSync(huskyPreCommit, \"utf8\");\n\t\t\tif (content.includes(\"forge-ts check\")) {\n\t\t\t\thookConfigured = true;\n\t\t\t\thookLocation = \"husky pre-commit\";\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore read errors\n\t\t}\n\t}\n\n\tif (!hookConfigured && existsSync(lefthookYml)) {\n\t\ttry {\n\t\t\tconst content = readFileSync(lefthookYml, \"utf8\");\n\t\t\tif (content.includes(\"forge-ts check\")) {\n\t\t\t\thookConfigured = true;\n\t\t\t\thookLocation = \"lefthook\";\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore read errors\n\t\t}\n\t}\n\n\tif (hookConfigured) {\n\t\tchecks.push({\n\t\t\tname: \"Git hooks\",\n\t\t\tstatus: \"pass\",\n\t\t\tmessage: `Git hooks — forge-ts check in ${hookLocation}`,\n\t\t\tfixable: false,\n\t\t});\n\t} else {\n\t\tchecks.push({\n\t\t\tname: \"Git hooks\",\n\t\t\tstatus: \"warn\",\n\t\t\tmessage:\n\t\t\t\t\"Git hooks — forge-ts check not in pre-commit (run forge-ts init hooks)\",\n\t\t\tfixable: false,\n\t\t});\n\t}\n\n\t// -----------------------------------------------------------------------\n\t// Summary\n\t// -----------------------------------------------------------------------\n\n\tconst summary = {\n\t\tpassed: checks.filter((c) => c.status === \"pass\").length,\n\t\twarnings: checks.filter((c) => c.status === \"warn\").length,\n\t\terrors: checks.filter((c) => c.status === \"error\").length,\n\t\tinfo: checks.filter((c) => c.status === \"info\").length,\n\t};\n\n\tconst data: DoctorResult = {\n\t\tsuccess: summary.errors === 0,\n\t\tchecks,\n\t\tsummary,\n\t\tfixed,\n\t};\n\n\treturn {\n\t\toperation: \"doctor\",\n\t\tsuccess: summary.errors === 0,\n\t\tdata,\n\t\tduration: Date.now() - start,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Status prefix labels for human output.\n * @internal\n */\nconst STATUS_LABELS: Record<DoctorCheckStatus, string> = {\n\tpass: \"[PASS]\",\n\twarn: \"[WARN]\",\n\terror: \"[FAIL]\",\n\tinfo: \"[INFO]\",\n};\n\n/**\n * Formats a DoctorResult as human-readable text.\n * @internal\n */\nfunction formatDoctorHuman(result: DoctorResult): string {\n\tconst lines: string[] = [];\n\n\tlines.push(\"\\nforge-ts doctor: project health check\\n\");\n\n\tfor (const check of result.checks) {\n\t\tconst label = STATUS_LABELS[check.status];\n\t\tlines.push(` ${label} ${check.message}`);\n\t}\n\n\t// Fixed files\n\tif (result.fixed.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(\" Fixed:\");\n\t\tfor (const file of result.fixed) {\n\t\t\tlines.push(` ${file}`);\n\t\t}\n\t}\n\n\tlines.push(\"\");\n\tlines.push(\n\t\t` Summary: ${result.summary.passed} passed, ${result.summary.warnings} warning${result.summary.warnings !== 1 ? \"s\" : \"\"}, ${result.summary.errors} error${result.summary.errors !== 1 ? \"s\" : \"\"}`,\n\t);\n\n\tif (result.summary.errors > 0 || result.summary.warnings > 0) {\n\t\tlines.push(\n\t\t\t\" Run: forge-ts doctor --fix to auto-fix resolvable issues\",\n\t\t);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command definition\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts doctor`.\n *\n * Performs project integrity checks and optionally auto-fixes\n * resolvable issues with `--fix`.\n *\n * @example\n * ```typescript\n * import { doctorCommand } from \"@forge-ts/cli/commands/doctor\";\n * // Registered as a top-level subcommand of `forge-ts`\n * ```\n * @public\n */\nexport const doctorCommand = defineCommand({\n\tmeta: {\n\t\tname: \"doctor\",\n\t\tdescription: \"Project integrity check and repair\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tfix: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Auto-fix resolvable issues\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runDoctor({\n\t\t\tcwd: args.cwd,\n\t\t\tfix: args.fix,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\treturn formatDoctorHuman(data);\n\t\t\t}\n\t\t\treturn formatDoctorHuman(data);\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * The `forge-ts docs dev` command — starts a local doc preview server.\n *\n * Reads the ssgTarget from forge-ts config, looks up the adapter,\n * and spawns the correct dev server automatically.\n *\n * @packageDocumentation\n * @public\n */\n\nimport { spawn } from \"node:child_process\";\nimport { resolve } from \"node:path\";\nimport { loadConfig } from \"@forge-ts/core\";\nimport { DEFAULT_TARGET, getAdapter, type SSGTarget } from \"@forge-ts/gen\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\n\n/**\n * Starts the local dev server for the configured SSG target.\n *\n * Reads `gen.ssgTarget` from the forge-ts config, resolves the adapter,\n * and spawns the platform's dev server in the output directory.\n *\n * @param args - Command arguments.\n * @returns A promise that resolves when the server exits.\n *\n * @example\n * ```typescript\n * import { runDocsDev } from \"@forge-ts/cli\";\n * await runDocsDev({ cwd: \"./my-project\" });\n * ```\n * @public\n */\nexport async function runDocsDev(args: {\n\t/** Project root directory. */\n\tcwd?: string;\n\t/** Override the SSG target from config. */\n\ttarget?: string;\n\t/** Port to run the dev server on. */\n\tport?: string;\n}): Promise<void> {\n\tconst logger = createLogger();\n\tconst config = await loadConfig(args.cwd);\n\tconst target = (args.target ?? config.gen.ssgTarget ?? DEFAULT_TARGET) as SSGTarget;\n\tconst adapter = getAdapter(target);\n\tconst outDir = resolve(config.outDir);\n\tconst devCmd = adapter.getDevCommand(outDir);\n\n\tlogger.info(`Starting ${devCmd.label}...`);\n\tlogger.info(` Target: ${target}`);\n\tlogger.info(` Directory: ${outDir}`);\n\tlogger.info(` URL: ${devCmd.url}`);\n\tlogger.info(\"\");\n\n\tconst spawnArgs = [...devCmd.args];\n\tif (args.port) {\n\t\tspawnArgs.push(\"--port\", args.port);\n\t}\n\n\tconst proc = spawn(devCmd.bin, spawnArgs, {\n\t\tcwd: devCmd.cwd,\n\t\tstdio: \"inherit\",\n\t\tshell: true,\n\t});\n\n\treturn new Promise<void>((_resolve, reject) => {\n\t\tproc.on(\"close\", (code) => {\n\t\t\tif (code === 0) {\n\t\t\t\t_resolve();\n\t\t\t} else {\n\t\t\t\treject(new Error(`${devCmd.label} exited with code ${code}`));\n\t\t\t}\n\t\t});\n\t\tproc.on(\"error\", reject);\n\t});\n}\n\n/**\n * Citty command definition for `forge-ts docs dev`.\n *\n * @example\n * ```typescript\n * import { docsDevCommand } from \"@forge-ts/cli\";\n * ```\n * @public\n */\nexport const docsDevCommand = defineCommand({\n\tmeta: {\n\t\tname: \"dev\",\n\t\tdescription: \"Start a local doc preview server\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\ttarget: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SSG target override (reads from config by default)\",\n\t\t},\n\t\tport: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Port for the dev server\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tawait runDocsDev(args);\n\t},\n});\n","import { existsSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { loadConfig } from \"@forge-ts/core\";\nimport {\n\ttype AdapterContext,\n\tDEFAULT_TARGET,\n\tgetAdapter,\n\tgetAvailableTargets,\n\ttype SSGTarget,\n} from \"@forge-ts/gen\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Result of the `init docs` command.\n *\n * @example\n * ```typescript\n * import { runInitDocs } from \"@forge-ts/cli/commands/init-docs\";\n * const output = await runInitDocs({ target: \"mintlify\" });\n * console.log(output.data.summary.filesCreated); // number of files written\n * ```\n * @public\n */\nexport interface InitDocsResult {\n\t/** Whether the scaffold succeeded. */\n\tsuccess: boolean;\n\t/** The SSG target that was scaffolded. */\n\ttarget: SSGTarget;\n\t/** Summary of what was created. */\n\tsummary: {\n\t\t/** Number of files written to disk. */\n\t\tfilesCreated: number;\n\t\t/** Number of npm dependencies declared by the adapter. */\n\t\tdependencies: number;\n\t\t/** Number of package.json scripts declared by the adapter. */\n\t\tscripts: number;\n\t};\n\t/** Relative paths of all files created. */\n\tfiles: string[];\n\t/** Post-scaffold instructions for the user. */\n\tinstructions: string[];\n}\n\n/**\n * Arguments for the `init docs` command.\n * @internal\n */\nexport interface InitDocsArgs {\n\t/** SSG target to scaffold. Defaults to {@link DEFAULT_TARGET}. */\n\ttarget?: string;\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Output directory for the doc site (default: outDir from config or ./docs). */\n\toutDir?: string;\n\t/** Overwrite an existing scaffold without prompting. */\n\tforce?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Scaffolds a documentation site for the target SSG platform.\n *\n * Resolves the target from args, validates it, checks for an existing\n * scaffold, calls the adapter's `scaffold()` method, and writes all files\n * produced by the manifest to `outDir`.\n *\n * @param args - CLI arguments for the init docs command.\n * @returns A typed `CommandOutput<InitDocsResult>`.\n * @example\n * ```typescript\n * import { runInitDocs } from \"@forge-ts/cli/commands/init-docs\";\n * const output = await runInitDocs({ target: \"mintlify\", cwd: process.cwd() });\n * console.log(output.data.files); // list of created file paths\n * ```\n * @public\n */\nexport async function runInitDocs(args: InitDocsArgs): Promise<CommandOutput<InitDocsResult>> {\n\tconst start = Date.now();\n\n\t// 1. Resolve target\n\tconst rawTarget = args.target ?? DEFAULT_TARGET;\n\tconst available = getAvailableTargets();\n\tif (!available.includes(rawTarget as SSGTarget)) {\n\t\tconst err: ForgeCliError = {\n\t\t\tcode: \"INIT_UNKNOWN_TARGET\",\n\t\t\tmessage: `Unknown SSG target \"${rawTarget}\". Available targets: ${available.join(\", \")}`,\n\t\t};\n\t\treturn {\n\t\t\toperation: \"init.docs\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\ttarget: DEFAULT_TARGET,\n\t\t\t\tsummary: { filesCreated: 0, dependencies: 0, scripts: 0 },\n\t\t\t\tfiles: [],\n\t\t\t\tinstructions: [],\n\t\t\t},\n\t\t\terrors: [err],\n\t\t\tduration: Date.now() - start,\n\t\t};\n\t}\n\n\tconst target = rawTarget as SSGTarget;\n\tconst adapter = getAdapter(target);\n\n\t// 2. Load config to resolve outDir\n\tconst config = await loadConfig(args.cwd);\n\tconst outDir = args.outDir ? resolve(args.outDir) : config.outDir;\n\n\t// 3. Safety check: detect existing scaffold\n\tconst alreadyExists = await adapter.detectExisting(outDir);\n\tif (alreadyExists && !args.force) {\n\t\tconst err: ForgeCliError = {\n\t\t\tcode: \"INIT_ALREADY_EXISTS\",\n\t\t\tmessage: `Docs already scaffolded for ${target}. Use --force to overwrite.`,\n\t\t};\n\t\treturn {\n\t\t\toperation: \"init.docs\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\ttarget,\n\t\t\t\tsummary: { filesCreated: 0, dependencies: 0, scripts: 0 },\n\t\t\t\tfiles: [],\n\t\t\t\tinstructions: [],\n\t\t\t},\n\t\t\terrors: [err],\n\t\t\tduration: Date.now() - start,\n\t\t};\n\t}\n\n\t// 4. Check for cross-target collision (any other adapter already scaffolded)\n\tconst warnings: Array<{ code: string; message: string }> = [];\n\tfor (const otherTarget of available) {\n\t\tif (otherTarget === target) continue;\n\t\tconst otherAdapter = getAdapter(otherTarget as SSGTarget);\n\t\tconst otherExists = await otherAdapter.detectExisting(outDir);\n\t\tif (otherExists) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"INIT_TARGET_MISMATCH\",\n\t\t\t\tmessage: `Existing scaffold detected for ${otherTarget} but scaffolding for ${target}. Remove conflicting files to avoid issues.`,\n\t\t\t});\n\t\t}\n\t}\n\n\t// 5. Build AdapterContext — use an empty pages/symbols array for init\n\tconst projectName = config.rootDir.split(\"/\").pop() ?? \"Project\";\n\tconst context: AdapterContext = {\n\t\tconfig,\n\t\tprojectName,\n\t\tpages: [],\n\t\tsymbols: [],\n\t\toutDir,\n\t};\n\n\t// 6. Call adapter.scaffold() to get the ScaffoldManifest\n\tconst manifest = adapter.scaffold(context);\n\n\t// 7. Write all files from the manifest\n\tconst writtenFiles: string[] = [];\n\tfor (const file of manifest.files) {\n\t\tconst filePath = join(outDir, file.path);\n\t\tconst fileDir = filePath.substring(0, filePath.lastIndexOf(\"/\"));\n\t\tawait mkdir(fileDir, { recursive: true });\n\t\tawait writeFile(filePath, file.content, \"utf8\");\n\t\twrittenFiles.push(file.path);\n\t}\n\n\t// 8. Write tsdoc.json to project root (extends @forge-ts/tsdoc-config preset)\n\tif (config.tsdoc.writeConfig) {\n\t\tconst tsdocPath = join(config.rootDir, \"tsdoc.json\");\n\t\tif (existsSync(tsdocPath)) {\n\t\t\twarnings.push({\n\t\t\t\tcode: \"INIT_TSDOC_EXISTS\",\n\t\t\t\tmessage: \"tsdoc.json already exists — skipping. Remove it and re-run to regenerate.\",\n\t\t\t});\n\t\t} else {\n\t\t\tconst tsdocContent = JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\t$schema: \"https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json\",\n\t\t\t\t\textends: [\"@forge-ts/tsdoc-config/tsdoc.json\"],\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t\"\\t\",\n\t\t\t);\n\t\t\tawait mkdir(config.rootDir, { recursive: true });\n\t\t\tawait writeFile(tsdocPath, `${tsdocContent}\\n`, \"utf8\");\n\t\t\twrittenFiles.push(\"tsdoc.json\");\n\t\t}\n\t}\n\n\tconst depCount =\n\t\tObject.keys(manifest.dependencies).length + Object.keys(manifest.devDependencies).length;\n\tconst scriptCount = Object.keys(manifest.scripts).length;\n\n\tconst data: InitDocsResult = {\n\t\tsuccess: true,\n\t\ttarget,\n\t\tsummary: {\n\t\t\tfilesCreated: writtenFiles.length,\n\t\t\tdependencies: depCount,\n\t\t\tscripts: scriptCount,\n\t\t},\n\t\tfiles: writtenFiles,\n\t\tinstructions: manifest.instructions,\n\t};\n\n\treturn {\n\t\toperation: \"init.docs\",\n\t\tsuccess: true,\n\t\tdata,\n\t\twarnings:\n\t\t\twarnings.length > 0\n\t\t\t\t? warnings.map((w) => ({\n\t\t\t\t\t\tcode: w.code,\n\t\t\t\t\t\tmessage: w.message,\n\t\t\t\t\t\tfilePath: \"\",\n\t\t\t\t\t\tline: 0,\n\t\t\t\t\t\tcolumn: 0,\n\t\t\t\t\t}))\n\t\t\t\t: undefined,\n\t\tduration: Date.now() - start,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an InitDocsResult as human-readable text.\n * @internal\n */\nfunction formatInitDocsHuman(result: InitDocsResult): string {\n\tconst lines: string[] = [];\n\n\tif (!result.success) {\n\t\treturn \"\";\n\t}\n\n\tconst targetName = result.target.charAt(0).toUpperCase() + result.target.slice(1);\n\tlines.push(`\\n Scaffolding ${targetName} documentation site...\\n`);\n\n\tconst MAX_INLINE = 5;\n\tconst shown = result.files.slice(0, MAX_INLINE);\n\tconst remaining = result.files.length - shown.length;\n\n\tfor (const file of shown) {\n\t\tlines.push(` \\u2713 Created ${file}`);\n\t}\n\n\tif (remaining > 0) {\n\t\tlines.push(` ... (${remaining} more file${remaining !== 1 ? \"s\" : \"\"})`);\n\t}\n\n\tif (result.instructions.length > 0) {\n\t\tlines.push(\"\\n Next steps:\");\n\t\tresult.instructions.forEach((inst, idx) => {\n\t\t\tlines.push(` ${idx + 1}. ${inst}`);\n\t\t});\n\t}\n\n\tlines.push(\n\t\t`\\n ${result.summary.filesCreated} file${result.summary.filesCreated !== 1 ? \"s\" : \"\"} created for ${targetName} doc site.`,\n\t);\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command definition\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts init docs`.\n *\n * Scaffolds a complete documentation site for the target SSG platform.\n * Use `--json` for LAFS JSON envelope output (agent/CI-friendly).\n *\n * @example\n * ```typescript\n * import { initDocsCommand } from \"@forge-ts/cli/commands/init-docs\";\n * // Registered automatically as a subcommand of `forge-ts init`\n * ```\n * @public\n */\nexport const initDocsCommand = defineCommand({\n\tmeta: {\n\t\tname: \"init\",\n\t\tdescription: \"Scaffold a documentation site\",\n\t},\n\targs: {\n\t\ttarget: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: `SSG target: ${getAvailableTargets().join(\", \")} (default: ${DEFAULT_TARGET})`,\n\t\t},\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\t\"out-dir\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Output directory for doc site (default: ./docs)\",\n\t\t},\n\t\tforce: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Overwrite existing scaffold\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runInitDocs({\n\t\t\ttarget: args.target,\n\t\t\tcwd: args.cwd,\n\t\t\toutDir: args[\"out-dir\"],\n\t\t\tforce: args.force,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\tconst logger = createLogger();\n\t\t\t\tconst msg = cmd.errors?.[0]?.message ?? \"Scaffold failed\";\n\t\t\t\tlogger.error(msg);\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t\treturn formatInitDocsHuman(data);\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n\n// ---------------------------------------------------------------------------\n// Parent \"init\" command that exposes `forge-ts init docs`\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts init`.\n *\n * Exposes subcommands for scaffolding project artefacts.\n *\n * @example\n * ```typescript\n * import { initCommand } from \"@forge-ts/cli/commands/init-docs\";\n * // Registered automatically as a subcommand of `forge-ts`\n * ```\n * @public\n */\nexport const initCommand = defineCommand({\n\tmeta: {\n\t\tname: \"init\",\n\t\tdescription: \"Scaffold project artefacts\",\n\t},\n\tsubCommands: {\n\t\tdocs: initDocsCommand,\n\t},\n});\n","/**\n * `forge-ts init hooks` command — scaffolds git hook integration.\n *\n * Detects husky or lefthook in the project and generates appropriate\n * pre-commit hook files that run `forge-ts check` on each commit.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliWarning,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Detected hook manager in the project.\n * @public\n */\nexport type HookManager = \"husky\" | \"lefthook\" | \"none\";\n\n/**\n * Result of the `init hooks` command.\n *\n * @example\n * ```typescript\n * import { runInitHooks } from \"@forge-ts/cli/commands/init-hooks\";\n * const output = await runInitHooks({ cwd: process.cwd() });\n * console.log(output.data.hookManager); // \"husky\" | \"lefthook\" | \"none\"\n * ```\n * @public\n */\nexport interface InitHooksResult {\n\t/** Whether the hook scaffolding succeeded. */\n\tsuccess: boolean;\n\t/** The detected or chosen hook manager. */\n\thookManager: HookManager;\n\t/** Summary of what was created. */\n\tsummary: {\n\t\t/** Number of files written or updated. */\n\t\tfilesWritten: number;\n\t\t/** Number of files skipped (already existed). */\n\t\tfilesSkipped: number;\n\t};\n\t/** Relative paths of all files written. */\n\tfiles: string[];\n\t/** Post-scaffold instructions for the user. */\n\tinstructions: string[];\n}\n\n/**\n * Arguments for the `init hooks` command.\n * @internal\n */\nexport interface InitHooksArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Force overwrite existing hook files. */\n\tforce?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Detection helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Detects which hook manager is present in the project.\n *\n * Checks for:\n * - husky: `.husky/` directory or `husky` in package.json devDependencies\n * - lefthook: `lefthook.yml` or `lefthook` in package.json devDependencies\n *\n * @param rootDir - Absolute path to the project root.\n * @returns The detected hook manager, or \"none\" if neither is found.\n * @public\n */\nexport function detectHookManager(rootDir: string): HookManager {\n\t// Check for husky\n\tconst huskyDir = join(rootDir, \".husky\");\n\tif (existsSync(huskyDir)) {\n\t\treturn \"husky\";\n\t}\n\n\t// Check for lefthook\n\tconst lefthookYml = join(rootDir, \"lefthook.yml\");\n\tif (existsSync(lefthookYml)) {\n\t\treturn \"lefthook\";\n\t}\n\n\t// Check package.json devDependencies\n\tconst pkgJsonPath = join(rootDir, \"package.json\");\n\tif (existsSync(pkgJsonPath)) {\n\t\ttry {\n\t\t\tconst raw = readFileSync(pkgJsonPath, \"utf8\");\n\t\t\tconst pkg = JSON.parse(raw) as {\n\t\t\t\tdevDependencies?: Record<string, string>;\n\t\t\t\tdependencies?: Record<string, string>;\n\t\t\t};\n\t\t\tconst allDeps = { ...pkg.dependencies, ...pkg.devDependencies };\n\t\t\tif (\"husky\" in allDeps) return \"husky\";\n\t\t\tif (\"lefthook\" in allDeps) return \"lefthook\";\n\t\t} catch {\n\t\t\t// Ignore parse errors\n\t\t}\n\t}\n\n\treturn \"none\";\n}\n\n// ---------------------------------------------------------------------------\n// Hook content generators\n// ---------------------------------------------------------------------------\n\nconst HUSKY_PRE_COMMIT = `#!/usr/bin/env sh\n. \"$(dirname -- \"$0\")/_/husky.sh\"\n\nnpx forge-ts check\n`;\n\nconst LEFTHOOK_BLOCK = `pre-commit:\n commands:\n forge-ts-check:\n run: npx forge-ts check\n`;\n\n/**\n * Generates the husky pre-commit hook file content.\n * @internal\n */\nexport function generateHuskyHook(): string {\n\treturn HUSKY_PRE_COMMIT;\n}\n\n/**\n * Generates the lefthook pre-commit block.\n * @internal\n */\nexport function generateLefthookBlock(): string {\n\treturn LEFTHOOK_BLOCK;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Scaffolds git hook integration for the project.\n *\n * Detects the hook manager (husky or lefthook), generates appropriate\n * hook files, and reports what was written.\n *\n * @param args - CLI arguments for the init hooks command.\n * @returns A typed `CommandOutput<InitHooksResult>`.\n * @example\n * ```typescript\n * import { runInitHooks } from \"@forge-ts/cli/commands/init-hooks\";\n * const output = await runInitHooks({ cwd: \"/my/project\" });\n * console.log(output.data.files); // [\".husky/pre-commit\"]\n * ```\n * @public\n */\nexport async function runInitHooks(args: InitHooksArgs): Promise<CommandOutput<InitHooksResult>> {\n\tconst start = Date.now();\n\tconst rootDir = args.cwd ?? process.cwd();\n\n\tconst hookManager = detectHookManager(rootDir);\n\tconst writtenFiles: string[] = [];\n\tconst skippedFiles: string[] = [];\n\tconst warnings: ForgeCliWarning[] = [];\n\tconst instructions: string[] = [];\n\n\tif (hookManager === \"husky\" || hookManager === \"none\") {\n\t\t// Write husky pre-commit hook\n\t\tconst huskyDir = join(rootDir, \".husky\");\n\t\tconst hookPath = join(huskyDir, \"pre-commit\");\n\t\tconst relativePath = \".husky/pre-commit\";\n\n\t\tif (existsSync(hookPath) && !args.force) {\n\t\t\t// Check if our command is already in the file\n\t\t\tconst existing = await readFile(hookPath, \"utf8\");\n\t\t\tif (existing.includes(\"forge-ts check\")) {\n\t\t\t\tskippedFiles.push(relativePath);\n\t\t\t\twarnings.push({\n\t\t\t\t\tcode: \"HOOKS_ALREADY_EXISTS\",\n\t\t\t\t\tmessage: `${relativePath} already contains forge-ts check — skipping. Use --force to overwrite.`,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Append to existing hook\n\t\t\t\tconst appended = `${existing.trimEnd()}\\n\\nnpx forge-ts check\\n`;\n\t\t\t\tawait writeFile(hookPath, appended, { mode: 0o755 });\n\t\t\t\twrittenFiles.push(relativePath);\n\t\t\t}\n\t\t} else {\n\t\t\tawait mkdir(huskyDir, { recursive: true });\n\t\t\tawait writeFile(hookPath, HUSKY_PRE_COMMIT, { mode: 0o755 });\n\t\t\twrittenFiles.push(relativePath);\n\t\t}\n\n\t\tif (hookManager === \"none\") {\n\t\t\tinstructions.push(\n\t\t\t\t\"No hook manager detected. Wrote .husky/pre-commit as a starting point.\",\n\t\t\t\t\"Install husky to activate: npx husky-init && npm install (or pnpm dlx husky-init && pnpm install)\",\n\t\t\t);\n\t\t} else {\n\t\t\tinstructions.push(\"Husky pre-commit hook configured to run forge-ts check.\");\n\t\t}\n\t} else if (hookManager === \"lefthook\") {\n\t\tconst lefthookPath = join(rootDir, \"lefthook.yml\");\n\t\tconst relativePath = \"lefthook.yml\";\n\n\t\tif (existsSync(lefthookPath)) {\n\t\t\tconst existing = await readFile(lefthookPath, \"utf8\");\n\t\t\tif (existing.includes(\"forge-ts check\") && !args.force) {\n\t\t\t\tskippedFiles.push(relativePath);\n\t\t\t\twarnings.push({\n\t\t\t\t\tcode: \"HOOKS_ALREADY_EXISTS\",\n\t\t\t\t\tmessage: `${relativePath} already contains forge-ts check — skipping. Use --force to overwrite.`,\n\t\t\t\t});\n\t\t\t} else if (existing.includes(\"pre-commit:\") && !args.force) {\n\t\t\t\t// Append our command under the existing pre-commit section\n\t\t\t\tconst appended = `${existing.trimEnd()}\\n forge-ts-check:\\n run: npx forge-ts check\\n`;\n\t\t\t\tawait writeFile(lefthookPath, appended, \"utf8\");\n\t\t\t\twrittenFiles.push(relativePath);\n\t\t\t} else {\n\t\t\t\t// Append the full block\n\t\t\t\tconst appended = `${existing.trimEnd()}\\n\\n${LEFTHOOK_BLOCK}`;\n\t\t\t\tawait writeFile(lefthookPath, appended, \"utf8\");\n\t\t\t\twrittenFiles.push(relativePath);\n\t\t\t}\n\t\t} else {\n\t\t\tawait writeFile(lefthookPath, LEFTHOOK_BLOCK, \"utf8\");\n\t\t\twrittenFiles.push(relativePath);\n\t\t}\n\n\t\tinstructions.push(\"Lefthook pre-commit hook configured to run forge-ts check.\");\n\t}\n\n\tconst data: InitHooksResult = {\n\t\tsuccess: true,\n\t\thookManager,\n\t\tsummary: {\n\t\t\tfilesWritten: writtenFiles.length,\n\t\t\tfilesSkipped: skippedFiles.length,\n\t\t},\n\t\tfiles: writtenFiles,\n\t\tinstructions,\n\t};\n\n\treturn {\n\t\toperation: \"init.hooks\",\n\t\tsuccess: true,\n\t\tdata,\n\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\tduration: Date.now() - start,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an InitHooksResult as human-readable text.\n * @internal\n */\nfunction formatInitHooksHuman(result: InitHooksResult): string {\n\tconst lines: string[] = [];\n\n\tconst managerName = result.hookManager === \"none\" ? \"husky (default)\" : result.hookManager;\n\tlines.push(`\\n Configuring git hooks (${managerName})...\\n`);\n\n\tfor (const file of result.files) {\n\t\tlines.push(` \\u2713 ${file}`);\n\t}\n\n\tif (result.summary.filesSkipped > 0) {\n\t\tlines.push(` (${result.summary.filesSkipped} file(s) skipped — already configured)`);\n\t}\n\n\tif (result.instructions.length > 0) {\n\t\tlines.push(\"\\n Next steps:\");\n\t\tfor (const [idx, inst] of result.instructions.entries()) {\n\t\t\tlines.push(` ${idx + 1}. ${inst}`);\n\t\t}\n\t}\n\n\tlines.push(`\\n ${result.summary.filesWritten} file(s) written.`);\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command definition\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts init hooks`.\n *\n * Scaffolds git hook integration for the project by detecting the\n * hook manager (husky or lefthook) and generating pre-commit hooks.\n *\n * @example\n * ```typescript\n * import { initHooksCommand } from \"@forge-ts/cli/commands/init-hooks\";\n * // Registered as a subcommand of `forge-ts init`\n * ```\n * @public\n */\nexport const initHooksCommand = defineCommand({\n\tmeta: {\n\t\tname: \"hooks\",\n\t\tdescription: \"Scaffold git hook integration (husky/lefthook)\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tforce: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Overwrite existing hook files\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runInitHooks({\n\t\t\tcwd: args.cwd,\n\t\t\tforce: args.force,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\tconst logger = createLogger();\n\t\t\t\tconst msg = cmd.errors?.[0]?.message ?? \"Hook scaffolding failed\";\n\t\t\t\tlogger.error(msg);\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t\treturn formatInitHooksHuman(data);\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts lock` command — snapshots the current config and creates `.forge-lock.json`.\n *\n * This prevents LLM agents from silently weakening project settings.\n * Once locked, any attempt to weaken rule severities or disable guards\n * will cause `forge-ts check` to fail until `forge-ts unlock --reason=...`\n * is run.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\tappendAuditEvent,\n\tcreateLockManifest,\n\tloadConfig,\n\treadLockFile,\n\twriteLockFile,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `lock` command.\n * @public\n */\nexport interface LockResult {\n\t/** Whether the lock was successfully created. */\n\tsuccess: boolean;\n\t/** Path to the lock file that was written. */\n\tlockFile: string;\n\t/** ISO-8601 timestamp when the lock was created. */\n\tlockedAt: string;\n\t/** Identifier of who created the lock. */\n\tlockedBy: string;\n\t/** Summary of what was locked. */\n\tlocked: {\n\t\t/** Number of enforce rules captured. */\n\t\trules: number;\n\t\t/** Whether tsconfig guard settings were captured. */\n\t\ttsconfig: boolean;\n\t\t/** Whether biome guard settings were captured. */\n\t\tbiome: boolean;\n\t};\n\t/** Whether a previous lock file was overwritten. */\n\toverwrote: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the lock command: reads current config and creates `.forge-lock.json`.\n *\n * @param args - CLI arguments for the lock command.\n * @returns A typed `CommandOutput<LockResult>`.\n * @example\n * ```typescript\n * import { runLock } from \"@forge-ts/cli/commands/lock\";\n * const output = await runLock({ cwd: process.cwd() });\n * console.log(output.data.locked.rules); // number of rules locked\n * ```\n * @public\n */\nexport async function runLock(args: { cwd?: string }): Promise<CommandOutput<LockResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\tconst existingLock = readLockFile(rootDir);\n\tconst manifest = createLockManifest(config);\n\twriteLockFile(rootDir, manifest);\n\n\tappendAuditEvent(rootDir, {\n\t\ttimestamp: manifest.lockedAt,\n\t\tevent: \"config.lock\",\n\t\tuser: manifest.lockedBy,\n\t\tdetails: {\n\t\t\trules: Object.keys(manifest.config.rules).length,\n\t\t\ttsconfig: manifest.config.tsconfig !== undefined,\n\t\t\tbiome: manifest.config.biome !== undefined,\n\t\t\toverwrote: existingLock !== null,\n\t\t},\n\t});\n\n\tconst lockFile = `${rootDir}/.forge-lock.json`;\n\tconst data: LockResult = {\n\t\tsuccess: true,\n\t\tlockFile,\n\t\tlockedAt: manifest.lockedAt,\n\t\tlockedBy: manifest.lockedBy,\n\t\tlocked: {\n\t\t\trules: Object.keys(manifest.config.rules).length,\n\t\t\ttsconfig: manifest.config.tsconfig !== undefined,\n\t\t\tbiome: manifest.config.biome !== undefined,\n\t\t},\n\t\toverwrote: existingLock !== null,\n\t};\n\n\treturn {\n\t\toperation: \"lock\",\n\t\tsuccess: true,\n\t\tdata,\n\t\tduration: 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a LockResult as human-readable text.\n * @internal\n */\nfunction formatLockHuman(result: LockResult): string {\n\tconst lines: string[] = [];\n\n\tif (result.overwrote) {\n\t\tlines.push(\"forge-ts lock: updated existing lock\\n\");\n\t} else {\n\t\tlines.push(\"forge-ts lock: created .forge-lock.json\\n\");\n\t}\n\n\tlines.push(` Locked ${result.locked.rules} enforce rule(s)`);\n\tif (result.locked.tsconfig) {\n\t\tlines.push(\" Locked tsconfig guard settings\");\n\t}\n\tif (result.locked.biome) {\n\t\tlines.push(\" Locked biome guard settings\");\n\t}\n\tlines.push(`\\n Locked by: ${result.lockedBy}`);\n\tlines.push(` Locked at: ${result.lockedAt}`);\n\tlines.push(`\\n To modify locked settings, run: forge-ts unlock --reason=\"...\"`);\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts lock`.\n * @public\n */\nexport const lockCommand = defineCommand({\n\tmeta: {\n\t\tname: \"lock\",\n\t\tdescription: \"Lock current config to prevent silent weakening\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runLock({ cwd: args.cwd });\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatLockHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts prepublish` command — safety gate for npm publish.\n *\n * Runs `forge-ts check` then `forge-ts build` in sequence. If check fails,\n * the build step is skipped and the command exits non-zero. This is designed\n * to be wired into package.json as `\"prepublishOnly\": \"forge-ts prepublish\"`.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { defineCommand } from \"citty\";\nimport { createLogger } from \"../logger.js\";\nimport {\n\ttype CommandOutput,\n\temitResult,\n\ttype ForgeCliError,\n\ttype OutputFlags,\n\tresolveExitCode,\n} from \"../output.js\";\nimport { runBuild } from \"./build.js\";\nimport { runCheck } from \"./check.js\";\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `prepublish` command.\n *\n * @example\n * ```typescript\n * import { runPrepublish } from \"@forge-ts/cli/commands/prepublish\";\n * const output = await runPrepublish({ cwd: process.cwd() });\n * console.log(output.data.check.success); // true if check passed\n * console.log(output.data.build?.success); // true if build passed\n * ```\n * @public\n */\nexport interface PrepublishResult {\n\t/** Whether both check and build passed. */\n\tsuccess: boolean;\n\t/** Summary of the prepublish pipeline. */\n\tsummary: {\n\t\t/** Number of pipeline steps run. */\n\t\tsteps: number;\n\t\t/** Number of steps that passed. */\n\t\tpassed: number;\n\t\t/** Number of steps that failed. */\n\t\tfailed: number;\n\t\t/** Wall-clock duration of the entire pipeline in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Result of the check step. */\n\tcheck: {\n\t\t/** Whether the check passed. */\n\t\tsuccess: boolean;\n\t\t/** Error count from the check. */\n\t\terrors: number;\n\t\t/** Warning count from the check. */\n\t\twarnings: number;\n\t\t/** Duration of the check step in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Result of the build step (absent if check failed and build was skipped). */\n\tbuild?: {\n\t\t/** Whether the build passed. */\n\t\tsuccess: boolean;\n\t\t/** Number of build pipeline steps. */\n\t\tsteps: number;\n\t\t/** Number of build steps that succeeded. */\n\t\tsucceeded: number;\n\t\t/** Number of build steps that failed. */\n\t\tfailed: number;\n\t\t/** Duration of the build step in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** If check failed, the reason build was skipped. */\n\tskippedReason?: string;\n}\n\n/**\n * Arguments for the `prepublish` command.\n * @internal\n */\nexport interface PrepublishArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** Treat warnings as errors during the check step. */\n\tstrict?: boolean;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the prepublish safety gate: check then build.\n *\n * If the check step fails, the build step is skipped entirely.\n * Both steps use the same project root (cwd).\n *\n * @param args - CLI arguments for the prepublish command.\n * @returns A typed `CommandOutput<PrepublishResult>`.\n * @example\n * ```typescript\n * import { runPrepublish } from \"@forge-ts/cli/commands/prepublish\";\n * const output = await runPrepublish({ cwd: process.cwd() });\n * if (!output.success) process.exit(1);\n * ```\n * @public\n */\nexport async function runPrepublish(\n\targs: PrepublishArgs,\n): Promise<CommandOutput<PrepublishResult>> {\n\tconst start = Date.now();\n\tconst allErrors: ForgeCliError[] = [];\n\n\t// Step 1: Run check\n\tconst checkOutput = await runCheck({\n\t\tcwd: args.cwd,\n\t\tstrict: args.strict,\n\t\tmvi: args.mvi,\n\t});\n\tconst checkDuration = checkOutput.duration ?? 0;\n\n\tif (!checkOutput.success) {\n\t\t// Check failed — skip build\n\t\tconst data: PrepublishResult = {\n\t\t\tsuccess: false,\n\t\t\tsummary: {\n\t\t\t\tsteps: 1,\n\t\t\t\tpassed: 0,\n\t\t\t\tfailed: 1,\n\t\t\t\tduration: Date.now() - start,\n\t\t\t},\n\t\t\tcheck: {\n\t\t\t\tsuccess: false,\n\t\t\t\terrors: checkOutput.data.summary.errors,\n\t\t\t\twarnings: checkOutput.data.summary.warnings,\n\t\t\t\tduration: checkDuration,\n\t\t\t},\n\t\t\tskippedReason: \"Check failed — build step skipped.\",\n\t\t};\n\n\t\tif (checkOutput.errors) {\n\t\t\tallErrors.push(...checkOutput.errors);\n\t\t}\n\n\t\treturn {\n\t\t\toperation: \"prepublish\",\n\t\t\tsuccess: false,\n\t\t\tdata,\n\t\t\terrors: allErrors.length > 0 ? allErrors : undefined,\n\t\t\tduration: Date.now() - start,\n\t\t};\n\t}\n\n\t// Step 2: Run build\n\tconst buildOutput = await runBuild({\n\t\tcwd: args.cwd,\n\t\tmvi: args.mvi,\n\t});\n\tconst buildDuration = buildOutput.duration ?? 0;\n\n\tconst buildSuccess = buildOutput.success;\n\tconst overallSuccess = buildSuccess;\n\n\tif (buildOutput.errors) {\n\t\tallErrors.push(...buildOutput.errors);\n\t}\n\n\tconst data: PrepublishResult = {\n\t\tsuccess: overallSuccess,\n\t\tsummary: {\n\t\t\tsteps: 2,\n\t\t\tpassed: (checkOutput.success ? 1 : 0) + (buildSuccess ? 1 : 0),\n\t\t\tfailed: (checkOutput.success ? 0 : 1) + (buildSuccess ? 0 : 1),\n\t\t\tduration: Date.now() - start,\n\t\t},\n\t\tcheck: {\n\t\t\tsuccess: checkOutput.success,\n\t\t\terrors: checkOutput.data.summary.errors,\n\t\t\twarnings: checkOutput.data.summary.warnings,\n\t\t\tduration: checkDuration,\n\t\t},\n\t\tbuild: {\n\t\t\tsuccess: buildSuccess,\n\t\t\tsteps: buildOutput.data.summary.steps,\n\t\t\tsucceeded: buildOutput.data.summary.succeeded,\n\t\t\tfailed: buildOutput.data.summary.failed,\n\t\t\tduration: buildDuration,\n\t\t},\n\t};\n\n\treturn {\n\t\toperation: \"prepublish\",\n\t\tsuccess: overallSuccess,\n\t\tdata,\n\t\terrors: allErrors.length > 0 ? allErrors : undefined,\n\t\tduration: Date.now() - start,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats a PrepublishResult as human-readable text.\n * @internal\n */\nfunction formatPrepublishHuman(result: PrepublishResult): string {\n\tconst lines: string[] = [];\n\n\tlines.push(`\\n forge-ts prepublish: ${result.success ? \"PASSED\" : \"FAILED\"}\\n`);\n\n\t// Check step\n\tconst checkIcon = result.check.success ? \"\\u2713\" : \"\\u2717\";\n\tlines.push(\n\t\t` ${checkIcon} check: ${result.check.errors} error(s), ${result.check.warnings} warning(s) (${result.check.duration}ms)`,\n\t);\n\n\t// Build step\n\tif (result.build) {\n\t\tconst buildIcon = result.build.success ? \"\\u2713\" : \"\\u2717\";\n\t\tlines.push(\n\t\t\t` ${buildIcon} build: ${result.build.succeeded}/${result.build.steps} steps succeeded (${result.build.duration}ms)`,\n\t\t);\n\t} else if (result.skippedReason) {\n\t\tlines.push(` - build: skipped (${result.skippedReason})`);\n\t}\n\n\tlines.push(\n\t\t`\\n ${result.summary.passed}/${result.summary.steps} steps passed in ${result.summary.duration}ms`,\n\t);\n\n\tif (!result.success) {\n\t\tlines.push(\"\\n Publish blocked. Fix the above issues and re-run forge-ts prepublish.\");\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command definition\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts prepublish`.\n *\n * Runs check then build as a publish safety gate. Add to package.json as:\n * `\"prepublishOnly\": \"forge-ts prepublish\"`\n *\n * @example\n * ```typescript\n * import { prepublishCommand } from \"@forge-ts/cli/commands/prepublish\";\n * // Registered as `forge-ts prepublish`\n * ```\n * @public\n */\nexport const prepublishCommand = defineCommand({\n\tmeta: {\n\t\tname: \"prepublish\",\n\t\tdescription: \"Safety gate: check + build before npm publish\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tstrict: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Treat warnings as errors during check\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runPrepublish({\n\t\t\tcwd: args.cwd,\n\t\t\tstrict: args.strict,\n\t\t\tmvi: args.mvi,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data, cmd) => {\n\t\t\tif (!cmd.success) {\n\t\t\t\tconst logger = createLogger();\n\t\t\t\tlogger.error(\"Prepublish gate failed\");\n\t\t\t}\n\t\t\treturn formatPrepublishHuman(data);\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","import { loadConfig } from \"@forge-ts/core\";\nimport { doctest } from \"@forge-ts/doctest\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n/**\n * Arguments for the `test` command.\n * @internal\n */\nexport interface TestArgs {\n\t/** Project root directory (default: cwd). */\n\tcwd?: string;\n\t/** MVI verbosity level for structured output. */\n\tmvi?: string;\n}\n\n/**\n * A single test failure entry, included at standard and full MVI levels.\n * @public\n */\nexport interface TestFailure {\n\t/** Symbol name where the doctest failed. */\n\tsymbol: string;\n\t/** Absolute path to the source file. */\n\tfile: string;\n\t/** 1-based line number of the failing example. */\n\tline: number;\n\t/** Human-readable failure message. */\n\tmessage: string;\n}\n\n/**\n * Typed result for the `test` command.\n * @public\n */\nexport interface TestResult {\n\t/** Whether all doctests passed. */\n\tsuccess: boolean;\n\t/** Aggregate counts — always present regardless of MVI level. */\n\tsummary: {\n\t\t/** Number of passing doctests. */\n\t\tpassed: number;\n\t\t/** Number of failing doctests. */\n\t\tfailed: number;\n\t\t/** Total doctests run. */\n\t\ttotal: number;\n\t\t/** Wall-clock duration in milliseconds. */\n\t\tduration: number;\n\t};\n\t/** Per-failure details — present at standard and full MVI levels. */\n\tfailures?: TestFailure[];\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the doctest pipeline and returns a typed command output.\n *\n * @param args - CLI arguments for the test command.\n * @returns A typed `CommandOutput<TestResult>`.\n * @example\n * ```typescript\n * import { runTest } from \"@forge-ts/cli/commands/test\";\n * const output = await runTest({ cwd: process.cwd() });\n * console.log(output.data.summary.passed); // number of passing doctests\n * ```\n * @public\n */\nexport async function runTest(args: TestArgs): Promise<CommandOutput<TestResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst result = await doctest(config);\n\tconst mviLevel = args.mvi ?? \"standard\";\n\n\tconst failCount = result.errors.length;\n\tconst totalSymbols = result.symbols.length;\n\tconst passCount = totalSymbols - failCount > 0 ? totalSymbols - failCount : 0;\n\n\tconst summary = {\n\t\tpassed: passCount,\n\t\tfailed: failCount,\n\t\ttotal: totalSymbols,\n\t\tduration: result.duration,\n\t};\n\n\tconst data: TestResult = { success: result.success, summary };\n\n\tif (mviLevel !== \"minimal\") {\n\t\tdata.failures = result.errors.map((e) => ({\n\t\t\tsymbol: e.symbolName ?? \"\",\n\t\t\tfile: e.filePath ?? \"\",\n\t\t\tline: e.line,\n\t\t\tmessage: e.message,\n\t\t}));\n\t}\n\n\t// Populate top-level errors so the LAFS envelope error code is actionable.\n\tconst cliErrors = result.success\n\t\t? undefined\n\t\t: result.errors.map((e) => ({\n\t\t\t\tcode: e.code,\n\t\t\t\tmessage: e.message,\n\t\t\t}));\n\n\tconst cliWarnings = config._configWarnings?.map((msg) => ({\n\t\tcode: \"CONFIG_WARNING\",\n\t\tmessage: msg,\n\t\tfilePath: \"\",\n\t\tline: 0,\n\t\tcolumn: 0,\n\t}));\n\n\treturn {\n\t\toperation: \"test\",\n\t\tsuccess: result.success,\n\t\tdata,\n\t\terrors: cliErrors,\n\t\twarnings: cliWarnings,\n\t\tduration: result.duration,\n\t};\n}\n\n/**\n * Citty command definition for `forge-ts test`.\n * @public\n */\nexport const testCommand = defineCommand({\n\tmeta: {\n\t\tname: \"test\",\n\t\tdescription: \"Run @example blocks as doctests\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmvi: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"MVI verbosity level: minimal, standard, full\",\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst output = await runTest({ cwd: args.cwd, mvi: args.mvi });\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t\tmvi: args.mvi,\n\t\t};\n\n\t\temitResult(output, flags, (data) => {\n\t\t\tif (output.success) {\n\t\t\t\treturn `forge-ts test: all doctests passed. (${data.summary.duration}ms)`;\n\t\t\t}\n\t\t\tconst lines: string[] = [];\n\t\t\tfor (const f of data.failures ?? []) {\n\t\t\t\tlines.push(f.message);\n\t\t\t}\n\t\t\tlines.push(`forge-ts test: ${data.summary.failed} failure(s). (${data.summary.duration}ms)`);\n\t\t\treturn lines.join(\"\\n\");\n\t\t});\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n","/**\n * `forge-ts unlock` command — removes `.forge-lock.json` with a mandatory reason.\n *\n * The `--reason` flag is required to provide an audit trail explaining why\n * the config lock is being removed. This discourages silent weakening\n * of project settings by LLM agents.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n\tappendAuditEvent,\n\tgetCurrentUser,\n\tloadConfig,\n\treadLockFile,\n\tremoveLockFile,\n} from \"@forge-ts/core\";\nimport { defineCommand } from \"citty\";\nimport { type CommandOutput, emitResult, type OutputFlags, resolveExitCode } from \"../output.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Typed result for the `unlock` command.\n * @public\n */\nexport interface UnlockResult {\n\t/** Whether the unlock was successful. */\n\tsuccess: boolean;\n\t/** The reason provided for unlocking. */\n\treason: string;\n\t/** Who originally locked the config, if known. */\n\tpreviousLockedBy: string | null;\n\t/** When the config was originally locked, if known. */\n\tpreviousLockedAt: string | null;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Runs the unlock command: removes `.forge-lock.json` with a mandatory reason.\n *\n * @param args - CLI arguments for the unlock command.\n * @returns A typed `CommandOutput<UnlockResult>`.\n * @example\n * ```typescript\n * import { runUnlock } from \"@forge-ts/cli/commands/unlock\";\n * const output = await runUnlock({ cwd: process.cwd(), reason: \"Relaxing rules for migration\" });\n * console.log(output.data.success); // true\n * ```\n * @public\n */\nexport async function runUnlock(args: {\n\tcwd?: string;\n\treason: string;\n}): Promise<CommandOutput<UnlockResult>> {\n\tconst config = await loadConfig(args.cwd);\n\tconst rootDir = config.rootDir;\n\n\tconst existingLock = readLockFile(rootDir);\n\n\tif (!existingLock) {\n\t\treturn {\n\t\t\toperation: \"unlock\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\treason: args.reason,\n\t\t\t\tpreviousLockedBy: null,\n\t\t\t\tpreviousLockedAt: null,\n\t\t\t},\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_NO_LOCK\",\n\t\t\t\t\tmessage: \"No .forge-lock.json found. Nothing to unlock.\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tduration: 0,\n\t\t};\n\t}\n\n\tconst removed = removeLockFile(rootDir);\n\n\tif (!removed) {\n\t\treturn {\n\t\t\toperation: \"unlock\",\n\t\t\tsuccess: false,\n\t\t\tdata: {\n\t\t\t\tsuccess: false,\n\t\t\t\treason: args.reason,\n\t\t\t\tpreviousLockedBy: existingLock.lockedBy,\n\t\t\t\tpreviousLockedAt: existingLock.lockedAt,\n\t\t\t},\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tcode: \"FORGE_UNLOCK_FAILED\",\n\t\t\t\t\tmessage: \"Failed to remove .forge-lock.json. Check file permissions.\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tduration: 0,\n\t\t};\n\t}\n\n\tappendAuditEvent(rootDir, {\n\t\ttimestamp: new Date().toISOString(),\n\t\tevent: \"config.unlock\",\n\t\tuser: getCurrentUser(),\n\t\treason: args.reason,\n\t\tdetails: {\n\t\t\tpreviousLockedBy: existingLock.lockedBy,\n\t\t\tpreviousLockedAt: existingLock.lockedAt,\n\t\t},\n\t});\n\n\treturn {\n\t\toperation: \"unlock\",\n\t\tsuccess: true,\n\t\tdata: {\n\t\t\tsuccess: true,\n\t\t\treason: args.reason,\n\t\t\tpreviousLockedBy: existingLock.lockedBy,\n\t\t\tpreviousLockedAt: existingLock.lockedAt,\n\t\t},\n\t\tduration: 0,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Human formatter\n// ---------------------------------------------------------------------------\n\n/**\n * Formats an UnlockResult as human-readable text.\n * @internal\n */\nfunction formatUnlockHuman(result: UnlockResult): string {\n\tconst lines: string[] = [];\n\n\tif (!result.success) {\n\t\tlines.push(\"forge-ts unlock: FAILED\\n\");\n\t\tlines.push(\" No .forge-lock.json found. Nothing to unlock.\");\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tlines.push(\"forge-ts unlock: removed .forge-lock.json\\n\");\n\tlines.push(` Reason: ${result.reason}`);\n\tif (result.previousLockedBy) {\n\t\tlines.push(` Previously locked by: ${result.previousLockedBy}`);\n\t}\n\tif (result.previousLockedAt) {\n\t\tlines.push(` Previously locked at: ${result.previousLockedAt}`);\n\t}\n\tlines.push(\"\\n Config settings can now be modified freely.\");\n\tlines.push(\" Run `forge-ts lock` to re-lock after changes.\");\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Citty command\n// ---------------------------------------------------------------------------\n\n/**\n * Citty command definition for `forge-ts unlock`.\n * @public\n */\nexport const unlockCommand = defineCommand({\n\tmeta: {\n\t\tname: \"unlock\",\n\t\tdescription: \"Remove config lock (requires --reason)\",\n\t},\n\targs: {\n\t\tcwd: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Project root directory\",\n\t\t},\n\t\treason: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Mandatory reason for unlocking (audit trail)\",\n\t\t\trequired: true,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as LAFS JSON envelope (agent-friendly)\",\n\t\t\tdefault: false,\n\t\t},\n\t\thuman: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output as formatted text (default for TTY)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tquiet: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Suppress non-essential output\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (!args.reason) {\n\t\t\tconsole.error(\n\t\t\t\t\"[forge-ts] error: --reason is required. Provide a reason for unlocking the config.\",\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst output = await runUnlock({\n\t\t\tcwd: args.cwd,\n\t\t\treason: args.reason,\n\t\t});\n\n\t\tconst flags: OutputFlags = {\n\t\t\tjson: args.json,\n\t\t\thuman: args.human,\n\t\t\tquiet: args.quiet,\n\t\t};\n\n\t\temitResult(output, flags, (data) => formatUnlockHuman(data));\n\n\t\tprocess.exit(resolveExitCode(output));\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAS,qBAAqB;AAC9B,SAAS,iBAAAA,iBAAe,eAAe;;;ACfvC;AAAA,EAGC;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAoDvB,SAAS,SAAS,MAA6C;AACrE,QAAM,UAAU,KAAK,OAAO,QAAQ,IAAI;AACxC,QAAM,QAAQ,KAAK,SAAS;AAE5B,QAAM,SAAS,aAAa,SAAS;AAAA,IACpC;AAAA,IACA,WAAW,KAAK;AAAA,EACjB,CAAC;AAED,QAAM,OAAoB;AAAA,IACzB,SAAS;AAAA,IACT,OAAO,OAAO;AAAA,IACd;AAAA,EACD;AAEA,SAAO;AAAA,IACN,WAAW;AAAA,IACX,SAAS;AAAA,IACT;AAAA,EACD;AACD;AAaA,SAAS,iBAAiB,MAA2B;AACpD,MAAI,KAAK,UAAU,GAAG;AACrB,WAAO;AAAA,EACR;AAEA,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,mBAAmB,KAAK,KAAK;AAAA,CAAa;AAErD,aAAW,SAAS,KAAK,QAAQ;AAChC,UAAM,KAAK,KAAK,iBAAiB,KAAK,CAAC,EAAE;AAAA,EAC1C;AAEA,SAAO,MAAM,KAAK,IAAI;AACvB;AAOA,IAAM,oBAA8B;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAOO,IAAM,eAAe,c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and","loadConfig","defineCommand","loadConfig","defineCommand","output","loadConfig","defineCommand","loadConfig","defineCommand","defineCommand","pkg","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","existsSync","mkdir","writeFile","join","resolve","loadConfig","DEFAULT_TARGET","getAdapter","defineCommand","DEFAULT_TARGET","getAdapter","loadConfig","resolve","join","mkdir","writeFile","existsSync","defineCommand","existsSync","readFileSync","mkdir","writeFile","join","defineCommand","join","existsSync","readFileSync","pkg","join","existsSync","writeFile","mkdir","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","defineCommand","data","defineCommand","loadConfig","defineCommand","loadConfig","defineCommand","appendAuditEvent","loadConfig","readLockFile","defineCommand","loadConfig","readLockFile","appendAuditEvent","defineCommand","require","defineCommand","initCommand","runInitProject","emitResult","resolveExitCode","createLogger"]}