@codluv/versionguard 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,743 +1,851 @@
1
1
  #!/usr/bin/env node
2
- import * as fs from "node:fs";
2
+ import { $ as generateDependabotConfig, A as createCkmEngine, B as detectManifests, C as suggestNextVersion, D as getVersionFeedback, J as areHooksInstalled, L as getPackageVersion, O as getConfig, S as fixSyncIssues, T as getSyncFeedback, X as uninstallHooks, Y as installHooks, at as isValidCalVerFormat, et as writeDependabotConfig, f as findProjectRoot, i as validate, l as handlePostTag, n as doctor, nt as isChangesetMangled, o as createTag, p as formatNotProjectError, tt as fixChangesetMangling, v as runGuardChecks, w as getChangelogFeedback, y as fixAll, z as setPackageVersion } from "./chunks/src-BPMDUQfR.js";
3
3
  import * as path from "node:path";
4
+ import * as fs from "node:fs";
5
+ import * as yaml from "js-yaml";
4
6
  import { fileURLToPath } from "node:url";
5
7
  import chalk from "chalk";
6
8
  import { Command } from "commander";
7
- import { i as isValidCalVerFormat, c as createCkmEngine, g as getConfig, a as installHooks, b as getPackageVersion, d as getVersionFeedback, v as validate, h as handlePostTag, r as runGuardChecks, e as getSyncFeedback, f as getChangelogFeedback, j as doctor, k as fixAll, l as isChangesetMangled, m as fixChangesetMangling, n as fixSyncIssues, s as suggestNextVersion, o as setPackageVersion, p as createTag, u as uninstallHooks, q as areHooksInstalled, t as findProjectRoot, w as formatNotProjectError } from "./chunks/index-Cipg9sxE.js";
8
9
  import * as p from "@clack/prompts";
