@kb-labs/impact-core 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/workspace.ts","../../../src/core/changed-packages.ts","../../../src/core/dependency-graph.ts","../../../src/core/package-analyzer.ts","../../../src/core/doc-analyzer.ts","../../../src/core/test-analyzer.ts","../../../src/core/build-analyzer.ts","../../../src/core/impact-rules.ts","../../../src/core/formatter.ts","../../../src/cli/commands/check.ts"],"names":["join","existsSync","readFileSync","readdirSync"],"mappings":";;;;;;;AAIO,SAAS,kBAAkB,GAAA,EAAsB;AACtD,EAAA,IAAI,GAAA,GAAM,OAAA,CAAe,OAAA,CAAQ,KAAK,CAAA;AACtC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,EAAA,EAAI,CAAA,EAAA,EAAK;AAC3B,IAAA,IAAI,UAAA,CAAW,IAAA,CAAK,GAAA,EAAK,aAAa,CAAC,CAAA,IAAK,UAAA,CAAW,IAAA,CAAK,GAAA,EAAK,KAAA,EAAO,gBAAgB,CAAC,CAAA,EAAG;AAC1F,MAAA,OAAO,GAAA;AAAA,IACT;AACA,IAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,EAAK,IAAI,CAAA;AAChC,IAAA,IAAI,WAAW,GAAA,EAAK;AAAC,MAAA;AAAA,IAAM;AAC3B,IAAA,GAAA,GAAM,MAAA;AAAA,EACR;AACA,EAAA,MAAM,IAAI,MAAM,4EAA4E,CAAA;AAC9F;AAOO,SAAS,aAAa,aAAA,EAAkC;AAC7D,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,aAAA,EAAe,aAAa,CAAA;AAExD,EAAA,IAAI,UAAA,CAAW,cAAc,CAAA,EAAG;AAC9B,IAAA,OAAO,2BAAA,CAA4B,gBAAgB,aAAa,CAAA;AAAA,EAClE;AAGA,EAAA,OAAO,eAAe,aAAa,CAAA;AAC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,SAAA,EAAW,GAAG,QAAA,CAAS,UAAU,CAAA;AACtF,MAAA,MAAM,IAAA,GAAO,gBAAA,CAAiB,WAAA,EAAa,KAAK,CAAA;AAChD,MAAA,MAAM,KAAA,GAAQ,iBAAA,CAAkB,WAAA,EAAa,IAAI,CAAA;AACjD,MAAA,MAAM,KAAA,GAAQ,kBAAA,CAAmB,WAAA,EAAa,KAAK,CAAA;AACnD,MAAA,MAAM,eAAA,GAAkB,uBAAA,CAAwB,QAAA,EAAU,IAAI,CAAA;AAC9D,MAAA,MAAM,SAA+B,EAAE,QAAA,EAAU,IAAA,EAAM,KAAA,EAAO,OAAO,eAAA,EAAgB;AAErF,MAAA,IAAI,MAAM,IAAA,EAAM;AACd,QAAA,GAAA,CAAI,EAAA,EAAI,OAAO,MAAM,CAAA;AAAA,MACvB,CAAA,MAAO;AACL,QAAA,GAAA,CAAI,EAAA,EAAI,KAAA,GAAQ,mBAAA,CAAoB,MAAM,CAAC,CAAA;AAAA,MAC7C;AAEA,MAAA,OAAO,EAAE,QAAA,EAAU,CAAA,EAAG,MAAA,EAAO;AAAA,IAC/B;AAAA;AAEJ,CAAC","file":"check.js","sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type { SubRepo } from '@kb-labs/impact-contracts';\n\nexport function findWorkspaceRoot(cwd?: string): string {\n let dir = resolve(cwd ?? process.cwd());\n for (let i = 0; i < 10; i++) {\n if (existsSync(join(dir, '.gitmodules')) || existsSync(join(dir, '.kb', 'kb.config.json'))) {\n return dir;\n }\n const parent = resolve(dir, '..');\n if (parent === dir) {break;}\n dir = parent;\n }\n throw new Error('Could not find workspace root (no .gitmodules or .kb/kb.config.json found)');\n}\n\n/**\n * Parse .gitmodules to get submodule paths.\n * Returns entries like { path: \"platform/kb-labs-core\", name: \"kb-labs-core\", category: \"platform\" }.\n * Falls back to scanning top-level dirs for .git (flat layout).\n */\nexport function listSubRepos(workspaceRoot: string): SubRepo[] {\n const gitmodulesPath = join(workspaceRoot, '.gitmodules');\n\n if (existsSync(gitmodulesPath)) {\n return parseSubReposFromGitmodules(gitmodulesPath, workspaceRoot);\n }\n\n // Fallback: flat layout — top-level dirs with .git\n return scanFlatLayout(workspaceRoot);\n}\n\nfunction parseSubReposFromGitmodules(gitmodulesPath: string, workspaceRoot: string): SubRepo[] {\n const repos: SubRepo[] = [];\n try {\n const content = readFileSync(gitmodulesPath, 'utf-8');\n const pathMatches = content.matchAll(/^\\s*path\\s*=\\s*(.+)$/gm);\n for (const match of pathMatches) {\n const relPath = (match[1] ?? '').trim();\n if (!relPath) {continue;}\n\n const fullPath = join(workspaceRoot, relPath);\n if (!existsSync(join(fullPath, '.git')) && !existsSync(join(fullPath, 'package.json'))) {\n continue;\n }\n\n const parts = relPath.split('/');\n const name = parts.at(-1) ?? relPath;\n const category = parts.length > 1 ? parts.slice(0, -1).join('/') : '';\n repos.push({ path: relPath, category, name });\n }\n } catch {\n // ignore parse errors\n }\n return repos;\n}\n\nfunction scanFlatLayout(workspaceRoot: string): SubRepo[] {\n const repos: SubRepo[] = [];\n try {\n for (const entry of readdirSync(workspaceRoot, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === 'node_modules') {continue;}\n const fullPath = join(workspaceRoot, entry.name);\n if (existsSync(join(fullPath, '.git')) || existsSync(join(fullPath, 'package.json'))) {\n repos.push({ path: entry.name, category: '', name: entry.name });\n }\n }\n } catch {\n // ignore\n }\n return repos;\n}\n","import { execSync } from 'node:child_process';\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { ChangedPackage, SubRepo } from '@kb-labs/impact-contracts';\nimport { listSubRepos } from './workspace.js';\n\nfunction git(cwd: string, args: string): string {\n try {\n return execSync(`git ${args}`, { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();\n } catch {\n return '';\n }\n}\n\nfunction getSubmodulePointer(workspaceRoot: string, repoPath: string): string {\n const out = git(workspaceRoot, `ls-tree HEAD ${repoPath}`);\n const parts = out.split(/\\s+/);\n return parts[2] || '';\n}\n\nfunction getActualHead(fullPath: string): string {\n return git(fullPath, 'rev-parse HEAD');\n}\n\nfunction findPackagesInRepo(workspaceRoot: string, repo: SubRepo): ChangedPackage[] {\n const fullRepoPath = join(workspaceRoot, repo.path);\n const packagesDir = join(fullRepoPath, 'packages');\n const results: ChangedPackage[] = [];\n\n if (!existsSync(packagesDir)) {\n // Repo without packages/ — treat entire repo as one package\n const pkgJsonPath = join(fullRepoPath, 'package.json');\n if (!existsSync(pkgJsonPath)) {return [];}\n try {\n const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n if (pkg.name?.startsWith('@kb-labs/')) {\n results.push({ name: pkg.name, repo: repo.path, changedFiles: 1 });\n }\n } catch { /* skip */ }\n return results;\n }\n\n for (const entry of readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name.startsWith('.')) {continue;}\n const pkgJsonPath = join(packagesDir, entry.name, 'package.json');\n if (!existsSync(pkgJsonPath)) {continue;}\n try {\n const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n if (!pkg.name?.startsWith('@kb-labs/')) {continue;}\n\n // Count changed files in this package\n const pointerSha = getSubmodulePointer(workspaceRoot, repo.path);\n let changedFiles = 0;\n if (pointerSha) {\n const diff = git(fullRepoPath, `diff ${pointerSha}..HEAD --name-only -- packages/${entry.name}/src/`);\n changedFiles = diff ? diff.split('\\n').filter(Boolean).length : 0;\n } else {\n // Fallback: count dirty files\n const status = git(fullRepoPath, `status --porcelain -- packages/${entry.name}/src/`);\n changedFiles = status ? status.split('\\n').filter(Boolean).length : 0;\n }\n\n if (changedFiles > 0) {\n results.push({ name: pkg.name, repo: repo.path, changedFiles });\n }\n } catch { /* skip */ }\n }\n\n return results;\n}\n\nexport function detectChangedPackages(workspaceRoot: string): ChangedPackage[] {\n const repos = listSubRepos(workspaceRoot);\n const changed: ChangedPackage[] = [];\n\n for (const repo of repos) {\n const fullPath = join(workspaceRoot, repo.path);\n if (!existsSync(join(fullPath, '.git'))) {continue;}\n\n const pointerSha = getSubmodulePointer(workspaceRoot, repo.path);\n const actualSha = getActualHead(fullPath);\n\n // Skip if no changes\n if (pointerSha && pointerSha === actualSha) {continue;}\n\n // Also check dirty working tree\n if (pointerSha === actualSha) {\n const dirty = git(fullPath, 'status --porcelain');\n if (!dirty) {continue;}\n }\n\n const pkgs = findPackagesInRepo(workspaceRoot, repo);\n changed.push(...pkgs);\n }\n\n return changed;\n}\n","import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { DepGraphNode } from '@kb-labs/impact-contracts';\nimport { listSubRepos } from './workspace.js';\n\nfunction discoverPackages(workspaceRoot: string): Array<{ name: string; repo: string; deps: string[] }> {\n const repos = listSubRepos(workspaceRoot);\n const packages: Array<{ name: string; repo: string; deps: string[] }> = [];\n\n for (const repo of repos) {\n const fullRepoPath = join(workspaceRoot, repo.path);\n const packagesDir = join(fullRepoPath, 'packages');\n\n const dirs = existsSync(packagesDir)\n ? readdirSync(packagesDir, { withFileTypes: true })\n .filter((d) => d.isDirectory() && !d.name.startsWith('.'))\n .map((d) => join(packagesDir, d.name))\n : [fullRepoPath]; // repo without packages/\n\n for (const dir of dirs) {\n const pkgPath = join(dir, 'package.json');\n if (!existsSync(pkgPath)) {continue;}\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n if (!pkg.name?.startsWith('@kb-labs/')) {continue;}\n const allDeps = { ...pkg.dependencies };\n const kbDeps = Object.keys(allDeps).filter((d) => d.startsWith('@kb-labs/'));\n packages.push({ name: pkg.name, repo: repo.path, deps: kbDeps });\n } catch { /* skip */ }\n }\n }\n\n return packages;\n}\n\nexport function buildReverseDependencyGraph(workspaceRoot: string): Map<string, DepGraphNode> {\n const packages = discoverPackages(workspaceRoot);\n const graph = new Map<string, DepGraphNode>();\n\n // Initialize nodes\n for (const pkg of packages) {\n graph.set(pkg.name, {\n name: pkg.name,\n repo: pkg.repo,\n dependsOn: pkg.deps,\n dependedBy: [],\n });\n }\n\n // Build reverse edges\n for (const pkg of packages) {\n for (const dep of pkg.deps) {\n const node = graph.get(dep);\n if (node) {\n node.dependedBy.push(pkg.name);\n }\n }\n }\n\n return graph;\n}\n","import type { ChangedPackage, DepGraphNode, PackageImpact } from '@kb-labs/impact-contracts';\n\nexport function analyzePackageImpact(\n changed: ChangedPackage[],\n graph: Map<string, DepGraphNode>,\n): { direct: PackageImpact[]; dependent: PackageImpact[]; transitive: PackageImpact[] } {\n const direct: PackageImpact[] = [];\n const dependent: PackageImpact[] = [];\n const transitive: PackageImpact[] = [];\n\n const changedNames = new Set(changed.map((c) => c.name));\n const seen = new Set<string>();\n\n // Direct — packages that changed\n for (const pkg of changed) {\n direct.push({\n name: pkg.name,\n repo: pkg.repo,\n level: 'direct',\n changedFiles: pkg.changedFiles,\n });\n seen.add(pkg.name);\n }\n\n // BFS from direct to find dependent and transitive\n const queue: Array<{ name: string; depth: number }> = [];\n\n for (const name of changedNames) {\n const node = graph.get(name);\n if (!node) {continue;}\n for (const dep of node.dependedBy) {\n if (!seen.has(dep)) {\n queue.push({ name: dep, depth: 1 });\n }\n }\n }\n\n while (queue.length > 0) {\n const { name, depth } = queue.shift()!;\n if (seen.has(name)) {continue;}\n seen.add(name);\n\n const node = graph.get(name);\n if (!node) {continue;}\n\n // Find reason (which direct/dependent package it depends on)\n const reasonPkg = node.dependsOn.find((d) => changedNames.has(d) || seen.has(d));\n const impact: PackageImpact = {\n name: node.name,\n repo: node.repo,\n level: depth === 1 ? 'dependent' : 'transitive',\n reason: reasonPkg ? `depends on ${reasonPkg}` : undefined,\n };\n\n if (depth === 1) {\n dependent.push(impact);\n } else {\n transitive.push(impact);\n }\n\n // Enqueue next level\n for (const dep of node.dependedBy) {\n if (!seen.has(dep)) {\n queue.push({ name: dep, depth: depth + 1 });\n }\n }\n }\n\n return { direct, dependent, transitive };\n}\n\nexport function generateRecommendations(\n packages: { direct: PackageImpact[]; dependent: PackageImpact[]; transitive: PackageImpact[] },\n docs: { stale: Array<{ file?: string }>; review: Array<{ file?: string }>; reindex: Array<{ command?: string }> },\n): string[] {\n const recs: string[] = [];\n\n if (packages.dependent.length > 0) {\n const names = packages.dependent.map((p) => p.name).join(', ');\n recs.push(`Rebuild ${names}`);\n }\n\n // Collect unique repos that need testing\n const testRepos = new Set([\n ...packages.dependent.map((p) => p.repo),\n ...packages.transitive.map((p) => p.repo),\n ]);\n if (testRepos.size > 0) {\n recs.push(`Run tests in ${[...testRepos].join(', ')}`);\n }\n\n for (const doc of docs.stale) {\n if (doc.file) {recs.push(`Regenerate ${doc.file}`);}\n }\n\n for (const doc of docs.review) {\n if (doc.file) {recs.push(`Review ${doc.file}`);}\n }\n\n for (const doc of docs.reindex) {\n if (doc.command) {recs.push(`Run: ${doc.command}`);}\n }\n\n return recs;\n}\n","import type { DocImpact, ImpactPluginConfig, PackageImpact } from '@kb-labs/impact-contracts';\n\nfunction matchesRule(packageName: string, pattern: string): boolean {\n if (pattern === packageName) {return true;}\n if (pattern === '__new_package__') {return false;} // handled separately\n\n // Simple glob: *-cli matches @kb-labs/agent-cli\n if (pattern.startsWith('*')) {\n return packageName.endsWith(pattern.slice(1));\n }\n if (pattern.endsWith('*')) {\n return packageName.startsWith(pattern.slice(0, -1));\n }\n\n return false;\n}\n\nexport function analyzeDocImpact(\n impactedPackages: PackageImpact[],\n config: ImpactPluginConfig,\n): { stale: DocImpact[]; review: DocImpact[]; reindex: DocImpact[] } {\n const stale: DocImpact[] = [];\n const review: DocImpact[] = [];\n const reindex: DocImpact[] = [];\n\n const seenDocs = new Set<string>();\n\n for (const pkg of impactedPackages) {\n for (const rule of config.docRules) {\n if (!matchesRule(pkg.name, rule.match)) {continue;}\n\n if (rule.action === 'reindex') {\n const key = `reindex:${rule.command ?? ''}`;\n if (!seenDocs.has(key)) {\n seenDocs.add(key);\n reindex.push({\n reason: `${pkg.name} changed`,\n action: 'reindex',\n command: rule.command,\n });\n }\n continue;\n }\n\n for (const doc of rule.docs ?? []) {\n const key = `${rule.action}:${doc}`;\n if (seenDocs.has(key)) {continue;}\n seenDocs.add(key);\n\n const impact: DocImpact = {\n file: doc,\n reason: `${pkg.name} changed`,\n action: rule.action,\n command: rule.command,\n };\n\n if (rule.action === 'regenerate') {stale.push(impact);}\n else {review.push(impact);}\n }\n }\n }\n\n return { stale, review, reindex };\n}\n","import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { PackageImpact, TestImpact } from '@kb-labs/impact-contracts';\n\nconst TEST_DIRS = ['tests', 'test', '__tests__'];\nconst TEST_PATTERNS = ['.test.ts', '.spec.ts', '.test.tsx', '.spec.tsx'];\n\nfunction findPackageDir(workspaceRoot: string, repo: string, packageName: string): string | null {\n const repoPath = join(workspaceRoot, repo);\n const packagesDir = join(repoPath, 'packages');\n\n if (!existsSync(packagesDir)) {\n // Repo without packages/ — the repo itself is the package\n return repoPath;\n }\n\n // Search for the package by name in package.json files\n for (const entry of readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name.startsWith('.')) {continue;}\n const pkgJsonPath = join(packagesDir, entry.name, 'package.json');\n if (!existsSync(pkgJsonPath)) {continue;}\n try {\n const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n if (pkg.name === packageName) {\n return join(packagesDir, entry.name);\n }\n } catch { /* skip */ }\n }\n\n return null;\n}\n\nfunction countTestFiles(dir: string): number {\n let count = 0;\n\n function walk(d: string): void {\n if (!existsSync(d)) {return;}\n for (const entry of readdirSync(d, { withFileTypes: true })) {\n if (entry.name === 'node_modules' || entry.name === 'dist') {continue;}\n const full = join(d, entry.name);\n if (entry.isDirectory()) {\n walk(full);\n } else if (TEST_PATTERNS.some((p) => entry.name.endsWith(p))) {\n count++;\n }\n }\n }\n\n walk(dir);\n return count;\n}\n\nfunction detectTests(packageDir: string): { hasTests: boolean; testCount: number } {\n // Check dedicated test directories\n for (const testDir of TEST_DIRS) {\n const fullPath = join(packageDir, testDir);\n if (existsSync(fullPath)) {\n const count = countTestFiles(fullPath);\n if (count > 0) {return { hasTests: true, testCount: count };}\n }\n }\n\n // Also check src/ for co-located test files\n const srcDir = join(packageDir, 'src');\n if (existsSync(srcDir)) {\n const count = countTestFiles(srcDir);\n if (count > 0) {return { hasTests: true, testCount: count };}\n }\n\n return { hasTests: false, testCount: 0 };\n}\n\nexport function analyzeTestImpact(\n allImpacted: PackageImpact[],\n workspaceRoot: string,\n): { mustRun: TestImpact[]; noTests: TestImpact[] } {\n const mustRun: TestImpact[] = [];\n const noTests: TestImpact[] = [];\n\n for (const pkg of allImpacted) {\n const pkgDir = findPackageDir(workspaceRoot, pkg.repo, pkg.name);\n const { hasTests, testCount } = pkgDir ? detectTests(pkgDir) : { hasTests: false, testCount: 0 };\n\n const impact: TestImpact = {\n name: pkg.name,\n repo: pkg.repo,\n level: pkg.level,\n reason: pkg.reason,\n hasTests,\n testCount: hasTests ? testCount : undefined,\n command: hasTests ? `pnpm --filter ${pkg.name} run test` : undefined,\n };\n\n if (hasTests) {\n mustRun.push(impact);\n } else {\n noTests.push(impact);\n }\n }\n\n return { mustRun, noTests };\n}\n","import type { BuildImpact, BuildPlan, DepGraphNode, PackageImpact } from '@kb-labs/impact-contracts';\n\n/**\n * Topological sort of impacted packages — returns correct build order.\n * Uses Kahn's algorithm on the subgraph of only affected packages.\n */\nexport function analyzeBuildImpact(\n allImpacted: PackageImpact[],\n graph: Map<string, DepGraphNode>,\n): BuildPlan {\n const impactedNames = new Set(allImpacted.map((p) => p.name));\n const impactedMap = new Map(allImpacted.map((p) => [p.name, p]));\n\n // Build subgraph of only impacted packages\n const inDegree = new Map<string, number>();\n const deps = new Map<string, string[]>(); // name → deps that are also impacted\n\n for (const name of impactedNames) {\n const node = graph.get(name);\n const filteredDeps = (node?.dependsOn ?? []).filter((d) => impactedNames.has(d));\n deps.set(name, filteredDeps);\n inDegree.set(name, filteredDeps.length);\n }\n\n // Kahn's algorithm\n const queue: string[] = [];\n for (const [name, degree] of inDegree) {\n if (degree === 0) {queue.push(name);}\n }\n\n const sorted: string[] = [];\n while (queue.length > 0) {\n const current = queue.shift()!;\n sorted.push(current);\n\n // Find packages that depend on current (and are in our impacted set)\n const node = graph.get(current);\n if (node) {\n for (const dependent of node.dependedBy) {\n if (!impactedNames.has(dependent)) {continue;}\n const deg = (inDegree.get(dependent) ?? 1) - 1;\n inDegree.set(dependent, deg);\n if (deg === 0) {queue.push(dependent);}\n }\n }\n }\n\n // If some packages weren't reached (circular deps), append them at the end\n for (const name of impactedNames) {\n if (!sorted.includes(name)) {sorted.push(name);}\n }\n\n const steps: BuildImpact[] = sorted.map((name, idx) => {\n const pkg = impactedMap.get(name)!;\n return {\n name: pkg.name,\n repo: pkg.repo,\n level: pkg.level,\n order: idx + 1,\n reason: pkg.reason,\n };\n });\n\n // Generate a single command that builds in order\n const filterArgs = sorted.map((name) => `--filter ${name}`).join(' ');\n const command = sorted.length > 0\n ? `pnpm ${filterArgs} run build`\n : '';\n\n return {\n steps,\n command,\n totalPackages: steps.length,\n };\n}\n","import { DEFAULT_IMPACT_CONFIG, type ImpactPluginConfig } from '@kb-labs/impact-contracts';\n\nexport async function loadImpactRules(useConfigFn?: () => Promise<Partial<ImpactPluginConfig> | undefined>): Promise<ImpactPluginConfig> {\n if (useConfigFn) {\n try {\n const config = await useConfigFn();\n if (config?.docRules?.length) {return { docRules: config.docRules };}\n } catch { /* fallback to defaults */ }\n }\n return DEFAULT_IMPACT_CONFIG;\n}\n","import type { ImpactAnalysisResult } from '@kb-labs/impact-contracts';\n\nconst BOLD = '\\x1b[1m';\nconst DIM = '\\x1b[2m';\nconst RESET = '\\x1b[0m';\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst GREEN = '\\x1b[32m';\nconst CYAN = '\\x1b[36m';\n\nexport function formatHumanReadable(result: ImpactAnalysisResult): string {\n const lines: string[] = [];\n\n lines.push(`${BOLD}📊 Impact Analysis${RESET}`);\n lines.push('');\n\n // ── Package Impact ──\n const { direct, dependent, transitive } = result.packages;\n const totalPkgs = direct.length + dependent.length + transitive.length;\n\n if (totalPkgs > 0) {\n lines.push(`${BOLD}📦 Package Impact${RESET}`);\n\n if (direct.length > 0) {\n lines.push(` ${GREEN}Direct (${direct.length}):${RESET}`);\n for (const p of direct) {\n lines.push(` ${p.name} ${DIM}(${p.repo})${RESET} — ${p.changedFiles} file${p.changedFiles === 1 ? '' : 's'} changed`);\n }\n }\n\n if (dependent.length > 0) {\n lines.push(` ${YELLOW}Dependent (${dependent.length}):${RESET}`);\n for (const p of dependent) {\n lines.push(` ${p.name} ${DIM}← ${p.reason}${RESET}`);\n }\n }\n\n if (transitive.length > 0) {\n lines.push(` ${DIM}Transitive (${transitive.length}):${RESET}`);\n for (const p of transitive) {\n lines.push(` ${p.name} ${DIM}← ${p.reason}${RESET}`);\n }\n }\n\n lines.push('');\n }\n\n // ── Build Impact ──\n const { steps: buildSteps, command: buildCommand, totalPackages: buildTotal } = result.build;\n\n if (buildTotal > 0) {\n lines.push(`${BOLD}🔨 Build Impact${RESET}`);\n lines.push(` ${YELLOW}Rebuild (${buildTotal} packages in order):${RESET}`);\n for (const b of buildSteps) {\n const reason = b.level === 'direct' ? 'changed' : b.reason ?? '';\n lines.push(` ${DIM}${b.order}.${RESET} ${b.name} ${DIM}← ${reason}${RESET}`);\n }\n if (buildCommand) {\n lines.push('');\n lines.push(` ${CYAN}→ ${buildCommand}${RESET}`);\n }\n lines.push('');\n }\n\n // ── Doc Impact ──\n const { stale, review, reindex } = result.docs;\n const totalDocs = stale.length + review.length + reindex.length;\n\n if (totalDocs > 0) {\n lines.push(`${BOLD}📄 Doc Impact${RESET}`);\n\n if (stale.length > 0) {\n lines.push(` ${YELLOW}Stale (${stale.length}):${RESET}`);\n for (const d of stale) {\n lines.push(` ${d.file} — ${d.reason}`);\n if (d.command) {lines.push(` ${CYAN}→ Run: ${d.command}${RESET}`);}\n }\n }\n\n if (review.length > 0) {\n lines.push(` ${GREEN}Review (${review.length}):${RESET}`);\n for (const d of review) {\n lines.push(` ${d.file} — ${d.reason}`);\n }\n }\n\n if (reindex.length > 0) {\n lines.push(` ${CYAN}Reindex (${reindex.length}):${RESET}`);\n for (const d of reindex) {\n lines.push(` ${d.reason}`);\n if (d.command) {lines.push(` ${CYAN}→ Run: ${d.command}${RESET}`);}\n }\n }\n\n lines.push('');\n }\n\n // ── Test Impact ──\n const { mustRun, noTests } = result.tests;\n const totalTests = mustRun.length + noTests.length;\n\n if (totalTests > 0) {\n lines.push(`${BOLD}🧪 Test Impact${RESET}`);\n\n if (mustRun.length > 0) {\n lines.push(` ${GREEN}Must run (${mustRun.length}):${RESET}`);\n for (const t of mustRun) {\n const count = t.testCount ? ` — ${t.testCount} test file${t.testCount === 1 ? '' : 's'}` : '';\n const reason = t.level === 'direct' ? 'changed' : t.reason ?? '';\n lines.push(` ${t.name}${count} ${DIM}← ${reason}${RESET}`);\n if (t.command) {lines.push(` ${CYAN}→ ${t.command}${RESET}`);}\n }\n }\n\n if (noTests.length > 0) {\n lines.push(` ${RED}⚠️ No tests (${noTests.length}):${RESET}`);\n for (const t of noTests) {\n const reason = t.level === 'direct' ? 'changed, NO TESTS' : `${t.reason}, NO TESTS`;\n lines.push(` ${RED}${t.name}${RESET} ${DIM}← ${reason}${RESET}`);\n }\n }\n\n lines.push('');\n }\n\n // ── Recommendations ──\n if (result.recommendations.length > 0) {\n lines.push(`${BOLD}⚠️ Recommendations:${RESET}`);\n for (const rec of result.recommendations) {\n lines.push(` • ${rec}`);\n }\n lines.push('');\n }\n\n if (totalPkgs === 0 && totalDocs === 0 && totalTests === 0) {\n lines.push(`${GREEN}✅ No impact detected.${RESET}`);\n }\n\n return lines.join('\\n');\n}\n","import { defineCommand, type PluginContextV3, type CommandResult } from '@kb-labs/sdk';\nimport type { ImpactAnalysisResult, ImpactPluginConfig } from '@kb-labs/impact-contracts';\nimport {\n findWorkspaceRoot,\n detectChangedPackages,\n buildReverseDependencyGraph,\n analyzePackageImpact,\n generateRecommendations,\n analyzeDocImpact,\n analyzeTestImpact,\n analyzeBuildImpact,\n loadImpactRules,\n formatHumanReadable,\n} from '../../core/index.js';\n\ninterface CheckFlags {\n json?: boolean;\n}\n\ninterface CheckInput {\n argv: string[];\n flags: CheckFlags;\n}\n\nconst EMPTY_RESULT: ImpactAnalysisResult = {\n packages: { direct: [], dependent: [], transitive: [] },\n docs: { stale: [], review: [], reindex: [] },\n tests: { mustRun: [], noTests: [] },\n build: { steps: [], command: '', totalPackages: 0 },\n recommendations: [],\n};\n\nexport default defineCommand<unknown, CheckInput, ImpactAnalysisResult>({\n id: 'impact:check',\n description: 'Full impact analysis (packages + docs)',\n\n handler: {\n async execute(\n ctx: PluginContextV3<unknown>,\n input: CheckInput,\n ): Promise<CommandResult<ImpactAnalysisResult>> {\n const flags = input.flags ?? (input as unknown as CheckFlags);\n\n let root: string;\n try {\n root = findWorkspaceRoot();\n } catch {\n if (flags.json) {ctx.ui?.json?.(EMPTY_RESULT);}\n else {ctx.ui?.warn?.('Could not find workspace root');}\n return { exitCode: 1 };\n }\n\n const changed = detectChangedPackages(root);\n if (changed.length === 0) {\n if (flags.json) {ctx.ui?.json?.(EMPTY_RESULT);}\n else {ctx.ui?.success?.('No changes detected');}\n return { exitCode: 0, result: EMPTY_RESULT };\n }\n\n const graph = buildReverseDependencyGraph(root);\n const packages = analyzePackageImpact(changed, graph);\n\n const useConfigFn = async () => {\n try {\n const { useConfig } = await import('@kb-labs/sdk');\n return await useConfig<Partial<ImpactPluginConfig>>();\n } catch {\n return undefined;\n }\n };\n\n const rules = await loadImpactRules(useConfigFn);\n const allImpacted = [...packages.direct, ...packages.dependent, ...packages.transitive];\n const docs = analyzeDocImpact(allImpacted, rules);\n const tests = analyzeTestImpact(allImpacted, root);\n const build = analyzeBuildImpact(allImpacted, graph);\n const recommendations = generateRecommendations(packages, docs);\n const result: ImpactAnalysisResult = { packages, docs, tests, build, recommendations };\n\n if (flags.json) {\n ctx.ui?.json?.(result);\n } else {\n ctx.ui?.write?.(formatHumanReadable(result));\n }\n\n return { exitCode: 0, result };\n },\n },\n});\n"]}
@@ -0,0 +1,12 @@
1
+ import * as _kb_labs_shared_command_kit from '@kb-labs/shared-command-kit';
2
+
3
+ interface DocsFlags {
4
+ json?: boolean;
5
+ }
6
+ interface DocsInput {
7
+ argv: string[];
8
+ flags: DocsFlags;
9
+ }
10
+ declare const _default: _kb_labs_shared_command_kit.CommandHandlerV3<unknown, DocsInput, unknown>;
11
+
12
+ export { _default as default };
@@ -0,0 +1,508 @@
1
+ import { defineCommand } from '@kb-labs/sdk';
2
+ import { existsSync, readFileSync, readdirSync } from 'fs';
3
+ import { resolve, join } from 'path';
4
+ import { execSync } from 'child_process';
5
+ import { DEFAULT_IMPACT_CONFIG } from '@kb-labs/impact-contracts';
6
+
7
+ // src/cli/commands/docs.ts
8
+ function findWorkspaceRoot(cwd) {
9
+ let dir = resolve(process.cwd());
10
+ for (let i = 0; i < 10; i++) {
11
+ if (existsSync(join(dir, ".gitmodules")) || existsSync(join(dir, ".kb", "kb.config.json"))) {
12
+ return dir;
13
+ }
14
+ const parent = resolve(dir, "..");
15
+ if (parent === dir) {
16
+ break;
17
+ }
18
+ dir = parent;
19
+ }
20
+ throw new Error("Could not find workspace root (no .gitmodules or .kb/kb.config.json found)");
21
+ }
22
+ function listSubRepos(workspaceRoot) {
23
+ const gitmodulesPath = join(workspaceRoot, ".gitmodules");
24
+ if (existsSync(gitmodulesPath)) {
25
+ return parseSubReposFromGitmodules(gitmodulesPath, workspaceRoot);
26
+ }
27
+ return scanFlatLayout(workspaceRoot);
28
+ }
29
+ function parseSubReposFromGitmodules(gitmodulesPath, workspaceRoot) {
30
+ const repos = [];
31
+ try {
32
+ const content = readFileSync(gitmodulesPath, "utf-8");
33
+ const pathMatches = content.matchAll(/^\s*path\s*=\s*(.+)$/gm);
34
+ for (const match of pathMatches) {
35
+ const relPath = (match[1] ?? "").trim();
36
+ if (!relPath) {
37
+ continue;
38
+ }
39
+ const fullPath = join(workspaceRoot, relPath);
40
+ if (!existsSync(join(fullPath, ".git")) && !existsSync(join(fullPath, "package.json"))) {
41
+ continue;
42
+ }
43
+ const parts = relPath.split("/");
44
+ const name = parts.at(-1) ?? relPath;
45
+ const category = parts.length > 1 ? parts.slice(0, -1).join("/") : "";
46
+ repos.push({ path: relPath, category, name });
47
+ }
48
+ } catch {
49
+ }
50
+ return repos;
51
+ }
52
+ function scanFlatLayout(workspaceRoot) {
53
+ const repos = [];
54
+ try {
55
+ for (const entry of readdirSync(workspaceRoot, { withFileTypes: true })) {
56
+ if (!entry.isDirectory() || entry.name.startsWith(".") || entry.name === "node_modules") {
57
+ continue;
58
+ }
59
+ const fullPath = join(workspaceRoot, entry.name);
60
+ if (existsSync(join(fullPath, ".git")) || existsSync(join(fullPath, "package.json"))) {
61
+ repos.push({ path: entry.name, category: "", name: entry.name });
62
+ }
63
+ }
64
+ } catch {
65
+ }
66
+ return repos;
67
+ }
68
+ function git(cwd, args) {
69
+ try {
70
+ return execSync(`git ${args}`, { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
71
+ } catch {
72
+ return "";
73
+ }
74
+ }
75
+ function getSubmodulePointer(workspaceRoot, repoPath) {
76
+ const out = git(workspaceRoot, `ls-tree HEAD ${repoPath}`);
77
+ const parts = out.split(/\s+/);
78
+ return parts[2] || "";
79
+ }
80
+ function getActualHead(fullPath) {
81
+ return git(fullPath, "rev-parse HEAD");
82
+ }
83
+ function findPackagesInRepo(workspaceRoot, repo) {
84
+ const fullRepoPath = join(workspaceRoot, repo.path);
85
+ const packagesDir = join(fullRepoPath, "packages");
86
+ const results = [];
87
+ if (!existsSync(packagesDir)) {
88
+ const pkgJsonPath = join(fullRepoPath, "package.json");
89
+ if (!existsSync(pkgJsonPath)) {
90
+ return [];
91
+ }
92
+ try {
93
+ const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
94
+ if (pkg.name?.startsWith("@kb-labs/")) {
95
+ results.push({ name: pkg.name, repo: repo.path, changedFiles: 1 });
96
+ }
97
+ } catch {
98
+ }
99
+ return results;
100
+ }
101
+ for (const entry of readdirSync(packagesDir, { withFileTypes: true })) {
102
+ if (!entry.isDirectory() || entry.name.startsWith(".")) {
103
+ continue;
104
+ }
105
+ const pkgJsonPath = join(packagesDir, entry.name, "package.json");
106
+ if (!existsSync(pkgJsonPath)) {
107
+ continue;
108
+ }
109
+ try {
110
+ const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
111
+ if (!pkg.name?.startsWith("@kb-labs/")) {
112
+ continue;
113
+ }
114
+ const pointerSha = getSubmodulePointer(workspaceRoot, repo.path);
115
+ let changedFiles = 0;
116
+ if (pointerSha) {
117
+ const diff = git(fullRepoPath, `diff ${pointerSha}..HEAD --name-only -- packages/${entry.name}/src/`);
118
+ changedFiles = diff ? diff.split("\n").filter(Boolean).length : 0;
119
+ } else {
120
+ const status = git(fullRepoPath, `status --porcelain -- packages/${entry.name}/src/`);
121
+ changedFiles = status ? status.split("\n").filter(Boolean).length : 0;
122
+ }
123
+ if (changedFiles > 0) {
124
+ results.push({ name: pkg.name, repo: repo.path, changedFiles });
125
+ }
126
+ } catch {
127
+ }
128
+ }
129
+ return results;
130
+ }
131
+ function detectChangedPackages(workspaceRoot) {
132
+ const repos = listSubRepos(workspaceRoot);
133
+ const changed = [];
134
+ for (const repo of repos) {
135
+ const fullPath = join(workspaceRoot, repo.path);
136
+ if (!existsSync(join(fullPath, ".git"))) {
137
+ continue;
138
+ }
139
+ const pointerSha = getSubmodulePointer(workspaceRoot, repo.path);
140
+ const actualSha = getActualHead(fullPath);
141
+ if (pointerSha && pointerSha === actualSha) {
142
+ continue;
143
+ }
144
+ if (pointerSha === actualSha) {
145
+ const dirty = git(fullPath, "status --porcelain");
146
+ if (!dirty) {
147
+ continue;
148
+ }
149
+ }
150
+ const pkgs = findPackagesInRepo(workspaceRoot, repo);
151
+ changed.push(...pkgs);
152
+ }
153
+ return changed;
154
+ }
155
+ function discoverPackages(workspaceRoot) {
156
+ const repos = listSubRepos(workspaceRoot);
157
+ const packages = [];
158
+ for (const repo of repos) {
159
+ const fullRepoPath = join(workspaceRoot, repo.path);
160
+ const packagesDir = join(fullRepoPath, "packages");
161
+ const dirs = existsSync(packagesDir) ? readdirSync(packagesDir, { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => join(packagesDir, d.name)) : [fullRepoPath];
162
+ for (const dir of dirs) {
163
+ const pkgPath = join(dir, "package.json");
164
+ if (!existsSync(pkgPath)) {
165
+ continue;
166
+ }
167
+ try {
168
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
169
+ if (!pkg.name?.startsWith("@kb-labs/")) {
170
+ continue;
171
+ }
172
+ const allDeps = { ...pkg.dependencies };
173
+ const kbDeps = Object.keys(allDeps).filter((d) => d.startsWith("@kb-labs/"));
174
+ packages.push({ name: pkg.name, repo: repo.path, deps: kbDeps });
175
+ } catch {
176
+ }
177
+ }
178
+ }
179
+ return packages;
180
+ }
181
+ function buildReverseDependencyGraph(workspaceRoot) {
182
+ const packages = discoverPackages(workspaceRoot);
183
+ const graph = /* @__PURE__ */ new Map();
184
+ for (const pkg of packages) {
185
+ graph.set(pkg.name, {
186
+ name: pkg.name,
187
+ repo: pkg.repo,
188
+ dependsOn: pkg.deps,
189
+ dependedBy: []
190
+ });
191
+ }
192
+ for (const pkg of packages) {
193
+ for (const dep of pkg.deps) {
194
+ const node = graph.get(dep);
195
+ if (node) {
196
+ node.dependedBy.push(pkg.name);
197
+ }
198
+ }
199
+ }
200
+ return graph;
201
+ }
202
+
203
+ // src/core/package-analyzer.ts
204
+ function analyzePackageImpact(changed, graph) {
205
+ const direct = [];
206
+ const dependent = [];
207
+ const transitive = [];
208
+ const changedNames = new Set(changed.map((c) => c.name));
209
+ const seen = /* @__PURE__ */ new Set();
210
+ for (const pkg of changed) {
211
+ direct.push({
212
+ name: pkg.name,
213
+ repo: pkg.repo,
214
+ level: "direct",
215
+ changedFiles: pkg.changedFiles
216
+ });
217
+ seen.add(pkg.name);
218
+ }
219
+ const queue = [];
220
+ for (const name of changedNames) {
221
+ const node = graph.get(name);
222
+ if (!node) {
223
+ continue;
224
+ }
225
+ for (const dep of node.dependedBy) {
226
+ if (!seen.has(dep)) {
227
+ queue.push({ name: dep, depth: 1 });
228
+ }
229
+ }
230
+ }
231
+ while (queue.length > 0) {
232
+ const { name, depth } = queue.shift();
233
+ if (seen.has(name)) {
234
+ continue;
235
+ }
236
+ seen.add(name);
237
+ const node = graph.get(name);
238
+ if (!node) {
239
+ continue;
240
+ }
241
+ const reasonPkg = node.dependsOn.find((d) => changedNames.has(d) || seen.has(d));
242
+ const impact = {
243
+ name: node.name,
244
+ repo: node.repo,
245
+ level: depth === 1 ? "dependent" : "transitive",
246
+ reason: reasonPkg ? `depends on ${reasonPkg}` : void 0
247
+ };
248
+ if (depth === 1) {
249
+ dependent.push(impact);
250
+ } else {
251
+ transitive.push(impact);
252
+ }
253
+ for (const dep of node.dependedBy) {
254
+ if (!seen.has(dep)) {
255
+ queue.push({ name: dep, depth: depth + 1 });
256
+ }
257
+ }
258
+ }
259
+ return { direct, dependent, transitive };
260
+ }
261
+
262
+ // src/core/doc-analyzer.ts
263
+ function matchesRule(packageName, pattern) {
264
+ if (pattern === packageName) {
265
+ return true;
266
+ }
267
+ if (pattern === "__new_package__") {
268
+ return false;
269
+ }
270
+ if (pattern.startsWith("*")) {
271
+ return packageName.endsWith(pattern.slice(1));
272
+ }
273
+ if (pattern.endsWith("*")) {
274
+ return packageName.startsWith(pattern.slice(0, -1));
275
+ }
276
+ return false;
277
+ }
278
+ function analyzeDocImpact(impactedPackages, config) {
279
+ const stale = [];
280
+ const review = [];
281
+ const reindex = [];
282
+ const seenDocs = /* @__PURE__ */ new Set();
283
+ for (const pkg of impactedPackages) {
284
+ for (const rule of config.docRules) {
285
+ if (!matchesRule(pkg.name, rule.match)) {
286
+ continue;
287
+ }
288
+ if (rule.action === "reindex") {
289
+ const key = `reindex:${rule.command ?? ""}`;
290
+ if (!seenDocs.has(key)) {
291
+ seenDocs.add(key);
292
+ reindex.push({
293
+ reason: `${pkg.name} changed`,
294
+ action: "reindex",
295
+ command: rule.command
296
+ });
297
+ }
298
+ continue;
299
+ }
300
+ for (const doc of rule.docs ?? []) {
301
+ const key = `${rule.action}:${doc}`;
302
+ if (seenDocs.has(key)) {
303
+ continue;
304
+ }
305
+ seenDocs.add(key);
306
+ const impact = {
307
+ file: doc,
308
+ reason: `${pkg.name} changed`,
309
+ action: rule.action,
310
+ command: rule.command
311
+ };
312
+ if (rule.action === "regenerate") {
313
+ stale.push(impact);
314
+ } else {
315
+ review.push(impact);
316
+ }
317
+ }
318
+ }
319
+ }
320
+ return { stale, review, reindex };
321
+ }
322
+ async function loadImpactRules(useConfigFn) {
323
+ if (useConfigFn) {
324
+ try {
325
+ const config = await useConfigFn();
326
+ if (config?.docRules?.length) {
327
+ return { docRules: config.docRules };
328
+ }
329
+ } catch {
330
+ }
331
+ }
332
+ return DEFAULT_IMPACT_CONFIG;
333
+ }
334
+
335
+ // src/core/formatter.ts
336
+ var BOLD = "\x1B[1m";
337
+ var DIM = "\x1B[2m";
338
+ var RESET = "\x1B[0m";
339
+ var RED = "\x1B[31m";
340
+ var YELLOW = "\x1B[33m";
341
+ var GREEN = "\x1B[32m";
342
+ var CYAN = "\x1B[36m";
343
+ function formatHumanReadable(result) {
344
+ const lines = [];
345
+ lines.push(`${BOLD}\u{1F4CA} Impact Analysis${RESET}`);
346
+ lines.push("");
347
+ const { direct, dependent, transitive } = result.packages;
348
+ const totalPkgs = direct.length + dependent.length + transitive.length;
349
+ if (totalPkgs > 0) {
350
+ lines.push(`${BOLD}\u{1F4E6} Package Impact${RESET}`);
351
+ if (direct.length > 0) {
352
+ lines.push(` ${GREEN}Direct (${direct.length}):${RESET}`);
353
+ for (const p of direct) {
354
+ lines.push(` ${p.name} ${DIM}(${p.repo})${RESET} \u2014 ${p.changedFiles} file${p.changedFiles === 1 ? "" : "s"} changed`);
355
+ }
356
+ }
357
+ if (dependent.length > 0) {
358
+ lines.push(` ${YELLOW}Dependent (${dependent.length}):${RESET}`);
359
+ for (const p of dependent) {
360
+ lines.push(` ${p.name} ${DIM}\u2190 ${p.reason}${RESET}`);
361
+ }
362
+ }
363
+ if (transitive.length > 0) {
364
+ lines.push(` ${DIM}Transitive (${transitive.length}):${RESET}`);
365
+ for (const p of transitive) {
366
+ lines.push(` ${p.name} ${DIM}\u2190 ${p.reason}${RESET}`);
367
+ }
368
+ }
369
+ lines.push("");
370
+ }
371
+ const { stale, review, reindex } = result.docs;
372
+ const totalDocs = stale.length + review.length + reindex.length;
373
+ if (totalDocs > 0) {
374
+ lines.push(`${BOLD}\u{1F4C4} Doc Impact${RESET}`);
375
+ if (stale.length > 0) {
376
+ lines.push(` ${YELLOW}Stale (${stale.length}):${RESET}`);
377
+ for (const d of stale) {
378
+ lines.push(` ${d.file} \u2014 ${d.reason}`);
379
+ if (d.command) {
380
+ lines.push(` ${CYAN}\u2192 Run: ${d.command}${RESET}`);
381
+ }
382
+ }
383
+ }
384
+ if (review.length > 0) {
385
+ lines.push(` ${GREEN}Review (${review.length}):${RESET}`);
386
+ for (const d of review) {
387
+ lines.push(` ${d.file} \u2014 ${d.reason}`);
388
+ }
389
+ }
390
+ if (reindex.length > 0) {
391
+ lines.push(` ${CYAN}Reindex (${reindex.length}):${RESET}`);
392
+ for (const d of reindex) {
393
+ lines.push(` ${d.reason}`);
394
+ if (d.command) {
395
+ lines.push(` ${CYAN}\u2192 Run: ${d.command}${RESET}`);
396
+ }
397
+ }
398
+ }
399
+ lines.push("");
400
+ }
401
+ const { mustRun, noTests } = result.tests;
402
+ const totalTests = mustRun.length + noTests.length;
403
+ if (totalTests > 0) {
404
+ lines.push(`${BOLD}\u{1F9EA} Test Impact${RESET}`);
405
+ if (mustRun.length > 0) {
406
+ lines.push(` ${GREEN}Must run (${mustRun.length}):${RESET}`);
407
+ for (const t of mustRun) {
408
+ const count = t.testCount ? ` \u2014 ${t.testCount} test file${t.testCount === 1 ? "" : "s"}` : "";
409
+ const reason = t.level === "direct" ? "changed" : t.reason ?? "";
410
+ lines.push(` ${t.name}${count} ${DIM}\u2190 ${reason}${RESET}`);
411
+ if (t.command) {
412
+ lines.push(` ${CYAN}\u2192 ${t.command}${RESET}`);
413
+ }
414
+ }
415
+ }
416
+ if (noTests.length > 0) {
417
+ lines.push(` ${RED}\u26A0\uFE0F No tests (${noTests.length}):${RESET}`);
418
+ for (const t of noTests) {
419
+ const reason = t.level === "direct" ? "changed, NO TESTS" : `${t.reason}, NO TESTS`;
420
+ lines.push(` ${RED}${t.name}${RESET} ${DIM}\u2190 ${reason}${RESET}`);
421
+ }
422
+ }
423
+ lines.push("");
424
+ }
425
+ if (result.recommendations.length > 0) {
426
+ lines.push(`${BOLD}\u26A0\uFE0F Recommendations:${RESET}`);
427
+ for (const rec of result.recommendations) {
428
+ lines.push(` \u2022 ${rec}`);
429
+ }
430
+ lines.push("");
431
+ }
432
+ if (totalPkgs === 0 && totalDocs === 0 && totalTests === 0) {
433
+ lines.push(`${GREEN}\u2705 No impact detected.${RESET}`);
434
+ }
435
+ return lines.join("\n");
436
+ }
437
+
438
+ // src/cli/commands/docs.ts
439
+ var docs_default = defineCommand({
440
+ id: "impact:docs",
441
+ description: "Documentation impact analysis",
442
+ handler: {
443
+ async execute(ctx, input) {
444
+ const flags = input.flags ?? input;
445
+ let root;
446
+ try {
447
+ root = findWorkspaceRoot();
448
+ } catch {
449
+ if (flags.json) {
450
+ ctx.ui?.json?.({ docs: { stale: [], review: [], reindex: [] } });
451
+ } else {
452
+ ctx.ui?.warn?.("Could not find workspace root");
453
+ }
454
+ return { exitCode: 1 };
455
+ }
456
+ const changed = detectChangedPackages(root);
457
+ if (changed.length === 0) {
458
+ const empty = { docs: { stale: [], review: [], reindex: [] }, recommendations: [] };
459
+ if (flags.json) {
460
+ ctx.ui?.json?.(empty);
461
+ } else {
462
+ ctx.ui?.success?.("No changes detected");
463
+ }
464
+ return { exitCode: 0, result: empty };
465
+ }
466
+ const graph = buildReverseDependencyGraph(root);
467
+ const packages = analyzePackageImpact(changed, graph);
468
+ const useConfigFn = async () => {
469
+ try {
470
+ const { useConfig } = await import('@kb-labs/sdk');
471
+ return await useConfig();
472
+ } catch {
473
+ return void 0;
474
+ }
475
+ };
476
+ const rules = await loadImpactRules(useConfigFn);
477
+ const allImpacted = [...packages.direct, ...packages.dependent];
478
+ const docs = analyzeDocImpact(allImpacted, rules);
479
+ const recommendations = [];
480
+ for (const d of docs.stale) {
481
+ if (d.command) {
482
+ recommendations.push(`Run: ${d.command}`);
483
+ }
484
+ }
485
+ for (const d of docs.reindex) {
486
+ if (d.command) {
487
+ recommendations.push(`Run: ${d.command}`);
488
+ }
489
+ }
490
+ const result = { docs, recommendations };
491
+ if (flags.json) {
492
+ ctx.ui?.json?.(result);
493
+ } else {
494
+ ctx.ui?.write?.(formatHumanReadable({
495
+ packages: { direct: [], dependent: [], transitive: [] },
496
+ docs,
497
+ tests: { mustRun: [], noTests: [] },
498
+ recommendations
499
+ }));
500
+ }
501
+ return { exitCode: 0, result };
502
+ }
503
+ }
504
+ });
505
+
506
+ export { docs_default as default };
507
+ //# sourceMappingURL=docs.js.map
508
+ //# sourceMappingURL=docs.js.map