@ekanos/cli 0.30.0 → 0.32.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 (41) hide show
  1. package/README.md +4 -3
  2. package/dist/commands/apps.d.ts +10 -0
  3. package/dist/commands/apps.js +39 -12
  4. package/dist/commands/apps.js.map +1 -1
  5. package/dist/commands/contract.js +12 -11
  6. package/dist/commands/contract.js.map +1 -1
  7. package/dist/commands/dev.js +1 -0
  8. package/dist/commands/dev.js.map +1 -1
  9. package/dist/commands/doctor.d.ts +29 -0
  10. package/dist/commands/doctor.js +188 -0
  11. package/dist/commands/doctor.js.map +1 -0
  12. package/dist/commands/init.js +3 -0
  13. package/dist/commands/init.js.map +1 -1
  14. package/dist/commands/status.js +48 -2
  15. package/dist/commands/status.js.map +1 -1
  16. package/dist/contract-verification.d.ts +20 -0
  17. package/dist/contract-verification.js +49 -0
  18. package/dist/contract-verification.js.map +1 -0
  19. package/dist/doctor-api.d.ts +41 -0
  20. package/dist/doctor-api.js +79 -0
  21. package/dist/doctor-api.js.map +1 -0
  22. package/dist/feedback-context.js +1 -0
  23. package/dist/feedback-context.js.map +1 -1
  24. package/dist/host-snapshots.d.ts +7 -1
  25. package/dist/host-snapshots.js +15 -2
  26. package/dist/host-snapshots.js.map +1 -1
  27. package/dist/index.js +35 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/project.js +12 -0
  30. package/dist/project.js.map +1 -1
  31. package/dist/toolchain-snapshot.d.ts +36 -0
  32. package/dist/toolchain-snapshot.js +144 -0
  33. package/dist/toolchain-snapshot.js.map +1 -0
  34. package/dist/validate-findings.js +10 -1
  35. package/dist/validate-findings.js.map +1 -1
  36. package/package.json +2 -2
  37. package/templates/AGENTS.md.tmpl +1 -1
  38. package/templates/experience/package.json.tmpl +4 -4
  39. package/templates/package.json.tmpl +4 -4
  40. package/templates/src/integration.ts.tmpl +5 -56
  41. package/templates/src/widget.ts.tmpl +65 -0