9
- import * as yaml from "js-yaml";
10
- const ckmRaw = '{\n "$schema": "https://forge-ts.dev/schemas/ckm/v1.json",\n "version": "1.0.0",\n "project": "@codluv/versionguard",\n "generated": "2026-03-26T21:16:11.940Z",\n "concepts": [\n {\n "id": "concept-ManifestConfig",\n "name": "ManifestConfig",\n "what": "Configures the version source manifest.",\n "properties": [\n {\n "name": "source",\n "type": "ManifestSourceType",\n "description": "Manifest file to read the version from. Use `\'auto\'` for file-existence detection or a specific filename."\n },\n {\n "name": "path",\n "type": "string | undefined",\n "description": "Dotted key path to the version field within the manifest. For example `\'version\'` for package.json, `\'package.version\'` for Cargo.toml, or `\'project.version\'` for pyproject.toml."\n },\n {\n "name": "regex",\n "type": "string | undefined",\n "description": "Regex pattern to extract the version from source-code manifests. Capture group 1 must contain the version string."\n }\n ]\n },\n {\n "id": "concept-SemVerConfig",\n "name": "SemVerConfig",\n "what": "Configures SemVer validation rules.",\n "properties": [\n {\n "name": "allowVPrefix",\n "type": "boolean",\n "description": "Tolerates a leading `v` prefix (e.g. `v1.2.3`). When enabled the prefix is stripped before parsing."\n },\n {\n "name": "allowBuildMetadata",\n "type": "boolean",\n "description": "Permits `+build` metadata on version strings."\n },\n {\n "name": "requirePrerelease",\n "type": "boolean",\n "description": "Requires every version to carry a prerelease label."\n }\n ]\n },\n {\n "id": "concept-CalVerConfig",\n "name": "CalVerConfig",\n "what": "Configures CalVer validation rules.",\n "properties": [\n {\n "name": "format",\n "type": "CalVerFormat",\n "description": "Calendar format used when parsing and validating versions."\n },\n {\n "name": "preventFutureDates",\n "type": "boolean",\n "description": "Rejects versions that point to a future date."\n },\n {\n "name": "strictMutualExclusion",\n "type": "boolean | undefined",\n "description": "Enforces that week tokens (WW/0W) cannot be mixed with month/day tokens."\n }\n ]\n },\n {\n "id": "concept-SyncConfig",\n "name": "SyncConfig",\n "what": "Configures files and patterns that should stay in sync with the canonical version.",\n "properties": [\n {\n "name": "files",\n "type": "string[]",\n "description": "File globs or paths that should be scanned for version updates."\n },\n {\n "name": "patterns",\n "type": "SyncPattern[]",\n "description": "Replacement patterns applied to matching files."\n }\n ]\n },\n {\n "id": "concept-ChangelogConfig",\n "name": "ChangelogConfig",\n "what": "Controls changelog validation behavior.",\n "properties": [\n {\n "name": "enabled",\n "type": "boolean",\n "description": "Enables changelog validation."\n },\n {\n "name": "file",\n "type": "string",\n "description": "Path to the changelog file to inspect."\n },\n {\n "name": "strict",\n "type": "boolean",\n "description": "Treats changelog problems as hard failures."\n },\n {\n "name": "requireEntry",\n "type": "boolean",\n "description": "Requires an entry for the current version."\n },\n {\n "name": "enforceStructure",\n "type": "boolean | undefined",\n "description": "Validates that changelog section headers use only allowed names. When enabled, any `### SectionName` header not present in `sections` is reported as an error."\n },\n {\n "name": "sections",\n "type": "string[] | undefined",\n "description": "Allowed Keep a Changelog section names. Only applied when `enforceStructure` is `true`."\n }\n ]\n },\n {\n "id": "concept-GitHooksConfig",\n "name": "GitHooksConfig",\n "what": "Toggles each supported git hook integration.",\n "properties": [\n {\n "name": "\'pre-commit\'",\n "type": "boolean",\n "description": "Enables validation during the `pre-commit` hook."\n },\n {\n "name": "\'pre-push\'",\n "type": "boolean",\n "description": "Enables validation during the `pre-push` hook."\n },\n {\n "name": "\'post-tag\'",\n "type": "boolean",\n "description": "Enables follow-up tasks after a tag is created."\n }\n ]\n },\n {\n "id": "concept-GitConfig",\n "name": "GitConfig",\n "what": "Configures git-related enforcement.",\n "properties": [\n {\n "name": "hooks",\n "type": "GitHooksConfig",\n "description": "Hook toggles used by the CLI and validation workflow."\n },\n {\n "name": "enforceHooks",\n "type": "boolean",\n "description": "Fails validation when required hooks are missing."\n }\n ]\n },\n {\n "id": "concept-VersioningConfig",\n "name": "VersioningConfig",\n "what": "Configures the active versioning mode.",\n "properties": [\n {\n "name": "type",\n "type": "VersioningType",\n "description": "Versioning strategy used for the project."\n },\n {\n "name": "schemeRules",\n "type": "SchemeRules | undefined",\n "description": "Scheme-level validation rules applied regardless of versioning type."\n },\n {\n "name": "semver",\n "type": "SemVerConfig | undefined",\n "description": "SemVer-specific settings when `type` is `\'semver\'`."\n },\n {\n "name": "calver",\n "type": "CalVerConfig | undefined",\n "description": "CalVer-specific settings when `type` is `\'calver\'`."\n }\n ]\n },\n {\n "id": "concept-ScanAllowlistEntry",\n "name": "ScanAllowlistEntry",\n "what": "An intentional version reference that should be excluded from scan results.",\n "properties": [\n {\n "name": "file",\n "type": "string",\n "description": "Glob pattern matching the file(s) where this reference is intentional."\n },\n {\n "name": "reason",\n "type": "string | undefined",\n "description": "Reason this reference is allowed (for documentation / review)."\n }\n ]\n },\n {\n "id": "concept-ScanConfig",\n "name": "ScanConfig",\n "what": "Configures repo-wide scanning for hardcoded version literals.",\n "properties": [\n {\n "name": "enabled",\n "type": "boolean",\n "description": "Enables repo-wide scanning for stale version literals."\n },\n {\n "name": "patterns",\n "type": "string[]",\n "description": "Regex patterns that match version-like strings in source files. Capture group 1 must contain the version string."\n },\n {\n "name": "allowlist",\n "type": "ScanAllowlistEntry[]",\n "description": "Files containing intentional version references that should not be flagged."\n }\n ]\n },\n {\n "id": "concept-VersionGuardConfig",\n "name": "VersionGuardConfig",\n "what": "Top-level configuration consumed by versionguard.",\n "properties": [\n {\n "name": "versioning",\n "type": "VersioningConfig",\n "description": "Active versioning settings."\n },\n {\n "name": "manifest",\n "type": "ManifestConfig",\n "description": "Version source manifest settings."\n },\n {\n "name": "sync",\n "type": "SyncConfig",\n "description": "Synchronization settings for mirrored version strings."\n },\n {\n "name": "changelog",\n "type": "ChangelogConfig",\n "description": "Changelog validation settings."\n },\n {\n "name": "git",\n "type": "GitConfig",\n "description": "Git enforcement settings."\n },\n {\n "name": "scan",\n "type": "ScanConfig",\n "description": "Repo-wide version literal scanning."\n },\n {\n "name": "ignore",\n "type": "string[]",\n "description": "Files or patterns excluded from validation."\n }\n ]\n },\n {\n "id": "concept-ValidationResult",\n "name": "ValidationResult",\n "what": "Result returned by version parsing and validation helpers.",\n "properties": [\n {\n "name": "valid",\n "type": "boolean",\n "description": "Indicates whether validation completed without errors."\n },\n {\n "name": "errors",\n "type": "ValidationError[]",\n "description": "Collected validation issues."\n },\n {\n "name": "version",\n "type": "ParsedVersion | undefined",\n "description": "Parsed version details when validation succeeds."\n }\n ]\n },\n {\n "id": "concept-SyncResult",\n "name": "SyncResult",\n "what": "Reports the result of synchronizing a single file.",\n "properties": [\n {\n "name": "file",\n "type": "string",\n "description": "File that was inspected or updated."\n },\n {\n "name": "updated",\n "type": "boolean",\n "description": "Indicates whether the file content changed."\n },\n {\n "name": "changes",\n "type": "SyncChange[]",\n "description": "Detailed replacements applied within the file."\n }\n ]\n },\n {\n "id": "concept-FullValidationResult",\n "name": "FullValidationResult",\n "what": "Combined result from a full project validation run.",\n "properties": [\n {\n "name": "valid",\n "type": "boolean",\n "description": "Indicates whether all checks passed."\n },\n {\n "name": "version",\n "type": "string",\n "description": "Canonical version string used for validation."\n },\n {\n "name": "versionValid",\n "type": "boolean",\n "description": "Indicates whether the root version string is valid."\n },\n {\n "name": "syncValid",\n "type": "boolean",\n "description": "Indicates whether synchronized files are in sync."\n },\n {\n "name": "changelogValid",\n "type": "boolean",\n "description": "Indicates whether changelog checks passed."\n },\n {\n "name": "errors",\n "type": "string[]",\n "description": "Human-readable validation failures collected during the run."\n }\n ]\n },\n {\n "id": "concept-ChangelogValidationResult",\n "name": "ChangelogValidationResult",\n "what": "Describes the outcome of validating a changelog file.",\n "properties": [\n {\n "name": "valid",\n "type": "boolean",\n "description": "Indicates whether the changelog satisfies all requested checks."\n },\n {\n "name": "errors",\n "type": "string[]",\n "description": "Human-readable validation errors."\n },\n {\n "name": "hasEntryForVersion",\n "type": "boolean",\n "description": "Indicates whether the changelog contains an entry for the requested version."\n }\n ]\n },\n {\n "id": "concept-ChangelogStructureOptions",\n "name": "ChangelogStructureOptions",\n "what": "Options for changelog structure enforcement.",\n "properties": [\n {\n "name": "enforceStructure",\n "type": "boolean | undefined",\n "description": "Validate section headers against an allowed list."\n },\n {\n "name": "sections",\n "type": "string[] | undefined",\n "description": "Allowed section names. Defaults to Keep a Changelog standard sections."\n }\n ]\n },\n {\n "id": "concept-CkmConfigEntry",\n "name": "CkmConfigEntry",\n "what": "A config schema entry with type, description, and default.",\n "properties": [\n {\n "name": "key",\n "type": "string",\n "description": "Dotted key path (e.g., `\'CalVerConfig.format\'`)."\n },\n {\n "name": "type",\n "type": "string",\n "description": "TypeScript type."\n },\n {\n "name": "description",\n "type": "string",\n "description": "Description from TSDoc."\n },\n {\n "name": "default",\n "type": "string | undefined",\n "description": "Default value if specified via `@defaultValue`."\n }\n ]\n },\n {\n "id": "concept-FeedbackResult",\n "name": "FeedbackResult",\n "what": "Aggregates validation errors with suggested next steps.",\n "properties": [\n {\n "name": "valid",\n "type": "boolean",\n "description": "Indicates whether the inspected version state is valid."\n },\n {\n "name": "errors",\n "type": "ValidationError[]",\n "description": "Validation errors collected during the check."\n },\n {\n "name": "suggestions",\n "type": "Suggestion[]",\n "description": "Suggested next steps for resolving the reported issues."\n },\n {\n "name": "canAutoFix",\n "type": "boolean",\n "description": "Indicates whether at least one suggestion can be auto-applied."\n }\n ]\n },\n {\n "id": "concept-FixResult",\n "name": "FixResult",\n "what": "Fix entry point exports for auto-remediation helpers.",\n "properties": [\n {\n "name": "fixed",\n "type": "boolean",\n "description": "Indicates whether the operation changed repository state."\n },\n {\n "name": "message",\n "type": "string",\n "description": "Human-readable description of the fix attempt."\n },\n {\n "name": "file",\n "type": "string | undefined",\n "description": "Absolute path to the file that was updated, when applicable."\n }\n ]\n },\n {\n "id": "concept-ProjectRootResult",\n "name": "ProjectRootResult",\n "what": "Result of project root detection.",\n "properties": [\n {\n "name": "found",\n "type": "boolean",\n "description": "Whether a project root was found."\n },\n {\n "name": "root",\n "type": "string",\n "description": "The resolved project root directory, or the original cwd if not found."\n },\n {\n "name": "marker",\n "type": "string | undefined",\n "description": "Which marker file was found."\n },\n {\n "name": "hasConfig",\n "type": "boolean",\n "description": "Whether the directory has a VersionGuard config."\n },\n {\n "name": "hasGit",\n "type": "boolean",\n "description": "Whether the directory is inside a git repository."\n },\n {\n "name": "hasManifest",\n "type": "boolean",\n "description": "Whether a version manifest file exists."\n }\n ]\n },\n {\n "id": "concept-InitOptions",\n "name": "InitOptions",\n "what": "Options for headless (non-interactive) initialization.",\n "properties": [\n {\n "name": "cwd",\n "type": "string",\n "description": "Working directory path."\n },\n {\n "name": "type",\n "type": "\\"semver\\" | \\"calver\\" | undefined",\n "description": "Versioning type (semver or calver)."\n },\n {\n "name": "format",\n "type": "string | undefined",\n "description": "CalVer format string."\n },\n {\n "name": "allowVPrefix",\n "type": "boolean | undefined",\n "description": "Allow v-prefix on SemVer versions."\n },\n {\n "name": "allowBuildMetadata",\n "type": "boolean | undefined",\n "description": "Allow build metadata on SemVer versions."\n },\n {\n "name": "requirePrerelease",\n "type": "boolean | undefined",\n "description": "Require prerelease labels on SemVer versions."\n },\n {\n "name": "manifest",\n "type": "string | undefined",\n "description": "Manifest source type."\n },\n {\n "name": "hooks",\n "type": "boolean | undefined",\n "description": "Whether to install git hooks."\n },\n {\n "name": "changelog",\n "type": "boolean | undefined",\n "description": "Whether to enable changelog validation."\n },\n {\n "name": "yes",\n "type": "boolean | undefined",\n "description": "Accept defaults without prompting."\n },\n {\n "name": "force",\n "type": "boolean | undefined",\n "description": "Overwrite existing config."\n }\n ]\n }\n ],\n "operations": [\n {\n "id": "op-validateModifier",\n "name": "validateModifier",\n "what": "Validates a pre-release / modifier tag against the allowed modifiers list.",\n "inputs": [\n {\n "name": "modifier",\n "type": "unknown",\n "required": true,\n "description": "Raw modifier string (e.g. `\\"alpha.1\\"`, `\\"rc2\\"`, `\\"dev\\"`)."\n },\n {\n "name": "schemeRules",\n "type": "unknown",\n "required": true,\n "description": "Scheme rules containing the allowed modifiers list."\n }\n ],\n "outputs": {\n "text": "A validation error when the modifier is disallowed, otherwise `null`."\n }\n },\n {\n "id": "op-validate",\n "name": "validate",\n "what": "Validates a CalVer string against formatting and date rules.",\n "inputs": [\n {\n "name": "version",\n "type": "unknown",\n "required": true,\n "description": "Version string to validate."\n },\n {\n "name": "calverFormat",\n "type": "unknown",\n "required": true,\n "description": "Format expected for the version string."\n },\n {\n "name": "preventFutureDates",\n "type": "unknown",\n "required": true,\n "description": "Whether future dates should be reported as errors."\n },\n {\n "name": "schemeRules",\n "type": "unknown",\n "required": true,\n "description": "Optional scheme rules for modifier validation and segment count warnings."\n }\n ],\n "outputs": {\n "text": "A validation result containing any discovered errors and the parsed version on success."\n }\n },\n {\n "id": "op-validateChangelog",\n "name": "validateChangelog",\n "what": "Validates a changelog file for release readiness.",\n "inputs": [\n {\n "name": "changelogPath",\n "type": "unknown",\n "required": true,\n "description": "Path to the changelog file."\n },\n {\n "name": "version",\n "type": "unknown",\n "required": true,\n "description": "Version that must be present in the changelog."\n },\n {\n "name": "strict",\n "type": "unknown",\n "required": true,\n "description": "Whether to require compare links and dated release headings."\n },\n {\n "name": "requireEntry",\n "type": "unknown",\n "required": true,\n "description": "Whether the requested version must already have an entry."\n },\n {\n "name": "structure",\n "type": "unknown",\n "required": true,\n "description": "Optional structure enforcement options."\n }\n ],\n "outputs": {\n "text": "The result of validating the changelog file."\n }\n },\n {\n "id": "op-createCkmEngine",\n "name": "createCkmEngine",\n "what": "Creates a CKM engine from a parsed manifest.",\n "inputs": [\n {\n "name": "manifest",\n "type": "unknown",\n "required": true,\n "description": "Parsed CKM manifest (from forge-ts `ckm.json`)."\n }\n ],\n "outputs": {\n "text": "A configured CKM engine."\n }\n },\n {\n "id": "op-checkHardcodedVersions",\n "name": "checkHardcodedVersions",\n "what": "Checks configured files for hardcoded version mismatches.",\n "inputs": [\n {\n "name": "expectedVersion",\n "type": "unknown",\n "required": true,\n "description": "Version all matching entries should use."\n },\n {\n "name": "config",\n "type": "unknown",\n "required": true,\n "description": "Sync configuration describing files and replacement patterns."\n },\n {\n "name": "ignorePatterns",\n "type": "unknown",\n "required": true,\n "description": "Glob patterns to exclude while scanning."\n },\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Project directory used to resolve file globs."\n }\n ],\n "outputs": {\n "text": "A list of detected version mismatches."\n }\n },\n {\n "id": "op-generateHookScript",\n "name": "generateHookScript",\n "what": "Generates the shell script content for a Git hook.",\n "inputs": [\n {\n "name": "hookName",\n "type": "unknown",\n "required": true,\n "description": "Name of the Git hook to generate."\n }\n ],\n "outputs": {\n "text": "Executable shell script contents for the hook."\n }\n },\n {\n "id": "op-checkHooksPathOverride",\n "name": "checkHooksPathOverride",\n "what": "Checks whether git hooks have been redirected away from the repository.",\n "inputs": [\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Repository directory to inspect."\n }\n ],\n "outputs": {\n "text": "A guard warning when a hooksPath override is detected."\n }\n },\n {\n "id": "op-checkHuskyBypass",\n "name": "checkHuskyBypass",\n "what": "Checks whether the HUSKY environment variable is disabling hooks.",\n "inputs": [],\n "outputs": {\n "text": "A guard warning when the HUSKY bypass is detected."\n }\n },\n {\n "id": "op-checkHookIntegrity",\n "name": "checkHookIntegrity",\n "what": "Verifies that installed hook scripts match the expected content.",\n "inputs": [\n {\n "name": "config",\n "type": "unknown",\n "required": true,\n "description": "VersionGuard configuration that defines which hooks should exist."\n },\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Repository directory to inspect."\n }\n ],\n "outputs": {\n "text": "Guard warnings for each hook that has been tampered with."\n }\n },\n {\n "id": "op-checkEnforceHooksPolicy",\n "name": "checkEnforceHooksPolicy",\n "what": "Checks whether hooks are configured as required but not enforced.",\n "inputs": [\n {\n "name": "config",\n "type": "unknown",\n "required": true,\n "description": "VersionGuard configuration to inspect."\n }\n ],\n "outputs": {\n "text": "A guard warning when hooks are enabled but not enforced."\n }\n },\n {\n "id": "op-runGuardChecks",\n "name": "runGuardChecks",\n "what": "Runs all guard checks and returns a consolidated report.",\n "inputs": [\n {\n "name": "config",\n "type": "unknown",\n "required": true,\n "description": "VersionGuard configuration."\n },\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Repository directory to inspect."\n }\n ],\n "outputs": {\n "text": "A guard report with all findings."\n }\n },\n {\n "id": "op-initConfig",\n "name": "initConfig",\n "what": "Initializes a new VersionGuard config file in a project.",\n "inputs": [\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Project directory where the config should be created."\n }\n ],\n "outputs": {\n "text": "The path to the created config file."\n }\n },\n {\n "id": "op-createTag",\n "name": "createTag",\n "what": "Creates a release tag and optionally fixes version state first.",\n "inputs": [\n {\n "name": "version",\n "type": "unknown",\n "required": true,\n "description": "Version to embed in the new tag name."\n },\n {\n "name": "message",\n "type": "unknown",\n "required": true,\n "description": "Custom annotated tag message."\n },\n {\n "name": "autoFix",\n "type": "unknown",\n "required": true,\n "description": "Whether to auto-fix version mismatches before tagging."\n },\n {\n "name": "config",\n "type": "unknown",\n "required": true,\n "description": "Loaded VersionGuard configuration used for validation and fixes."\n },\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Repository directory where git commands should run."\n }\n ],\n "outputs": {\n "text": "The tagging outcome and any actions performed along the way."\n }\n },\n {\n "id": "op-validateTagForPush",\n "name": "validateTagForPush",\n "what": "Validates that a local tag is safe to push to the default remote.",\n "inputs": [\n {\n "name": "tagName",\n "type": "unknown",\n "required": true,\n "description": "Name of the tag to validate."\n },\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Repository directory where git commands should run."\n }\n ],\n "outputs": {\n "text": "A validation result with an optional suggested fix command."\n }\n },\n {\n "id": "op-validateVersion",\n "name": "validateVersion",\n "what": "Validates a version string against the active versioning strategy.",\n "inputs": [\n {\n "name": "version",\n "type": "unknown",\n "required": true,\n "description": "Version string to validate."\n },\n {\n "name": "config",\n "type": "unknown",\n "required": true,\n "description": "VersionGuard configuration that selects the validation rules."\n }\n ],\n "outputs": {\n "text": "The validation result for the provided version."\n }\n },\n {\n "id": "op-runWizard",\n "name": "runWizard",\n "what": "Runs the interactive setup wizard.",\n "inputs": [\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Project directory to initialize."\n }\n ],\n "outputs": {\n "text": "The path to the created config file, or `null` if cancelled."\n }\n },\n {\n "id": "op-runHeadless",\n "name": "runHeadless",\n "what": "Initializes VersionGuard non-interactively using CLI flags.",\n "inputs": [\n {\n "name": "options",\n "type": "unknown",\n "required": true,\n "description": "Headless initialization options."\n }\n ],\n "outputs": {\n "text": "The path to the created config file."\n }\n },\n {\n "id": "op-createProgram",\n "name": "createProgram",\n "what": "Creates the VersionGuard CLI program definition.",\n "inputs": [],\n "outputs": {\n "text": "A configured Commander program for the VersionGuard CLI."\n }\n },\n {\n "id": "op-runCli",\n "name": "runCli",\n "what": "Parses CLI arguments and executes the matching command.",\n "inputs": [\n {\n "name": "argv",\n "type": "unknown",\n "required": true,\n "description": "Full argument vector to parse."\n }\n ]\n },\n {\n "id": "op-createTempProject",\n "name": "createTempProject",\n "what": "Creates a temporary project directory with a minimal `package.json` fixture.",\n "inputs": [],\n "outputs": {\n "text": "The absolute path to the temporary project directory."\n }\n },\n {\n "id": "op-initGitRepo",\n "name": "initGitRepo",\n "what": "Initializes a git repository in a fixture directory with a first commit.",\n "inputs": [\n {\n "name": "cwd",\n "type": "unknown",\n "required": true,\n "description": "Absolute path to the fixture repository."\n }\n ]\n },\n {\n "id": "op-createBareRemote",\n "name": "createBareRemote",\n "what": "Creates a bare git repository to use as a remote in integration tests.",\n "inputs": [],\n "outputs": {\n "text": "The absolute path to the new bare repository."\n }\n }\n ],\n "constraints": [],\n "workflows": [],\n "configSchema": [\n {\n "key": "ManifestConfig.source",\n "type": "ManifestSourceType",\n "description": "Manifest file to read the version from. Use `\'auto\'` for file-existence detection or a specific filename.",\n "default": "\'auto\'"\n },\n {\n "key": "ManifestConfig.path",\n "type": "string | undefined",\n "description": "Dotted key path to the version field within the manifest. For example `\'version\'` for package.json, `\'package.version\'` for Cargo.toml, or `\'project.version\'` for pyproject.toml.",\n "default": "undefined (uses the provider\'s built-in default)"\n },\n {\n "key": "ManifestConfig.regex",\n "type": "string | undefined",\n "description": "Regex pattern to extract the version from source-code manifests. Capture group 1 must contain the version string.",\n "default": "undefined"\n },\n {\n "key": "SemVerConfig.allowVPrefix",\n "type": "boolean",\n "description": "Tolerates a leading `v` prefix (e.g. `v1.2.3`). When enabled the prefix is stripped before parsing.",\n "default": "false"\n },\n {\n "key": "SemVerConfig.allowBuildMetadata",\n "type": "boolean",\n "description": "Permits `+build` metadata on version strings.",\n "default": "true"\n },\n {\n "key": "SemVerConfig.requirePrerelease",\n "type": "boolean",\n "description": "Requires every version to carry a prerelease label.",\n "default": "false"\n },\n {\n "key": "CalVerConfig.format",\n "type": "CalVerFormat",\n "description": "Calendar format used when parsing and validating versions."\n },\n {\n "key": "CalVerConfig.preventFutureDates",\n "type": "boolean",\n "description": "Rejects versions that point to a future date.",\n "default": "true"\n },\n {\n "key": "CalVerConfig.strictMutualExclusion",\n "type": "boolean | undefined",\n "description": "Enforces that week tokens (WW/0W) cannot be mixed with month/day tokens.",\n "default": "true"\n },\n {\n "key": "SyncConfig.files",\n "type": "string[]",\n "description": "File globs or paths that should be scanned for version updates."\n },\n {\n "key": "SyncConfig.patterns",\n "type": "SyncPattern[]",\n "description": "Replacement patterns applied to matching files."\n },\n {\n "key": "ChangelogConfig.enabled",\n "type": "boolean",\n "description": "Enables changelog validation.",\n "default": "false"\n },\n {\n "key": "ChangelogConfig.file",\n "type": "string",\n "description": "Path to the changelog file to inspect."\n },\n {\n "key": "ChangelogConfig.strict",\n "type": "boolean",\n "description": "Treats changelog problems as hard failures.",\n "default": "false"\n },\n {\n "key": "ChangelogConfig.requireEntry",\n "type": "boolean",\n "description": "Requires an entry for the current version.",\n "default": "false"\n },\n {\n "key": "ChangelogConfig.enforceStructure",\n "type": "boolean | undefined",\n "description": "Validates that changelog section headers use only allowed names. When enabled, any `### SectionName` header not present in `sections` is reported as an error.",\n "default": "false"\n },\n {\n "key": "ChangelogConfig.sections",\n "type": "string[] | undefined",\n "description": "Allowed Keep a Changelog section names. Only applied when `enforceStructure` is `true`.",\n "default": "[\'Added\', \'Changed\', \'Deprecated\', \'Removed\', \'Fixed\', \'Security\']"\n },\n {\n "key": "GitHooksConfig.\'pre-commit\'",\n "type": "boolean",\n "description": "Enables validation during the `pre-commit` hook.",\n "default": "false"\n },\n {\n "key": "GitHooksConfig.\'pre-push\'",\n "type": "boolean",\n "description": "Enables validation during the `pre-push` hook.",\n "default": "false"\n },\n {\n "key": "GitHooksConfig.\'post-tag\'",\n "type": "boolean",\n "description": "Enables follow-up tasks after a tag is created.",\n "default": "false"\n },\n {\n "key": "GitConfig.hooks",\n "type": "GitHooksConfig",\n "description": "Hook toggles used by the CLI and validation workflow."\n },\n {\n "key": "GitConfig.enforceHooks",\n "type": "boolean",\n "description": "Fails validation when required hooks are missing.",\n "default": "false"\n },\n {\n "key": "VersioningConfig.type",\n "type": "VersioningType",\n "description": "Versioning strategy used for the project."\n },\n {\n "key": "VersioningConfig.schemeRules",\n "type": "SchemeRules | undefined",\n "description": "Scheme-level validation rules applied regardless of versioning type.",\n "default": "`{ maxNumericSegments: 3, allowedModifiers: [\'dev\', \'alpha\', \'beta\', \'rc\'] }`"\n },\n {\n "key": "VersioningConfig.semver",\n "type": "SemVerConfig | undefined",\n "description": "SemVer-specific settings when `type` is `\'semver\'`.",\n "default": "`{ allowVPrefix: false, allowBuildMetadata: true, requirePrerelease: false }`"\n },\n {\n "key": "VersioningConfig.calver",\n "type": "CalVerConfig | undefined",\n "description": "CalVer-specific settings when `type` is `\'calver\'`.",\n "default": "undefined"\n },\n {\n "key": "ScanConfig.enabled",\n "type": "boolean",\n "description": "Enables repo-wide scanning for stale version literals.",\n "default": "false"\n },\n {\n "key": "ScanConfig.patterns",\n "type": "string[]",\n "description": "Regex patterns that match version-like strings in source files. Capture group 1 must contain the version string.",\n "default": "Patterns matching common version formats in code, CI, and Docker files."\n },\n {\n "key": "ScanConfig.allowlist",\n "type": "ScanAllowlistEntry[]",\n "description": "Files containing intentional version references that should not be flagged.",\n "default": "[]"\n },\n {\n "key": "VersionGuardConfig.versioning",\n "type": "VersioningConfig",\n "description": "Active versioning settings."\n },\n {\n "key": "VersionGuardConfig.manifest",\n "type": "ManifestConfig",\n "description": "Version source manifest settings.",\n "default": "`{ source: \'auto\' }`"\n },\n {\n "key": "VersionGuardConfig.sync",\n "type": "SyncConfig",\n "description": "Synchronization settings for mirrored version strings."\n },\n {\n "key": "VersionGuardConfig.changelog",\n "type": "ChangelogConfig",\n "description": "Changelog validation settings."\n },\n {\n "key": "VersionGuardConfig.git",\n "type": "GitConfig",\n "description": "Git enforcement settings."\n },\n {\n "key": "VersionGuardConfig.scan",\n "type": "ScanConfig",\n "description": "Repo-wide version literal scanning.",\n "default": "`{ enabled: false, patterns: [...], allowlist: [] }`"\n },\n {\n "key": "VersionGuardConfig.ignore",\n "type": "string[]",\n "description": "Files or patterns excluded from validation."\n },\n {\n "key": "ChangelogStructureOptions.enforceStructure",\n "type": "boolean | undefined",\n "description": "Validate section headers against an allowed list."\n },\n {\n "key": "ChangelogStructureOptions.sections",\n "type": "string[] | undefined",\n "description": "Allowed section names. Defaults to Keep a Changelog standard sections."\n },\n {\n "key": "CkmConfigEntry.key",\n "type": "string",\n "description": "Dotted key path (e.g., `\'CalVerConfig.format\'`)."\n },\n {\n "key": "CkmConfigEntry.type",\n "type": "string",\n "description": "TypeScript type."\n },\n {\n "key": "CkmConfigEntry.description",\n "type": "string",\n "description": "Description from TSDoc."\n },\n {\n "key": "CkmConfigEntry.default",\n "type": "string | undefined",\n "description": "Default value if specified via `@defaultValue`."\n },\n {\n "key": "InitOptions.cwd",\n "type": "string",\n "description": "Working directory path."\n },\n {\n "key": "InitOptions.type",\n "type": "\\"semver\\" | \\"calver\\" | undefined",\n "description": "Versioning type (semver or calver)."\n },\n {\n "key": "InitOptions.format",\n "type": "string | undefined",\n "description": "CalVer format string."\n },\n {\n "key": "InitOptions.allowVPrefix",\n "type": "boolean | undefined",\n "description": "Allow v-prefix on SemVer versions."\n },\n {\n "key": "InitOptions.allowBuildMetadata",\n "type": "boolean | undefined",\n "description": "Allow build metadata on SemVer versions."\n },\n {\n "key": "InitOptions.requirePrerelease",\n "type": "boolean | undefined",\n "description": "Require prerelease labels on SemVer versions."\n },\n {\n "key": "InitOptions.manifest",\n "type": "string | undefined",\n "description": "Manifest source type."\n },\n {\n "key": "InitOptions.hooks",\n "type": "boolean | undefined",\n "description": "Whether to install git hooks."\n },\n {\n "key": "InitOptions.changelog",\n "type": "boolean | undefined",\n "description": "Whether to enable changelog validation."\n },\n {\n "key": "InitOptions.yes",\n "type": "boolean | undefined",\n "description": "Accept defaults without prompting."\n },\n {\n "key": "InitOptions.force",\n "type": "boolean | undefined",\n "description": "Overwrite existing config."\n }\n ]\n}';
11
- const llmsRaw = "# @codluv/versionguard\n> Strict versioning enforcement for SemVer and CalVer — language-agnostic manifest support, git hooks, changelog validation, and file sync\n> Version: 0.7.0\n\n## Install\n\n```bash\nnpm install -D @codluv/versionguard\n```\n\n## Documentation\n\n- [API Reference](./api-reference.mdx): Full API documentation (MDX)\n- [Full Context](./llms-full.txt): Complete symbol documentation for deep LLM consumption\n\n## Packages\n\n### main\n90 functions, 55 types\n\n- getSemVerConfig() — Resolves the SemVer config from a VersionGuard config.\n- getCalVerConfig() — Extracts the CalVer config from a VersionGuard config, throwing if missing.\n- validateModifier() — Validates a pre-release / modifier tag against the allowed modifiers list.\n- isValidCalVerFormat() — Validates that a CalVer format string is composed of valid tokens and follows structural rules.\n- parseFormat() — Breaks a CalVer format string into its component tokens.\n- getRegexForFormat() — Builds a regular expression that matches a supported CalVer format.\n- parse() — Parses a CalVer string using the supplied format.\n- validate() — Validates a CalVer string against formatting and date rules.\n- format() — Formats a parsed CalVer object back into a version string.\n- getCurrentVersion() — Creates the current CalVer string for a format.\n- compare() — Compares two CalVer strings using a shared format.\n- increment() — Increments a CalVer string.\n- getNextVersions() — Returns the most likely next CalVer candidates.\n- validateChangelog() — Validates a changelog file for release readiness.\n- getLatestVersion() — Gets the most recent released version from a changelog.\n- addVersionEntry() — Inserts a new version entry beneath the `[Unreleased]` section.\n- isChangesetMangled() — Detects whether a changelog has been mangled by Changesets.\n- fixChangesetMangling() — Fixes a Changesets-mangled changelog into proper Keep a Changelog format.\n- createCkmEngine() — Creates a CKM engine from a parsed manifest.\n- parse() — Parses a semantic version string.\n- validate() — Validates that a string is a supported semantic version.\n- compare() — Compares two semantic version strings.\n- gt() — Checks whether one semantic version is greater than another.\n- lt() — Checks whether one semantic version is less than another.\n- eq() — Checks whether two semantic versions are equal in precedence.\n- increment() — Increments a semantic version string by release type.\n- format() — Formats a parsed semantic version object.\n- getVersionFeedback() — Generates actionable feedback for a version string.\n- getSyncFeedback() — Generates suggestions for version sync mismatches in a file.\n- getChangelogFeedback() — Generates suggestions for changelog-related validation issues.\n- getTagFeedback() — Generates suggestions for git tag mismatches.\n- getNestedValue() — Traverses a nested object using a dotted key path.\n- setNestedValue() — Sets a value at a dotted key path, throwing if intermediate segments are missing.\n- escapeRegExp() — Escapes special regex characters in a string for safe use in `new RegExp()`.\n- resolveVersionSource() — Resolves the version source provider for a project.\n- detectManifests() — Detects all manifest files present in a project directory.\n- getPackageJsonPath() — Gets the `package.json` path for a project directory.\n- readPackageJson() — Reads and parses a project's `package.json` file.\n- writePackageJson() — Writes a `package.json` document back to disk.\n- getPackageVersion() — Gets the version string from the project manifest. When a `manifest` config is provided, uses the configured version source provider (auto-detection or explicit). Falls back to `package.json` for backwards compatibility when no config is provided.\n- setPackageVersion() — Sets the version field in the project manifest. When a `manifest` config is provided, uses the configured version source provider. Falls back to `package.json` for backwards compatibility when no config is provided.\n- getVersionSource() — Resolves the version source provider for a project.\n- syncVersion() — Synchronizes configured files to a single version string.\n- syncFile() — Synchronizes a single file to a target version.\n- checkHardcodedVersions() — Checks configured files for hardcoded version mismatches.\n- scanRepoForVersions() — Scans the entire repository for hardcoded version literals.\n- fixPackageVersion() — Updates the `package.json` version field when needed.\n- fixSyncIssues() — Synchronizes configured files to the package version.\n- fixChangelog() — Ensures the changelog contains an entry for a version.\n- fixAll() — Runs all configured auto-fix operations.\n- suggestNextVersion() — Suggests candidate next versions for a release.\n- installHooks() — Installs VersionGuard-managed Git hooks in a repository.\n- uninstallHooks() — Removes VersionGuard-managed Git hooks from a repository.\n- findGitDir() — Finds the nearest `.git` directory by walking up from a starting directory.\n- areHooksInstalled() — Checks whether all VersionGuard-managed hooks are installed.\n- generateHookScript() — Generates the shell script content for a Git hook.\n- checkHooksPathOverride() — Checks whether git hooks have been redirected away from the repository.\n- checkHuskyBypass() — Checks whether the HUSKY environment variable is disabling hooks.\n- checkHookIntegrity() — Verifies that installed hook scripts match the expected content.\n- checkEnforceHooksPolicy() — Checks whether hooks are configured as required but not enforced.\n- runGuardChecks() — Runs all guard checks and returns a consolidated report.\n- getDefaultConfig() — Returns a deep-cloned copy of the built-in VersionGuard configuration.\n- findConfig() — Finds the first supported VersionGuard config file in a directory.\n- loadConfig() — Loads a VersionGuard config file from disk.\n- getConfig() — Resolves the active VersionGuard configuration for a project.\n- initConfig() — Initializes a new VersionGuard config file in a project.\n- findProjectRoot() — Walks up from `startDir` to find the nearest project root.\n- formatNotProjectError() — Formats a helpful error message when a command can't find a project.\n- getLatestTag() — Returns the most recent reachable git tag for a repository.\n- getAllTags() — Lists all tags in a repository.\n- createTag() — Creates a release tag and optionally fixes version state first.\n- handlePostTag() — Runs post-tag validation and sync checks.\n- validateTagForPush() — Validates that a local tag is safe to push to the default remote.\n- suggestTagMessage() — Suggests an annotated tag message from changelog content.\n- validateVersion() — Validates a version string against the active versioning strategy.\n- validate() — Validates the current project state against the supplied configuration.\n- doctor() — Runs an extended readiness check for a project.\n- sync() — Synchronizes configured files to the current package version.\n- canBump() — Determines whether a project can move from one version to another.\n- runWizard() — Runs the interactive setup wizard.\n- runHeadless() — Initializes VersionGuard non-interactively using CLI flags.\n- createProgram() — Creates the VersionGuard CLI program definition.\n- runCli() — Parses CLI arguments and executes the matching command.\n- shouldRunCli() — Determines whether the current module is the invoked CLI entry point.\n- createTempProject() — Creates a temporary project directory with a minimal `package.json` fixture.\n- initGitRepo() — Initializes a git repository in a fixture directory with a first commit.\n- writeTextFile() — Writes a text fixture file relative to a temporary project directory.\n- createBareRemote() — Creates a bare git repository to use as a remote in integration tests.\n- addGitRemote() — Adds a local bare repository as the `origin` remote for a fixture repo.\n- commitAll() — Stages all changes and creates a commit in a fixture repository.\n\n- VersioningType — Supported versioning strategies.\n- ManifestSourceType — Supported manifest source types for version extraction.\n- ManifestConfig — Configures the version source manifest.\n- CalVerToken — Valid CalVer token names for building format strings.\n- CalVerFormat — A CalVer format string composed of dot-separated tokens.\n- SchemeRules — Configures scheme-level validation rules applied regardless of versioning type.\n- SemVerConfig — Configures SemVer validation rules.\n- CalVerConfig — Configures CalVer validation rules.\n- SyncPattern — Describes a search-and-replace pattern used during version synchronization.\n- SyncConfig — Configures files and patterns that should stay in sync with the canonical version.\n- ChangelogConfig — Controls changelog validation behavior.\n- GitHooksConfig — Toggles each supported git hook integration.\n- GitConfig — Configures git-related enforcement.\n- VersioningConfig — Configures the active versioning mode.\n- ScanAllowlistEntry — An intentional version reference that should be excluded from scan results.\n- ScanConfig — Configures repo-wide scanning for hardcoded version literals.\n- VersionGuardConfig — Top-level configuration consumed by versionguard.\n- SemVer — Parsed semantic version components.\n- CalVer — Parsed calendar version components.\n- ParsedSemVer — Parsed semantic version result wrapper.\n- ParsedCalVer — Parsed calendar version result wrapper.\n- ParsedVersion — Union of supported parsed version payloads.\n- ValidationError — Describes a single validation problem.\n- ValidationResult — Result returned by version parsing and validation helpers.\n- SyncChange — Describes a single in-file version replacement.\n- SyncResult — Reports the result of synchronizing a single file.\n- VersionMismatch — Reports a discovered version mismatch.\n- FullValidationResult — Combined result from a full project validation run.\n- DoctorReport — Reports whether a project is ready to pass VersionGuard checks.\n- ParsedCalVerFormat — Parsed token layout for a supported CalVer format string.\n- ChangelogValidationResult — Describes the outcome of validating a changelog file.\n- ChangelogStructureOptions — Options for changelog structure enforcement.\n- CkmConcept — A domain concept extracted from an exported interface or type.\n- CkmProperty — A property within a concept.\n- CkmOperation — A user-facing operation extracted from an exported function.\n- CkmInput — A function parameter within an operation.\n- CkmConstraint — A constraint enforced by the tool.\n- CkmWorkflow — A multi-step workflow for a common goal.\n- CkmConfigEntry — A config schema entry with type, description, and default.\n- CkmManifest — The complete Codebase Knowledge Manifest.\n- CkmTopic — An auto-generated topic derived from CKM data.\n- CkmEngine — The CKM engine — provides topic derivation, filtering, and output formatting.\n- Suggestion — Feedback entry point exports for suggestion and guidance helpers.\n- FeedbackResult — Aggregates validation errors with suggested next steps.\n- VersionSourceProvider — Abstraction for reading and writing a version string from any manifest format.\n- PackageJsonValue — JSON-compatible scalar, array, or object value used by package metadata.\n- PackageJsonArray — Recursive array type used for arbitrary JSON-compatible package values.\n- PackageJsonObject — Recursive object type used for arbitrary JSON-compatible package values.\n- PackageJson — Minimal shape of a `package.json` document used by VersionGuard.\n- FixResult — Fix entry point exports for auto-remediation helpers.\n- GuardWarning — Describes a single guard finding.\n- GuardReport — Result of a full guard check pass.\n- ProjectRootResult — Result of project root detection.\n- TagInfo — Tag entry point exports for release-tag management helpers.\n- InitOptions — Options for headless (non-interactive) initialization.\n";
10
+ //#region docs/ckm.json?raw
11
+ var ckm_default = "{\n \"$schema\": \"https://forge-ts.dev/schemas/ckm/v1.json\",\n \"version\": \"1.0.0\",\n \"project\": \"@codluv/versionguard\",\n \"generated\": \"2026-03-26T22:14:21.976Z\",\n \"concepts\": [\n {\n \"id\": \"concept-ManifestConfig\",\n \"name\": \"ManifestConfig\",\n \"what\": \"Configures the version source manifest.\",\n \"properties\": [\n {\n \"name\": \"source\",\n \"type\": \"ManifestSourceType\",\n \"description\": \"Manifest file to read the version from. Use `'auto'` for file-existence detection or a specific filename.\"\n },\n {\n \"name\": \"path\",\n \"type\": \"string | undefined\",\n \"description\": \"Dotted key path to the version field within the manifest. For example `'version'` for package.json, `'package.version'` for Cargo.toml, or `'project.version'` for pyproject.toml.\"\n },\n {\n \"name\": \"regex\",\n \"type\": \"string | undefined\",\n \"description\": \"Regex pattern to extract the version from source-code manifests. Capture group 1 must contain the version string.\"\n }\n ]\n },\n {\n \"id\": \"concept-SemVerConfig\",\n \"name\": \"SemVerConfig\",\n \"what\": \"Configures SemVer validation rules.\",\n \"properties\": [\n {\n \"name\": \"allowVPrefix\",\n \"type\": \"boolean\",\n \"description\": \"Tolerates a leading `v` prefix (e.g. `v1.2.3`). When enabled the prefix is stripped before parsing.\"\n },\n {\n \"name\": \"allowBuildMetadata\",\n \"type\": \"boolean\",\n \"description\": \"Permits `+build` metadata on version strings.\"\n },\n {\n \"name\": \"requirePrerelease\",\n \"type\": \"boolean\",\n \"description\": \"Requires every version to carry a prerelease label.\"\n }\n ]\n },\n {\n \"id\": \"concept-CalVerConfig\",\n \"name\": \"CalVerConfig\",\n \"what\": \"Configures CalVer validation rules.\",\n \"properties\": [\n {\n \"name\": \"format\",\n \"type\": \"CalVerFormat\",\n \"description\": \"Calendar format used when parsing and validating versions.\"\n },\n {\n \"name\": \"preventFutureDates\",\n \"type\": \"boolean\",\n \"description\": \"Rejects versions that point to a future date.\"\n },\n {\n \"name\": \"strictMutualExclusion\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Enforces that week tokens (WW/0W) cannot be mixed with month/day tokens.\"\n }\n ]\n },\n {\n \"id\": \"concept-SyncConfig\",\n \"name\": \"SyncConfig\",\n \"what\": \"Configures files and patterns that should stay in sync with the canonical version.\",\n \"properties\": [\n {\n \"name\": \"files\",\n \"type\": \"string[]\",\n \"description\": \"File globs or paths that should be scanned for version updates.\"\n },\n {\n \"name\": \"patterns\",\n \"type\": \"SyncPattern[]\",\n \"description\": \"Replacement patterns applied to matching files.\"\n }\n ]\n },\n {\n \"id\": \"concept-ChangelogConfig\",\n \"name\": \"ChangelogConfig\",\n \"what\": \"Controls changelog validation behavior.\",\n \"properties\": [\n {\n \"name\": \"enabled\",\n \"type\": \"boolean\",\n \"description\": \"Enables changelog validation.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"string\",\n \"description\": \"Path to the changelog file to inspect.\"\n },\n {\n \"name\": \"strict\",\n \"type\": \"boolean\",\n \"description\": \"Treats changelog problems as hard failures.\"\n },\n {\n \"name\": \"requireEntry\",\n \"type\": \"boolean\",\n \"description\": \"Requires an entry for the current version.\"\n },\n {\n \"name\": \"enforceStructure\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Validates that changelog section headers use only allowed names. When enabled, any `### SectionName` header not present in `sections` is reported as an error.\"\n },\n {\n \"name\": \"sections\",\n \"type\": \"string[] | undefined\",\n \"description\": \"Allowed Keep a Changelog section names. Only applied when `enforceStructure` is `true`.\"\n }\n ]\n },\n {\n \"id\": \"concept-GitHooksConfig\",\n \"name\": \"GitHooksConfig\",\n \"what\": \"Toggles each supported git hook integration.\",\n \"properties\": [\n {\n \"name\": \"'pre-commit'\",\n \"type\": \"boolean\",\n \"description\": \"Enables validation during the `pre-commit` hook.\"\n },\n {\n \"name\": \"'pre-push'\",\n \"type\": \"boolean\",\n \"description\": \"Enables validation during the `pre-push` hook.\"\n },\n {\n \"name\": \"'post-tag'\",\n \"type\": \"boolean\",\n \"description\": \"Enables follow-up tasks after a tag is created.\"\n }\n ]\n },\n {\n \"id\": \"concept-GitConfig\",\n \"name\": \"GitConfig\",\n \"what\": \"Configures git-related enforcement.\",\n \"properties\": [\n {\n \"name\": \"hooks\",\n \"type\": \"GitHooksConfig\",\n \"description\": \"Hook toggles used by the CLI and validation workflow.\"\n },\n {\n \"name\": \"enforceHooks\",\n \"type\": \"boolean\",\n \"description\": \"Fails validation when required hooks are missing.\"\n }\n ]\n },\n {\n \"id\": \"concept-GitHubConfig\",\n \"name\": \"GitHubConfig\",\n \"what\": \"Configures GitHub-specific integration features.\",\n \"properties\": [\n {\n \"name\": \"dependabot\",\n \"type\": \"boolean\",\n \"description\": \"Generates `.github/dependabot.yml` from detected manifests during init.\"\n }\n ]\n },\n {\n \"id\": \"concept-VersioningConfig\",\n \"name\": \"VersioningConfig\",\n \"what\": \"Configures the active versioning mode.\",\n \"properties\": [\n {\n \"name\": \"type\",\n \"type\": \"VersioningType\",\n \"description\": \"Versioning strategy used for the project.\"\n },\n {\n \"name\": \"schemeRules\",\n \"type\": \"SchemeRules | undefined\",\n \"description\": \"Scheme-level validation rules applied regardless of versioning type.\"\n },\n {\n \"name\": \"semver\",\n \"type\": \"SemVerConfig | undefined\",\n \"description\": \"SemVer-specific settings when `type` is `'semver'`.\"\n },\n {\n \"name\": \"calver\",\n \"type\": \"CalVerConfig | undefined\",\n \"description\": \"CalVer-specific settings when `type` is `'calver'`.\"\n }\n ]\n },\n {\n \"id\": \"concept-ScanAllowlistEntry\",\n \"name\": \"ScanAllowlistEntry\",\n \"what\": \"An intentional version reference that should be excluded from scan results.\",\n \"properties\": [\n {\n \"name\": \"file\",\n \"type\": \"string\",\n \"description\": \"Glob pattern matching the file(s) where this reference is intentional.\"\n },\n {\n \"name\": \"reason\",\n \"type\": \"string | undefined\",\n \"description\": \"Reason this reference is allowed (for documentation / review).\"\n }\n ]\n },\n {\n \"id\": \"concept-ScanConfig\",\n \"name\": \"ScanConfig\",\n \"what\": \"Configures repo-wide scanning for hardcoded version literals.\",\n \"properties\": [\n {\n \"name\": \"enabled\",\n \"type\": \"boolean\",\n \"description\": \"Enables repo-wide scanning for stale version literals.\"\n },\n {\n \"name\": \"patterns\",\n \"type\": \"string[]\",\n \"description\": \"Regex patterns that match version-like strings in source files. Capture group 1 must contain the version string.\"\n },\n {\n \"name\": \"allowlist\",\n \"type\": \"ScanAllowlistEntry[]\",\n \"description\": \"Files containing intentional version references that should not be flagged.\"\n }\n ]\n },\n {\n \"id\": \"concept-VersionGuardConfig\",\n \"name\": \"VersionGuardConfig\",\n \"what\": \"Top-level configuration consumed by versionguard.\",\n \"properties\": [\n {\n \"name\": \"versioning\",\n \"type\": \"VersioningConfig\",\n \"description\": \"Active versioning settings.\"\n },\n {\n \"name\": \"manifest\",\n \"type\": \"ManifestConfig\",\n \"description\": \"Version source manifest settings.\"\n },\n {\n \"name\": \"sync\",\n \"type\": \"SyncConfig\",\n \"description\": \"Synchronization settings for mirrored version strings.\"\n },\n {\n \"name\": \"changelog\",\n \"type\": \"ChangelogConfig\",\n \"description\": \"Changelog validation settings.\"\n },\n {\n \"name\": \"git\",\n \"type\": \"GitConfig\",\n \"description\": \"Git enforcement settings.\"\n },\n {\n \"name\": \"github\",\n \"type\": \"GitHubConfig\",\n \"description\": \"GitHub integration settings.\"\n },\n {\n \"name\": \"scan\",\n \"type\": \"ScanConfig\",\n \"description\": \"Repo-wide version literal scanning.\"\n },\n {\n \"name\": \"ignore\",\n \"type\": \"string[]\",\n \"description\": \"Files or patterns excluded from validation.\"\n }\n ]\n },\n {\n \"id\": \"concept-ValidationResult\",\n \"name\": \"ValidationResult\",\n \"what\": \"Result returned by version parsing and validation helpers.\",\n \"properties\": [\n {\n \"name\": \"valid\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether validation completed without errors.\"\n },\n {\n \"name\": \"errors\",\n \"type\": \"ValidationError[]\",\n \"description\": \"Collected validation issues.\"\n },\n {\n \"name\": \"version\",\n \"type\": \"ParsedVersion | undefined\",\n \"description\": \"Parsed version details when validation succeeds.\"\n }\n ]\n },\n {\n \"id\": \"concept-SyncResult\",\n \"name\": \"SyncResult\",\n \"what\": \"Reports the result of synchronizing a single file.\",\n \"properties\": [\n {\n \"name\": \"file\",\n \"type\": \"string\",\n \"description\": \"File that was inspected or updated.\"\n },\n {\n \"name\": \"updated\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether the file content changed.\"\n },\n {\n \"name\": \"changes\",\n \"type\": \"SyncChange[]\",\n \"description\": \"Detailed replacements applied within the file.\"\n }\n ]\n },\n {\n \"id\": \"concept-FullValidationResult\",\n \"name\": \"FullValidationResult\",\n \"what\": \"Combined result from a full project validation run.\",\n \"properties\": [\n {\n \"name\": \"valid\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether all checks passed.\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\",\n \"description\": \"Canonical version string used for validation.\"\n },\n {\n \"name\": \"versionValid\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether the root version string is valid.\"\n },\n {\n \"name\": \"syncValid\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether synchronized files are in sync.\"\n },\n {\n \"name\": \"changelogValid\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether changelog checks passed.\"\n },\n {\n \"name\": \"errors\",\n \"type\": \"string[]\",\n \"description\": \"Human-readable validation failures collected during the run.\"\n }\n ]\n },\n {\n \"id\": \"concept-ChangelogValidationResult\",\n \"name\": \"ChangelogValidationResult\",\n \"what\": \"Describes the outcome of validating a changelog file.\",\n \"properties\": [\n {\n \"name\": \"valid\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether the changelog satisfies all requested checks.\"\n },\n {\n \"name\": \"errors\",\n \"type\": \"string[]\",\n \"description\": \"Human-readable validation errors.\"\n },\n {\n \"name\": \"hasEntryForVersion\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether the changelog contains an entry for the requested version.\"\n }\n ]\n },\n {\n \"id\": \"concept-ChangelogStructureOptions\",\n \"name\": \"ChangelogStructureOptions\",\n \"what\": \"Options for changelog structure enforcement.\",\n \"properties\": [\n {\n \"name\": \"enforceStructure\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Validate section headers against an allowed list.\"\n },\n {\n \"name\": \"sections\",\n \"type\": \"string[] | undefined\",\n \"description\": \"Allowed section names. Defaults to Keep a Changelog standard sections.\"\n }\n ]\n },\n {\n \"id\": \"concept-CkmConfigEntry\",\n \"name\": \"CkmConfigEntry\",\n \"what\": \"A config schema entry with type, description, and default.\",\n \"properties\": [\n {\n \"name\": \"key\",\n \"type\": \"string\",\n \"description\": \"Dotted key path (e.g., `'CalVerConfig.format'`).\"\n },\n {\n \"name\": \"type\",\n \"type\": \"string\",\n \"description\": \"TypeScript type.\"\n },\n {\n \"name\": \"description\",\n \"type\": \"string\",\n \"description\": \"Description from TSDoc.\"\n },\n {\n \"name\": \"default\",\n \"type\": \"string | undefined\",\n \"description\": \"Default value if specified via `@defaultValue`.\"\n }\n ]\n },\n {\n \"id\": \"concept-FeedbackResult\",\n \"name\": \"FeedbackResult\",\n \"what\": \"Aggregates validation errors with suggested next steps.\",\n \"properties\": [\n {\n \"name\": \"valid\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether the inspected version state is valid.\"\n },\n {\n \"name\": \"errors\",\n \"type\": \"ValidationError[]\",\n \"description\": \"Validation errors collected during the check.\"\n },\n {\n \"name\": \"suggestions\",\n \"type\": \"Suggestion[]\",\n \"description\": \"Suggested next steps for resolving the reported issues.\"\n },\n {\n \"name\": \"canAutoFix\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether at least one suggestion can be auto-applied.\"\n }\n ]\n },\n {\n \"id\": \"concept-FixResult\",\n \"name\": \"FixResult\",\n \"what\": \"Fix entry point exports for auto-remediation helpers.\",\n \"properties\": [\n {\n \"name\": \"fixed\",\n \"type\": \"boolean\",\n \"description\": \"Indicates whether the operation changed repository state.\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\",\n \"description\": \"Human-readable description of the fix attempt.\"\n },\n {\n \"name\": \"file\",\n \"type\": \"string | undefined\",\n \"description\": \"Absolute path to the file that was updated, when applicable.\"\n }\n ]\n },\n {\n \"id\": \"concept-ProjectRootResult\",\n \"name\": \"ProjectRootResult\",\n \"what\": \"Result of project root detection.\",\n \"properties\": [\n {\n \"name\": \"found\",\n \"type\": \"boolean\",\n \"description\": \"Whether a project root was found.\"\n },\n {\n \"name\": \"root\",\n \"type\": \"string\",\n \"description\": \"The resolved project root directory, or the original cwd if not found.\"\n },\n {\n \"name\": \"marker\",\n \"type\": \"string | undefined\",\n \"description\": \"Which marker file was found.\"\n },\n {\n \"name\": \"hasConfig\",\n \"type\": \"boolean\",\n \"description\": \"Whether the directory has a VersionGuard config.\"\n },\n {\n \"name\": \"hasGit\",\n \"type\": \"boolean\",\n \"description\": \"Whether the directory is inside a git repository.\"\n },\n {\n \"name\": \"hasManifest\",\n \"type\": \"boolean\",\n \"description\": \"Whether a version manifest file exists.\"\n }\n ]\n },\n {\n \"id\": \"concept-InitOptions\",\n \"name\": \"InitOptions\",\n \"what\": \"Options for headless (non-interactive) initialization.\",\n \"properties\": [\n {\n \"name\": \"cwd\",\n \"type\": \"string\",\n \"description\": \"Working directory path.\"\n },\n {\n \"name\": \"type\",\n \"type\": \"\\\"semver\\\" | \\\"calver\\\" | undefined\",\n \"description\": \"Versioning type (semver or calver).\"\n },\n {\n \"name\": \"format\",\n \"type\": \"string | undefined\",\n \"description\": \"CalVer format string.\"\n },\n {\n \"name\": \"allowVPrefix\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Allow v-prefix on SemVer versions.\"\n },\n {\n \"name\": \"allowBuildMetadata\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Allow build metadata on SemVer versions.\"\n },\n {\n \"name\": \"requirePrerelease\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Require prerelease labels on SemVer versions.\"\n },\n {\n \"name\": \"manifest\",\n \"type\": \"string | undefined\",\n \"description\": \"Manifest source type.\"\n },\n {\n \"name\": \"github\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Whether to generate GitHub integration files (dependabot.yml).\"\n },\n {\n \"name\": \"hooks\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Whether to install git hooks.\"\n },\n {\n \"name\": \"changelog\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Whether to enable changelog validation.\"\n },\n {\n \"name\": \"yes\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Accept defaults without prompting.\"\n },\n {\n \"name\": \"force\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Overwrite existing config.\"\n }\n ]\n }\n ],\n \"operations\": [\n {\n \"id\": \"op-validateModifier\",\n \"name\": \"validateModifier\",\n \"what\": \"Validates a pre-release / modifier tag against the allowed modifiers list.\",\n \"inputs\": [\n {\n \"name\": \"modifier\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Raw modifier string (e.g. `\\\"alpha.1\\\"`, `\\\"rc2\\\"`, `\\\"dev\\\"`).\"\n },\n {\n \"name\": \"schemeRules\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Scheme rules containing the allowed modifiers list.\"\n }\n ],\n \"outputs\": {\n \"text\": \"A validation error when the modifier is disallowed, otherwise `null`.\"\n }\n },\n {\n \"id\": \"op-validate\",\n \"name\": \"validate\",\n \"what\": \"Validates a CalVer string against formatting and date rules.\",\n \"inputs\": [\n {\n \"name\": \"version\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Version string to validate.\"\n },\n {\n \"name\": \"calverFormat\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Format expected for the version string.\"\n },\n {\n \"name\": \"preventFutureDates\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Whether future dates should be reported as errors.\"\n },\n {\n \"name\": \"schemeRules\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Optional scheme rules for modifier validation and segment count warnings.\"\n }\n ],\n \"outputs\": {\n \"text\": \"A validation result containing any discovered errors and the parsed version on success.\"\n }\n },\n {\n \"id\": \"op-validateChangelog\",\n \"name\": \"validateChangelog\",\n \"what\": \"Validates a changelog file for release readiness.\",\n \"inputs\": [\n {\n \"name\": \"changelogPath\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Path to the changelog file.\"\n },\n {\n \"name\": \"version\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Version that must be present in the changelog.\"\n },\n {\n \"name\": \"strict\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Whether to require compare links and dated release headings.\"\n },\n {\n \"name\": \"requireEntry\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Whether the requested version must already have an entry.\"\n },\n {\n \"name\": \"structure\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Optional structure enforcement options.\"\n }\n ],\n \"outputs\": {\n \"text\": \"The result of validating the changelog file.\"\n }\n },\n {\n \"id\": \"op-createCkmEngine\",\n \"name\": \"createCkmEngine\",\n \"what\": \"Creates a CKM engine from a parsed manifest.\",\n \"inputs\": [\n {\n \"name\": \"manifest\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Parsed CKM manifest (from forge-ts `ckm.json`).\"\n }\n ],\n \"outputs\": {\n \"text\": \"A configured CKM engine.\"\n }\n },\n {\n \"id\": \"op-checkHardcodedVersions\",\n \"name\": \"checkHardcodedVersions\",\n \"what\": \"Checks configured files for hardcoded version mismatches.\",\n \"inputs\": [\n {\n \"name\": \"expectedVersion\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Version all matching entries should use.\"\n },\n {\n \"name\": \"config\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Sync configuration describing files and replacement patterns.\"\n },\n {\n \"name\": \"ignorePatterns\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Glob patterns to exclude while scanning.\"\n },\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Project directory used to resolve file globs.\"\n }\n ],\n \"outputs\": {\n \"text\": \"A list of detected version mismatches.\"\n }\n },\n {\n \"id\": \"op-generateHookScript\",\n \"name\": \"generateHookScript\",\n \"what\": \"Generates the shell script content for a Git hook.\",\n \"inputs\": [\n {\n \"name\": \"hookName\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Name of the Git hook to generate.\"\n }\n ],\n \"outputs\": {\n \"text\": \"Executable shell script contents for the hook.\"\n }\n },\n {\n \"id\": \"op-checkHooksPathOverride\",\n \"name\": \"checkHooksPathOverride\",\n \"what\": \"Checks whether git hooks have been redirected away from the repository.\",\n \"inputs\": [\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Repository directory to inspect.\"\n }\n ],\n \"outputs\": {\n \"text\": \"A guard warning when a hooksPath override is detected.\"\n }\n },\n {\n \"id\": \"op-checkHuskyBypass\",\n \"name\": \"checkHuskyBypass\",\n \"what\": \"Checks whether the HUSKY environment variable is disabling hooks.\",\n \"inputs\": [],\n \"outputs\": {\n \"text\": \"A guard warning when the HUSKY bypass is detected.\"\n }\n },\n {\n \"id\": \"op-checkHookIntegrity\",\n \"name\": \"checkHookIntegrity\",\n \"what\": \"Verifies that installed hook scripts match the expected content.\",\n \"inputs\": [\n {\n \"name\": \"config\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"VersionGuard configuration that defines which hooks should exist.\"\n },\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Repository directory to inspect.\"\n }\n ],\n \"outputs\": {\n \"text\": \"Guard warnings for each hook that has been tampered with.\"\n }\n },\n {\n \"id\": \"op-checkEnforceHooksPolicy\",\n \"name\": \"checkEnforceHooksPolicy\",\n \"what\": \"Checks whether hooks are configured as required but not enforced.\",\n \"inputs\": [\n {\n \"name\": \"config\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"VersionGuard configuration to inspect.\"\n }\n ],\n \"outputs\": {\n \"text\": \"A guard warning when hooks are enabled but not enforced.\"\n }\n },\n {\n \"id\": \"op-runGuardChecks\",\n \"name\": \"runGuardChecks\",\n \"what\": \"Runs all guard checks and returns a consolidated report.\",\n \"inputs\": [\n {\n \"name\": \"config\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"VersionGuard configuration.\"\n },\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Repository directory to inspect.\"\n }\n ],\n \"outputs\": {\n \"text\": \"A guard report with all findings.\"\n }\n },\n {\n \"id\": \"op-generateDependabotConfig\",\n \"name\": \"generateDependabotConfig\",\n \"what\": \"Generates Dependabot YAML configuration from detected manifests.\",\n \"inputs\": [\n {\n \"name\": \"manifests\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Detected manifest source types from the project.\"\n }\n ],\n \"outputs\": {\n \"text\": \"The Dependabot configuration as a YAML string.\"\n }\n },\n {\n \"id\": \"op-initConfig\",\n \"name\": \"initConfig\",\n \"what\": \"Initializes a new VersionGuard config file in a project.\",\n \"inputs\": [\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Project directory where the config should be created.\"\n }\n ],\n \"outputs\": {\n \"text\": \"The path to the created config file.\"\n }\n },\n {\n \"id\": \"op-createTag\",\n \"name\": \"createTag\",\n \"what\": \"Creates a release tag and optionally fixes version state first.\",\n \"inputs\": [\n {\n \"name\": \"version\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Version to embed in the new tag name.\"\n },\n {\n \"name\": \"message\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Custom annotated tag message.\"\n },\n {\n \"name\": \"autoFix\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Whether to auto-fix version mismatches before tagging.\"\n },\n {\n \"name\": \"config\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Loaded VersionGuard configuration used for validation and fixes.\"\n },\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Repository directory where git commands should run.\"\n }\n ],\n \"outputs\": {\n \"text\": \"The tagging outcome and any actions performed along the way.\"\n }\n },\n {\n \"id\": \"op-validateTagForPush\",\n \"name\": \"validateTagForPush\",\n \"what\": \"Validates that a local tag is safe to push to the default remote.\",\n \"inputs\": [\n {\n \"name\": \"tagName\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Name of the tag to validate.\"\n },\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Repository directory where git commands should run.\"\n }\n ],\n \"outputs\": {\n \"text\": \"A validation result with an optional suggested fix command.\"\n }\n },\n {\n \"id\": \"op-validateVersion\",\n \"name\": \"validateVersion\",\n \"what\": \"Validates a version string against the active versioning strategy.\",\n \"inputs\": [\n {\n \"name\": \"version\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Version string to validate.\"\n },\n {\n \"name\": \"config\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"VersionGuard configuration that selects the validation rules.\"\n }\n ],\n \"outputs\": {\n \"text\": \"The validation result for the provided version.\"\n }\n },\n {\n \"id\": \"op-runWizard\",\n \"name\": \"runWizard\",\n \"what\": \"Runs the interactive setup wizard.\",\n \"inputs\": [\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Project directory to initialize.\"\n }\n ],\n \"outputs\": {\n \"text\": \"The path to the created config file, or `null` if cancelled.\"\n }\n },\n {\n \"id\": \"op-runHeadless\",\n \"name\": \"runHeadless\",\n \"what\": \"Initializes VersionGuard non-interactively using CLI flags.\",\n \"inputs\": [\n {\n \"name\": \"options\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Headless initialization options.\"\n }\n ],\n \"outputs\": {\n \"text\": \"The path to the created config file.\"\n }\n },\n {\n \"id\": \"op-createProgram\",\n \"name\": \"createProgram\",\n \"what\": \"Creates the VersionGuard CLI program definition.\",\n \"inputs\": [],\n \"outputs\": {\n \"text\": \"A configured Commander program for the VersionGuard CLI.\"\n }\n },\n {\n \"id\": \"op-runCli\",\n \"name\": \"runCli\",\n \"what\": \"Parses CLI arguments and executes the matching command.\",\n \"inputs\": [\n {\n \"name\": \"argv\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Full argument vector to parse.\"\n }\n ]\n },\n {\n \"id\": \"op-createTempProject\",\n \"name\": \"createTempProject\",\n \"what\": \"Creates a temporary project directory with a minimal `package.json` fixture.\",\n \"inputs\": [],\n \"outputs\": {\n \"text\": \"The absolute path to the temporary project directory.\"\n }\n },\n {\n \"id\": \"op-initGitRepo\",\n \"name\": \"initGitRepo\",\n \"what\": \"Initializes a git repository in a fixture directory with a first commit.\",\n \"inputs\": [\n {\n \"name\": \"cwd\",\n \"type\": \"unknown\",\n \"required\": true,\n \"description\": \"Absolute path to the fixture repository.\"\n }\n ]\n },\n {\n \"id\": \"op-createBareRemote\",\n \"name\": \"createBareRemote\",\n \"what\": \"Creates a bare git repository to use as a remote in integration tests.\",\n \"inputs\": [],\n \"outputs\": {\n \"text\": \"The absolute path to the new bare repository.\"\n }\n }\n ],\n \"constraints\": [],\n \"workflows\": [],\n \"configSchema\": [\n {\n \"key\": \"ManifestConfig.source\",\n \"type\": \"ManifestSourceType\",\n \"description\": \"Manifest file to read the version from. Use `'auto'` for file-existence detection or a specific filename.\",\n \"default\": \"'auto'\"\n },\n {\n \"key\": \"ManifestConfig.path\",\n \"type\": \"string | undefined\",\n \"description\": \"Dotted key path to the version field within the manifest. For example `'version'` for package.json, `'package.version'` for Cargo.toml, or `'project.version'` for pyproject.toml.\",\n \"default\": \"undefined (uses the provider's built-in default)\"\n },\n {\n \"key\": \"ManifestConfig.regex\",\n \"type\": \"string | undefined\",\n \"description\": \"Regex pattern to extract the version from source-code manifests. Capture group 1 must contain the version string.\",\n \"default\": \"undefined\"\n },\n {\n \"key\": \"SemVerConfig.allowVPrefix\",\n \"type\": \"boolean\",\n \"description\": \"Tolerates a leading `v` prefix (e.g. `v1.2.3`). When enabled the prefix is stripped before parsing.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"SemVerConfig.allowBuildMetadata\",\n \"type\": \"boolean\",\n \"description\": \"Permits `+build` metadata on version strings.\",\n \"default\": \"true\"\n },\n {\n \"key\": \"SemVerConfig.requirePrerelease\",\n \"type\": \"boolean\",\n \"description\": \"Requires every version to carry a prerelease label.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"CalVerConfig.format\",\n \"type\": \"CalVerFormat\",\n \"description\": \"Calendar format used when parsing and validating versions.\"\n },\n {\n \"key\": \"CalVerConfig.preventFutureDates\",\n \"type\": \"boolean\",\n \"description\": \"Rejects versions that point to a future date.\",\n \"default\": \"true\"\n },\n {\n \"key\": \"CalVerConfig.strictMutualExclusion\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Enforces that week tokens (WW/0W) cannot be mixed with month/day tokens.\",\n \"default\": \"true\"\n },\n {\n \"key\": \"SyncConfig.files\",\n \"type\": \"string[]\",\n \"description\": \"File globs or paths that should be scanned for version updates.\"\n },\n {\n \"key\": \"SyncConfig.patterns\",\n \"type\": \"SyncPattern[]\",\n \"description\": \"Replacement patterns applied to matching files.\"\n },\n {\n \"key\": \"ChangelogConfig.enabled\",\n \"type\": \"boolean\",\n \"description\": \"Enables changelog validation.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"ChangelogConfig.file\",\n \"type\": \"string\",\n \"description\": \"Path to the changelog file to inspect.\"\n },\n {\n \"key\": \"ChangelogConfig.strict\",\n \"type\": \"boolean\",\n \"description\": \"Treats changelog problems as hard failures.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"ChangelogConfig.requireEntry\",\n \"type\": \"boolean\",\n \"description\": \"Requires an entry for the current version.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"ChangelogConfig.enforceStructure\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Validates that changelog section headers use only allowed names. When enabled, any `### SectionName` header not present in `sections` is reported as an error.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"ChangelogConfig.sections\",\n \"type\": \"string[] | undefined\",\n \"description\": \"Allowed Keep a Changelog section names. Only applied when `enforceStructure` is `true`.\",\n \"default\": \"['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security']\"\n },\n {\n \"key\": \"GitHooksConfig.'pre-commit'\",\n \"type\": \"boolean\",\n \"description\": \"Enables validation during the `pre-commit` hook.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"GitHooksConfig.'pre-push'\",\n \"type\": \"boolean\",\n \"description\": \"Enables validation during the `pre-push` hook.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"GitHooksConfig.'post-tag'\",\n \"type\": \"boolean\",\n \"description\": \"Enables follow-up tasks after a tag is created.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"GitConfig.hooks\",\n \"type\": \"GitHooksConfig\",\n \"description\": \"Hook toggles used by the CLI and validation workflow.\"\n },\n {\n \"key\": \"GitConfig.enforceHooks\",\n \"type\": \"boolean\",\n \"description\": \"Fails validation when required hooks are missing.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"GitHubConfig.dependabot\",\n \"type\": \"boolean\",\n \"description\": \"Generates `.github/dependabot.yml` from detected manifests during init.\",\n \"default\": \"true\"\n },\n {\n \"key\": \"VersioningConfig.type\",\n \"type\": \"VersioningType\",\n \"description\": \"Versioning strategy used for the project.\"\n },\n {\n \"key\": \"VersioningConfig.schemeRules\",\n \"type\": \"SchemeRules | undefined\",\n \"description\": \"Scheme-level validation rules applied regardless of versioning type.\",\n \"default\": \"`{ maxNumericSegments: 3, allowedModifiers: ['dev', 'alpha', 'beta', 'rc'] }`\"\n },\n {\n \"key\": \"VersioningConfig.semver\",\n \"type\": \"SemVerConfig | undefined\",\n \"description\": \"SemVer-specific settings when `type` is `'semver'`.\",\n \"default\": \"`{ allowVPrefix: false, allowBuildMetadata: true, requirePrerelease: false }`\"\n },\n {\n \"key\": \"VersioningConfig.calver\",\n \"type\": \"CalVerConfig | undefined\",\n \"description\": \"CalVer-specific settings when `type` is `'calver'`.\",\n \"default\": \"undefined\"\n },\n {\n \"key\": \"ScanConfig.enabled\",\n \"type\": \"boolean\",\n \"description\": \"Enables repo-wide scanning for stale version literals.\",\n \"default\": \"false\"\n },\n {\n \"key\": \"ScanConfig.patterns\",\n \"type\": \"string[]\",\n \"description\": \"Regex patterns that match version-like strings in source files. Capture group 1 must contain the version string.\",\n \"default\": \"Patterns matching common version formats in code, CI, and Docker files.\"\n },\n {\n \"key\": \"ScanConfig.allowlist\",\n \"type\": \"ScanAllowlistEntry[]\",\n \"description\": \"Files containing intentional version references that should not be flagged.\",\n \"default\": \"[]\"\n },\n {\n \"key\": \"VersionGuardConfig.versioning\",\n \"type\": \"VersioningConfig\",\n \"description\": \"Active versioning settings.\"\n },\n {\n \"key\": \"VersionGuardConfig.manifest\",\n \"type\": \"ManifestConfig\",\n \"description\": \"Version source manifest settings.\",\n \"default\": \"`{ source: 'auto' }`\"\n },\n {\n \"key\": \"VersionGuardConfig.sync\",\n \"type\": \"SyncConfig\",\n \"description\": \"Synchronization settings for mirrored version strings.\"\n },\n {\n \"key\": \"VersionGuardConfig.changelog\",\n \"type\": \"ChangelogConfig\",\n \"description\": \"Changelog validation settings.\"\n },\n {\n \"key\": \"VersionGuardConfig.git\",\n \"type\": \"GitConfig\",\n \"description\": \"Git enforcement settings.\"\n },\n {\n \"key\": \"VersionGuardConfig.github\",\n \"type\": \"GitHubConfig\",\n \"description\": \"GitHub integration settings.\",\n \"default\": \"`{ dependabot: true }`\"\n },\n {\n \"key\": \"VersionGuardConfig.scan\",\n \"type\": \"ScanConfig\",\n \"description\": \"Repo-wide version literal scanning.\",\n \"default\": \"`{ enabled: false, patterns: [...], allowlist: [] }`\"\n },\n {\n \"key\": \"VersionGuardConfig.ignore\",\n \"type\": \"string[]\",\n \"description\": \"Files or patterns excluded from validation.\"\n },\n {\n \"key\": \"ChangelogStructureOptions.enforceStructure\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Validate section headers against an allowed list.\"\n },\n {\n \"key\": \"ChangelogStructureOptions.sections\",\n \"type\": \"string[] | undefined\",\n \"description\": \"Allowed section names. Defaults to Keep a Changelog standard sections.\"\n },\n {\n \"key\": \"CkmConfigEntry.key\",\n \"type\": \"string\",\n \"description\": \"Dotted key path (e.g., `'CalVerConfig.format'`).\"\n },\n {\n \"key\": \"CkmConfigEntry.type\",\n \"type\": \"string\",\n \"description\": \"TypeScript type.\"\n },\n {\n \"key\": \"CkmConfigEntry.description\",\n \"type\": \"string\",\n \"description\": \"Description from TSDoc.\"\n },\n {\n \"key\": \"CkmConfigEntry.default\",\n \"type\": \"string | undefined\",\n \"description\": \"Default value if specified via `@defaultValue`.\"\n },\n {\n \"key\": \"InitOptions.cwd\",\n \"type\": \"string\",\n \"description\": \"Working directory path.\"\n },\n {\n \"key\": \"InitOptions.type\",\n \"type\": \"\\\"semver\\\" | \\\"calver\\\" | undefined\",\n \"description\": \"Versioning type (semver or calver).\"\n },\n {\n \"key\": \"InitOptions.format\",\n \"type\": \"string | undefined\",\n \"description\": \"CalVer format string.\"\n },\n {\n \"key\": \"InitOptions.allowVPrefix\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Allow v-prefix on SemVer versions.\"\n },\n {\n \"key\": \"InitOptions.allowBuildMetadata\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Allow build metadata on SemVer versions.\"\n },\n {\n \"key\": \"InitOptions.requirePrerelease\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Require prerelease labels on SemVer versions.\"\n },\n {\n \"key\": \"InitOptions.manifest\",\n \"type\": \"string | undefined\",\n \"description\": \"Manifest source type.\"\n },\n {\n \"key\": \"InitOptions.github\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Whether to generate GitHub integration files (dependabot.yml).\"\n },\n {\n \"key\": \"InitOptions.hooks\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Whether to install git hooks.\"\n },\n {\n \"key\": \"InitOptions.changelog\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Whether to enable changelog validation.\"\n },\n {\n \"key\": \"InitOptions.yes\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Accept defaults without prompting.\"\n },\n {\n \"key\": \"InitOptions.force\",\n \"type\": \"boolean | undefined\",\n \"description\": \"Overwrite existing config.\"\n }\n ]\n}";
12
+ //#endregion
13
+ //#region docs/llms.txt?raw
14
+ var llms_default = "# @codluv/versionguard\n> Strict versioning enforcement for SemVer and CalVer — language-agnostic manifest support, git hooks, changelog validation, and file sync\n> Version: 0.8.1\n\n## Install\n\n```bash\nnpm install -D @codluv/versionguard\n```\n\n## Documentation\n\n- [API Reference](./api-reference.mdx): Full API documentation (MDX)\n- [Full Context](./llms-full.txt): Complete symbol documentation for deep LLM consumption\n\n## Packages\n\n### main\n93 functions, 56 types\n\n- getSemVerConfig() — Resolves the SemVer config from a VersionGuard config.\n- getCalVerConfig() — Extracts the CalVer config from a VersionGuard config, throwing if missing.\n- validateModifier() — Validates a pre-release / modifier tag against the allowed modifiers list.\n- isValidCalVerFormat() — Validates that a CalVer format string is composed of valid tokens and follows structural rules.\n- parseFormat() — Breaks a CalVer format string into its component tokens.\n- getRegexForFormat() — Builds a regular expression that matches a supported CalVer format.\n- parse() — Parses a CalVer string using the supplied format.\n- validate() — Validates a CalVer string against formatting and date rules.\n- format() — Formats a parsed CalVer object back into a version string.\n- getCurrentVersion() — Creates the current CalVer string for a format.\n- compare() — Compares two CalVer strings using a shared format.\n- increment() — Increments a CalVer string.\n- getNextVersions() — Returns the most likely next CalVer candidates.\n- validateChangelog() — Validates a changelog file for release readiness.\n- getLatestVersion() — Gets the most recent released version from a changelog.\n- addVersionEntry() — Inserts a new version entry beneath the `[Unreleased]` section.\n- isChangesetMangled() — Detects whether a changelog has been mangled by Changesets.\n- fixChangesetMangling() — Fixes a Changesets-mangled changelog into proper Keep a Changelog format.\n- createCkmEngine() — Creates a CKM engine from a parsed manifest.\n- parse() — Parses a semantic version string.\n- validate() — Validates that a string is a supported semantic version.\n- compare() — Compares two semantic version strings.\n- gt() — Checks whether one semantic version is greater than another.\n- lt() — Checks whether one semantic version is less than another.\n- eq() — Checks whether two semantic versions are equal in precedence.\n- increment() — Increments a semantic version string by release type.\n- format() — Formats a parsed semantic version object.\n- getVersionFeedback() — Generates actionable feedback for a version string.\n- getSyncFeedback() — Generates suggestions for version sync mismatches in a file.\n- getChangelogFeedback() — Generates suggestions for changelog-related validation issues.\n- getTagFeedback() — Generates suggestions for git tag mismatches.\n- getNestedValue() — Traverses a nested object using a dotted key path.\n- setNestedValue() — Sets a value at a dotted key path, throwing if intermediate segments are missing.\n- escapeRegExp() — Escapes special regex characters in a string for safe use in `new RegExp()`.\n- resolveVersionSource() — Resolves the version source provider for a project.\n- detectManifests() — Detects all manifest files present in a project directory.\n- getPackageJsonPath() — Gets the `package.json` path for a project directory.\n- readPackageJson() — Reads and parses a project's `package.json` file.\n- writePackageJson() — Writes a `package.json` document back to disk.\n- getPackageVersion() — Gets the version string from the project manifest. When a `manifest` config is provided, uses the configured version source provider (auto-detection or explicit). Falls back to `package.json` for backwards compatibility when no config is provided.\n- setPackageVersion() — Sets the version field in the project manifest. When a `manifest` config is provided, uses the configured version source provider. Falls back to `package.json` for backwards compatibility when no config is provided.\n- getVersionSource() — Resolves the version source provider for a project.\n- syncVersion() — Synchronizes configured files to a single version string.\n- syncFile() — Synchronizes a single file to a target version.\n- checkHardcodedVersions() — Checks configured files for hardcoded version mismatches.\n- scanRepoForVersions() — Scans the entire repository for hardcoded version literals.\n- fixPackageVersion() — Updates the `package.json` version field when needed.\n- fixSyncIssues() — Synchronizes configured files to the package version.\n- fixChangelog() — Ensures the changelog contains an entry for a version.\n- fixAll() — Runs all configured auto-fix operations.\n- suggestNextVersion() — Suggests candidate next versions for a release.\n- installHooks() — Installs VersionGuard-managed Git hooks in a repository.\n- uninstallHooks() — Removes VersionGuard-managed Git hooks from a repository.\n- findGitDir() — Finds the nearest `.git` directory by walking up from a starting directory.\n- areHooksInstalled() — Checks whether all VersionGuard-managed hooks are installed.\n- generateHookScript() — Generates the shell script content for a Git hook.\n- checkHooksPathOverride() — Checks whether git hooks have been redirected away from the repository.\n- checkHuskyBypass() — Checks whether the HUSKY environment variable is disabling hooks.\n- checkHookIntegrity() — Verifies that installed hook scripts match the expected content.\n- checkEnforceHooksPolicy() — Checks whether hooks are configured as required but not enforced.\n- runGuardChecks() — Runs all guard checks and returns a consolidated report.\n- generateDependabotConfig() — Generates Dependabot YAML configuration from detected manifests.\n- writeDependabotConfig() — Writes a Dependabot configuration file to `.github/dependabot.yml`.\n- dependabotConfigExists() — Checks whether `.github/dependabot.yml` exists in the project.\n- getDefaultConfig() — Returns a deep-cloned copy of the built-in VersionGuard configuration.\n- findConfig() — Finds the first supported VersionGuard config file in a directory.\n- loadConfig() — Loads a VersionGuard config file from disk.\n- getConfig() — Resolves the active VersionGuard configuration for a project.\n- initConfig() — Initializes a new VersionGuard config file in a project.\n- findProjectRoot() — Walks up from `startDir` to find the nearest project root.\n- formatNotProjectError() — Formats a helpful error message when a command can't find a project.\n- getLatestTag() — Returns the most recent reachable git tag for a repository.\n- getAllTags() — Lists all tags in a repository.\n- createTag() — Creates a release tag and optionally fixes version state first.\n- handlePostTag() — Runs post-tag validation and sync checks.\n- validateTagForPush() — Validates that a local tag is safe to push to the default remote.\n- suggestTagMessage() — Suggests an annotated tag message from changelog content.\n- validateVersion() — Validates a version string against the active versioning strategy.\n- validate() — Validates the current project state against the supplied configuration.\n- doctor() — Runs an extended readiness check for a project.\n- sync() — Synchronizes configured files to the current package version.\n- canBump() — Determines whether a project can move from one version to another.\n- runWizard() — Runs the interactive setup wizard.\n- runHeadless() — Initializes VersionGuard non-interactively using CLI flags.\n- createProgram() — Creates the VersionGuard CLI program definition.\n- runCli() — Parses CLI arguments and executes the matching command.\n- shouldRunCli() — Determines whether the current module is the invoked CLI entry point.\n- createTempProject() — Creates a temporary project directory with a minimal `package.json` fixture.\n- initGitRepo() — Initializes a git repository in a fixture directory with a first commit.\n- writeTextFile() — Writes a text fixture file relative to a temporary project directory.\n- createBareRemote() — Creates a bare git repository to use as a remote in integration tests.\n- addGitRemote() — Adds a local bare repository as the `origin` remote for a fixture repo.\n- commitAll() — Stages all changes and creates a commit in a fixture repository.\n\n- VersioningType — Supported versioning strategies.\n- ManifestSourceType — Supported manifest source types for version extraction.\n- ManifestConfig — Configures the version source manifest.\n- CalVerToken — Valid CalVer token names for building format strings.\n- CalVerFormat — A CalVer format string composed of dot-separated tokens.\n- SchemeRules — Configures scheme-level validation rules applied regardless of versioning type.\n- SemVerConfig — Configures SemVer validation rules.\n- CalVerConfig — Configures CalVer validation rules.\n- SyncPattern — Describes a search-and-replace pattern used during version synchronization.\n- SyncConfig — Configures files and patterns that should stay in sync with the canonical version.\n- ChangelogConfig — Controls changelog validation behavior.\n- GitHooksConfig — Toggles each supported git hook integration.\n- GitConfig — Configures git-related enforcement.\n- GitHubConfig — Configures GitHub-specific integration features.\n- VersioningConfig — Configures the active versioning mode.\n- ScanAllowlistEntry — An intentional version reference that should be excluded from scan results.\n- ScanConfig — Configures repo-wide scanning for hardcoded version literals.\n- VersionGuardConfig — Top-level configuration consumed by versionguard.\n- SemVer — Parsed semantic version components.\n- CalVer — Parsed calendar version components.\n- ParsedSemVer — Parsed semantic version result wrapper.\n- ParsedCalVer — Parsed calendar version result wrapper.\n- ParsedVersion — Union of supported parsed version payloads.\n- ValidationError — Describes a single validation problem.\n- ValidationResult — Result returned by version parsing and validation helpers.\n- SyncChange — Describes a single in-file version replacement.\n- SyncResult — Reports the result of synchronizing a single file.\n- VersionMismatch — Reports a discovered version mismatch.\n- FullValidationResult — Combined result from a full project validation run.\n- DoctorReport — Reports whether a project is ready to pass VersionGuard checks.\n- ParsedCalVerFormat — Parsed token layout for a supported CalVer format string.\n- ChangelogValidationResult — Describes the outcome of validating a changelog file.\n- ChangelogStructureOptions — Options for changelog structure enforcement.\n- CkmConcept — A domain concept extracted from an exported interface or type.\n- CkmProperty — A property within a concept.\n- CkmOperation — A user-facing operation extracted from an exported function.\n- CkmInput — A function parameter within an operation.\n- CkmConstraint — A constraint enforced by the tool.\n- CkmWorkflow — A multi-step workflow for a common goal.\n- CkmConfigEntry — A config schema entry with type, description, and default.\n- CkmManifest — The complete Codebase Knowledge Manifest.\n- CkmTopic — An auto-generated topic derived from CKM data.\n- CkmEngine — The CKM engine — provides topic derivation, filtering, and output formatting.\n- Suggestion — Feedback entry point exports for suggestion and guidance helpers.\n- FeedbackResult — Aggregates validation errors with suggested next steps.\n- VersionSourceProvider — Abstraction for reading and writing a version string from any manifest format.\n- PackageJsonValue — JSON-compatible scalar, array, or object value used by package metadata.\n- PackageJsonArray — Recursive array type used for arbitrary JSON-compatible package values.\n- PackageJsonObject — Recursive object type used for arbitrary JSON-compatible package values.\n- PackageJson — Minimal shape of a `package.json` document used by VersionGuard.\n- FixResult — Fix entry point exports for auto-remediation helpers.\n- GuardWarning — Describes a single guard finding.\n- GuardReport — Result of a full guard check pass.\n- ProjectRootResult — Result of project root detection.\n- TagInfo — Tag entry point exports for release-tag management helpers.\n- InitOptions — Options for headless (non-interactive) initialization.\n";
15
+ //#endregion
16
+ //#region src/init-wizard.ts
17
+ /**
18
+ * Interactive setup wizard and headless init for VersionGuard.
19
+ *
20
+ * @packageDocumentation
21
+ */
22
+ /**
23
+ * Runs the interactive setup wizard.
24
+ *
25
+ * @remarks
26
+ * Walks the user through versioning type, CalVer format, manifest source,
27
+ * git hooks, and changelog configuration. Writes `.versionguard.yml` when done.
28
+ *
29
+ * @param cwd - Project directory to initialize.
30
+ * @returns The path to the created config file, or `null` if cancelled.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const configPath = await runWizard(process.cwd());
35
+ * ```
36
+ *
37
+ * @public
38
+ * @since 0.3.0
39
+ */
12
40
  async function runWizard(cwd) {
13
- p.intro("VersionGuard Setup");
14
- const existingConfig = findExistingConfig(cwd);
15
- if (existingConfig) {
16
- p.log.warning(`Config already exists: ${path.relative(cwd, existingConfig)}`);
17
- const overwrite = await p.confirm({ message: "Overwrite existing config?" });
18
- if (p.isCancel(overwrite) || !overwrite) {
19
- p.outro("Setup cancelled.");
20
- return null;
21
- }
22
- }
23
- const type = await p.select({
24
- message: "Versioning strategy",
25
- options: [
26
- { value: "semver", label: "SemVer", hint: "MAJOR.MINOR.PATCH (e.g., 1.2.3)" },
27
- { value: "calver", label: "CalVer", hint: "Calendar-based (e.g., 2026.3.0)" }
28
- ]
29
- });
30
- if (p.isCancel(type)) {
31
- p.outro("Setup cancelled.");
32
- return null;
33
- }
34
- let format;
35
- let allowVPrefix = false;
36
- let allowBuildMetadata = true;
37
- let requirePrerelease = false;
38
- if (type === "calver") {
39
- const selected = await selectCalVerFormat();
40
- if (!selected) {
41
- p.outro("Setup cancelled.");
42
- return null;
43
- }
44
- format = selected;
45
- } else {
46
- const semverOptions = await selectSemVerOptions();
47
- if (!semverOptions) {
48
- p.outro("Setup cancelled.");
49
- return null;
50
- }
51
- allowVPrefix = semverOptions.allowVPrefix;
52
- allowBuildMetadata = semverOptions.allowBuildMetadata;
53
- requirePrerelease = semverOptions.requirePrerelease;
54
- }
55
- const manifest = await selectManifest(cwd);
56
- if (manifest === null) {
57
- p.outro("Setup cancelled.");
58
- return null;
59
- }
60
- const hooks = await p.confirm({
61
- message: "Install git hooks? (pre-commit, pre-push, post-tag)",
62
- initialValue: true
63
- });
64
- if (p.isCancel(hooks)) {
65
- p.outro("Setup cancelled.");
66
- return null;
67
- }
68
- const changelog = await p.confirm({
69
- message: "Enable changelog validation?",
70
- initialValue: true
71
- });
72
- if (p.isCancel(changelog)) {
73
- p.outro("Setup cancelled.");
74
- return null;
75
- }
76
- const config = buildConfig({
77
- type,
78
- format,
79
- allowVPrefix,
80
- allowBuildMetadata,
81
- requirePrerelease,
82
- manifest: manifest === "auto" ? void 0 : manifest,
83
- hooks,
84
- changelog
85
- });
86
- const configPath = writeConfig(cwd, config);
87
- p.log.success(`Created ${path.relative(cwd, configPath)}`);
88
- p.outro("Run `vg validate` to verify your setup.");
89
- return configPath;
41
+ p.intro("VersionGuard Setup");
42
+ const existingConfig = findExistingConfig(cwd);
43
+ if (existingConfig) {
44
+ p.log.warning(`Config already exists: ${path.relative(cwd, existingConfig)}`);
45
+ const overwrite = await p.confirm({ message: "Overwrite existing config?" });
46
+ if (p.isCancel(overwrite) || !overwrite) {
47
+ p.outro("Setup cancelled.");
48
+ return null;
49
+ }
50
+ }
51
+ const type = await p.select({
52
+ message: "Versioning strategy",
53
+ options: [{
54
+ value: "semver",
55
+ label: "SemVer",
56
+ hint: "MAJOR.MINOR.PATCH (e.g., 1.2.3)"
57
+ }, {
58
+ value: "calver",
59
+ label: "CalVer",
60
+ hint: "Calendar-based (e.g., 2026.3.0)"
61
+ }]
62
+ });
63
+ if (p.isCancel(type)) {
64
+ p.outro("Setup cancelled.");
65
+ return null;
66
+ }
67
+ let format;
68
+ let allowVPrefix = false;
69
+ let allowBuildMetadata = true;
70
+ let requirePrerelease = false;
71
+ if (type === "calver") {
72
+ const selected = await selectCalVerFormat();
73
+ if (!selected) {
74
+ p.outro("Setup cancelled.");
75
+ return null;
76
+ }
77
+ format = selected;
78
+ } else {
79
+ const semverOptions = await selectSemVerOptions();
80
+ if (!semverOptions) {
81
+ p.outro("Setup cancelled.");
82
+ return null;
83
+ }
84
+ allowVPrefix = semverOptions.allowVPrefix;
85
+ allowBuildMetadata = semverOptions.allowBuildMetadata;
86
+ requirePrerelease = semverOptions.requirePrerelease;
87
+ }
88
+ const manifest = await selectManifest(cwd);
89
+ if (manifest === null) {
90
+ p.outro("Setup cancelled.");
91
+ return null;
92
+ }
93
+ const hooks = await p.confirm({
94
+ message: "Install git hooks? (pre-commit, pre-push, post-tag)",
95
+ initialValue: true
96
+ });
97
+ if (p.isCancel(hooks)) {
98
+ p.outro("Setup cancelled.");
99
+ return null;
100
+ }
101
+ const changelog = await p.confirm({
102
+ message: "Enable changelog validation?",
103
+ initialValue: true
104
+ });
105
+ if (p.isCancel(changelog)) {
106
+ p.outro("Setup cancelled.");
107
+ return null;
108
+ }
109
+ const github = await p.confirm({
110
+ message: "Generate .github/dependabot.yml for automated dependency updates?",
111
+ initialValue: true
112
+ });
113
+ if (p.isCancel(github)) {
114
+ p.outro("Setup cancelled.");
115
+ return null;
116
+ }
117
+ const configPath = writeConfig(cwd, buildConfig({
118
+ type,
119
+ format,
120
+ allowVPrefix,
121
+ allowBuildMetadata,
122
+ requirePrerelease,
123
+ manifest: manifest === "auto" ? void 0 : manifest,
124
+ github,
125
+ hooks,
126
+ changelog
127
+ }));
128
+ if (github) {
129
+ const dependabotPath = writeDependabotConfig(cwd, generateDependabotConfig(detectManifests(cwd)));
130
+ p.log.success(`Created ${path.relative(cwd, dependabotPath)}`);
131
+ }
132
+ p.log.success(`Created ${path.relative(cwd, configPath)}`);
133
+ p.outro("Run `vg validate` to verify your setup.");
134
+ return configPath;
90
135
  }
