@ekanos/cli 0.22.1 → 0.23.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.
Files changed (76) hide show
  1. package/README.md +18 -4
  2. package/dist/commands/add.js +21 -10
  3. package/dist/commands/add.js.map +1 -1
  4. package/dist/commands/contract.js +12 -2
  5. package/dist/commands/contract.js.map +1 -1
  6. package/dist/commands/dev.js +33 -2
  7. package/dist/commands/dev.js.map +1 -1
  8. package/dist/commands/publish.d.ts +6 -0
  9. package/dist/commands/publish.js +80 -4
  10. package/dist/commands/publish.js.map +1 -1
  11. package/dist/commands/status.d.ts +44 -0
  12. package/dist/commands/status.js +79 -18
  13. package/dist/commands/status.js.map +1 -1
  14. package/dist/commands/upgrade.js +287 -144
  15. package/dist/commands/upgrade.js.map +1 -1
  16. package/dist/docs-links.js +5 -1
  17. package/dist/docs-links.js.map +1 -1
  18. package/dist/errors.d.ts +2 -0
  19. package/dist/errors.js +9 -0
  20. package/dist/errors.js.map +1 -1
  21. package/dist/exit-codes.d.ts +3 -0
  22. package/dist/exit-codes.js +3 -0
  23. package/dist/exit-codes.js.map +1 -1
  24. package/dist/experience/checks.js +2 -1
  25. package/dist/experience/checks.js.map +1 -1
  26. package/dist/experience/definition-checks.d.ts +7 -0
  27. package/dist/experience/definition-checks.js +36 -4
  28. package/dist/experience/definition-checks.js.map +1 -1
  29. package/dist/experience/init.js +10 -0
  30. package/dist/experience/init.js.map +1 -1
  31. package/dist/experience/load-experience.js +33 -2
  32. package/dist/experience/load-experience.js.map +1 -1
  33. package/dist/experience/pins.d.ts +10 -0
  34. package/dist/experience/pins.js +19 -1
  35. package/dist/experience/pins.js.map +1 -1
  36. package/dist/generated/phosphor-names.d.ts +3 -0
  37. package/dist/generated/phosphor-names.js +1541 -0
  38. package/dist/generated/phosphor-names.js.map +1 -0
  39. package/dist/harness-scaffold.d.ts +13 -0
  40. package/dist/harness-scaffold.js +19 -3
  41. package/dist/harness-scaffold.js.map +1 -1
  42. package/dist/icon-findings.d.ts +12 -17
  43. package/dist/icon-findings.js +49 -74
  44. package/dist/icon-findings.js.map +1 -1
  45. package/dist/index.js +28 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/lockfile-instances.d.ts +60 -0
  48. package/dist/lockfile-instances.js +177 -0
  49. package/dist/lockfile-instances.js.map +1 -0
  50. package/dist/pack-hygiene.d.ts +8 -0
  51. package/dist/pack-hygiene.js +57 -0
  52. package/dist/pack-hygiene.js.map +1 -0
  53. package/dist/package-manager.d.ts +34 -6
  54. package/dist/package-manager.js +130 -20
  55. package/dist/package-manager.js.map +1 -1
  56. package/dist/project.js +11 -0
  57. package/dist/project.js.map +1 -1
  58. package/dist/repo/scaffold.js +4 -0
  59. package/dist/repo/scaffold.js.map +1 -1
  60. package/dist/validate-findings.js +10 -1
  61. package/dist/validate-findings.js.map +1 -1
  62. package/dist/workspace-root.d.ts +16 -0
  63. package/dist/workspace-root.js +50 -0
  64. package/dist/workspace-root.js.map +1 -0
  65. package/package.json +4 -4
  66. package/templates/AGENTS.md.tmpl +11 -15
  67. package/templates/experience/package.json.tmpl +8 -6
  68. package/templates/experience/src/widgets/hello-widget.test.tsx.tmpl +49 -0
  69. package/templates/experience/vitest.config.ts.tmpl +21 -0
  70. package/templates/harness/next.config.mjs.tmpl +7 -4
  71. package/templates/package.json.tmpl +5 -5
  72. package/templates/skills/build-integration/references/widget-design.md +2 -3
  73. package/templates/skills/polish-widgets/references/patterns.md +5 -5
  74. package/dist/generated/fa-free-names.d.ts +0 -9
  75. package/dist/generated/fa-free-names.js +0 -2599
  76. package/dist/generated/fa-free-names.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SA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H,WAAW,CAAC,MAAM,GAAG,CAAC;YACpB,CAAC,CAAC;gBACE,4EAA4E;gBAC5E,GAAG,KAAK;aACT;YACH,CAAC,CAAC,KAAK;KACZ,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Finding } from '@ekanos/integration-schema';\nimport { spawn } from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\n\nimport { resolveAuthEnvironment } from '../auth/session';\nimport { cliVersion } from '../compatibility';\nimport type { CliContext } from '../context';\nimport {\n invalidStateError,\n networkError,\n preconditionError,\n validationError,\n} from '../errors';\nimport { EXIT_CODES } from '../exit-codes';\nimport { readInstalledPackageManifest } from '../harness-scaffold';\nimport {\n type PackageManager,\n detectPackageManager,\n installExactArgs,\n lockfileName,\n} from '../package-manager';\nimport {\n type BuildScriptsResult,\n ensureBuildScriptsAnswered,\n skippedBuildScriptsHint,\n findIgnoredBuilds,\n ignoredBuildsHint,\n isIgnoredBuildsFailure,\n WORKSPACE_FILE,\n} from '../pnpm-builds';\nimport { loadProject } from '../project';\nimport { classifyPath, writeFileNoFollow } from '../safe-fs';\nimport { renderTemplate, toDisplayName } from '../templates';\nimport {\n TOOLCHAIN_PACKAGES,\n type ToolchainKey,\n type ToolchainVersions,\n isExactVersion,\n} from '../toolchain';\nimport { resolveToolchainTarget } from '../toolchain-resolve';\nimport { type Ui, displayPath } from '../ui';\nimport { collectAllFindings } from '../validate-findings';\nimport {\n AGENT_CONTEXT_FILES,\n DOCS_GROUNDING_FILES,\n copyBundledSkillTrees,\n} from './init';\nimport { promptYesNo } from './publish';\n\n/**\n * `ekanos upgrade` — move a project's toolchain to a coherent target version\n * and VERIFY it before calling the job done.\n *\n * The whole point of this verb is that it cannot leave a project worse off\n * than it found it: `package.json` and the lockfile are snapshotted before\n * anything installs, the target set is only ever a coherence-checked whole\n * (never \"latest of each, independently\" — see `toolchain-resolve.ts`), and\n * any failure from install through validate through the project's own test\n * script rolls everything back to the snapshot and says exactly which step\n * failed. A partner (or an agent) running this unattended should never end up\n * with a half-upgraded, uninstallable project.\n */\n\nexport interface UpgradeArgs {\n dir: string;\n host?: string;\n env: Record<string, string | undefined>;\n /** Report current vs. target and exit 0. Never mutates anything. */\n check: boolean;\n /** Skip the interactive confirm; required to mutate outside a TTY. */\n yes: boolean;\n /** Skip the post-install validate + test-script verification. */\n noVerify: boolean;\n stdinIsTTY?: boolean;\n confirm?: (question: string) => Promise<boolean>;\n}\n\n/** Injectable seams so tests can exercise install/verify/rollback without shelling out. */\nexport interface UpgradeDeps {\n resolveTarget?: typeof resolveToolchainTarget;\n runInstall?: (\n argv: string[],\n bin: string,\n cwd: string,\n ) => Promise<{ code: number; output: string }>;\n runValidateStep?: (\n projectDir: string,\n ) => Promise<{ ok: boolean; findings?: Finding[] }>;\n runTestStep?: (\n projectDir: string,\n pm: PackageManager,\n ) => Promise<{ code: number; output: string }>;\n}\n\ninterface DeltaEntry {\n current: string | null;\n target: string;\n changed: boolean;\n}\n\nexport async function runUpgrade(\n ctx: CliContext,\n args: UpgradeArgs,\n deps: UpgradeDeps = {},\n): Promise<number> {\n const loaded = loadProject(args.dir);\n const pm = detectPackageManager(loaded.projectDir);\n\n // Captured BEFORE anything installs: the templates the project's CURRENT\n // (pre-upgrade) local `@ekanos/cli` ships, which is what actually\n // generated the agent-context files on disk — not necessarily this\n // process's own bundled templates, since `upgrade` is a machine-level verb\n // that never delegates and is routinely invoked via a DIFFERENT (global)\n // install. See `regenerateAgentContextFiles`.\n const oldAgentTemplates = captureAgentTemplates(loaded.projectDir);\n\n const current = readCurrentToolchain(loaded.projectDir);\n\n const session = resolveSessionQuietly(ctx, args);\n const resolveTarget = deps.resolveTarget ?? resolveToolchainTarget;\n const resolution = await resolveTarget({\n host: session?.host,\n session: session?.session,\n });\n\n if (resolution.status === 'unavailable') {\n throw networkError(\n 'Could not resolve a toolchain target from the Ekanos host or the ' +\n 'npm registry.',\n 'Check connectivity and retry. If this deployment has no ' +\n '\"/api/partner/toolchain\" route yet, the npm registry is the ' +\n 'fallback and a failure there means npm itself is unreachable.',\n );\n }\n\n if (resolution.status === 'incoherent') {\n throw preconditionError(\n `The resolved toolchain versions do not form an installable set: ` +\n resolution.detail,\n 'Retry in a moment — this is almost always a multi-package publish ' +\n 'still in flight, and it self-resolves once every package finishes ' +\n 'publishing.',\n );\n }\n\n if (resolution.status === 'invalid') {\n throw invalidStateError(\n `Refusing to upgrade: ${resolution.detail}.`,\n 'A toolchain version must be an exact release such as \"1.2.3\" — never a ' +\n 'git, file or tarball spec, which would install code from elsewhere. ' +\n '\"ekanos whoami\" shows which host you are signed in to.',\n );\n }\n\n const target = resolution.target;\n const deltas = computeDeltas(current, target);\n\n if (args.check) {\n return ctx.succeed(\n {\n source: resolution.source,\n current,\n target,\n deltas,\n ...(resolution.source === 'host'\n ? { minimum: resolution.minimum, notes: resolution.notes }\n : {}),\n },\n checkSummary(ctx.ui, resolution.source, deltas),\n );\n }\n\n const changedKeys = (Object.keys(deltas) as ToolchainKey[]).filter(\n (key) => deltas[key]!.changed,\n );\n\n if (changedKeys.length === 0) {\n return ctx.succeed(\n { source: resolution.source, current, target, deltas },\n ctx.ui.result({\n title: 'Already up to date',\n rows: [['Target', `resolved from ${resolution.source}`]],\n }),\n );\n }\n\n const isHuman = !ctx.jsonMode;\n const stdinIsTTY = args.stdinIsTTY ?? process.stdin.isTTY === true;\n const canPrompt = isHuman && stdinIsTTY;\n\n if (!args.yes) {\n if (!canPrompt) {\n throw validationError(\n 'Refusing to modify the project non-interactively without --yes.',\n 'Pass \"ekanos upgrade --yes\" to proceed, or \"ekanos upgrade --check\" ' +\n 'to preview the target with no changes.',\n );\n }\n\n ctx.log(planSummary(ctx.ui, resolution.source, deltas));\n const confirm = args.confirm ?? promptYesNo;\n const confirmed = await confirm('Upgrade now? [y/N]');\n\n if (!confirmed) {\n throw validationError(\n 'Upgrade was not confirmed.',\n 'Re-run \"ekanos upgrade --yes\" to proceed non-interactively, or ' +\n '\"ekanos upgrade --check\" to preview with no changes. Nothing was ' +\n 'modified.',\n );\n }\n }\n\n const packageJsonPath = path.join(loaded.projectDir, 'package.json');\n const manifest = readManifest(packageJsonPath);\n const specs = buildInstallSpecs(manifest, target, changedKeys);\n\n if (specs.length === 0) {\n return ctx.succeed(\n { source: resolution.source, current, target, deltas },\n ctx.ui.result({\n title: 'Nothing to install',\n tone: 'warn',\n notes: [\n 'None of the changed packages are direct dependencies of this project.',\n 'Their versions follow from whichever direct dependency pins them.',\n ],\n }),\n );\n }\n\n const snapshot = snapshotProject(loaded.projectDir, pm);\n let answeredBuildScripts: string[] = [];\n let buildScriptsSkipped: BuildScriptsResult['skipped'];\n\n try {\n const runInstall = deps.runInstall ?? defaultRunInstall;\n\n // pnpm 10+ refuses dependency build scripts nobody has answered, and a\n // new toolchain release can grow that list (0.4.0 added @swc/core and\n // @parcel/watcher via next-intl). A project scaffolded under an older\n // CLI has no line for them, so answer the closure BEFORE `pnpm add`, or\n // the install writes placeholders and exits ERR_PNPM_IGNORED_BUILDS.\n const buildScripts: BuildScriptsResult =\n pm.name === 'pnpm'\n ? ensureBuildScriptsAnswered(loaded.projectDir)\n : { changed: [] };\n answeredBuildScripts = buildScripts.changed;\n if (buildScripts.skipped) {\n buildScriptsSkipped = buildScripts.skipped;\n ctx.log(ctx.ui.dim(skippedBuildScriptsHint(buildScripts.skipped)));\n }\n if (answeredBuildScripts.length > 0) {\n ctx.log(\n ctx.ui.dim(\n `Answered dependency build scripts in pnpm-workspace.yaml: ${answeredBuildScripts.join(', ')}.`,\n ),\n );\n }\n\n for (const group of [\n specs.filter((s) => !s.dev),\n specs.filter((s) => s.dev),\n ]) {\n if (group.length === 0) continue;\n\n const argv = installExactArgs(\n pm,\n group.map((s) => `${s.name}@${s.version}`),\n group[0]!.dev,\n );\n ctx.log(\n ctx.ui.dim(\n `Running \"${pm.bin} ${argv.join(' ')}\" in ${displayPath(loaded.projectDir, process.cwd())}…`,\n ),\n );\n const result = await runInstall(argv, pm.bin, loaded.projectDir);\n\n if (result.code !== 0) {\n return await failAndRollback(\n ctx,\n snapshot,\n pm,\n loaded.projectDir,\n runInstall,\n {\n step: 'install',\n exitCode: EXIT_CODES.PRECONDITION_FAILED,\n message: isIgnoredBuildsFailure(result.output)\n ? `\"${pm.bin} ${argv.join(' ')}\" exited with code ${result.code}: ${ignoredBuildsHint(findIgnoredBuilds(result.output))}`\n : `\"${pm.bin} ${argv.join(' ')}\" exited with code ${result.code}.`,\n output: result.output,\n },\n );\n }\n }\n\n if (!args.noVerify) {\n const runValidateStep = deps.runValidateStep ?? defaultRunValidateStep;\n const validateResult = await runValidateStep(loaded.projectDir);\n\n if (!validateResult.ok) {\n return await failAndRollback(\n ctx,\n snapshot,\n pm,\n loaded.projectDir,\n runInstall,\n {\n step: 'validate',\n exitCode: EXIT_CODES.VALIDATION,\n message:\n 'The upgraded toolchain fails \"ekanos validate\" against this ' +\n \"project's own integration definition.\",\n output: JSON.stringify(validateResult.findings ?? [], null, 2),\n },\n );\n }\n\n const runTestStep = deps.runTestStep ?? defaultRunTestStep;\n const testResult = await runTestStep(loaded.projectDir, pm);\n\n if (testResult.code !== 0) {\n return await failAndRollback(\n ctx,\n snapshot,\n pm,\n loaded.projectDir,\n runInstall,\n {\n step: 'test',\n exitCode: testResult.code,\n message: `The project's test script exited with code ${testResult.code} on the upgraded toolchain.`,\n output: testResult.output,\n },\n );\n }\n }\n } finally {\n snapshot.dispose();\n }\n\n const newTemplatesDir = path.join(\n loaded.projectDir,\n 'node_modules',\n '@ekanos',\n 'cli',\n 'templates',\n );\n\n const regenerated = regenerateAgentContextFiles({\n projectDir: loaded.projectDir,\n slug: loaded.primary.slug,\n oldTemplates: oldAgentTemplates,\n newTemplatesDir,\n });\n\n // The regenerated AGENTS.md and skills may now REFERENCE artifacts this\n // project predates (docs/api-notes.md, .mcp.json, bundled skill trees) —\n // instructions pointing at files that don't exist are exactly the stale-docs\n // failure the docs-grounding feature closes, so create what's missing.\n // Create-if-missing ONLY: these files are partner/agent-authored after the\n // scaffold and are never regenerated.\n const scaffolded = scaffoldMissingDocsArtifacts({\n projectDir: loaded.projectDir,\n slug: loaded.primary.slug,\n newTemplatesDir,\n });\n\n // `specs` only ever covers DIRECT dependencies (see `buildInstallSpecs`) —\n // a changed key with no spec is transitive and was never actually\n // installed here, so the report (and the human summary) must say so\n // explicitly rather than implying every changed key was upgraded. This\n // matters most for exactly the scenario this PR's own delegation feature\n // targets: a globally-installed `ekanos` with no local `@ekanos/cli`\n // devDependency, where `cli` changes in `deltas` but the running global\n // binary itself is untouched by this command.\n const installedKeys = specs.map((spec) => spec.key);\n const skippedKeys = changedKeys.filter((key) => !installedKeys.includes(key));\n\n return ctx.succeed(\n {\n source: resolution.source,\n current,\n target,\n deltas,\n installed: installedKeys,\n skippedTransitive: skippedKeys,\n buildScripts: {\n answered: answeredBuildScripts,\n ...(buildScriptsSkipped ? { skipped: buildScriptsSkipped } : {}),\n },\n regenerated,\n scaffolded,\n },\n successSummary(\n ctx.ui,\n installedKeys,\n skippedKeys,\n deltas,\n regenerated,\n scaffolded,\n ),\n );\n}\n\n/**\n * Best-effort host/session resolution — NEVER throws. `upgrade` must work for\n * a partner who has never logged in at all (pure npm-registry flow), so the\n * throwing `resolveAuthEnvironment`/`requireSession` machinery is unusable\n * here; this mirrors the tolerant lookup `update-notice.ts` uses.\n */\nfunction resolveSessionQuietly(\n ctx: CliContext,\n args: UpgradeArgs,\n): { host: string; session: { accessToken: string } } | null {\n try {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const session = env.store.read(env.host);\n return session ? { host: env.host, session } : null;\n } catch {\n return null;\n }\n}\n\nfunction readCurrentToolchain(\n projectDir: string,\n): Record<ToolchainKey, string | null> {\n const result = {} as Record<ToolchainKey, string | null>;\n\n for (const [key, pkg] of Object.entries(TOOLCHAIN_PACKAGES) as [\n ToolchainKey,\n string,\n ][]) {\n const installed = readInstalledPackageManifest(projectDir, pkg);\n result[key] = installed?.version ?? (key === 'cli' ? cliVersion() : null);\n }\n\n return result;\n}\n\nfunction computeDeltas(\n current: Record<ToolchainKey, string | null>,\n target: ToolchainVersions,\n): Record<ToolchainKey, DeltaEntry> {\n const keys = Object.keys(TOOLCHAIN_PACKAGES) as ToolchainKey[];\n const result = {} as Record<ToolchainKey, DeltaEntry>;\n\n for (const key of keys) {\n result[key] = {\n current: current[key],\n target: target[key],\n changed: current[key] !== target[key],\n };\n }\n\n return result;\n}\n\ninterface InstallSpec {\n key: ToolchainKey;\n name: string;\n version: string;\n dev: boolean;\n}\n\n/**\n * Only packages the project depends on DIRECTLY are installed explicitly —\n * `@ekanos/integration-schema` and often `@ekanos/harness` are transitive\n * (pulled in by `@ekanos/sdk`), and forcing an exact transitive version would\n * need a package-manager-specific override mechanism this CLI does not\n * manage. Their versions follow from whichever direct dependency pins them,\n * which is exactly what the coherent target guarantees is already correct.\n */\nfunction buildInstallSpecs(\n manifest: Record<string, unknown>,\n target: ToolchainVersions,\n changedKeys: readonly ToolchainKey[],\n): InstallSpec[] {\n const deps = (manifest.dependencies ?? {}) as Record<string, unknown>;\n const devDeps = (manifest.devDependencies ?? {}) as Record<string, unknown>;\n\n const specs: InstallSpec[] = [];\n\n for (const key of changedKeys) {\n const pkg = TOOLCHAIN_PACKAGES[key];\n // Resolution already refuses an inexact version; this is the last check\n // before a value reaches `pnpm add`.\n if (!isExactVersion(target[key])) {\n throw invalidStateError(\n `Refusing to install ${pkg}@${target[key]}: not an exact version.`,\n 'A toolchain version must be an exact release such as \"1.2.3\".',\n );\n }\n if (pkg in deps) {\n specs.push({ key, name: pkg, version: target[key], dev: false });\n } else if (pkg in devDeps) {\n specs.push({ key, name: pkg, version: target[key], dev: true });\n }\n }\n\n return specs;\n}\n\nfunction readManifest(packageJsonPath: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n } catch (error) {\n throw preconditionError(\n `Could not read ${packageJsonPath}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n 'Ensure the project has a valid package.json, then re-run \"ekanos upgrade\".',\n );\n }\n if (typeof parsed !== 'object' || parsed === null) {\n throw preconditionError(\n `${packageJsonPath} does not contain a JSON object.`,\n 'Fix package.json, then re-run \"ekanos upgrade\".',\n );\n }\n return parsed as Record<string, unknown>;\n}\n\ninterface Snapshot {\n restore: () => void;\n dispose: () => void;\n}\n\n/**\n * Copy `package.json`, `pnpm-workspace.yaml` and the lockfile to a temp directory before anything\n * installs. `restore()` copies them back (and removes a lockfile that did not\n * exist before, if the failed install created one); `dispose()` cleans up the\n * temp copies once the run is over, success or failure.\n */\nfunction snapshotProject(projectDir: string, pm: PackageManager): Snapshot {\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ekanos-upgrade-'));\n const packageJsonPath = path.join(projectDir, 'package.json');\n\n // bun has shipped both a text (`bun.lock`) and a legacy binary\n // (`bun.lockb`) lockfile; snapshot whichever is actually present.\n const lockCandidates =\n pm.name === 'bun' ? ['bun.lock', 'bun.lockb'] : [lockfileName(pm)];\n const lockName = lockCandidates.find((name) =>\n fs.existsSync(path.join(projectDir, name)),\n );\n const lockfilePath = lockName\n ? path.join(projectDir, lockName)\n : path.join(projectDir, lockfileName(pm));\n const lockfileExisted = lockName !== undefined;\n\n const workspacePath = path.join(projectDir, WORKSPACE_FILE);\n const workspaceExisted = fs.existsSync(workspacePath);\n\n fs.copyFileSync(packageJsonPath, path.join(tmpDir, 'package.json'));\n if (workspaceExisted) {\n fs.copyFileSync(workspacePath, path.join(tmpDir, 'workspace.snapshot'));\n }\n if (lockfileExisted) {\n fs.copyFileSync(lockfilePath, path.join(tmpDir, 'lockfile.snapshot'));\n }\n\n return {\n restore: () => {\n fs.copyFileSync(path.join(tmpDir, 'package.json'), packageJsonPath);\n if (workspaceExisted) {\n fs.copyFileSync(path.join(tmpDir, 'workspace.snapshot'), workspacePath);\n } else if (fs.existsSync(workspacePath)) {\n fs.rmSync(workspacePath);\n }\n if (lockfileExisted) {\n fs.copyFileSync(path.join(tmpDir, 'lockfile.snapshot'), lockfilePath);\n } else if (fs.existsSync(lockfilePath)) {\n fs.rmSync(lockfilePath);\n }\n },\n dispose: () => {\n fs.rmSync(tmpDir, { recursive: true, force: true });\n },\n };\n}\n\ninterface StepFailure {\n step: 'install' | 'validate' | 'test';\n exitCode: number;\n message: string;\n output: string;\n}\n\n/**\n * The one rollback path every failure funnels through: restore the snapshot,\n * reinstall to put `node_modules` back in sync with the restored\n * `package.json`/lockfile, and report exactly which step failed and what it\n * said — with an explicit statement that the project was restored, so a\n * partner (or an agent) never has to wonder whether they are looking at a\n * half-upgraded tree.\n */\nasync function failAndRollback(\n ctx: CliContext,\n snapshot: Snapshot,\n pm: PackageManager,\n projectDir: string,\n runInstall: (\n argv: string[],\n bin: string,\n cwd: string,\n ) => Promise<{ code: number; output: string }>,\n failure: StepFailure,\n): Promise<number> {\n ctx.warn(\n `ekanos: the \"${failure.step}\" step failed — rolling back package.json ` +\n 'and the lockfile, then reinstalling to restore node_modules…',\n );\n\n snapshot.restore();\n // The SAME injectable installer seam used for the forward install — a test\n // that mocks it never shells out for the rollback path either.\n const restore = await runInstall(['install'], pm.bin, projectDir);\n\n return ctx.failWith({\n code: `upgrade_${failure.step}_failed`,\n message: failure.message,\n hint:\n `The project HAS BEEN RESTORED to its pre-upgrade state (package.json, ` +\n `lockfile and node_modules all rolled back${\n restore.code === 0\n ? ''\n : ' — though the restore install itself also failed with code ' +\n `${restore.code}; run \"${pm.bin} install\" by hand to finish ` +\n 'repairing node_modules'\n }). Read the output in data.output, fix the underlying issue, and ` +\n 're-run \"ekanos upgrade\".',\n exitCode: failure.exitCode,\n data: { step: failure.step, output: failure.output },\n });\n}\n\nasync function defaultRunInstall(\n argv: string[],\n bin: string,\n cwd: string,\n): Promise<{ code: number; output: string }> {\n return new Promise((resolve, reject) => {\n const child = spawn(bin, argv, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });\n let output = '';\n child.stdout?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.on('error', reject);\n child.on('close', (code) => resolve({ code: code ?? 1, output }));\n });\n}\n\nasync function defaultRunValidateStep(\n projectDir: string,\n): Promise<{ ok: boolean; findings?: Finding[] }> {\n const loaded = loadProject(projectDir);\n const findings = await collectAllFindings(loaded);\n const errorCount = findings.filter((f) => f.severity === 'error').length;\n return { ok: errorCount === 0, findings };\n}\n\nasync function defaultRunTestStep(\n projectDir: string,\n pm: PackageManager,\n): Promise<{ code: number; output: string }> {\n return new Promise((resolve, reject) => {\n const child = spawn(pm.bin, ['run', 'test'], {\n cwd: projectDir,\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n let output = '';\n child.stdout?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.on('error', reject);\n child.on('close', (code) => resolve({ code: code ?? 1, output }));\n });\n}\n\n/** Why a scaffolded doc file was left alone. Reported so a human knows whether to merge or to investigate. */\ntype SkipReason = 'edited-locally' | 'not-a-file' | 'write-refused';\n\ninterface RegenerationReport {\n updated: string[];\n unchanged: string[];\n needsAttention: string[];\n /** One entry per `needsAttention` path. */\n skipped: { file: string; reason: SkipReason }[];\n}\n\n/**\n * Read every `AGENT_CONTEXT_FILES` template source out of the project's\n * CURRENT (pre-upgrade) local `@ekanos/cli` install, before anything installs\n * over it. Missing entirely (the package isn't a resolvable local dependency)\n * just means every file below is treated conservatively — see\n * `regenerateAgentContextFiles`.\n */\nfunction captureAgentTemplates(projectDir: string): Map<string, string> {\n const templatesDir = path.join(\n projectDir,\n 'node_modules',\n '@ekanos',\n 'cli',\n 'templates',\n );\n const captured = new Map<string, string>();\n\n for (const { template } of AGENT_CONTEXT_FILES) {\n const templatePath = path.join(templatesDir, template);\n try {\n captured.set(template, fs.readFileSync(templatePath, 'utf8'));\n } catch {\n // Not resolvable — left out of the map, handled as \"can't verify\" below.\n }\n }\n\n return captured;\n}\n\n/**\n * Create the docs-grounding artifacts a pre-0.1.7 project is missing, from\n * the NEWLY installed CLI's bundled templates: `docs/api-notes.md`,\n * `.mcp.json`, and any bundled skill trees. Strictly create-if-missing —\n * an existing file is the partner's (api-notes is agent-authored, .mcp.json\n * may carry local servers) and is never touched, force or not. Writes go\n * through safe-fs like init's own scaffold pass.\n */\nfunction scaffoldMissingDocsArtifacts(params: {\n projectDir: string;\n slug: string;\n newTemplatesDir: string;\n}): { created: string[]; needsAttention: string[] } {\n const vars = { SLUG: params.slug, DISPLAY_NAME: toDisplayName(params.slug) };\n const created: string[] = [];\n const needsAttention: string[] = [];\n\n // This runs AFTER snapshot.dispose(): the toolchain upgrade has already\n // succeeded and there is no rollback left to protect. A refused write here\n // (a symlinked `docs/` or `.claude` ancestor — safe-fs throws rather than\n // follow it) must therefore be REPORTED, never thrown — the same stance\n // `regenerateAgentContextFiles` takes, for the same reason: a hard failure\n // now would misreport a successful upgrade.\n for (const { template, dest } of DOCS_GROUNDING_FILES) {\n const destPath = path.join(params.projectDir, dest);\n const kind = classifyPath(destPath);\n // A real file or directory is the partner's — skipping it quietly IS the\n // contract. A symlink (or fifo, socket, …) is not \"already there\": it is\n // a path we refuse to write through, and silence would hide that — same\n // reporting stance as regenerateAgentContextFiles.\n if (kind === 'file' || kind === 'directory') continue;\n if (kind !== 'missing') {\n needsAttention.push(dest);\n continue;\n }\n\n const templatePath = path.join(params.newTemplatesDir, template);\n if (!fs.existsSync(templatePath)) continue; // older target toolchain\n\n try {\n writeFileNoFollow(\n params.projectDir,\n destPath,\n renderTemplate(fs.readFileSync(templatePath, 'utf8'), vars),\n );\n created.push(dest);\n } catch {\n needsAttention.push(dest);\n }\n }\n\n try {\n // 'collect': a refused file is recorded and the walk continues, so files\n // that DID land — in this skill tree or an earlier one — stay in\n // `created` instead of vanishing when a later write refuses.\n const skills = copyBundledSkillTrees(\n params.projectDir,\n false,\n path.join(params.newTemplatesDir, 'skills'),\n 'collect',\n );\n created.push(...skills.created);\n needsAttention.push(...skills.refused);\n } catch {\n // Last resort (an unreadable templates dir, not a refused write — those\n // are collected above).\n needsAttention.push('.claude/skills');\n }\n\n return { created, needsAttention };\n}\n\n/**\n * Regenerate `AGENTS.md`, `CLAUDE.md` and the Claude Code skill from the\n * NEWLY installed CLI's bundled templates — using the exact byte-comparison\n * discipline `harness-scaffold.ts` applies to the dev harness shell: a file\n * whose current bytes match what the project's PRE-upgrade local CLI would\n * have rendered (captured in `oldTemplates`, before install ran) is\n * untouched by the partner and safe to regenerate; anything else has been\n * edited and is left alone, reported so a human can merge it by hand. A\n * stale AGENTS.md teaches an agent yesterday's contract — that is as harmful\n * as a stale binary, which is why this runs on every successful upgrade\n * rather than only on `init`.\n */\nfunction regenerateAgentContextFiles(params: {\n projectDir: string;\n slug: string;\n oldTemplates: Map<string, string>;\n newTemplatesDir: string;\n}): RegenerationReport {\n const vars = { SLUG: params.slug, DISPLAY_NAME: toDisplayName(params.slug) };\n const updated: string[] = [];\n const unchanged: string[] = [];\n const needsAttention: string[] = [];\n const skipped: { file: string; reason: SkipReason }[] = [];\n const skip = (file: string, reason: SkipReason) => {\n needsAttention.push(file);\n skipped.push({ file, reason });\n };\n\n for (const { template, dest } of AGENT_CONTEXT_FILES) {\n const destPath = path.join(params.projectDir, dest);\n const kind = classifyPath(destPath);\n if (kind === 'missing') continue; // never scaffolded — nothing to upgrade\n if (kind !== 'file') {\n // A symlink (or anything else odd) is not ours to write through — same\n // stance as init's scaffold pass, but reported instead of thrown: the\n // upgrade itself already succeeded, so surface it for a human.\n skip(dest, 'not-a-file');\n continue;\n }\n\n const current = fs.readFileSync(destPath, 'utf8');\n const oldSource = params.oldTemplates.get(template);\n\n const oldRendered =\n oldSource === undefined ? null : renderTemplate(oldSource, vars);\n\n if (oldRendered === null || current !== oldRendered) {\n // Differs from what the pre-upgrade CLI rendered: edited by the partner\n // (or the project was renamed after scaffold — same thing to us).\n skip(dest, 'edited-locally');\n continue;\n }\n\n const newTemplatePath = path.join(params.newTemplatesDir, template);\n if (!fs.existsSync(newTemplatePath)) continue;\n\n const newRendered = renderTemplate(\n fs.readFileSync(newTemplatePath, 'utf8'),\n vars,\n );\n\n if (newRendered === current) {\n unchanged.push(dest);\n continue;\n }\n\n try {\n writeFileNoFollow(params.projectDir, destPath, newRendered);\n updated.push(dest);\n } catch {\n // A symlinked ANCESTOR (.claude centralized across projects) passes the\n // leaf classifyPath check above but is refused by the guarded write —\n // and this runs post-rollback, so a throw here would misreport a\n // successful toolchain upgrade as failed. Report it instead, like every\n // other post-rollback write path in this file.\n skip(dest, 'write-refused');\n }\n }\n\n return { updated, unchanged, needsAttention, skipped };\n}\n\nfunction describeDelta(delta: DeltaEntry): string {\n return `${delta.current ?? 'not installed'} → ${delta.target}`;\n}\n\nfunction checkSummary(\n ui: Ui,\n source: 'host' | 'npm',\n deltas: Record<ToolchainKey, DeltaEntry>,\n): string {\n const entries = Object.entries(deltas) as [ToolchainKey, DeltaEntry][];\n const pending = entries.filter(([, delta]) => delta.changed).length;\n\n return ui.result({\n title:\n pending === 0 ? 'Toolchain is current' : 'Toolchain update available',\n tone: pending === 0 ? 'ok' : 'warn',\n rows: entries.map(([key, delta]): [string, string] => [\n key,\n delta.changed ? describeDelta(delta) : `${delta.target} · current`,\n ]),\n notes: [\n `Target resolved from ${source}.` +\n (pending > 0 ? ' Run \"ekanos upgrade\" to apply it.' : ''),\n ],\n });\n}\n\nfunction planSummary(\n ui: Ui,\n source: string,\n deltas: Record<ToolchainKey, DeltaEntry>,\n): string {\n return ui.result({\n title: 'Upgrading',\n rows: (Object.entries(deltas) as [ToolchainKey, DeltaEntry][])\n .filter(([, delta]) => delta.changed)\n .map(([key, delta]): [string, string] => [key, describeDelta(delta)]),\n notes: [`Target resolved from ${source}.`],\n });\n}\n\nfunction successSummary(\n ui: Ui,\n installedKeys: readonly ToolchainKey[],\n skippedKeys: readonly ToolchainKey[],\n deltas: Record<ToolchainKey, DeltaEntry>,\n regenerated: RegenerationReport,\n scaffolded: { created: string[]; needsAttention: string[] },\n): string {\n const arrow = (key: ToolchainKey) => `${key} → ${deltas[key]!.target}`;\n const attention =\n regenerated.needsAttention.length > 0 ||\n scaffolded.needsAttention.length > 0;\n\n const notes: string[] = [];\n if (scaffolded.created.length > 0) {\n notes.push(\n 'New in this toolchain: see AGENTS.md\\'s \"API documentation\" section.',\n );\n }\n if (scaffolded.needsAttention.length > 0) {\n // Never suggest --force here — it overwrites every scaffolded file,\n // including src/integration.ts.\n notes.push(\n 'A path component is a symlink or unwritable, so those files were not created. ' +\n 'Fix the path, then run \"ekanos init --slug <slug> --dir .\" WITHOUT --force: ' +\n 'init is per-file idempotent and creates only what is missing.',\n );\n }\n if (regenerated.needsAttention.length > 0) {\n const edited = regenerated.skipped\n .filter((s) => s.reason === 'edited-locally')\n .map((s) => s.file);\n const other = regenerated.skipped.filter(\n (s) => s.reason !== 'edited-locally',\n );\n if (edited.length > 0) {\n notes.push(\n `${edited.join(', ')} differ${edited.length === 1 ? 's' : ''} from what the previous CLI scaffolded (edited, or the project was renamed), so the new template was not applied — merge it by hand, or delete the file and run \"ekanos init --slug <slug> --dir .\" to re-create it.`,\n );\n }\n for (const { file, reason } of other) {\n notes.push(\n reason === 'not-a-file'\n ? `${file} is a symlink or not a regular file, so it was left alone.`\n : `${file} could not be written (a symlinked ancestor?), so it was left alone.`,\n );\n }\n }\n\n return ui.result({\n title:\n installedKeys.length > 0 ? 'Toolchain upgraded' : 'Nothing to install',\n tone: attention || installedKeys.length === 0 ? 'warn' : 'ok',\n rows: [\n ...(installedKeys.length > 0\n ? [['Installed', installedKeys.map(arrow)] as const]\n : []),\n ...(skippedKeys.length > 0\n ? [['Not installed', skippedKeys.map(arrow)] as const]\n : []),\n ...(regenerated.updated.length > 0\n ? [['Regenerated', regenerated.updated] as const]\n : []),\n ...(scaffolded.created.length > 0\n ? [['Created', scaffolded.created] as const]\n : []),\n ...(regenerated.needsAttention.length > 0\n ? [['Modified', regenerated.needsAttention] as const]\n : []),\n ...(scaffolded.needsAttention.length > 0\n ? [['Could not create', scaffolded.needsAttention] as const]\n : []),\n ],\n notes:\n skippedKeys.length > 0\n ? [\n 'Not installed = transitive, or not a local dependency (e.g. a global CLI).',\n ...notes,\n ]\n : notes,\n });\n}\n"]}
1
+ {"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAEL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,2BAA2B,EAC3B,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OA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AC,MAAM,GAAG,CAAC;gBAChC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,WAAW,CAAC,OAAO,CAAU,CAAC;gBACjD,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;gBAC/B,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAU,CAAC;gBAC5C,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;gBACvC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,cAAc,CAAU,CAAC;gBACrD,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;gBACtC,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC,cAAc,CAAU,CAAC;gBAC5D,CAAC,CAAC,EAAE,CAAC;SACR;QACD,KAAK,EACH,WAAW,CAAC,MAAM,GAAG,CAAC;YACpB,CAAC,CAAC;gBACE,4EAA4E;gBAC5E,GAAG,KAAK;aACT;YACH,CAAC,CAAC,KAAK;KACZ,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Finding } from '@ekanos/integration-schema';\nimport { discoverRepo, isRepoRoot } from '@ekanos/integration-schema/repo';\nimport { spawn } from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\n\nimport { resolveAuthEnvironment } from '../auth/session';\nimport { cliVersion } from '../compatibility';\nimport type { CliContext } from '../context';\nimport {\n invalidStateError,\n networkError,\n preconditionError,\n validationError,\n} from '../errors';\nimport { EXIT_CODES } from '../exit-codes';\nimport { readInstalledPackageManifest } from '../harness-scaffold';\nimport {\n type PackageManager,\n detectPackageManager,\n frozenInstallArgs,\n installExactArgs,\n isMultiPackageWorkspaceRoot,\n lockfileNames,\n} from '../package-manager';\nimport {\n type BuildScriptsResult,\n ensureBuildScriptsAnswered,\n skippedBuildScriptsHint,\n findIgnoredBuilds,\n ignoredBuildsHint,\n isIgnoredBuildsFailure,\n WORKSPACE_FILE,\n} from '../pnpm-builds';\nimport { loadProject } from '../project';\nimport { classifyPath, writeFileNoFollow } from '../safe-fs';\nimport { renderTemplate, toDisplayName } from '../templates';\nimport {\n TOOLCHAIN_PACKAGES,\n type ToolchainKey,\n type ToolchainVersions,\n isExactVersion,\n} from '../toolchain';\nimport { resolveToolchainTarget } from '../toolchain-resolve';\nimport { type Ui, displayPath } from '../ui';\nimport { collectAllFindings } from '../validate-findings';\nimport {\n AGENT_CONTEXT_FILES,\n DOCS_GROUNDING_FILES,\n copyBundledSkillTrees,\n} from './init';\nimport { promptYesNo } from './publish';\n\n/**\n * `ekanos upgrade` — move a project's toolchain to a coherent target version\n * and VERIFY it before calling the job done.\n *\n * The whole point of this verb is that it cannot leave a project worse off\n * than it found it: `package.json` and the lockfile are snapshotted before\n * anything installs, the target set is only ever a coherence-checked whole\n * (never \"latest of each, independently\" — see `toolchain-resolve.ts`), and\n * any failure from install through validate through the project's own test\n * script rolls everything back to the snapshot and says exactly which step\n * failed. A partner (or an agent) running this unattended should never end up\n * with a half-upgraded, uninstallable project.\n */\n\nexport interface UpgradeArgs {\n dir: string;\n host?: string;\n env: Record<string, string | undefined>;\n /** Report current vs. target and exit 0. Never mutates anything. */\n check: boolean;\n /** Skip the interactive confirm; required to mutate outside a TTY. */\n yes: boolean;\n /** Skip the post-install validate + test-script verification. */\n noVerify: boolean;\n stdinIsTTY?: boolean;\n confirm?: (question: string) => Promise<boolean>;\n}\n\n/** Injectable seams so tests can exercise install/verify/rollback without shelling out. */\nexport interface UpgradeDeps {\n resolveTarget?: typeof resolveToolchainTarget;\n runInstall?: (\n argv: string[],\n bin: string,\n cwd: string,\n ) => Promise<{ code: number; output: string }>;\n runValidateStep?: (\n projectDir: string,\n ) => Promise<{ ok: boolean; findings?: Finding[] }>;\n runTestStep?: (\n projectDir: string,\n pm: PackageManager,\n ) => Promise<{ code: number; output: string }>;\n}\n\ninterface DeltaEntry {\n current: string | null;\n target: string;\n changed: boolean;\n}\n\n/**\n * One `package.json` the upgrade moves. A single project is one target; a\n * repo root (`ekanos.json` with `kind: \"repo\"`) is the root plus every\n * package that depends on the toolchain, upgraded together against ONE\n * lockfile — the same unit `ekanos dev` serves from a repo root.\n */\ninterface UpgradeTarget {\n /** Absolute directory holding the `package.json`. */\n dir: string;\n /** Relative to the repo root, forward slashes; `''` for a single project or the root itself. */\n relDir: string;\n /** The integration slug, for agent-context regeneration; null for a repo root or an experience. */\n slug: string | null;\n /** Whether `ekanos validate`'s findings pass applies (integration packages). */\n validate: boolean;\n}\n\ninterface UpgradePlan {\n /** Where the current toolchain is read from: the project, or the repo root. */\n baseDir: string;\n repo: boolean;\n targets: UpgradeTarget[];\n}\n\nconst TOOLCHAIN_NAMES: readonly string[] = Object.values(TOOLCHAIN_PACKAGES);\n\nfunction dependsOnToolchain(dir: string): boolean {\n const manifestPath = path.join(dir, 'package.json');\n if (!fs.existsSync(manifestPath)) return false;\n const manifest = readManifest(manifestPath);\n return ['dependencies', 'devDependencies'].some((field) => {\n const deps = manifest[field];\n return (\n typeof deps === 'object' &&\n deps !== null &&\n TOOLCHAIN_NAMES.some((name) => name in deps)\n );\n });\n}\n\nfunction planUpgrade(ctx: CliContext, dir: string): UpgradePlan {\n const absolute = path.resolve(dir);\n if (!isRepoRoot(absolute)) {\n const loaded = loadProject(dir);\n return {\n baseDir: loaded.projectDir,\n repo: false,\n targets: [\n {\n dir: loaded.projectDir,\n relDir: '',\n slug: loaded.primary.slug,\n validate: true,\n },\n ],\n };\n }\n\n const repo = discoverRepo(absolute);\n for (const problem of repo.problems) {\n ctx.warn(`${problem.where}: ${problem.message}`);\n }\n const targets: UpgradeTarget[] = [\n ...(dependsOnToolchain(repo.root)\n ? [{ dir: repo.root, relDir: '', slug: null, validate: false }]\n : []),\n ...repo.packages\n .filter((pkg) => dependsOnToolchain(pkg.dir))\n .map((pkg) => ({\n dir: pkg.dir,\n relDir: pkg.relDir,\n slug: pkg.kind === 'integration' ? pkg.name : null,\n validate: pkg.kind === 'integration',\n })),\n ];\n return { baseDir: repo.root, repo: true, targets };\n}\n\nexport async function runUpgrade(\n ctx: CliContext,\n args: UpgradeArgs,\n deps: UpgradeDeps = {},\n): Promise<number> {\n const plan = planUpgrade(ctx, args.dir);\n const pm = detectPackageManager(plan.baseDir);\n\n // Captured BEFORE anything installs: the templates the project's CURRENT\n // (pre-upgrade) local `@ekanos/cli` ships, which is what actually\n // generated the agent-context files on disk — not necessarily this\n // process's own bundled templates, since `upgrade` is a machine-level verb\n // that never delegates and is routinely invoked via a DIFFERENT (global)\n // install. See `regenerateAgentContextFiles`.\n const oldAgentTemplates = new Map(\n plan.targets\n .filter((target) => target.slug !== null)\n .map((target) => [\n target.dir,\n captureAgentTemplates(cliTemplatesDir(target.dir, pm.root)),\n ]),\n );\n\n const current = readCurrentToolchain(plan.baseDir, pm.root);\n\n const session = resolveSessionQuietly(ctx, args);\n const resolveTarget = deps.resolveTarget ?? resolveToolchainTarget;\n const resolution = await resolveTarget({\n host: session?.host,\n session: session?.session,\n });\n\n if (resolution.status === 'unavailable') {\n throw networkError(\n 'Could not resolve a toolchain target from the Ekanos host or the ' +\n 'npm registry.',\n 'Check connectivity and retry. If this deployment has no ' +\n '\"/api/partner/toolchain\" route yet, the npm registry is the ' +\n 'fallback and a failure there means npm itself is unreachable.',\n );\n }\n\n if (resolution.status === 'incoherent') {\n throw preconditionError(\n `The resolved toolchain versions do not form an installable set: ` +\n resolution.detail,\n 'Retry in a moment — this is almost always a multi-package publish ' +\n 'still in flight, and it self-resolves once every package finishes ' +\n 'publishing.',\n );\n }\n\n if (resolution.status === 'invalid') {\n throw invalidStateError(\n `Refusing to upgrade: ${resolution.detail}.`,\n 'A toolchain version must be an exact release such as \"1.2.3\" — never a ' +\n 'git, file or tarball spec, which would install code from elsewhere. ' +\n '\"ekanos whoami\" shows which host you are signed in to.',\n );\n }\n\n const target = resolution.target;\n const deltas = computeDeltas(current, target);\n const scope = {\n packageManager: { name: pm.name, root: pm.root },\n ...(plan.repo\n ? { packages: plan.targets.map((t) => t.relDir || '.') }\n : {}),\n };\n\n if (args.check) {\n return ctx.succeed(\n {\n source: resolution.source,\n current,\n target,\n deltas,\n ...scope,\n ...(resolution.source === 'host'\n ? { minimum: resolution.minimum, notes: resolution.notes }\n : {}),\n },\n checkSummary(ctx.ui, resolution.source, deltas),\n );\n }\n\n const changedKeys = (Object.keys(deltas) as ToolchainKey[]).filter(\n (key) => deltas[key]!.changed,\n );\n\n if (changedKeys.length === 0) {\n return ctx.succeed(\n { source: resolution.source, current, target, deltas, ...scope },\n ctx.ui.result({\n title: 'Already up to date',\n rows: [['Target', `resolved from ${resolution.source}`]],\n }),\n );\n }\n\n const isHuman = !ctx.jsonMode;\n const stdinIsTTY = args.stdinIsTTY ?? process.stdin.isTTY === true;\n const canPrompt = isHuman && stdinIsTTY;\n\n if (!args.yes) {\n if (!canPrompt) {\n throw validationError(\n 'Refusing to modify the project non-interactively without --yes.',\n 'Pass \"ekanos upgrade --yes\" to proceed, or \"ekanos upgrade --check\" ' +\n 'to preview the target with no changes.',\n );\n }\n\n ctx.log(planSummary(ctx.ui, resolution.source, deltas));\n const confirm = args.confirm ?? promptYesNo;\n const confirmed = await confirm('Upgrade now? [y/N]');\n\n if (!confirmed) {\n throw validationError(\n 'Upgrade was not confirmed.',\n 'Re-run \"ekanos upgrade --yes\" to proceed non-interactively, or ' +\n '\"ekanos upgrade --check\" to preview with no changes. Nothing was ' +\n 'modified.',\n );\n }\n }\n\n const work = plan.targets.map((t) => ({\n target: t,\n specs: buildInstallSpecs(\n readManifest(path.join(t.dir, 'package.json')),\n target,\n changedKeys,\n ),\n }));\n\n if (work.every((item) => item.specs.length === 0)) {\n return ctx.succeed(\n { source: resolution.source, current, target, deltas, ...scope },\n ctx.ui.result({\n title: 'Nothing to install',\n tone: 'warn',\n notes: [\n 'None of the changed packages are direct dependencies of this project.',\n 'Their versions follow from whichever direct dependency pins them.',\n ],\n }),\n );\n }\n\n const snapshot = snapshotFiles([\n ...plan.targets.map((t) => path.join(t.dir, 'package.json')),\n ...lockfileNames(pm).map((name) => path.join(pm.root, name)),\n path.join(plan.baseDir, WORKSPACE_FILE),\n path.join(pm.root, WORKSPACE_FILE),\n ]);\n const hadLockfile = lockfileNames(pm).some((name) =>\n snapshot.existed(path.join(pm.root, name)),\n );\n const runInstall = deps.runInstall ?? defaultRunInstall;\n const rollback = (failure: StepFailure) =>\n failAndRollback(ctx, snapshot, pm, hadLockfile, runInstall, failure);\n let answeredBuildScripts: string[] = [];\n let buildScriptsSkipped: BuildScriptsResult['skipped'];\n\n try {\n // pnpm 10+ refuses dependency build scripts nobody has answered, and a\n // new toolchain release can grow that list (0.4.0 added @swc/core and\n // @parcel/watcher via next-intl). A project scaffolded under an older\n // CLI has no line for them, so answer the closure BEFORE `pnpm add`, or\n // the install writes placeholders and exits ERR_PNPM_IGNORED_BUILDS. A\n // package inside someone else's workspace is told which file to edit\n // rather than having that file edited for it.\n const buildScripts: BuildScriptsResult =\n pm.name === 'pnpm'\n ? ensureBuildScriptsAnswered(plan.baseDir)\n : { changed: [] };\n answeredBuildScripts = buildScripts.changed;\n if (buildScripts.skipped) {\n buildScriptsSkipped = buildScripts.skipped;\n ctx.log(ctx.ui.dim(skippedBuildScriptsHint(buildScripts.skipped)));\n }\n if (answeredBuildScripts.length > 0) {\n ctx.log(\n ctx.ui.dim(\n `Answered dependency build scripts in pnpm-workspace.yaml: ${answeredBuildScripts.join(', ')}.`,\n ),\n );\n }\n\n const atWorkspaceRoot = isMultiPackageWorkspaceRoot(pm.root);\n for (const { target: t, specs } of work) {\n for (const group of [\n specs.filter((s) => !s.dev),\n specs.filter((s) => s.dev),\n ]) {\n if (group.length === 0) continue;\n\n const argv = installExactArgs(\n pm,\n group.map((s) => `${s.name}@${s.version}`),\n group[0]!.dev,\n atWorkspaceRoot && t.dir === pm.root,\n );\n ctx.log(\n ctx.ui.dim(\n `Running \"${pm.bin} ${argv.join(' ')}\" in ${displayPath(t.dir, process.cwd())}…`,\n ),\n );\n const result = await runInstall(argv, pm.bin, t.dir);\n\n if (result.code !== 0) {\n return await rollback({\n step: 'install',\n exitCode: EXIT_CODES.PRECONDITION_FAILED,\n message: isIgnoredBuildsFailure(result.output)\n ? `\"${pm.bin} ${argv.join(' ')}\" exited with code ${result.code}: ${ignoredBuildsHint(findIgnoredBuilds(result.output))}`\n : `\"${pm.bin} ${argv.join(' ')}\" exited with code ${result.code}.`,\n output: result.output,\n });\n }\n }\n }\n\n if (!args.noVerify) {\n const runValidateStep = deps.runValidateStep ?? defaultRunValidateStep;\n for (const t of plan.targets.filter((item) => item.validate)) {\n const validateResult = await runValidateStep(t.dir);\n\n if (!validateResult.ok) {\n return await rollback({\n step: 'validate',\n exitCode: EXIT_CODES.VALIDATION,\n message:\n 'The upgraded toolchain fails \"ekanos validate\" against ' +\n (plan.repo\n ? `${t.relDir}'s integration definition.`\n : \"this project's own integration definition.\"),\n output: JSON.stringify(validateResult.findings ?? [], null, 2),\n });\n }\n }\n\n // A single project always runs its test script. In a repo, each\n // package that declares one runs it; the root holds no tests.\n const testTargets = plan.repo\n ? plan.targets.filter((t) => t.relDir !== '' && hasTestScript(t.dir))\n : plan.targets;\n const runTestStep = deps.runTestStep ?? defaultRunTestStep;\n for (const t of testTargets) {\n const testResult = await runTestStep(t.dir, pm);\n\n if (testResult.code !== 0) {\n return await rollback({\n step: 'test',\n exitCode: testResult.code,\n message: `${plan.repo ? `${t.relDir}: the` : \"The project's\"} test script exited with code ${testResult.code} on the upgraded toolchain.`,\n output: testResult.output,\n });\n }\n }\n }\n } finally {\n snapshot.dispose();\n }\n\n const regenerated: RegenerationReport = {\n updated: [],\n unchanged: [],\n needsAttention: [],\n skipped: [],\n };\n const scaffolded = {\n created: [] as string[],\n needsAttention: [] as string[],\n };\n const under = (relDir: string, file: string) =>\n relDir === '' ? file : `${relDir}/${file}`;\n\n for (const t of plan.targets) {\n if (t.slug === null) continue;\n const newTemplatesDir = cliTemplatesDir(t.dir, pm.root);\n\n const report = regenerateAgentContextFiles({\n projectDir: t.dir,\n slug: t.slug,\n oldTemplates: oldAgentTemplates.get(t.dir) ?? new Map(),\n newTemplatesDir,\n });\n regenerated.updated.push(...report.updated.map((f) => under(t.relDir, f)));\n regenerated.unchanged.push(\n ...report.unchanged.map((f) => under(t.relDir, f)),\n );\n regenerated.needsAttention.push(\n ...report.needsAttention.map((f) => under(t.relDir, f)),\n );\n regenerated.skipped.push(\n ...report.skipped.map((s) => ({ ...s, file: under(t.relDir, s.file) })),\n );\n\n // The regenerated AGENTS.md and skills may now REFERENCE artifacts this\n // project predates (docs/api-notes.md, .mcp.json, bundled skill trees) —\n // instructions pointing at files that don't exist are exactly the\n // stale-docs failure the docs-grounding feature closes, so create what's\n // missing. Create-if-missing ONLY: these files are partner/agent-authored\n // after the scaffold and are never regenerated.\n const docs = scaffoldMissingDocsArtifacts({\n projectDir: t.dir,\n slug: t.slug,\n newTemplatesDir,\n });\n scaffolded.created.push(...docs.created.map((f) => under(t.relDir, f)));\n scaffolded.needsAttention.push(\n ...docs.needsAttention.map((f) => under(t.relDir, f)),\n );\n }\n\n // `specs` only ever covers DIRECT dependencies (see `buildInstallSpecs`) —\n // a changed key with no spec is transitive and was never actually\n // installed here, so the report (and the human summary) must say so\n // explicitly rather than implying every changed key was upgraded. This\n // matters most for a globally-installed `ekanos` with no local\n // `@ekanos/cli` devDependency, where `cli` changes in `deltas` but the\n // running global binary itself is untouched by this command.\n const installedKeys = [\n ...new Set(work.flatMap((item) => item.specs.map((spec) => spec.key))),\n ];\n const skippedKeys = changedKeys.filter((key) => !installedKeys.includes(key));\n\n return ctx.succeed(\n {\n source: resolution.source,\n current,\n target,\n deltas,\n ...scope,\n installed: installedKeys,\n skippedTransitive: skippedKeys,\n buildScripts: {\n answered: answeredBuildScripts,\n ...(buildScriptsSkipped ? { skipped: buildScriptsSkipped } : {}),\n },\n regenerated,\n scaffolded,\n },\n successSummary(\n ctx.ui,\n installedKeys,\n skippedKeys,\n deltas,\n regenerated,\n scaffolded,\n ),\n );\n}\n\nfunction hasTestScript(dir: string): boolean {\n const scripts = readManifest(path.join(dir, 'package.json')).scripts;\n return typeof scripts === 'object' && scripts !== null && 'test' in scripts;\n}\n\n/**\n * The nearest `node_modules/@ekanos/cli/templates` from `dir` up to `top`\n * (the workspace root): pnpm links it into each package, npm and yarn hoist\n * it to the root. Falls back to the package's own path, where a missing\n * directory just means \"cannot verify\" to the regeneration below.\n */\nfunction cliTemplatesDir(dir: string, top: string): string {\n const own = path.join(dir, 'node_modules', '@ekanos', 'cli', 'templates');\n let current = path.resolve(dir);\n const stop = path.resolve(top);\n for (;;) {\n const candidate = path.join(\n current,\n 'node_modules',\n '@ekanos',\n 'cli',\n 'templates',\n );\n if (fs.existsSync(candidate)) return candidate;\n if (current === stop) return own;\n const parent = path.dirname(current);\n if (parent === current) return own;\n current = parent;\n }\n}\n\n/**\n * Best-effort host/session resolution — NEVER throws. `upgrade` must work for\n * a partner who has never logged in at all (pure npm-registry flow), so the\n * throwing `resolveAuthEnvironment`/`requireSession` machinery is unusable\n * here; this mirrors the tolerant lookup `update-notice.ts` uses.\n */\nfunction resolveSessionQuietly(\n ctx: CliContext,\n args: UpgradeArgs,\n): { host: string; session: { accessToken: string } } | null {\n try {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const session = env.store.read(env.host);\n return session ? { host: env.host, session } : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The installed toolchain, read from the nearest `node_modules` holding each\n * package between `projectDir` and `top` (the workspace root): npm and yarn\n * hoist a workspace package's dependencies to the root.\n */\nfunction readCurrentToolchain(\n projectDir: string,\n top: string,\n): Record<ToolchainKey, string | null> {\n const result = {} as Record<ToolchainKey, string | null>;\n const dirs: string[] = [];\n for (let dir = path.resolve(projectDir); ; dir = path.dirname(dir)) {\n dirs.push(dir);\n if (dir === path.resolve(top) || path.dirname(dir) === dir) break;\n }\n\n for (const [key, pkg] of Object.entries(TOOLCHAIN_PACKAGES) as [\n ToolchainKey,\n string,\n ][]) {\n const installed = dirs\n .map((dir) => readInstalledPackageManifest(dir, pkg))\n .find((manifest) => manifest !== null);\n result[key] = installed?.version ?? (key === 'cli' ? cliVersion() : null);\n }\n\n return result;\n}\n\nfunction computeDeltas(\n current: Record<ToolchainKey, string | null>,\n target: ToolchainVersions,\n): Record<ToolchainKey, DeltaEntry> {\n const keys = Object.keys(TOOLCHAIN_PACKAGES) as ToolchainKey[];\n const result = {} as Record<ToolchainKey, DeltaEntry>;\n\n for (const key of keys) {\n result[key] = {\n current: current[key],\n target: target[key],\n changed: current[key] !== target[key],\n };\n }\n\n return result;\n}\n\ninterface InstallSpec {\n key: ToolchainKey;\n name: string;\n version: string;\n dev: boolean;\n}\n\n/**\n * Only packages the project depends on DIRECTLY are installed explicitly —\n * `@ekanos/integration-schema` and often `@ekanos/harness` are transitive\n * (pulled in by `@ekanos/sdk`), and forcing an exact transitive version would\n * need a package-manager-specific override mechanism this CLI does not\n * manage. Their versions follow from whichever direct dependency pins them,\n * which is exactly what the coherent target guarantees is already correct.\n */\nfunction buildInstallSpecs(\n manifest: Record<string, unknown>,\n target: ToolchainVersions,\n changedKeys: readonly ToolchainKey[],\n): InstallSpec[] {\n const deps = (manifest.dependencies ?? {}) as Record<string, unknown>;\n const devDeps = (manifest.devDependencies ?? {}) as Record<string, unknown>;\n\n const specs: InstallSpec[] = [];\n\n for (const key of changedKeys) {\n const pkg = TOOLCHAIN_PACKAGES[key];\n // Resolution already refuses an inexact version; this is the last check\n // before a value reaches `pnpm add`.\n if (!isExactVersion(target[key])) {\n throw invalidStateError(\n `Refusing to install ${pkg}@${target[key]}: not an exact version.`,\n 'A toolchain version must be an exact release such as \"1.2.3\".',\n );\n }\n if (pkg in deps) {\n specs.push({ key, name: pkg, version: target[key], dev: false });\n } else if (pkg in devDeps) {\n specs.push({ key, name: pkg, version: target[key], dev: true });\n }\n }\n\n return specs;\n}\n\nfunction readManifest(packageJsonPath: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n } catch (error) {\n throw preconditionError(\n `Could not read ${packageJsonPath}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n 'Ensure the project has a valid package.json, then re-run \"ekanos upgrade\".',\n );\n }\n if (typeof parsed !== 'object' || parsed === null) {\n throw preconditionError(\n `${packageJsonPath} does not contain a JSON object.`,\n 'Fix package.json, then re-run \"ekanos upgrade\".',\n );\n }\n return parsed as Record<string, unknown>;\n}\n\ninterface Snapshot {\n /** Whether `file` existed when the snapshot was taken. */\n existed: (file: string) => boolean;\n restore: () => void;\n dispose: () => void;\n}\n\n/**\n * Copy every file in `files` that exists to a temp directory before anything\n * installs: each target's `package.json`, the lockfile and\n * `pnpm-workspace.yaml` at the package manager's root (the WORKSPACE root\n * for a workspace package — that is where an install writes them).\n * `restore()` copies them back and removes any of them the failed run\n * created; `dispose()` cleans up the temp copies once the run is over,\n * success or failure.\n */\nfunction snapshotFiles(files: readonly string[]): Snapshot {\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ekanos-upgrade-'));\n const entries = [...new Set(files.map((file) => path.resolve(file)))].map(\n (file, index) => {\n const copy = path.join(tmpDir, String(index));\n const existed = fs.existsSync(file);\n if (existed) fs.copyFileSync(file, copy);\n return { file, copy, existed };\n },\n );\n\n return {\n existed: (file) =>\n entries.find((entry) => entry.file === path.resolve(file))?.existed ??\n false,\n restore: () => {\n for (const { file, copy, existed } of entries) {\n if (existed) fs.copyFileSync(copy, file);\n else if (fs.existsSync(file)) fs.rmSync(file);\n }\n },\n dispose: () => {\n fs.rmSync(tmpDir, { recursive: true, force: true });\n },\n };\n}\n\ninterface StepFailure {\n step: 'install' | 'validate' | 'test';\n exitCode: number;\n message: string;\n output: string;\n}\n\n/**\n * The one rollback path every failure funnels through: restore the snapshot,\n * then reinstall with the SAME package manager, frozen to the restored\n * lockfile, at its root — so `node_modules` matches the restored\n * `package.json`/lockfile again. npm run inside a pnpm workspace is what\n * broke a project once; it is never used for a project another manager owns.\n *\n * The report says exactly which step failed and what it said, and states the\n * project's real state: restored when the reinstall succeeded, and when it\n * did not, that `node_modules` is NOT consistent, with the command to repair\n * it by hand. Never a success claim the reinstall did not earn.\n */\nasync function failAndRollback(\n ctx: CliContext,\n snapshot: Snapshot,\n pm: PackageManager,\n hadLockfile: boolean,\n runInstall: InstallRunner,\n failure: StepFailure,\n): Promise<number> {\n ctx.warn(\n `ekanos: the \"${failure.step}\" step failed — rolling back package.json ` +\n `and the lockfile, then reinstalling with ${pm.name} to restore node_modules…`,\n );\n\n snapshot.restore();\n // The SAME injectable installer seam used for the forward install — a test\n // that mocks it never shells out for the rollback path either.\n const reinstallArgs = frozenInstallArgs(pm, hadLockfile);\n const reinstall = await runInstall(reinstallArgs, pm.bin, pm.root);\n const reinstallCommand = `${pm.bin} ${reinstallArgs.join(' ')}`;\n const manual = `cd ${pm.root} && ${reinstallCommand}`;\n const restored = reinstall.code === 0;\n\n return ctx.failWith({\n code: `upgrade_${failure.step}_failed`,\n message: restored\n ? failure.message\n : `${failure.message} The rollback reinstall (\"${reinstallCommand}\") ALSO failed with code ${reinstall.code}.`,\n hint: restored\n ? 'The project HAS BEEN RESTORED to its pre-upgrade state (package.json, ' +\n 'lockfile and node_modules all rolled back). Read the output in ' +\n 'data.output, fix the underlying issue, and re-run \"ekanos upgrade\".'\n : 'package.json and the lockfile were restored, but node_modules was NOT ' +\n 'reinstalled and does not match them. Repair it by hand before ' +\n `anything else: ${manual}. Then read data.output and data.rollback, ` +\n 'fix the underlying issue, and re-run \"ekanos upgrade\".',\n exitCode: failure.exitCode,\n data: {\n step: failure.step,\n output: failure.output,\n rollback: {\n filesRestored: true,\n nodeModulesRestored: restored,\n command: reinstallCommand,\n cwd: pm.root,\n exitCode: reinstall.code,\n ...(restored ? {} : { output: reinstall.output, manual }),\n },\n },\n });\n}\n\ntype InstallRunner = NonNullable<UpgradeDeps['runInstall']>;\n\n/**\n * Spawn the package manager. A spawn failure (the binary is missing) resolves\n * as exit 127, the shell's \"command not found\", rather than rejecting: the\n * caller must still roll back, and a rejection would skip straight past it.\n */\nasync function defaultRunInstall(\n argv: string[],\n bin: string,\n cwd: string,\n): Promise<{ code: number; output: string }> {\n return new Promise((resolve) => {\n const child = spawn(bin, argv, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });\n let output = '';\n child.stdout?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.on('error', (error) => {\n resolve({ code: 127, output: `${output}${error.message}` });\n });\n child.on('close', (code) => resolve({ code: code ?? 1, output }));\n });\n}\n\nasync function defaultRunValidateStep(\n projectDir: string,\n): Promise<{ ok: boolean; findings?: Finding[] }> {\n const loaded = loadProject(projectDir);\n const findings = await collectAllFindings(loaded);\n const errorCount = findings.filter((f) => f.severity === 'error').length;\n return { ok: errorCount === 0, findings };\n}\n\nasync function defaultRunTestStep(\n projectDir: string,\n pm: PackageManager,\n): Promise<{ code: number; output: string }> {\n return new Promise((resolve, reject) => {\n const child = spawn(pm.bin, ['run', 'test'], {\n cwd: projectDir,\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n let output = '';\n child.stdout?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n output += chunk.toString();\n });\n child.on('error', reject);\n child.on('close', (code) => resolve({ code: code ?? 1, output }));\n });\n}\n\n/** Why a scaffolded doc file was left alone. Reported so a human knows whether to merge or to investigate. */\ntype SkipReason = 'edited-locally' | 'not-a-file' | 'write-refused';\n\ninterface RegenerationReport {\n updated: string[];\n unchanged: string[];\n needsAttention: string[];\n /** One entry per `needsAttention` path. */\n skipped: { file: string; reason: SkipReason }[];\n}\n\n/**\n * Read every `AGENT_CONTEXT_FILES` template source out of the project's\n * CURRENT (pre-upgrade) local `@ekanos/cli` install, before anything installs\n * over it. Missing entirely (the package isn't a resolvable local dependency)\n * just means every file below is treated conservatively — see\n * `regenerateAgentContextFiles`.\n */\nfunction captureAgentTemplates(templatesDir: string): Map<string, string> {\n const captured = new Map<string, string>();\n\n for (const { template } of AGENT_CONTEXT_FILES) {\n const templatePath = path.join(templatesDir, template);\n try {\n captured.set(template, fs.readFileSync(templatePath, 'utf8'));\n } catch {\n // Not resolvable — left out of the map, handled as \"can't verify\" below.\n }\n }\n\n return captured;\n}\n\n/**\n * Create the docs-grounding artifacts a pre-0.1.7 project is missing, from\n * the NEWLY installed CLI's bundled templates: `docs/api-notes.md`,\n * `.mcp.json`, and any bundled skill trees. Strictly create-if-missing —\n * an existing file is the partner's (api-notes is agent-authored, .mcp.json\n * may carry local servers) and is never touched, force or not. Writes go\n * through safe-fs like init's own scaffold pass.\n */\nfunction scaffoldMissingDocsArtifacts(params: {\n projectDir: string;\n slug: string;\n newTemplatesDir: string;\n}): { created: string[]; needsAttention: string[] } {\n const vars = { SLUG: params.slug, DISPLAY_NAME: toDisplayName(params.slug) };\n const created: string[] = [];\n const needsAttention: string[] = [];\n\n // This runs AFTER snapshot.dispose(): the toolchain upgrade has already\n // succeeded and there is no rollback left to protect. A refused write here\n // (a symlinked `docs/` or `.claude` ancestor — safe-fs throws rather than\n // follow it) must therefore be REPORTED, never thrown — the same stance\n // `regenerateAgentContextFiles` takes, for the same reason: a hard failure\n // now would misreport a successful upgrade.\n for (const { template, dest } of DOCS_GROUNDING_FILES) {\n const destPath = path.join(params.projectDir, dest);\n const kind = classifyPath(destPath);\n // A real file or directory is the partner's — skipping it quietly IS the\n // contract. A symlink (or fifo, socket, …) is not \"already there\": it is\n // a path we refuse to write through, and silence would hide that — same\n // reporting stance as regenerateAgentContextFiles.\n if (kind === 'file' || kind === 'directory') continue;\n if (kind !== 'missing') {\n needsAttention.push(dest);\n continue;\n }\n\n const templatePath = path.join(params.newTemplatesDir, template);\n if (!fs.existsSync(templatePath)) continue; // older target toolchain\n\n try {\n writeFileNoFollow(\n params.projectDir,\n destPath,\n renderTemplate(fs.readFileSync(templatePath, 'utf8'), vars),\n );\n created.push(dest);\n } catch {\n needsAttention.push(dest);\n }\n }\n\n try {\n // 'collect': a refused file is recorded and the walk continues, so files\n // that DID land — in this skill tree or an earlier one — stay in\n // `created` instead of vanishing when a later write refuses.\n const skills = copyBundledSkillTrees(\n params.projectDir,\n false,\n path.join(params.newTemplatesDir, 'skills'),\n 'collect',\n );\n created.push(...skills.created);\n needsAttention.push(...skills.refused);\n } catch {\n // Last resort (an unreadable templates dir, not a refused write — those\n // are collected above).\n needsAttention.push('.claude/skills');\n }\n\n return { created, needsAttention };\n}\n\n/**\n * Regenerate `AGENTS.md`, `CLAUDE.md` and the Claude Code skill from the\n * NEWLY installed CLI's bundled templates — using the exact byte-comparison\n * discipline `harness-scaffold.ts` applies to the dev harness shell: a file\n * whose current bytes match what the project's PRE-upgrade local CLI would\n * have rendered (captured in `oldTemplates`, before install ran) is\n * untouched by the partner and safe to regenerate; anything else has been\n * edited and is left alone, reported so a human can merge it by hand. A\n * stale AGENTS.md teaches an agent yesterday's contract — that is as harmful\n * as a stale binary, which is why this runs on every successful upgrade\n * rather than only on `init`.\n */\nfunction regenerateAgentContextFiles(params: {\n projectDir: string;\n slug: string;\n oldTemplates: Map<string, string>;\n newTemplatesDir: string;\n}): RegenerationReport {\n const vars = { SLUG: params.slug, DISPLAY_NAME: toDisplayName(params.slug) };\n const updated: string[] = [];\n const unchanged: string[] = [];\n const needsAttention: string[] = [];\n const skipped: { file: string; reason: SkipReason }[] = [];\n const skip = (file: string, reason: SkipReason) => {\n needsAttention.push(file);\n skipped.push({ file, reason });\n };\n\n for (const { template, dest } of AGENT_CONTEXT_FILES) {\n const destPath = path.join(params.projectDir, dest);\n const kind = classifyPath(destPath);\n if (kind === 'missing') continue; // never scaffolded — nothing to upgrade\n if (kind !== 'file') {\n // A symlink (or anything else odd) is not ours to write through — same\n // stance as init's scaffold pass, but reported instead of thrown: the\n // upgrade itself already succeeded, so surface it for a human.\n skip(dest, 'not-a-file');\n continue;\n }\n\n const current = fs.readFileSync(destPath, 'utf8');\n const oldSource = params.oldTemplates.get(template);\n\n const oldRendered =\n oldSource === undefined ? null : renderTemplate(oldSource, vars);\n\n if (oldRendered === null || current !== oldRendered) {\n // Differs from what the pre-upgrade CLI rendered: edited by the partner\n // (or the project was renamed after scaffold — same thing to us).\n skip(dest, 'edited-locally');\n continue;\n }\n\n const newTemplatePath = path.join(params.newTemplatesDir, template);\n if (!fs.existsSync(newTemplatePath)) continue;\n\n const newRendered = renderTemplate(\n fs.readFileSync(newTemplatePath, 'utf8'),\n vars,\n );\n\n if (newRendered === current) {\n unchanged.push(dest);\n continue;\n }\n\n try {\n writeFileNoFollow(params.projectDir, destPath, newRendered);\n updated.push(dest);\n } catch {\n // A symlinked ANCESTOR (.claude centralized across projects) passes the\n // leaf classifyPath check above but is refused by the guarded write —\n // and this runs post-rollback, so a throw here would misreport a\n // successful toolchain upgrade as failed. Report it instead, like every\n // other post-rollback write path in this file.\n skip(dest, 'write-refused');\n }\n }\n\n return { updated, unchanged, needsAttention, skipped };\n}\n\nfunction describeDelta(delta: DeltaEntry): string {\n return `${delta.current ?? 'not installed'} → ${delta.target}`;\n}\n\nfunction checkSummary(\n ui: Ui,\n source: 'host' | 'npm',\n deltas: Record<ToolchainKey, DeltaEntry>,\n): string {\n const entries = Object.entries(deltas) as [ToolchainKey, DeltaEntry][];\n const pending = entries.filter(([, delta]) => delta.changed).length;\n\n return ui.result({\n title:\n pending === 0 ? 'Toolchain is current' : 'Toolchain update available',\n tone: pending === 0 ? 'ok' : 'warn',\n rows: entries.map(([key, delta]): [string, string] => [\n key,\n delta.changed ? describeDelta(delta) : `${delta.target} · current`,\n ]),\n notes: [\n `Target resolved from ${source}.` +\n (pending > 0 ? ' Run \"ekanos upgrade\" to apply it.' : ''),\n ],\n });\n}\n\nfunction planSummary(\n ui: Ui,\n source: string,\n deltas: Record<ToolchainKey, DeltaEntry>,\n): string {\n return ui.result({\n title: 'Upgrading',\n rows: (Object.entries(deltas) as [ToolchainKey, DeltaEntry][])\n .filter(([, delta]) => delta.changed)\n .map(([key, delta]): [string, string] => [key, describeDelta(delta)]),\n notes: [`Target resolved from ${source}.`],\n });\n}\n\nfunction successSummary(\n ui: Ui,\n installedKeys: readonly ToolchainKey[],\n skippedKeys: readonly ToolchainKey[],\n deltas: Record<ToolchainKey, DeltaEntry>,\n regenerated: RegenerationReport,\n scaffolded: { created: string[]; needsAttention: string[] },\n): string {\n const arrow = (key: ToolchainKey) => `${key} → ${deltas[key]!.target}`;\n const attention =\n regenerated.needsAttention.length > 0 ||\n scaffolded.needsAttention.length > 0;\n\n const notes: string[] = [];\n if (scaffolded.created.length > 0) {\n notes.push(\n 'New in this toolchain: see AGENTS.md\\'s \"API documentation\" section.',\n );\n }\n if (scaffolded.needsAttention.length > 0) {\n // Never suggest --force here — it overwrites every scaffolded file,\n // including src/integration.ts.\n notes.push(\n 'A path component is a symlink or unwritable, so those files were not created. ' +\n 'Fix the path, then run \"ekanos init --slug <slug> --dir .\" WITHOUT --force: ' +\n 'init is per-file idempotent and creates only what is missing.',\n );\n }\n if (regenerated.needsAttention.length > 0) {\n const edited = regenerated.skipped\n .filter((s) => s.reason === 'edited-locally')\n .map((s) => s.file);\n const other = regenerated.skipped.filter(\n (s) => s.reason !== 'edited-locally',\n );\n if (edited.length > 0) {\n notes.push(\n `${edited.join(', ')} differ${edited.length === 1 ? 's' : ''} from what the previous CLI scaffolded (edited, or the project was renamed), so the new template was not applied — merge it by hand, or delete the file and run \"ekanos init --slug <slug> --dir .\" to re-create it.`,\n );\n }\n for (const { file, reason } of other) {\n notes.push(\n reason === 'not-a-file'\n ? `${file} is a symlink or not a regular file, so it was left alone.`\n : `${file} could not be written (a symlinked ancestor?), so it was left alone.`,\n );\n }\n }\n\n return ui.result({\n title:\n installedKeys.length > 0 ? 'Toolchain upgraded' : 'Nothing to install',\n tone: attention || installedKeys.length === 0 ? 'warn' : 'ok',\n rows: [\n ...(installedKeys.length > 0\n ? [['Installed', installedKeys.map(arrow)] as const]\n : []),\n ...(skippedKeys.length > 0\n ? [['Not installed', skippedKeys.map(arrow)] as const]\n : []),\n ...(regenerated.updated.length > 0\n ? [['Regenerated', regenerated.updated] as const]\n : []),\n ...(scaffolded.created.length > 0\n ? [['Created', scaffolded.created] as const]\n : []),\n ...(regenerated.needsAttention.length > 0\n ? [['Modified', regenerated.needsAttention] as const]\n : []),\n ...(scaffolded.needsAttention.length > 0\n ? [['Could not create', scaffolded.needsAttention] as const]\n : []),\n ],\n notes:\n skippedKeys.length > 0\n ? [\n 'Not installed = transitive, or not a local dependency (e.g. a global CLI).',\n ...notes,\n ]\n : notes,\n });\n}\n"]}
@@ -16,6 +16,7 @@ export const ERROR_DOCS = {
16
16
  auth_required: docsPage(COMMON_ERRORS, 'exit-4-auth_required'),
17
17
  forbidden: docsPage(COMMON_ERRORS, 'exit-5-forbidden'),
18
18
  gate_failed: docsPage(COMMON_ERRORS, 'exit-10-gate_failed'),
19
+ timeout: docsPage(COMMON_ERRORS, 'exit-11-timeout'),
19
20
  };