@@ -1 +1 @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G,EAAE,IAAI,CAAC,GAAG,IACV,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE;YAC3D,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE;YACxD,CAAC,CAAC,EAAE,CAAC,GACJ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;YAC9D,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YAC3B,CAAC,CAAC,EAAE,CAAC,GACJ,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ;YACtC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;YAC7B,CAAC,CAAC,EAAE,CAAC,EACP,CAAC;IACL,CAAC;CACF,CAAC;AAEF,yEAAyE;AACzE,SAAS,gBAAgB,CAAC,IAAY,EAAE,KAAa;IACnD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import {\n type Contract,\n type ContractProblem,\n assessContractTransition,\n checkContractFreshness,\n diffContract,\n validateAgainstSchema,\n verifyContract,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { CliContext } from '../context';\nimport { type HarnessResolver, loadHarnessResolver } from '../dev-experience';\nimport { preconditionError, usageError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { loadDefinition } from '../load-definition';\nimport { loadProject } from '../project';\nimport type { ExperienceCommand } from './index-experience';\n\n/** The slice of `@ekanos/sdk/contract` this command uses. */\nexport interface ContractModule {\n analyzeContract(\n definition: unknown,\n options: {\n packageVersion: string;\n contractVersion: string;\n previous?: Contract | null;\n examples?: Readonly<Record<string, unknown>>;\n },\n ): {\n contract: Contract;\n diagnostics: Array<{\n rule: string;\n severity: 'error' | 'warn' | 'info';\n message: string;\n operation?: string;\n }>;\n };\n synthesizeExample(schema: unknown): unknown;\n}\n\nexport interface ContractArgs {\n dir: string;\n check: boolean;\n record: boolean;\n bump: boolean;\n env?: Record<string, string | undefined>;\n /**\n * `--record --op tool/x[,action/y]`: record REAL examples for these\n * operations from a run through the harness runner, instead of writing\n * placeholders.\n */\n ops?: string[];\n /** Which run mode produces the example (default `fixtures`). */\n from?: 'fixtures' | 'live';\n /** JSON input for the recorded run (single `--op` only); default: synthesized from the input schema. */\n input?: string;\n /** Test seam; the default loads the project's installed `@ekanos/harness/resolver`. */\n loadHarness?: (projectDir: string) => Promise<HarnessResolver>;\n /** Test seam; the default loads `@ekanos/sdk/contract` from the project. */\n loadModule?: (projectDir: string) => Promise<ContractModule>;\n}\n\nasync function loadProjectModule(projectDir: string): Promise<ContractModule> {\n try {\n const require = createRequire(path.join(projectDir, 'package.json'));\n return (await import(\n pathToFileURL(require.resolve('@ekanos/sdk/contract')).href\n )) as ContractModule;\n } catch {\n throw preconditionError(\n 'This project\\'s @ekanos/sdk does not provide \"@ekanos/sdk/contract\".',\n 'Upgrade @ekanos/sdk to a version that ships contract emission, then re-run.',\n );\n }\n}\n\nfunction readJson<T>(file: string): T | null {\n try {\n return JSON.parse(fs.readFileSync(file, 'utf8')) as T;\n } catch {\n return null;\n }\n}\n\nfunction readExamples(dir: string): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n if (!fs.existsSync(dir)) return out;\n for (const name of fs.readdirSync(dir)) {\n const match = /^(tool|action)-(.+)\\.json$/.exec(name);\n const value = match ? readJson<unknown>(path.join(dir, name)) : null;\n if (match && value !== null) out[`${match[1]}/${match[2]}`] = value;\n }\n return out;\n}\n\n/** The smallest contractVersion that satisfies the transition rules. */\nexport function nextContractVersion(\n previous: Contract,\n next: Contract,\n): string | null {\n const diff = diffContract(previous, next);\n if (diff.breaking.length === 0 && diff.compatible.length === 0) {\n return canonicalSurfaceEqual(previous, next)\n ? null\n : bump(previous.contractVersion, 'patch');\n }\n const zero = previous.compatLine.startsWith('0.');\n if (diff.breaking.length > 0)\n return bump(previous.contractVersion, zero ? 'minor' : 'major');\n return bump(previous.contractVersion, zero ? 'patch' : 'minor');\n}\n\nfunction canonicalSurfaceEqual(a: Contract, b: Contract): boolean {\n return checkContractFreshness(b, a).length === 0;\n}\n\nfunction bump(version: string, part: 'major' | 'minor' | 'patch'): string {\n const [major = 0, minor = 0, patch = 0] = version.split(/[.+-]/).map(Number);\n if (part === 'major') return `${major + 1}.0.0`;\n if (part === 'minor') return `${major}.${minor + 1}.0`;\n return `${major}.${minor}.${patch + 1}`;\n}\n\nfunction describe(problem: ContractProblem): string {\n return `${problem.operation ? `${problem.operation}: ` : ''}${problem.message}`;\n}\n\n/**\n * `ekanos contract`: derive `contract.json` from the integration definition.\n * See the command's usage text for the three modes.\n */\nexport async function runContract(\n ctx: CliContext,\n args: ContractArgs,\n): Promise<ExitCode> {\n if (args.check && (args.record || args.bump)) {\n throw usageError(\n '--check cannot be combined with --record or --bump.',\n 'Run them separately: \"ekanos contract --record\", then \"ekanos contract --check\".',\n );\n }\n const loaded = loadProject(args.dir);\n if (loaded.project.kind === 'experience') {\n throw preconditionError(\n 'An experience has no contract of its own.',\n 'Run \"ekanos contract\" in the integration project.',\n );\n }\n const configPath = loaded.configPath;\n const DEFAULT_CONTRACT_VERSION = '0.1.0';\n let declared = loaded.project.contract?.version;\n if (!declared) {\n if (args.check) {\n throw preconditionError(\n 'ekanos.json declares no contract version.',\n `Run \"ekanos contract\" once to add \"contract\": { \"version\": \"${DEFAULT_CONTRACT_VERSION}\" }, or add it yourself.`,\n );\n }\n const raw = readJson<Record<string, unknown>>(configPath);\n if (!raw) {\n throw preconditionError(\n `${configPath} is not readable.`,\n 'Fix ekanos.json, then re-run.',\n );\n }\n fs.writeFileSync(\n configPath,\n `${JSON.stringify({ ...raw, contract: { version: DEFAULT_CONTRACT_VERSION } }, null, 2)}\\n`,\n );\n declared = DEFAULT_CONTRACT_VERSION;\n ctx.log(\n `ekanos.json had no contract version: added \"contract\": { \"version\": \"${DEFAULT_CONTRACT_VERSION}\" }.`,\n );\n }\n const pkg = readJson<{ version?: string }>(\n path.join(loaded.projectDir, 'package.json'),\n );\n if (!pkg?.version) {\n throw preconditionError(\n 'package.json has no readable \"version\".',\n 'Add a semver version to package.json.',\n );\n }\n\n const sdk = await (args.loadModule ?? loadProjectModule)(loaded.projectDir);\n const def = await loadDefinition(loaded.primary.entryPath, loaded.projectDir);\n if (!def.ok) {\n throw validationError(\n `The integration definition did not load: ${def.message}`,\n 'Run \"ekanos validate\" first and fix what it reports.',\n );\n }\n\n const contractFile = path.join(loaded.projectDir, 'contract.json');\n const examplesDir = path.join(loaded.projectDir, 'contracts', 'examples');\n const previous = fs.existsSync(contractFile)\n ? verifyContract(readJson<unknown>(contractFile)).contract\n : null;\n\n let contractVersion = declared;\n const analyze = () =>\n sdk.analyzeContract(def.definition, {\n packageVersion: pkg.version as string,\n contractVersion,\n previous,\n examples: readExamples(examplesDir),\n });\n\n let result = analyze();\n\n const wanted = args.ops ?? [];\n if (wanted.length > 0 && !args.record) {\n throw usageError(\n '--op only applies with --record.',\n 'Run \"ekanos contract --record --op tool/<name>\".',\n );\n }\n if (args.input !== undefined && wanted.length !== 1) {\n throw usageError(\n '--input needs exactly one --op.',\n 'Record one operation at a time with its own --input.',\n );\n }\n\n if (args.record && wanted.length > 0) {\n let input: unknown;\n if (args.input !== undefined) {\n try {\n input = JSON.parse(args.input);\n } catch {\n throw usageError(\n '--input is not valid JSON.',\n 'Pass the operation input as a JSON object, e.g. --input \\'{\"limit\":5}\\'.',\n );\n }\n }\n const mode = args.from ?? 'fixtures';\n const harness = await (args.loadHarness ?? loadHarnessResolver)(\n loaded.projectDir,\n );\n if (typeof harness.runOperationOnce !== 'function') {\n throw preconditionError(\n 'The installed @ekanos/harness cannot run an operation for recording.',\n 'Upgrade @ekanos/harness and @ekanos/cli together, then re-run.',\n );\n }\n const wrote: string[] = [];\n for (const key of wanted) {\n const op = result.contract.operations.find((o) =>\n o.id.endsWith(`/${key}`),\n );\n if (!op) {\n throw validationError(\n `The contract has no operation \"${key}\".`,\n `Known operations: ${result.contract.operations.map((o) => `${o.kind}/${o.name}`).join(', ') || 'none'}.`,\n );\n }\n if (op.effect === 'write') {\n // A write is only ever recorded from a scenario fixture: reading a\n // file performs nothing. Running it live would perform it for real.\n const fixture = writeFixturePath(loaded.primary.slug, key);\n if (mode === 'live') {\n throw validationError(\n `${key} is a write; --from live would perform it for real, and a recording never does.`,\n `Add ${fixture} (a real-shaped response), then run \"ekanos contract --record --op ${key} --from fixtures\".`,\n );\n }\n if (!fs.existsSync(path.join(loaded.projectDir, fixture))) {\n throw validationError(\n `${key} is a write with no scenario fixture to record from.`,\n `Add ${fixture} holding a real-shaped response, then re-run \"ekanos contract --record --op ${key} --from fixtures\". Nothing is called.`,\n );\n }\n }\n if (op.opaque.output) {\n throw validationError(\n `${key} has an opaque output schema, so a recording cannot be validated.`,\n 'Declare an output schema first.',\n );\n }\n const run = await harness.runOperationOnce({\n projectRoot: loaded.projectDir,\n op: key,\n input: input ?? sdk.synthesizeExample(op.input),\n mode,\n env: args.env,\n deriveContract: () => result.contract,\n });\n if (!run.ok) {\n throw validationError(\n `Recording ${key} (${mode}) failed: ${run.reason}${run.detail ? ` - ${run.detail}` : ` - ${run.message}`}`,\n mode === 'live'\n ? 'Check the credentials (ekanos dev -> Connect) and the input, then re-run.'\n : `Fixtures mode reads fixtures/<slug>/${key.replace('/', '-')}.default.json (or an existing outputExample). Author that file, or record from a real run with \"--from live\".`,\n );\n }\n const problems = validateAgainstSchema(op.output, run.data);\n if (problems.length > 0) {\n throw validationError(\n `${key} returned data that does not satisfy its output schema: ${problems[0]}`,\n 'Fix the output schema or the handler; nothing was written.',\n );\n }\n const file = path.join(examplesDir, `${key.replace('/', '-')}.json`);\n fs.mkdirSync(examplesDir, { recursive: true });\n fs.writeFileSync(file, `${JSON.stringify(run.data, null, 2)}\\n`);\n wrote.push(path.relative(loaded.projectDir, file));\n }\n ctx.log(\n `Recorded ${wrote.length} example(s) from a ${mode} run: ${wrote.join(', ')}. Review them before committing${mode === 'live' ? ' (live data may contain real records)' : ''}.`,\n );\n result = analyze();\n } else if (args.record) {\n const wrote: string[] = [];\n const advice: string[] = [];\n for (const diag of result.diagnostics) {\n if (diag.rule !== 'contract/example-missing' || !diag.operation) continue;\n const op = result.contract.operations.find((o) =>\n o.id.endsWith(`/${diag.operation}`),\n );\n if (!op || op.opaque.output) continue;\n const file = path.join(\n examplesDir,\n `${diag.operation.replace('/', '-')}.json`,\n );\n fs.mkdirSync(examplesDir, { recursive: true });\n fs.writeFileSync(\n file,\n `${JSON.stringify(sdk.synthesizeExample(op.output), null, 2)}\\n`,\n );\n wrote.push(path.relative(loaded.projectDir, file));\n advice.push(\n op.effect === 'write'\n ? `${diag.operation}: add ${writeFixturePath(loaded.primary.slug, diag.operation)} with a real-shaped response, then \"ekanos contract --record --op ${diag.operation} --from fixtures\" (writes are never recorded live)`\n : `${diag.operation}: add ${writeFixturePath(loaded.primary.slug, diag.operation)}, or \"ekanos contract --record --op ${diag.operation} --from live\"`,\n );\n }\n if (wrote.length > 0) {\n ctx.log(\n `Wrote ${wrote.length} placeholder example(s) synthesized from the output schema (not recorded from a run): ${wrote.join(', ')}. Fixtures mode will serve these placeholders until you replace them:\\n ${advice.join('\\n ')}`,\n );\n result = analyze();\n }\n }\n\n if (args.bump && previous) {\n const wanted = nextContractVersion(previous, result.contract);\n if (wanted && wanted !== contractVersion) {\n contractVersion = wanted;\n const raw = readJson<Record<string, unknown>>(configPath) ?? {};\n raw.contract = {\n ...(raw.contract as object | undefined),\n version: wanted,\n };\n fs.writeFileSync(configPath, `${JSON.stringify(raw, null, 2)}\\n`);\n ctx.log(`contract.version ${declared} -> ${wanted} in ekanos.json`);\n result = analyze();\n }\n }\n\n for (const diag of result.diagnostics) {\n ctx.log(\n `${diag.severity === 'error' ? 'error' : diag.severity === 'warn' ? 'warn ' : 'info '} ${diag.operation ? `${diag.operation}: ` : ''}${diag.message} (${diag.rule})`,\n );\n }\n const errors = result.diagnostics.filter((d) => d.severity === 'error');\n if (errors.length > 0) {\n throw validationError(\n `${errors.length} contract error(s): ${errors\n .slice(0, 3)\n .map((e) => `${e.operation ?? ''} ${e.message}`.trim())\n .join('; ')}`,\n 'Fix them (declare outputs and examples, or run \"ekanos contract --record\"), then re-run.',\n );\n }\n\n const transition = previous\n ? assessContractTransition(previous, result.contract).problems\n : [];\n\n if (args.check) {\n const problems = checkContractFreshness(result.contract, previous, {\n strictPackageVersion: true,\n });\n if (problems.length > 0) {\n throw validationError(\n `contract.json is out of date: ${problems.map(describe).join(' | ')}`,\n 'Run \"ekanos contract\" (add --bump for the version) and commit contract.json.',\n );\n }\n return ctx.succeed(\n {\n ok: true,\n digest: result.contract.digest,\n operations: result.contract.operations.length,\n diagnostics: result.diagnostics,\n },\n `contract.json is current (${result.contract.operations.length} operations).`,\n );\n }\n\n if (transition.length > 0) {\n throw validationError(\n `This change is not allowed on the current contract version: ${transition.map(describe).join(' | ')}`,\n 'Run \"ekanos contract --bump\", or set contract.version in ekanos.json by hand (a breaking change needs a new compat line).',\n );\n }\n fs.writeFileSync(\n contractFile,\n `${JSON.stringify(result.contract, null, 2)}\\n`,\n );\n return ctx.succeed(\n {\n written: 'contract.json',\n digest: result.contract.digest,\n operations: result.contract.operations.length,\n diagnostics: result.diagnostics,\n },\n `Wrote contract.json (${result.contract.operations.length} operations, ${result.contract.compatLine} line, contract ${result.contract.contractVersion}).`,\n );\n}\n\nexport const contractCommand: ExperienceCommand = {\n name: 'contract',\n usage: [\n ' contract Derive ./contract.json from the integration definition;',\n ' --check fails on a stale file (CI, prepack), --record writes',\n ' missing output examples, --bump bumps the contract version',\n ],\n specs: {\n dir: {\n type: 'string',\n description: 'Project directory (default: the current one)',\n },\n check: {\n type: 'boolean',\n description: 'Derive in memory and fail if contract.json differs',\n },\n record: {\n type: 'boolean',\n description:\n 'Write placeholder examples (contracts/examples) for operations that have none; with --op, record real ones from a run',\n },\n op: {\n type: 'string',\n description:\n 'With --record: operation(s) to record from a real run, comma separated (tool/list_posts)',\n },\n from: {\n type: 'string',\n description:\n 'With --op: run mode to record from, fixtures (default) or live',\n },\n input: {\n type: 'string',\n description: 'With --op: JSON input for the recorded run',\n },\n bump: {\n type: 'boolean',\n description:\n 'Rewrite ekanos.json contract.version to match the surface change',\n },\n },\n run(ctx, args) {\n const from = args.flags.from;\n if (from !== undefined && from !== 'live' && from !== 'fixtures') {\n throw usageError(\n `--from must be \"fixtures\" or \"live\", not \"${String(from)}\".`,\n 'Run \"ekanos contract --record --op tool/<name> --from live\".',\n );\n }\n\n return runContract(ctx, {\n dir: args.dir,\n check: args.flags.check === true,\n record: args.flags.record === true,\n bump: args.flags.bump === true,\n env: args.env,\n ...(typeof args.flags.op === 'string' && args.flags.op !== ''\n ? { ops: args.flags.op.split(',').map((o) => o.trim()) }\n : {}),\n ...(args.flags.from === 'live' || args.flags.from === 'fixtures'\n ? { from: args.flags.from }\n : {}),\n ...(typeof args.flags.input === 'string'\n ? { input: args.flags.input }\n : {}),\n });\n },\n};\n\n/** Where a scenario fixture for an operation lives, project-relative. */\nfunction writeFixturePath(slug: string, opKey: string): string {\n return path.join('fixtures', slug, `${opKey.replace('/', '-')}.default.json`);\n}\n"]}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/commands/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EACxB,sBAAsB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C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,EAC9B,GAAG,EAAE,IAAI,CAAC,GAAG,IACV,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE;YAC3D,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE;YACxD,CAAC,CAAC,EAAE,CAAC,GACJ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;YAC9D,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YAC3B,CAAC,CAAC,EAAE,CAAC,GACJ,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ;YACtC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;YAC7B,CAAC,CAAC,EAAE,CAAC,EACP,CAAC;IACL,CAAC;CACF,CAAC;AAEF,yEAAyE;AACzE,SAAS,gBAAgB,CAAC,IAAY,EAAE,KAAa;IACnD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import {\n type Contract,\n assessContractTransition,\n checkContractFreshness,\n diffContract,\n validateAgainstSchema,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { CliContext } from '../context';\nimport {\n CONTRACT_FIX_HINT,\n describeContractProblem,\n readCommittedContract,\n} from '../contract-verification';\nimport { type HarnessResolver, loadHarnessResolver } from '../dev-experience';\nimport { preconditionError, usageError, validationError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { readProjectKind } from '../experience/project';\nimport { loadDefinition } from '../load-definition';\nimport { loadProject } from '../project';\nimport type { ExperienceCommand } from './index-experience';\n\n/** The slice of `@ekanos/sdk/contract` this command uses. */\nexport interface ContractModule {\n analyzeContract(\n definition: unknown,\n options: {\n packageVersion: string;\n contractVersion: string;\n previous?: Contract | null;\n examples?: Readonly<Record<string, unknown>>;\n },\n ): {\n contract: Contract;\n diagnostics: Array<{\n rule: string;\n severity: 'error' | 'warn' | 'info';\n message: string;\n operation?: string;\n }>;\n };\n synthesizeExample(schema: unknown): unknown;\n}\n\nexport interface ContractArgs {\n dir: string;\n check: boolean;\n record: boolean;\n bump: boolean;\n env?: Record<string, string | undefined>;\n /**\n * `--record --op tool/x[,action/y]`: record REAL examples for these\n * operations from a run through the harness runner, instead of writing\n * placeholders.\n */\n ops?: string[];\n /** Which run mode produces the example (default `fixtures`). */\n from?: 'fixtures' | 'live';\n /** JSON input for the recorded run (single `--op` only); default: synthesized from the input schema. */\n input?: string;\n /** Test seam; the default loads the project's installed `@ekanos/harness/resolver`. */\n loadHarness?: (projectDir: string) => Promise<HarnessResolver>;\n /** Test seam; the default loads `@ekanos/sdk/contract` from the project. */\n loadModule?: (projectDir: string) => Promise<ContractModule>;\n}\n\nasync function loadProjectModule(projectDir: string): Promise<ContractModule> {\n try {\n const require = createRequire(path.join(projectDir, 'package.json'));\n return (await import(\n pathToFileURL(require.resolve('@ekanos/sdk/contract')).href\n )) as ContractModule;\n } catch {\n throw preconditionError(\n 'This project\\'s @ekanos/sdk does not provide \"@ekanos/sdk/contract\".',\n 'Upgrade @ekanos/sdk to a version that ships contract emission, then re-run.',\n );\n }\n}\n\nfunction readJson<T>(file: string): T | null {\n try {\n return JSON.parse(fs.readFileSync(file, 'utf8')) as T;\n } catch {\n return null;\n }\n}\n\nfunction readExamples(dir: string): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n if (!fs.existsSync(dir)) return out;\n for (const name of fs.readdirSync(dir)) {\n const match = /^(tool|action)-(.+)\\.json$/.exec(name);\n const value = match ? readJson<unknown>(path.join(dir, name)) : null;\n if (match && value !== null) out[`${match[1]}/${match[2]}`] = value;\n }\n return out;\n}\n\n/** The smallest contractVersion that satisfies the transition rules. */\nexport function nextContractVersion(\n previous: Contract,\n next: Contract,\n): string | null {\n const diff = diffContract(previous, next);\n if (diff.breaking.length === 0 && diff.compatible.length === 0) {\n return canonicalSurfaceEqual(previous, next)\n ? null\n : bump(previous.contractVersion, 'patch');\n }\n const zero = previous.compatLine.startsWith('0.');\n if (diff.breaking.length > 0)\n return bump(previous.contractVersion, zero ? 'minor' : 'major');\n return bump(previous.contractVersion, zero ? 'patch' : 'minor');\n}\n\nfunction canonicalSurfaceEqual(a: Contract, b: Contract): boolean {\n return checkContractFreshness(b, a).length === 0;\n}\n\nfunction bump(version: string, part: 'major' | 'minor' | 'patch'): string {\n const [major = 0, minor = 0, patch = 0] = version.split(/[.+-]/).map(Number);\n if (part === 'major') return `${major + 1}.0.0`;\n if (part === 'minor') return `${major}.${minor + 1}.0`;\n return `${major}.${minor}.${patch + 1}`;\n}\n\n/**\n * `ekanos contract`: derive `contract.json` from the integration definition.\n * See the command's usage text for the three modes.\n */\nexport async function runContract(\n ctx: CliContext,\n args: ContractArgs,\n): Promise<ExitCode> {\n if (args.check && (args.record || args.bump)) {\n throw usageError(\n '--check cannot be combined with --record or --bump.',\n 'Run them separately: \"ekanos contract --record\", then \"ekanos contract --check\".',\n );\n }\n if (readProjectKind(path.resolve(args.dir)) === 'experience') {\n throw preconditionError(\n 'An experience has no contract of its own.',\n 'Run \"ekanos contract\" in the integration project.',\n );\n }\n const loaded = loadProject(args.dir);\n const configPath = loaded.configPath;\n const DEFAULT_CONTRACT_VERSION = '0.1.0';\n let declared = loaded.project.contract?.version;\n if (!declared) {\n if (args.check) {\n throw preconditionError(\n 'ekanos.json declares no contract version.',\n `Run \"ekanos contract\" once to add \"contract\": { \"version\": \"${DEFAULT_CONTRACT_VERSION}\" }, or add it yourself.`,\n );\n }\n const raw = readJson<Record<string, unknown>>(configPath);\n if (!raw) {\n throw preconditionError(\n `${configPath} is not readable.`,\n 'Fix ekanos.json, then re-run.',\n );\n }\n fs.writeFileSync(\n configPath,\n `${JSON.stringify({ ...raw, contract: { version: DEFAULT_CONTRACT_VERSION } }, null, 2)}\\n`,\n );\n declared = DEFAULT_CONTRACT_VERSION;\n ctx.log(\n `ekanos.json had no contract version: added \"contract\": { \"version\": \"${DEFAULT_CONTRACT_VERSION}\" }.`,\n );\n }\n const pkg = readJson<{ version?: string }>(\n path.join(loaded.projectDir, 'package.json'),\n );\n if (!pkg?.version) {\n throw preconditionError(\n 'package.json has no readable \"version\".',\n 'Add a semver version to package.json.',\n );\n }\n\n const sdk = await (args.loadModule ?? loadProjectModule)(loaded.projectDir);\n const def = await loadDefinition(loaded.primary.entryPath, loaded.projectDir);\n if (!def.ok) {\n throw validationError(\n `The integration definition did not load: ${def.message}`,\n 'Run \"ekanos validate\" first and fix what it reports.',\n );\n }\n\n const contractFile = path.join(loaded.projectDir, 'contract.json');\n const examplesDir = path.join(loaded.projectDir, 'contracts', 'examples');\n const committed = readCommittedContract(loaded.projectDir);\n if (args.check && committed.problems.length > 0) {\n throw validationError(\n `contract.json is not valid: ${committed.problems.map(describeContractProblem).join(' | ')}`,\n CONTRACT_FIX_HINT,\n );\n }\n const previous = committed.contract;\n\n let contractVersion = declared;\n const analyze = () =>\n sdk.analyzeContract(def.definition, {\n packageVersion: pkg.version as string,\n contractVersion,\n previous,\n examples: readExamples(examplesDir),\n });\n\n let result = analyze();\n\n const wanted = args.ops ?? [];\n if (wanted.length > 0 && !args.record) {\n throw usageError(\n '--op only applies with --record.',\n 'Run \"ekanos contract --record --op tool/<name>\".',\n );\n }\n if (args.input !== undefined && wanted.length !== 1) {\n throw usageError(\n '--input needs exactly one --op.',\n 'Record one operation at a time with its own --input.',\n );\n }\n\n if (args.record && wanted.length > 0) {\n let input: unknown;\n if (args.input !== undefined) {\n try {\n input = JSON.parse(args.input);\n } catch {\n throw usageError(\n '--input is not valid JSON.',\n 'Pass the operation input as a JSON object, e.g. --input \\'{\"limit\":5}\\'.',\n );\n }\n }\n const mode = args.from ?? 'fixtures';\n const harness = await (args.loadHarness ?? loadHarnessResolver)(\n loaded.projectDir,\n );\n if (typeof harness.runOperationOnce !== 'function') {\n throw preconditionError(\n 'The installed @ekanos/harness cannot run an operation for recording.',\n 'Upgrade @ekanos/harness and @ekanos/cli together, then re-run.',\n );\n }\n const wrote: string[] = [];\n for (const key of wanted) {\n const op = result.contract.operations.find((o) =>\n o.id.endsWith(`/${key}`),\n );\n if (!op) {\n throw validationError(\n `The contract has no operation \"${key}\".`,\n `Known operations: ${result.contract.operations.map((o) => `${o.kind}/${o.name}`).join(', ') || 'none'}.`,\n );\n }\n if (op.effect === 'write') {\n // A write is only ever recorded from a scenario fixture: reading a\n // file performs nothing. Running it live would perform it for real.\n const fixture = writeFixturePath(loaded.primary.slug, key);\n if (mode === 'live') {\n throw validationError(\n `${key} is a write; --from live would perform it for real, and a recording never does.`,\n `Add ${fixture} (a real-shaped response), then run \"ekanos contract --record --op ${key} --from fixtures\".`,\n );\n }\n if (!fs.existsSync(path.join(loaded.projectDir, fixture))) {\n throw validationError(\n `${key} is a write with no scenario fixture to record from.`,\n `Add ${fixture} holding a real-shaped response, then re-run \"ekanos contract --record --op ${key} --from fixtures\". Nothing is called.`,\n );\n }\n }\n if (op.opaque.output) {\n throw validationError(\n `${key} has an opaque output schema, so a recording cannot be validated.`,\n 'Declare an output schema first.',\n );\n }\n const run = await harness.runOperationOnce({\n projectRoot: loaded.projectDir,\n op: key,\n input: input ?? sdk.synthesizeExample(op.input),\n mode,\n env: args.env,\n deriveContract: () => result.contract,\n });\n if (!run.ok) {\n throw validationError(\n `Recording ${key} (${mode}) failed: ${run.reason}${run.detail ? ` - ${run.detail}` : ` - ${run.message}`}`,\n mode === 'live'\n ? 'Check the credentials (ekanos dev -> Connect) and the input, then re-run.'\n : `Fixtures mode reads fixtures/<slug>/${key.replace('/', '-')}.default.json (or an existing outputExample). Author that file, or record from a real run with \"--from live\".`,\n );\n }\n const problems = validateAgainstSchema(op.output, run.data);\n if (problems.length > 0) {\n throw validationError(\n `${key} returned data that does not satisfy its output schema: ${problems[0]}`,\n 'Fix the output schema or the handler; nothing was written.',\n );\n }\n const file = path.join(examplesDir, `${key.replace('/', '-')}.json`);\n fs.mkdirSync(examplesDir, { recursive: true });\n fs.writeFileSync(file, `${JSON.stringify(run.data, null, 2)}\\n`);\n wrote.push(path.relative(loaded.projectDir, file));\n }\n ctx.log(\n `Recorded ${wrote.length} example(s) from a ${mode} run: ${wrote.join(', ')}. Review them before committing${mode === 'live' ? ' (live data may contain real records)' : ''}.`,\n );\n result = analyze();\n } else if (args.record) {\n const wrote: string[] = [];\n const advice: string[] = [];\n for (const diag of result.diagnostics) {\n if (diag.rule !== 'contract/example-missing' || !diag.operation) continue;\n const op = result.contract.operations.find((o) =>\n o.id.endsWith(`/${diag.operation}`),\n );\n if (!op || op.opaque.output) continue;\n const file = path.join(\n examplesDir,\n `${diag.operation.replace('/', '-')}.json`,\n );\n fs.mkdirSync(examplesDir, { recursive: true });\n fs.writeFileSync(\n file,\n `${JSON.stringify(sdk.synthesizeExample(op.output), null, 2)}\\n`,\n );\n wrote.push(path.relative(loaded.projectDir, file));\n advice.push(\n op.effect === 'write'\n ? `${diag.operation}: add ${writeFixturePath(loaded.primary.slug, diag.operation)} with a real-shaped response, then \"ekanos contract --record --op ${diag.operation} --from fixtures\" (writes are never recorded live)`\n : `${diag.operation}: add ${writeFixturePath(loaded.primary.slug, diag.operation)}, or \"ekanos contract --record --op ${diag.operation} --from live\"`,\n );\n }\n if (wrote.length > 0) {\n ctx.log(\n `Wrote ${wrote.length} placeholder example(s) synthesized from the output schema (not recorded from a run): ${wrote.join(', ')}. Fixtures mode will serve these placeholders until you replace them:\\n ${advice.join('\\n ')}`,\n );\n result = analyze();\n }\n }\n\n if (args.bump && previous) {\n const wanted = nextContractVersion(previous, result.contract);\n if (wanted && wanted !== contractVersion) {\n contractVersion = wanted;\n const raw = readJson<Record<string, unknown>>(configPath) ?? {};\n raw.contract = {\n ...(raw.contract as object | undefined),\n version: wanted,\n };\n fs.writeFileSync(configPath, `${JSON.stringify(raw, null, 2)}\\n`);\n ctx.log(`contract.version ${declared} -> ${wanted} in ekanos.json`);\n result = analyze();\n }\n }\n\n for (const diag of result.diagnostics) {\n ctx.log(\n `${diag.severity === 'error' ? 'error' : diag.severity === 'warn' ? 'warn ' : 'info '} ${diag.operation ? `${diag.operation}: ` : ''}${diag.message} (${diag.rule})`,\n );\n }\n const errors = result.diagnostics.filter((d) => d.severity === 'error');\n if (errors.length > 0) {\n throw validationError(\n `${errors.length} contract error(s): ${errors\n .slice(0, 3)\n .map((e) => `${e.operation ?? ''} ${e.message}`.trim())\n .join('; ')}`,\n 'Fix them (declare outputs and examples, or run \"ekanos contract --record\"), then re-run.',\n );\n }\n\n const transition = previous\n ? assessContractTransition(previous, result.contract).problems\n : [];\n\n if (args.check) {\n const problems = checkContractFreshness(result.contract, previous, {\n strictPackageVersion: true,\n });\n if (problems.length > 0) {\n throw validationError(\n `contract.json is out of date: ${problems.map(describeContractProblem).join(' | ')}`,\n 'Run \"ekanos contract\" (add --bump for the version) and commit contract.json.',\n );\n }\n return ctx.succeed(\n {\n ok: true,\n digest: result.contract.digest,\n operations: result.contract.operations.length,\n diagnostics: result.diagnostics,\n },\n `contract.json is current (${result.contract.operations.length} operations).`,\n );\n }\n\n if (transition.length > 0) {\n throw validationError(\n `This change is not allowed on the current contract version: ${transition.map(describeContractProblem).join(' | ')}`,\n 'Run \"ekanos contract --bump\", or set contract.version in ekanos.json by hand (a breaking change needs a new compat line).',\n );\n }\n fs.writeFileSync(\n contractFile,\n `${JSON.stringify(result.contract, null, 2)}\\n`,\n );\n return ctx.succeed(\n {\n written: 'contract.json',\n digest: result.contract.digest,\n operations: result.contract.operations.length,\n diagnostics: result.diagnostics,\n },\n `Wrote contract.json (${result.contract.operations.length} operations, ${result.contract.compatLine} line, contract ${result.contract.contractVersion}).`,\n );\n}\n\nexport const contractCommand: ExperienceCommand = {\n name: 'contract',\n usage: [\n ' contract Derive ./contract.json from the integration definition;',\n ' --check fails on a stale file (CI, prepack), --record writes',\n ' missing output examples, --bump bumps the contract version',\n ],\n specs: {\n dir: {\n type: 'string',\n description: 'Project directory (default: the current one)',\n },\n check: {\n type: 'boolean',\n description: 'Derive in memory and fail if contract.json differs',\n },\n record: {\n type: 'boolean',\n description:\n 'Write placeholder examples (contracts/examples) for operations that have none; with --op, record real ones from a run',\n },\n op: {\n type: 'string',\n description:\n 'With --record: operation(s) to record from a real run, comma separated (tool/list_posts)',\n },\n from: {\n type: 'string',\n description:\n 'With --op: run mode to record from, fixtures (default) or live',\n },\n input: {\n type: 'string',\n description: 'With --op: JSON input for the recorded run',\n },\n bump: {\n type: 'boolean',\n description:\n 'Rewrite ekanos.json contract.version to match the surface change',\n },\n },\n run(ctx, args) {\n const from = args.flags.from;\n if (from !== undefined && from !== 'live' && from !== 'fixtures') {\n throw usageError(\n `--from must be \"fixtures\" or \"live\", not \"${String(from)}\".`,\n 'Run \"ekanos contract --record --op tool/<name> --from live\".',\n );\n }\n\n return runContract(ctx, {\n dir: args.dir,\n check: args.flags.check === true,\n record: args.flags.record === true,\n bump: args.flags.bump === true,\n env: args.env,\n ...(typeof args.flags.op === 'string' && args.flags.op !== ''\n ? { ops: args.flags.op.split(',').map((o) => o.trim()) }\n : {}),\n ...(args.flags.from === 'live' || args.flags.from === 'fixtures'\n ? { from: args.flags.from }\n : {}),\n ...(typeof args.flags.input === 'string'\n ? { input: args.flags.input }\n : {}),\n });\n },\n};\n\n/** Where a scenario fixture for an operation lives, project-relative. */\nfunction writeFixturePath(slug: string, opKey: string): string {\n return path.join('fixtures', slug, `${opKey.replace('/', '-')}.default.json`);\n}\n"]}
@@ -265,6 +265,7 @@ export async function runDev(ctx, args) {
265
265
  : startHostSnapshotRefresher(Object.assign({ ctx, env: (_e = args.env) !== null && _e !== void 0 ? _e : process.env, projectDir: loaded.projectDir }, (repo
266
266
  ? {
267
267
  fallbackSource: sharedPackageSource(repo.packages.map((pkg) => pkg.dir)),
268
+ packageDirs: repo.packages.map((pkg) => pkg.dir),
268
269
  }
269
270
  : {})));
270
271
  const tail = createOutputTail();
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAEL,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,GACtB,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Ac,EAAE,CAAC;YACrC,OAAO,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;gBAC/D,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;eAAO,CAAC;QACP,GAAG,CAAC,GAAG,CACL,GAAG,CAAC,EAAE,CAAC,GAAG,CACR,iKAAiK,CAClK,CACF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { type SourceCatalog } from '@ekanos/integration-schema';\nimport {\n type RepoDiscovery,\n discoverRepo,\n isRepoRoot,\n} from '@ekanos/integration-schema/repo';\nimport { spawn } from 'node:child_process';\nimport * as path from 'node:path';\n\nimport {\n requireSession,\n resolveAuthEnvironment,\n refreshStoredSession,\n} from '../auth/session';\nimport { fetchSourceCatalog } from '../catalog-api';\nimport { assertHarnessCompatible } from '../compatibility';\nimport type { CliContext } from '../context';\nimport {\n type HarnessResolver,\n detectKind,\n loadHarnessResolver,\n readExperienceProject,\n writeSessionCatalog,\n} from '../dev-experience';\nimport { preconditionError, usageError } from '../errors';\nimport {\n BUILD_CACHE_DIR,\n HARNESS_DIR,\n HARNESS_PACKAGE,\n SHELL_REGISTRY_FILENAME,\n assertShellDirIsOurs,\n bootstrapHarnessConfig,\n ensureGitignoreEntry,\n missingDependencies,\n readInstalledHarness,\n scaffoldShell,\n} from '../harness-scaffold';\nimport {\n readSourceSelection,\n sharedPackageSource,\n startHostSnapshotRefresher,\n} from '../host-snapshots';\nimport {\n DUPLICATE_INSTANCE_HINT,\n describeDuplicates,\n scanLockfileInstances,\n} from '../lockfile-instances';\nimport {\n detectPackageManager,\n execArgs,\n formatCommand,\n installCommand,\n} from '../package-manager';\nimport {\n createOutputTail,\n findIgnoredBuilds,\n ignoredBuildsHint,\n} from '../pnpm-builds';\nimport { loadProject } from '../project';\nimport { resolveSourceTarget } from '../source-target';\nimport { displayPath } from '../ui';\nimport { announceUpdate, checkForUpdate } from '../update-notice';\nimport { findWorkspaceRoot } from '../workspace-root';\n\nexport interface DevArgs {\n /** Project directory (contains ekanos.json). Defaults to cwd. */\n dir: string;\n /** Port for the dev server. */\n port?: string;\n /**\n * Interface to bind. Defaults to loopback — see `resolveHost`. Anything\n * else is an explicit, warned-about decision to expose the harness.\n *\n * NOTE: unrelated to the Ekanos HOST the update notice checks against —\n * this is the local bind address for `next dev`, never an Ekanos origin.\n */\n host?: string;\n /** Rewrite every generated file even when its bytes already match. */\n force: boolean;\n /**\n * Explicit `--start` / `--no-start`. Undefined means \"decide from the\n * output mode\": a JSON caller is an agent or a pipe and must not be handed\n * a process that never exits.\n */\n start?: boolean;\n env?: Record<string, string | undefined>;\n /** Experience projects: an offline directory of contracts (`--contracts-dir`). */\n contractsDir?: string;\n /** Test seams. */\n loadResolver?: (projectDir: string) => Promise<HarnessResolver>;\n fetchCatalog?: () => Promise<SourceCatalog | null>;\n /**\n * Keep `.ekanos/catalog.json` and `.ekanos/publish-status.json` fresh while\n * the server runs. On by default; tests turn it off.\n */\n hostSnapshots?: boolean;\n}\n\nconst DEFAULT_PORT = 3100;\n\n/**\n * Loopback, NOT Next's default.\n *\n * `next dev` binds 0.0.0.0 unless told otherwise, so the harness would be\n * reachable by anyone on the same network — a coffee-shop Wi-Fi, a shared\n * office VLAN — while we printed \"http://localhost:3100\" and implied\n * otherwise. It renders a partner's integration with their fixtures and, in\n * live mode, whatever their vendor API returns; there is no auth in front of\n * any of it. Binding loopback by default costs a partner nothing and makes\n * exposure a thing they ask for.\n */\nconst DEFAULT_HOST = '127.0.0.1';\n\n/** Addresses that are only reachable from this machine. */\nconst LOOPBACK_HOSTS = new Set(['127.0.0.1', '::1', 'localhost']);\n\n/**\n * Set for the dev server when `--host` binds beyond loopback. The shell's\n * API routes (`@ekanos/harness/api`) refuse non-loopback `Host` headers\n * unless this is `1`: they hold the partner's local OAuth credentials and\n * run handlers on request, so exposing them has to be a decision — this one,\n * made after the warning below — rather than a side effect of the bind.\n */\nconst EXPOSED_ENV = 'EKANOS_HARNESS_EXPOSED';\n\n/** Where the harness generates, and reads, local dev credentials. */\nconst LOCAL_SECRETS_PATH = path.join('.ekanos', 'local-secrets.json');\n\n/**\n * `dev` — scaffold the local harness shell into the partner's project, then\n * run it with their own Next.\n *\n * The shape of this verb follows from one rule: we must be able to ship a\n * harness bugfix as an `@ekanos/harness` version bump that a partner picks up\n * with `pnpm up`, with zero edits to any file they own. So everything under\n * `.ekanos/` is generated, gitignored and rewritten freely, `harness.config.ts`\n * at the project root is written once and never touched again, and all actual\n * harness behaviour lives in the installed package.\n *\n * Two idempotency properties matter and are both tested: a second run produces\n * byte-identical files and rewrites nothing (so Next's watcher stays quiet),\n * and `.gitignore` never grows a duplicate line.\n */\nexport async function runDev(ctx: CliContext, args: DevArgs): Promise<number> {\n // At a repo root one harness serves every package; anywhere else the\n // project is a single integration or experience, exactly as before.\n const repo = isRepoRoot(path.resolve(args.dir))\n ? discoverRepo(path.resolve(args.dir))\n : null;\n const experience =\n repo === null && detectKind(path.resolve(args.dir)) === 'experience';\n const loaded: DevProject = repo\n ? repoProject(repo)\n : experience\n ? experienceProject(path.resolve(args.dir))\n : loadProject(args.dir);\n const port = parsePort(args.port);\n const host = parseHost(args.host);\n const exposed = !LOOPBACK_HOSTS.has(host);\n const pm = detectPackageManager(loaded.projectDir);\n\n const notice = await checkForUpdate({ env: args.env ?? process.env });\n announceUpdate(ctx, notice, { env: args.env ?? process.env });\n\n // Fail before writing anything: the shell declares no dependencies of its\n // own, so a missing one would otherwise surface as an opaque Next\n // resolution error minutes later.\n const missing = missingDependencies(loaded.projectDir);\n if (missing.length > 0) {\n throw preconditionError(\n `${missing.length} package${missing.length === 1 ? '' : 's'} the ` +\n `harness needs ${missing.length === 1 ? 'is' : 'are'} not installed ` +\n `in ${loaded.projectDir}: ${missing.join(', ')}.`,\n `Run \"${installCommand(pm, missing)}\" in ${loaded.projectDir}, then ` +\n 're-run \"ekanos dev\".',\n );\n }\n\n warnOnDuplicateInstances(ctx, loaded.projectDir);\n\n const harness = readInstalledHarness(loaded.projectDir);\n const harnessVersion = harness?.version;\n if (!harnessVersion) {\n throw preconditionError(\n `${HARNESS_PACKAGE} is installed but declares no version.`,\n `Reinstall it with \"${installCommand(pm, [HARNESS_PACKAGE])}\" in ` +\n `${loaded.projectDir}, then re-run \"ekanos dev\".`,\n );\n }\n\n // The templates ship with the CLI and the code they import ships with the\n // harness, so a partner can upgrade one without the other. Name that\n // mismatch here rather than letting it surface later as a module-resolution\n // error inside a shell we cheerfully certified as current.\n assertHarnessCompatible({\n harnessVersion,\n harnessManifest: harness?.manifest,\n installHint: (spec) => installCommand(pm, [spec]),\n });\n\n // Validate the shell target BEFORE writing anything at all. Bootstrapping\n // harness.config.ts first and only then discovering that .ekanos/harness is\n // a file or someone else's tree would leave the project half-scaffolded.\n assertShellDirIsOurs(path.join(loaded.projectDir, HARNESS_DIR), args.force);\n\n // An experience has no integration to register, so it gets no\n // project-root registry: the shell carries its own empty one.\n if (repo) {\n for (const problem of repo.problems) {\n ctx.warn(`${problem.where}: ${problem.message}`);\n }\n }\n\n // A repo's integration packages each keep their own harness.config.ts; the\n // repo shell's registry imports them.\n const repoConfigs = repo\n ? repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) =>\n bootstrapHarnessConfig(pkg.dir, loadProject(pkg.dir).integrations),\n )\n : [];\n const config = repo\n ? {\n bootstrapped: repoConfigs.some((result) => result.bootstrapped),\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : experience\n ? {\n bootstrapped: false,\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : bootstrapHarnessConfig(loaded.projectDir, loaded.integrations);\n // A package inside a workspace resolves `next` and the harness from the\n // workspace root's node_modules (pnpm symlinks them there), so Turbopack's\n // root has to be that root, not the package.\n const turbopackRoot = findWorkspaceRoot(loaded.projectDir);\n if (turbopackRoot !== loaded.projectDir) {\n ctx.log(\n ctx.ui.dim(\n `Workspace package: Turbopack uses the workspace root ${displayPath(turbopackRoot, process.cwd())}.`,\n ),\n );\n }\n const shell = scaffoldShell({\n projectDir: loaded.projectDir,\n turbopackRoot,\n slug: loaded.primary.slug,\n harnessVersion,\n force: args.force,\n sourceGlobs: loaded.project.sourceGlobs,\n ...(experience\n ? { experienceEntry: readExperienceProject(loaded.projectDir).entry }\n : {}),\n ...(repo\n ? {\n repo: {\n integrations: repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) => ({ name: pkg.name, dir: pkg.relDir })),\n experiences: repo.packages\n .filter((pkg) => pkg.kind === 'experience')\n .map((pkg) => ({\n name: pkg.name,\n dir: pkg.relDir,\n entry: readExperienceProject(pkg.dir).entry,\n })),\n },\n }\n : {}),\n });\n const gitignoreUpdated = ensureGitignoreEntry(loaded.projectDir);\n\n if (shell.stale) {\n ctx.log(\n `Regenerating ${HARNESS_DIR} — ${shell.staleReasons.join('; ')}. ` +\n `Nothing you own changed; ${config.configPath} is untouched.`,\n );\n }\n if (shell.buildCacheCleared) {\n ctx.log(\n ` removed ${HARNESS_DIR}/${BUILD_CACHE_DIR} (Next's cache from the previous shell)`,\n );\n }\n\n if (config.bootstrapped) {\n ctx.log(` created harness.config.ts (yours — edit it, we never will)`);\n }\n for (const file of shell.created) ctx.log(` created ${HARNESS_DIR}/${file}`);\n for (const file of shell.updated) ctx.log(` updated ${HARNESS_DIR}/${file}`);\n if (gitignoreUpdated) ctx.log(' updated .gitignore (.ekanos/)');\n ctx.log(\n ` live-mode OAuth: the harness generates ${LOCAL_SECRETS_PATH} on first ` +\n 'use — fill it in and follow \"Local OAuth\" on the Activation surface.',\n );\n\n let integrations: ExperienceStartup | null = null;\n if (repo) {\n // Each experience package resolves its own integrations through the repo\n // server; the session catalog is shared from the repo root.\n writeSessionCatalog(\n loaded.projectDir,\n await tryFetchCatalog(ctx, args, loaded.projectDir),\n );\n for (const pkg of repo.packages) {\n ctx.log(` ${pkg.kind} ${pkg.name} v${pkg.version} (${pkg.relDir})`);\n }\n } else if (experience) {\n integrations = await resolveExperienceIntegrations(\n ctx,\n args,\n loaded.projectDir,\n );\n }\n\n // `--hostname` is passed ALWAYS, never left to Next's default, so the URL\n // we print is the URL that is actually served.\n const serverArgs = ['dev', '--port', String(port), '--hostname', host];\n const serverEnv: Record<string, string> = exposed\n ? { [EXPOSED_ENV]: '1' }\n : {};\n const command =\n (exposed ? `${EXPOSED_ENV}=1 ` : '') +\n formatCommand(pm.bin, execArgs(pm, 'next', serverArgs));\n const url = `http://${displayHost(host)}:${port}`;\n\n const scaffold = {\n kind: repo ? 'repo' : experience ? 'experience' : 'integration',\n ...(repo\n ? {\n packages: repo.packages.map((pkg) => ({\n name: pkg.name,\n kind: pkg.kind,\n dir: pkg.relDir,\n })),\n }\n : {}),\n ...(integrations\n ? {\n overrides: integrations.overrides,\n publishBlocked: integrations.overrides.length > 0,\n }\n : {}),\n slug: loaded.primary.slug,\n // An experience lists the integrations it depends on (provenance lines);\n // an integration project lists its own slugs.\n integrations: integrations\n ? integrations.lines\n : repo\n ? repo.packages\n .filter((p) => p.kind === 'integration')\n .map((p) => p.name)\n : loaded.integrations.map((i) => i.slug),\n projectDir: loaded.projectDir,\n turbopackRoot,\n harnessDir: shell.harnessDir,\n harnessVersion,\n previousVersion: shell.previousVersion,\n previousMarker: shell.previousMarker,\n stale: shell.stale,\n staleReasons: shell.staleReasons,\n buildCacheCleared: shell.buildCacheCleared,\n sourceGlobs: loaded.project.sourceGlobs ?? [],\n created: shell.created,\n updated: shell.updated,\n unchanged: shell.unchanged,\n configBootstrapped: config.bootstrapped,\n configPath: config.configPath,\n gitignoreUpdated,\n ...(notice ? { toolchain: notice } : {}),\n };\n\n if (exposed) {\n ctx.warn(\n `WARNING: --host ${host} exposes the harness beyond this machine. It ` +\n 'has no authentication, and it renders your fixtures and — in live ' +\n 'mode — real responses from your vendor API. Its API routes hold the ' +\n `client secret from ${LOCAL_SECRETS_PATH}, the tokens onTokens stored, ` +\n 'and run your handlers on request; they refuse non-loopback callers ' +\n `unless ${EXPOSED_ENV}=1, which this sets. Anyone who can reach ` +\n `${url} can read and run all of it. Omit --host to bind ${DEFAULT_HOST}.`,\n );\n }\n\n // A JSON caller is an agent or a pipe. Handing it a dev server that never\n // exits would hang its tool call forever and it would never see the\n // envelope, so JSON mode scaffolds and reports the command instead of\n // running it. `--start` overrides; `--no-start` opts out in a terminal.\n const shouldStart = args.start ?? !ctx.jsonMode;\n if (!shouldStart) {\n const reason = args.start === false ? 'no-start' : 'non-interactive';\n const note =\n reason === 'non-interactive'\n ? `Scaffolded only: the server was NOT started because this run is non-interactive (JSON output, a pipe, or an agent). Pass --start to run it, or run: ${command}`\n : `Scaffolded only (--no-start). Run: ${command}`;\n ctx.log(note);\n return ctx.succeed(\n {\n ...scaffold,\n server: {\n started: false,\n reason,\n note,\n command,\n url,\n port,\n host,\n exposed,\n },\n },\n ctx.ui.result({\n title: 'Harness ready',\n rows: [\n ['Directory', displayPath(shell.harnessDir, process.cwd())],\n ['URL', url],\n ['Started', 'no (scaffold only)'],\n ['Start', command],\n ],\n }),\n );\n }\n\n ctx.log(ctx.ui.dim(`Starting the harness on ${url} (${command})…`));\n // The catalog and publish status the harness shows, read with this CLI's\n // login and refreshed while the server runs; the harness never holds a token.\n const stopHostSnapshots =\n args.hostSnapshots === false\n ? () => undefined\n : startHostSnapshotRefresher({\n ctx,\n env: args.env ?? process.env,\n projectDir: loaded.projectDir,\n // A repo root names no Source of its own; its packages do, so a\n // repo whose packages all publish to one Source reads that one.\n ...(repo\n ? {\n fallbackSource: sharedPackageSource(\n repo.packages.map((pkg) => pkg.dir),\n ),\n }\n : {}),\n });\n const tail = createOutputTail();\n let exitCode: number;\n try {\n exitCode = await spawnServer({\n ctx,\n tail,\n bin: pm.bin,\n argv: execArgs(pm, 'next', serverArgs),\n cwd: shell.harnessDir,\n env: serverEnv,\n });\n } finally {\n stopHostSnapshots();\n }\n\n const data = {\n ...scaffold,\n server: { started: true, command, url, port, host, exposed, exitCode },\n };\n\n if (exitCode === 0) {\n return ctx.succeed(\n data,\n ctx.ui.result({ title: 'Harness stopped', rows: [['URL', url]] }),\n );\n }\n\n const ignoredBuilds = findIgnoredBuilds(tail.text());\n\n return ctx.failWith({\n code: 'dev_server_failed',\n message: `\"${command}\" exited with code ${exitCode}.`,\n hint:\n ignoredBuilds.length > 0\n ? ignoredBuildsHint(ignoredBuilds)\n : 'Read the Next output on stderr. If it cannot resolve @ekanos/harness ' +\n `or next, reinstall dependencies in ${loaded.projectDir}; if a route ` +\n `fails to compile, delete ${shell.harnessDir} and re-run \"ekanos dev\".`,\n // Transparent passthrough of Next's own exit code.\n exitCode,\n data,\n });\n}\n\n/**\n * Warn — never fail — when the lockfile resolves `@ekanos/sdk` or `@ekanos/ui`\n * more than once: the harness would mount its providers from one copy and the\n * project's hooks would read the other's, which throws at render time with a\n * message that points nowhere near the lockfile.\n */\nfunction warnOnDuplicateInstances(ctx: CliContext, projectDir: string): void {\n const scan = scanLockfileInstances(projectDir);\n if (scan.status === 'unreadable') {\n ctx.log(\n ctx.ui.dim(\n `Could not check ${scan.lockfile} for duplicate @ekanos/sdk copies: ${scan.reason}`,\n ),\n );\n return;\n }\n if (scan.status !== 'ok') return;\n const lines = describeDuplicates(scan.duplicates);\n if (lines.length === 0) return;\n\n ctx.warn(\n `WARNING: ${lines.join('; ')} (${scan.lockfile}). The harness and your ` +\n 'code may load different copies, and a provider from one is invisible ' +\n `to hooks from the other. ${DUPLICATE_INSTANCE_HINT}`,\n );\n}\n\nfunction spawnServer(params: {\n ctx: CliContext;\n tail: ReturnType<typeof createOutputTail>;\n bin: string;\n argv: string[];\n cwd: string;\n env: Record<string, string>;\n}): Promise<number> {\n return new Promise<number>((resolve, reject) => {\n const child = spawn(params.bin, params.argv, {\n cwd: params.cwd,\n env: { ...process.env, ...params.env },\n // stdin inherited so Next's own key handling works; stdout/stderr piped\n // so we can route them and keep OUR stdout reserved for the envelope.\n stdio: ['inherit', 'pipe', 'pipe'],\n });\n\n child.stdout?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n (params.ctx.jsonMode ? process.stderr : process.stdout).write(chunk);\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n process.stderr.write(chunk);\n });\n\n child.on('error', (error) => reject(error));\n child.on('close', (code) => resolve(code ?? 1));\n });\n}\n\n/**\n * The hostname to show a human. `127.0.0.1` is spelled `localhost` because\n * that is what people type; a wildcard bind is spelled `localhost` too, but\n * only after `exposed` has already been warned about — printing `0.0.0.0` as\n * a URL is not useful.\n */\nfunction displayHost(host: string): string {\n if (host === '127.0.0.1' || host === '0.0.0.0' || host === '::') {\n return 'localhost';\n }\n if (host === '::1') return '[::1]';\n return host;\n}\n\nfunction parseHost(raw: string | undefined): string {\n if (raw === undefined) return DEFAULT_HOST;\n\n const host = raw.trim();\n if (host.length === 0) {\n throw usageError(\n 'Invalid --host \"\".',\n `Pass an interface to bind, e.g. \"--host 0.0.0.0\" to expose the ` +\n `harness on your network, or omit it to bind ${DEFAULT_HOST}.`,\n );\n }\n return host;\n}\n\nfunction parsePort(raw: string | undefined): number {\n if (raw === undefined) return DEFAULT_PORT;\n\n const port = Number(raw);\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw usageError(\n `Invalid --port \"${raw}\".`,\n 'Pass an integer between 1 and 65535, e.g. \"--port 3100\".',\n );\n }\n return port;\n}\n\ninterface DevProject {\n projectDir: string;\n integrations: Array<{ slug: string; entry: string }>;\n primary: { slug: string };\n project: { sourceGlobs?: string[] | undefined };\n}\n\nfunction experienceProject(projectDir: string): DevProject {\n const { slug } = readExperienceProject(projectDir);\n return {\n projectDir,\n // An experience registers no integration of its own with the harness; its\n // integrations come from ekanos.json through /__ekanos/api.\n integrations: [],\n primary: { slug },\n project: {},\n };\n}\n\nfunction repoProject(repo: RepoDiscovery): DevProject {\n return {\n projectDir: repo.root,\n integrations: [],\n primary: { slug: path.basename(repo.root) },\n // The shell's stylesheet scans integrations/ already; experiences/ is the\n // other half of a repo.\n project: { sourceGlobs: ['experiences/**/*.{ts,tsx}'] },\n };\n}\n\ninterface ExperienceStartup {\n lines: string[];\n overrides: Array<{ integration: string; path: string; via: 'file' | 'env' }>;\n}\n\n/**\n * Resolve every integration with the harness the project installed, print where each\n * came from, and refuse to start when an integration cannot be served (a pin the\n * resolver cannot satisfy is a startup failure, not a blank widget later).\n */\nasync function resolveExperienceIntegrations(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<ExperienceStartup> {\n const env = args.env ?? process.env;\n const resolver = await (args.loadResolver ?? loadHarnessResolver)(projectDir);\n\n const catalog = await (\n args.fetchCatalog ?? (() => tryFetchCatalog(ctx, args, projectDir))\n )();\n writeSessionCatalog(projectDir, catalog);\n\n const contractsDir = args.contractsDir ?? env.EKANOS_CONTRACTS_DIR;\n const resolution = await resolver.resolveIntegrations({\n projectRoot: projectDir,\n env,\n ...(contractsDir ? { contractsDir: path.resolve(contractsDir) } : {}),\n catalog,\n });\n const lines = resolver.formatProvenanceLines(resolution as never);\n for (const line of lines) ctx.log(line);\n for (const notice of resolution.notices) ctx.warn(notice);\n\n if (resolution.errors.length > 0) {\n throw preconditionError(\n `${resolution.errors.length} integration${resolution.errors.length === 1 ? '' : 's'} could not be resolved: ${resolution.errors\n .map((e) => e.message)\n .join(' | ')}`,\n 'Fix the pin in ekanos.json (or run \"ekanos sync\"), or remove the bad override in ekanos.local.json, then re-run \"ekanos dev\".',\n );\n }\n return { lines, overrides: resolution.overrides };\n}\n\n/** The dev's Source catalog when a session exists; null (offline) otherwise. Never throws. */\nasync function tryFetchCatalog(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<SourceCatalog | null> {\n try {\n const env = resolveAuthEnvironment(\n ctx,\n undefined,\n args.env ?? process.env,\n {\n projectDir,\n },\n );\n let session = requireSession(env);\n // The harness's Source switcher, when it picked one; the host refuses a\n // Source the developer no longer holds a seat on.\n const resolved = await resolveSourceTarget(env, session, {\n source: readSourceSelection(projectDir) ?? undefined,\n dir: projectDir,\n });\n session = resolved.session;\n let result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n if (result.status === 'unauthorized') {\n session = await refreshStoredSession(env, session);\n result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n }\n return result.status === 'ok' ? result.catalog : null;\n } catch {\n ctx.log(\n ctx.ui.dim(\n 'No CLI session: integrations resolve offline (registry integrations fixtures-only, overrides unverified). Run \"ekanos login\" to enable develop-aware live mode.',\n ),\n );\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAEL,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,WAAW,EACX,eAAe,EACf,uBAA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,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE;YACvD,MAAM,QAAE,mBAAmB,CAAC,UAAU,CAAC,mCAAI,SAAS;YACpD,GAAG,EAAE,UAAU;SAChB,CAAC,CAAC;QACH,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC3B,IAAI,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;YACnE,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;YACrC,OAAO,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;gBAC/D,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;eAAO,CAAC;QACP,GAAG,CAAC,GAAG,CACL,GAAG,CAAC,EAAE,CAAC,GAAG,CACR,iKAAiK,CAClK,CACF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { type SourceCatalog } from '@ekanos/integration-schema';\nimport {\n type RepoDiscovery,\n discoverRepo,\n isRepoRoot,\n} from '@ekanos/integration-schema/repo';\nimport { spawn } from 'node:child_process';\nimport * as path from 'node:path';\n\nimport {\n requireSession,\n resolveAuthEnvironment,\n refreshStoredSession,\n} from '../auth/session';\nimport { fetchSourceCatalog } from '../catalog-api';\nimport { assertHarnessCompatible } from '../compatibility';\nimport type { CliContext } from '../context';\nimport {\n type HarnessResolver,\n detectKind,\n loadHarnessResolver,\n readExperienceProject,\n writeSessionCatalog,\n} from '../dev-experience';\nimport { preconditionError, usageError } from '../errors';\nimport {\n BUILD_CACHE_DIR,\n HARNESS_DIR,\n HARNESS_PACKAGE,\n SHELL_REGISTRY_FILENAME,\n assertShellDirIsOurs,\n bootstrapHarnessConfig,\n ensureGitignoreEntry,\n missingDependencies,\n readInstalledHarness,\n scaffoldShell,\n} from '../harness-scaffold';\nimport {\n readSourceSelection,\n sharedPackageSource,\n startHostSnapshotRefresher,\n} from '../host-snapshots';\nimport {\n DUPLICATE_INSTANCE_HINT,\n describeDuplicates,\n scanLockfileInstances,\n} from '../lockfile-instances';\nimport {\n detectPackageManager,\n execArgs,\n formatCommand,\n installCommand,\n} from '../package-manager';\nimport {\n createOutputTail,\n findIgnoredBuilds,\n ignoredBuildsHint,\n} from '../pnpm-builds';\nimport { loadProject } from '../project';\nimport { resolveSourceTarget } from '../source-target';\nimport { displayPath } from '../ui';\nimport { announceUpdate, checkForUpdate } from '../update-notice';\nimport { findWorkspaceRoot } from '../workspace-root';\n\nexport interface DevArgs {\n /** Project directory (contains ekanos.json). Defaults to cwd. */\n dir: string;\n /** Port for the dev server. */\n port?: string;\n /**\n * Interface to bind. Defaults to loopback — see `resolveHost`. Anything\n * else is an explicit, warned-about decision to expose the harness.\n *\n * NOTE: unrelated to the Ekanos HOST the update notice checks against —\n * this is the local bind address for `next dev`, never an Ekanos origin.\n */\n host?: string;\n /** Rewrite every generated file even when its bytes already match. */\n force: boolean;\n /**\n * Explicit `--start` / `--no-start`. Undefined means \"decide from the\n * output mode\": a JSON caller is an agent or a pipe and must not be handed\n * a process that never exits.\n */\n start?: boolean;\n env?: Record<string, string | undefined>;\n /** Experience projects: an offline directory of contracts (`--contracts-dir`). */\n contractsDir?: string;\n /** Test seams. */\n loadResolver?: (projectDir: string) => Promise<HarnessResolver>;\n fetchCatalog?: () => Promise<SourceCatalog | null>;\n /**\n * Keep `.ekanos/catalog.json` and `.ekanos/publish-status.json` fresh while\n * the server runs. On by default; tests turn it off.\n */\n hostSnapshots?: boolean;\n}\n\nconst DEFAULT_PORT = 3100;\n\n/**\n * Loopback, NOT Next's default.\n *\n * `next dev` binds 0.0.0.0 unless told otherwise, so the harness would be\n * reachable by anyone on the same network — a coffee-shop Wi-Fi, a shared\n * office VLAN — while we printed \"http://localhost:3100\" and implied\n * otherwise. It renders a partner's integration with their fixtures and, in\n * live mode, whatever their vendor API returns; there is no auth in front of\n * any of it. Binding loopback by default costs a partner nothing and makes\n * exposure a thing they ask for.\n */\nconst DEFAULT_HOST = '127.0.0.1';\n\n/** Addresses that are only reachable from this machine. */\nconst LOOPBACK_HOSTS = new Set(['127.0.0.1', '::1', 'localhost']);\n\n/**\n * Set for the dev server when `--host` binds beyond loopback. The shell's\n * API routes (`@ekanos/harness/api`) refuse non-loopback `Host` headers\n * unless this is `1`: they hold the partner's local OAuth credentials and\n * run handlers on request, so exposing them has to be a decision — this one,\n * made after the warning below — rather than a side effect of the bind.\n */\nconst EXPOSED_ENV = 'EKANOS_HARNESS_EXPOSED';\n\n/** Where the harness generates, and reads, local dev credentials. */\nconst LOCAL_SECRETS_PATH = path.join('.ekanos', 'local-secrets.json');\n\n/**\n * `dev` — scaffold the local harness shell into the partner's project, then\n * run it with their own Next.\n *\n * The shape of this verb follows from one rule: we must be able to ship a\n * harness bugfix as an `@ekanos/harness` version bump that a partner picks up\n * with `pnpm up`, with zero edits to any file they own. So everything under\n * `.ekanos/` is generated, gitignored and rewritten freely, `harness.config.ts`\n * at the project root is written once and never touched again, and all actual\n * harness behaviour lives in the installed package.\n *\n * Two idempotency properties matter and are both tested: a second run produces\n * byte-identical files and rewrites nothing (so Next's watcher stays quiet),\n * and `.gitignore` never grows a duplicate line.\n */\nexport async function runDev(ctx: CliContext, args: DevArgs): Promise<number> {\n // At a repo root one harness serves every package; anywhere else the\n // project is a single integration or experience, exactly as before.\n const repo = isRepoRoot(path.resolve(args.dir))\n ? discoverRepo(path.resolve(args.dir))\n : null;\n const experience =\n repo === null && detectKind(path.resolve(args.dir)) === 'experience';\n const loaded: DevProject = repo\n ? repoProject(repo)\n : experience\n ? experienceProject(path.resolve(args.dir))\n : loadProject(args.dir);\n const port = parsePort(args.port);\n const host = parseHost(args.host);\n const exposed = !LOOPBACK_HOSTS.has(host);\n const pm = detectPackageManager(loaded.projectDir);\n\n const notice = await checkForUpdate({ env: args.env ?? process.env });\n announceUpdate(ctx, notice, { env: args.env ?? process.env });\n\n // Fail before writing anything: the shell declares no dependencies of its\n // own, so a missing one would otherwise surface as an opaque Next\n // resolution error minutes later.\n const missing = missingDependencies(loaded.projectDir);\n if (missing.length > 0) {\n throw preconditionError(\n `${missing.length} package${missing.length === 1 ? '' : 's'} the ` +\n `harness needs ${missing.length === 1 ? 'is' : 'are'} not installed ` +\n `in ${loaded.projectDir}: ${missing.join(', ')}.`,\n `Run \"${installCommand(pm, missing)}\" in ${loaded.projectDir}, then ` +\n 're-run \"ekanos dev\".',\n );\n }\n\n warnOnDuplicateInstances(ctx, loaded.projectDir);\n\n const harness = readInstalledHarness(loaded.projectDir);\n const harnessVersion = harness?.version;\n if (!harnessVersion) {\n throw preconditionError(\n `${HARNESS_PACKAGE} is installed but declares no version.`,\n `Reinstall it with \"${installCommand(pm, [HARNESS_PACKAGE])}\" in ` +\n `${loaded.projectDir}, then re-run \"ekanos dev\".`,\n );\n }\n\n // The templates ship with the CLI and the code they import ships with the\n // harness, so a partner can upgrade one without the other. Name that\n // mismatch here rather than letting it surface later as a module-resolution\n // error inside a shell we cheerfully certified as current.\n assertHarnessCompatible({\n harnessVersion,\n harnessManifest: harness?.manifest,\n installHint: (spec) => installCommand(pm, [spec]),\n });\n\n // Validate the shell target BEFORE writing anything at all. Bootstrapping\n // harness.config.ts first and only then discovering that .ekanos/harness is\n // a file or someone else's tree would leave the project half-scaffolded.\n assertShellDirIsOurs(path.join(loaded.projectDir, HARNESS_DIR), args.force);\n\n // An experience has no integration to register, so it gets no\n // project-root registry: the shell carries its own empty one.\n if (repo) {\n for (const problem of repo.problems) {\n ctx.warn(`${problem.where}: ${problem.message}`);\n }\n }\n\n // A repo's integration packages each keep their own harness.config.ts; the\n // repo shell's registry imports them.\n const repoConfigs = repo\n ? repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) =>\n bootstrapHarnessConfig(pkg.dir, loadProject(pkg.dir).integrations),\n )\n : [];\n const config = repo\n ? {\n bootstrapped: repoConfigs.some((result) => result.bootstrapped),\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : experience\n ? {\n bootstrapped: false,\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : bootstrapHarnessConfig(loaded.projectDir, loaded.integrations);\n // A package inside a workspace resolves `next` and the harness from the\n // workspace root's node_modules (pnpm symlinks them there), so Turbopack's\n // root has to be that root, not the package.\n const turbopackRoot = findWorkspaceRoot(loaded.projectDir);\n if (turbopackRoot !== loaded.projectDir) {\n ctx.log(\n ctx.ui.dim(\n `Workspace package: Turbopack uses the workspace root ${displayPath(turbopackRoot, process.cwd())}.`,\n ),\n );\n }\n const shell = scaffoldShell({\n projectDir: loaded.projectDir,\n turbopackRoot,\n slug: loaded.primary.slug,\n harnessVersion,\n force: args.force,\n sourceGlobs: loaded.project.sourceGlobs,\n ...(experience\n ? { experienceEntry: readExperienceProject(loaded.projectDir).entry }\n : {}),\n ...(repo\n ? {\n repo: {\n integrations: repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) => ({ name: pkg.name, dir: pkg.relDir })),\n experiences: repo.packages\n .filter((pkg) => pkg.kind === 'experience')\n .map((pkg) => ({\n name: pkg.name,\n dir: pkg.relDir,\n entry: readExperienceProject(pkg.dir).entry,\n })),\n },\n }\n : {}),\n });\n const gitignoreUpdated = ensureGitignoreEntry(loaded.projectDir);\n\n if (shell.stale) {\n ctx.log(\n `Regenerating ${HARNESS_DIR} — ${shell.staleReasons.join('; ')}. ` +\n `Nothing you own changed; ${config.configPath} is untouched.`,\n );\n }\n if (shell.buildCacheCleared) {\n ctx.log(\n ` removed ${HARNESS_DIR}/${BUILD_CACHE_DIR} (Next's cache from the previous shell)`,\n );\n }\n\n if (config.bootstrapped) {\n ctx.log(` created harness.config.ts (yours — edit it, we never will)`);\n }\n for (const file of shell.created) ctx.log(` created ${HARNESS_DIR}/${file}`);\n for (const file of shell.updated) ctx.log(` updated ${HARNESS_DIR}/${file}`);\n if (gitignoreUpdated) ctx.log(' updated .gitignore (.ekanos/)');\n ctx.log(\n ` live-mode OAuth: the harness generates ${LOCAL_SECRETS_PATH} on first ` +\n 'use — fill it in and follow \"Local OAuth\" on the Activation surface.',\n );\n\n let integrations: ExperienceStartup | null = null;\n if (repo) {\n // Each experience package resolves its own integrations through the repo\n // server; the session catalog is shared from the repo root.\n writeSessionCatalog(\n loaded.projectDir,\n await tryFetchCatalog(ctx, args, loaded.projectDir),\n );\n for (const pkg of repo.packages) {\n ctx.log(` ${pkg.kind} ${pkg.name} v${pkg.version} (${pkg.relDir})`);\n }\n } else if (experience) {\n integrations = await resolveExperienceIntegrations(\n ctx,\n args,\n loaded.projectDir,\n );\n }\n\n // `--hostname` is passed ALWAYS, never left to Next's default, so the URL\n // we print is the URL that is actually served.\n const serverArgs = ['dev', '--port', String(port), '--hostname', host];\n const serverEnv: Record<string, string> = exposed\n ? { [EXPOSED_ENV]: '1' }\n : {};\n const command =\n (exposed ? `${EXPOSED_ENV}=1 ` : '') +\n formatCommand(pm.bin, execArgs(pm, 'next', serverArgs));\n const url = `http://${displayHost(host)}:${port}`;\n\n const scaffold = {\n kind: repo ? 'repo' : experience ? 'experience' : 'integration',\n ...(repo\n ? {\n packages: repo.packages.map((pkg) => ({\n name: pkg.name,\n kind: pkg.kind,\n dir: pkg.relDir,\n })),\n }\n : {}),\n ...(integrations\n ? {\n overrides: integrations.overrides,\n publishBlocked: integrations.overrides.length > 0,\n }\n : {}),\n slug: loaded.primary.slug,\n // An experience lists the integrations it depends on (provenance lines);\n // an integration project lists its own slugs.\n integrations: integrations\n ? integrations.lines\n : repo\n ? repo.packages\n .filter((p) => p.kind === 'integration')\n .map((p) => p.name)\n : loaded.integrations.map((i) => i.slug),\n projectDir: loaded.projectDir,\n turbopackRoot,\n harnessDir: shell.harnessDir,\n harnessVersion,\n previousVersion: shell.previousVersion,\n previousMarker: shell.previousMarker,\n stale: shell.stale,\n staleReasons: shell.staleReasons,\n buildCacheCleared: shell.buildCacheCleared,\n sourceGlobs: loaded.project.sourceGlobs ?? [],\n created: shell.created,\n updated: shell.updated,\n unchanged: shell.unchanged,\n configBootstrapped: config.bootstrapped,\n configPath: config.configPath,\n gitignoreUpdated,\n ...(notice ? { toolchain: notice } : {}),\n };\n\n if (exposed) {\n ctx.warn(\n `WARNING: --host ${host} exposes the harness beyond this machine. It ` +\n 'has no authentication, and it renders your fixtures and — in live ' +\n 'mode — real responses from your vendor API. Its API routes hold the ' +\n `client secret from ${LOCAL_SECRETS_PATH}, the tokens onTokens stored, ` +\n 'and run your handlers on request; they refuse non-loopback callers ' +\n `unless ${EXPOSED_ENV}=1, which this sets. Anyone who can reach ` +\n `${url} can read and run all of it. Omit --host to bind ${DEFAULT_HOST}.`,\n );\n }\n\n // A JSON caller is an agent or a pipe. Handing it a dev server that never\n // exits would hang its tool call forever and it would never see the\n // envelope, so JSON mode scaffolds and reports the command instead of\n // running it. `--start` overrides; `--no-start` opts out in a terminal.\n const shouldStart = args.start ?? !ctx.jsonMode;\n if (!shouldStart) {\n const reason = args.start === false ? 'no-start' : 'non-interactive';\n const note =\n reason === 'non-interactive'\n ? `Scaffolded only: the server was NOT started because this run is non-interactive (JSON output, a pipe, or an agent). Pass --start to run it, or run: ${command}`\n : `Scaffolded only (--no-start). Run: ${command}`;\n ctx.log(note);\n return ctx.succeed(\n {\n ...scaffold,\n server: {\n started: false,\n reason,\n note,\n command,\n url,\n port,\n host,\n exposed,\n },\n },\n ctx.ui.result({\n title: 'Harness ready',\n rows: [\n ['Directory', displayPath(shell.harnessDir, process.cwd())],\n ['URL', url],\n ['Started', 'no (scaffold only)'],\n ['Start', command],\n ],\n }),\n );\n }\n\n ctx.log(ctx.ui.dim(`Starting the harness on ${url} (${command})…`));\n // The catalog and publish status the harness shows, read with this CLI's\n // login and refreshed while the server runs; the harness never holds a token.\n const stopHostSnapshots =\n args.hostSnapshots === false\n ? () => undefined\n : startHostSnapshotRefresher({\n ctx,\n env: args.env ?? process.env,\n projectDir: loaded.projectDir,\n // A repo root names no Source of its own; its packages do, so a\n // repo whose packages all publish to one Source reads that one.\n ...(repo\n ? {\n fallbackSource: sharedPackageSource(\n repo.packages.map((pkg) => pkg.dir),\n ),\n packageDirs: repo.packages.map((pkg) => pkg.dir),\n }\n : {}),\n });\n const tail = createOutputTail();\n let exitCode: number;\n try {\n exitCode = await spawnServer({\n ctx,\n tail,\n bin: pm.bin,\n argv: execArgs(pm, 'next', serverArgs),\n cwd: shell.harnessDir,\n env: serverEnv,\n });\n } finally {\n stopHostSnapshots();\n }\n\n const data = {\n ...scaffold,\n server: { started: true, command, url, port, host, exposed, exitCode },\n };\n\n if (exitCode === 0) {\n return ctx.succeed(\n data,\n ctx.ui.result({ title: 'Harness stopped', rows: [['URL', url]] }),\n );\n }\n\n const ignoredBuilds = findIgnoredBuilds(tail.text());\n\n return ctx.failWith({\n code: 'dev_server_failed',\n message: `\"${command}\" exited with code ${exitCode}.`,\n hint:\n ignoredBuilds.length > 0\n ? ignoredBuildsHint(ignoredBuilds)\n : 'Read the Next output on stderr. If it cannot resolve @ekanos/harness ' +\n `or next, reinstall dependencies in ${loaded.projectDir}; if a route ` +\n `fails to compile, delete ${shell.harnessDir} and re-run \"ekanos dev\".`,\n // Transparent passthrough of Next's own exit code.\n exitCode,\n data,\n });\n}\n\n/**\n * Warn — never fail — when the lockfile resolves `@ekanos/sdk` or `@ekanos/ui`\n * more than once: the harness would mount its providers from one copy and the\n * project's hooks would read the other's, which throws at render time with a\n * message that points nowhere near the lockfile.\n */\nfunction warnOnDuplicateInstances(ctx: CliContext, projectDir: string): void {\n const scan = scanLockfileInstances(projectDir);\n if (scan.status === 'unreadable') {\n ctx.log(\n ctx.ui.dim(\n `Could not check ${scan.lockfile} for duplicate @ekanos/sdk copies: ${scan.reason}`,\n ),\n );\n return;\n }\n if (scan.status !== 'ok') return;\n const lines = describeDuplicates(scan.duplicates);\n if (lines.length === 0) return;\n\n ctx.warn(\n `WARNING: ${lines.join('; ')} (${scan.lockfile}). The harness and your ` +\n 'code may load different copies, and a provider from one is invisible ' +\n `to hooks from the other. ${DUPLICATE_INSTANCE_HINT}`,\n );\n}\n\nfunction spawnServer(params: {\n ctx: CliContext;\n tail: ReturnType<typeof createOutputTail>;\n bin: string;\n argv: string[];\n cwd: string;\n env: Record<string, string>;\n}): Promise<number> {\n return new Promise<number>((resolve, reject) => {\n const child = spawn(params.bin, params.argv, {\n cwd: params.cwd,\n env: { ...process.env, ...params.env },\n // stdin inherited so Next's own key handling works; stdout/stderr piped\n // so we can route them and keep OUR stdout reserved for the envelope.\n stdio: ['inherit', 'pipe', 'pipe'],\n });\n\n child.stdout?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n (params.ctx.jsonMode ? process.stderr : process.stdout).write(chunk);\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n process.stderr.write(chunk);\n });\n\n child.on('error', (error) => reject(error));\n child.on('close', (code) => resolve(code ?? 1));\n });\n}\n\n/**\n * The hostname to show a human. `127.0.0.1` is spelled `localhost` because\n * that is what people type; a wildcard bind is spelled `localhost` too, but\n * only after `exposed` has already been warned about — printing `0.0.0.0` as\n * a URL is not useful.\n */\nfunction displayHost(host: string): string {\n if (host === '127.0.0.1' || host === '0.0.0.0' || host === '::') {\n return 'localhost';\n }\n if (host === '::1') return '[::1]';\n return host;\n}\n\nfunction parseHost(raw: string | undefined): string {\n if (raw === undefined) return DEFAULT_HOST;\n\n const host = raw.trim();\n if (host.length === 0) {\n throw usageError(\n 'Invalid --host \"\".',\n `Pass an interface to bind, e.g. \"--host 0.0.0.0\" to expose the ` +\n `harness on your network, or omit it to bind ${DEFAULT_HOST}.`,\n );\n }\n return host;\n}\n\nfunction parsePort(raw: string | undefined): number {\n if (raw === undefined) return DEFAULT_PORT;\n\n const port = Number(raw);\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw usageError(\n `Invalid --port \"${raw}\".`,\n 'Pass an integer between 1 and 65535, e.g. \"--port 3100\".',\n );\n }\n return port;\n}\n\ninterface DevProject {\n projectDir: string;\n integrations: Array<{ slug: string; entry: string }>;\n primary: { slug: string };\n project: { sourceGlobs?: string[] | undefined };\n}\n\nfunction experienceProject(projectDir: string): DevProject {\n const { slug } = readExperienceProject(projectDir);\n return {\n projectDir,\n // An experience registers no integration of its own with the harness; its\n // integrations come from ekanos.json through /__ekanos/api.\n integrations: [],\n primary: { slug },\n project: {},\n };\n}\n\nfunction repoProject(repo: RepoDiscovery): DevProject {\n return {\n projectDir: repo.root,\n integrations: [],\n primary: { slug: path.basename(repo.root) },\n // The shell's stylesheet scans integrations/ already; experiences/ is the\n // other half of a repo.\n project: { sourceGlobs: ['experiences/**/*.{ts,tsx}'] },\n };\n}\n\ninterface ExperienceStartup {\n lines: string[];\n overrides: Array<{ integration: string; path: string; via: 'file' | 'env' }>;\n}\n\n/**\n * Resolve every integration with the harness the project installed, print where each\n * came from, and refuse to start when an integration cannot be served (a pin the\n * resolver cannot satisfy is a startup failure, not a blank widget later).\n */\nasync function resolveExperienceIntegrations(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<ExperienceStartup> {\n const env = args.env ?? process.env;\n const resolver = await (args.loadResolver ?? loadHarnessResolver)(projectDir);\n\n const catalog = await (\n args.fetchCatalog ?? (() => tryFetchCatalog(ctx, args, projectDir))\n )();\n writeSessionCatalog(projectDir, catalog);\n\n const contractsDir = args.contractsDir ?? env.EKANOS_CONTRACTS_DIR;\n const resolution = await resolver.resolveIntegrations({\n projectRoot: projectDir,\n env,\n ...(contractsDir ? { contractsDir: path.resolve(contractsDir) } : {}),\n catalog,\n });\n const lines = resolver.formatProvenanceLines(resolution as never);\n for (const line of lines) ctx.log(line);\n for (const notice of resolution.notices) ctx.warn(notice);\n\n if (resolution.errors.length > 0) {\n throw preconditionError(\n `${resolution.errors.length} integration${resolution.errors.length === 1 ? '' : 's'} could not be resolved: ${resolution.errors\n .map((e) => e.message)\n .join(' | ')}`,\n 'Fix the pin in ekanos.json (or run \"ekanos sync\"), or remove the bad override in ekanos.local.json, then re-run \"ekanos dev\".',\n );\n }\n return { lines, overrides: resolution.overrides };\n}\n\n/** The dev's Source catalog when a session exists; null (offline) otherwise. Never throws. */\nasync function tryFetchCatalog(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<SourceCatalog | null> {\n try {\n const env = resolveAuthEnvironment(\n ctx,\n undefined,\n args.env ?? process.env,\n {\n projectDir,\n },\n );\n let session = requireSession(env);\n // The harness's Source switcher, when it picked one; the host refuses a\n // Source the developer no longer holds a seat on.\n const resolved = await resolveSourceTarget(env, session, {\n source: readSourceSelection(projectDir) ?? undefined,\n dir: projectDir,\n });\n session = resolved.session;\n let result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n if (result.status === 'unauthorized') {\n session = await refreshStoredSession(env, session);\n result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n }\n return result.status === 'ok' ? result.catalog : null;\n } catch {\n ctx.log(\n ctx.ui.dim(\n 'No CLI session: integrations resolve offline (registry integrations fixtures-only, overrides unverified). Run \"ekanos login\" to enable develop-aware live mode.',\n ),\n );\n return null;\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import type { CliContext } from '../context.js';
2
+ export interface DoctorArgs {
3
+ host?: string;
4
+ source?: string;
5
+ /** `ns__slug`, `ns/slug` or a bare global slug. */
6
+ target?: string;
7
+ /** Names the kind; without it the host is asked as an integration, then as an experience. */
8
+ kind?: string;
9
+ /** Adds the connection checks, as the calling person. */
10
+ team?: string;
11
+ dir: string;
12
+ env: Record<string, string | undefined>;
13
+ }
14
+ /**
15
+ * `doctor` — whether one published package resolves on a host, check by check,
16
+ * without invoking it (plan 263 §6). An integration is checked against the
17
+ * deployed registry, its contract, product row, visibility, entitlement and
18
+ * release; an experience also per integration it uses, with the refusal the
19
+ * executor would give. `--team` adds the connection each one resolves to, as
20
+ * the caller. The OAuth redirect URI each connection's connect sends is
21
+ * listed, with a warning where it has drifted: the app config records a URI on
22
+ * a host the Source no longer serves callbacks from, or records none and so
23
+ * sends the per-integration URI (plan 263 §4).
24
+ *
25
+ * Exit 0 only when the report is `ok`; otherwise the report is still printed
26
+ * (human mode on stderr with the error, `--json` in `data`) and the exit code
27
+ * is 1.
28
+ */
29
+ export declare function runDoctor(ctx: CliContext, args: DoctorArgs): Promise<number>;
@@ -0,0 +1,188 @@
1
+ import { tryParseIntegrationRef, } from '@ekanos/integration-schema';
2
+ import { loginHint } from '../auth/host-trust.js';
3
+ import { refreshStoredSession, requireSession, resolveAuthEnvironment, } from '../auth/session.js';
4
+ import { fetchDoctorReport, unknownTargetError, } from '../doctor-api.js';
5
+ import { authRequiredError, usageError } from '../errors.js';
6
+ import { isProductSlug } from '../product-slug.js';
7
+ import { resolveSourceTarget } from '../source-target.js';
8
+ import { pluralize } from '../ui.js';
9
+ /** The exit code of a report that is not `ok`, as the doctor contract fixes it. */
10
+ const DOCTOR_FAILED_EXIT = 1;
11
+ const TARGET_SHAPE = 'A target is an integration or experience token ("vastly-internal__news"), ' +
12
+ 'its package name ("vastly-internal/news") or a bare global slug ("linear").';
13
+ /**
14
+ * `doctor` — whether one published package resolves on a host, check by check,
15
+ * without invoking it (plan 263 §6). An integration is checked against the
16
+ * deployed registry, its contract, product row, visibility, entitlement and
17
+ * release; an experience also per integration it uses, with the refusal the
18
+ * executor would give. `--team` adds the connection each one resolves to, as
19
+ * the caller. The OAuth redirect URI each connection's connect sends is
20
+ * listed, with a warning where it has drifted: the app config records a URI on
21
+ * a host the Source no longer serves callbacks from, or records none and so
22
+ * sends the per-integration URI (plan 263 §4).
23
+ *
24
+ * Exit 0 only when the report is `ok`; otherwise the report is still printed
25
+ * (human mode on stderr with the error, `--json` in `data`) and the exit code
26
+ * is 1.
27
+ */
28
+ export async function runDoctor(ctx, args) {
29
+ var _a;
30
+ const token = normalizeTarget(args.target);
31
+ const kinds = kindsToTry(args.kind);
32
+ const env = resolveAuthEnvironment(ctx, args.host, args.env, {
33
+ projectDir: args.dir,
34
+ });
35
+ let session = requireSession(env);
36
+ const resolved = await resolveSourceTarget(env, session, args);
37
+ session = resolved.session;
38
+ let report = null;
39
+ let unknownMessage = null;
40
+ for (const kind of kinds) {
41
+ const query = { source: resolved.source, kind, token, team: args.team };
42
+ let result = await fetchDoctorReport(env.host, session.accessToken, query);
43
+ if (result.status === 'unauthorized') {
44
+ session = await refreshStoredSession(env, session);
45
+ result = await fetchDoctorReport(env.host, session.accessToken, query);
46
+ }
47
+ const outcome = requireReport(result, env);
48
+ if (outcome) {
49
+ report = outcome;
50
+ break;
51
+ }
52
+ unknownMessage = result.status === 'unknown-target' ? result.message : null;
53
+ }
54
+ if (!report) {
55
+ throw unknownTargetError(token, resolved.source, unknownMessage);
56
+ }
57
+ const human = renderReport(ctx.ui, report, {
58
+ source: resolved.source,
59
+ team: (_a = args.team) !== null && _a !== void 0 ? _a : null,
60
+ });
61
+ if (report.ok)
62
+ return ctx.succeed(report, human);
63
+ // A failing run writes to stderr, as every failure path does; stdout holds
64
+ // only the one envelope.
65
+ if (!ctx.jsonMode)
66
+ ctx.log(human);
67
+ return ctx.failWith({
68
+ code: 'doctor_failed',
69
+ message: failureMessage(report),
70
+ hint: 'Fix what is marked above (the full report is in data), then run ' +
71
+ `"ekanos doctor ${token}" again.`,
72
+ exitCode: DOCTOR_FAILED_EXIT,
73
+ data: report,
74
+ });
75
+ }
76
+ /** `ns/slug` becomes the token `ns__slug`; a token or bare slug stays as typed. */
77
+ function normalizeTarget(target) {
78
+ const typed = target === null || target === void 0 ? void 0 : target.trim();
79
+ if (!typed) {
80
+ throw usageError('Which package? "ekanos doctor" needs an integration or experience.', `Run "ekanos doctor <token-or-ref>", e.g. "ekanos doctor vastly-internal/news". ${TARGET_SHAPE}`);
81
+ }
82
+ if (typed.includes('/')) {
83
+ const ref = tryParseIntegrationRef(typed);
84
+ if (ref)
85
+ return ref.token;
86
+ }
87
+ else if (isProductSlug(typed)) {
88
+ return typed;
89
+ }
90
+ throw usageError(`"${typed}" is not a package name.`, TARGET_SHAPE);
91
+ }
92
+ function kindsToTry(kind) {
93
+ if (kind === undefined)
94
+ return ['integration', 'experience'];
95
+ if (kind === 'integration' || kind === 'experience')
96
+ return [kind];
97
+ throw usageError(`--kind "${kind}" is not a kind of package.`, 'Pass "--kind integration" or "--kind experience", or leave it out and the host is asked as each.');
98
+ }
99
+ /** The report, or null when the host does not know the target as this kind. */
100
+ function requireReport(result, env) {
101
+ if (result.status === 'ok')
102
+ return result.report;
103
+ if (result.status === 'unknown-target')
104
+ return null;
105
+ throw authRequiredError(`The session for ${env.host} could not authorize the doctor report.`, loginHint(env));
106
+ }
107
+ function failedChecks(report) {
108
+ return (report.checks.filter((check) => !check.ok).length +
109
+ report.slots.reduce((count, slot) => count + slot.checks.filter((check) => !check.ok).length, 0));
110
+ }
111
+ function failureMessage(report) {
112
+ const checks = failedChecks(report);
113
+ const refused = report.slots.filter((slot) => slot.refusal).length;
114
+ const parts = [
115
+ checks > 0 ? pluralize(checks, 'failing check') : null,
116
+ refused > 0 ? `${pluralize(refused, 'integration')} refused` : null,
117
+ ].filter((part) => part !== null);
118
+ return `${report.target.token} is not ready on this host${parts.length > 0 ? `: ${parts.join(', ')}` : ''}.`;
119
+ }
120
+ function checkLine(ui, check, indent) {
121
+ const mark = check.ok ? ui.ok(ui.glyphs.ok) : ui.err(ui.glyphs.err);
122
+ const detail = check.detail ? ui.dim(` — ${check.detail}`) : '';
123
+ return `${indent}${mark} ${check.id}${detail}`;
124
+ }
125
+ function slotLines(ui, slot) {
126
+ const lines = [
127
+ ` ${ui.bold(slot.slot)} ${ui.dim(`${slot.integration} · line ${slot.line} · ${slot.modes.join(', ')}`)}`,
128
+ ...slot.checks.map((check) => checkLine(ui, check, ' ')),
129
+ ];
130
+ if (slot.refusal) {
131
+ const { reason, check, detail } = slot.refusal;
132
+ lines.push(` ${ui.err(ui.glyphs.err)} refused: ${ui.bold(reason)}${check ? ui.dim(` (check: ${check})`) : ''}${detail ? ui.dim(` — ${detail}`) : ''}`);
133
+ }
134
+ return lines;
135
+ }
136
+ function renderReport(ui, report, scope) {
137
+ const { target } = report;
138
+ const rows = [
139
+ [
140
+ target.kind === 'experience' ? 'Experience' : 'Integration',
141
+ target.version ? `${target.token}@${target.version}` : target.token,
142
+ ],
143
+ ['Environment', report.environment],
144
+ ['Source', scope.source],
145
+ ];
146
+ if (scope.team)
147
+ rows.push(['Team', scope.team]);
148
+ const blocks = [
149
+ ui.result({
150
+ title: report.ok ? 'Ready' : 'Not ready',
151
+ tone: report.ok ? 'ok' : 'err',
152
+ rows,
153
+ }),
154
+ ];
155
+ if (report.checks.length > 0) {
156
+ blocks.push([
157
+ ui.section('checks'),
158
+ ...report.checks.map((check) => checkLine(ui, check, ' ')),
159
+ ].join('\n'));
160
+ }
161
+ if (report.slots.length > 0) {
162
+ blocks.push([
163
+ ui.section('integrations it uses'),
164
+ ...report.slots.flatMap((slot) => slotLines(ui, slot)),
165
+ ].join('\n'));
166
+ }
167
+ if (report.oauth.length > 0) {
168
+ blocks.push([
169
+ ui.section('oauth redirect'),
170
+ ...report.oauth.flatMap((entry) => [
171
+ ` ${ui.bold(entry.integration)} ${ui.dim(`connection ${entry.connection}`)}`,
172
+ ` ${ui.dim('expected')} ${entry.expectedRedirectUri}`,
173
+ ...(entry.drift
174
+ ? [
175
+ entry.storedRedirectUri
176
+ ? ` ${ui.warn(ui.glyphs.warn)} drift: the app records ${entry.storedRedirectUri}, on a host this Source no longer serves OAuth callbacks from.`
177
+ : ` ${ui.warn(ui.glyphs.warn)} drift: the app records no redirect URI, so connects send the per-integration URI above, which stops matching if the integration's slug or namespace changes.`,
178
+ ]
179
+ : []),
180
+ ]),
181
+ ].join('\n'));
182
+ }
183
+ if (target.kind === 'experience' && !scope.team) {
184
+ blocks.push(ui.hint('Add "--team <slug>" to check the connection each integration resolves to for that team.'));
185
+ }
186
+ return blocks.join('\n\n');
187
+ }
188
+ //# sourceMappingURL=doctor.js.map