136
+ /**
137
+ * Initializes VersionGuard non-interactively using CLI flags.
138
+ *
139
+ * @remarks
140
+ * When `--yes` is passed, all defaults are used without prompting.
141
+ * Individual flags override specific defaults.
142
+ *
143
+ * @param options - Headless initialization options.
144
+ * @returns The path to the created config file.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const configPath = runHeadless({ cwd: process.cwd(), type: 'calver', format: 'YYYY.M.MICRO' });
149
+ * ```
150
+ *
151
+ * @public
152
+ * @since 0.3.0
153
+ */
91
154
  function runHeadless(options) {
92
- const existingConfig = findExistingConfig(options.cwd);
93
- if (existingConfig && !options.force && !options.yes) {
94
- throw new Error(
95
- `Config already exists: ${existingConfig}. Use --force to overwrite or --yes to accept defaults.`
96
- );
97
- }
98
- const config = buildConfig({
99
- type: options.type ?? "semver",
100
- format: options.format,
101
- allowVPrefix: options.allowVPrefix ?? false,
102
- allowBuildMetadata: options.allowBuildMetadata ?? true,
103
- requirePrerelease: options.requirePrerelease ?? false,
104
- manifest: options.manifest,
105
- hooks: options.hooks ?? true,
106
- changelog: options.changelog ?? true
107
- });
108
- return writeConfig(options.cwd, config);
155
+ const existingConfig = findExistingConfig(options.cwd);
156
+ if (existingConfig && !options.force && !options.yes) throw new Error(`Config already exists: ${existingConfig}. Use --force to overwrite or --yes to accept defaults.`);
157
+ const config = buildConfig({
158
+ type: options.type ?? "semver",
159
+ format: options.format,
160
+ allowVPrefix: options.allowVPrefix ?? false,
161
+ allowBuildMetadata: options.allowBuildMetadata ?? true,
162
+ requirePrerelease: options.requirePrerelease ?? false,
163
+ manifest: options.manifest,
164
+ github: options.github ?? true,
165
+ hooks: options.hooks ?? true,
166
+ changelog: options.changelog ?? true
167
+ });
168
+ const configPath = writeConfig(options.cwd, config);
169
+ if (options.github !== false) {
170
+ const dependabotContent = generateDependabotConfig(detectManifests(options.cwd));
171
+ writeDependabotConfig(options.cwd, dependabotContent);
172
+ }
173
+ return configPath;
109
174
  }