20
21
  /** The schema-skew entry: documented under `precondition_failed`, but only for skew. */
21
22
  export const SCHEMA_SKEW_DOCS = docsPage(COMMON_ERRORS, 'exit-9-precondition_failed-schema-skew');
@@ -27,7 +28,10 @@ export const SCHEMA_SKEW_DOCS = docsPage(COMMON_ERRORS, 'exit-9-precondition_fai
27
28
  export const FINDING_DOCS = {
28
29
  'project.host-compiler-rules': docsPage(COMMON_ERRORS, 'project-host-compiler-rules-warning'),
29
30
  'project.slug-agreement': docsPage(COMMON_ERRORS, 'project-slug-agreement-error'),
30
- 'icons/pro-only': docsPage(COMMON_ERRORS, 'icons/pro-only-warning'),
31
+ 'icons/unknown': docsPage(COMMON_ERRORS, 'icons/unknown-warning'),
32
+ 'icons/font-awesome': docsPage(COMMON_ERRORS, 'icons/font-awesome-warning'),
31
33
  'collision.widget-id': docsPage(COMMON_ERRORS, 'collision-widget-id-error'),
34
+ 'pack.empty-file': docsPage(COMMON_ERRORS, 'pack-empty-file-and-pack-test-file-warning'),
35
+ 'pack.test-file': docsPage(COMMON_ERRORS, 'pack-empty-file-and-pack-test-file-warning'),
32
36
  };
33
37
  //# sourceMappingURL=docs-links.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"docs-links.js","sourceRoot":"","sources":["../src/docs-links.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAErD,gEAAgE;AAChE,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,MAAe;IACpD,OAAO,GAAG,YAAY,IAAI,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAqC;IAC1D,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAC9D,SAAS,EAAE,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;IACtD,WAAW,EAAE,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;CAC5D,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CACtC,aAAa,EACb,wCAAwC,CACzC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAqC;IAC5D,6BAA6B,EAAE,QAAQ,CACrC,aAAa,EACb,qCAAqC,CACtC;IACD,wBAAwB,EAAE,QAAQ,CAChC,aAAa,EACb,8BAA8B,CAC/B;IACD,gBAAgB,EAAE,QAAQ,CAAC,aAAa,EAAE,wBAAwB,CAAC;IACnE,qBAAqB,EAAE,QAAQ,CAAC,aAAa,EAAE,2BAA2B,CAAC;CAC5E,CAAC","sourcesContent":["/**\n * The public Ekanos SDK docs. Every docs URL the CLI prints or emits is built\n * from this one constant, so a move of the site is a one-line change.\n */\nexport const SDK_DOCS_URL = 'https://sdk.ekanos.dev';\n\n/** A page on the docs site, e.g. `docsPage('cli/commands')`. */\nexport function docsPage(page: string, anchor?: string): string {\n return `${SDK_DOCS_URL}/${page}${anchor ? `#${anchor}` : ''}`;\n}\n\nconst COMMON_ERRORS = 'troubleshooting/common-errors';\n\n/**\n * The common-errors entries for the CLI error codes the docs document. Anchors\n * are the headings under \"CLI errors\" in common-errors.mdx.\n */\nexport const ERROR_DOCS: Readonly<Record<string, string>> = {\n auth_required: docsPage(COMMON_ERRORS, 'exit-4-auth_required'),\n forbidden: docsPage(COMMON_ERRORS, 'exit-5-forbidden'),\n gate_failed: docsPage(COMMON_ERRORS, 'exit-10-gate_failed'),\n};\n\n/** The schema-skew entry: documented under `precondition_failed`, but only for skew. */\nexport const SCHEMA_SKEW_DOCS = docsPage(\n COMMON_ERRORS,\n 'exit-9-precondition_failed-schema-skew',\n);\n\n/**\n * The validation findings the common-errors page documents, by `check` id.\n * Anchors are the headings under \"Validation findings\". A check absent here\n * has no docs entry, so the renderer prints no link rather than a dead one.\n */\nexport const FINDING_DOCS: Readonly<Record<string, string>> = {\n 'project.host-compiler-rules': docsPage(\n COMMON_ERRORS,\n 'project-host-compiler-rules-warning',\n ),\n 'project.slug-agreement': docsPage(\n COMMON_ERRORS,\n 'project-slug-agreement-error',\n ),\n 'icons/pro-only': docsPage(COMMON_ERRORS, 'icons/pro-only-warning'),\n 'collision.widget-id': docsPage(COMMON_ERRORS, 'collision-widget-id-error'),\n};\n"]}
1
+ {"version":3,"file":"docs-links.js","sourceRoot":"","sources":["../src/docs-links.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAErD,gEAAgE;AAChE,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,MAAe;IACpD,OAAO,GAAG,YAAY,IAAI,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAqC;IAC1D,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAC9D,SAAS,EAAE,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;IACtD,WAAW,EAAE,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC3D,OAAO,EAAE,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAC;CACpD,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CACtC,aAAa,EACb,wCAAwC,CACzC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAqC;IAC5D,6BAA6B,EAAE,QAAQ,CACrC,aAAa,EACb,qCAAqC,CACtC;IACD,wBAAwB,EAAE,QAAQ,CAChC,aAAa,EACb,8BAA8B,CAC/B;IACD,eAAe,EAAE,QAAQ,CAAC,aAAa,EAAE,uBAAuB,CAAC;IACjE,oBAAoB,EAAE,QAAQ,CAAC,aAAa,EAAE,4BAA4B,CAAC;IAC3E,qBAAqB,EAAE,QAAQ,CAAC,aAAa,EAAE,2BAA2B,CAAC;IAC3E,iBAAiB,EAAE,QAAQ,CACzB,aAAa,EACb,4CAA4C,CAC7C;IACD,gBAAgB,EAAE,QAAQ,CACxB,aAAa,EACb,4CAA4C,CAC7C;CACF,CAAC","sourcesContent":["/**\n * The public Ekanos SDK docs. Every docs URL the CLI prints or emits is built\n * from this one constant, so a move of the site is a one-line change.\n */\nexport const SDK_DOCS_URL = 'https://sdk.ekanos.dev';\n\n/** A page on the docs site, e.g. `docsPage('cli/commands')`. */\nexport function docsPage(page: string, anchor?: string): string {\n return `${SDK_DOCS_URL}/${page}${anchor ? `#${anchor}` : ''}`;\n}\n\nconst COMMON_ERRORS = 'troubleshooting/common-errors';\n\n/**\n * The common-errors entries for the CLI error codes the docs document. Anchors\n * are the headings under \"CLI errors\" in common-errors.mdx.\n */\nexport const ERROR_DOCS: Readonly<Record<string, string>> = {\n auth_required: docsPage(COMMON_ERRORS, 'exit-4-auth_required'),\n forbidden: docsPage(COMMON_ERRORS, 'exit-5-forbidden'),\n gate_failed: docsPage(COMMON_ERRORS, 'exit-10-gate_failed'),\n timeout: docsPage(COMMON_ERRORS, 'exit-11-timeout'),\n};\n\n/** The schema-skew entry: documented under `precondition_failed`, but only for skew. */\nexport const SCHEMA_SKEW_DOCS = docsPage(\n COMMON_ERRORS,\n 'exit-9-precondition_failed-schema-skew',\n);\n\n/**\n * The validation findings the common-errors page documents, by `check` id.\n * Anchors are the headings under \"Validation findings\". A check absent here\n * has no docs entry, so the renderer prints no link rather than a dead one.\n */\nexport const FINDING_DOCS: Readonly<Record<string, string>> = {\n 'project.host-compiler-rules': docsPage(\n COMMON_ERRORS,\n 'project-host-compiler-rules-warning',\n ),\n 'project.slug-agreement': docsPage(\n COMMON_ERRORS,\n 'project-slug-agreement-error',\n ),\n 'icons/unknown': docsPage(COMMON_ERRORS, 'icons/unknown-warning'),\n 'icons/font-awesome': docsPage(COMMON_ERRORS, 'icons/font-awesome-warning'),\n 'collision.widget-id': docsPage(COMMON_ERRORS, 'collision-widget-id-error'),\n 'pack.empty-file': docsPage(\n COMMON_ERRORS,\n 'pack-empty-file-and-pack-test-file-warning',\n ),\n 'pack.test-file': docsPage(\n COMMON_ERRORS,\n 'pack-empty-file-and-pack-test-file-warning',\n ),\n};\n"]}
package/dist/errors.d.ts CHANGED
@@ -37,6 +37,8 @@ export declare function authRequiredError(message: string, hint: string): CliErr
37
37
  export declare function forbiddenError(message: string, hint: string): CliError;
38
38
  /** A publish gate rejected the submission. Exit 10. */
39
39
  export declare function gateFailedError(message: string, hint: string): CliError;
40
+ /** A wait for a remote verdict ran out of time; the verdict may still arrive. Exit 11. */
41
+ export declare function timeoutError(message: string, hint: string): CliError;
40
42
  /** A network operation failed (DNS, TLS, timeout, 5xx). Exit 8. */
41
43
  export declare function networkError(message: string, hint: string): CliError;
42
44
  /**
package/dist/errors.js CHANGED
@@ -96,6 +96,15 @@ export function gateFailedError(message, hint) {
96
96
  hint,
97
97
  });
98
98
  }
99
+ /** A wait for a remote verdict ran out of time; the verdict may still arrive. Exit 11. */
100
+ export function timeoutError(message, hint) {
101
+ return new CliError({
102
+ code: ERROR_CODES.TIMEOUT,
103
+ exitCode: EXIT_CODES.TIMEOUT,
104
+ message,
105
+ hint,
106
+ });
107
+ }
99
108
  /** A network operation failed (DNS, TLS, timeout, 5xx). Exit 8. */
100
109
  export function networkError(message, hint) {
101
110
  return new CliError({
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,WAAW,EACX,UAAU,GAGX,MAAM,cAAc,CAAC;AAEtB;;;;;;;GAOG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAOjC,YAAY,MAMX;;QACC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvB,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,CAAC,OAAO,wCAAwC;gBACrE,uDAAuD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAA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AAC,QAAQ;QAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO;QACP,IAAI,EACF,wEAAwE;YACxE,4DAA4D;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { ERROR_DOCS } from './docs-links';\nimport {\n ERROR_CODES,\n EXIT_CODES,\n type ErrorCode,\n type ExitCode,\n} from './exit-codes';\n\n/**\n * The one error type every command path throws. It carries the three things\n * the envelope needs — a stable string `code`, a human `message`, and a\n * non-empty imperative `hint` — plus the numeric `exitCode` the process ends\n * with. Constructing one with an empty hint is a programming error and throws\n * immediately, which is what lets `context.fail()` guarantee the envelope's\n * \"every error has a hint\" invariant without a runtime check at the edge.\n */\nexport class CliError extends Error {\n readonly code: ErrorCode;\n readonly exitCode: ExitCode;\n readonly hint: string;\n /** A docs URL for this error, when the docs document it. Absent otherwise. */\n readonly docs?: string;\n\n constructor(params: {\n code: ErrorCode;\n exitCode: ExitCode;\n message: string;\n hint: string;\n docs?: string;\n }) {\n super(params.message);\n this.name = 'CliError';\n\n if (!params.hint || params.hint.trim().length === 0) {\n throw new Error(\n `CliError for \"${params.message}\" was constructed with an empty hint. ` +\n 'Every CLI error must carry an imperative remediation.',\n );\n }\n\n this.code = params.code;\n this.exitCode = params.exitCode;\n this.hint = params.hint;\n this.docs = params.docs ?? ERROR_DOCS[params.code];\n }\n}\n\n/** A usage error (unknown flag/command, bad argument). Exit 2. */\nexport function usageError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.USAGE,\n exitCode: EXIT_CODES.USAGE,\n message,\n hint,\n });\n}\n\n/** Validation produced error-severity findings. Exit 3. */\nexport function validationError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.VALIDATION,\n exitCode: EXIT_CODES.VALIDATION,\n message,\n hint,\n });\n}\n\n/** A precondition failure (missing tool, config, or file). Exit 9. */\nexport function preconditionError(\n message: string,\n hint: string,\n docs?: string,\n): CliError {\n return new CliError({\n code: ERROR_CODES.PRECONDITION_FAILED,\n exitCode: EXIT_CODES.PRECONDITION_FAILED,\n message,\n hint,\n docs,\n });\n}\n\n/** An invalid-state failure (idempotency / ordering). Exit 7. */\nexport function invalidStateError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.INVALID_STATE,\n exitCode: EXIT_CODES.INVALID_STATE,\n message,\n hint,\n });\n}\n\n/** A not-found failure. Exit 6. */\nexport function notFoundError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NOT_FOUND,\n exitCode: EXIT_CODES.NOT_FOUND,\n message,\n hint,\n });\n}\n\n/** Authentication is required but absent or expired. Exit 4. */\nexport function authRequiredError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.AUTH_REQUIRED,\n exitCode: EXIT_CODES.AUTH_REQUIRED,\n message,\n hint,\n });\n}\n\n/** Authenticated, but the server refused. Exit 5. */\nexport function forbiddenError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.FORBIDDEN,\n exitCode: EXIT_CODES.FORBIDDEN,\n message,\n hint,\n });\n}\n\n/** A publish gate rejected the submission. Exit 10. */\nexport function gateFailedError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.GATE_FAILED,\n exitCode: EXIT_CODES.GATE_FAILED,\n message,\n hint,\n });\n}\n\n/** A network operation failed (DNS, TLS, timeout, 5xx). Exit 8. */\nexport function networkError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NETWORK,\n exitCode: EXIT_CODES.NETWORK,\n message,\n hint,\n });\n}\n\n/**\n * Coerce anything thrown into a CliError. A thrown CliError passes through; a\n * plain Error becomes an INTERNAL (exit 1) with a generic-but-non-empty hint.\n */\nexport function toCliError(error: unknown): CliError {\n if (error instanceof CliError) return error;\n\n const message = error instanceof Error ? error.message : String(error);\n return new CliError({\n code: ERROR_CODES.INTERNAL,\n exitCode: EXIT_CODES.INTERNAL,\n message,\n hint:\n 'This is an internal CLI error. Re-run with --json to capture the full ' +\n 'envelope and report it at npm@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AAe,CAAC,OAAe,EAAE,IAAY;IAC3D,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,WAAW;QAC7B,QAAQ,EAAE,UAAU,CAAC,WAAW;QAChC,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,IAAY;IACxD,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,OAAO;QACzB,QAAQ,EAAE,UAAU,CAAC,OAAO;QAC5B,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,IAAY;IACxD,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,OAAO;QACzB,QAAQ,EAAE,UAAU,CAAC,OAAO;QAC5B,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAI,KAAK,YAAY,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,QAAQ;QAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO;QACP,IAAI,EACF,wEAAwE;YACxE,4DAA4D;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { ERROR_DOCS } from './docs-links';\nimport {\n ERROR_CODES,\n EXIT_CODES,\n type ErrorCode,\n type ExitCode,\n} from './exit-codes';\n\n/**\n * The one error type every command path throws. It carries the three things\n * the envelope needs — a stable string `code`, a human `message`, and a\n * non-empty imperative `hint` — plus the numeric `exitCode` the process ends\n * with. Constructing one with an empty hint is a programming error and throws\n * immediately, which is what lets `context.fail()` guarantee the envelope's\n * \"every error has a hint\" invariant without a runtime check at the edge.\n */\nexport class CliError extends Error {\n readonly code: ErrorCode;\n readonly exitCode: ExitCode;\n readonly hint: string;\n /** A docs URL for this error, when the docs document it. Absent otherwise. */\n readonly docs?: string;\n\n constructor(params: {\n code: ErrorCode;\n exitCode: ExitCode;\n message: string;\n hint: string;\n docs?: string;\n }) {\n super(params.message);\n this.name = 'CliError';\n\n if (!params.hint || params.hint.trim().length === 0) {\n throw new Error(\n `CliError for \"${params.message}\" was constructed with an empty hint. ` +\n 'Every CLI error must carry an imperative remediation.',\n );\n }\n\n this.code = params.code;\n this.exitCode = params.exitCode;\n this.hint = params.hint;\n this.docs = params.docs ?? ERROR_DOCS[params.code];\n }\n}\n\n/** A usage error (unknown flag/command, bad argument). Exit 2. */\nexport function usageError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.USAGE,\n exitCode: EXIT_CODES.USAGE,\n message,\n hint,\n });\n}\n\n/** Validation produced error-severity findings. Exit 3. */\nexport function validationError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.VALIDATION,\n exitCode: EXIT_CODES.VALIDATION,\n message,\n hint,\n });\n}\n\n/** A precondition failure (missing tool, config, or file). Exit 9. */\nexport function preconditionError(\n message: string,\n hint: string,\n docs?: string,\n): CliError {\n return new CliError({\n code: ERROR_CODES.PRECONDITION_FAILED,\n exitCode: EXIT_CODES.PRECONDITION_FAILED,\n message,\n hint,\n docs,\n });\n}\n\n/** An invalid-state failure (idempotency / ordering). Exit 7. */\nexport function invalidStateError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.INVALID_STATE,\n exitCode: EXIT_CODES.INVALID_STATE,\n message,\n hint,\n });\n}\n\n/** A not-found failure. Exit 6. */\nexport function notFoundError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NOT_FOUND,\n exitCode: EXIT_CODES.NOT_FOUND,\n message,\n hint,\n });\n}\n\n/** Authentication is required but absent or expired. Exit 4. */\nexport function authRequiredError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.AUTH_REQUIRED,\n exitCode: EXIT_CODES.AUTH_REQUIRED,\n message,\n hint,\n });\n}\n\n/** Authenticated, but the server refused. Exit 5. */\nexport function forbiddenError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.FORBIDDEN,\n exitCode: EXIT_CODES.FORBIDDEN,\n message,\n hint,\n });\n}\n\n/** A publish gate rejected the submission. Exit 10. */\nexport function gateFailedError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.GATE_FAILED,\n exitCode: EXIT_CODES.GATE_FAILED,\n message,\n hint,\n });\n}\n\n/** A wait for a remote verdict ran out of time; the verdict may still arrive. Exit 11. */\nexport function timeoutError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.TIMEOUT,\n exitCode: EXIT_CODES.TIMEOUT,\n message,\n hint,\n });\n}\n\n/** A network operation failed (DNS, TLS, timeout, 5xx). Exit 8. */\nexport function networkError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NETWORK,\n exitCode: EXIT_CODES.NETWORK,\n message,\n hint,\n });\n}\n\n/**\n * Coerce anything thrown into a CliError. A thrown CliError passes through; a\n * plain Error becomes an INTERNAL (exit 1) with a generic-but-non-empty hint.\n */\nexport function toCliError(error: unknown): CliError {\n if (error instanceof CliError) return error;\n\n const message = error instanceof Error ? error.message : String(error);\n return new CliError({\n code: ERROR_CODES.INTERNAL,\n exitCode: EXIT_CODES.INTERNAL,\n message,\n hint:\n 'This is an internal CLI error. Re-run with --json to capture the full ' +\n 'envelope and report it at npm@govastly.com if it persists.',\n });\n}\n"]}
@@ -30,6 +30,8 @@ export declare const EXIT_CODES: {
30
30
  readonly PRECONDITION_FAILED: 9;
31
31
  /** A remote/publish gate rejected the submission. */
32
32
  readonly GATE_FAILED: 10;
33
+ /** A wait for a remote verdict ran out of time (the verdict may still arrive). */
34
+ readonly TIMEOUT: 11;
33
35
  };
34
36
  export type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
35
37
  /**
@@ -48,5 +50,6 @@ export declare const ERROR_CODES: {
48
50
  readonly NETWORK: 'network';
49
51
  readonly PRECONDITION_FAILED: 'precondition_failed';
50
52
  readonly GATE_FAILED: 'gate_failed';
53
+ readonly TIMEOUT: 'timeout';
51
54
  };
52
55
  export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
@@ -30,6 +30,8 @@ export const EXIT_CODES = {
30
30
  PRECONDITION_FAILED: 9,
31
31
  /** A remote/publish gate rejected the submission. */
32
32
  GATE_FAILED: 10,
33
+ /** A wait for a remote verdict ran out of time (the verdict may still arrive). */
34
+ TIMEOUT: 11,
33
35
  };
