@ekanos/cli 0.31.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.
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/commands/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EACxB,sBAAsB,EACtB,YAAY,EACZ,qBAAqB,EACrB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAwB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA+CzC,KAAK,UAAU,iBAAiB,CAAC,UAAkB;IACjD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,MAAM,MAAM,CAClB,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAC5D,CAAmB,CAAC;IACvB,CAAC;eAAO,CAAC;QACP,MAAM,iBAAiB,CACrB,sEAAsE,EACtE,6EAA6E,CAC9E,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAI,IAAY;IAC/B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,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AM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,IAAI,EAClC,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 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.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EACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAChC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,IAAI,EAClC,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"]}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAW,SAAS,EAAE,MAAM,OAAO,CAAC;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AAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import {\n type DoctorCheck,\n type DoctorReport,\n type DoctorSlot,\n tryParseIntegrationRef,\n} from '@ekanos/integration-schema';\n\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport type { CliContext } from '../context';\nimport {\n type DoctorTargetKind,\n type FetchDoctorResult,\n fetchDoctorReport,\n unknownTargetError,\n} from '../doctor-api';\nimport { authRequiredError, usageError } from '../errors';\nimport { isProductSlug } from '../product-slug';\nimport { resolveSourceTarget } from '../source-target';\nimport { type Ui, pluralize } from '../ui';\n\n/** The exit code of a report that is not `ok`, as the doctor contract fixes it. */\nconst DOCTOR_FAILED_EXIT = 1;\n\nexport interface DoctorArgs {\n host?: string;\n source?: string;\n /** `ns__slug`, `ns/slug` or a bare global slug. */\n target?: string;\n /** Names the kind; without it the host is asked as an integration, then as an experience. */\n kind?: string;\n /** Adds the connection checks, as the calling person. */\n team?: string;\n dir: string;\n env: Record<string, string | undefined>;\n}\n\nconst TARGET_SHAPE =\n 'A target is an integration or experience token (\"vastly-internal__news\"), ' +\n 'its package name (\"vastly-internal/news\") or a bare global slug (\"linear\").';\n\n/**\n * `doctor` — whether one published package resolves on a host, check by check,\n * without invoking it (plan 263 §6). An integration is checked against the\n * deployed registry, its contract, product row, visibility, entitlement and\n * release; an experience also per integration it uses, with the refusal the\n * executor would give. `--team` adds the connection each one resolves to, as\n * the caller. The OAuth redirect URI each connection's connect sends is\n * listed, with a warning where it has drifted: the app config records a URI on\n * a host the Source no longer serves callbacks from, or records none and so\n * sends the per-integration URI (plan 263 §4).\n *\n * Exit 0 only when the report is `ok`; otherwise the report is still printed\n * (human mode on stderr with the error, `--json` in `data`) and the exit code\n * is 1.\n */\nexport async function runDoctor(\n ctx: CliContext,\n args: DoctorArgs,\n): Promise<number> {\n const token = normalizeTarget(args.target);\n const kinds = kindsToTry(args.kind);\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n let session = requireSession(env);\n\n const resolved = await resolveSourceTarget(env, session, args);\n session = resolved.session;\n\n let report: DoctorReport | null = null;\n let unknownMessage: string | null = null;\n\n for (const kind of kinds) {\n const query = { source: resolved.source, kind, token, team: args.team };\n let result = await fetchDoctorReport(env.host, session.accessToken, query);\n if (result.status === 'unauthorized') {\n session = await refreshStoredSession(env, session);\n result = await fetchDoctorReport(env.host, session.accessToken, query);\n }\n\n const outcome = requireReport(result, env);\n if (outcome) {\n report = outcome;\n break;\n }\n unknownMessage = result.status === 'unknown-target' ? result.message : null;\n }\n\n if (!report) {\n throw unknownTargetError(token, resolved.source, unknownMessage);\n }\n\n const human = renderReport(ctx.ui, report, {\n source: resolved.source,\n team: args.team ?? null,\n });\n\n if (report.ok) return ctx.succeed(report, human);\n\n // A failing run writes to stderr, as every failure path does; stdout holds\n // only the one envelope.\n if (!ctx.jsonMode) ctx.log(human);\n\n return ctx.failWith({\n code: 'doctor_failed',\n message: failureMessage(report),\n hint:\n 'Fix what is marked above (the full report is in data), then run ' +\n `\"ekanos doctor ${token}\" again.`,\n exitCode: DOCTOR_FAILED_EXIT,\n data: report,\n });\n}\n\n/** `ns/slug` becomes the token `ns__slug`; a token or bare slug stays as typed. */\nfunction normalizeTarget(target: string | undefined): string {\n const typed = target?.trim();\n if (!typed) {\n throw usageError(\n 'Which package? \"ekanos doctor\" needs an integration or experience.',\n `Run \"ekanos doctor <token-or-ref>\", e.g. \"ekanos doctor vastly-internal/news\". ${TARGET_SHAPE}`,\n );\n }\n\n if (typed.includes('/')) {\n const ref = tryParseIntegrationRef(typed);\n if (ref) return ref.token;\n } else if (isProductSlug(typed)) {\n return typed;\n }\n\n throw usageError(`\"${typed}\" is not a package name.`, TARGET_SHAPE);\n}\n\nfunction kindsToTry(kind: string | undefined): DoctorTargetKind[] {\n if (kind === undefined) return ['integration', 'experience'];\n if (kind === 'integration' || kind === 'experience') return [kind];\n\n throw usageError(\n `--kind \"${kind}\" is not a kind of package.`,\n 'Pass \"--kind integration\" or \"--kind experience\", or leave it out and the host is asked as each.',\n );\n}\n\n/** The report, or null when the host does not know the target as this kind. */\nfunction requireReport(\n result: FetchDoctorResult,\n env: AuthEnvironment,\n): DoctorReport | null {\n if (result.status === 'ok') return result.report;\n if (result.status === 'unknown-target') return null;\n\n throw authRequiredError(\n `The session for ${env.host} could not authorize the doctor report.`,\n loginHint(env),\n );\n}\n\nfunction failedChecks(report: DoctorReport): number {\n return (\n report.checks.filter((check) => !check.ok).length +\n report.slots.reduce(\n (count, slot) => count + slot.checks.filter((check) => !check.ok).length,\n 0,\n )\n );\n}\n\nfunction failureMessage(report: DoctorReport): string {\n const checks = failedChecks(report);\n const refused = report.slots.filter((slot) => slot.refusal).length;\n const parts = [\n checks > 0 ? pluralize(checks, 'failing check') : null,\n refused > 0 ? `${pluralize(refused, 'integration')} refused` : null,\n ].filter((part) => part !== null);\n\n return `${report.target.token} is not ready on this host${\n parts.length > 0 ? `: ${parts.join(', ')}` : ''\n }.`;\n}\n\nfunction checkLine(ui: Ui, check: DoctorCheck, indent: string): string {\n const mark = check.ok ? ui.ok(ui.glyphs.ok) : ui.err(ui.glyphs.err);\n const detail = check.detail ? ui.dim(` — ${check.detail}`) : '';\n\n return `${indent}${mark} ${check.id}${detail}`;\n}\n\nfunction slotLines(ui: Ui, slot: DoctorSlot): string[] {\n const lines = [\n ` ${ui.bold(slot.slot)} ${ui.dim(\n `${slot.integration} · line ${slot.line} · ${slot.modes.join(', ')}`,\n )}`,\n ...slot.checks.map((check) => checkLine(ui, check, ' ')),\n ];\n\n if (slot.refusal) {\n const { reason, check, detail } = slot.refusal;\n lines.push(\n ` ${ui.err(ui.glyphs.err)} refused: ${ui.bold(reason)}${\n check ? ui.dim(` (check: ${check})`) : ''\n }${detail ? ui.dim(` — ${detail}`) : ''}`,\n );\n }\n\n return lines;\n}\n\nfunction renderReport(\n ui: Ui,\n report: DoctorReport,\n scope: { source: string; team: string | null },\n): string {\n const { target } = report;\n const rows: Array<[string, string]> = [\n [\n target.kind === 'experience' ? 'Experience' : 'Integration',\n target.version ? `${target.token}@${target.version}` : target.token,\n ],\n ['Environment', report.environment],\n ['Source', scope.source],\n ];\n if (scope.team) rows.push(['Team', scope.team]);\n\n const blocks = [\n ui.result({\n title: report.ok ? 'Ready' : 'Not ready',\n tone: report.ok ? 'ok' : 'err',\n rows,\n }),\n ];\n\n if (report.checks.length > 0) {\n blocks.push(\n [\n ui.section('checks'),\n ...report.checks.map((check) => checkLine(ui, check, ' ')),\n ].join('\\n'),\n );\n }\n\n if (report.slots.length > 0) {\n blocks.push(\n [\n ui.section('integrations it uses'),\n ...report.slots.flatMap((slot) => slotLines(ui, slot)),\n ].join('\\n'),\n );\n }\n\n if (report.oauth.length > 0) {\n blocks.push(\n [\n ui.section('oauth redirect'),\n ...report.oauth.flatMap((entry) => [\n ` ${ui.bold(entry.integration)} ${ui.dim(`connection ${entry.connection}`)}`,\n ` ${ui.dim('expected')} ${entry.expectedRedirectUri}`,\n ...(entry.drift\n ? [\n entry.storedRedirectUri\n ? ` ${ui.warn(ui.glyphs.warn)} drift: the app records ${entry.storedRedirectUri}, on a host this Source no longer serves OAuth callbacks from.`\n : ` ${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.`,\n ]\n : []),\n ]),\n ].join('\\n'),\n );\n }\n\n if (target.kind === 'experience' && !scope.team) {\n blocks.push(\n ui.hint(\n 'Add \"--team <slug>\" to check the connection each integration resolves to for that team.',\n ),\n );\n }\n\n return blocks.join('\\n\\n');\n}\n"]}
@@ -80,6 +80,9 @@ const FILES = [
80
80
  // own header for what it does and why it tolerates a non-git directory.
81
81
  { template: 'scripts/setup-hooks.mjs.tmpl', dest: 'scripts/setup-hooks.mjs' },
82
82
  { template: 'src/integration.ts.tmpl', dest: 'src/integration.ts' },
83
+ // The widget component, in its own 'use client' module. Defined inline in
84
+ // integration.ts it cannot cross to the browser, and the host refuses it.
85
+ { template: 'src/widget.ts.tmpl', dest: 'src/widget.ts' },
83
86
  {
84
87
  template: 'src/integration.test.ts.tmpl',
85
88
  dest: 'src/integration.test.ts',
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAGL,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAW,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAkD9C,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAElD;;;;;;;GAOG;AACH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAyC;IACvE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,E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,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;oBACnD,aAAa;oBACb,YAAY;iBACb;aACF;YACD,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;SACjC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { printBanner } from '../banner';\nimport type { CliContext } from '../context';\nimport { copyTreeVerbatim } from '../copy-tree';\nimport { SDK_DOCS_URL, docsPage } from '../docs-links';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { runInitExperience } from '../experience/init';\nimport {\n type Manifest,\n type ManifestNote,\n mergeManifest,\n serializeManifest,\n} from '../merge-manifest';\nimport {\n type EkanosProject,\n docEntryProblem,\n serializeProject,\n} from '../project';\nimport { runInitRepo } from '../repo/scaffold';\nimport { classifyPath, readFileNoFollow, writeFileNoFollow } from '../safe-fs';\nimport { readTemplate, templatesDir, toDisplayName } from '../templates';\nimport { type Ui, displayPath, pluralize } from '../ui';\nimport { canWizard, wizard } from '../wizard';\n\n/**\n * A file init did not write, and what the partner should do about it.\n *\n * Every ERROR path in this CLI carries an imperative hint; a skip did not, and\n * that asymmetry was the bug — `skipped package.json (already exists)` hid the\n * loss of eleven dependencies and the project's module type.\n */\nexport interface SkippedFile {\n file: string;\n reason: string;\n hint: string;\n}\n\nexport interface InitArgs {\n slug?: string;\n /**\n * Explicit target directory. When omitted, init scaffolds into `./<slug>`\n * under `cwd` — never into `cwd` itself. A real partner ran `init` in a\n * populated directory and got six files sprayed into it; `--dir .` is the\n * explicit opt-in for that.\n */\n dir?: string;\n cwd: string;\n force: boolean;\n /** Accepted for non-interactive ergonomics; init never prompts regardless. */\n yes: boolean;\n /**\n * Repeatable `--docs` entries — http(s) URLs or project-relative paths to\n * the target API's documentation, written into the scaffolded ekanos.json\n * as `docs`. Absent flag means the field is simply omitted; init never\n * prompts for it.\n */\n docs?: string[];\n /** `integration` (default), `experience` or `repo`. */\n kind?: string;\n /**\n * The project is a package of an Ekanos repo (`ekanos new`): the repo root\n * owns the pnpm workspace file, so the package does not get its own.\n */\n inRepo?: boolean;\n /**\n * Test-only override for the clack wizard gate (`canWizard` in\n * `wizard.ts`) — never set from real CLI wiring. See `RunOptions` in\n * `index.ts`.\n */\n stdinIsTTY?: boolean;\n}\n\nconst SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * The files init writes: template basename → destination path.\n *\n * `package.json` is handled separately (see `writeManifest`) because it is the\n * one file a partner plausibly already has — `npm init -y` before `ekanos\n * init` is the ordinary way to start — and skipping it silently costs them\n * every dependency and script.\n */\n/**\n * The agent-context files. The SDK's day-1 users are coding agents, so the\n * scaffold ships the authoring contract alongside the code: AGENTS.md is the\n * contract, CLAUDE.md points at it, and the Claude Code skill teaches the\n * iterate-validate-publish loop. Version-matched to the CLI because they live\n * in its templates.\n *\n * Exported so `ekanos upgrade` can regenerate exactly this set from the\n * NEWLY installed CLI's templates after a version bump — a stale AGENTS.md\n * teaches an agent yesterday's contract, which is as harmful as a stale\n * binary. One list, so `init` and `upgrade` can never disagree on what \"the\n * agent-context files\" even are.\n */\nexport const AGENT_CONTEXT_FILES: { template: string; dest: string }[] = [\n { template: 'AGENTS.md.tmpl', dest: 'AGENTS.md' },\n { template: 'CLAUDE.md.tmpl', dest: 'CLAUDE.md' },\n { template: 'claude-skill.md.tmpl', dest: '.claude/skills/ekanos/SKILL.md' },\n];\n\n/**\n * The docs-grounding artifacts, exported for the same reason as\n * `AGENT_CONTEXT_FILES`: `upgrade` must create these when they are missing\n * (an older project upgrading into a toolchain whose AGENTS.md and skills\n * now reference them), and one list keeps `init` and `upgrade` from ever\n * disagreeing on what they are. Unlike the agent-context files these are\n * NEVER regenerated — `docs/api-notes.md` is agent/partner-authored after\n * the scaffold and `.mcp.json` may carry local additions — only created\n * when absent.\n */\nexport const DOCS_GROUNDING_FILES: { template: string; dest: string }[] = [\n // The agent-authored snapshot of the target API — see the template itself\n // and AGENTS.md's \"API documentation\" section for the convention.\n { template: 'docs/api-notes.md.tmpl', dest: 'docs/api-notes.md' },\n // Per-project MCP config so Claude Code picks up Context7 (the docs\n // fallback in the resolution ladder) without any global setup.\n { template: 'mcp.json.tmpl', dest: '.mcp.json' },\n];\n\nconst FILES: { template: string; dest: string }[] = [\n { template: 'ekanos.json.tmpl', dest: 'ekanos.json' },\n { template: 'gitignore.tmpl', dest: '.gitignore' },\n // pnpm's build-script approval for esbuild (vitest's dependency). Without\n // it a fresh scaffold's `ekanos test` fails on the first run under pnpm —\n // see the template's own header.\n { template: 'pnpm-workspace.yaml.tmpl', dest: 'pnpm-workspace.yaml' },\n // Without this, the `typecheck` script below prints tsc's help and exits 1 —\n // and, worse, no type error in the scaffold ever surfaces.\n { template: 'tsconfig.json.tmpl', dest: 'tsconfig.json' },\n { template: 'vitest.config.ts.tmpl', dest: 'vitest.config.ts' },\n // The lint config, wiring up BOTH SDK presets: the capability control at\n // `error` and the design rules at `warn`. INIT-ONLY, deliberately —\n // `upgrade` cannot deliver it, because the `eslint` and\n // `@typescript-eslint/parser` devDependencies and the `lint` script it\n // needs come from the package.json merge, which only `init` runs. An\n // existing project gets the preset by hand: add the two devDependencies,\n // a `\"lint\": \"eslint .\"` script, and copy this template's contents.\n { template: 'eslint.config.mjs.tmpl', dest: 'eslint.config.mjs' },\n // Wired via package.json's \"prepare\" script — see setup-hooks.mjs.tmpl's\n // own header for what it does and why it tolerates a non-git directory.\n { template: 'scripts/setup-hooks.mjs.tmpl', dest: 'scripts/setup-hooks.mjs' },\n { template: 'src/integration.ts.tmpl', dest: 'src/integration.ts' },\n {\n template: 'src/integration.test.ts.tmpl',\n dest: 'src/integration.test.ts',\n },\n ...DOCS_GROUNDING_FILES,\n ...AGENT_CONTEXT_FILES,\n];\n\n/**\n * `init` — instantiate a project from the bundled template: ekanos.json, a\n * working minimal defineIntegration, a test, a vitest config (with the\n * required SDK inline block), a .gitignore, and a package.json with real\n * published deps. Idempotent: an existing file is left untouched (reported as\n * skipped) unless --force is passed. Never prompts — a missing --slug fails\n * with a usage error naming the flag.\n *\n * In human mode at a real TTY (`canWizard`), the scaffold runs behind a\n * clack `intro`/spinner/`outro` flow instead of the flat `ctx.log` lines\n * below — see `wizard.ts`. This is a restyle, not a new interaction: the\n * data written to disk and the JSON/human-non-TTY envelope are identical\n * either way, and nothing here ever waits on a prompt.\n */\nexport async function runInit(\n ctx: CliContext,\n args: InitArgs,\n): Promise<ExitCode> {\n if (args.kind !== undefined && args.kind !== 'integration') {\n if (args.kind === 'repo') return runInitRepo(ctx, args);\n if (args.kind !== 'experience') {\n throw usageError(\n `Unknown --kind \"${args.kind}\".`,\n 'Use \"integration\" (default), \"experience\" or \"repo\".',\n );\n }\n\n return runInitExperience(ctx, args);\n }\n\n const slug = args.slug;\n if (!slug) {\n throw usageError(\n 'init requires a slug.',\n 'Pass it explicitly: \"ekanos init --slug <your-integration> --yes\". ' +\n 'The CLI never prompts, so the slug must be on the command line.',\n );\n }\n if (!SLUG_PATTERN.test(slug)) {\n throw usageError(\n `Invalid slug \"${slug}\".`,\n 'Use kebab-case: lowercase [a-z0-9] segments joined by single hyphens, ' +\n 'e.g. \"acme-crm\".',\n );\n }\n\n // Same rule the ekanos.json schema enforces, applied at the flag so a bad\n // entry fails HERE (usage, exit 2) instead of scaffolding a project whose\n // very first `ekanos validate` cannot even load its config.\n const docs = args.docs ?? [];\n for (const entry of docs) {\n const problem = docEntryProblem(entry);\n if (problem) {\n throw usageError(\n `Invalid --docs value: ${problem}`,\n 'Pass --docs an http(s) URL or a project-relative path, e.g. ' +\n '\"--docs https://developer.example.com/openapi.json\" or ' +\n '\"--docs docs/api.md\". Repeat the flag for multiple entries.',\n );\n }\n }\n\n const useWizard = canWizard(ctx, { stdinIsTTY: args.stdinIsTTY });\n if (useWizard) wizard.intro('ekanos init');\n\n // Default to `./<slug>`, not the cwd: scaffolding six files into whatever\n // directory the partner happened to be sitting in is how a real project got\n // polluted. `--dir .` remains the explicit way to scaffold in place.\n const targetDir =\n args.dir !== undefined\n ? path.resolve(args.cwd, args.dir)\n : path.resolve(args.cwd, slug);\n const vars = { SLUG: slug, DISPLAY_NAME: toDisplayName(slug) };\n\n const created: string[] = [];\n const skipped: SkippedFile[] = [];\n\n // The project root is the guard for every write below: creating it raw is\n // fine (it is the boundary, not inside it), but everything under it goes\n // through safe-fs so a planted symlink refuses loudly instead of teleporting\n // a write outside the project. See safe-fs.ts for the threat model. The one\n // case the guard cannot see is the boundary ITSELF being a symlink — the\n // containment math is lexical against `targetDir`, so a planted link there\n // would relocate every \"contained\" write wholesale. Refuse it. (A symlinked\n // ANCESTOR — macOS's /tmp, a linked home — stays fine: only the leaf is\n // checked.)\n let targetStats: fs.Stats | null = null;\n try {\n targetStats = fs.lstatSync(targetDir);\n } catch {\n targetStats = null; // does not exist yet — ours to create\n }\n if (targetStats?.isSymbolicLink()) {\n throw invalidStateError(\n `The target directory ${targetDir} is a symlink, so the scaffold's ` +\n 'write-containment guarantees cannot hold there.',\n 'Scaffold into the real directory (pass its resolved path to --dir), ' +\n 'or remove the symlink first.',\n );\n }\n fs.mkdirSync(targetDir, { recursive: true });\n\n const spinner = useWizard ? wizard.spinner() : null;\n spinner?.start(`Scaffolding \"${slug}\"…`);\n\n for (const { template, dest } of FILES) {\n if (args.inRepo && dest === 'pnpm-workspace.yaml') continue;\n const destPath = path.join(targetDir, dest);\n const kind = classifyPath(destPath);\n // A symlink is never \"already exists\": skipping would keep the plant, and\n // writing through it is the attack — writeFileNoFollow refuses it.\n if (kind !== 'missing' && kind !== 'symlink' && !args.force) {\n skipped.push({\n file: dest,\n reason: 'it already exists',\n hint:\n `Compare it against the scaffold and merge anything you are ` +\n `missing, or re-run with --force to overwrite ${dest}.`,\n });\n continue;\n }\n\n writeFileNoFollow(\n targetDir,\n destPath,\n dest === 'ekanos.json'\n ? renderEkanosConfig(vars, docs)\n : readTemplate(template, vars),\n );\n created.push(dest);\n }\n\n const skills = copyBundledSkillTrees(targetDir, args.force);\n created.push(...skills.created);\n skipped.push(...skills.skipped);\n\n const manifest = writeManifest(targetDir, vars, args.force);\n if (manifest.kind === 'created') created.push('package.json');\n\n spinner?.stop(`Scaffolded \"${slug}\"`);\n\n if (useWizard) {\n // Per-file \"created\" detail stays collapsed into the count above — the\n // note surfaces only what needs a partner's attention: skips (they hid\n // real data loss before, see `SkippedFile`'s doc comment) and manifest\n // notes.\n wizard.note(wizardSummaryDetail({ created, skipped, manifest }), 'Summary');\n } else {\n for (const file of created) ctx.log(` created ${file}`);\n if (manifest.kind === 'merged') {\n ctx.log(\n ` merged package.json (added ${manifest.added.length} field${\n manifest.added.length === 1 ? '' : 's'\n })`,\n );\n }\n if (manifest.kind === 'unchanged') {\n ctx.log(' package.json already had everything the scaffold adds');\n }\n for (const skip of skipped) {\n ctx.log(` skipped ${skip.file} — ${skip.reason}. ${skip.hint}`);\n }\n for (const note of manifest.notes) {\n ctx.warn(` ${note.message} ${note.hint}`);\n }\n }\n\n const data = {\n slug,\n dir: targetDir,\n created,\n skipped,\n manifest: {\n action: manifest.kind,\n added: manifest.added,\n kept: manifest.kept,\n notes: manifest.notes,\n },\n docs: SDK_DOCS_URL,\n };\n\n printBanner(ctx);\n\n if (useWizard) {\n const relDir = path.relative(args.cwd, targetDir) || '.';\n wizard.outro(\n `Next steps:\\n\\n cd ${relDir}\\n npm install\\n ekanos dev\\n\\nDocs: ${docsPage('quickstart')}`,\n );\n }\n\n // The wizard's note + outro already said everything; a trailing line would\n // only repeat them.\n return ctx.succeed(\n data,\n useWizard\n ? ''\n : humanResult(ctx.ui, {\n slug,\n dir: displayPath(targetDir, args.cwd),\n created: created.length,\n skipped: skipped.length,\n manifestAction: manifest.kind,\n manifestAdded: manifest.added.length,\n noteCount: manifest.notes.length,\n }),\n );\n}\n\n/**\n * The clack `note()` body for a successful wizard-mode scaffold — collapses\n * \"created\" down to a count (the flat per-file lines this replaces are the\n * `else` branch above) and surfaces only what needs a partner's attention:\n * skips and manifest notes, each with its full hint.\n */\nfunction wizardSummaryDetail(params: {\n created: string[];\n skipped: SkippedFile[];\n manifest: ManifestOutcome;\n}): string {\n const { created, skipped, manifest } = params;\n const lines: string[] = [\n `${created.length} file${created.length === 1 ? '' : 's'} written`,\n ];\n\n if (manifest.kind === 'merged') {\n lines.push(\n `package.json merged (+${manifest.added.length} field${\n manifest.added.length === 1 ? '' : 's'\n })`,\n );\n } else if (manifest.kind === 'unchanged') {\n lines.push('package.json already had everything the scaffold adds');\n }\n\n if (skipped.length > 0) {\n lines.push('', 'Skipped (already existed):');\n\n // Identical advice that only differs by file name is said once, not\n // once per file — twenty near-identical sentences hide the files.\n const groups = new Map<string, string[]>();\n for (const skip of skipped) {\n const key = skip.hint.split(skip.file).join('{file}');\n groups.set(key, [...(groups.get(key) ?? []), skip.file]);\n }\n\n for (const [hint, files] of groups) {\n if (files.length === 1) {\n lines.push(` ${files[0]} — ${hint.replace('{file}', files[0]!)}`);\n continue;\n }\n lines.push(...files.map((file) => ` ${file}`));\n lines.push(` ${hint.split('{file}').join('each file')}`);\n }\n }\n\n for (const note of manifest.notes) {\n lines.push('', `⚠ ${note.message} ${note.hint}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * The scaffolded ekanos.json: the template, plus the collected `--docs`\n * entries when there are any. Parse-then-serialize (rather than string\n * surgery) so the written file is exactly what `loadProject` will read back.\n */\nfunction renderEkanosConfig(\n vars: Readonly<Record<string, string>>,\n docs: string[],\n): string {\n const rendered = readTemplate('ekanos.json.tmpl', vars);\n if (docs.length === 0) return rendered;\n const project = JSON.parse(rendered) as EkanosProject;\n return serializeProject({ ...project, docs });\n}\n\n/**\n * Copy every bundled skill tree (`templates/skills/<name>/`) into the\n * scaffolded project at `.claude/skills/<name>/`, verbatim — see\n * `copyTreeVerbatim` for why these are bytes, never rendered templates. The\n * walk is generic: a skill directory added to the published templates ships\n * with no code change here. A CLI build with no `templates/skills/` at all\n * (today's) scaffolds nothing and reports nothing.\n *\n * `skillsRoot` is injectable for tests; real callers take the default.\n */\nexport function copyBundledSkillTrees(\n targetDir: string,\n force: boolean,\n skillsRoot = path.join(templatesDir(), 'skills'),\n onRefusal: 'throw' | 'collect' = 'throw',\n only?: readonly string[],\n): { created: string[]; skipped: SkippedFile[]; refused: string[] } {\n if (!fs.existsSync(skillsRoot))\n return { created: [], skipped: [], refused: [] };\n\n const created: string[] = [];\n const skipped: SkippedFile[] = [];\n const refused: string[] = [];\n\n const skillDirs = fs\n .readdirSync(skillsRoot, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .filter((name) => !only || only.includes(name))\n .sort();\n\n for (const name of skillDirs) {\n const destBase = path.join('.claude', 'skills', name);\n const result = copyTreeVerbatim(\n path.join(skillsRoot, name),\n path.join(targetDir, destBase),\n { force, root: targetDir, onRefusal },\n );\n created.push(...result.created.map((rel) => path.join(destBase, rel)));\n refused.push(...result.refused.map((rel) => path.join(destBase, rel)));\n skipped.push(\n ...result.skipped.map((rel) => {\n const file = path.join(destBase, rel);\n return {\n file,\n reason: 'it already exists',\n hint:\n `Compare it against the bundled skill and merge anything you ` +\n `are missing, or re-run with --force to overwrite ${file}.`,\n };\n }),\n );\n }\n\n return { created, skipped, refused };\n}\n\ntype ManifestOutcome = {\n kind: 'created' | 'merged' | 'unchanged';\n added: string[];\n kept: string[];\n notes: ManifestNote[];\n};\n\n/**\n * Write or MERGE package.json.\n *\n * A partner who ran `npm init -y` first had a manifest with none of the\n * scaffold's dependencies and `\"type\": \"commonjs\"` under ESM sources, and the\n * old behaviour reported that as one word: \"skipped\". Merging is additive — a\n * version or script they already set is theirs and is never touched — so the\n * ordinary `npm init -y` path now lands somewhere that installs and runs.\n */\nfunction writeManifest(\n targetDir: string,\n vars: Readonly<Record<string, string>>,\n force: boolean,\n): ManifestOutcome {\n const destPath = path.join(targetDir, 'package.json');\n const rendered = readTemplate('package.json.tmpl', vars);\n\n // readFileNoFollow refuses a symlinked package.json outright, so the write\n // below can never follow one either; null means genuinely absent.\n const existingRaw = readFileNoFollow(targetDir, destPath);\n\n if (existingRaw === null || force) {\n writeFileNoFollow(targetDir, destPath, rendered);\n return { kind: 'created', added: [], kept: [], notes: [] };\n }\n\n const template = JSON.parse(rendered) as Manifest;\n\n let existing: Manifest;\n try {\n existing = JSON.parse(existingRaw) as Manifest;\n } catch (error) {\n // Unparseable: do not guess, and do not clobber. Name the fix.\n return {\n kind: 'unchanged',\n added: [],\n kept: [],\n notes: [\n {\n field: '(root)',\n message: `package.json is not valid JSON: ${\n error instanceof Error ? error.message : String(error)\n }`,\n hint:\n 'Fix the JSON syntax, then re-run \"ekanos init\" to have the ' +\n \"scaffold's dependencies and scripts merged in.\",\n },\n ],\n };\n }\n\n const result = mergeManifest(existing, template);\n if (!result.changed) {\n return {\n kind: 'unchanged',\n added: [],\n kept: result.kept,\n notes: result.notes,\n };\n }\n\n writeFileNoFollow(targetDir, destPath, serializeManifest(result.manifest));\n return {\n kind: 'merged',\n added: result.added,\n kept: result.kept,\n notes: result.notes,\n };\n}\n\nfunction humanResult(\n ui: Ui,\n params: {\n slug: string;\n dir: string;\n created: number;\n skipped: number;\n manifestAction: ManifestOutcome['kind'];\n manifestAdded: number;\n noteCount: number;\n },\n): string {\n const files = [\n ...(params.created > 0 ? [`${params.created} written`] : []),\n ...(params.manifestAction === 'merged'\n ? [`${pluralize(params.manifestAdded, 'package.json field')} merged`]\n : []),\n ...(params.skipped > 0 ? [`${params.skipped} skipped`] : []),\n ];\n const attention = params.skipped > 0 || params.noteCount > 0;\n\n if (files.length === 0 && params.noteCount === 0) {\n return ui.result({\n title: `${params.slug} is already scaffolded`,\n rows: [['Directory', params.dir]],\n });\n }\n\n return ui.result({\n title: `Scaffolded ${params.slug}`,\n tone: attention ? 'warn' : 'ok',\n rows: [\n ['Directory', params.dir],\n ...(files.length > 0 ? [['Files', files.join(' · ')] as const] : []),\n ...(params.noteCount > 0\n ? [\n [\n 'Attention',\n `${pluralize(params.noteCount, 'note')} above`,\n ] as const,\n ]\n : []),\n [\n 'Next',\n [\n ...(params.dir === '.' ? [] : [`cd ${params.dir}`]),\n 'npm install',\n 'ekanos dev',\n ],\n ],\n ['Docs', docsPage('quickstart')],\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAGL,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAW,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAkD9C,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAElD;;;;;;;GAOG;AACH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAyC;IACvE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AAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ;qBACtC;iBACX;gBACH,CAAC,CAAC,EAAE,CAAC;YACP;gBACE,MAAM;gBACN;oBACE,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;oBACnD,aAAa;oBACb,YAAY;iBACb;aACF;YACD,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;SACjC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { printBanner } from '../banner';\nimport type { CliContext } from '../context';\nimport { copyTreeVerbatim } from '../copy-tree';\nimport { SDK_DOCS_URL, docsPage } from '../docs-links';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { runInitExperience } from '../experience/init';\nimport {\n type Manifest,\n type ManifestNote,\n mergeManifest,\n serializeManifest,\n} from '../merge-manifest';\nimport {\n type EkanosProject,\n docEntryProblem,\n serializeProject,\n} from '../project';\nimport { runInitRepo } from '../repo/scaffold';\nimport { classifyPath, readFileNoFollow, writeFileNoFollow } from '../safe-fs';\nimport { readTemplate, templatesDir, toDisplayName } from '../templates';\nimport { type Ui, displayPath, pluralize } from '../ui';\nimport { canWizard, wizard } from '../wizard';\n\n/**\n * A file init did not write, and what the partner should do about it.\n *\n * Every ERROR path in this CLI carries an imperative hint; a skip did not, and\n * that asymmetry was the bug — `skipped package.json (already exists)` hid the\n * loss of eleven dependencies and the project's module type.\n */\nexport interface SkippedFile {\n file: string;\n reason: string;\n hint: string;\n}\n\nexport interface InitArgs {\n slug?: string;\n /**\n * Explicit target directory. When omitted, init scaffolds into `./<slug>`\n * under `cwd` — never into `cwd` itself. A real partner ran `init` in a\n * populated directory and got six files sprayed into it; `--dir .` is the\n * explicit opt-in for that.\n */\n dir?: string;\n cwd: string;\n force: boolean;\n /** Accepted for non-interactive ergonomics; init never prompts regardless. */\n yes: boolean;\n /**\n * Repeatable `--docs` entries — http(s) URLs or project-relative paths to\n * the target API's documentation, written into the scaffolded ekanos.json\n * as `docs`. Absent flag means the field is simply omitted; init never\n * prompts for it.\n */\n docs?: string[];\n /** `integration` (default), `experience` or `repo`. */\n kind?: string;\n /**\n * The project is a package of an Ekanos repo (`ekanos new`): the repo root\n * owns the pnpm workspace file, so the package does not get its own.\n */\n inRepo?: boolean;\n /**\n * Test-only override for the clack wizard gate (`canWizard` in\n * `wizard.ts`) — never set from real CLI wiring. See `RunOptions` in\n * `index.ts`.\n */\n stdinIsTTY?: boolean;\n}\n\nconst SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * The files init writes: template basename → destination path.\n *\n * `package.json` is handled separately (see `writeManifest`) because it is the\n * one file a partner plausibly already has — `npm init -y` before `ekanos\n * init` is the ordinary way to start — and skipping it silently costs them\n * every dependency and script.\n */\n/**\n * The agent-context files. The SDK's day-1 users are coding agents, so the\n * scaffold ships the authoring contract alongside the code: AGENTS.md is the\n * contract, CLAUDE.md points at it, and the Claude Code skill teaches the\n * iterate-validate-publish loop. Version-matched to the CLI because they live\n * in its templates.\n *\n * Exported so `ekanos upgrade` can regenerate exactly this set from the\n * NEWLY installed CLI's templates after a version bump — a stale AGENTS.md\n * teaches an agent yesterday's contract, which is as harmful as a stale\n * binary. One list, so `init` and `upgrade` can never disagree on what \"the\n * agent-context files\" even are.\n */\nexport const AGENT_CONTEXT_FILES: { template: string; dest: string }[] = [\n { template: 'AGENTS.md.tmpl', dest: 'AGENTS.md' },\n { template: 'CLAUDE.md.tmpl', dest: 'CLAUDE.md' },\n { template: 'claude-skill.md.tmpl', dest: '.claude/skills/ekanos/SKILL.md' },\n];\n\n/**\n * The docs-grounding artifacts, exported for the same reason as\n * `AGENT_CONTEXT_FILES`: `upgrade` must create these when they are missing\n * (an older project upgrading into a toolchain whose AGENTS.md and skills\n * now reference them), and one list keeps `init` and `upgrade` from ever\n * disagreeing on what they are. Unlike the agent-context files these are\n * NEVER regenerated — `docs/api-notes.md` is agent/partner-authored after\n * the scaffold and `.mcp.json` may carry local additions — only created\n * when absent.\n */\nexport const DOCS_GROUNDING_FILES: { template: string; dest: string }[] = [\n // The agent-authored snapshot of the target API — see the template itself\n // and AGENTS.md's \"API documentation\" section for the convention.\n { template: 'docs/api-notes.md.tmpl', dest: 'docs/api-notes.md' },\n // Per-project MCP config so Claude Code picks up Context7 (the docs\n // fallback in the resolution ladder) without any global setup.\n { template: 'mcp.json.tmpl', dest: '.mcp.json' },\n];\n\nconst FILES: { template: string; dest: string }[] = [\n { template: 'ekanos.json.tmpl', dest: 'ekanos.json' },\n { template: 'gitignore.tmpl', dest: '.gitignore' },\n // pnpm's build-script approval for esbuild (vitest's dependency). Without\n // it a fresh scaffold's `ekanos test` fails on the first run under pnpm —\n // see the template's own header.\n { template: 'pnpm-workspace.yaml.tmpl', dest: 'pnpm-workspace.yaml' },\n // Without this, the `typecheck` script below prints tsc's help and exits 1 —\n // and, worse, no type error in the scaffold ever surfaces.\n { template: 'tsconfig.json.tmpl', dest: 'tsconfig.json' },\n { template: 'vitest.config.ts.tmpl', dest: 'vitest.config.ts' },\n // The lint config, wiring up BOTH SDK presets: the capability control at\n // `error` and the design rules at `warn`. INIT-ONLY, deliberately —\n // `upgrade` cannot deliver it, because the `eslint` and\n // `@typescript-eslint/parser` devDependencies and the `lint` script it\n // needs come from the package.json merge, which only `init` runs. An\n // existing project gets the preset by hand: add the two devDependencies,\n // a `\"lint\": \"eslint .\"` script, and copy this template's contents.\n { template: 'eslint.config.mjs.tmpl', dest: 'eslint.config.mjs' },\n // Wired via package.json's \"prepare\" script — see setup-hooks.mjs.tmpl's\n // own header for what it does and why it tolerates a non-git directory.\n { template: 'scripts/setup-hooks.mjs.tmpl', dest: 'scripts/setup-hooks.mjs' },\n { template: 'src/integration.ts.tmpl', dest: 'src/integration.ts' },\n // The widget component, in its own 'use client' module. Defined inline in\n // integration.ts it cannot cross to the browser, and the host refuses it.\n { template: 'src/widget.ts.tmpl', dest: 'src/widget.ts' },\n {\n template: 'src/integration.test.ts.tmpl',\n dest: 'src/integration.test.ts',\n },\n ...DOCS_GROUNDING_FILES,\n ...AGENT_CONTEXT_FILES,\n];\n\n/**\n * `init` — instantiate a project from the bundled template: ekanos.json, a\n * working minimal defineIntegration, a test, a vitest config (with the\n * required SDK inline block), a .gitignore, and a package.json with real\n * published deps. Idempotent: an existing file is left untouched (reported as\n * skipped) unless --force is passed. Never prompts — a missing --slug fails\n * with a usage error naming the flag.\n *\n * In human mode at a real TTY (`canWizard`), the scaffold runs behind a\n * clack `intro`/spinner/`outro` flow instead of the flat `ctx.log` lines\n * below — see `wizard.ts`. This is a restyle, not a new interaction: the\n * data written to disk and the JSON/human-non-TTY envelope are identical\n * either way, and nothing here ever waits on a prompt.\n */\nexport async function runInit(\n ctx: CliContext,\n args: InitArgs,\n): Promise<ExitCode> {\n if (args.kind !== undefined && args.kind !== 'integration') {\n if (args.kind === 'repo') return runInitRepo(ctx, args);\n if (args.kind !== 'experience') {\n throw usageError(\n `Unknown --kind \"${args.kind}\".`,\n 'Use \"integration\" (default), \"experience\" or \"repo\".',\n );\n }\n\n return runInitExperience(ctx, args);\n }\n\n const slug = args.slug;\n if (!slug) {\n throw usageError(\n 'init requires a slug.',\n 'Pass it explicitly: \"ekanos init --slug <your-integration> --yes\". ' +\n 'The CLI never prompts, so the slug must be on the command line.',\n );\n }\n if (!SLUG_PATTERN.test(slug)) {\n throw usageError(\n `Invalid slug \"${slug}\".`,\n 'Use kebab-case: lowercase [a-z0-9] segments joined by single hyphens, ' +\n 'e.g. \"acme-crm\".',\n );\n }\n\n // Same rule the ekanos.json schema enforces, applied at the flag so a bad\n // entry fails HERE (usage, exit 2) instead of scaffolding a project whose\n // very first `ekanos validate` cannot even load its config.\n const docs = args.docs ?? [];\n for (const entry of docs) {\n const problem = docEntryProblem(entry);\n if (problem) {\n throw usageError(\n `Invalid --docs value: ${problem}`,\n 'Pass --docs an http(s) URL or a project-relative path, e.g. ' +\n '\"--docs https://developer.example.com/openapi.json\" or ' +\n '\"--docs docs/api.md\". Repeat the flag for multiple entries.',\n );\n }\n }\n\n const useWizard = canWizard(ctx, { stdinIsTTY: args.stdinIsTTY });\n if (useWizard) wizard.intro('ekanos init');\n\n // Default to `./<slug>`, not the cwd: scaffolding six files into whatever\n // directory the partner happened to be sitting in is how a real project got\n // polluted. `--dir .` remains the explicit way to scaffold in place.\n const targetDir =\n args.dir !== undefined\n ? path.resolve(args.cwd, args.dir)\n : path.resolve(args.cwd, slug);\n const vars = { SLUG: slug, DISPLAY_NAME: toDisplayName(slug) };\n\n const created: string[] = [];\n const skipped: SkippedFile[] = [];\n\n // The project root is the guard for every write below: creating it raw is\n // fine (it is the boundary, not inside it), but everything under it goes\n // through safe-fs so a planted symlink refuses loudly instead of teleporting\n // a write outside the project. See safe-fs.ts for the threat model. The one\n // case the guard cannot see is the boundary ITSELF being a symlink — the\n // containment math is lexical against `targetDir`, so a planted link there\n // would relocate every \"contained\" write wholesale. Refuse it. (A symlinked\n // ANCESTOR — macOS's /tmp, a linked home — stays fine: only the leaf is\n // checked.)\n let targetStats: fs.Stats | null = null;\n try {\n targetStats = fs.lstatSync(targetDir);\n } catch {\n targetStats = null; // does not exist yet — ours to create\n }\n if (targetStats?.isSymbolicLink()) {\n throw invalidStateError(\n `The target directory ${targetDir} is a symlink, so the scaffold's ` +\n 'write-containment guarantees cannot hold there.',\n 'Scaffold into the real directory (pass its resolved path to --dir), ' +\n 'or remove the symlink first.',\n );\n }\n fs.mkdirSync(targetDir, { recursive: true });\n\n const spinner = useWizard ? wizard.spinner() : null;\n spinner?.start(`Scaffolding \"${slug}\"…`);\n\n for (const { template, dest } of FILES) {\n if (args.inRepo && dest === 'pnpm-workspace.yaml') continue;\n const destPath = path.join(targetDir, dest);\n const kind = classifyPath(destPath);\n // A symlink is never \"already exists\": skipping would keep the plant, and\n // writing through it is the attack — writeFileNoFollow refuses it.\n if (kind !== 'missing' && kind !== 'symlink' && !args.force) {\n skipped.push({\n file: dest,\n reason: 'it already exists',\n hint:\n `Compare it against the scaffold and merge anything you are ` +\n `missing, or re-run with --force to overwrite ${dest}.`,\n });\n continue;\n }\n\n writeFileNoFollow(\n targetDir,\n destPath,\n dest === 'ekanos.json'\n ? renderEkanosConfig(vars, docs)\n : readTemplate(template, vars),\n );\n created.push(dest);\n }\n\n const skills = copyBundledSkillTrees(targetDir, args.force);\n created.push(...skills.created);\n skipped.push(...skills.skipped);\n\n const manifest = writeManifest(targetDir, vars, args.force);\n if (manifest.kind === 'created') created.push('package.json');\n\n spinner?.stop(`Scaffolded \"${slug}\"`);\n\n if (useWizard) {\n // Per-file \"created\" detail stays collapsed into the count above — the\n // note surfaces only what needs a partner's attention: skips (they hid\n // real data loss before, see `SkippedFile`'s doc comment) and manifest\n // notes.\n wizard.note(wizardSummaryDetail({ created, skipped, manifest }), 'Summary');\n } else {\n for (const file of created) ctx.log(` created ${file}`);\n if (manifest.kind === 'merged') {\n ctx.log(\n ` merged package.json (added ${manifest.added.length} field${\n manifest.added.length === 1 ? '' : 's'\n })`,\n );\n }\n if (manifest.kind === 'unchanged') {\n ctx.log(' package.json already had everything the scaffold adds');\n }\n for (const skip of skipped) {\n ctx.log(` skipped ${skip.file} — ${skip.reason}. ${skip.hint}`);\n }\n for (const note of manifest.notes) {\n ctx.warn(` ${note.message} ${note.hint}`);\n }\n }\n\n const data = {\n slug,\n dir: targetDir,\n created,\n skipped,\n manifest: {\n action: manifest.kind,\n added: manifest.added,\n kept: manifest.kept,\n notes: manifest.notes,\n },\n docs: SDK_DOCS_URL,\n };\n\n printBanner(ctx);\n\n if (useWizard) {\n const relDir = path.relative(args.cwd, targetDir) || '.';\n wizard.outro(\n `Next steps:\\n\\n cd ${relDir}\\n npm install\\n ekanos dev\\n\\nDocs: ${docsPage('quickstart')}`,\n );\n }\n\n // The wizard's note + outro already said everything; a trailing line would\n // only repeat them.\n return ctx.succeed(\n data,\n useWizard\n ? ''\n : humanResult(ctx.ui, {\n slug,\n dir: displayPath(targetDir, args.cwd),\n created: created.length,\n skipped: skipped.length,\n manifestAction: manifest.kind,\n manifestAdded: manifest.added.length,\n noteCount: manifest.notes.length,\n }),\n );\n}\n\n/**\n * The clack `note()` body for a successful wizard-mode scaffold — collapses\n * \"created\" down to a count (the flat per-file lines this replaces are the\n * `else` branch above) and surfaces only what needs a partner's attention:\n * skips and manifest notes, each with its full hint.\n */\nfunction wizardSummaryDetail(params: {\n created: string[];\n skipped: SkippedFile[];\n manifest: ManifestOutcome;\n}): string {\n const { created, skipped, manifest } = params;\n const lines: string[] = [\n `${created.length} file${created.length === 1 ? '' : 's'} written`,\n ];\n\n if (manifest.kind === 'merged') {\n lines.push(\n `package.json merged (+${manifest.added.length} field${\n manifest.added.length === 1 ? '' : 's'\n })`,\n );\n } else if (manifest.kind === 'unchanged') {\n lines.push('package.json already had everything the scaffold adds');\n }\n\n if (skipped.length > 0) {\n lines.push('', 'Skipped (already existed):');\n\n // Identical advice that only differs by file name is said once, not\n // once per file — twenty near-identical sentences hide the files.\n const groups = new Map<string, string[]>();\n for (const skip of skipped) {\n const key = skip.hint.split(skip.file).join('{file}');\n groups.set(key, [...(groups.get(key) ?? []), skip.file]);\n }\n\n for (const [hint, files] of groups) {\n if (files.length === 1) {\n lines.push(` ${files[0]} — ${hint.replace('{file}', files[0]!)}`);\n continue;\n }\n lines.push(...files.map((file) => ` ${file}`));\n lines.push(` ${hint.split('{file}').join('each file')}`);\n }\n }\n\n for (const note of manifest.notes) {\n lines.push('', `⚠ ${note.message} ${note.hint}`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * The scaffolded ekanos.json: the template, plus the collected `--docs`\n * entries when there are any. Parse-then-serialize (rather than string\n * surgery) so the written file is exactly what `loadProject` will read back.\n */\nfunction renderEkanosConfig(\n vars: Readonly<Record<string, string>>,\n docs: string[],\n): string {\n const rendered = readTemplate('ekanos.json.tmpl', vars);\n if (docs.length === 0) return rendered;\n const project = JSON.parse(rendered) as EkanosProject;\n return serializeProject({ ...project, docs });\n}\n\n/**\n * Copy every bundled skill tree (`templates/skills/<name>/`) into the\n * scaffolded project at `.claude/skills/<name>/`, verbatim — see\n * `copyTreeVerbatim` for why these are bytes, never rendered templates. The\n * walk is generic: a skill directory added to the published templates ships\n * with no code change here. A CLI build with no `templates/skills/` at all\n * (today's) scaffolds nothing and reports nothing.\n *\n * `skillsRoot` is injectable for tests; real callers take the default.\n */\nexport function copyBundledSkillTrees(\n targetDir: string,\n force: boolean,\n skillsRoot = path.join(templatesDir(), 'skills'),\n onRefusal: 'throw' | 'collect' = 'throw',\n only?: readonly string[],\n): { created: string[]; skipped: SkippedFile[]; refused: string[] } {\n if (!fs.existsSync(skillsRoot))\n return { created: [], skipped: [], refused: [] };\n\n const created: string[] = [];\n const skipped: SkippedFile[] = [];\n const refused: string[] = [];\n\n const skillDirs = fs\n .readdirSync(skillsRoot, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .filter((name) => !only || only.includes(name))\n .sort();\n\n for (const name of skillDirs) {\n const destBase = path.join('.claude', 'skills', name);\n const result = copyTreeVerbatim(\n path.join(skillsRoot, name),\n path.join(targetDir, destBase),\n { force, root: targetDir, onRefusal },\n );\n created.push(...result.created.map((rel) => path.join(destBase, rel)));\n refused.push(...result.refused.map((rel) => path.join(destBase, rel)));\n skipped.push(\n ...result.skipped.map((rel) => {\n const file = path.join(destBase, rel);\n return {\n file,\n reason: 'it already exists',\n hint:\n `Compare it against the bundled skill and merge anything you ` +\n `are missing, or re-run with --force to overwrite ${file}.`,\n };\n }),\n );\n }\n\n return { created, skipped, refused };\n}\n\ntype ManifestOutcome = {\n kind: 'created' | 'merged' | 'unchanged';\n added: string[];\n kept: string[];\n notes: ManifestNote[];\n};\n\n/**\n * Write or MERGE package.json.\n *\n * A partner who ran `npm init -y` first had a manifest with none of the\n * scaffold's dependencies and `\"type\": \"commonjs\"` under ESM sources, and the\n * old behaviour reported that as one word: \"skipped\". Merging is additive — a\n * version or script they already set is theirs and is never touched — so the\n * ordinary `npm init -y` path now lands somewhere that installs and runs.\n */\nfunction writeManifest(\n targetDir: string,\n vars: Readonly<Record<string, string>>,\n force: boolean,\n): ManifestOutcome {\n const destPath = path.join(targetDir, 'package.json');\n const rendered = readTemplate('package.json.tmpl', vars);\n\n // readFileNoFollow refuses a symlinked package.json outright, so the write\n // below can never follow one either; null means genuinely absent.\n const existingRaw = readFileNoFollow(targetDir, destPath);\n\n if (existingRaw === null || force) {\n writeFileNoFollow(targetDir, destPath, rendered);\n return { kind: 'created', added: [], kept: [], notes: [] };\n }\n\n const template = JSON.parse(rendered) as Manifest;\n\n let existing: Manifest;\n try {\n existing = JSON.parse(existingRaw) as Manifest;\n } catch (error) {\n // Unparseable: do not guess, and do not clobber. Name the fix.\n return {\n kind: 'unchanged',\n added: [],\n kept: [],\n notes: [\n {\n field: '(root)',\n message: `package.json is not valid JSON: ${\n error instanceof Error ? error.message : String(error)\n }`,\n hint:\n 'Fix the JSON syntax, then re-run \"ekanos init\" to have the ' +\n \"scaffold's dependencies and scripts merged in.\",\n },\n ],\n };\n }\n\n const result = mergeManifest(existing, template);\n if (!result.changed) {\n return {\n kind: 'unchanged',\n added: [],\n kept: result.kept,\n notes: result.notes,\n };\n }\n\n writeFileNoFollow(targetDir, destPath, serializeManifest(result.manifest));\n return {\n kind: 'merged',\n added: result.added,\n kept: result.kept,\n notes: result.notes,\n };\n}\n\nfunction humanResult(\n ui: Ui,\n params: {\n slug: string;\n dir: string;\n created: number;\n skipped: number;\n manifestAction: ManifestOutcome['kind'];\n manifestAdded: number;\n noteCount: number;\n },\n): string {\n const files = [\n ...(params.created > 0 ? [`${params.created} written`] : []),\n ...(params.manifestAction === 'merged'\n ? [`${pluralize(params.manifestAdded, 'package.json field')} merged`]\n : []),\n ...(params.skipped > 0 ? [`${params.skipped} skipped`] : []),\n ];\n const attention = params.skipped > 0 || params.noteCount > 0;\n\n if (files.length === 0 && params.noteCount === 0) {\n return ui.result({\n title: `${params.slug} is already scaffolded`,\n rows: [['Directory', params.dir]],\n });\n }\n\n return ui.result({\n title: `Scaffolded ${params.slug}`,\n tone: attention ? 'warn' : 'ok',\n rows: [\n ['Directory', params.dir],\n ...(files.length > 0 ? [['Files', files.join(' · ')] as const] : []),\n ...(params.noteCount > 0\n ? [\n [\n 'Attention',\n `${pluralize(params.noteCount, 'note')} above`,\n ] as const,\n ]\n : []),\n [\n 'Next',\n [\n ...(params.dir === '.' ? [] : [`cd ${params.dir}`]),\n 'npm install',\n 'ekanos dev',\n ],\n ],\n ['Docs', docsPage('quickstart')],\n ],\n });\n}\n"]}