110
175
  async function selectCalVerFormat() {
111
- const preset = await p.select({
112
- message: "CalVer format",
113
- options: [
114
- { value: "YYYY.M.MICRO", label: "YYYY.M.MICRO", hint: "calver.org standard — 2026.3.0" },
115
- { value: "YYYY.MM.MICRO", label: "YYYY.MM.MICRO", hint: "padded month — 2026.03.0" },
116
- { value: "YY.0M.MICRO", label: "YY.0M.MICRO", hint: "Twisted/pip style — 26.03.0" },
117
- { value: "YYYY.0M.0D", label: "YYYY.0M.0D", hint: "date-based — 2026.03.25" },
118
- {
119
- value: "YYYY.0M.0D.MICRO",
120
- label: "YYYY.0M.0D.MICRO",
121
- hint: "youtube-dl style — 2026.03.25.0"
122
- },
123
- { value: "YY.0M", label: "YY.0M", hint: "Ubuntu style — 26.03" },
124
- { value: "custom", label: "Custom...", hint: "enter your own token format" }
125
- ]
126
- });
127
- if (p.isCancel(preset)) return null;
128
- if (preset === "custom") {
129
- const custom = await p.text({
130
- message: "Enter CalVer format (dot-separated tokens)",
131
- placeholder: "YYYY.MM.MICRO",
132
- validate(value) {
133
- if (!value || !isValidCalVerFormat(value)) {
134
- return "Invalid format. Use tokens: YYYY|YY|0Y, MM|M|0M, WW|0W, DD|D|0D, MICRO|PATCH";
135
- }
136
- }
137
- });
138
- if (p.isCancel(custom)) return null;
139
- return custom;
140
- }
141
- return preset;
176
+ const preset = await p.select({
177
+ message: "CalVer format",
178
+ options: [
179
+ {
180
+ value: "YYYY.M.MICRO",
181
+ label: "YYYY.M.MICRO",
182
+ hint: "calver.org standard — 2026.3.0"
183
+ },
184
+ {
185
+ value: "YYYY.MM.MICRO",
186
+ label: "YYYY.MM.MICRO",
187
+ hint: "padded month — 2026.03.0"
188
+ },
189
+ {
190
+ value: "YY.0M.MICRO",
191
+ label: "YY.0M.MICRO",
192
+ hint: "Twisted/pip style — 26.03.0"
193
+ },
194
+ {
195
+ value: "YYYY.0M.0D",
196
+ label: "YYYY.0M.0D",
197
+ hint: "date-based — 2026.03.25"
198
+ },
199
+ {
200
+ value: "YYYY.0M.0D.MICRO",
201
+ label: "YYYY.0M.0D.MICRO",
202
+ hint: "youtube-dl style — 2026.03.25.0"
203
+ },
204
+ {
205
+ value: "YY.0M",
206
+ label: "YY.0M",
207
+ hint: "Ubuntu style — 26.03"
208
+ },
209
+ {
210
+ value: "custom",
211
+ label: "Custom...",
212
+ hint: "enter your own token format"
213
+ }
214
+ ]
215
+ });
216
+ if (p.isCancel(preset)) return null;
217
+ if (preset === "custom") {
218
+ const custom = await p.text({
219
+ message: "Enter CalVer format (dot-separated tokens)",
220
+ placeholder: "YYYY.MM.MICRO",
221
+ validate(value) {
222
+ if (!value || !isValidCalVerFormat(value)) return "Invalid format. Use tokens: YYYY|YY|0Y, MM|M|0M, WW|0W, DD|D|0D, MICRO|PATCH";
223
+ }
224
+ });
225
+ if (p.isCancel(custom)) return null;
226
+ return custom;
227
+ }
228
+ return preset;
142
229
  }
