@ankhorage/doctor 0.12.16 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2f38cf5: Adopt canonical Contracts Capability descriptors for Doctor provider metadata and validate package/provider capability catalogs with the shared runtime API.
8
+
3
9
  ## 0.12.16
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # @ankhorage/doctor
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v0.12.16](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v0.13.0](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
7
7
 
8
8
  Executable Ankh provider and standalone CLI for lightweight repo and package compliance diagnostics.
9
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,MAAM,MAAM,iBAAi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AAS,gBAAgB,EAAE,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACxD,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AA+BD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CA+I/B"}
package/dist/analysis.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { promises as fs } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
+ import { areCapabilitiesEqual, isCapability, normalizeCapability, } from '@ankhorage/contracts/capabilities';
4
5
  import { REPOSITORY_RULE_METADATA } from '@ankhorage/rules-repository';
5
6
  import { uniqueSortedStrings } from '@ankhorage/utility/array';
6
7
  import { getRepositoryRule } from './utils/getRepositoryRule.js';
@@ -427,22 +428,20 @@ async function validateAnkhMetadataAndProvider(request) {
427
428
  if (inspection.result === null) {
428
429
  return diagnostics;
429
430
  }
430
- const metadataCapabilities = Array.isArray(metadata.capabilities)
431
- ? metadata.capabilities.filter(isNonEmptyString)
432
- : [];
433
- const providerCapabilities = uniqueSortedStrings(inspection.result.capabilities);
431
+ const metadataCapabilities = readCapabilities(metadata.capabilities);
432
+ const providerCapabilities = inspection.result.capabilities;
434
433
  const commandCapabilities = uniqueSortedStrings(inspection.result.commandCapabilities);
435
- if (!sameStringSet(metadataCapabilities, commandCapabilities)) {
434
+ if (!sameCapabilitySet(metadataCapabilities, providerCapabilities)) {
436
435
  diagnostics.push(createDiagnostic({
437
436
  code: 'field-invalid',
438
- message: 'package.json.ankh capabilities must match the implemented provider command capabilities exactly.',
437
+ message: 'package.json.ankh capabilities must match the implemented provider capability descriptors exactly.',
439
438
  path: request.packageJsonPath,
440
439
  profile: request.profile,
441
440
  ruleId: 'package.ankh.capabilities.match-provider',
442
441
  severity: 'error',
443
442
  }));
444
443
  }
445
- if (!sameStringSet(providerCapabilities, commandCapabilities)) {
444
+ if (!sameStringSet(providerCapabilities.map((capability) => capability.id), commandCapabilities)) {
446
445
  diagnostics.push(createDiagnostic({
447
446
  code: 'field-invalid',
448
447
  message: 'Provider export capabilities must match the provider command capability surface.',
@@ -495,7 +494,7 @@ async function inspectProviderSource(request) {
495
494
  result: null,
496
495
  };
497
496
  }
498
- const capabilities = readStringArray(provider.capabilities);
497
+ const capabilities = readCapabilities(provider.capabilities);
499
498
  const commands = Array.isArray(provider.commands) ? provider.commands : [];
500
499
  const handlers = Array.isArray(provider.handlers) ? provider.handlers : [];
501
500
  const commandCapabilities = commands.flatMap((command) => isRecord(command) && isNonEmptyString(command.capability) ? [command.capability] : []);
@@ -736,8 +735,8 @@ function validateAnkhMetadataShape(value, providerPackage) {
736
735
  return 'Non-provider package metadata, when present, must use null or a package-relative "./..." provider value.';
737
736
  }
738
737
  if (!Array.isArray(value.capabilities) ||
739
- value.capabilities.some((capability) => !isNonEmptyString(capability))) {
740
- return 'package.json "ankh.capabilities" must be an array of non-empty strings.';
738
+ value.capabilities.some((capability) => !isCapability(capability))) {
739
+ return 'package.json "ankh.capabilities" must be an array of canonical Capability descriptors.';
741
740
  }
742
741
  return null;
743
742
  }
@@ -806,6 +805,22 @@ function isStringTuple(value) {
806
805
  function readStringArray(value) {
807
806
  return Array.isArray(value) ? value.filter(isNonEmptyString) : [];
808
807
  }
808
+ /*** Read and normalize canonical Capability descriptors from untrusted metadata. */
809
+ function readCapabilities(value) {
810
+ return Array.isArray(value) ? value.filter(isCapability).map(normalizeCapability) : [];
811
+ }
812
+ /*** Compare capability collections by canonical id and descriptor semantics. */
813
+ function sameCapabilitySet(left, right) {
814
+ const leftById = new Map(left.map((capability) => [capability.id, capability]));
815
+ const rightById = new Map(right.map((capability) => [capability.id, capability]));
816
+ return (leftById.size === left.length &&
817
+ rightById.size === right.length &&
818
+ leftById.size === rightById.size &&
819
+ [...leftById].every(([id, capability]) => {
820
+ const other = rightById.get(id);
821
+ return other !== undefined && areCapabilitiesEqual(capability, other);
822
+ }));
823
+ }
809
824
  function sameStringSet(left, right) {
810
825
  const leftSet = uniqueSortedStrings(left);
811
826
  const rightSet = uniqueSortedStrings(right);
@@ -1 +1 @@
1
- {"version":3,"file":"analysis.js","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAI/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAgDjE,MAAM,YAAY,GAAG;IACnB,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IACvC,EAAE,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE;IAC/E,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE;I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B,CAAC,KAAK,CAAC,CAAC;IAC5C,OAAO,CACL,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CACjG,CAAC;AACJ,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { REPOSITORY_RULE_METADATA } from '@ankhorage/rules-repository';\nimport { uniqueSortedStrings } from '@ankhorage/utility/array';\n\nimport type { DoctorDiagnostic, DoctorPolicyProfile, DoctorRuleId } from './diagnostics.js';\nimport type { DoctorReadiness } from './readiness.js';\nimport { getRepositoryRule } from './utils/getRepositoryRule.js';\n\nexport type DoctorTargetCheck = 'manifest' | 'package' | 'repo';\nexport type DoctorTargetMode = 'fix' | 'package' | 'repo' | 'validate';\nexport type DoctorPlannedChangeKind =\n 'create-directory' | 'create-file' | 'update-json' | 'update-text';\n\nexport interface DoctorAnalysisRequest {\n readonly cwd: string;\n readonly inputPath?: string;\n readonly mode: DoctorTargetMode;\n}\n\nexport interface DoctorPlannedChange {\n readonly description: string;\n readonly filePath: string;\n readonly kind: DoctorPlannedChangeKind;\n readonly ruleId: DoctorRuleId;\n readonly safe: boolean;\n}\n\nexport interface DoctorFixPlan {\n readonly changes: readonly DoctorPlannedChange[];\n readonly diagnostics: readonly DoctorDiagnostic[];\n readonly profile: DoctorPolicyProfile;\n readonly targetPath: string;\n}\n\nexport interface DoctorAnalysisResult {\n readonly appliedChecks: readonly DoctorTargetCheck[];\n readonly diagnostics: readonly DoctorDiagnostic[];\n readonly fixPlan: DoctorFixPlan | null;\n readonly hasPackageJson: boolean;\n readonly plannedChanges: readonly DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly readiness?: readonly DoctorReadiness[];\n readonly repoMarkers: readonly string[];\n readonly targetPath: string;\n}\n\ninterface ProviderInspectionResult {\n readonly capabilities: readonly string[];\n readonly commandCapabilities: readonly string[];\n readonly commandPaths: readonly string[];\n readonly handlerPaths: readonly string[];\n readonly sourcePath: string;\n}\n\nconst REPO_MARKERS = [\n { label: '.git', relativePath: '.git' },\n { label: '.github/workflows', relativePath: path.join('.github', 'workflows') },\n { label: '.changeset', relativePath: '.changeset' },\n { label: 'package.json', relativePath: 'package.json' },\n { label: 'pnpm-workspace.yaml', relativePath: 'pnpm-workspace.yaml' },\n { label: 'bun.lock', relativePath: 'bun.lock' },\n { label: 'bun.lockb', relativePath: 'bun.lockb' },\n { label: 'package-lock.json', relativePath: 'package-lock.json' },\n { label: 'yarn.lock', relativePath: 'yarn.lock' },\n] as const;\n\nconst PUBLIC_PACKAGE_POLICY = REPOSITORY_RULE_METADATA.publicPackage;\n\nconst PROVIDER_SOURCE_CANDIDATES = [\n path.join('src', 'ankh.provider.ts'),\n path.join('src', 'ankh.provider.tsx'),\n path.join('src', 'ankh.provider.js'),\n path.join('src', 'ankh.provider.mjs'),\n] as const;\n\nexport async function analyzeDoctorTarget(\n request: DoctorAnalysisRequest,\n): Promise<DoctorAnalysisResult> {\n const targetPath = path.resolve(request.cwd, request.inputPath ?? '.');\n const stats = await statOrNull(targetPath);\n\n if (stats === null) {\n return createEarlyResult(\n targetPath,\n createDiagnostic({\n code: 'target-not-found',\n message: `Target path does not exist: ${targetPath}`,\n path: targetPath,\n profile: 'unknown',\n ruleId: 'target.path.exists',\n severity: 'error',\n }),\n );\n }\n\n if (!stats.isDirectory()) {\n return createEarlyResult(\n targetPath,\n createDiagnostic({\n code: 'target-not-directory',\n message: `Target path must be a directory: ${targetPath}`,\n path: targetPath,\n profile: 'unknown',\n ruleId: 'target.path.directory',\n severity: 'error',\n }),\n );\n }\n\n const repoMarkers = await findRepoMarkers(targetPath);\n const packageJsonPath = path.join(targetPath, 'package.json');\n const hasPackageJson = repoMarkers.includes('package.json');\n const appliedChecks: DoctorTargetCheck[] = [];\n const diagnostics: DoctorDiagnostic[] = [];\n const plannedChanges: DoctorPlannedChange[] = [];\n\n const packageJson = hasPackageJson ? await readPackageJson(packageJsonPath) : null;\n if (packageJson !== null && packageJson.diagnostic !== null) {\n diagnostics.push(packageJson.diagnostic);\n }\n\n const profile = detectProfile(repoMarkers, packageJson?.parsed ?? null);\n\n const shouldRunRepoChecks =\n request.mode === 'repo' ||\n ((request.mode === 'validate' || request.mode === 'fix') && repoMarkers.length > 0);\n const shouldRunPackageChecks =\n request.mode === 'package' ||\n ((request.mode === 'validate' || request.mode === 'fix') && hasPackageJson);\n\n if (request.mode === 'repo' && repoMarkers.length === 0) {\n diagnostics.push(\n createDiagnostic({\n code: 'unsupported-target',\n message:\n 'Target is not a repo/workspace-root candidate because no repo markers were found.',\n path: targetPath,\n profile,\n ruleId: 'target.repo-markers.required',\n severity: 'error',\n }),\n );\n }\n\n if (request.mode === 'package' && !hasPackageJson) {\n diagnostics.push(\n createDiagnostic({\n code: 'unsupported-target',\n message: 'Target does not contain a readable package.json file.',\n path: packageJsonPath,\n profile,\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n );\n }\n\n if (\n (request.mode === 'validate' || request.mode === 'fix') &&\n repoMarkers.length === 0 &&\n !hasPackageJson\n ) {\n diagnostics.push(\n createDiagnostic({\n code: 'unsupported-target',\n message: 'Target is neither a repo/workspace-root candidate nor a package root.',\n path: targetPath,\n profile,\n ruleId: 'target.profile.supported',\n severity: 'error',\n }),\n );\n }\n\n if (shouldRunRepoChecks && repoMarkers.length > 0) {\n appliedChecks.push('repo');\n diagnostics.push(\n ...(await analyzeRepoPolicy({\n packageJson: packageJson?.parsed ?? null,\n plannedChanges,\n profile,\n repoMarkers,\n targetPath,\n })),\n );\n }\n\n if (shouldRunPackageChecks && hasPackageJson) {\n appliedChecks.push('package');\n diagnostics.push(\n ...(await analyzePackagePolicy({\n packageJson: packageJson?.parsed ?? null,\n packageJsonPath,\n plannedChanges,\n profile,\n targetPath,\n })),\n );\n }\n\n const fixPlan =\n request.mode === 'fix'\n ? {\n changes: plannedChanges,\n diagnostics,\n profile,\n targetPath,\n }\n : null;\n\n return {\n appliedChecks,\n diagnostics,\n fixPlan,\n hasPackageJson,\n plannedChanges,\n profile,\n repoMarkers,\n targetPath,\n };\n}\n\nasync function analyzeRepoPolicy(request: {\n readonly packageJson: Record<string, unknown> | null;\n readonly plannedChanges: DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly repoMarkers: readonly string[];\n readonly targetPath: string;\n}): Promise<DoctorDiagnostic[]> {\n const diagnostics: DoctorDiagnostic[] = [];\n\n if (request.profile === 'public-package') {\n for (const artifact of PUBLIC_PACKAGE_POLICY.requiredRepoPaths) {\n await maybeRequirePath(\n diagnostics,\n request.plannedChanges,\n request.targetPath,\n artifact.path,\n artifact.ruleId,\n artifact.kind === 'file' ? 'create-file' : 'create-directory',\n );\n }\n }\n\n if (request.profile === 'integration-monorepo') {\n if (!request.repoMarkers.includes('package.json')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-path',\n message: 'The integration monorepo root must include a package.json file.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n );\n }\n\n if (request.packageJson !== null) {\n if (request.packageJson.ankh !== undefined) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message:\n 'The integration monorepo root must not publish top-level package.json.ankh metadata.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'integration.package.ankh.disallowed',\n severity: 'error',\n }),\n );\n }\n\n if (request.packageJson.private !== true) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'The integration monorepo root must remain private.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'integration.package.private.required',\n severity: 'error',\n }),\n );\n }\n\n if (!Array.isArray(request.packageJson.workspaces)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: 'The integration monorepo root must declare workspaces.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'integration.package.workspaces.required',\n severity: 'error',\n }),\n );\n }\n }\n }\n\n return diagnostics;\n}\n\nasync function analyzePackagePolicy(request: {\n readonly packageJson: Record<string, unknown> | null;\n readonly packageJsonPath: string;\n readonly plannedChanges: DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly targetPath: string;\n}): Promise<DoctorDiagnostic[]> {\n if (request.packageJson === null) {\n return [];\n }\n\n const diagnostics: DoctorDiagnostic[] = [];\n const { packageJson } = request;\n\n if (request.profile === 'public-package') {\n requirePublicPackageFields({\n diagnostics,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n profile: request.profile,\n });\n }\n\n if (request.profile !== 'public-package') {\n return diagnostics.concat(\n await validateAnkhMetadataAndProvider({\n diagnostics,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n plannedChanges: request.plannedChanges,\n profile: request.profile,\n targetPath: request.targetPath,\n }),\n );\n }\n\n if (packageJson.private === true) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'Public package profiles must not set private: true.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.privateDisallowedRuleId),\n }),\n );\n }\n\n if (\n packageJson.type !== undefined &&\n packageJson.type !== PUBLIC_PACKAGE_POLICY.packageType.value\n ) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: `package.json \"type\" must be \"${PUBLIC_PACKAGE_POLICY.packageType.value}\".`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.packageType.ruleId),\n }),\n );\n }\n\n const { publishConfig } = packageJson;\n if (\n isRecord(publishConfig) &&\n publishConfig.access !== PUBLIC_PACKAGE_POLICY.publishAccess.value\n ) {\n diagnostics.push(\n createDiagnostic({\n code: isNonEmptyString(publishConfig.access) ? 'field-invalid' : 'field-missing',\n message: `package.json publishConfig.access must exist and equal \"${PUBLIC_PACKAGE_POLICY.publishAccess.value}\".`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.publishAccess.ruleId),\n }),\n );\n }\n\n if (!isNonEmptyString(packageJson.packageManager)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: 'package.json must define a Bun-aligned packageManager field.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.packageManager.requiredRuleId),\n }),\n );\n request.plannedChanges.push(\n createPlannedChange({\n description: `Add packageManager: \"bun@${Bun.version}\" to package.json.`,\n filePath: request.packageJsonPath,\n kind: 'update-json',\n ruleId: PUBLIC_PACKAGE_POLICY.packageManager.requiredRuleId,\n }),\n );\n } else if (!packageJson.packageManager.startsWith('bun@')) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'package.json packageManager must be Bun-aligned, for example \"bun@1.x\".',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.packageManager.bunRuleId),\n }),\n );\n }\n\n const scripts = isRecord(packageJson.scripts) ? packageJson.scripts : null;\n for (const requirement of PUBLIC_PACKAGE_POLICY.requiredScripts) {\n if (scripts === null || !isNonEmptyString(scripts[requirement.name])) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-script',\n message: `Missing required package script: ${requirement.name}`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(requirement.ruleId),\n }),\n );\n }\n }\n\n const devDependencies = isRecord(packageJson.devDependencies)\n ? packageJson.devDependencies\n : null;\n const dependencies = isRecord(packageJson.dependencies) ? packageJson.dependencies : null;\n if (!hasDependency(dependencies, 'typescript') && !hasDependency(devDependencies, 'typescript')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'Public package repos must declare TypeScript in dependencies or devDependencies.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.typescript),\n }),\n );\n }\n\n const changesetsDependencyDiagnostic = createChangesetsDependencyDiagnostic({\n dependencies,\n devDependencies,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n profile: request.profile,\n });\n if (changesetsDependencyDiagnostic !== null) {\n diagnostics.push(changesetsDependencyDiagnostic);\n }\n\n if (!hasDependency(devDependencies, '@types/bun')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'Public package repos must declare @types/bun in devDependencies.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.bunTypes),\n }),\n );\n }\n\n if (!hasDependency(devDependencies, '@types/node')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'Public package repos must declare @types/node in devDependencies.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.nodeTypes),\n }),\n );\n }\n\n if (expectsDevtools(packageJson) && !hasDependency(devDependencies, '@ankhorage/devtools')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message:\n 'This package consumes shared Ankhorage lint/format/knip tooling and must declare @ankhorage/devtools.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.devtools),\n }),\n );\n }\n\n if (\n packageJson.name !== '@ankhorage/paradox' &&\n (await expectsParadox(request.targetPath, packageJson)) &&\n !hasDependency(devDependencies, '@ankhorage/paradox')\n ) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'This package owns Paradox docs generation and must declare @ankhorage/paradox.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.paradox),\n }),\n );\n }\n\n return diagnostics.concat(\n await validateAnkhMetadataAndProvider({\n diagnostics,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n plannedChanges: request.plannedChanges,\n profile: request.profile,\n targetPath: request.targetPath,\n }),\n );\n}\n\nfunction createChangesetsDependencyDiagnostic(request: {\n readonly dependencies: Record<string, unknown> | null;\n readonly devDependencies: Record<string, unknown> | null;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n}): DoctorDiagnostic | null {\n const dependencyDeclared = hasDependency(request.dependencies, '@changesets/cli');\n const devDependencyDeclared = hasDependency(request.devDependencies, '@changesets/cli');\n const isDevtoolsOwner = request.packageJson.name === '@ankhorage/devtools';\n const placementIsCurrent = isDevtoolsOwner\n ? dependencyDeclared && !devDependencyDeclared\n : !dependencyDeclared && !devDependencyDeclared;\n\n if (placementIsCurrent) {\n return null;\n }\n\n return createDiagnostic({\n code: isDevtoolsOwner ? 'missing-dependency' : 'field-invalid',\n message: isDevtoolsOwner\n ? '@ankhorage/devtools must publish @changesets/cli in dependencies, not devDependencies.'\n : 'Public package repos must not declare @changesets/cli directly; @ankhorage/devtools owns Changesets execution.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.changesets),\n });\n}\n\nasync function validateAnkhMetadataAndProvider(request: {\n readonly diagnostics: readonly DoctorDiagnostic[];\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly plannedChanges: DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly targetPath: string;\n}): Promise<DoctorDiagnostic[]> {\n const diagnostics: DoctorDiagnostic[] = [];\n const metadata = request.packageJson.ankh;\n const providerPackage =\n (isRecord(metadata) && isNonEmptyString(metadata.provider)) ||\n (await isProviderPackage(request.targetPath));\n\n if (providerPackage && metadata === undefined) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: 'Provider packages must define package.json.ankh metadata.',\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.required-for-provider',\n severity: 'error',\n }),\n );\n request.plannedChanges.push(\n createPlannedChange({\n description:\n 'Add a package.json.ankh block describing the implemented provider category, provider path, and capabilities.',\n filePath: request.packageJsonPath,\n kind: 'update-json',\n ruleId: 'package.ankh.required-for-provider',\n }),\n );\n return diagnostics;\n }\n\n if (metadata === undefined) {\n return diagnostics;\n }\n\n const metadataValidation = validateAnkhMetadataShape(metadata, providerPackage);\n if (metadataValidation !== null) {\n diagnostics.push(\n createDiagnostic({\n code: 'invalid-ankh-metadata',\n message: metadataValidation,\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.present.valid-shape',\n severity: 'error',\n }),\n );\n return diagnostics;\n }\n\n if (!providerPackage) {\n return diagnostics;\n }\n\n if (!isRecord(metadata) || !isNonEmptyString(metadata.provider)) {\n diagnostics.push(\n createDiagnostic({\n code: 'invalid-ankh-metadata',\n message: 'Provider package metadata must define a package-relative provider path.',\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.provider-path.required',\n severity: 'error',\n }),\n );\n return diagnostics;\n }\n\n const inspection = await inspectProviderSource({\n metadataProviderPath: metadata.provider,\n packageRoot: request.targetPath,\n profile: request.profile,\n });\n\n if (inspection.diagnostic !== null) {\n diagnostics.push(inspection.diagnostic);\n return diagnostics;\n }\n\n if (inspection.result === null) {\n return diagnostics;\n }\n\n const metadataCapabilities = Array.isArray(metadata.capabilities)\n ? metadata.capabilities.filter(isNonEmptyString)\n : [];\n const providerCapabilities = uniqueSortedStrings(inspection.result.capabilities);\n const commandCapabilities = uniqueSortedStrings(inspection.result.commandCapabilities);\n\n if (!sameStringSet(metadataCapabilities, commandCapabilities)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message:\n 'package.json.ankh capabilities must match the implemented provider command capabilities exactly.',\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.capabilities.match-provider',\n severity: 'error',\n }),\n );\n }\n\n if (!sameStringSet(providerCapabilities, commandCapabilities)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'Provider export capabilities must match the provider command capability surface.',\n path: inspection.result.sourcePath,\n profile: request.profile,\n ruleId: 'provider.commands.match-capabilities',\n severity: 'error',\n }),\n );\n }\n\n if (!sameStringSet(inspection.result.commandPaths, inspection.result.handlerPaths)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'Every provider command descriptor must have a matching handler path.',\n path: inspection.result.sourcePath,\n profile: request.profile,\n ruleId: 'provider.commands.match-handlers',\n severity: 'error',\n }),\n );\n }\n\n return diagnostics;\n}\n\nasync function inspectProviderSource(request: {\n readonly metadataProviderPath: string;\n readonly packageRoot: string;\n readonly profile: DoctorPolicyProfile;\n}): Promise<{\n readonly diagnostic: DoctorDiagnostic | null;\n readonly result: ProviderInspectionResult | null;\n}> {\n const sourcePath = await resolveProviderSourcePath(\n request.packageRoot,\n request.metadataProviderPath,\n );\n if (sourcePath === null) {\n return {\n diagnostic: createDiagnostic({\n code: 'provider-source-missing',\n message:\n 'Provider package metadata is present, but no provider source file could be resolved for inspection.',\n path: request.packageRoot,\n profile: request.profile,\n ruleId: 'provider.source.required',\n severity: 'error',\n }),\n result: null,\n };\n }\n\n try {\n const importedModule: unknown = await import(pathToFileURL(sourcePath).href);\n const provider = isRecord(importedModule) ? importedModule.default : undefined;\n if (!isRecord(provider)) {\n return {\n diagnostic: createDiagnostic({\n code: 'provider-source-import-failed',\n message: 'Provider source default export must be an object.',\n path: sourcePath,\n profile: request.profile,\n ruleId: 'provider.source.importable',\n severity: 'error',\n }),\n result: null,\n };\n }\n\n const capabilities = readStringArray(provider.capabilities);\n const commands = Array.isArray(provider.commands) ? provider.commands : [];\n const handlers = Array.isArray(provider.handlers) ? provider.handlers : [];\n\n const commandCapabilities = commands.flatMap((command) =>\n isRecord(command) && isNonEmptyString(command.capability) ? [command.capability] : [],\n );\n const commandPaths = commands.flatMap((command) => {\n const pathValue = isRecord(command) ? command.path : undefined;\n return isStringTuple(pathValue) ? [pathValue.join(' ')] : [];\n });\n const handlerPaths = handlers.flatMap((handler) => {\n const pathValue = isRecord(handler) ? handler.path : undefined;\n const handlerFunction = isRecord(handler) ? handler.handler : undefined;\n return isStringTuple(pathValue) && typeof handlerFunction === 'function'\n ? [pathValue.join(' ')]\n : [];\n });\n\n return {\n diagnostic: null,\n result: {\n capabilities,\n commandCapabilities,\n commandPaths,\n handlerPaths,\n sourcePath,\n },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n diagnostic: createDiagnostic({\n code: 'provider-source-import-failed',\n message: `Failed to import provider source: ${message}`,\n path: sourcePath,\n profile: request.profile,\n ruleId: 'provider.source.importable',\n severity: 'error',\n }),\n result: null,\n };\n }\n}\n\nasync function resolveProviderSourcePath(\n packageRoot: string,\n metadataProviderPath: string,\n): Promise<string | null> {\n const candidates = new Set<string>();\n candidates.add(path.resolve(packageRoot, metadataProviderPath));\n\n if (metadataProviderPath.startsWith('./dist/') && metadataProviderPath.endsWith('.js')) {\n const relativeStem = metadataProviderPath.slice('./dist/'.length, -'.js'.length);\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.ts`));\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.tsx`));\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.js`));\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.mjs`));\n }\n\n for (const providerSourceCandidate of PROVIDER_SOURCE_CANDIDATES) {\n candidates.add(path.resolve(packageRoot, providerSourceCandidate));\n }\n\n for (const candidate of candidates) {\n if (await pathExists(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\nasync function findRepoMarkers(targetPath: string): Promise<readonly string[]> {\n return (\n await Promise.all(\n REPO_MARKERS.map(async (marker) =>\n (await pathExists(path.join(targetPath, marker.relativePath))) ? marker.label : null,\n ),\n )\n ).filter((marker): marker is (typeof REPO_MARKERS)[number]['label'] => marker !== null);\n}\n\nasync function readPackageJson(packageJsonPath: string): Promise<{\n readonly diagnostic: DoctorDiagnostic | null;\n readonly parsed: Record<string, unknown> | null;\n}> {\n let parsed: unknown;\n\n try {\n parsed = JSON.parse(await fs.readFile(packageJsonPath, 'utf8')) as unknown;\n } catch (error) {\n return {\n diagnostic: createDiagnostic({\n code: 'invalid-package-json',\n message: createInvalidPackageJsonMessage(error),\n path: packageJsonPath,\n profile: 'unknown',\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n parsed: null,\n };\n }\n\n if (!isRecord(parsed)) {\n return {\n diagnostic: createDiagnostic({\n code: 'invalid-package-json',\n message: 'package.json must contain a JSON object.',\n path: packageJsonPath,\n profile: 'unknown',\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n parsed: null,\n };\n }\n\n return {\n diagnostic: null,\n parsed,\n };\n}\n\nfunction detectProfile(\n repoMarkers: readonly string[],\n packageJson: Record<string, unknown> | null,\n): DoctorPolicyProfile {\n if (packageJson !== null) {\n if (packageJson.name === 'ankhorage4') {\n return 'integration-monorepo';\n }\n\n if (isNonEmptyString(packageJson.name) && packageJson.name.startsWith('@ankhorage/')) {\n return packageJson.private === true ? 'unknown' : 'public-package';\n }\n }\n\n if (repoMarkers.length > 0) {\n return 'unknown';\n }\n\n return 'unknown';\n}\n\nasync function isProviderPackage(targetPath: string): Promise<boolean> {\n for (const candidate of PROVIDER_SOURCE_CANDIDATES) {\n if (await pathExists(path.join(targetPath, candidate))) {\n return true;\n }\n }\n\n return false;\n}\n\n/*** Validate every generic public-package metadata field from canonical Policy. */\nfunction requirePublicPackageFields(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n}): void {\n for (const requirement of PUBLIC_PACKAGE_POLICY.requiredFields) {\n const input = {\n diagnostics: request.diagnostics,\n fieldName: requirement.name,\n packageJson: request.packageJson,\n packageJsonPath: request.packageJsonPath,\n profile: request.profile,\n ruleId: requirement.ruleId,\n };\n\n switch (requirement.kind) {\n case 'non-empty-string':\n requireNonEmptyStringField(input);\n break;\n case 'record':\n requireRecordField(input);\n break;\n case 'string-array':\n requireStringArrayField(input);\n break;\n }\n }\n}\n\nasync function maybeRequirePath(\n diagnostics: DoctorDiagnostic[],\n plannedChanges: DoctorPlannedChange[],\n rootPath: string,\n relativePath: string,\n ruleId:\n | 'repo.changelog.required'\n | 'repo.changeset.required'\n | 'repo.license.required'\n | 'repo.readme.required'\n | 'repo.workflows.required',\n kind: DoctorPlannedChangeKind,\n): Promise<void> {\n const absolutePath = path.join(rootPath, relativePath);\n if (await pathExists(absolutePath)) {\n return;\n }\n\n diagnostics.push(\n createDiagnostic({\n code: 'missing-path',\n message: `Missing expected repo artifact: ${relativePath}`,\n path: absolutePath,\n profile: 'public-package',\n ...repositoryRuleFields(ruleId),\n }),\n );\n plannedChanges.push(\n createPlannedChange({\n description: `Create missing ${relativePath}.`,\n filePath: absolutePath,\n kind,\n ruleId,\n }),\n );\n}\n\nfunction requireNonEmptyStringField(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly fieldName: string;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n readonly ruleId: DoctorRuleId;\n}): void {\n if (isNonEmptyString(request.packageJson[request.fieldName])) {\n return;\n }\n\n request.diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: `package.json must define a non-empty \"${request.fieldName}\" field.`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(request.ruleId),\n }),\n );\n}\n\nfunction requireRecordField(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly fieldName: string;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n readonly ruleId: DoctorRuleId;\n}): void {\n if (isRecord(request.packageJson[request.fieldName])) {\n return;\n }\n\n request.diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: `package.json must define an object \"${request.fieldName}\" field.`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(request.ruleId),\n }),\n );\n}\n\nfunction requireStringArrayField(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly fieldName: string;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n readonly ruleId: DoctorRuleId;\n}): void {\n if (readStringArray(request.packageJson[request.fieldName]).length > 0) {\n return;\n }\n\n request.diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: `package.json must define a non-empty string array \"${request.fieldName}\" field.`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(request.ruleId),\n }),\n );\n}\n\nasync function expectsParadox(\n targetPath: string,\n packageJson: Record<string, unknown>,\n): Promise<boolean> {\n const scripts = isRecord(packageJson.scripts) ? packageJson.scripts : null;\n const docsScript = scripts?.docs;\n if (\n isNonEmptyString(docsScript) &&\n (docsScript.includes('paradox') || docsScript.includes('@ankhorage/paradox'))\n ) {\n return true;\n }\n\n return (\n (await pathExists(path.join(targetPath, 'paradox.config.ts'))) ||\n (await pathExists(path.join(targetPath, 'src', 'readme-usage.ts')))\n );\n}\n\nfunction expectsDevtools(packageJson: Record<string, unknown>): boolean {\n const scripts = isRecord(packageJson.scripts) ? packageJson.scripts : null;\n if (scripts === null) {\n return false;\n }\n\n return Object.values(scripts).some(\n (scriptValue) =>\n isNonEmptyString(scriptValue) &&\n (scriptValue.includes('ankhorage-eslint') ||\n scriptValue.includes('ankhorage-prettier') ||\n scriptValue.includes('ankhorage-knip')),\n );\n}\n\nfunction hasDependency(\n dependencyMap: Record<string, unknown> | null,\n dependencyName: string,\n): boolean {\n return dependencyMap !== null && isNonEmptyString(dependencyMap[dependencyName]);\n}\n\nfunction validateAnkhMetadataShape(value: unknown, providerPackage: boolean): string | null {\n if (!isRecord(value)) {\n return 'package.json \"ankh\" metadata must be an object when present.';\n }\n\n if (!isNonEmptyString(value.category)) {\n return 'package.json \"ankh.category\" must be a non-empty string.';\n }\n\n if (\n providerPackage &&\n !(isNonEmptyString(value.provider) && isPackageRelativeProviderPath(value.provider))\n ) {\n return 'Provider package metadata must define a package-relative \"./...\" provider path.';\n }\n\n if (\n !providerPackage &&\n value.provider !== undefined &&\n !(value.provider === null || isPackageRelativeProviderPath(value.provider))\n ) {\n return 'Non-provider package metadata, when present, must use null or a package-relative \"./...\" provider value.';\n }\n\n if (\n !Array.isArray(value.capabilities) ||\n value.capabilities.some((capability) => !isNonEmptyString(capability))\n ) {\n return 'package.json \"ankh.capabilities\" must be an array of non-empty strings.';\n }\n\n return null;\n}\n\nfunction createEarlyResult(targetPath: string, diagnostic: DoctorDiagnostic): DoctorAnalysisResult {\n return {\n appliedChecks: [],\n diagnostics: [diagnostic],\n fixPlan: null,\n hasPackageJson: false,\n plannedChanges: [],\n profile: 'unknown',\n repoMarkers: [],\n targetPath,\n };\n}\n\n/*** Return canonical rule id and severity from the repository Rules provider. */\nfunction repositoryRuleFields(ruleId: DoctorRuleId): Pick<DoctorDiagnostic, 'ruleId' | 'severity'> {\n const rule = getRepositoryRule(ruleId);\n return { ruleId: rule.id, severity: rule.severity };\n}\n\nfunction createDiagnostic(diagnostic: DoctorDiagnostic): DoctorDiagnostic {\n return diagnostic;\n}\n\nfunction createPlannedChange(change: Omit<DoctorPlannedChange, 'safe'>): DoctorPlannedChange {\n return {\n ...change,\n safe: true,\n };\n}\n\nfunction createInvalidPackageJsonMessage(error: unknown): string {\n const message = error instanceof Error ? error.message : String(error);\n return `package.json contains invalid JSON: ${message}`;\n}\n\nasync function pathExists(targetPath: string): Promise<boolean> {\n return (await statOrNull(targetPath)) !== null;\n}\n\nasync function statOrNull(targetPath: string) {\n try {\n return await fs.stat(targetPath);\n } catch (error) {\n if (isMissingPathError(error)) {\n return null;\n }\n\n throw error;\n }\n}\n\nfunction isMissingPathError(error: unknown): error is NodeJS.ErrnoException {\n return (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n );\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.trim() !== '';\n}\n\nfunction isPackageRelativeProviderPath(value: unknown): value is string {\n return isNonEmptyString(value) && value.startsWith('./');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isStringTuple(value: unknown): value is readonly string[] {\n return Array.isArray(value) && value.length > 0 && value.every(isNonEmptyString);\n}\n\nfunction readStringArray(value: unknown): string[] {\n return Array.isArray(value) ? value.filter(isNonEmptyString) : [];\n}\n\nfunction sameStringSet(left: readonly string[], right: readonly string[]): boolean {\n const leftSet = uniqueSortedStrings(left);\n const rightSet = uniqueSortedStrings(right);\n return (\n leftSet.length === rightSet.length && leftSet.every((value, index) => value === rightSet[index])\n );\n}\n"]}
1
+ {"version":3,"file":"analysis.js","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,oBAAoB,EAEpB,YAAY,EACZ,mBAAmB,GACpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAI/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAgDjE,MAAM,YAAY,GAAG;IACnB,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IACvC,EAAE,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE;IAC/E,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE;IACnD,EAAE,KAAK,EAAE,cAAc,EAAE,Y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FileURL } from 'node:url';\n\nimport {\n areCapabilitiesEqual,\n type Capability,\n isCapability,\n normalizeCapability,\n} from '@ankhorage/contracts/capabilities';\nimport { REPOSITORY_RULE_METADATA } from '@ankhorage/rules-repository';\nimport { uniqueSortedStrings } from '@ankhorage/utility/array';\n\nimport type { DoctorDiagnostic, DoctorPolicyProfile, DoctorRuleId } from './diagnostics.js';\nimport type { DoctorReadiness } from './readiness.js';\nimport { getRepositoryRule } from './utils/getRepositoryRule.js';\n\nexport type DoctorTargetCheck = 'manifest' | 'package' | 'repo';\nexport type DoctorTargetMode = 'fix' | 'package' | 'repo' | 'validate';\nexport type DoctorPlannedChangeKind =\n 'create-directory' | 'create-file' | 'update-json' | 'update-text';\n\nexport interface DoctorAnalysisRequest {\n readonly cwd: string;\n readonly inputPath?: string;\n readonly mode: DoctorTargetMode;\n}\n\nexport interface DoctorPlannedChange {\n readonly description: string;\n readonly filePath: string;\n readonly kind: DoctorPlannedChangeKind;\n readonly ruleId: DoctorRuleId;\n readonly safe: boolean;\n}\n\nexport interface DoctorFixPlan {\n readonly changes: readonly DoctorPlannedChange[];\n readonly diagnostics: readonly DoctorDiagnostic[];\n readonly profile: DoctorPolicyProfile;\n readonly targetPath: string;\n}\n\nexport interface DoctorAnalysisResult {\n readonly appliedChecks: readonly DoctorTargetCheck[];\n readonly diagnostics: readonly DoctorDiagnostic[];\n readonly fixPlan: DoctorFixPlan | null;\n readonly hasPackageJson: boolean;\n readonly plannedChanges: readonly DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly readiness?: readonly DoctorReadiness[];\n readonly repoMarkers: readonly string[];\n readonly targetPath: string;\n}\n\ninterface ProviderInspectionResult {\n readonly capabilities: readonly Capability[];\n readonly commandCapabilities: readonly string[];\n readonly commandPaths: readonly string[];\n readonly handlerPaths: readonly string[];\n readonly sourcePath: string;\n}\n\nconst REPO_MARKERS = [\n { label: '.git', relativePath: '.git' },\n { label: '.github/workflows', relativePath: path.join('.github', 'workflows') },\n { label: '.changeset', relativePath: '.changeset' },\n { label: 'package.json', relativePath: 'package.json' },\n { label: 'pnpm-workspace.yaml', relativePath: 'pnpm-workspace.yaml' },\n { label: 'bun.lock', relativePath: 'bun.lock' },\n { label: 'bun.lockb', relativePath: 'bun.lockb' },\n { label: 'package-lock.json', relativePath: 'package-lock.json' },\n { label: 'yarn.lock', relativePath: 'yarn.lock' },\n] as const;\n\nconst PUBLIC_PACKAGE_POLICY = REPOSITORY_RULE_METADATA.publicPackage;\n\nconst PROVIDER_SOURCE_CANDIDATES = [\n path.join('src', 'ankh.provider.ts'),\n path.join('src', 'ankh.provider.tsx'),\n path.join('src', 'ankh.provider.js'),\n path.join('src', 'ankh.provider.mjs'),\n] as const;\n\nexport async function analyzeDoctorTarget(\n request: DoctorAnalysisRequest,\n): Promise<DoctorAnalysisResult> {\n const targetPath = path.resolve(request.cwd, request.inputPath ?? '.');\n const stats = await statOrNull(targetPath);\n\n if (stats === null) {\n return createEarlyResult(\n targetPath,\n createDiagnostic({\n code: 'target-not-found',\n message: `Target path does not exist: ${targetPath}`,\n path: targetPath,\n profile: 'unknown',\n ruleId: 'target.path.exists',\n severity: 'error',\n }),\n );\n }\n\n if (!stats.isDirectory()) {\n return createEarlyResult(\n targetPath,\n createDiagnostic({\n code: 'target-not-directory',\n message: `Target path must be a directory: ${targetPath}`,\n path: targetPath,\n profile: 'unknown',\n ruleId: 'target.path.directory',\n severity: 'error',\n }),\n );\n }\n\n const repoMarkers = await findRepoMarkers(targetPath);\n const packageJsonPath = path.join(targetPath, 'package.json');\n const hasPackageJson = repoMarkers.includes('package.json');\n const appliedChecks: DoctorTargetCheck[] = [];\n const diagnostics: DoctorDiagnostic[] = [];\n const plannedChanges: DoctorPlannedChange[] = [];\n\n const packageJson = hasPackageJson ? await readPackageJson(packageJsonPath) : null;\n if (packageJson !== null && packageJson.diagnostic !== null) {\n diagnostics.push(packageJson.diagnostic);\n }\n\n const profile = detectProfile(repoMarkers, packageJson?.parsed ?? null);\n\n const shouldRunRepoChecks =\n request.mode === 'repo' ||\n ((request.mode === 'validate' || request.mode === 'fix') && repoMarkers.length > 0);\n const shouldRunPackageChecks =\n request.mode === 'package' ||\n ((request.mode === 'validate' || request.mode === 'fix') && hasPackageJson);\n\n if (request.mode === 'repo' && repoMarkers.length === 0) {\n diagnostics.push(\n createDiagnostic({\n code: 'unsupported-target',\n message:\n 'Target is not a repo/workspace-root candidate because no repo markers were found.',\n path: targetPath,\n profile,\n ruleId: 'target.repo-markers.required',\n severity: 'error',\n }),\n );\n }\n\n if (request.mode === 'package' && !hasPackageJson) {\n diagnostics.push(\n createDiagnostic({\n code: 'unsupported-target',\n message: 'Target does not contain a readable package.json file.',\n path: packageJsonPath,\n profile,\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n );\n }\n\n if (\n (request.mode === 'validate' || request.mode === 'fix') &&\n repoMarkers.length === 0 &&\n !hasPackageJson\n ) {\n diagnostics.push(\n createDiagnostic({\n code: 'unsupported-target',\n message: 'Target is neither a repo/workspace-root candidate nor a package root.',\n path: targetPath,\n profile,\n ruleId: 'target.profile.supported',\n severity: 'error',\n }),\n );\n }\n\n if (shouldRunRepoChecks && repoMarkers.length > 0) {\n appliedChecks.push('repo');\n diagnostics.push(\n ...(await analyzeRepoPolicy({\n packageJson: packageJson?.parsed ?? null,\n plannedChanges,\n profile,\n repoMarkers,\n targetPath,\n })),\n );\n }\n\n if (shouldRunPackageChecks && hasPackageJson) {\n appliedChecks.push('package');\n diagnostics.push(\n ...(await analyzePackagePolicy({\n packageJson: packageJson?.parsed ?? null,\n packageJsonPath,\n plannedChanges,\n profile,\n targetPath,\n })),\n );\n }\n\n const fixPlan =\n request.mode === 'fix'\n ? {\n changes: plannedChanges,\n diagnostics,\n profile,\n targetPath,\n }\n : null;\n\n return {\n appliedChecks,\n diagnostics,\n fixPlan,\n hasPackageJson,\n plannedChanges,\n profile,\n repoMarkers,\n targetPath,\n };\n}\n\nasync function analyzeRepoPolicy(request: {\n readonly packageJson: Record<string, unknown> | null;\n readonly plannedChanges: DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly repoMarkers: readonly string[];\n readonly targetPath: string;\n}): Promise<DoctorDiagnostic[]> {\n const diagnostics: DoctorDiagnostic[] = [];\n\n if (request.profile === 'public-package') {\n for (const artifact of PUBLIC_PACKAGE_POLICY.requiredRepoPaths) {\n await maybeRequirePath(\n diagnostics,\n request.plannedChanges,\n request.targetPath,\n artifact.path,\n artifact.ruleId,\n artifact.kind === 'file' ? 'create-file' : 'create-directory',\n );\n }\n }\n\n if (request.profile === 'integration-monorepo') {\n if (!request.repoMarkers.includes('package.json')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-path',\n message: 'The integration monorepo root must include a package.json file.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n );\n }\n\n if (request.packageJson !== null) {\n if (request.packageJson.ankh !== undefined) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message:\n 'The integration monorepo root must not publish top-level package.json.ankh metadata.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'integration.package.ankh.disallowed',\n severity: 'error',\n }),\n );\n }\n\n if (request.packageJson.private !== true) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'The integration monorepo root must remain private.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'integration.package.private.required',\n severity: 'error',\n }),\n );\n }\n\n if (!Array.isArray(request.packageJson.workspaces)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: 'The integration monorepo root must declare workspaces.',\n path: path.join(request.targetPath, 'package.json'),\n profile: request.profile,\n ruleId: 'integration.package.workspaces.required',\n severity: 'error',\n }),\n );\n }\n }\n }\n\n return diagnostics;\n}\n\nasync function analyzePackagePolicy(request: {\n readonly packageJson: Record<string, unknown> | null;\n readonly packageJsonPath: string;\n readonly plannedChanges: DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly targetPath: string;\n}): Promise<DoctorDiagnostic[]> {\n if (request.packageJson === null) {\n return [];\n }\n\n const diagnostics: DoctorDiagnostic[] = [];\n const { packageJson } = request;\n\n if (request.profile === 'public-package') {\n requirePublicPackageFields({\n diagnostics,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n profile: request.profile,\n });\n }\n\n if (request.profile !== 'public-package') {\n return diagnostics.concat(\n await validateAnkhMetadataAndProvider({\n diagnostics,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n plannedChanges: request.plannedChanges,\n profile: request.profile,\n targetPath: request.targetPath,\n }),\n );\n }\n\n if (packageJson.private === true) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'Public package profiles must not set private: true.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.privateDisallowedRuleId),\n }),\n );\n }\n\n if (\n packageJson.type !== undefined &&\n packageJson.type !== PUBLIC_PACKAGE_POLICY.packageType.value\n ) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: `package.json \"type\" must be \"${PUBLIC_PACKAGE_POLICY.packageType.value}\".`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.packageType.ruleId),\n }),\n );\n }\n\n const { publishConfig } = packageJson;\n if (\n isRecord(publishConfig) &&\n publishConfig.access !== PUBLIC_PACKAGE_POLICY.publishAccess.value\n ) {\n diagnostics.push(\n createDiagnostic({\n code: isNonEmptyString(publishConfig.access) ? 'field-invalid' : 'field-missing',\n message: `package.json publishConfig.access must exist and equal \"${PUBLIC_PACKAGE_POLICY.publishAccess.value}\".`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.publishAccess.ruleId),\n }),\n );\n }\n\n if (!isNonEmptyString(packageJson.packageManager)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: 'package.json must define a Bun-aligned packageManager field.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.packageManager.requiredRuleId),\n }),\n );\n request.plannedChanges.push(\n createPlannedChange({\n description: `Add packageManager: \"bun@${Bun.version}\" to package.json.`,\n filePath: request.packageJsonPath,\n kind: 'update-json',\n ruleId: PUBLIC_PACKAGE_POLICY.packageManager.requiredRuleId,\n }),\n );\n } else if (!packageJson.packageManager.startsWith('bun@')) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'package.json packageManager must be Bun-aligned, for example \"bun@1.x\".',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.packageManager.bunRuleId),\n }),\n );\n }\n\n const scripts = isRecord(packageJson.scripts) ? packageJson.scripts : null;\n for (const requirement of PUBLIC_PACKAGE_POLICY.requiredScripts) {\n if (scripts === null || !isNonEmptyString(scripts[requirement.name])) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-script',\n message: `Missing required package script: ${requirement.name}`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(requirement.ruleId),\n }),\n );\n }\n }\n\n const devDependencies = isRecord(packageJson.devDependencies)\n ? packageJson.devDependencies\n : null;\n const dependencies = isRecord(packageJson.dependencies) ? packageJson.dependencies : null;\n if (!hasDependency(dependencies, 'typescript') && !hasDependency(devDependencies, 'typescript')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'Public package repos must declare TypeScript in dependencies or devDependencies.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.typescript),\n }),\n );\n }\n\n const changesetsDependencyDiagnostic = createChangesetsDependencyDiagnostic({\n dependencies,\n devDependencies,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n profile: request.profile,\n });\n if (changesetsDependencyDiagnostic !== null) {\n diagnostics.push(changesetsDependencyDiagnostic);\n }\n\n if (!hasDependency(devDependencies, '@types/bun')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'Public package repos must declare @types/bun in devDependencies.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.bunTypes),\n }),\n );\n }\n\n if (!hasDependency(devDependencies, '@types/node')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'Public package repos must declare @types/node in devDependencies.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.nodeTypes),\n }),\n );\n }\n\n if (expectsDevtools(packageJson) && !hasDependency(devDependencies, '@ankhorage/devtools')) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message:\n 'This package consumes shared Ankhorage lint/format/knip tooling and must declare @ankhorage/devtools.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.devtools),\n }),\n );\n }\n\n if (\n packageJson.name !== '@ankhorage/paradox' &&\n (await expectsParadox(request.targetPath, packageJson)) &&\n !hasDependency(devDependencies, '@ankhorage/paradox')\n ) {\n diagnostics.push(\n createDiagnostic({\n code: 'missing-dependency',\n message: 'This package owns Paradox docs generation and must declare @ankhorage/paradox.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.paradox),\n }),\n );\n }\n\n return diagnostics.concat(\n await validateAnkhMetadataAndProvider({\n diagnostics,\n packageJson,\n packageJsonPath: request.packageJsonPath,\n plannedChanges: request.plannedChanges,\n profile: request.profile,\n targetPath: request.targetPath,\n }),\n );\n}\n\nfunction createChangesetsDependencyDiagnostic(request: {\n readonly dependencies: Record<string, unknown> | null;\n readonly devDependencies: Record<string, unknown> | null;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n}): DoctorDiagnostic | null {\n const dependencyDeclared = hasDependency(request.dependencies, '@changesets/cli');\n const devDependencyDeclared = hasDependency(request.devDependencies, '@changesets/cli');\n const isDevtoolsOwner = request.packageJson.name === '@ankhorage/devtools';\n const placementIsCurrent = isDevtoolsOwner\n ? dependencyDeclared && !devDependencyDeclared\n : !dependencyDeclared && !devDependencyDeclared;\n\n if (placementIsCurrent) {\n return null;\n }\n\n return createDiagnostic({\n code: isDevtoolsOwner ? 'missing-dependency' : 'field-invalid',\n message: isDevtoolsOwner\n ? '@ankhorage/devtools must publish @changesets/cli in dependencies, not devDependencies.'\n : 'Public package repos must not declare @changesets/cli directly; @ankhorage/devtools owns Changesets execution.',\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(PUBLIC_PACKAGE_POLICY.dependencyRules.changesets),\n });\n}\n\nasync function validateAnkhMetadataAndProvider(request: {\n readonly diagnostics: readonly DoctorDiagnostic[];\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly plannedChanges: DoctorPlannedChange[];\n readonly profile: DoctorPolicyProfile;\n readonly targetPath: string;\n}): Promise<DoctorDiagnostic[]> {\n const diagnostics: DoctorDiagnostic[] = [];\n const metadata = request.packageJson.ankh;\n const providerPackage =\n (isRecord(metadata) && isNonEmptyString(metadata.provider)) ||\n (await isProviderPackage(request.targetPath));\n\n if (providerPackage && metadata === undefined) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: 'Provider packages must define package.json.ankh metadata.',\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.required-for-provider',\n severity: 'error',\n }),\n );\n request.plannedChanges.push(\n createPlannedChange({\n description:\n 'Add a package.json.ankh block describing the implemented provider category, provider path, and capabilities.',\n filePath: request.packageJsonPath,\n kind: 'update-json',\n ruleId: 'package.ankh.required-for-provider',\n }),\n );\n return diagnostics;\n }\n\n if (metadata === undefined) {\n return diagnostics;\n }\n\n const metadataValidation = validateAnkhMetadataShape(metadata, providerPackage);\n if (metadataValidation !== null) {\n diagnostics.push(\n createDiagnostic({\n code: 'invalid-ankh-metadata',\n message: metadataValidation,\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.present.valid-shape',\n severity: 'error',\n }),\n );\n return diagnostics;\n }\n\n if (!providerPackage) {\n return diagnostics;\n }\n\n if (!isRecord(metadata) || !isNonEmptyString(metadata.provider)) {\n diagnostics.push(\n createDiagnostic({\n code: 'invalid-ankh-metadata',\n message: 'Provider package metadata must define a package-relative provider path.',\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.provider-path.required',\n severity: 'error',\n }),\n );\n return diagnostics;\n }\n\n const inspection = await inspectProviderSource({\n metadataProviderPath: metadata.provider,\n packageRoot: request.targetPath,\n profile: request.profile,\n });\n\n if (inspection.diagnostic !== null) {\n diagnostics.push(inspection.diagnostic);\n return diagnostics;\n }\n\n if (inspection.result === null) {\n return diagnostics;\n }\n\n const metadataCapabilities = readCapabilities(metadata.capabilities);\n const providerCapabilities = inspection.result.capabilities;\n const commandCapabilities = uniqueSortedStrings(inspection.result.commandCapabilities);\n\n if (!sameCapabilitySet(metadataCapabilities, providerCapabilities)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message:\n 'package.json.ankh capabilities must match the implemented provider capability descriptors exactly.',\n path: request.packageJsonPath,\n profile: request.profile,\n ruleId: 'package.ankh.capabilities.match-provider',\n severity: 'error',\n }),\n );\n }\n\n if (\n !sameStringSet(\n providerCapabilities.map((capability) => capability.id),\n commandCapabilities,\n )\n ) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'Provider export capabilities must match the provider command capability surface.',\n path: inspection.result.sourcePath,\n profile: request.profile,\n ruleId: 'provider.commands.match-capabilities',\n severity: 'error',\n }),\n );\n }\n\n if (!sameStringSet(inspection.result.commandPaths, inspection.result.handlerPaths)) {\n diagnostics.push(\n createDiagnostic({\n code: 'field-invalid',\n message: 'Every provider command descriptor must have a matching handler path.',\n path: inspection.result.sourcePath,\n profile: request.profile,\n ruleId: 'provider.commands.match-handlers',\n severity: 'error',\n }),\n );\n }\n\n return diagnostics;\n}\n\nasync function inspectProviderSource(request: {\n readonly metadataProviderPath: string;\n readonly packageRoot: string;\n readonly profile: DoctorPolicyProfile;\n}): Promise<{\n readonly diagnostic: DoctorDiagnostic | null;\n readonly result: ProviderInspectionResult | null;\n}> {\n const sourcePath = await resolveProviderSourcePath(\n request.packageRoot,\n request.metadataProviderPath,\n );\n if (sourcePath === null) {\n return {\n diagnostic: createDiagnostic({\n code: 'provider-source-missing',\n message:\n 'Provider package metadata is present, but no provider source file could be resolved for inspection.',\n path: request.packageRoot,\n profile: request.profile,\n ruleId: 'provider.source.required',\n severity: 'error',\n }),\n result: null,\n };\n }\n\n try {\n const importedModule: unknown = await import(pathToFileURL(sourcePath).href);\n const provider = isRecord(importedModule) ? importedModule.default : undefined;\n if (!isRecord(provider)) {\n return {\n diagnostic: createDiagnostic({\n code: 'provider-source-import-failed',\n message: 'Provider source default export must be an object.',\n path: sourcePath,\n profile: request.profile,\n ruleId: 'provider.source.importable',\n severity: 'error',\n }),\n result: null,\n };\n }\n\n const capabilities = readCapabilities(provider.capabilities);\n const commands = Array.isArray(provider.commands) ? provider.commands : [];\n const handlers = Array.isArray(provider.handlers) ? provider.handlers : [];\n\n const commandCapabilities = commands.flatMap((command) =>\n isRecord(command) && isNonEmptyString(command.capability) ? [command.capability] : [],\n );\n const commandPaths = commands.flatMap((command) => {\n const pathValue = isRecord(command) ? command.path : undefined;\n return isStringTuple(pathValue) ? [pathValue.join(' ')] : [];\n });\n const handlerPaths = handlers.flatMap((handler) => {\n const pathValue = isRecord(handler) ? handler.path : undefined;\n const handlerFunction = isRecord(handler) ? handler.handler : undefined;\n return isStringTuple(pathValue) && typeof handlerFunction === 'function'\n ? [pathValue.join(' ')]\n : [];\n });\n\n return {\n diagnostic: null,\n result: {\n capabilities,\n commandCapabilities,\n commandPaths,\n handlerPaths,\n sourcePath,\n },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n diagnostic: createDiagnostic({\n code: 'provider-source-import-failed',\n message: `Failed to import provider source: ${message}`,\n path: sourcePath,\n profile: request.profile,\n ruleId: 'provider.source.importable',\n severity: 'error',\n }),\n result: null,\n };\n }\n}\n\nasync function resolveProviderSourcePath(\n packageRoot: string,\n metadataProviderPath: string,\n): Promise<string | null> {\n const candidates = new Set<string>();\n candidates.add(path.resolve(packageRoot, metadataProviderPath));\n\n if (metadataProviderPath.startsWith('./dist/') && metadataProviderPath.endsWith('.js')) {\n const relativeStem = metadataProviderPath.slice('./dist/'.length, -'.js'.length);\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.ts`));\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.tsx`));\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.js`));\n candidates.add(path.resolve(packageRoot, 'src', `${relativeStem}.mjs`));\n }\n\n for (const providerSourceCandidate of PROVIDER_SOURCE_CANDIDATES) {\n candidates.add(path.resolve(packageRoot, providerSourceCandidate));\n }\n\n for (const candidate of candidates) {\n if (await pathExists(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\nasync function findRepoMarkers(targetPath: string): Promise<readonly string[]> {\n return (\n await Promise.all(\n REPO_MARKERS.map(async (marker) =>\n (await pathExists(path.join(targetPath, marker.relativePath))) ? marker.label : null,\n ),\n )\n ).filter((marker): marker is (typeof REPO_MARKERS)[number]['label'] => marker !== null);\n}\n\nasync function readPackageJson(packageJsonPath: string): Promise<{\n readonly diagnostic: DoctorDiagnostic | null;\n readonly parsed: Record<string, unknown> | null;\n}> {\n let parsed: unknown;\n\n try {\n parsed = JSON.parse(await fs.readFile(packageJsonPath, 'utf8')) as unknown;\n } catch (error) {\n return {\n diagnostic: createDiagnostic({\n code: 'invalid-package-json',\n message: createInvalidPackageJsonMessage(error),\n path: packageJsonPath,\n profile: 'unknown',\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n parsed: null,\n };\n }\n\n if (!isRecord(parsed)) {\n return {\n diagnostic: createDiagnostic({\n code: 'invalid-package-json',\n message: 'package.json must contain a JSON object.',\n path: packageJsonPath,\n profile: 'unknown',\n ruleId: 'target.package-json.required',\n severity: 'error',\n }),\n parsed: null,\n };\n }\n\n return {\n diagnostic: null,\n parsed,\n };\n}\n\nfunction detectProfile(\n repoMarkers: readonly string[],\n packageJson: Record<string, unknown> | null,\n): DoctorPolicyProfile {\n if (packageJson !== null) {\n if (packageJson.name === 'ankhorage4') {\n return 'integration-monorepo';\n }\n\n if (isNonEmptyString(packageJson.name) && packageJson.name.startsWith('@ankhorage/')) {\n return packageJson.private === true ? 'unknown' : 'public-package';\n }\n }\n\n if (repoMarkers.length > 0) {\n return 'unknown';\n }\n\n return 'unknown';\n}\n\nasync function isProviderPackage(targetPath: string): Promise<boolean> {\n for (const candidate of PROVIDER_SOURCE_CANDIDATES) {\n if (await pathExists(path.join(targetPath, candidate))) {\n return true;\n }\n }\n\n return false;\n}\n\n/*** Validate every generic public-package metadata field from canonical Policy. */\nfunction requirePublicPackageFields(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n}): void {\n for (const requirement of PUBLIC_PACKAGE_POLICY.requiredFields) {\n const input = {\n diagnostics: request.diagnostics,\n fieldName: requirement.name,\n packageJson: request.packageJson,\n packageJsonPath: request.packageJsonPath,\n profile: request.profile,\n ruleId: requirement.ruleId,\n };\n\n switch (requirement.kind) {\n case 'non-empty-string':\n requireNonEmptyStringField(input);\n break;\n case 'record':\n requireRecordField(input);\n break;\n case 'string-array':\n requireStringArrayField(input);\n break;\n }\n }\n}\n\nasync function maybeRequirePath(\n diagnostics: DoctorDiagnostic[],\n plannedChanges: DoctorPlannedChange[],\n rootPath: string,\n relativePath: string,\n ruleId:\n | 'repo.changelog.required'\n | 'repo.changeset.required'\n | 'repo.license.required'\n | 'repo.readme.required'\n | 'repo.workflows.required',\n kind: DoctorPlannedChangeKind,\n): Promise<void> {\n const absolutePath = path.join(rootPath, relativePath);\n if (await pathExists(absolutePath)) {\n return;\n }\n\n diagnostics.push(\n createDiagnostic({\n code: 'missing-path',\n message: `Missing expected repo artifact: ${relativePath}`,\n path: absolutePath,\n profile: 'public-package',\n ...repositoryRuleFields(ruleId),\n }),\n );\n plannedChanges.push(\n createPlannedChange({\n description: `Create missing ${relativePath}.`,\n filePath: absolutePath,\n kind,\n ruleId,\n }),\n );\n}\n\nfunction requireNonEmptyStringField(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly fieldName: string;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n readonly ruleId: DoctorRuleId;\n}): void {\n if (isNonEmptyString(request.packageJson[request.fieldName])) {\n return;\n }\n\n request.diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: `package.json must define a non-empty \"${request.fieldName}\" field.`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(request.ruleId),\n }),\n );\n}\n\nfunction requireRecordField(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly fieldName: string;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n readonly ruleId: DoctorRuleId;\n}): void {\n if (isRecord(request.packageJson[request.fieldName])) {\n return;\n }\n\n request.diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: `package.json must define an object \"${request.fieldName}\" field.`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(request.ruleId),\n }),\n );\n}\n\nfunction requireStringArrayField(request: {\n readonly diagnostics: DoctorDiagnostic[];\n readonly fieldName: string;\n readonly packageJson: Record<string, unknown>;\n readonly packageJsonPath: string;\n readonly profile: DoctorPolicyProfile;\n readonly ruleId: DoctorRuleId;\n}): void {\n if (readStringArray(request.packageJson[request.fieldName]).length > 0) {\n return;\n }\n\n request.diagnostics.push(\n createDiagnostic({\n code: 'field-missing',\n message: `package.json must define a non-empty string array \"${request.fieldName}\" field.`,\n path: request.packageJsonPath,\n profile: request.profile,\n ...repositoryRuleFields(request.ruleId),\n }),\n );\n}\n\nasync function expectsParadox(\n targetPath: string,\n packageJson: Record<string, unknown>,\n): Promise<boolean> {\n const scripts = isRecord(packageJson.scripts) ? packageJson.scripts : null;\n const docsScript = scripts?.docs;\n if (\n isNonEmptyString(docsScript) &&\n (docsScript.includes('paradox') || docsScript.includes('@ankhorage/paradox'))\n ) {\n return true;\n }\n\n return (\n (await pathExists(path.join(targetPath, 'paradox.config.ts'))) ||\n (await pathExists(path.join(targetPath, 'src', 'readme-usage.ts')))\n );\n}\n\nfunction expectsDevtools(packageJson: Record<string, unknown>): boolean {\n const scripts = isRecord(packageJson.scripts) ? packageJson.scripts : null;\n if (scripts === null) {\n return false;\n }\n\n return Object.values(scripts).some(\n (scriptValue) =>\n isNonEmptyString(scriptValue) &&\n (scriptValue.includes('ankhorage-eslint') ||\n scriptValue.includes('ankhorage-prettier') ||\n scriptValue.includes('ankhorage-knip')),\n );\n}\n\nfunction hasDependency(\n dependencyMap: Record<string, unknown> | null,\n dependencyName: string,\n): boolean {\n return dependencyMap !== null && isNonEmptyString(dependencyMap[dependencyName]);\n}\n\nfunction validateAnkhMetadataShape(value: unknown, providerPackage: boolean): string | null {\n if (!isRecord(value)) {\n return 'package.json \"ankh\" metadata must be an object when present.';\n }\n\n if (!isNonEmptyString(value.category)) {\n return 'package.json \"ankh.category\" must be a non-empty string.';\n }\n\n if (\n providerPackage &&\n !(isNonEmptyString(value.provider) && isPackageRelativeProviderPath(value.provider))\n ) {\n return 'Provider package metadata must define a package-relative \"./...\" provider path.';\n }\n\n if (\n !providerPackage &&\n value.provider !== undefined &&\n !(value.provider === null || isPackageRelativeProviderPath(value.provider))\n ) {\n return 'Non-provider package metadata, when present, must use null or a package-relative \"./...\" provider value.';\n }\n\n if (\n !Array.isArray(value.capabilities) ||\n value.capabilities.some((capability) => !isCapability(capability))\n ) {\n return 'package.json \"ankh.capabilities\" must be an array of canonical Capability descriptors.';\n }\n\n return null;\n}\n\nfunction createEarlyResult(targetPath: string, diagnostic: DoctorDiagnostic): DoctorAnalysisResult {\n return {\n appliedChecks: [],\n diagnostics: [diagnostic],\n fixPlan: null,\n hasPackageJson: false,\n plannedChanges: [],\n profile: 'unknown',\n repoMarkers: [],\n targetPath,\n };\n}\n\n/*** Return canonical rule id and severity from the repository Rules provider. */\nfunction repositoryRuleFields(ruleId: DoctorRuleId): Pick<DoctorDiagnostic, 'ruleId' | 'severity'> {\n const rule = getRepositoryRule(ruleId);\n return { ruleId: rule.id, severity: rule.severity };\n}\n\nfunction createDiagnostic(diagnostic: DoctorDiagnostic): DoctorDiagnostic {\n return diagnostic;\n}\n\nfunction createPlannedChange(change: Omit<DoctorPlannedChange, 'safe'>): DoctorPlannedChange {\n return {\n ...change,\n safe: true,\n };\n}\n\nfunction createInvalidPackageJsonMessage(error: unknown): string {\n const message = error instanceof Error ? error.message : String(error);\n return `package.json contains invalid JSON: ${message}`;\n}\n\nasync function pathExists(targetPath: string): Promise<boolean> {\n return (await statOrNull(targetPath)) !== null;\n}\n\nasync function statOrNull(targetPath: string) {\n try {\n return await fs.stat(targetPath);\n } catch (error) {\n if (isMissingPathError(error)) {\n return null;\n }\n\n throw error;\n }\n}\n\nfunction isMissingPathError(error: unknown): error is NodeJS.ErrnoException {\n return (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n );\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.trim() !== '';\n}\n\nfunction isPackageRelativeProviderPath(value: unknown): value is string {\n return isNonEmptyString(value) && value.startsWith('./');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isStringTuple(value: unknown): value is readonly string[] {\n return Array.isArray(value) && value.length > 0 && value.every(isNonEmptyString);\n}\n\nfunction readStringArray(value: unknown): string[] {\n return Array.isArray(value) ? value.filter(isNonEmptyString) : [];\n}\n\n/*** Read and normalize canonical Capability descriptors from untrusted metadata. */\nfunction readCapabilities(value: unknown): Capability[] {\n return Array.isArray(value) ? value.filter(isCapability).map(normalizeCapability) : [];\n}\n\n/*** Compare capability collections by canonical id and descriptor semantics. */\nfunction sameCapabilitySet(left: readonly Capability[], right: readonly Capability[]): boolean {\n const leftById = new Map(left.map((capability) => [capability.id, capability]));\n const rightById = new Map(right.map((capability) => [capability.id, capability]));\n return (\n leftById.size === left.length &&\n rightById.size === right.length &&\n leftById.size === rightById.size &&\n [...leftById].every(([id, capability]) => {\n const other = rightById.get(id);\n return other !== undefined && areCapabilitiesEqual(capability, other);\n })\n );\n}\n\nfunction sameStringSet(left: readonly string[], right: readonly string[]): boolean {\n const leftSet = uniqueSortedStrings(left);\n const rightSet = uniqueSortedStrings(right);\n return (\n leftSet.length === rightSet.length && leftSet.every((value, index) => value === rightSet[index])\n );\n}\n"]}
@@ -0,0 +1,34 @@
1
+ export declare const CAPABILITIES: readonly [{
2
+ readonly id: "doctor.validate";
3
+ readonly owner: "@ankhorage/doctor";
4
+ readonly access: readonly ["invoke"];
5
+ readonly binding: {
6
+ readonly kind: "action";
7
+ readonly bindableAs: readonly ["target"];
8
+ };
9
+ }, {
10
+ readonly id: "doctor.fix";
11
+ readonly owner: "@ankhorage/doctor";
12
+ readonly access: readonly ["invoke"];
13
+ readonly binding: {
14
+ readonly kind: "action";
15
+ readonly bindableAs: readonly ["target"];
16
+ };
17
+ }, {
18
+ readonly id: "doctor.repo";
19
+ readonly owner: "@ankhorage/doctor";
20
+ readonly access: readonly ["invoke"];
21
+ readonly binding: {
22
+ readonly kind: "action";
23
+ readonly bindableAs: readonly ["target"];
24
+ };
25
+ }, {
26
+ readonly id: "doctor.package";
27
+ readonly owner: "@ankhorage/doctor";
28
+ readonly access: readonly ["invoke"];
29
+ readonly binding: {
30
+ readonly kind: "action";
31
+ readonly bindableAs: readonly ["target"];
32
+ };
33
+ }];
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/capabilities/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBiB,CAAC"}
@@ -0,0 +1,27 @@
1
+ export const CAPABILITIES = [
2
+ {
3
+ id: 'doctor.validate',
4
+ owner: '@ankhorage/doctor',
5
+ access: ['invoke'],
6
+ binding: { kind: 'action', bindableAs: ['target'] },
7
+ },
8
+ {
9
+ id: 'doctor.fix',
10
+ owner: '@ankhorage/doctor',
11
+ access: ['invoke'],
12
+ binding: { kind: 'action', bindableAs: ['target'] },
13
+ },
14
+ {
15
+ id: 'doctor.repo',
16
+ owner: '@ankhorage/doctor',
17
+ access: ['invoke'],
18
+ binding: { kind: 'action', bindableAs: ['target'] },
19
+ },
20
+ {
21
+ id: 'doctor.package',
22
+ owner: '@ankhorage/doctor',
23
+ access: ['invoke'],
24
+ binding: { kind: 'action', bindableAs: ['target'] },
25
+ },
26
+ ];
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capabilities/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;QACE,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,CAAC,QAAQ,CAAC;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE;KACpD;IACD;QACE,EAAE,EAAE,YAAY;QAChB,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,CAAC,QAAQ,CAAC;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE;KACpD;IACD;QACE,EAAE,EAAE,aAAa;QACjB,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,CAAC,QAAQ,CAAC;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE;KACpD;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,CAAC,QAAQ,CAAC;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE;KACpD;CACuC,CAAC","sourcesContent":["import type { Capability } from '@ankhorage/contracts/capabilities';\n\nexport const CAPABILITIES = [\n {\n id: 'doctor.validate',\n owner: '@ankhorage/doctor',\n access: ['invoke'],\n binding: { kind: 'action', bindableAs: ['target'] },\n },\n {\n id: 'doctor.fix',\n owner: '@ankhorage/doctor',\n access: ['invoke'],\n binding: { kind: 'action', bindableAs: ['target'] },\n },\n {\n id: 'doctor.repo',\n owner: '@ankhorage/doctor',\n access: ['invoke'],\n binding: { kind: 'action', bindableAs: ['target'] },\n },\n {\n id: 'doctor.package',\n owner: '@ankhorage/doctor',\n access: ['invoke'],\n binding: { kind: 'action', bindableAs: ['target'] },\n },\n] as const satisfies readonly Capability[];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAEtF,OAAO,EAGL,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AASxB,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACpD;AAED,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,kCAAuC,GAC/C,0BAA0B,CAgC5B;AAED,QAAA,MAAM,QAAQ,4BAAgC,CAAC;AAE/C,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAGtF,OAAO,EAGL,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAQxB,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACpD;AAED,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,kCAAuC,GAC/C,0BAA0B,CAgC5B;AAED,QAAA,MAAM,QAAQ,4BAAgC,CAAC;AAE/C,eAAe,QAAQ,CAAC"}
package/dist/cli/index.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { CAPABILITIES } from '../capabilities/index.js';
1
2
  import { createProviderCommandDescriptors, DOCTOR_COMMANDS, runDoctorCommand, } from '../commands.js';
2
3
  import { analyzeDoctorTargetWithCliLayout } from '../dependencyPolicyAnalysis.js';
3
- import { DOCTOR_CAPABILITIES, DOCTOR_COMMAND_CATEGORY, DOCTOR_PACKAGE_NAME, DOCTOR_PACKAGE_VERSION, } from '../packageMetadata.js';
4
+ import { DOCTOR_COMMAND_CATEGORY, DOCTOR_PACKAGE_NAME, DOCTOR_PACKAGE_VERSION, } from '../packageMetadata.js';
4
5
  export function createDoctorRuntimeProvider(options = {}) {
5
6
  const runCommandImpl = options.runCommandImpl ?? runDoctorCommand;
6
7
  const services = {
@@ -11,7 +12,7 @@ export function createDoctorRuntimeProvider(options = {}) {
11
12
  id: DOCTOR_PACKAGE_NAME,
12
13
  category: DOCTOR_COMMAND_CATEGORY,
13
14
  version: DOCTOR_PACKAGE_VERSION,
14
- capabilities: [...DOCTOR_CAPABILITIES],
15
+ capabilities: CAPABILITIES,
15
16
  commands: createProviderCommandDescriptors(),
16
17
  handlers: DOCTOR_COMMANDS.map((command) => {
17
18
  const handler = (request) => runCommandImpl({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gCAAgC,EAChC,eAAe,EAEf,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAO/B,MAAM,UAAU,2BAA2B,CACzC,UAA8C,EAAE;IAEhD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,gBAAgB,CAAC;IAClE,MAAM,QAAQ,GAAG;QACf,aAAa,EAAE,gCAAgC;QAC/C,GAAG,OAAO,CAAC,QAAQ;KACY,CAAC;IAElC,OAAO;QACL,EAAE,EAAE,mBAAmB;QACvB,QAAQ,EAAE,uBAAuB;QACjC,OAAO,EAAE,sBAAsB;QAC/B,YAAY,EAAE,CAAC,GAAG,mBAAmB,CAAC;QACtC,QAAQ,EAAE,gCAAgC,EAAE;QAC5C,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACxC,MAAM,OAAO,GAAuB,CAAC,OAAO,EAAE,EAAE,CAC9C,cAAc,CACZ;gBACE,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,OAAO;gBACP,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,EACD;gBACE,QAAQ;aACT,CACF,CAAC;YAEJ,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,OAAO;aACR,CAAC;QACJ,CAAC,CAAC;KACkC,CAAC;AACzC,CAAC;AAED,MAAM,QAAQ,GAAG,2BAA2B,EAAE,CAAC;AAE/C,eAAe,QAAQ,CAAC","sourcesContent":["import type { AnkhCommandHandler, AnkhRuntimeCommandProvider } from '@ankhorage/ankh';\n\nimport {\n createProviderCommandDescriptors,\n DOCTOR_COMMANDS,\n type DoctorCommandServices,\n runDoctorCommand,\n type RunDoctorCommandImpl,\n} from '../commands.js';\nimport { analyzeDoctorTargetWithCliLayout } from '../dependencyPolicyAnalysis.js';\nimport {\n DOCTOR_CAPABILITIES,\n DOCTOR_COMMAND_CATEGORY,\n DOCTOR_PACKAGE_NAME,\n DOCTOR_PACKAGE_VERSION,\n} from '../packageMetadata.js';\n\nexport interface CreateDoctorRuntimeProviderOptions {\n readonly runCommandImpl?: RunDoctorCommandImpl;\n readonly services?: Partial<DoctorCommandServices>;\n}\n\nexport function createDoctorRuntimeProvider(\n options: CreateDoctorRuntimeProviderOptions = {},\n): AnkhRuntimeCommandProvider {\n const runCommandImpl = options.runCommandImpl ?? runDoctorCommand;\n const services = {\n analyzeTarget: analyzeDoctorTargetWithCliLayout,\n ...options.services,\n } satisfies DoctorCommandServices;\n\n return {\n id: DOCTOR_PACKAGE_NAME,\n category: DOCTOR_COMMAND_CATEGORY,\n version: DOCTOR_PACKAGE_VERSION,\n capabilities: [...DOCTOR_CAPABILITIES],\n commands: createProviderCommandDescriptors(),\n handlers: DOCTOR_COMMANDS.map((command) => {\n const handler: AnkhCommandHandler = (request) =>\n runCommandImpl(\n {\n argv: request.argv,\n command,\n context: request.context,\n },\n {\n services,\n },\n );\n\n return {\n path: command.path,\n handler,\n };\n }),\n } satisfies AnkhRuntimeCommandProvider;\n}\n\nconst provider = createDoctorRuntimeProvider();\n\nexport default provider;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,gCAAgC,EAChC,eAAe,EAEf,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAO/B,MAAM,UAAU,2BAA2B,CACzC,UAA8C,EAAE;IAEhD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,gBAAgB,CAAC;IAClE,MAAM,QAAQ,GAAG;QACf,aAAa,EAAE,gCAAgC;QAC/C,GAAG,OAAO,CAAC,QAAQ;KACY,CAAC;IAElC,OAAO;QACL,EAAE,EAAE,mBAAmB;QACvB,QAAQ,EAAE,uBAAuB;QACjC,OAAO,EAAE,sBAAsB;QAC/B,YAAY,EAAE,YAAY;QAC1B,QAAQ,EAAE,gCAAgC,EAAE;QAC5C,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACxC,MAAM,OAAO,GAAuB,CAAC,OAAO,EAAE,EAAE,CAC9C,cAAc,CACZ;gBACE,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,OAAO;gBACP,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,EACD;gBACE,QAAQ;aACT,CACF,CAAC;YAEJ,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,OAAO;aACR,CAAC;QACJ,CAAC,CAAC;KACkC,CAAC;AACzC,CAAC;AAED,MAAM,QAAQ,GAAG,2BAA2B,EAAE,CAAC;AAE/C,eAAe,QAAQ,CAAC","sourcesContent":["import type { AnkhCommandHandler, AnkhRuntimeCommandProvider } from '@ankhorage/ankh';\n\nimport { CAPABILITIES } from '../capabilities/index.js';\nimport {\n createProviderCommandDescriptors,\n DOCTOR_COMMANDS,\n type DoctorCommandServices,\n runDoctorCommand,\n type RunDoctorCommandImpl,\n} from '../commands.js';\nimport { analyzeDoctorTargetWithCliLayout } from '../dependencyPolicyAnalysis.js';\nimport {\n DOCTOR_COMMAND_CATEGORY,\n DOCTOR_PACKAGE_NAME,\n DOCTOR_PACKAGE_VERSION,\n} from '../packageMetadata.js';\n\nexport interface CreateDoctorRuntimeProviderOptions {\n readonly runCommandImpl?: RunDoctorCommandImpl;\n readonly services?: Partial<DoctorCommandServices>;\n}\n\nexport function createDoctorRuntimeProvider(\n options: CreateDoctorRuntimeProviderOptions = {},\n): AnkhRuntimeCommandProvider {\n const runCommandImpl = options.runCommandImpl ?? runDoctorCommand;\n const services = {\n analyzeTarget: analyzeDoctorTargetWithCliLayout,\n ...options.services,\n } satisfies DoctorCommandServices;\n\n return {\n id: DOCTOR_PACKAGE_NAME,\n category: DOCTOR_COMMAND_CATEGORY,\n version: DOCTOR_PACKAGE_VERSION,\n capabilities: CAPABILITIES,\n commands: createProviderCommandDescriptors(),\n handlers: DOCTOR_COMMANDS.map((command) => {\n const handler: AnkhCommandHandler = (request) =>\n runCommandImpl(\n {\n argv: request.argv,\n command,\n context: request.context,\n },\n {\n services,\n },\n );\n\n return {\n path: command.path,\n handler,\n };\n }),\n } satisfies AnkhRuntimeCommandProvider;\n}\n\nconst provider = createDoctorRuntimeProvider();\n\nexport default provider;\n"]}
@@ -1,4 +1,5 @@
1
- import type { AnkhCapabilityId, AnkhCommandDescriptor } from '@ankhorage/contracts/cli';
1
+ import type { Capability } from '@ankhorage/contracts/capabilities';
2
+ import type { AnkhCommandDescriptor } from '@ankhorage/contracts/cli';
2
3
  import type { DoctorTargetMode } from './analysis.js';
3
4
  import { analyzeDoctorTargetWithCliLayout } from './cliLayoutAnalysis.js';
4
5
  import type { DoctorCommandContext, DoctorCommandRunResult } from './commandContext.js';
@@ -9,7 +10,7 @@ interface DoctorCommandRunRequest {
9
10
  }
10
11
  type DoctorCommandImplementation = (request: DoctorCommandRunRequest, services: DoctorCommandServices) => Promise<DoctorCommandRunResult>;
11
12
  export interface DoctorCommandDefinition {
12
- readonly capability: AnkhCapabilityId;
13
+ readonly capability: Capability['id'];
13
14
  readonly mode: DoctorTargetMode;
14
15
  readonly path: readonly [DoctorCommandName];
15
16
  readonly standaloneName: DoctorCommandName;
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAExF,OAAO,KAAK,EAA6C,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AASxF,KAAK,iBAAiB,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAEjE,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,KAAK,2BAA2B,GAAG,CACjC,OAAO,EAAE,uBAAuB,EAChC,QAAQ,EAAE,qBAAqB,KAC5B,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAErC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC5C,QAAQ,CAAC,cAAc,EAAE,iBAAiB,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,2BAA2B,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC1C,QA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AC,CAYjC;AAED,iBAAe,iBAAiB,CAC9B,OAAO,EAAE,uBAAuB,EAChC,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,sBAAsB,CAAC,CAYjC"}
package/dist/commands.js CHANGED
@@ -1,11 +1,12 @@
1
+ import { CAPABILITIES } from './capabilities/index.js';
1
2
  import { analyzeDoctorTargetWithCliLayout } from './cliLayoutAnalysis.js';
2
3
  import { countErrorDiagnostics, countWarningDiagnostics, } from './diagnostics.js';
3
- import { DOCTOR_CAPABILITIES, DOCTOR_COMMAND_CATEGORY } from './packageMetadata.js';
4
+ import { DOCTOR_COMMAND_CATEGORY } from './packageMetadata.js';
4
5
  const COMMAND_CAPABILITIES = {
5
- validate: DOCTOR_CAPABILITIES[0],
6
- fix: DOCTOR_CAPABILITIES[1],
7
- repo: DOCTOR_CAPABILITIES[2],
8
- package: DOCTOR_CAPABILITIES[3],
6
+ validate: CAPABILITIES[0].id,
7
+ fix: CAPABILITIES[1].id,
8
+ repo: CAPABILITIES[2].id,
9
+ package: CAPABILITIES[3].id,
9
10
  };
10
11
  export const DOCTOR_COMMANDS = [
11
12
  {
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AA4CpF,MAAM,oBAAoB,GAAG;IAC3B,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAChC,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC3B,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;CAC+B,CAAC;AAEjE,MAAM,CAAC,MAAM,eAAe,GAAG;IA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annedChange, DoctorTargetMode } from './analysis.js';\nimport { analyzeDoctorTargetWithCliLayout } from './cliLayoutAnalysis.js';\nimport type { DoctorCommandContext, DoctorCommandRunResult } from './commandContext.js';\nimport {\n countErrorDiagnostics,\n countWarningDiagnostics,\n type DoctorDiagnostic,\n} from './diagnostics.js';\nimport { DOCTOR_CAPABILITIES, DOCTOR_COMMAND_CATEGORY } from './packageMetadata.js';\nimport type { DoctorReadiness } from './readiness.js';\n\ntype DoctorCommandName = 'fix' | 'package' | 'repo' | 'validate';\n\ninterface DoctorCommandRunRequest {\n readonly context: DoctorCommandContext;\n readonly inputPath?: string;\n}\n\ntype DoctorCommandImplementation = (\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n) => Promise<DoctorCommandRunResult>;\n\nexport interface DoctorCommandDefinition {\n readonly capability: AnkhCapabilityId;\n readonly mode: DoctorTargetMode;\n readonly path: readonly [DoctorCommandName];\n readonly standaloneName: DoctorCommandName;\n readonly summary: string;\n readonly run: DoctorCommandImplementation;\n}\n\nexport interface DoctorCommandInvocation {\n readonly argv: readonly string[];\n readonly command: DoctorCommandDefinition;\n readonly context: DoctorCommandContext;\n}\n\nexport interface DoctorCommandServices {\n readonly analyzeTarget: typeof analyzeDoctorTargetWithCliLayout;\n}\n\nexport interface RunDoctorCommandOptions {\n readonly runCommandImpl?: RunDoctorCommandImpl;\n readonly services?: Partial<DoctorCommandServices>;\n}\n\nexport type RunDoctorCommandImpl = (\n request: DoctorCommandInvocation,\n options?: RunDoctorCommandOptions,\n) => Promise<DoctorCommandRunResult>;\n\nconst COMMAND_CAPABILITIES = {\n validate: DOCTOR_CAPABILITIES[0],\n fix: DOCTOR_CAPABILITIES[1],\n repo: DOCTOR_CAPABILITIES[2],\n package: DOCTOR_CAPABILITIES[3],\n} as const satisfies Record<DoctorCommandName, AnkhCapabilityId>;\n\nexport const DOCTOR_COMMANDS = [\n {\n standaloneName: 'validate',\n path: ['validate'],\n capability: COMMAND_CAPABILITIES.validate,\n mode: 'validate',\n summary:\n 'Validate a repo, package, or app-manifest JSON path with the applicable Doctor profile.',\n run: runValidateCommand,\n },\n {\n standaloneName: 'fix',\n path: ['fix'],\n capability: COMMAND_CAPABILITIES.fix,\n mode: 'fix',\n summary: 'Build a non-mutating fix plan for deterministic doctor policy violations.',\n run: runFixCommand,\n },\n {\n standaloneName: 'repo',\n path: ['repo'],\n capability: COMMAND_CAPABILITIES.repo,\n mode: 'repo',\n summary: 'Force repo-light diagnostics for a repo/workspace-root candidate path.',\n run: runRepoCommand,\n },\n {\n standaloneName: 'package',\n path: ['package'],\n capability: COMMAND_CAPABILITIES.package,\n mode: 'package',\n summary: 'Force package-light diagnostics for a directory containing package.json.',\n run: runPackageCommand,\n },\n] as const satisfies readonly DoctorCommandDefinition[];\n\nexport async function runDoctorCommand(\n request: DoctorCommandInvocation,\n options: RunDoctorCommandOptions = {},\n): Promise<DoctorCommandRunResult> {\n const services = createDoctorCommandServices(options.services);\n\n try {\n const parsedArgs = parseCommandArguments(request.command, request.argv);\n if (parsedArgs.kind === 'help') {\n request.context.writeStdout(renderCommandHelp(request.command));\n return { exitCode: 0 };\n }\n\n return await request.command.run(\n {\n context: request.context,\n inputPath: parsedArgs.inputPath,\n },\n services,\n );\n } catch (error) {\n request.context.writeStderr(renderCommandFailure(request.command.standaloneName, error));\n return { exitCode: 1 };\n }\n}\n\nexport function createProviderCommandDescriptors(): readonly AnkhCommandDescriptor[] {\n return DOCTOR_COMMANDS.map((command) => ({\n capability: command.capability,\n path: command.path,\n summary: command.summary,\n }));\n}\n\nexport function findDoctorCommandByStandaloneName(value: string): DoctorCommandDefinition | null {\n return DOCTOR_COMMANDS.find((command) => command.standaloneName === value) ?? null;\n}\n\nexport function renderRootHelp(version: string): string {\n const commandLines = DOCTOR_COMMANDS.map(\n (command) => ` ${command.standaloneName.padEnd(8, ' ')} ${command.summary}`,\n ).join('\\n');\n\n return [\n `@ankhorage/doctor v${version}`,\n '',\n 'Usage:',\n ' ankhorage-doctor <command> [path]',\n ` ankh ${DOCTOR_COMMAND_CATEGORY} <command> [path]`,\n '',\n 'Commands:',\n commandLines,\n '',\n 'Path resolution:',\n ' Pass a repo/package directory or app-manifest JSON file, or omit [path] to inspect the current directory.',\n '',\n ].join('\\n');\n}\n\nexport function renderUnknownCommand(value: string): string {\n return [`Unknown doctor command: ${value}`, '', 'Run ankhorage-doctor --help', ''].join('\\n');\n}\n\nfunction renderCommandHelp(command: DoctorCommandDefinition): string {\n return [\n command.summary,\n '',\n 'Usage:',\n ` ankhorage-doctor ${command.standaloneName} [path]`,\n ` ankh ${DOCTOR_COMMAND_CATEGORY} ${command.path.join(' ')} [path]`,\n '',\n 'Path resolution:',\n ' Pass a repo/package directory or app-manifest JSON file, or omit [path] to inspect the current directory.',\n '',\n ].join('\\n');\n}\n\nfunction createDoctorCommandServices(\n overrides: Partial<DoctorCommandServices> = {},\n): DoctorCommandServices {\n return {\n analyzeTarget: overrides.analyzeTarget ?? analyzeDoctorTargetWithCliLayout,\n };\n}\n\nfunction parseCommandArguments(\n command: DoctorCommandDefinition,\n argv: readonly string[],\n): { readonly kind: 'help' } | { readonly kind: 'run'; readonly inputPath?: string } {\n const [firstArg] = argv;\n\n if (argv.length === 1 && firstArg !== undefined && isHelpToken(firstArg)) {\n return { kind: 'help' };\n }\n\n if (argv.length > 1) {\n throw new Error(`Doctor ${command.standaloneName} accepts at most one path argument.`);\n }\n\n return {\n kind: 'run',\n inputPath: firstArg,\n };\n}\n\nasync function runValidateCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'validate',\n });\n\n request.context.writeStdout(renderAnalysisReport('validate', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nasync function runFixCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'fix',\n });\n\n request.context.writeStdout(renderAnalysisReport('fix', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nasync function runRepoCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'repo',\n });\n\n request.context.writeStdout(renderAnalysisReport('repo', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nasync function runPackageCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'package',\n });\n\n request.context.writeStdout(renderAnalysisReport('package', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nfunction renderAnalysisReport(\n commandName: DoctorCommandName,\n result: DoctorAnalysisResult,\n): string {\n const lines = [\n `doctor ${commandName}`,\n `target: ${result.targetPath}`,\n `profile: ${result.profile}`,\n `checks: ${result.appliedChecks.length > 0 ? result.appliedChecks.join(', ') : 'none'}`,\n `repoMarkers: ${result.repoMarkers.length > 0 ? result.repoMarkers.join(', ') : 'none'}`,\n '',\n 'Diagnostics:',\n ];\n\n if (result.diagnostics.length === 0) {\n lines.push(' none');\n } else {\n for (const diagnostic of result.diagnostics) {\n lines.push(renderDiagnosticLine(diagnostic));\n }\n }\n\n const readiness = result.readiness ?? [];\n lines.push('');\n lines.push('Readiness:');\n if (readiness.length === 0) {\n lines.push(' none');\n } else {\n for (const item of readiness) {\n lines.push(renderReadinessLine(item));\n }\n }\n\n if (commandName === 'fix') {\n lines.push('');\n lines.push('Planned changes:');\n\n if (result.plannedChanges.length === 0) {\n lines.push(' none');\n } else {\n for (const change of result.plannedChanges) {\n lines.push(renderPlannedChangeLine(change));\n }\n }\n }\n\n const errorCount = countErrorDiagnostics(result.diagnostics);\n const warningCount = countWarningDiagnostics(result.diagnostics);\n\n lines.push('');\n lines.push(`Summary: ${errorCount} error(s), ${warningCount} warning(s)`);\n lines.push('');\n\n return lines.join('\\n');\n}\n\nfunction renderDiagnosticLine(diagnostic: DoctorDiagnostic): string {\n return ` - ${diagnostic.severity.toUpperCase()} ${diagnostic.ruleId} (${diagnostic.code}): ${diagnostic.message}`;\n}\n\nfunction renderReadinessLine(item: DoctorReadiness): string {\n return ` - ${item.target} ${item.environment} ${item.provider} ${item.transport}: ${item.status} — ${item.message}`;\n}\n\nfunction renderPlannedChangeLine(change: DoctorPlannedChange): string {\n return ` - ${change.ruleId} [${change.kind}]: ${change.description}`;\n}\n\nfunction renderCommandFailure(commandName: DoctorCommandName, error: unknown): string {\n const message = error instanceof Error ? error.message : String(error);\n return [`Failed to run doctor ${commandName}: ${message}`, ''].join('\\n');\n}\n\nfunction isHelpToken(value: string): boolean {\n return value === '--help' || value === '-h' || value === 'help';\n}\n"]}
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AA4C/D,MAAM,oBAAoB,GAAG;IAC3B,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;IAC5B,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;IACvB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;IACxB,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;C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import type { AnkhCommandDescriptor } from '@ankhorage/contracts/cli';\n\nimport type { DoctorAnalysisResult, DoctorPlannedChange, DoctorTargetMode } from './analysis.js';\nimport { CAPABILITIES } from './capabilities/index.js';\nimport { analyzeDoctorTargetWithCliLayout } from './cliLayoutAnalysis.js';\nimport type { DoctorCommandContext, DoctorCommandRunResult } from './commandContext.js';\nimport {\n countErrorDiagnostics,\n countWarningDiagnostics,\n type DoctorDiagnostic,\n} from './diagnostics.js';\nimport { DOCTOR_COMMAND_CATEGORY } from './packageMetadata.js';\nimport type { DoctorReadiness } from './readiness.js';\n\ntype DoctorCommandName = 'fix' | 'package' | 'repo' | 'validate';\n\ninterface DoctorCommandRunRequest {\n readonly context: DoctorCommandContext;\n readonly inputPath?: string;\n}\n\ntype DoctorCommandImplementation = (\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n) => Promise<DoctorCommandRunResult>;\n\nexport interface DoctorCommandDefinition {\n readonly capability: Capability['id'];\n readonly mode: DoctorTargetMode;\n readonly path: readonly [DoctorCommandName];\n readonly standaloneName: DoctorCommandName;\n readonly summary: string;\n readonly run: DoctorCommandImplementation;\n}\n\nexport interface DoctorCommandInvocation {\n readonly argv: readonly string[];\n readonly command: DoctorCommandDefinition;\n readonly context: DoctorCommandContext;\n}\n\nexport interface DoctorCommandServices {\n readonly analyzeTarget: typeof analyzeDoctorTargetWithCliLayout;\n}\n\nexport interface RunDoctorCommandOptions {\n readonly runCommandImpl?: RunDoctorCommandImpl;\n readonly services?: Partial<DoctorCommandServices>;\n}\n\nexport type RunDoctorCommandImpl = (\n request: DoctorCommandInvocation,\n options?: RunDoctorCommandOptions,\n) => Promise<DoctorCommandRunResult>;\n\nconst COMMAND_CAPABILITIES = {\n validate: CAPABILITIES[0].id,\n fix: CAPABILITIES[1].id,\n repo: CAPABILITIES[2].id,\n package: CAPABILITIES[3].id,\n} as const satisfies Record<DoctorCommandName, Capability['id']>;\n\nexport const DOCTOR_COMMANDS = [\n {\n standaloneName: 'validate',\n path: ['validate'],\n capability: COMMAND_CAPABILITIES.validate,\n mode: 'validate',\n summary:\n 'Validate a repo, package, or app-manifest JSON path with the applicable Doctor profile.',\n run: runValidateCommand,\n },\n {\n standaloneName: 'fix',\n path: ['fix'],\n capability: COMMAND_CAPABILITIES.fix,\n mode: 'fix',\n summary: 'Build a non-mutating fix plan for deterministic doctor policy violations.',\n run: runFixCommand,\n },\n {\n standaloneName: 'repo',\n path: ['repo'],\n capability: COMMAND_CAPABILITIES.repo,\n mode: 'repo',\n summary: 'Force repo-light diagnostics for a repo/workspace-root candidate path.',\n run: runRepoCommand,\n },\n {\n standaloneName: 'package',\n path: ['package'],\n capability: COMMAND_CAPABILITIES.package,\n mode: 'package',\n summary: 'Force package-light diagnostics for a directory containing package.json.',\n run: runPackageCommand,\n },\n] as const satisfies readonly DoctorCommandDefinition[];\n\nexport async function runDoctorCommand(\n request: DoctorCommandInvocation,\n options: RunDoctorCommandOptions = {},\n): Promise<DoctorCommandRunResult> {\n const services = createDoctorCommandServices(options.services);\n\n try {\n const parsedArgs = parseCommandArguments(request.command, request.argv);\n if (parsedArgs.kind === 'help') {\n request.context.writeStdout(renderCommandHelp(request.command));\n return { exitCode: 0 };\n }\n\n return await request.command.run(\n {\n context: request.context,\n inputPath: parsedArgs.inputPath,\n },\n services,\n );\n } catch (error) {\n request.context.writeStderr(renderCommandFailure(request.command.standaloneName, error));\n return { exitCode: 1 };\n }\n}\n\nexport function createProviderCommandDescriptors(): readonly AnkhCommandDescriptor[] {\n return DOCTOR_COMMANDS.map((command) => ({\n capability: command.capability,\n path: command.path,\n summary: command.summary,\n }));\n}\n\nexport function findDoctorCommandByStandaloneName(value: string): DoctorCommandDefinition | null {\n return DOCTOR_COMMANDS.find((command) => command.standaloneName === value) ?? null;\n}\n\nexport function renderRootHelp(version: string): string {\n const commandLines = DOCTOR_COMMANDS.map(\n (command) => ` ${command.standaloneName.padEnd(8, ' ')} ${command.summary}`,\n ).join('\\n');\n\n return [\n `@ankhorage/doctor v${version}`,\n '',\n 'Usage:',\n ' ankhorage-doctor <command> [path]',\n ` ankh ${DOCTOR_COMMAND_CATEGORY} <command> [path]`,\n '',\n 'Commands:',\n commandLines,\n '',\n 'Path resolution:',\n ' Pass a repo/package directory or app-manifest JSON file, or omit [path] to inspect the current directory.',\n '',\n ].join('\\n');\n}\n\nexport function renderUnknownCommand(value: string): string {\n return [`Unknown doctor command: ${value}`, '', 'Run ankhorage-doctor --help', ''].join('\\n');\n}\n\nfunction renderCommandHelp(command: DoctorCommandDefinition): string {\n return [\n command.summary,\n '',\n 'Usage:',\n ` ankhorage-doctor ${command.standaloneName} [path]`,\n ` ankh ${DOCTOR_COMMAND_CATEGORY} ${command.path.join(' ')} [path]`,\n '',\n 'Path resolution:',\n ' Pass a repo/package directory or app-manifest JSON file, or omit [path] to inspect the current directory.',\n '',\n ].join('\\n');\n}\n\nfunction createDoctorCommandServices(\n overrides: Partial<DoctorCommandServices> = {},\n): DoctorCommandServices {\n return {\n analyzeTarget: overrides.analyzeTarget ?? analyzeDoctorTargetWithCliLayout,\n };\n}\n\nfunction parseCommandArguments(\n command: DoctorCommandDefinition,\n argv: readonly string[],\n): { readonly kind: 'help' } | { readonly kind: 'run'; readonly inputPath?: string } {\n const [firstArg] = argv;\n\n if (argv.length === 1 && firstArg !== undefined && isHelpToken(firstArg)) {\n return { kind: 'help' };\n }\n\n if (argv.length > 1) {\n throw new Error(`Doctor ${command.standaloneName} accepts at most one path argument.`);\n }\n\n return {\n kind: 'run',\n inputPath: firstArg,\n };\n}\n\nasync function runValidateCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'validate',\n });\n\n request.context.writeStdout(renderAnalysisReport('validate', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nasync function runFixCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'fix',\n });\n\n request.context.writeStdout(renderAnalysisReport('fix', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nasync function runRepoCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'repo',\n });\n\n request.context.writeStdout(renderAnalysisReport('repo', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nasync function runPackageCommand(\n request: DoctorCommandRunRequest,\n services: DoctorCommandServices,\n): Promise<DoctorCommandRunResult> {\n const result = await services.analyzeTarget({\n cwd: request.context.cwd,\n inputPath: request.inputPath,\n mode: 'package',\n });\n\n request.context.writeStdout(renderAnalysisReport('package', result));\n\n return {\n exitCode: countErrorDiagnostics(result.diagnostics) > 0 ? 1 : 0,\n };\n}\n\nfunction renderAnalysisReport(\n commandName: DoctorCommandName,\n result: DoctorAnalysisResult,\n): string {\n const lines = [\n `doctor ${commandName}`,\n `target: ${result.targetPath}`,\n `profile: ${result.profile}`,\n `checks: ${result.appliedChecks.length > 0 ? result.appliedChecks.join(', ') : 'none'}`,\n `repoMarkers: ${result.repoMarkers.length > 0 ? result.repoMarkers.join(', ') : 'none'}`,\n '',\n 'Diagnostics:',\n ];\n\n if (result.diagnostics.length === 0) {\n lines.push(' none');\n } else {\n for (const diagnostic of result.diagnostics) {\n lines.push(renderDiagnosticLine(diagnostic));\n }\n }\n\n const readiness = result.readiness ?? [];\n lines.push('');\n lines.push('Readiness:');\n if (readiness.length === 0) {\n lines.push(' none');\n } else {\n for (const item of readiness) {\n lines.push(renderReadinessLine(item));\n }\n }\n\n if (commandName === 'fix') {\n lines.push('');\n lines.push('Planned changes:');\n\n if (result.plannedChanges.length === 0) {\n lines.push(' none');\n } else {\n for (const change of result.plannedChanges) {\n lines.push(renderPlannedChangeLine(change));\n }\n }\n }\n\n const errorCount = countErrorDiagnostics(result.diagnostics);\n const warningCount = countWarningDiagnostics(result.diagnostics);\n\n lines.push('');\n lines.push(`Summary: ${errorCount} error(s), ${warningCount} warning(s)`);\n lines.push('');\n\n return lines.join('\\n');\n}\n\nfunction renderDiagnosticLine(diagnostic: DoctorDiagnostic): string {\n return ` - ${diagnostic.severity.toUpperCase()} ${diagnostic.ruleId} (${diagnostic.code}): ${diagnostic.message}`;\n}\n\nfunction renderReadinessLine(item: DoctorReadiness): string {\n return ` - ${item.target} ${item.environment} ${item.provider} ${item.transport}: ${item.status} — ${item.message}`;\n}\n\nfunction renderPlannedChangeLine(change: DoctorPlannedChange): string {\n return ` - ${change.ruleId} [${change.kind}]: ${change.description}`;\n}\n\nfunction renderCommandFailure(commandName: DoctorCommandName, error: unknown): string {\n const message = error instanceof Error ? error.message : String(error);\n return [`Failed to run doctor ${commandName}: ${message}`, ''].join('\\n');\n}\n\nfunction isHelpToken(value: string): boolean {\n return value === '--help' || value === '-h' || value === 'help';\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export type { DoctorAnalysisRequest, DoctorAnalysisResult, DoctorFixPlan, DoctorPlannedChange, DoctorPlannedChangeKind, DoctorTargetCheck, DoctorTargetMode, } from './analysis.js';
2
2
  export { analyzeAuthReadiness, type DoctorAuthReadinessAnalysis } from './authReadinessAnalysis.js';
3
3
  export { analyzeAuthReadinessFile } from './authReadinessFileAnalysis.js';
4
+ export { CAPABILITIES } from './capabilities/index.js';
4
5
  export { createDoctorRuntimeProvider, type CreateDoctorRuntimeProviderOptions, } from './cli/index.js';
5
6
  export { runCli } from './cli/standalone.js';
6
7
  export type { DoctorCommandContext, DoctorCommandRunResult } from './commandContext.js';
@@ -8,6 +9,6 @@ export { createDefaultCommandContext } from './commandContext.js';
8
9
  export { analyzeDoctorTarget, analyzeDoctorTargetWithCliLayout, } from './dependencyPolicyAnalysis.js';
9
10
  export type { DoctorDiagnostic, DoctorDiagnosticCode, DoctorDiagnosticSeverity, DoctorPolicyProfile, DoctorRuleId, } from './diagnostics.js';
10
11
  export { analyzeAppManifest, analyzeAppManifestFile, analyzeAppManifestTarget, } from './manifestAnalysis.js';
11
- export { DOCTOR_CAPABILITIES, DOCTOR_COMMAND_CATEGORY, DOCTOR_PACKAGE_METADATA, DOCTOR_PACKAGE_NAME, DOCTOR_PACKAGE_VERSION, } from './packageMetadata.js';
12
+ export { DOCTOR_COMMAND_CATEGORY, DOCTOR_PACKAGE_METADATA, DOCTOR_PACKAGE_NAME, DOCTOR_PACKAGE_VERSION, } from './packageMetadata.js';
12
13
  export type { DoctorReadiness, DoctorReadinessStatus } from './readiness.js';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACL,2BAA2B,EAC3B,KAAK,kCAAkC,GACxC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,gBAAgB,EACh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BAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  export { analyzeAuthReadiness } from './authReadinessAnalysis.js';
2
2
  export { analyzeAuthReadinessFile } from './authReadinessFileAnalysis.js';
3
+ export { CAPABILITIES } from './capabilities/index.js';
3
4
  export { createDoctorRuntimeProvider, } from './cli/index.js';
4
5
  export { runCli } from './cli/standalone.js';
5
6
  export { createDefaultCommandContext } from './commandContext.js';
6
7
  export { analyzeDoctorTarget, analyzeDoctorTargetWithCliLayout, } from './dependencyPolicyAnalysis.js';
7
8
  export { analyzeAppManifest, analyzeAppManifestFile, analyzeAppManifestTarget, } from './manifestAnalysis.js';
8
- export { DOCTOR_CAPABILITIES, DOCTOR_COMMAND_CATEGORY, DOCTOR_PACKAGE_METADATA, DOCTOR_PACKAGE_NAME, DOCTOR_PACKAGE_VERSION, } from './packageMetadata.js';
9
+ export { DOCTOR_COMMAND_CATEGORY, DOCTOR_PACKAGE_METADATA, DOCTOR_PACKAGE_NAME, DOCTOR_PACKAGE_VERSION, } from './packageMetadata.js';
9
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAoC,MAAM,4BAA4B,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACL,2BAA2B,GAE5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC","sourcesContent":["export type {\n DoctorAnalysisRequest,\n DoctorAnalysisResult,\n DoctorFixPlan,\n DoctorPlannedChange,\n DoctorPlannedChangeKind,\n DoctorTargetCheck,\n DoctorTargetMode,\n} from './analysis.js';\nexport { analyzeAuthReadiness, type DoctorAuthReadinessAnalysis } from './authReadinessAnalysis.js';\nexport { analyzeAuthReadinessFile } from './authReadinessFileAnalysis.js';\nexport {\n createDoctorRuntimeProvider,\n type CreateDoctorRuntimeProviderOptions,\n} from './cli/index.js';\nexport { runCli } from './cli/standalone.js';\nexport type { DoctorCommandContext, DoctorCommandRunResult } from './commandContext.js';\nexport { createDefaultCommandContext } from './commandContext.js';\nexport {\n analyzeDoctorTarget,\n analyzeDoctorTargetWithCliLayout,\n} from './dependencyPolicyAnalysis.js';\nexport type {\n DoctorDiagnostic,\n DoctorDiagnosticCode,\n DoctorDiagnosticSeverity,\n DoctorPolicyProfile,\n DoctorRuleId,\n} from './diagnostics.js';\nexport {\n analyzeAppManifest,\n analyzeAppManifestFile,\n analyzeAppManifestTarget,\n} from './manifestAnalysis.js';\nexport {\n DOCTOR_CAPABILITIES,\n DOCTOR_COMMAND_CATEGORY,\n DOCTOR_PACKAGE_METADATA,\n DOCTOR_PACKAGE_NAME,\n DOCTOR_PACKAGE_VERSION,\n} from './packageMetadata.js';\nexport type { DoctorReadiness, DoctorReadinessStatus } from './readiness.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAoC,MAAM,4BAA4B,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,2BAA2B,GAE5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC","sourcesContent":["export type {\n DoctorAnalysisRequest,\n DoctorAnalysisResult,\n DoctorFixPlan,\n DoctorPlannedChange,\n DoctorPlannedChangeKind,\n DoctorTargetCheck,\n DoctorTargetMode,\n} from './analysis.js';\nexport { analyzeAuthReadiness, type DoctorAuthReadinessAnalysis } from './authReadinessAnalysis.js';\nexport { analyzeAuthReadinessFile } from './authReadinessFileAnalysis.js';\nexport { CAPABILITIES } from './capabilities/index.js';\nexport {\n createDoctorRuntimeProvider,\n type CreateDoctorRuntimeProviderOptions,\n} from './cli/index.js';\nexport { runCli } from './cli/standalone.js';\nexport type { DoctorCommandContext, DoctorCommandRunResult } from './commandContext.js';\nexport { createDefaultCommandContext } from './commandContext.js';\nexport {\n analyzeDoctorTarget,\n analyzeDoctorTargetWithCliLayout,\n} from './dependencyPolicyAnalysis.js';\nexport type {\n DoctorDiagnostic,\n DoctorDiagnosticCode,\n DoctorDiagnosticSeverity,\n DoctorPolicyProfile,\n DoctorRuleId,\n} from './diagnostics.js';\nexport {\n analyzeAppManifest,\n analyzeAppManifestFile,\n analyzeAppManifestTarget,\n} from './manifestAnalysis.js';\nexport {\n DOCTOR_COMMAND_CATEGORY,\n DOCTOR_PACKAGE_METADATA,\n DOCTOR_PACKAGE_NAME,\n DOCTOR_PACKAGE_VERSION,\n} from './packageMetadata.js';\nexport type { DoctorReadiness, DoctorReadinessStatus } from './readiness.js';\n"]}
@@ -1,10 +1,41 @@
1
1
  export declare const DOCTOR_PACKAGE_NAME: string;
2
2
  export declare const DOCTOR_PACKAGE_VERSION: string;
3
3
  export declare const DOCTOR_COMMAND_CATEGORY: "doctor";
4
- export declare const DOCTOR_CAPABILITIES: readonly ["doctor.validate", "doctor.fix", "doctor.repo", "doctor.package"];
5
4
  export declare const DOCTOR_PACKAGE_METADATA: {
6
5
  readonly category: "doctor";
7
6
  readonly provider: "./dist/cli/index.js";
8
- readonly capabilities: readonly ["doctor.validate", "doctor.fix", "doctor.repo", "doctor.package"];
7
+ readonly capabilities: readonly [{
8
+ readonly id: "doctor.validate";
9
+ readonly owner: "@ankhorage/doctor";
10
+ readonly access: readonly ["invoke"];
11
+ readonly binding: {
12
+ readonly kind: "action";
13
+ readonly bindableAs: readonly ["target"];
14
+ };
15
+ }, {
16
+ readonly id: "doctor.fix";
17
+ readonly owner: "@ankhorage/doctor";
18
+ readonly access: readonly ["invoke"];
19
+ readonly binding: {
20
+ readonly kind: "action";
21
+ readonly bindableAs: readonly ["target"];
22
+ };
23
+ }, {
24
+ readonly id: "doctor.repo";
25
+ readonly owner: "@ankhorage/doctor";
26
+ readonly access: readonly ["invoke"];
27
+ readonly binding: {
28
+ readonly kind: "action";
29
+ readonly bindableAs: readonly ["target"];
30
+ };
31
+ }, {
32
+ readonly id: "doctor.package";
33
+ readonly owner: "@ankhorage/doctor";
34
+ readonly access: readonly ["invoke"];
35
+ readonly binding: {
36
+ readonly kind: "action";
37
+ readonly bindableAs: readonly ["target"];
38
+ };
39
+ }];
9
40
  };
10
41
  //# sourceMappingURL=packageMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageMetadata.d.ts","sourceRoot":"","sources":["../src/packageMetadata.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,mBAAmB,QAAmB,CAAC;AACpD,eAAO,MAAM,sBAAsB,QAAsB,CAAC;AAC1D,eAAO,MAAM,uBAAuB,UAAkD,CAAC;AACvF,eAAO,MAAM,mBAAmB,6EAKgB,CAAC;AAEjD,eAAO,MAAM,uBAAuB;;;;CAII,CAAC"}
1
+ {"version":3,"file":"packageMetadata.d.ts","sourceRoot":"","sources":["../src/packageMetadata.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,QAAmB,CAAC;AACpD,eAAO,MAAM,sBAAsB,QAAsB,CAAC;AAC1D,eAAO,MAAM,uBAAuB,UAAkD,CAAC;AAEvF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAII,CAAC"}
@@ -1,16 +1,11 @@
1
1
  import packageJson from '../package.json';
2
+ import { CAPABILITIES } from './capabilities/index.js';
2
3
  export const DOCTOR_PACKAGE_NAME = packageJson.name;
3
4
  export const DOCTOR_PACKAGE_VERSION = packageJson.version;
4
5
  export const DOCTOR_COMMAND_CATEGORY = 'doctor';
5
- export const DOCTOR_CAPABILITIES = [
6
- 'doctor.validate',
7
- 'doctor.fix',
8
- 'doctor.repo',
9
- 'doctor.package',
10
- ];
11
6
  export const DOCTOR_PACKAGE_METADATA = {
12
7
  category: DOCTOR_COMMAND_CATEGORY,
13
8
  provider: './dist/cli/index.js',
14
- capabilities: DOCTOR_CAPABILITIES,
9
+ capabilities: CAPABILITIES,
15
10
  };
16
11
  //# sourceMappingURL=packageMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageMetadata.js","sourceRoot":"","sources":["../src/packageMetadata.ts"],"names":[],"mappings":"AAMA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,IAAI,CAAC;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC,OAAO,CAAC;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,QAA+C,CAAC;AACvF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,iBAAiB;IACjB,YAAY;IACZ,aAAa;IACb,gBAAgB;CAC8B,CAAC;AAEjD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,uBAAuB;IACjC,QAAQ,EAAE,qBAAqB;IAC/B,YAAY,EAAE,mBAAmB;CACK,CAAC","sourcesContent":["import type {\n AnkhCapabilityId,\n AnkhCommandCategory,\n AnkhPackageMetadata,\n} from '@ankhorage/contracts/cli';\n\nimport packageJson from '../package.json';\n\nexport const DOCTOR_PACKAGE_NAME = packageJson.name;\nexport const DOCTOR_PACKAGE_VERSION = packageJson.version;\nexport const DOCTOR_COMMAND_CATEGORY = 'doctor' as const satisfies AnkhCommandCategory;\nexport const DOCTOR_CAPABILITIES = [\n 'doctor.validate',\n 'doctor.fix',\n 'doctor.repo',\n 'doctor.package',\n] as const satisfies readonly AnkhCapabilityId[];\n\nexport const DOCTOR_PACKAGE_METADATA = {\n category: DOCTOR_COMMAND_CATEGORY,\n provider: './dist/cli/index.js',\n capabilities: DOCTOR_CAPABILITIES,\n} as const satisfies AnkhPackageMetadata;\n"]}
1
+ {"version":3,"file":"packageMetadata.js","sourceRoot":"","sources":["../src/packageMetadata.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,IAAI,CAAC;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC,OAAO,CAAC;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,QAA+C,CAAC;AAEvF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,uBAAuB;IACjC,QAAQ,EAAE,qBAAqB;IAC/B,YAAY,EAAE,YAAY;CACY,CAAC","sourcesContent":["import type { AnkhCommandCategory, AnkhPackageMetadata } from '@ankhorage/contracts/cli';\n\nimport packageJson from '../package.json';\nimport { CAPABILITIES } from './capabilities/index.js';\n\nexport const DOCTOR_PACKAGE_NAME = packageJson.name;\nexport const DOCTOR_PACKAGE_VERSION = packageJson.version;\nexport const DOCTOR_COMMAND_CATEGORY = 'doctor' as const satisfies AnkhCommandCategory;\n\nexport const DOCTOR_PACKAGE_METADATA = {\n category: DOCTOR_COMMAND_CATEGORY,\n provider: './dist/cli/index.js',\n capabilities: CAPABILITIES,\n} as const satisfies AnkhPackageMetadata;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ankhorage/doctor",
3
- "version": "0.12.16",
3
+ "version": "0.13.0",
4
4
  "description": "Executable Ankh provider and standalone CLI for lightweight repo and package compliance diagnostics.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -39,7 +39,12 @@
39
39
  "import": "./dist/cli/index.js",
40
40
  "default": "./dist/cli/index.js"
41
41
  },
42
- "./package.json": "./package.json"
42
+ "./package.json": "./package.json",
43
+ "./capabilities": {
44
+ "types": "./dist/capabilities/index.d.ts",
45
+ "import": "./dist/capabilities/index.js",
46
+ "default": "./dist/capabilities/index.js"
47
+ }
43
48
  },
44
49
  "files": [
45
50
  "dist",
@@ -56,10 +61,58 @@
56
61
  "category": "doctor",
57
62
  "provider": "./dist/cli/index.js",
58
63
  "capabilities": [
59
- "doctor.validate",
60
- "doctor.fix",
61
- "doctor.repo",
62
- "doctor.package"
64
+ {
65
+ "id": "doctor.validate",
66
+ "owner": "@ankhorage/doctor",
67
+ "access": [
68
+ "invoke"
69
+ ],
70
+ "binding": {
71
+ "kind": "action",
72
+ "bindableAs": [
73
+ "target"
74
+ ]
75
+ }
76
+ },
77
+ {
78
+ "id": "doctor.fix",
79
+ "owner": "@ankhorage/doctor",
80
+ "access": [
81
+ "invoke"
82
+ ],
83
+ "binding": {
84
+ "kind": "action",
85
+ "bindableAs": [
86
+ "target"
87
+ ]
88
+ }
89
+ },
90
+ {
91
+ "id": "doctor.repo",
92
+ "owner": "@ankhorage/doctor",
93
+ "access": [
94
+ "invoke"
95
+ ],
96
+ "binding": {
97
+ "kind": "action",
98
+ "bindableAs": [
99
+ "target"
100
+ ]
101
+ }
102
+ },
103
+ {
104
+ "id": "doctor.package",
105
+ "owner": "@ankhorage/doctor",
106
+ "access": [
107
+ "invoke"
108
+ ],
109
+ "binding": {
110
+ "kind": "action",
111
+ "bindableAs": [
112
+ "target"
113
+ ]
114
+ }
115
+ }
63
116
  ]
64
117
  },
65
118
  "scripts": {
@@ -78,7 +131,7 @@
78
131
  "test:standalone": "bun test tests/standaloneContract.test.ts"
79
132
  },
80
133
  "dependencies": {
81
- "@ankhorage/contracts": "^22.8.103",
134
+ "@ankhorage/contracts": "^24.1.0",
82
135
  "@ankhorage/dependency-graph": "^1.2.0",
83
136
  "@ankhorage/rules-architecture": "^0.5.0",
84
137
  "@ankhorage/rules-repository": "^0.2.0",
@@ -86,8 +139,8 @@
86
139
  "@ankhorage/utility": "^1.9.85"
87
140
  },
88
141
  "devDependencies": {
89
- "@ankhorage/ankh": "^0.11.1",
90
- "@ankhorage/devtools": "^2.1.13",
142
+ "@ankhorage/ankh": "^0.12.0",
143
+ "@ankhorage/devtools": "^2.1.18",
91
144
  "@ankhorage/paradox": "^0.2.28",
92
145
  "@types/bun": "^1.4.2",
93
146
  "@types/node": "^26.6.4",
package/src/analysis.ts CHANGED
@@ -2,6 +2,12 @@ import { promises as fs } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
4
 
5
+ import {
6
+ areCapabilitiesEqual,
7
+ type Capability,
8
+ isCapability,
9
+ normalizeCapability,
10
+ } from '@ankhorage/contracts/capabilities';
5
11
  import { REPOSITORY_RULE_METADATA } from '@ankhorage/rules-repository';
6
12
  import { uniqueSortedStrings } from '@ankhorage/utility/array';
7
13
 
@@ -48,7 +54,7 @@ export interface DoctorAnalysisResult {
48
54
  }
49
55
 
50
56
  interface ProviderInspectionResult {
51
- readonly capabilities: readonly string[];
57
+ readonly capabilities: readonly Capability[];
52
58
  readonly commandCapabilities: readonly string[];
53
59
  readonly commandPaths: readonly string[];
54
60
  readonly handlerPaths: readonly string[];
@@ -639,18 +645,16 @@ async function validateAnkhMetadataAndProvider(request: {
639
645
  return diagnostics;
640
646
  }
641
647
 
642
- const metadataCapabilities = Array.isArray(metadata.capabilities)
643
- ? metadata.capabilities.filter(isNonEmptyString)
644
- : [];
645
- const providerCapabilities = uniqueSortedStrings(inspection.result.capabilities);
648
+ const metadataCapabilities = readCapabilities(metadata.capabilities);
649
+ const providerCapabilities = inspection.result.capabilities;
646
650
  const commandCapabilities = uniqueSortedStrings(inspection.result.commandCapabilities);
647
651
 
648
- if (!sameStringSet(metadataCapabilities, commandCapabilities)) {
652
+ if (!sameCapabilitySet(metadataCapabilities, providerCapabilities)) {
649
653
  diagnostics.push(
650
654
  createDiagnostic({
651
655
  code: 'field-invalid',
652
656
  message:
653
- 'package.json.ankh capabilities must match the implemented provider command capabilities exactly.',
657
+ 'package.json.ankh capabilities must match the implemented provider capability descriptors exactly.',
654
658
  path: request.packageJsonPath,
655
659
  profile: request.profile,
656
660
  ruleId: 'package.ankh.capabilities.match-provider',
@@ -659,7 +663,12 @@ async function validateAnkhMetadataAndProvider(request: {
659
663
  );
660
664
  }
661
665
 
662
- if (!sameStringSet(providerCapabilities, commandCapabilities)) {
666
+ if (
667
+ !sameStringSet(
668
+ providerCapabilities.map((capability) => capability.id),
669
+ commandCapabilities,
670
+ )
671
+ ) {
663
672
  diagnostics.push(
664
673
  createDiagnostic({
665
674
  code: 'field-invalid',
@@ -732,7 +741,7 @@ async function inspectProviderSource(request: {
732
741
  };
733
742
  }
734
743
 
735
- const capabilities = readStringArray(provider.capabilities);
744
+ const capabilities = readCapabilities(provider.capabilities);
736
745
  const commands = Array.isArray(provider.commands) ? provider.commands : [];
737
746
  const handlers = Array.isArray(provider.handlers) ? provider.handlers : [];
738
747
 
@@ -1092,9 +1101,9 @@ function validateAnkhMetadataShape(value: unknown, providerPackage: boolean): st
1092
1101
 
1093
1102
  if (
1094
1103
  !Array.isArray(value.capabilities) ||
1095
- value.capabilities.some((capability) => !isNonEmptyString(capability))
1104
+ value.capabilities.some((capability) => !isCapability(capability))
1096
1105
  ) {
1097
- return 'package.json "ankh.capabilities" must be an array of non-empty strings.';
1106
+ return 'package.json "ankh.capabilities" must be an array of canonical Capability descriptors.';
1098
1107
  }
1099
1108
 
1100
1109
  return null;
@@ -1180,6 +1189,26 @@ function readStringArray(value: unknown): string[] {
1180
1189
  return Array.isArray(value) ? value.filter(isNonEmptyString) : [];
1181
1190
  }
1182
1191
 
1192
+ /*** Read and normalize canonical Capability descriptors from untrusted metadata. */
1193
+ function readCapabilities(value: unknown): Capability[] {
1194
+ return Array.isArray(value) ? value.filter(isCapability).map(normalizeCapability) : [];
1195
+ }
1196
+
1197
+ /*** Compare capability collections by canonical id and descriptor semantics. */
1198
+ function sameCapabilitySet(left: readonly Capability[], right: readonly Capability[]): boolean {
1199
+ const leftById = new Map(left.map((capability) => [capability.id, capability]));
1200
+ const rightById = new Map(right.map((capability) => [capability.id, capability]));
1201
+ return (
1202
+ leftById.size === left.length &&
1203
+ rightById.size === right.length &&
1204
+ leftById.size === rightById.size &&
1205
+ [...leftById].every(([id, capability]) => {
1206
+ const other = rightById.get(id);
1207
+ return other !== undefined && areCapabilitiesEqual(capability, other);
1208
+ })
1209
+ );
1210
+ }
1211
+
1183
1212
  function sameStringSet(left: readonly string[], right: readonly string[]): boolean {
1184
1213
  const leftSet = uniqueSortedStrings(left);
1185
1214
  const rightSet = uniqueSortedStrings(right);
@@ -0,0 +1,28 @@
1
+ import type { Capability } from '@ankhorage/contracts/capabilities';
2
+
3
+ export const CAPABILITIES = [
4
+ {
5
+ id: 'doctor.validate',
6
+ owner: '@ankhorage/doctor',
7
+ access: ['invoke'],
8
+ binding: { kind: 'action', bindableAs: ['target'] },
9
+ },
10
+ {
11
+ id: 'doctor.fix',
12
+ owner: '@ankhorage/doctor',
13
+ access: ['invoke'],
14
+ binding: { kind: 'action', bindableAs: ['target'] },
15
+ },
16
+ {
17
+ id: 'doctor.repo',
18
+ owner: '@ankhorage/doctor',
19
+ access: ['invoke'],
20
+ binding: { kind: 'action', bindableAs: ['target'] },
21
+ },
22
+ {
23
+ id: 'doctor.package',
24
+ owner: '@ankhorage/doctor',
25
+ access: ['invoke'],
26
+ binding: { kind: 'action', bindableAs: ['target'] },
27
+ },
28
+ ] as const satisfies readonly Capability[];
package/src/cli/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { AnkhCommandHandler, AnkhRuntimeCommandProvider } from '@ankhorage/ankh';
2
2
 
3
+ import { CAPABILITIES } from '../capabilities/index.js';
3
4
  import {
4
5
  createProviderCommandDescriptors,
5
6
  DOCTOR_COMMANDS,
@@ -9,7 +10,6 @@ import {
9
10
  } from '../commands.js';
10
11
  import { analyzeDoctorTargetWithCliLayout } from '../dependencyPolicyAnalysis.js';
11
12
  import {
12
- DOCTOR_CAPABILITIES,
13
13
  DOCTOR_COMMAND_CATEGORY,
14
14
  DOCTOR_PACKAGE_NAME,
15
15
  DOCTOR_PACKAGE_VERSION,
@@ -33,7 +33,7 @@ export function createDoctorRuntimeProvider(
33
33
  id: DOCTOR_PACKAGE_NAME,
34
34
  category: DOCTOR_COMMAND_CATEGORY,
35
35
  version: DOCTOR_PACKAGE_VERSION,
36
- capabilities: [...DOCTOR_CAPABILITIES],
36
+ capabilities: CAPABILITIES,
37
37
  commands: createProviderCommandDescriptors(),
38
38
  handlers: DOCTOR_COMMANDS.map((command) => {
39
39
  const handler: AnkhCommandHandler = (request) =>
package/src/commands.ts CHANGED
@@ -1,6 +1,8 @@
1
- import type { AnkhCapabilityId, AnkhCommandDescriptor } from '@ankhorage/contracts/cli';
1
+ import type { Capability } from '@ankhorage/contracts/capabilities';
2
+ import type { AnkhCommandDescriptor } from '@ankhorage/contracts/cli';
2
3
 
3
4
  import type { DoctorAnalysisResult, DoctorPlannedChange, DoctorTargetMode } from './analysis.js';
5
+ import { CAPABILITIES } from './capabilities/index.js';
4
6
  import { analyzeDoctorTargetWithCliLayout } from './cliLayoutAnalysis.js';
5
7
  import type { DoctorCommandContext, DoctorCommandRunResult } from './commandContext.js';
6
8
  import {
@@ -8,7 +10,7 @@ import {
8
10
  countWarningDiagnostics,
9
11
  type DoctorDiagnostic,
10
12
  } from './diagnostics.js';
11
- import { DOCTOR_CAPABILITIES, DOCTOR_COMMAND_CATEGORY } from './packageMetadata.js';
13
+ import { DOCTOR_COMMAND_CATEGORY } from './packageMetadata.js';
12
14
  import type { DoctorReadiness } from './readiness.js';
13
15
 
14
16
  type DoctorCommandName = 'fix' | 'package' | 'repo' | 'validate';
@@ -24,7 +26,7 @@ type DoctorCommandImplementation = (
24
26
  ) => Promise<DoctorCommandRunResult>;
25
27
 
26
28
  export interface DoctorCommandDefinition {
27
- readonly capability: AnkhCapabilityId;
29
+ readonly capability: Capability['id'];
28
30
  readonly mode: DoctorTargetMode;
29
31
  readonly path: readonly [DoctorCommandName];
30
32
  readonly standaloneName: DoctorCommandName;
@@ -53,11 +55,11 @@ export type RunDoctorCommandImpl = (
53
55
  ) => Promise<DoctorCommandRunResult>;
54
56
 
55
57
  const COMMAND_CAPABILITIES = {
56
- validate: DOCTOR_CAPABILITIES[0],
57
- fix: DOCTOR_CAPABILITIES[1],
58
- repo: DOCTOR_CAPABILITIES[2],
59
- package: DOCTOR_CAPABILITIES[3],
60
- } as const satisfies Record<DoctorCommandName, AnkhCapabilityId>;
58
+ validate: CAPABILITIES[0].id,
59
+ fix: CAPABILITIES[1].id,
60
+ repo: CAPABILITIES[2].id,
61
+ package: CAPABILITIES[3].id,
62
+ } as const satisfies Record<DoctorCommandName, Capability['id']>;
61
63
 
62
64
  export const DOCTOR_COMMANDS = [
63
65
  {
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export type {
9
9
  } from './analysis.js';
10
10
  export { analyzeAuthReadiness, type DoctorAuthReadinessAnalysis } from './authReadinessAnalysis.js';
11
11
  export { analyzeAuthReadinessFile } from './authReadinessFileAnalysis.js';
12
+ export { CAPABILITIES } from './capabilities/index.js';
12
13
  export {
13
14
  createDoctorRuntimeProvider,
14
15
  type CreateDoctorRuntimeProviderOptions,
@@ -33,7 +34,6 @@ export {
33
34
  analyzeAppManifestTarget,
34
35
  } from './manifestAnalysis.js';
35
36
  export {
36
- DOCTOR_CAPABILITIES,
37
37
  DOCTOR_COMMAND_CATEGORY,
38
38
  DOCTOR_PACKAGE_METADATA,
39
39
  DOCTOR_PACKAGE_NAME,
@@ -1,23 +1,14 @@
1
- import type {
2
- AnkhCapabilityId,
3
- AnkhCommandCategory,
4
- AnkhPackageMetadata,
5
- } from '@ankhorage/contracts/cli';
1
+ import type { AnkhCommandCategory, AnkhPackageMetadata } from '@ankhorage/contracts/cli';
6
2
 
7
3
  import packageJson from '../package.json';
4
+ import { CAPABILITIES } from './capabilities/index.js';
8
5
 
9
6
  export const DOCTOR_PACKAGE_NAME = packageJson.name;
10
7
  export const DOCTOR_PACKAGE_VERSION = packageJson.version;
11
8
  export const DOCTOR_COMMAND_CATEGORY = 'doctor' as const satisfies AnkhCommandCategory;
12
- export const DOCTOR_CAPABILITIES = [
13
- 'doctor.validate',
14
- 'doctor.fix',
15
- 'doctor.repo',
16
- 'doctor.package',
17
- ] as const satisfies readonly AnkhCapabilityId[];
18
9
 
19
10
  export const DOCTOR_PACKAGE_METADATA = {
20
11
  category: DOCTOR_COMMAND_CATEGORY,
21
12
  provider: './dist/cli/index.js',
22
- capabilities: DOCTOR_CAPABILITIES,
13
+ capabilities: CAPABILITIES,
23
14
  } as const satisfies AnkhPackageMetadata;