34
36
  /**
35
37
  * Stable string codes carried in the JSON error envelope. Kept alongside the
@@ -47,5 +49,6 @@ export const ERROR_CODES = {
47
49
  NETWORK: 'network',
48
50
  PRECONDITION_FAILED: 'precondition_failed',
49
51
  GATE_FAILED: 'gate_failed',
52
+ TIMEOUT: 'timeout',
50
53
  };
51
54
  //# sourceMappingURL=exit-codes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../src/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,eAAe;IACf,EAAE,EAAE,CAAC;IACL,6EAA6E;IAC7E,QAAQ,EAAE,CAAC;IACX,yEAAyE;IACzE,KAAK,EAAE,CAAC;IACR,+EAA+E;IAC/E,UAAU,EAAE,CAAC;IACb,6CAA6C;IAC7C,aAAa,EAAE,CAAC;IAChB,wCAAwC;IACxC,SAAS,EAAE,CAAC;IACZ,kEAAkE;IAClE,SAAS,EAAE,CAAC;IACZ,4EAA4E;IAC5E,aAAa,EAAE,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,CAAC;IACV,2EAA2E;IAC3E,mBAAmB,EAAE,CAAC;IACtB,qDAAqD;IACrD,WAAW,EAAE,EAAE;CACP,CAAC;AAIX;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;IAClB,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;CAClB,CAAC","sourcesContent":["/**\n * The frozen exit-code taxonomy. This is a PUBLIC CONTRACT: agents and CI\n * branch on these numbers, so a value never changes meaning once shipped. New\n * conditions get new numbers; they are never renumbered.\n *\n * This cut (init / validate / test) only ever emits 0, 1, 2, 3, and 9 — but\n * the whole taxonomy is fixed here up front so later cuts (auth, publish, the\n * remote gate) slot in without renumbering.\n */\nexport const EXIT_CODES = {\n /** Success. */\n OK: 0,\n /** An unexpected internal error — a bug in the CLI, not the user's input. */\n INTERNAL: 1,\n /** Usage error: an unknown flag/command, a missing required argument. */\n USAGE: 2,\n /** Validation produced error-severity findings (the definition is invalid). */\n VALIDATION: 3,\n /** Authentication is required but absent. */\n AUTH_REQUIRED: 4,\n /** Authenticated, but not permitted. */\n FORBIDDEN: 5,\n /** A named resource (project, file, definition) was not found. */\n NOT_FOUND: 6,\n /** The command cannot run in the current state (idempotency / ordering). */\n INVALID_STATE: 7,\n /** A network operation failed. */\n NETWORK: 8,\n /** A precondition failed (a required tool, config, or file is missing). */\n PRECONDITION_FAILED: 9,\n /** A remote/publish gate rejected the submission. */\n GATE_FAILED: 10,\n} as const;\n\nexport type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];\n\n/**\n * Stable string codes carried in the JSON error envelope. Kept alongside the\n * numeric exits so a machine reader can switch on a name without memorizing an\n * integer. One code per numeric exit that this taxonomy can emit.\n */\nexport const ERROR_CODES = {\n INTERNAL: 'internal',\n USAGE: 'usage',\n VALIDATION: 'validation',\n AUTH_REQUIRED: 'auth_required',\n FORBIDDEN: 'forbidden',\n NOT_FOUND: 'not_found',\n INVALID_STATE: 'invalid_state',\n NETWORK: 'network',\n PRECONDITION_FAILED: 'precondition_failed',\n GATE_FAILED: 'gate_failed',\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n"]}
1
+ {"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../src/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,eAAe;IACf,EAAE,EAAE,CAAC;IACL,6EAA6E;IAC7E,QAAQ,EAAE,CAAC;IACX,yEAAyE;IACzE,KAAK,EAAE,CAAC;IACR,+EAA+E;IAC/E,UAAU,EAAE,CAAC;IACb,6CAA6C;IAC7C,aAAa,EAAE,CAAC;IAChB,wCAAwC;IACxC,SAAS,EAAE,CAAC;IACZ,kEAAkE;IAClE,SAAS,EAAE,CAAC;IACZ,4EAA4E;IAC5E,aAAa,EAAE,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,CAAC;IACV,2EAA2E;IAC3E,mBAAmB,EAAE,CAAC;IACtB,qDAAqD;IACrD,WAAW,EAAE,EAAE;IACf,kFAAkF;IAClF,OAAO,EAAE,EAAE;CACH,CAAC;AAIX;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;IAClB,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;CACV,CAAC","sourcesContent":["/**\n * The frozen exit-code taxonomy. This is a PUBLIC CONTRACT: agents and CI\n * branch on these numbers, so a value never changes meaning once shipped. New\n * conditions get new numbers; they are never renumbered.\n *\n * This cut (init / validate / test) only ever emits 0, 1, 2, 3, and 9 — but\n * the whole taxonomy is fixed here up front so later cuts (auth, publish, the\n * remote gate) slot in without renumbering.\n */\nexport const EXIT_CODES = {\n /** Success. */\n OK: 0,\n /** An unexpected internal error — a bug in the CLI, not the user's input. */\n INTERNAL: 1,\n /** Usage error: an unknown flag/command, a missing required argument. */\n USAGE: 2,\n /** Validation produced error-severity findings (the definition is invalid). */\n VALIDATION: 3,\n /** Authentication is required but absent. */\n AUTH_REQUIRED: 4,\n /** Authenticated, but not permitted. */\n FORBIDDEN: 5,\n /** A named resource (project, file, definition) was not found. */\n NOT_FOUND: 6,\n /** The command cannot run in the current state (idempotency / ordering). */\n INVALID_STATE: 7,\n /** A network operation failed. */\n NETWORK: 8,\n /** A precondition failed (a required tool, config, or file is missing). */\n PRECONDITION_FAILED: 9,\n /** A remote/publish gate rejected the submission. */\n GATE_FAILED: 10,\n /** A wait for a remote verdict ran out of time (the verdict may still arrive). */\n TIMEOUT: 11,\n} as const;\n\nexport type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];\n\n/**\n * Stable string codes carried in the JSON error envelope. Kept alongside the\n * numeric exits so a machine reader can switch on a name without memorizing an\n * integer. One code per numeric exit that this taxonomy can emit.\n */\nexport const ERROR_CODES = {\n INTERNAL: 'internal',\n USAGE: 'usage',\n VALIDATION: 'validation',\n AUTH_REQUIRED: 'auth_required',\n FORBIDDEN: 'forbidden',\n NOT_FOUND: 'not_found',\n INVALID_STATE: 'invalid_state',\n NETWORK: 'network',\n PRECONDITION_FAILED: 'precondition_failed',\n GATE_FAILED: 'gate_failed',\n TIMEOUT: 'timeout',\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n"]}
@@ -6,7 +6,7 @@ import { analyzeDefinition, checkFixtures, } from './definition-checks.js';
6
6
  import { generateIntegrationsDts } from './integrations-codegen.js';
7
7
  import { loadExperience } from './load-experience.js';
8
8
  import { isOverridesFileTracked } from './overrides.js';
9
- import { checkIntegrationPins, } from './pins.js';
9
+ import { checkConnectionLevels, checkIntegrationPins, } from './pins.js';
10
10
  import { LOCAL_OVERRIDES_FILE, INTEGRATIONS_DTS, LEGACY_SLOTS_DTS, readLockfile, } from './project.js';
11
11
  export const GENERATED_TYPES_CHECK = 'checks/generated-types';
12
12
  export const LOCAL_OVERRIDES_CHECK = 'checks/local-overrides';
@@ -85,6 +85,7 @@ export async function runExperienceChecks(project, options) {
85
85
  const lock = readLockfile(project);
86
86
  const pins = checkIntegrationPins(project, lock, (_a = options.pinsResolver) !== null && _a !== void 0 ? _a : undefined);
87
87
  findings.push(...pins.findings);
88
+ findings.push(...checkConnectionLevels(pins.pinned));
88
89
  if (isOverridesFileTracked(project)) {
89
90
  findings.push({
90
91
  check: LOCAL_OVERRIDES_CHECK,
@@ -1 +1 @@
1
- {"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/experience/checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAEL,iBAAiB,EACjB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,oBAAoB,EAEpB,gBAAgB,EAChB,gBAAgB,EAChB,Y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AAE,OAAO,CAAC,KAAK;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,SAAS;QAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAE/D,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM;QACN,SAAS,QAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS,mCAAI,EAAE;KACrC,CAAC;AACJ,CAAC","sourcesContent":["import type { Finding, WorkflowTemplate } from '@ekanos/integration-schema';\nimport { spawnSync } from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { checkExperienceBoundary } from './boundary';\nimport {\n type DefinitionAnalysis,\n analyzeDefinition,\n checkFixtures,\n} from './definition-checks';\nimport type { LoadedExperienceModule } from './definition-shape';\nimport { generateIntegrationsDts } from './integrations-codegen';\nimport { loadExperience } from './load-experience';\nimport { isOverridesFileTracked } from './overrides';\nimport {\n type PinnedIntegration,\n type PinsResolver,\n checkIntegrationPins,\n} from './pins';\nimport {\n LOCAL_OVERRIDES_FILE,\n type ExperienceProject,\n INTEGRATIONS_DTS,\n LEGACY_SLOTS_DTS,\n readLockfile,\n} from './project';\n\nexport const GENERATED_TYPES_CHECK = 'checks/generated-types';\nexport const LOCAL_OVERRIDES_CHECK = 'checks/local-overrides';\nexport const TYPECHECK_CHECK = 'checks/typecheck';\n\nexport interface ExperienceCheckOptions {\n typecheck: boolean;\n /** Skip loading the entry (used by commands that only need the static stages). */\n loadDefinition: boolean;\n inlineSdk?: string;\n /** The harness's pins resolver (`harnessPinsResolver`); absent = committed snapshots only. */\n pinsResolver?: PinsResolver | null;\n}\n\nexport interface ExperienceCheckResult {\n findings: Finding[];\n pinned: PinnedIntegration[];\n loaded?: LoadedExperienceModule;\n workflows: WorkflowTemplate[];\n}\n\n/** The dts the pinned contracts generate: shared by `codegen` and the freshness check. */\nexport function expectedIntegrationsDts(\n pinned: readonly PinnedIntegration[],\n): string {\n return generateIntegrationsDts(\n pinned.map(({ use, contract }) => ({\n integration: use.name,\n contract,\n operations: use.operations\n .map((id) => /\\/((?:tool|action)\\/.+)$/.exec(id)?.[1])\n .filter((key): key is string => key !== undefined),\n })),\n );\n}\n\nfunction checkGeneratedTypes(\n project: ExperienceProject,\n pinned: readonly PinnedIntegration[],\n): Finding[] {\n const file = path.join(project.dir, INTEGRATIONS_DTS);\n const current = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null;\n const findings: Finding[] = [];\n if (fs.existsSync(path.join(project.dir, LEGACY_SLOTS_DTS))) {\n findings.push({\n check: GENERATED_TYPES_CHECK,\n severity: 'warn',\n message: `${LEGACY_SLOTS_DTS} is the previous name of ${INTEGRATIONS_DTS}.`,\n hint: `Delete it and list ${INTEGRATIONS_DTS} in tsconfig.json \"include\"; until then \"ekanos sync\" keeps it as a re-export.`,\n file: LEGACY_SLOTS_DTS,\n });\n }\n if (current === expectedIntegrationsDts(pinned)) return findings;\n\n return [\n ...findings,\n {\n check: GENERATED_TYPES_CHECK,\n severity: 'error',\n message: `${INTEGRATIONS_DTS} is ${current === null ? 'missing' : 'out of date'} for the pinned contracts.`,\n hint: 'Run \"ekanos codegen\" and commit the result.',\n file: INTEGRATIONS_DTS,\n },\n ];\n}\n\nfunction runTypecheck(project: ExperienceProject): Finding[] {\n const tsc = path.join(project.dir, 'node_modules', '.bin', 'tsc');\n if (\n !fs.existsSync(tsc) ||\n !fs.existsSync(path.join(project.dir, 'tsconfig.json'))\n ) {\n return [\n {\n check: TYPECHECK_CHECK,\n severity: 'warn',\n message: 'typecheck skipped: no local TypeScript or tsconfig.json.',\n hint: 'Install typescript and keep a tsconfig.json to type-check against the generated integrations.',\n },\n ];\n }\n const result = spawnSync(tsc, ['--noEmit', '-p', 'tsconfig.json'], {\n cwd: project.dir,\n encoding: 'utf8',\n });\n if (result.status === 0) return [];\n\n const lines = `${result.stdout}${result.stderr}`\n .split('\\n')\n .filter((l) => l.trim() !== '');\n\n return lines.slice(0, 20).map((line) => {\n const m = /^(.+?)\\((\\d+),\\d+\\): (.*)$/.exec(line);\n\n return {\n check: TYPECHECK_CHECK,\n severity: 'error' as const,\n message: m ? (m[3] as string) : line,\n hint: 'Fix the type error; it is what the generated integration types caught.',\n ...(m ? { file: m[1] as string, line: Number(m[2]) } : {}),\n };\n });\n}\n\n/**\n * The experience gate, in dependency order. Stages that need an earlier stage's\n * output are skipped when it failed, so one root cause yields one finding, not\n * a cascade.\n */\nexport async function runExperienceChecks(\n project: ExperienceProject,\n options: ExperienceCheckOptions,\n): Promise<ExperienceCheckResult> {\n const findings: Finding[] = [];\n const lock = readLockfile(project);\n\n const pins = checkIntegrationPins(\n project,\n lock,\n options.pinsResolver ?? undefined,\n );\n findings.push(...pins.findings);\n\n if (isOverridesFileTracked(project)) {\n findings.push({\n check: LOCAL_OVERRIDES_CHECK,\n severity: 'error',\n message: `${LOCAL_OVERRIDES_FILE} is tracked by git.`,\n hint: `It is per-developer and must stay untracked: \"git rm --cached ${LOCAL_OVERRIDES_FILE}\" and add it to .gitignore.`,\n file: LOCAL_OVERRIDES_FILE,\n });\n }\n\n const pinsOk = pins.findings.length === 0;\n if (pinsOk || pins.pinned.length > 0) {\n findings.push(...checkGeneratedTypes(project, pins.pinned));\n }\n\n findings.push(...(await checkExperienceBoundary(project)));\n findings.push(...checkFixtures(project, pins.pinned));\n\n let loaded: LoadedExperienceModule | undefined;\n let analysis: DefinitionAnalysis | undefined;\n if (options.loadDefinition && pinsOk) {\n const result = await loadExperience(project, {\n inlineSdk: options.inlineSdk,\n });\n if (result.ok) {\n loaded = result;\n analysis = analyzeDefinition(project, result, pins.pinned);\n findings.push(...analysis.findings);\n } else {\n findings.push({\n check: 'checks/experience-definition',\n severity: 'error',\n message: result.message,\n hint: 'Fix the entry so it exports defineExperience({...}) as default.',\n file: project.entry,\n });\n }\n }\n\n if (options.typecheck) findings.push(...runTypecheck(project));\n\n return {\n findings,\n pinned: pins.pinned,\n loaded,\n workflows: analysis?.workflows ?? [],\n };\n}\n"]}
1
+ {"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/experience/checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAEL,iBAAiB,EACjB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,oBAAoB,EAEpB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAkBlD,0FAA0F;AAC1F,MAAM,UAAU,uBAAuB,CACrC,MAAoC;IAEpC,OAAO,uBAAuB,CAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QACjC,WAAW,EAAE,GAAG,CAAC,IAAI;QACrB,QAAQ;QACR,UAAU,EAAE,GAAG,CAAC,UAAU;aACvB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,kBAAC,MAAA,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,0CAAG,CAAC,CA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,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAEtD,IAAI,MAA0C,CAAC;IAC/C,IAAI,QAAwC,CAAC;IAC7C,IAAI,OAAO,CAAC,cAAc,IAAI,MAAM,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE;YAC3C,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;YACd,MAAM,GAAG,MAAM,CAAC;YAChB,QAAQ,GAAG,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3D,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,8BAA8B;gBACrC,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,IAAI,EAAE,iEAAiE;gBACvE,IAAI,EAAE,OAAO,CAAC,KAAK;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,SAAS;QAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAE/D,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM;QACN,SAAS,QAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS,mCAAI,EAAE;KACrC,CAAC;AACJ,CAAC","sourcesContent":["import type { Finding, WorkflowTemplate } from '@ekanos/integration-schema';\nimport { spawnSync } from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { checkExperienceBoundary } from './boundary';\nimport {\n type DefinitionAnalysis,\n analyzeDefinition,\n checkFixtures,\n} from './definition-checks';\nimport type { LoadedExperienceModule } from './definition-shape';\nimport { generateIntegrationsDts } from './integrations-codegen';\nimport { loadExperience } from './load-experience';\nimport { isOverridesFileTracked } from './overrides';\nimport {\n type PinnedIntegration,\n type PinsResolver,\n checkConnectionLevels,\n checkIntegrationPins,\n} from './pins';\nimport {\n LOCAL_OVERRIDES_FILE,\n type ExperienceProject,\n INTEGRATIONS_DTS,\n LEGACY_SLOTS_DTS,\n readLockfile,\n} from './project';\n\nexport const GENERATED_TYPES_CHECK = 'checks/generated-types';\nexport const LOCAL_OVERRIDES_CHECK = 'checks/local-overrides';\nexport const TYPECHECK_CHECK = 'checks/typecheck';\n\nexport interface ExperienceCheckOptions {\n typecheck: boolean;\n /** Skip loading the entry (used by commands that only need the static stages). */\n loadDefinition: boolean;\n inlineSdk?: string;\n /** The harness's pins resolver (`harnessPinsResolver`); absent = committed snapshots only. */\n pinsResolver?: PinsResolver | null;\n}\n\nexport interface ExperienceCheckResult {\n findings: Finding[];\n pinned: PinnedIntegration[];\n loaded?: LoadedExperienceModule;\n workflows: WorkflowTemplate[];\n}\n\n/** The dts the pinned contracts generate: shared by `codegen` and the freshness check. */\nexport function expectedIntegrationsDts(\n pinned: readonly PinnedIntegration[],\n): string {\n return generateIntegrationsDts(\n pinned.map(({ use, contract }) => ({\n integration: use.name,\n contract,\n operations: use.operations\n .map((id) => /\\/((?:tool|action)\\/.+)$/.exec(id)?.[1])\n .filter((key): key is string => key !== undefined),\n })),\n );\n}\n\nfunction checkGeneratedTypes(\n project: ExperienceProject,\n pinned: readonly PinnedIntegration[],\n): Finding[] {\n const file = path.join(project.dir, INTEGRATIONS_DTS);\n const current = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null;\n const findings: Finding[] = [];\n if (fs.existsSync(path.join(project.dir, LEGACY_SLOTS_DTS))) {\n findings.push({\n check: GENERATED_TYPES_CHECK,\n severity: 'warn',\n message: `${LEGACY_SLOTS_DTS} is the previous name of ${INTEGRATIONS_DTS}.`,\n hint: `Delete it and list ${INTEGRATIONS_DTS} in tsconfig.json \"include\"; until then \"ekanos sync\" keeps it as a re-export.`,\n file: LEGACY_SLOTS_DTS,\n });\n }\n if (current === expectedIntegrationsDts(pinned)) return findings;\n\n return [\n ...findings,\n {\n check: GENERATED_TYPES_CHECK,\n severity: 'error',\n message: `${INTEGRATIONS_DTS} is ${current === null ? 'missing' : 'out of date'} for the pinned contracts.`,\n hint: 'Run \"ekanos codegen\" and commit the result.',\n file: INTEGRATIONS_DTS,\n },\n ];\n}\n\nfunction runTypecheck(project: ExperienceProject): Finding[] {\n const tsc = path.join(project.dir, 'node_modules', '.bin', 'tsc');\n if (\n !fs.existsSync(tsc) ||\n !fs.existsSync(path.join(project.dir, 'tsconfig.json'))\n ) {\n return [\n {\n check: TYPECHECK_CHECK,\n severity: 'warn',\n message: 'typecheck skipped: no local TypeScript or tsconfig.json.',\n hint: 'Install typescript and keep a tsconfig.json to type-check against the generated integrations.',\n },\n ];\n }\n const result = spawnSync(tsc, ['--noEmit', '-p', 'tsconfig.json'], {\n cwd: project.dir,\n encoding: 'utf8',\n });\n if (result.status === 0) return [];\n\n const lines = `${result.stdout}${result.stderr}`\n .split('\\n')\n .filter((l) => l.trim() !== '');\n\n return lines.slice(0, 20).map((line) => {\n const m = /^(.+?)\\((\\d+),\\d+\\): (.*)$/.exec(line);\n\n return {\n check: TYPECHECK_CHECK,\n severity: 'error' as const,\n message: m ? (m[3] as string) : line,\n hint: 'Fix the type error; it is what the generated integration types caught.',\n ...(m ? { file: m[1] as string, line: Number(m[2]) } : {}),\n };\n });\n}\n\n/**\n * The experience gate, in dependency order. Stages that need an earlier stage's\n * output are skipped when it failed, so one root cause yields one finding, not\n * a cascade.\n */\nexport async function runExperienceChecks(\n project: ExperienceProject,\n options: ExperienceCheckOptions,\n): Promise<ExperienceCheckResult> {\n const findings: Finding[] = [];\n const lock = readLockfile(project);\n\n const pins = checkIntegrationPins(\n project,\n lock,\n options.pinsResolver ?? undefined,\n );\n findings.push(...pins.findings);\n findings.push(...checkConnectionLevels(pins.pinned));\n\n if (isOverridesFileTracked(project)) {\n findings.push({\n check: LOCAL_OVERRIDES_CHECK,\n severity: 'error',\n message: `${LOCAL_OVERRIDES_FILE} is tracked by git.`,\n hint: `It is per-developer and must stay untracked: \"git rm --cached ${LOCAL_OVERRIDES_FILE}\" and add it to .gitignore.`,\n file: LOCAL_OVERRIDES_FILE,\n });\n }\n\n const pinsOk = pins.findings.length === 0;\n if (pinsOk || pins.pinned.length > 0) {\n findings.push(...checkGeneratedTypes(project, pins.pinned));\n }\n\n findings.push(...(await checkExperienceBoundary(project)));\n findings.push(...checkFixtures(project, pins.pinned));\n\n let loaded: LoadedExperienceModule | undefined;\n let analysis: DefinitionAnalysis | undefined;\n if (options.loadDefinition && pinsOk) {\n const result = await loadExperience(project, {\n inlineSdk: options.inlineSdk,\n });\n if (result.ok) {\n loaded = result;\n analysis = analyzeDefinition(project, result, pins.pinned);\n findings.push(...analysis.findings);\n } else {\n findings.push({\n check: 'checks/experience-definition',\n severity: 'error',\n message: result.message,\n hint: 'Fix the entry so it exports defineExperience({...}) as default.',\n file: project.entry,\n });\n }\n }\n\n if (options.typecheck) findings.push(...runTypecheck(project));\n\n return {\n findings,\n pinned: pins.pinned,\n loaded,\n workflows: analysis?.workflows ?? [],\n };\n}\n"]}
@@ -22,6 +22,13 @@ export declare function analyzeDefinition(project: ExperienceProject, loaded: Lo
22
22
  * so a definition built by an older SDK, or by hand, cannot slip past.
23
23
  */
24
24
  export declare function checkSurfaces(project: ExperienceProject, definition: LoadedExperienceDefinition): Finding[];
25
+ /**
26
+ * The dashboard reads a widget's `size`, `layouts.lg.w` and `layouts.lg.maxHeight`
27
+ * and nothing else. `x`, `y` and `h` are required by the layout type, so their
28
+ * presence says nothing; a `md` or `sm` box is optional and is never read, so
29
+ * declaring one is a finding.
30
+ */
31
+ export declare function checkWidgetLayouts(project: ExperienceProject, definition: LoadedExperienceDefinition): Finding[];
25
32
  /** `dist/surfaces.json`: the surfaces and suggested layout as data, no code. */
26
33
  export declare function buildSurfaces(project: ExperienceProject, definition: LoadedExperienceDefinition): ExperienceSurfaces;
27
34
  /** `fixtures/<integration>/<kind>-<name>.<variant>.json` must satisfy the pinned output schema. */