143
230
  async function selectSemVerOptions() {
144
- const customize = await p.confirm({
145
- message: "Customize SemVer rules? (defaults work for most projects)",
146
- initialValue: false
147
- });
148
- if (p.isCancel(customize)) return null;
149
- if (!customize) {
150
- return { allowVPrefix: false, allowBuildMetadata: true, requirePrerelease: false };
151
- }
152
- const allowVPrefix = await p.confirm({
153
- message: "Allow v-prefix? (e.g., v1.2.3)",
154
- initialValue: false
155
- });
156
- if (p.isCancel(allowVPrefix)) return null;
157
- const allowBuildMetadata = await p.confirm({
158
- message: "Allow build metadata? (e.g., 1.2.3+build.123)",
159
- initialValue: true
160
- });
161
- if (p.isCancel(allowBuildMetadata)) return null;
162
- const requirePrerelease = await p.confirm({
163
- message: "Require prerelease labels? (e.g., 1.2.3-alpha.1)",
164
- initialValue: false
165
- });
166
- if (p.isCancel(requirePrerelease)) return null;
167
- return { allowVPrefix, allowBuildMetadata, requirePrerelease };
231
+ const customize = await p.confirm({
232
+ message: "Customize SemVer rules? (defaults work for most projects)",
233
+ initialValue: false
234
+ });
235
+ if (p.isCancel(customize)) return null;
236
+ if (!customize) return {
237
+ allowVPrefix: false,
238
+ allowBuildMetadata: true,
239
+ requirePrerelease: false
240
+ };
241
+ const allowVPrefix = await p.confirm({
242
+ message: "Allow v-prefix? (e.g., v1.2.3)",
243
+ initialValue: false
244
+ });
245
+ if (p.isCancel(allowVPrefix)) return null;
246
+ const allowBuildMetadata = await p.confirm({
247
+ message: "Allow build metadata? (e.g., 1.2.3+build.123)",
248
+ initialValue: true
249
+ });
250
+ if (p.isCancel(allowBuildMetadata)) return null;
251
+ const requirePrerelease = await p.confirm({
252
+ message: "Require prerelease labels? (e.g., 1.2.3-alpha.1)",
253
+ initialValue: false
254
+ });
255
+ if (p.isCancel(requirePrerelease)) return null;
256
+ return {
257
+ allowVPrefix,
258
+ allowBuildMetadata,
259
+ requirePrerelease
260
+ };
168
261
  }
169
262
  async function selectManifest(cwd) {
170
- const detected = [];
171
- const checks = [
172
- { file: "package.json", label: "package.json", hint: "Node.js / Bun" },
173
- { file: "Cargo.toml", label: "Cargo.toml", hint: "Rust" },
174
- { file: "pyproject.toml", label: "pyproject.toml", hint: "Python" },
175
- { file: "pubspec.yaml", label: "pubspec.yaml", hint: "Dart / Flutter" },
176
- { file: "composer.json", label: "composer.json", hint: "PHP" },
177
- { file: "pom.xml", label: "pom.xml", hint: "Java / Maven" },
178
- { file: "VERSION", label: "VERSION", hint: "Plain text file" }
179
- ];
180
- for (const check of checks) {
181
- if (fs.existsSync(path.join(cwd, check.file))) {
182
- detected.push({ value: check.file, label: `${check.label} (detected)`, hint: check.hint });
183
- }
184
- }
185
- const options = [
186
- { value: "auto", label: "Auto-detect", hint: "scan for known manifests at runtime" },
187
- ...detected,
188
- ...checks.filter((c) => !detected.some((d) => d.value === c.file)).map((c) => ({ value: c.file, label: c.label, hint: c.hint })),
189
- { value: "git-tag", label: "Git tags", hint: "Go / Swift — version from tags" }
190
- ];
191
- const result = await p.select({
192
- message: "Version source",
193
- options,
194
- initialValue: detected.length === 1 ? detected[0].value : "auto"
195
- });
196
- if (p.isCancel(result)) return null;
197
- return result;
263
+ const detected = [];
264
+ const checks = [
265
+ {
266
+ file: "package.json",
267
+ label: "package.json",
268
+ hint: "Node.js / Bun"
269
+ },
270
+ {
271
+ file: "Cargo.toml",
272
+ label: "Cargo.toml",
273
+ hint: "Rust"
274
+ },
275
+ {
276
+ file: "pyproject.toml",
277
+ label: "pyproject.toml",
278
+ hint: "Python"
279
+ },
280
+ {
281
+ file: "pubspec.yaml",
282
+ label: "pubspec.yaml",
283
+ hint: "Dart / Flutter"
284
+ },
285
+ {
286
+ file: "composer.json",
287
+ label: "composer.json",
288
+ hint: "PHP"
289
+ },
290
+ {
291
+ file: "pom.xml",
292
+ label: "pom.xml",
293
+ hint: "Java / Maven"
294
+ },
295
+ {
296
+ file: "VERSION",
297
+ label: "VERSION",
298
+ hint: "Plain text file"
299
+ }
300
+ ];
301
+ for (const check of checks) if (fs.existsSync(path.join(cwd, check.file))) detected.push({
302
+ value: check.file,
303
+ label: `${check.label} (detected)`,
304
+ hint: check.hint
305
+ });
306
+ const options = [
307
+ {
308
+ value: "auto",
309
+ label: "Auto-detect",
310
+ hint: "scan for known manifests at runtime"
311
+ },
312
+ ...detected,
313
+ ...checks.filter((c) => !detected.some((d) => d.value === c.file)).map((c) => ({
314
+ value: c.file,
315
+ label: c.label,
316
+ hint: c.hint
317
+ })),
318
+ {
319
+ value: "git-tag",
320
+ label: "Git tags",
321
+ hint: "Go / Swift — version from tags"
322
+ }
323
+ ];
324
+ const result = await p.select({
325
+ message: "Version source",
326
+ options,
327
+ initialValue: detected.length === 1 ? detected[0].value : "auto"
328
+ });
329
+ if (p.isCancel(result)) return null;
330
+ return result;
198
331
  }
199
332
  function buildConfig(input) {
200
- const versioning = {
201
- type: input.type,
202
- semver: {
203
- allowVPrefix: input.allowVPrefix,
204
- allowBuildMetadata: input.allowBuildMetadata,
205
- requirePrerelease: input.requirePrerelease
206
- },
207
- calver: {
208
- format: input.format ?? "YYYY.MM.PATCH",
209
- preventFutureDates: true
210
- }
211
- };
212
- const config = { versioning };
213
- if (input.manifest) {
214
- config.manifest = { source: input.manifest };
215
- }
216
- config.sync = {
217
- files: ["README.md", "CHANGELOG.md"],
218
- patterns: [
219
- {
220
- regex: `(version\\s*[=:]\\s*["'])(.+?)(["'])`,
221
- template: "$1{{version}}$3"
222
- },
223
- {
224
- regex: "(##\\s*\\[)(.+?)(\\])",
225
- template: "$1{{version}}$3"
226
- }
227
- ]
228
- };
229
- config.changelog = {
230
- enabled: input.changelog,
231
- file: "CHANGELOG.md",
232
- strict: true,
233
- requireEntry: input.changelog
234
- };
235
- config.git = {
236
- hooks: {
237
- "pre-commit": input.hooks,
238
- "pre-push": input.hooks,
239
- "post-tag": input.hooks
240
- },
241
- enforceHooks: input.hooks
242
- };
243
- config.ignore = ["node_modules/**", "dist/**", ".git/**", "*.lock", ".changeset/**"];
244
- return config;
333
+ const config = { versioning: {
334
+ type: input.type,
335
+ semver: {
336
+ allowVPrefix: input.allowVPrefix,
337
+ allowBuildMetadata: input.allowBuildMetadata,
338
+ requirePrerelease: input.requirePrerelease
339
+ },
340
+ calver: {
341
+ format: input.format ?? "YYYY.MM.PATCH",
342
+ preventFutureDates: true
343
+ }
344
+ } };
345
+ if (input.manifest) config.manifest = { source: input.manifest };
346
+ config.sync = {
347
+ files: ["README.md", "CHANGELOG.md"],
348
+ patterns: [{
349
+ regex: "(version\\s*[=:]\\s*[\"'])(.+?)([\"'])",
350
+ template: "$1{{version}}$3"
351
+ }, {
352
+ regex: "(##\\s*\\[)(.+?)(\\])",
353
+ template: "$1{{version}}$3"
354
+ }]
355
+ };
356
+ config.changelog = {
357
+ enabled: input.changelog,
358
+ file: "CHANGELOG.md",
359
+ strict: true,
360
+ requireEntry: input.changelog
361
+ };
362
+ config.github = { dependabot: input.github };
363
+ config.git = {
364
+ hooks: {
365
+ "pre-commit": input.hooks,
366
+ "pre-push": input.hooks,
367
+ "post-tag": input.hooks
368
+ },
369
+ enforceHooks: input.hooks
370
+ };
371
+ config.ignore = [
372
+ "node_modules/**",
373
+ "dist/**",
374
+ ".git/**",
375
+ "*.lock",
376
+ ".changeset/**"
377
+ ];
378
+ return config;
245
379
  }
246
380
  function writeConfig(cwd, config) {
247
- const configPath = path.join(cwd, ".versionguard.yml");
248
- const content = yaml.dump(config, {
249
- indent: 2,
250
- lineWidth: 120,
251
- noRefs: true,
252
- quotingType: '"',
253
- forceQuotes: false
254
- });
255
- fs.writeFileSync(configPath, content, "utf-8");
256
- return configPath;
381
+ const configPath = path.join(cwd, ".versionguard.yml");
382
+ const content = yaml.dump(config, {
383
+ indent: 2,
384
+ lineWidth: 120,
385
+ noRefs: true,
386
+ quotingType: "\"",
387
+ forceQuotes: false
388
+ });
389
+ fs.writeFileSync(configPath, content, "utf-8");
390
+ return configPath;
257
391
  }
258
392
  function findExistingConfig(cwd) {
259
- for (const name of [
260
- ".versionguard.yml",
261
- ".versionguard.yaml",
262
- "versionguard.yml",
263
- "versionguard.yaml"
264
- ]) {
265
- const full = path.join(cwd, name);
266
- if (fs.existsSync(full)) return full;
267
- }
268
- return null;
393
+ for (const name of [
394
+ ".versionguard.yml",
395
+ ".versionguard.yaml",
396
+ "versionguard.yml",
397
+ "versionguard.yaml"
398
+ ]) {
399
+ const full = path.join(cwd, name);
400
+ if (fs.existsSync(full)) return full;
401
+ }
402
+ return null;
269
403
  }
270
- const CLI_DIR = path.dirname(fileURLToPath(import.meta.url));
271
- const CLI_VERSION = JSON.parse(fs.readFileSync(path.join(CLI_DIR, "..", "package.json"), "utf-8")).version;
272
- const ckmEngine = createCkmEngine(JSON.parse(ckmRaw));
273
- const styles = {
274
- error: chalk.red,
275
- warning: chalk.yellow,
276
- success: chalk.green,
277
- info: chalk.blue,
278
- dim: chalk.gray,
279
- bold: chalk.bold
404
+ //#endregion
405
+ //#region src/cli.ts
406
+ var CLI_DIR = path.dirname(fileURLToPath(import.meta.url));
407
+ var CLI_VERSION = JSON.parse(fs.readFileSync(path.join(CLI_DIR, "..", "package.json"), "utf-8")).version;
408
+ var ckmEngine = createCkmEngine(JSON.parse(ckm_default));
409
+ var styles = {
410
+ error: chalk.red,
411
+ warning: chalk.yellow,
412
+ success: chalk.green,
413
+ info: chalk.blue,
414
+ dim: chalk.gray,
415
+ bold: chalk.bold
280
416
  };
417
+ /**
418
+ * Resolves the effective project root, checking for project markers.
419
+ * Exits with helpful guidance if not in a project directory.
420
+ */
281
421
  function requireProject(cwd, command) {
282
- const result = findProjectRoot(cwd);
283
- if (!result.found) {
284
- console.error(styles.error(formatNotProjectError(cwd, command)));
285
- process.exit(1);
286
- }
287
- return result.root;
422
+ const result = findProjectRoot(cwd);
423
+ if (!result.found) {
424
+ console.error(styles.error(formatNotProjectError(cwd, command)));
425
+ process.exit(1);
426
+ }
427
+ return result.root;
288
428
  }
429
+ /**
430
+ * Creates the VersionGuard CLI program definition.
431
+ *
432
+ * @public
433
+ * @since 0.1.0
434
+ * @remarks
435
+ * This function wires all commands, options, and handlers onto a fresh Commander
436
+ * program instance without parsing arguments yet.
437
+ *
438
+ * @returns A configured Commander program for the VersionGuard CLI.
439
+ *
440
+ * @example
441
+ * ```typescript
442
+ * const program = createProgram();
443
+ * console.log(program.name());
444
+ * ```
445
+ */
289
446
  function createProgram() {
290
- const program = new Command();
291
- program.name("vg").description("Strict versioning enforcement for SemVer and CalVer (alias: versionguard)").version(CLI_VERSION);
292
- program.command("init").description("Initialize VersionGuard configuration (interactive wizard or headless)").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-t, --type <type>", "Versioning type: semver or calver").option("-f, --format <format>", "CalVer format tokens (e.g., YYYY.M.MICRO)").option("--allow-v-prefix", "SemVer: allow v-prefix (e.g., v1.2.3)").option("--no-build-metadata", "SemVer: disallow +build metadata").option("--require-prerelease", "SemVer: require prerelease labels").option("--manifest <source>", "Manifest source (e.g., Cargo.toml, pyproject.toml, auto)").option("--hooks", "Install git hooks (default: true)").option("--no-hooks", "Skip git hooks").option("--changelog", "Enable changelog validation (default: true)").option("--no-changelog", "Disable changelog validation").option("-y, --yes", "Accept all defaults, no prompts").option("--force", "Overwrite existing config file").action(
293
- async (options) => {
294
- try {
295
- const isHeadless = options.yes || options.type || options.format || options.manifest || options.allowVPrefix || options.buildMetadata === false || options.requirePrerelease;
296
- let configPath;
297
- if (isHeadless) {
298
- configPath = runHeadless({
299
- cwd: options.cwd,
300
- type: options.type,
301
- format: options.format,
302
- allowVPrefix: options.allowVPrefix,
303
- allowBuildMetadata: options.buildMetadata,
304
- requirePrerelease: options.requirePrerelease,
305
- manifest: options.manifest,
306
- hooks: options.hooks,
307
- changelog: options.changelog,
308
- yes: options.yes,
309
- force: options.force
310
- });
311
- console.log(styles.success(`✓ Created ${path.relative(options.cwd, configPath)}`));
312
- } else {
313
- configPath = await runWizard(options.cwd);
314
- if (!configPath) {
315
- process.exit(0);
316
- return;
317
- }
318
- }
319
- try {
320
- const config = getConfig(options.cwd);
321
- if (config.git.enforceHooks) {
322
- installHooks(config.git, options.cwd);
323
- console.log(styles.success("✓ Git hooks installed"));
324
- }
325
- } catch {
326
- console.log(styles.info("ℹ Skipped hooks install (not a git repository)"));
327
- }
328
- } catch (error) {
329
- console.error(styles.error(`✗ ${error.message}`));
330
- process.exit(1);
331
- }
332
- }
333
- );
334
- program.command("check").description("Check the current version with actionable feedback").option("-c, --cwd <path>", "Working directory", process.cwd()).option("--prev <version>", "Previous version for comparison").option("--json", "Print machine-readable JSON output").action((options) => {
335
- try {
336
- options.cwd = requireProject(options.cwd, "check");
337
- const config = getConfig(options.cwd);
338
- const version = getPackageVersion(options.cwd, config.manifest);
339
- const result = getVersionFeedback(version, config, options.prev);
340
- if (options.json) {
341
- console.log(
342
- JSON.stringify(
343
- {
344
- version,
345
- versioningType: config.versioning.type,
346
- valid: result.valid,
347
- errors: result.errors,
348
- suggestions: result.suggestions
349
- },
350
- null,
351
- 2
352
- )
353
- );
354
- if (!result.valid) {
355
- process.exit(1);
356
- }
357
- return;
358
- }
359
- console.log(styles.bold(`Current version: ${version}`));
360
- console.log(styles.dim(`Versioning type: ${config.versioning.type}`));
361
- console.log("");
362
- if (result.valid) {
363
- console.log(styles.success("✓ Version is valid"));
364
- return;
365
- }
366
- console.log(styles.error("✗ Version has issues:"));
367
- console.log("");
368
- for (const error of result.errors) {
369
- console.log(styles.error(` ✗ ${error.message}`));
370
- }
371
- if (result.suggestions.length > 0) {
372
- console.log("");
373
- console.log(styles.info("How to fix:"));
374
- for (const suggestion of result.suggestions) {
375
- console.log(` → ${suggestion.message}`);
376
- if (suggestion.fix) {
377
- console.log(styles.dim(` Run: ${suggestion.fix}`));
378
- }
379
- }
380
- }
381
- process.exit(1);
382
- } catch (error) {
383
- console.error(styles.error(`✗ ${error.message}`));
384
- process.exit(1);
385
- }
386
- });
387
- program.command("validate").description("Run full validation with smart feedback").option("-c, --cwd <path>", "Working directory", process.cwd()).option("--hook <name>", "Running as git hook").option("--json", "Print machine-readable JSON output").option("--strict", "Run guard checks and fail on any policy gap or bypass").option("--scan", "Run repo-wide scan for stale version literals").action(
388
- (options) => {
389
- try {
390
- options.cwd = requireProject(options.cwd, "validate");
391
- const config = getConfig(options.cwd);
392
- if (options.scan && config.scan) {
393
- config.scan.enabled = true;
394
- }
395
- const version = getPackageVersion(options.cwd, config.manifest);
396
- const result = validate(config, options.cwd);
397
- let postTagResult;
398
- let guardReport;
399
- if (options.hook === "post-tag") {
400
- postTagResult = handlePostTag(config, options.cwd);
401
- }
402
- if (options.strict) {
403
- guardReport = runGuardChecks(config, options.cwd);
404
- }
405
- if (options.json) {
406
- console.log(
407
- JSON.stringify(
408
- {
409
- ...result,
410
- hook: options.hook ?? null,
411
- postTag: postTagResult ?? null,
412
- guard: guardReport ?? null
413
- },
414
- null,
415
- 2
416
- )
417
- );
418
- if (!result.valid || postTagResult && !postTagResult.success || guardReport && !guardReport.safe) {
419
- process.exit(1);
420
- }
421
- return;
422
- }
423
- console.log(styles.bold(`Validating version ${version}...`));
424
- console.log("");
425
- if (!result.syncValid) {
426
- console.log(styles.error("Sync Issues:"));
427
- for (const error of result.errors.filter((item) => item.includes("mismatch"))) {
428
- const parts = error.match(
429
- /Version mismatch in (.+):(\d+) - found "(.+?)" but expected "(.+?)"/
430
- );
431
- if (!parts) {
432
- continue;
433
- }
434
- const suggestions = getSyncFeedback(parts[1], parts[3], parts[4]);
435
- console.log(styles.error(` ${parts[1]} has wrong version`));
436
- console.log(styles.dim(` Found: "${parts[3]}" Expected: "${parts[4]}"`));
437
- if (suggestions[0]?.fix) {
438
- console.log(styles.info(` Fix: ${suggestions[0].fix}`));
439
- }
440
- }
441
- console.log("");
442
- }
443
- const scanErrors = result.errors.filter((item) => item.startsWith("Stale version"));
444
- if (scanErrors.length > 0) {
445
- console.log(styles.error("Scan Findings:"));
446
- for (const error of scanErrors) {
447
- const parts = error.match(
448
- /Stale version in (.+):(\d+) - found "(.+?)" but expected "(.+?)"/
449
- );
450
- if (parts) {
451
- console.log(styles.error(` ✗ ${parts[1]}:${parts[2]} has "${parts[3]}"`));
452
- }
453
- }
454
- console.log(
455
- styles.dim(" Hint: add entries to scan.allowlist to exclude intentional references")
456
- );
457
- console.log("");
458
- }
459
- if (config.changelog.enabled && !result.changelogValid) {
460
- console.log(styles.error("Changelog Issues:"));
461
- for (const error of result.errors.filter(
462
- (item) => item.toLowerCase().includes("changelog")
463
- )) {
464
- console.log(styles.error(` ✗ ${error}`));
465
- }
466
- const suggestions = getChangelogFeedback(false, version);
467
- if (suggestions[0]?.fix) {
468
- console.log(styles.info(`Fix: ${suggestions[0].fix}`));
469
- }
470
- console.log("");
471
- }
472
- if (postTagResult) {
473
- if (!postTagResult.success) {
474
- console.log(styles.error(`✗ ${postTagResult.message}`));
475
- process.exit(1);
476
- }
477
- }
478
- if (guardReport && guardReport.warnings.length > 0) {
479
- console.log(styles.bold("Guard Checks:"));
480
- for (const warning of guardReport.warnings) {
481
- const icon = warning.severity === "error" ? styles.error("✗") : styles.warning("⚠");
482
- console.log(` ${icon} [${warning.code}] ${warning.message}`);
483
- if (warning.fix) {
484
- console.log(styles.dim(` Fix: ${warning.fix}`));
485
- }
486
- }
487
- console.log("");
488
- }
489
- if (!result.valid || guardReport && !guardReport.safe) {
490
- console.log(styles.error("✗ Validation failed"));
491
- process.exit(1);
492
- }
493
- console.log(styles.success("✓ All validations passed"));
494
- } catch (error) {
495
- console.error(styles.error(`✗ ${error.message}`));
496
- process.exit(1);
497
- }
498
- }
499
- );
500
- program.command("doctor").description("Report repository readiness in one pass").option("-c, --cwd <path>", "Working directory", process.cwd()).option("--json", "Print machine-readable JSON output").option("--strict", "Include guard checks for bypass detection").action((options) => {
501
- try {
502
- options.cwd = requireProject(options.cwd, "doctor");
503
- const config = getConfig(options.cwd);
504
- const report = doctor(config, options.cwd);
505
- const guardReport = options.strict ? runGuardChecks(config, options.cwd) : void 0;
506
- if (options.json) {
507
- console.log(JSON.stringify({ ...report, guard: guardReport ?? null }, null, 2));
508
- if (!report.ready || guardReport && !guardReport.safe) {
509
- process.exit(1);
510
- }
511
- return;
512
- }
513
- console.log(styles.bold("VersionGuard Doctor"));
514
- console.log(` Version: ${report.version || "(missing)"}`);
515
- console.log(` Version valid: ${report.versionValid ? "yes" : "no"}`);
516
- console.log(` Files in sync: ${report.syncValid ? "yes" : "no"}`);
517
- console.log(` Changelog ready: ${report.changelogValid ? "yes" : "no"}`);
518
- console.log(` Git repository: ${report.gitRepository ? "yes" : "no"}`);
519
- console.log(
520
- ` Hooks installed: ${report.gitRepository ? report.hooksInstalled ? "yes" : "no" : "n/a"}`
521
- );
522
- console.log(
523
- ` Worktree clean: ${report.gitRepository ? report.worktreeClean ? "yes" : "no" : "n/a"}`
524
- );
525
- if (guardReport) {
526
- console.log(` Guard safe: ${guardReport.safe ? "yes" : "no"}`);
527
- }
528
- if (!report.ready || guardReport && !guardReport.safe) {
529
- console.log("");
530
- console.log(styles.error("Issues:"));
531
- for (const error of report.errors) {
532
- console.log(styles.error(` ✗ ${error}`));
533
- }
534
- if (guardReport) {
535
- for (const warning of guardReport.warnings) {
536
- const icon = warning.severity === "error" ? "✗" : "⚠";
537
- console.log(styles.error(` ${icon} [${warning.code}] ${warning.message}`));
538
- if (warning.fix) {
539
- console.log(styles.dim(` Fix: ${warning.fix}`));
540
- }
541
- }
542
- }
543
- process.exit(1);
544
- }
545
- console.log("");
546
- console.log(styles.success("✓ Repository is ready"));
547
- } catch (error) {
548
- console.error(styles.error(`✗ ${error.message}`));
549
- process.exit(1);
550
- }
551
- });
552
- program.command("fix").description("Auto-fix detected issues").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
553
- try {
554
- options.cwd = requireProject(options.cwd, "fix");
555
- const config = getConfig(options.cwd);
556
- const version = getPackageVersion(options.cwd, config.manifest);
557
- const results = fixAll(config, version, options.cwd);
558
- console.log(styles.bold(`Fixing issues for version ${version}...`));
559
- console.log("");
560
- for (const result of results) {
561
- const printer = result.fixed ? styles.success : styles.dim;
562
- console.log(printer(`${result.fixed ? "✓" : "•"} ${result.message}`));
563
- }
564
- } catch (error) {
565
- console.error(styles.error(`✗ ${error.message}`));
566
- process.exit(1);
567
- }
568
- });
569
- program.command("fix-changelog").description("Fix Changesets-mangled changelog into Keep a Changelog format").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
570
- try {
571
- options.cwd = requireProject(options.cwd, "fix-changelog");
572
- const config = getConfig(options.cwd);
573
- const changelogPath = path.join(options.cwd, config.changelog.file);
574
- if (!isChangesetMangled(changelogPath)) {
575
- console.log(styles.dim("Changelog is not mangled — no fix needed"));
576
- return;
577
- }
578
- const fixed = fixChangesetMangling(changelogPath);
579
- if (fixed) {
580
- console.log(
581
- styles.success(`✓ Restructured ${config.changelog.file} to Keep a Changelog format`)
582
- );
583
- } else {
584
- console.log(styles.dim("• Could not auto-fix changelog structure"));
585
- }
586
- } catch (error) {
587
- console.error(styles.error(`✗ ${error.message}`));
588
- process.exit(1);
589
- }
590
- });
591
- program.command("sync").description("Sync version to all configured files").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
592
- try {
593
- options.cwd = requireProject(options.cwd, "sync");
594
- const config = getConfig(options.cwd);
595
- const version = getPackageVersion(options.cwd, config.manifest);
596
- const results = fixSyncIssues(config, options.cwd);
597
- console.log(styles.bold(`Syncing version ${version}...`));
598
- for (const result of results) {
599
- const printer = result.fixed ? styles.success : styles.dim;
600
- console.log(printer(`${result.fixed ? "✓" : "•"} ${result.message}`));
601
- }
602
- } catch (error) {
603
- console.error(styles.error(`✗ ${error.message}`));
604
- process.exit(1);
605
- }
606
- });
607
- program.command("bump").description("Suggest and optionally apply the next version").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-t, --type <type>", "Bump type (major, minor, patch, auto)").option("--apply", "Apply the first suggested version").action(
608
- (options) => {
609
- try {
610
- options.cwd = requireProject(options.cwd, "bump");
611
- const config = getConfig(options.cwd);
612
- const currentVersion = getPackageVersion(options.cwd, config.manifest);
613
- const suggestions = suggestNextVersion(currentVersion, config, options.type);
614
- console.log(styles.bold(`Current version: ${currentVersion}`));
615
- console.log("");
616
- for (const [index, suggestion] of suggestions.entries()) {
617
- console.log(` ${index + 1}. ${styles.bold(suggestion.version)}`);
618
- console.log(` ${styles.dim(suggestion.reason)}`);
619
- }
620
- if (options.apply) {
621
- const nextVersion = suggestions[0]?.version;
622
- if (!nextVersion) {
623
- throw new Error("No version suggestion available");
624
- }
625
- setPackageVersion(nextVersion, options.cwd, config.manifest);
626
- fixAll(config, nextVersion, options.cwd);
627
- console.log(styles.success(`✓ Updated to ${nextVersion}`));
628
- }
629
- } catch (error) {
630
- console.error(styles.error(`✗ ${error.message}`));
631
- process.exit(1);
632
- }
633
- }
634
- );
635
- program.command("tag").description("Create a git tag with automation").argument("[version]", "Version to tag (defaults to manifest version)").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-m, --message <msg>", "Tag message").option("--no-fix", "Skip auto-fixing files before tagging").action(
636
- (version, options) => {
637
- try {
638
- options.cwd = requireProject(options.cwd, "tag");
639
- const config = getConfig(options.cwd);
640
- const tagVersion = version || getPackageVersion(options.cwd, config.manifest);
641
- const result = createTag(
642
- tagVersion,
643
- options.message,
644
- options.fix !== false,
645
- config,
646
- options.cwd
647
- );
648
- if (!result.success) {
649
- console.log(styles.error(`✗ ${result.message}`));
650
- process.exit(1);
651
- }
652
- console.log(styles.success(`✓ ${result.message}`));
653
- for (const action of result.actions) {
654
- console.log(` • ${action}`);
655
- }
656
- } catch (error) {
657
- console.error(styles.error(`✗ ${error.message}`));
658
- process.exit(1);
659
- }
660
- }
661
- );
662
- program.command("ckm [topic]").description("Codebase Knowledge Manifest — auto-generated docs and help").option("--json", "Machine-readable CKM output for LLM agents").option("--llm", "Full API context (forge-ts llms.txt)").action((topic, options) => {
663
- if (options.llm) {
664
- console.log(llmsRaw);
665
- return;
666
- }
667
- if (options.json) {
668
- console.log(JSON.stringify(ckmEngine.getTopicJson(topic), null, 2));
669
- return;
670
- }
671
- if (topic) {
672
- const content = ckmEngine.getTopicContent(topic);
673
- if (!content) {
674
- console.error(styles.error(`Unknown topic: ${topic}`));
675
- console.log("");
676
- console.log(ckmEngine.getTopicIndex("vg"));
677
- process.exit(1);
678
- }
679
- console.log(content);
680
- } else {
681
- console.log(ckmEngine.getTopicIndex("vg"));
682
- }
683
- });
684
- const hooksCommand = program.command("hooks").description("Manage git hooks");
685
- hooksCommand.command("install").description("Install git hooks").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
686
- try {
687
- options.cwd = requireProject(options.cwd, "hooks install");
688
- const config = getConfig(options.cwd);
689
- installHooks(config.git, options.cwd);
690
- console.log(styles.success("✓ Git hooks installed"));
691
- } catch (error) {
692
- console.error(styles.error(`✗ ${error.message}`));
693
- process.exit(1);
694
- }
695
- });
696
- hooksCommand.command("uninstall").description("Uninstall git hooks").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
697
- try {
698
- options.cwd = requireProject(options.cwd, "hooks uninstall");
699
- uninstallHooks(options.cwd);
700
- console.log(styles.success("✓ Git hooks uninstalled"));
701
- } catch (error) {
702
- console.error(styles.error(`✗ ${error.message}`));
703
- process.exit(1);
704
- }
705
- });
706
- hooksCommand.command("status").description("Check if hooks are installed").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
707
- try {
708
- options.cwd = requireProject(options.cwd, "hooks status");
709
- if (areHooksInstalled(options.cwd)) {
710
- console.log(styles.success("✓ VersionGuard hooks are installed"));
711
- return;
712
- }
713
- console.log(styles.warning("✗ VersionGuard hooks are not installed"));
714
- process.exit(1);
715
- } catch (error) {
716
- console.error(styles.error(`✗ ${error.message}`));
717
- process.exit(1);
718
- }
719
- });
720
- return program;
447
+ const program = new Command();
448
+ program.name("vg").description("Strict versioning enforcement for SemVer and CalVer (alias: versionguard)").version(CLI_VERSION);
449
+ program.command("init").description("Initialize VersionGuard configuration (interactive wizard or headless)").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-t, --type <type>", "Versioning type: semver or calver").option("-f, --format <format>", "CalVer format tokens (e.g., YYYY.M.MICRO)").option("--allow-v-prefix", "SemVer: allow v-prefix (e.g., v1.2.3)").option("--no-build-metadata", "SemVer: disallow +build metadata").option("--require-prerelease", "SemVer: require prerelease labels").option("--manifest <source>", "Manifest source (e.g., Cargo.toml, pyproject.toml, auto)").option("--hooks", "Install git hooks (default: true)").option("--no-hooks", "Skip git hooks").option("--changelog", "Enable changelog validation (default: true)").option("--no-changelog", "Disable changelog validation").option("--github", "Generate GitHub integration files (default: true)").option("--no-github", "Skip GitHub integration (dependabot.yml)").option("-y, --yes", "Accept all defaults, no prompts").option("--force", "Overwrite existing config file").action(async (options) => {
450
+ try {
451
+ const isHeadless = options.yes || options.type || options.format || options.manifest || options.allowVPrefix || options.buildMetadata === false || options.requirePrerelease;
452
+ let configPath;
453
+ if (isHeadless) {
454
+ configPath = runHeadless({
455
+ cwd: options.cwd,
456
+ type: options.type,
457
+ format: options.format,
458
+ allowVPrefix: options.allowVPrefix,
459
+ allowBuildMetadata: options.buildMetadata,
460
+ requirePrerelease: options.requirePrerelease,
461
+ manifest: options.manifest,
462
+ github: options.github,
463
+ hooks: options.hooks,
464
+ changelog: options.changelog,
465
+ yes: options.yes,
466
+ force: options.force
467
+ });
468
+ console.log(styles.success(`✓ Created ${path.relative(options.cwd, configPath)}`));
469
+ } else {
470
+ configPath = await runWizard(options.cwd);
471
+ if (!configPath) {
472
+ process.exit(0);
473
+ return;
474
+ }
475
+ }
476
+ try {
477
+ const config = getConfig(options.cwd);
478
+ if (config.git.enforceHooks) {
479
+ installHooks(config.git, options.cwd);
480
+ console.log(styles.success("✓ Git hooks installed"));
481
+ }
482
+ } catch {
483
+ console.log(styles.info("ℹ Skipped hooks install (not a git repository)"));
484
+ }
485
+ } catch (error) {
486
+ console.error(styles.error(`✗ ${error.message}`));
487
+ process.exit(1);
488
+ }
489
+ });
490
+ program.command("check").description("Check the current version with actionable feedback").option("-c, --cwd <path>", "Working directory", process.cwd()).option("--prev <version>", "Previous version for comparison").option("--json", "Print machine-readable JSON output").action((options) => {
491
+ try {
492
+ options.cwd = requireProject(options.cwd, "check");
493
+ const config = getConfig(options.cwd);
494
+ const version = getPackageVersion(options.cwd, config.manifest);
495
+ const result = getVersionFeedback(version, config, options.prev);
496
+ if (options.json) {
497
+ console.log(JSON.stringify({
498
+ version,
499
+ versioningType: config.versioning.type,
500
+ valid: result.valid,
501
+ errors: result.errors,
502
+ suggestions: result.suggestions
503
+ }, null, 2));
504
+ if (!result.valid) process.exit(1);
505
+ return;
506
+ }
507
+ console.log(styles.bold(`Current version: ${version}`));
508
+ console.log(styles.dim(`Versioning type: ${config.versioning.type}`));
509
+ console.log("");
510
+ if (result.valid) {
511
+ console.log(styles.success("✓ Version is valid"));
512
+ return;
513
+ }
514
+ console.log(styles.error("✗ Version has issues:"));
515
+ console.log("");
516
+ for (const error of result.errors) console.log(styles.error(` ${error.message}`));
517
+ if (result.suggestions.length > 0) {
518
+ console.log("");
519
+ console.log(styles.info("How to fix:"));
520
+ for (const suggestion of result.suggestions) {
521
+ console.log(` → ${suggestion.message}`);
522
+ if (suggestion.fix) console.log(styles.dim(` Run: ${suggestion.fix}`));
523
+ }
524
+ }
525
+ process.exit(1);
526
+ } catch (error) {
527
+ console.error(styles.error(`✗ ${error.message}`));
528
+ process.exit(1);
529
+ }
530
+ });
531
+ program.command("validate").description("Run full validation with smart feedback").option("-c, --cwd <path>", "Working directory", process.cwd()).option("--hook <name>", "Running as git hook").option("--json", "Print machine-readable JSON output").option("--strict", "Run guard checks and fail on any policy gap or bypass").option("--scan", "Run repo-wide scan for stale version literals").action((options) => {
532
+ try {
533
+ options.cwd = requireProject(options.cwd, "validate");
534
+ const config = getConfig(options.cwd);
535
+ if (options.scan && config.scan) config.scan.enabled = true;
536
+ const version = getPackageVersion(options.cwd, config.manifest);
537
+ const result = validate(config, options.cwd);
538
+ let postTagResult;
539
+ let guardReport;
540
+ if (options.hook === "post-tag") postTagResult = handlePostTag(config, options.cwd);
541
+ if (options.strict) guardReport = runGuardChecks(config, options.cwd);
542
+ if (options.json) {
543
+ console.log(JSON.stringify({
544
+ ...result,
545
+ hook: options.hook ?? null,
546
+ postTag: postTagResult ?? null,
547
+ guard: guardReport ?? null
548
+ }, null, 2));
549
+ if (!result.valid || postTagResult && !postTagResult.success || guardReport && !guardReport.safe) process.exit(1);
550
+ return;
551
+ }
552
+ console.log(styles.bold(`Validating version ${version}...`));
553
+ console.log("");
554
+ if (!result.syncValid) {
555
+ console.log(styles.error("Sync Issues:"));
556
+ for (const error of result.errors.filter((item) => item.includes("mismatch"))) {
557
+ const parts = error.match(/Version mismatch in (.+):(\d+) - found "(.+?)" but expected "(.+?)"/);
558
+ if (!parts) continue;
559
+ const suggestions = getSyncFeedback(parts[1], parts[3], parts[4]);
560
+ console.log(styles.error(` ✗ ${parts[1]} has wrong version`));
561
+ console.log(styles.dim(` Found: "${parts[3]}" Expected: "${parts[4]}"`));
562
+ if (suggestions[0]?.fix) console.log(styles.info(` Fix: ${suggestions[0].fix}`));
563
+ }
564
+ console.log("");
565
+ }
566
+ const scanErrors = result.errors.filter((item) => item.startsWith("Stale version"));
567
+ if (scanErrors.length > 0) {
568
+ console.log(styles.error("Scan Findings:"));
569
+ for (const error of scanErrors) {
570
+ const parts = error.match(/Stale version in (.+):(\d+) - found "(.+?)" but expected "(.+?)"/);
571
+ if (parts) console.log(styles.error(` ✗ ${parts[1]}:${parts[2]} has "${parts[3]}"`));
572
+ }
573
+ console.log(styles.dim(" Hint: add entries to scan.allowlist to exclude intentional references"));
574
+ console.log("");
575
+ }
576
+ if (config.changelog.enabled && !result.changelogValid) {
577
+ console.log(styles.error("Changelog Issues:"));
578
+ for (const error of result.errors.filter((item) => item.toLowerCase().includes("changelog"))) console.log(styles.error(` ✗ ${error}`));
579
+ const suggestions = getChangelogFeedback(false, version);
580
+ if (suggestions[0]?.fix) console.log(styles.info(`Fix: ${suggestions[0].fix}`));
581
+ console.log("");
582
+ }
583
+ if (postTagResult) {
584
+ if (!postTagResult.success) {
585
+ console.log(styles.error(`✗ ${postTagResult.message}`));
586
+ process.exit(1);
587
+ }
588
+ }
589
+ if (guardReport && guardReport.warnings.length > 0) {
590
+ console.log(styles.bold("Guard Checks:"));
591
+ for (const warning of guardReport.warnings) {
592
+ const icon = warning.severity === "error" ? styles.error("") : styles.warning("⚠");
593
+ console.log(` ${icon} [${warning.code}] ${warning.message}`);
594
+ if (warning.fix) console.log(styles.dim(` Fix: ${warning.fix}`));
595
+ }
596
+ console.log("");
597
+ }
598
+ if (!result.valid || guardReport && !guardReport.safe) {
599
+ console.log(styles.error("✗ Validation failed"));
600
+ process.exit(1);
601
+ }
602
+ console.log(styles.success(" All validations passed"));
603
+ } catch (error) {
604
+ console.error(styles.error(`✗ ${error.message}`));
605
+ process.exit(1);
606
+ }
607
+ });
608
+ program.command("doctor").description("Report repository readiness in one pass").option("-c, --cwd <path>", "Working directory", process.cwd()).option("--json", "Print machine-readable JSON output").option("--strict", "Include guard checks for bypass detection").action((options) => {
609
+ try {
610
+ options.cwd = requireProject(options.cwd, "doctor");
611
+ const config = getConfig(options.cwd);
612
+ const report = doctor(config, options.cwd);
613
+ const guardReport = options.strict ? runGuardChecks(config, options.cwd) : void 0;
614
+ if (options.json) {
615
+ console.log(JSON.stringify({
616
+ ...report,
617
+ guard: guardReport ?? null
618
+ }, null, 2));
619
+ if (!report.ready || guardReport && !guardReport.safe) process.exit(1);
620
+ return;
621
+ }
622
+ console.log(styles.bold("VersionGuard Doctor"));
623
+ console.log(` Version: ${report.version || "(missing)"}`);
624
+ console.log(` Version valid: ${report.versionValid ? "yes" : "no"}`);
625
+ console.log(` Files in sync: ${report.syncValid ? "yes" : "no"}`);
626
+ console.log(` Changelog ready: ${report.changelogValid ? "yes" : "no"}`);
627
+ console.log(` Git repository: ${report.gitRepository ? "yes" : "no"}`);
628
+ console.log(` Hooks installed: ${report.gitRepository ? report.hooksInstalled ? "yes" : "no" : "n/a"}`);
629
+ console.log(` Worktree clean: ${report.gitRepository ? report.worktreeClean ? "yes" : "no" : "n/a"}`);
630
+ if (guardReport) console.log(` Guard safe: ${guardReport.safe ? "yes" : "no"}`);
631
+ if (!report.ready || guardReport && !guardReport.safe) {
632
+ console.log("");
633
+ console.log(styles.error("Issues:"));
634
+ for (const error of report.errors) console.log(styles.error(` ✗ ${error}`));
635
+ if (guardReport) for (const warning of guardReport.warnings) {
636
+ const icon = warning.severity === "error" ? "✗" : "⚠";
637
+ console.log(styles.error(` ${icon} [${warning.code}] ${warning.message}`));
638
+ if (warning.fix) console.log(styles.dim(` Fix: ${warning.fix}`));
639
+ }
640
+ process.exit(1);
641
+ }
642
+ console.log("");
643
+ console.log(styles.success("✓ Repository is ready"));
644
+ } catch (error) {
645
+ console.error(styles.error(`✗ ${error.message}`));
646
+ process.exit(1);
647
+ }
648
+ });
649
+ program.command("fix").description("Auto-fix detected issues").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
650
+ try {
651
+ options.cwd = requireProject(options.cwd, "fix");
652
+ const config = getConfig(options.cwd);
653
+ const version = getPackageVersion(options.cwd, config.manifest);
654
+ const results = fixAll(config, version, options.cwd);
655
+ console.log(styles.bold(`Fixing issues for version ${version}...`));
656
+ console.log("");
657
+ for (const result of results) {
658
+ const printer = result.fixed ? styles.success : styles.dim;
659
+ console.log(printer(`${result.fixed ? "" : "•"} ${result.message}`));
660
+ }
661
+ } catch (error) {
662
+ console.error(styles.error(`✗ ${error.message}`));
663
+ process.exit(1);
664
+ }
665
+ });
666
+ program.command("fix-changelog").description("Fix Changesets-mangled changelog into Keep a Changelog format").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
667
+ try {
668
+ options.cwd = requireProject(options.cwd, "fix-changelog");
669
+ const config = getConfig(options.cwd);
670
+ const changelogPath = path.join(options.cwd, config.changelog.file);
671
+ if (!isChangesetMangled(changelogPath)) {
672
+ console.log(styles.dim("• Changelog is not mangled no fix needed"));
673
+ return;
674
+ }
675
+ if (fixChangesetMangling(changelogPath)) console.log(styles.success(`✓ Restructured ${config.changelog.file} to Keep a Changelog format`));
676
+ else console.log(styles.dim("• Could not auto-fix changelog structure"));
677
+ } catch (error) {
678
+ console.error(styles.error(`✗ ${error.message}`));
679
+ process.exit(1);
680
+ }
681
+ });
682
+ program.command("sync").description("Sync version to all configured files").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
683
+ try {
684
+ options.cwd = requireProject(options.cwd, "sync");
685
+ const config = getConfig(options.cwd);
686
+ const version = getPackageVersion(options.cwd, config.manifest);
687
+ const results = fixSyncIssues(config, options.cwd);
688
+ console.log(styles.bold(`Syncing version ${version}...`));
689
+ for (const result of results) {
690
+ const printer = result.fixed ? styles.success : styles.dim;
691
+ console.log(printer(`${result.fixed ? "✓" : "•"} ${result.message}`));
692
+ }
693
+ } catch (error) {
694
+ console.error(styles.error(`✗ ${error.message}`));
695
+ process.exit(1);
696
+ }
697
+ });
698
+ program.command("bump").description("Suggest and optionally apply the next version").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-t, --type <type>", "Bump type (major, minor, patch, auto)").option("--apply", "Apply the first suggested version").action((options) => {
699
+ try {
700
+ options.cwd = requireProject(options.cwd, "bump");
701
+ const config = getConfig(options.cwd);
702
+ const currentVersion = getPackageVersion(options.cwd, config.manifest);
703
+ const suggestions = suggestNextVersion(currentVersion, config, options.type);
704
+ console.log(styles.bold(`Current version: ${currentVersion}`));
705
+ console.log("");
706
+ for (const [index, suggestion] of suggestions.entries()) {
707
+ console.log(` ${index + 1}. ${styles.bold(suggestion.version)}`);
708
+ console.log(` ${styles.dim(suggestion.reason)}`);
709
+ }
710
+ if (options.apply) {
711
+ const nextVersion = suggestions[0]?.version;
712
+ if (!nextVersion) throw new Error("No version suggestion available");
713
+ setPackageVersion(nextVersion, options.cwd, config.manifest);
714
+ fixAll(config, nextVersion, options.cwd);
715
+ console.log(styles.success(`✓ Updated to ${nextVersion}`));
716
+ }
717
+ } catch (error) {
718
+ console.error(styles.error(`✗ ${error.message}`));
719
+ process.exit(1);
720
+ }
721
+ });
722
+ program.command("tag").description("Create a git tag with automation").argument("[version]", "Version to tag (defaults to manifest version)").option("-c, --cwd <path>", "Working directory", process.cwd()).option("-m, --message <msg>", "Tag message").option("--no-fix", "Skip auto-fixing files before tagging").action((version, options) => {
723
+ try {
724
+ options.cwd = requireProject(options.cwd, "tag");
725
+ const config = getConfig(options.cwd);
726
+ const result = createTag(version || getPackageVersion(options.cwd, config.manifest), options.message, options.fix !== false, config, options.cwd);
727
+ if (!result.success) {
728
+ console.log(styles.error(`✗ ${result.message}`));
729
+ process.exit(1);
730
+ }
731
+ console.log(styles.success(`✓ ${result.message}`));
732
+ for (const action of result.actions) console.log(` ${action}`);
733
+ } catch (error) {
734
+ console.error(styles.error(`✗ ${error.message}`));
735
+ process.exit(1);
736
+ }
737
+ });
738
+ program.command("ckm [topic]").description("Codebase Knowledge Manifest — auto-generated docs and help").option("--json", "Machine-readable CKM output for LLM agents").option("--llm", "Full API context (forge-ts llms.txt)").action((topic, options) => {
739
+ if (options.llm) {
740
+ console.log(llms_default);
741
+ return;
742
+ }
743
+ if (options.json) {
744
+ console.log(JSON.stringify(ckmEngine.getTopicJson(topic), null, 2));
745
+ return;
746
+ }
747
+ if (topic) {
748
+ const content = ckmEngine.getTopicContent(topic);
749
+ if (!content) {
750
+ console.error(styles.error(`Unknown topic: ${topic}`));
751
+ console.log("");
752
+ console.log(ckmEngine.getTopicIndex("vg"));
753
+ process.exit(1);
754
+ }
755
+ console.log(content);
756
+ } else console.log(ckmEngine.getTopicIndex("vg"));
757
+ });
758
+ const hooksCommand = program.command("hooks").description("Manage git hooks");
759
+ hooksCommand.command("install").description("Install git hooks").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
760
+ try {
761
+ options.cwd = requireProject(options.cwd, "hooks install");
762
+ installHooks(getConfig(options.cwd).git, options.cwd);
763
+ console.log(styles.success("✓ Git hooks installed"));
764
+ } catch (error) {
765
+ console.error(styles.error(`✗ ${error.message}`));
766
+ process.exit(1);
767
+ }
768
+ });
769
+ hooksCommand.command("uninstall").description("Uninstall git hooks").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
770
+ try {
771
+ options.cwd = requireProject(options.cwd, "hooks uninstall");
772
+ uninstallHooks(options.cwd);
773
+ console.log(styles.success("✓ Git hooks uninstalled"));
774
+ } catch (error) {
775
+ console.error(styles.error(`✗ ${error.message}`));
776
+ process.exit(1);
777
+ }
778
+ });
779
+ hooksCommand.command("status").description("Check if hooks are installed").option("-c, --cwd <path>", "Working directory", process.cwd()).action((options) => {
780
+ try {
781
+ options.cwd = requireProject(options.cwd, "hooks status");
782
+ if (areHooksInstalled(options.cwd)) {
783
+ console.log(styles.success("✓ VersionGuard hooks are installed"));
784
+ return;
785
+ }
786
+ console.log(styles.warning("✗ VersionGuard hooks are not installed"));
787
+ process.exit(1);
788
+ } catch (error) {
789
+ console.error(styles.error(`✗ ${error.message}`));
790
+ process.exit(1);
791
+ }
792
+ });
793
+ return program;
721
794
  }
795
+ /**
796
+ * Parses CLI arguments and executes the matching command.
797
+ *
798
+ * @public
799
+ * @since 0.1.0
800
+ * @remarks
801
+ * This helper delegates argument parsing to the Commander program created by
802
+ * {@link createProgram}. It resolves when the selected command finishes.
803
+ *
804
+ * @param argv - Full argument vector to parse.
805
+ * @see {@link createProgram}
806
+ *
807
+ * @example
808
+ * ```typescript
809
+ * const argv = ['node', 'versionguard', 'check'];
810
+ * await runCli(argv);
811
+ * ```
812
+ */
722
813
  async function runCli(argv = process.argv) {
723
- await createProgram().parseAsync(argv);
814
+ await createProgram().parseAsync(argv);
724
815
  }
816
+ /**
817
+ * Determines whether the current module is the invoked CLI entry point.
818
+ *
819
+ * @public
820
+ * @since 0.1.0
821
+ * @remarks
822
+ * This helper compares the resolved script path from `argv` with the current
823
+ * module URL so the CLI runs only during direct execution.
824
+ *
825
+ * @param argv - Full process argument vector.
826
+ * @param metaUrl - Module URL to compare against the invoked entry path.
827
+ * @returns `true` when the current module should launch the CLI.
828
+ *
829
+ * @example
830
+ * ```typescript
831
+ * const shouldRun = shouldRunCli(process.argv, import.meta.url);
832
+ * console.log(shouldRun);
833
+ * ```
834
+ */
725
835
  function shouldRunCli(argv = process.argv, metaUrl = import.meta.url) {
726
- if (!argv[1]) return false;
727
- const metaPath = fileURLToPath(metaUrl);
728
- const resolved = path.resolve(argv[1]);
729
- try {
730
- return fs.realpathSync(resolved) === metaPath;
731
- } catch {
732
- return resolved === metaPath;
733
- }
734
- }
735
- if (shouldRunCli()) {
736
- void runCli();
836
+ if (!argv[1]) return false;
837
+ const metaPath = fileURLToPath(metaUrl);
838
+ const resolved = path.resolve(argv[1]);
839
+ try {
840
+ return fs.realpathSync(resolved) === metaPath;
841
+ } catch {
842
+ return resolved === metaPath;
843
+ }
737
844
  }
738
- export {
739
- createProgram,
740
- runCli,
741
- shouldRunCli
742
- };
743
- //# sourceMappingURL=cli.js.map
845
+ /* v8 ignore start -- exercised only by direct CLI execution */
846
+ if (shouldRunCli()) runCli();
847
+ /* v8 ignore stop */
848
+ //#endregion
849
+ export { createProgram, runCli, shouldRunCli };
850
+
851
+ //# sourceMappingURL=cli.js.map