@ekanos/cli 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -98,7 +98,7 @@ prompts. `init` requires `--slug` and fails with a usage error naming the flag
98
98
  rather than asking for it.
99
99
 
100
100
  `validate`, `dev`, `publish` and `status` additionally carry an OPTIONAL
101
- `data.toolchain` field — `{ status: 'behind' | 'unsupported', current, target,
101
+ `data.toolchain` field (every time, not only when the stderr notice is shown) — `{ status: 'behind' | 'unsupported', current, target,
102
102
  upgradeCommand: 'ekanos upgrade' }` — whenever the background update check
103
103
  (see [Keeping the toolchain current](#keeping-the-toolchain-current)) finds
104
104
  this CLI is not current. Absent when current, unresolvable, or disabled via
@@ -491,9 +491,14 @@ turned into an uninstallable tree.
491
491
 
492
492
  ### The proactive update notice
493
493
 
494
- `validate`, `dev`, `publish` and `status` all check (in the background, with a
495
- 24h cache and a 1.5s timeout — never blocking, never changing a verb's exit
496
- code) whether a newer `@ekanos/cli` exists. Human mode gets one stderr line;
494
+ Every command except `init`, `login`, `logout` and `upgrade` checks in the
495
+ background whether a newer `@ekanos/cli` exists. It asks at most once every 4
496
+ hours (the answer is cached in `~/.ekanos/update-check.json`), gives up after
497
+ 1.5s, never delays a command and never changes its exit code; an answer not in
498
+ by the time the command finishes is dropped and asked again next time. A
499
+ newer version is announced after the command's own output, once per 4 hours,
500
+ and at once when an even newer one ships; the `unsupported` notice repeats on
501
+ every command until you upgrade. Human mode gets one stderr line;
497
502
  JSON mode never prints prose to stdout, but the envelope's `data.toolchain`
498
503
  carries `{ status: 'behind' | 'unsupported', current, target, upgradeCommand
499
504
  }` when you're not current, and (with `--json` or a detected agent) the same
package/dist/bin.js CHANGED
@@ -16,10 +16,15 @@ async function main() {
16
16
  announceDelegation(plan, argv, process.env, process.stdout.isTTY === true);
17
17
  return delegate(plan, argv, process.env);
18
18
  }
19
- // The two run-level courtesies only a real invocation turns on: recording
20
- // a failure for `ekanos feedback --last-error`, and the background check
21
- // for fixes to your own reports. Tests opt in, against their own home.
22
- return run(argv, { recordLastError: true, feedbackUpdates: true });
19
+ // The run-level courtesies only a real invocation turns on: recording a
20
+ // failure for `ekanos feedback --last-error`, and the background checks
21
+ // for a newer CLI and for fixes to your own reports. Tests opt in, against
22
+ // their own home.
23
+ return run(argv, {
24
+ recordLastError: true,
25
+ feedbackUpdates: true,
26
+ updateCheck: true,
27
+ });
23
28
  }
24
29
  main()
25
30
  .then((code) => {
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B;;;;;;;GAOG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE9D,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;QAC3E,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,0EAA0E;IAC1E,yEAAyE;IACzE,uEAAuE;IACvE,OAAO,GAAG,CAAC,IAAI,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,IAAI,EAAE;KACH,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;IACb,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;;IACxB,2EAA2E;IAC3E,oEAAoE;IACpE,uCAAuC;IACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,iCACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAC,KAAK,CAAC,KAAK,mCAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACxE,IAAI,CACL,CAAC;IACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { announceDelegation, delegate, planDelegation } from './delegate';\nimport { run } from './index';\n\n/**\n * The bin entry — the ONLY place that calls process.exit, so `run()` stays a\n * pure, testable function that returns an exit code. Argv is sliced to drop\n * the node executable and this script path.\n *\n * Before dispatching, check whether this invocation should delegate to the\n * current project's OWN pinned `@ekanos/cli` — see `delegate.ts` for why.\n */\nasync function main(): Promise<number> {\n const argv = process.argv.slice(2);\n const plan = planDelegation(argv, process.env, process.cwd());\n\n if (plan.shouldDelegate) {\n announceDelegation(plan, argv, process.env, process.stdout.isTTY === true);\n return delegate(plan, argv, process.env);\n }\n\n // The two run-level courtesies only a real invocation turns on: recording\n // a failure for `ekanos feedback --last-error`, and the background check\n // for fixes to your own reports. Tests opt in, against their own home.\n return run(argv, { recordLastError: true, feedbackUpdates: true });\n}\n\nmain()\n .then((code) => {\n process.exitCode = code;\n })\n .catch((error: unknown) => {\n // run() catches its own errors and emits the envelope; reaching here means\n // the envelope machinery itself threw. Fail loudly on stderr (never\n // stdout) with the internal exit code.\n process.stderr.write(\n `ekanos: fatal internal error: ${\n error instanceof Error ? (error.stack ?? error.message) : String(error)\n }\\n`,\n );\n process.exitCode = 1;\n });\n"]}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],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AO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { announceDelegation, delegate, planDelegation } from './delegate';\nimport { run } from './index';\n\n/**\n * The bin entry — the ONLY place that calls process.exit, so `run()` stays a\n * pure, testable function that returns an exit code. Argv is sliced to drop\n * the node executable and this script path.\n *\n * Before dispatching, check whether this invocation should delegate to the\n * current project's OWN pinned `@ekanos/cli` — see `delegate.ts` for why.\n */\nasync function main(): Promise<number> {\n const argv = process.argv.slice(2);\n const plan = planDelegation(argv, process.env, process.cwd());\n\n if (plan.shouldDelegate) {\n announceDelegation(plan, argv, process.env, process.stdout.isTTY === true);\n return delegate(plan, argv, process.env);\n }\n\n // The run-level courtesies only a real invocation turns on: recording a\n // failure for `ekanos feedback --last-error`, and the background checks\n // for a newer CLI and for fixes to your own reports. Tests opt in, against\n // their own home.\n return run(argv, {\n recordLastError: true,\n feedbackUpdates: true,\n updateCheck: true,\n });\n}\n\nmain()\n .then((code) => {\n process.exitCode = code;\n })\n .catch((error: unknown) => {\n // run() catches its own errors and emits the envelope; reaching here means\n // the envelope machinery itself threw. Fail loudly on stderr (never\n // stdout) with the internal exit code.\n process.stderr.write(\n `ekanos: fatal internal error: ${\n error instanceof Error ? (error.stack ?? error.message) : String(error)\n }\\n`,\n );\n process.exitCode = 1;\n });\n"]}
@@ -57,7 +57,7 @@ const LOCAL_SECRETS_PATH = path.join('.ekanos', 'local-secrets.json');
57
57
  * and `.gitignore` never grows a duplicate line.
58
58
  */
59
59
  export async function runDev(ctx, args) {
60
- var _a, _b, _c, _d;
60
+ var _a, _b, _c, _d, _e;
61
61
  // At a repo root one harness serves every package; anywhere else the
62
62
  // project is a single integration or experience, exactly as before.
63
63
  const repo = isRepoRoot(path.resolve(args.dir))
@@ -74,7 +74,7 @@ export async function runDev(ctx, args) {
74
74
  const exposed = !LOOPBACK_HOSTS.has(host);
75
75
  const pm = detectPackageManager(loaded.projectDir);
76
76
  const notice = await checkForUpdate({ env: (_a = args.env) !== null && _a !== void 0 ? _a : process.env });
77
- announceUpdate(ctx, notice);
77
+ announceUpdate(ctx, notice, { env: (_b = args.env) !== null && _b !== void 0 ? _b : process.env });
78
78
  // Fail before writing anything: the shell declares no dependencies of its
79
79
  // own, so a missing one would otherwise surface as an opaque Next
80
80
  // resolution error minutes later.
@@ -217,7 +217,7 @@ export async function runDev(ctx, args) {
217
217
  ? repo.packages
218
218
  .filter((p) => p.kind === 'integration')
219
219
  .map((p) => p.name)
220
- : loaded.integrations.map((i) => i.slug), projectDir: loaded.projectDir, turbopackRoot, harnessDir: shell.harnessDir, harnessVersion, previousVersion: shell.previousVersion, previousMarker: shell.previousMarker, stale: shell.stale, staleReasons: shell.staleReasons, buildCacheCleared: shell.buildCacheCleared, sourceGlobs: (_b = loaded.project.sourceGlobs) !== null && _b !== void 0 ? _b : [], created: shell.created, updated: shell.updated, unchanged: shell.unchanged, configBootstrapped: config.bootstrapped, configPath: config.configPath, gitignoreUpdated }), (notice ? { toolchain: notice } : {}));
220
+ : loaded.integrations.map((i) => i.slug), projectDir: loaded.projectDir, turbopackRoot, harnessDir: shell.harnessDir, harnessVersion, previousVersion: shell.previousVersion, previousMarker: shell.previousMarker, stale: shell.stale, staleReasons: shell.staleReasons, buildCacheCleared: shell.buildCacheCleared, sourceGlobs: (_c = loaded.project.sourceGlobs) !== null && _c !== void 0 ? _c : [], created: shell.created, updated: shell.updated, unchanged: shell.unchanged, configBootstrapped: config.bootstrapped, configPath: config.configPath, gitignoreUpdated }), (notice ? { toolchain: notice } : {}));
221
221
  if (exposed) {
222
222
  ctx.warn(`WARNING: --host ${host} exposes the harness beyond this machine. It ` +
223
223
  'has no authentication, and it renders your fixtures and — in live ' +
@@ -231,7 +231,7 @@ export async function runDev(ctx, args) {
231
231
  // exits would hang its tool call forever and it would never see the
232
232
  // envelope, so JSON mode scaffolds and reports the command instead of
233
233
  // running it. `--start` overrides; `--no-start` opts out in a terminal.
234
- const shouldStart = (_c = args.start) !== null && _c !== void 0 ? _c : !ctx.jsonMode;
234
+ const shouldStart = (_d = args.start) !== null && _d !== void 0 ? _d : !ctx.jsonMode;
235
235
  if (!shouldStart) {
236
236
  const reason = args.start === false ? 'no-start' : 'non-interactive';
237
237
  const note = reason === 'non-interactive'
@@ -262,7 +262,7 @@ export async function runDev(ctx, args) {
262
262
  // login and refreshed while the server runs; the harness never holds a token.
263
263
  const stopHostSnapshots = args.hostSnapshots === false
264
264
  ? () => undefined
265
- : startHostSnapshotRefresher(Object.assign({ ctx, env: (_d = args.env) !== null && _d !== void 0 ? _d : process.env, projectDir: loaded.projectDir }, (repo
265
+ : startHostSnapshotRefresher(Object.assign({ ctx, env: (_e = args.env) !== null && _e !== void 0 ? _e : process.env, projectDir: loaded.projectDir }, (repo
266
266
  ? {
267
267
  fallbackSource: sharedPackageSource(repo.packages.map((pkg) => pkg.dir)),
268
268
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAEL,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB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CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;YACnE,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;YACrC,OAAO,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;gBAC/D,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;eAAO,CAAC;QACP,GAAG,CAAC,GAAG,CACL,GAAG,CAAC,EAAE,CAAC,GAAG,CACR,iKAAiK,CAClK,CACF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { type SourceCatalog } from '@ekanos/integration-schema';\nimport {\n type RepoDiscovery,\n discoverRepo,\n isRepoRoot,\n} from '@ekanos/integration-schema/repo';\nimport { spawn } from 'node:child_process';\nimport * as path from 'node:path';\n\nimport {\n requireSession,\n resolveAuthEnvironment,\n refreshStoredSession,\n} from '../auth/session';\nimport { fetchSourceCatalog } from '../catalog-api';\nimport { assertHarnessCompatible } from '../compatibility';\nimport type { CliContext } from '../context';\nimport {\n type HarnessResolver,\n detectKind,\n loadHarnessResolver,\n readExperienceProject,\n writeSessionCatalog,\n} from '../dev-experience';\nimport { preconditionError, usageError } from '../errors';\nimport {\n BUILD_CACHE_DIR,\n HARNESS_DIR,\n HARNESS_PACKAGE,\n SHELL_REGISTRY_FILENAME,\n assertShellDirIsOurs,\n bootstrapHarnessConfig,\n ensureGitignoreEntry,\n missingDependencies,\n readInstalledHarness,\n scaffoldShell,\n} from '../harness-scaffold';\nimport {\n readSourceSelection,\n sharedPackageSource,\n startHostSnapshotRefresher,\n} from '../host-snapshots';\nimport {\n DUPLICATE_INSTANCE_HINT,\n describeDuplicates,\n scanLockfileInstances,\n} from '../lockfile-instances';\nimport {\n detectPackageManager,\n execArgs,\n formatCommand,\n installCommand,\n} from '../package-manager';\nimport {\n createOutputTail,\n findIgnoredBuilds,\n ignoredBuildsHint,\n} from '../pnpm-builds';\nimport { loadProject } from '../project';\nimport { resolveSourceTarget } from '../source-target';\nimport { displayPath } from '../ui';\nimport { announceUpdate, checkForUpdate } from '../update-notice';\nimport { findWorkspaceRoot } from '../workspace-root';\n\nexport interface DevArgs {\n /** Project directory (contains ekanos.json). Defaults to cwd. */\n dir: string;\n /** Port for the dev server. */\n port?: string;\n /**\n * Interface to bind. Defaults to loopback — see `resolveHost`. Anything\n * else is an explicit, warned-about decision to expose the harness.\n *\n * NOTE: unrelated to the Ekanos HOST the update notice checks against —\n * this is the local bind address for `next dev`, never an Ekanos origin.\n */\n host?: string;\n /** Rewrite every generated file even when its bytes already match. */\n force: boolean;\n /**\n * Explicit `--start` / `--no-start`. Undefined means \"decide from the\n * output mode\": a JSON caller is an agent or a pipe and must not be handed\n * a process that never exits.\n */\n start?: boolean;\n env?: Record<string, string | undefined>;\n /** Experience projects: an offline directory of contracts (`--contracts-dir`). */\n contractsDir?: string;\n /** Test seams. */\n loadResolver?: (projectDir: string) => Promise<HarnessResolver>;\n fetchCatalog?: () => Promise<SourceCatalog | null>;\n /**\n * Keep `.ekanos/catalog.json` and `.ekanos/publish-status.json` fresh while\n * the server runs. On by default; tests turn it off.\n */\n hostSnapshots?: boolean;\n}\n\nconst DEFAULT_PORT = 3100;\n\n/**\n * Loopback, NOT Next's default.\n *\n * `next dev` binds 0.0.0.0 unless told otherwise, so the harness would be\n * reachable by anyone on the same network — a coffee-shop Wi-Fi, a shared\n * office VLAN — while we printed \"http://localhost:3100\" and implied\n * otherwise. It renders a partner's integration with their fixtures and, in\n * live mode, whatever their vendor API returns; there is no auth in front of\n * any of it. Binding loopback by default costs a partner nothing and makes\n * exposure a thing they ask for.\n */\nconst DEFAULT_HOST = '127.0.0.1';\n\n/** Addresses that are only reachable from this machine. */\nconst LOOPBACK_HOSTS = new Set(['127.0.0.1', '::1', 'localhost']);\n\n/**\n * Set for the dev server when `--host` binds beyond loopback. The shell's\n * API routes (`@ekanos/harness/api`) refuse non-loopback `Host` headers\n * unless this is `1`: they hold the partner's local OAuth credentials and\n * run handlers on request, so exposing them has to be a decision — this one,\n * made after the warning below — rather than a side effect of the bind.\n */\nconst EXPOSED_ENV = 'EKANOS_HARNESS_EXPOSED';\n\n/** Where the harness generates, and reads, local dev credentials. */\nconst LOCAL_SECRETS_PATH = path.join('.ekanos', 'local-secrets.json');\n\n/**\n * `dev` — scaffold the local harness shell into the partner's project, then\n * run it with their own Next.\n *\n * The shape of this verb follows from one rule: we must be able to ship a\n * harness bugfix as an `@ekanos/harness` version bump that a partner picks up\n * with `pnpm up`, with zero edits to any file they own. So everything under\n * `.ekanos/` is generated, gitignored and rewritten freely, `harness.config.ts`\n * at the project root is written once and never touched again, and all actual\n * harness behaviour lives in the installed package.\n *\n * Two idempotency properties matter and are both tested: a second run produces\n * byte-identical files and rewrites nothing (so Next's watcher stays quiet),\n * and `.gitignore` never grows a duplicate line.\n */\nexport async function runDev(ctx: CliContext, args: DevArgs): Promise<number> {\n // At a repo root one harness serves every package; anywhere else the\n // project is a single integration or experience, exactly as before.\n const repo = isRepoRoot(path.resolve(args.dir))\n ? discoverRepo(path.resolve(args.dir))\n : null;\n const experience =\n repo === null && detectKind(path.resolve(args.dir)) === 'experience';\n const loaded: DevProject = repo\n ? repoProject(repo)\n : experience\n ? experienceProject(path.resolve(args.dir))\n : loadProject(args.dir);\n const port = parsePort(args.port);\n const host = parseHost(args.host);\n const exposed = !LOOPBACK_HOSTS.has(host);\n const pm = detectPackageManager(loaded.projectDir);\n\n const notice = await checkForUpdate({ env: args.env ?? process.env });\n announceUpdate(ctx, notice);\n\n // Fail before writing anything: the shell declares no dependencies of its\n // own, so a missing one would otherwise surface as an opaque Next\n // resolution error minutes later.\n const missing = missingDependencies(loaded.projectDir);\n if (missing.length > 0) {\n throw preconditionError(\n `${missing.length} package${missing.length === 1 ? '' : 's'} the ` +\n `harness needs ${missing.length === 1 ? 'is' : 'are'} not installed ` +\n `in ${loaded.projectDir}: ${missing.join(', ')}.`,\n `Run \"${installCommand(pm, missing)}\" in ${loaded.projectDir}, then ` +\n 're-run \"ekanos dev\".',\n );\n }\n\n warnOnDuplicateInstances(ctx, loaded.projectDir);\n\n const harness = readInstalledHarness(loaded.projectDir);\n const harnessVersion = harness?.version;\n if (!harnessVersion) {\n throw preconditionError(\n `${HARNESS_PACKAGE} is installed but declares no version.`,\n `Reinstall it with \"${installCommand(pm, [HARNESS_PACKAGE])}\" in ` +\n `${loaded.projectDir}, then re-run \"ekanos dev\".`,\n );\n }\n\n // The templates ship with the CLI and the code they import ships with the\n // harness, so a partner can upgrade one without the other. Name that\n // mismatch here rather than letting it surface later as a module-resolution\n // error inside a shell we cheerfully certified as current.\n assertHarnessCompatible({\n harnessVersion,\n harnessManifest: harness?.manifest,\n installHint: (spec) => installCommand(pm, [spec]),\n });\n\n // Validate the shell target BEFORE writing anything at all. Bootstrapping\n // harness.config.ts first and only then discovering that .ekanos/harness is\n // a file or someone else's tree would leave the project half-scaffolded.\n assertShellDirIsOurs(path.join(loaded.projectDir, HARNESS_DIR), args.force);\n\n // An experience has no integration to register, so it gets no\n // project-root registry: the shell carries its own empty one.\n if (repo) {\n for (const problem of repo.problems) {\n ctx.warn(`${problem.where}: ${problem.message}`);\n }\n }\n\n // A repo's integration packages each keep their own harness.config.ts; the\n // repo shell's registry imports them.\n const repoConfigs = repo\n ? repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) =>\n bootstrapHarnessConfig(pkg.dir, loadProject(pkg.dir).integrations),\n )\n : [];\n const config = repo\n ? {\n bootstrapped: repoConfigs.some((result) => result.bootstrapped),\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : experience\n ? {\n bootstrapped: false,\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : bootstrapHarnessConfig(loaded.projectDir, loaded.integrations);\n // A package inside a workspace resolves `next` and the harness from the\n // workspace root's node_modules (pnpm symlinks them there), so Turbopack's\n // root has to be that root, not the package.\n const turbopackRoot = findWorkspaceRoot(loaded.projectDir);\n if (turbopackRoot !== loaded.projectDir) {\n ctx.log(\n ctx.ui.dim(\n `Workspace package: Turbopack uses the workspace root ${displayPath(turbopackRoot, process.cwd())}.`,\n ),\n );\n }\n const shell = scaffoldShell({\n projectDir: loaded.projectDir,\n turbopackRoot,\n slug: loaded.primary.slug,\n harnessVersion,\n force: args.force,\n sourceGlobs: loaded.project.sourceGlobs,\n ...(experience\n ? { experienceEntry: readExperienceProject(loaded.projectDir).entry }\n : {}),\n ...(repo\n ? {\n repo: {\n integrations: repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) => ({ name: pkg.name, dir: pkg.relDir })),\n experiences: repo.packages\n .filter((pkg) => pkg.kind === 'experience')\n .map((pkg) => ({\n name: pkg.name,\n dir: pkg.relDir,\n entry: readExperienceProject(pkg.dir).entry,\n })),\n },\n }\n : {}),\n });\n const gitignoreUpdated = ensureGitignoreEntry(loaded.projectDir);\n\n if (shell.stale) {\n ctx.log(\n `Regenerating ${HARNESS_DIR} — ${shell.staleReasons.join('; ')}. ` +\n `Nothing you own changed; ${config.configPath} is untouched.`,\n );\n }\n if (shell.buildCacheCleared) {\n ctx.log(\n ` removed ${HARNESS_DIR}/${BUILD_CACHE_DIR} (Next's cache from the previous shell)`,\n );\n }\n\n if (config.bootstrapped) {\n ctx.log(` created harness.config.ts (yours — edit it, we never will)`);\n }\n for (const file of shell.created) ctx.log(` created ${HARNESS_DIR}/${file}`);\n for (const file of shell.updated) ctx.log(` updated ${HARNESS_DIR}/${file}`);\n if (gitignoreUpdated) ctx.log(' updated .gitignore (.ekanos/)');\n ctx.log(\n ` live-mode OAuth: the harness generates ${LOCAL_SECRETS_PATH} on first ` +\n 'use — fill it in and follow \"Local OAuth\" on the Activation surface.',\n );\n\n let integrations: ExperienceStartup | null = null;\n if (repo) {\n // Each experience package resolves its own integrations through the repo\n // server; the session catalog is shared from the repo root.\n writeSessionCatalog(\n loaded.projectDir,\n await tryFetchCatalog(ctx, args, loaded.projectDir),\n );\n for (const pkg of repo.packages) {\n ctx.log(` ${pkg.kind} ${pkg.name} v${pkg.version} (${pkg.relDir})`);\n }\n } else if (experience) {\n integrations = await resolveExperienceIntegrations(\n ctx,\n args,\n loaded.projectDir,\n );\n }\n\n // `--hostname` is passed ALWAYS, never left to Next's default, so the URL\n // we print is the URL that is actually served.\n const serverArgs = ['dev', '--port', String(port), '--hostname', host];\n const serverEnv: Record<string, string> = exposed\n ? { [EXPOSED_ENV]: '1' }\n : {};\n const command =\n (exposed ? `${EXPOSED_ENV}=1 ` : '') +\n formatCommand(pm.bin, execArgs(pm, 'next', serverArgs));\n const url = `http://${displayHost(host)}:${port}`;\n\n const scaffold = {\n kind: repo ? 'repo' : experience ? 'experience' : 'integration',\n ...(repo\n ? {\n packages: repo.packages.map((pkg) => ({\n name: pkg.name,\n kind: pkg.kind,\n dir: pkg.relDir,\n })),\n }\n : {}),\n ...(integrations\n ? {\n overrides: integrations.overrides,\n publishBlocked: integrations.overrides.length > 0,\n }\n : {}),\n slug: loaded.primary.slug,\n // An experience lists the integrations it depends on (provenance lines);\n // an integration project lists its own slugs.\n integrations: integrations\n ? integrations.lines\n : repo\n ? repo.packages\n .filter((p) => p.kind === 'integration')\n .map((p) => p.name)\n : loaded.integrations.map((i) => i.slug),\n projectDir: loaded.projectDir,\n turbopackRoot,\n harnessDir: shell.harnessDir,\n harnessVersion,\n previousVersion: shell.previousVersion,\n previousMarker: shell.previousMarker,\n stale: shell.stale,\n staleReasons: shell.staleReasons,\n buildCacheCleared: shell.buildCacheCleared,\n sourceGlobs: loaded.project.sourceGlobs ?? [],\n created: shell.created,\n updated: shell.updated,\n unchanged: shell.unchanged,\n configBootstrapped: config.bootstrapped,\n configPath: config.configPath,\n gitignoreUpdated,\n ...(notice ? { toolchain: notice } : {}),\n };\n\n if (exposed) {\n ctx.warn(\n `WARNING: --host ${host} exposes the harness beyond this machine. It ` +\n 'has no authentication, and it renders your fixtures and — in live ' +\n 'mode — real responses from your vendor API. Its API routes hold the ' +\n `client secret from ${LOCAL_SECRETS_PATH}, the tokens onTokens stored, ` +\n 'and run your handlers on request; they refuse non-loopback callers ' +\n `unless ${EXPOSED_ENV}=1, which this sets. Anyone who can reach ` +\n `${url} can read and run all of it. Omit --host to bind ${DEFAULT_HOST}.`,\n );\n }\n\n // A JSON caller is an agent or a pipe. Handing it a dev server that never\n // exits would hang its tool call forever and it would never see the\n // envelope, so JSON mode scaffolds and reports the command instead of\n // running it. `--start` overrides; `--no-start` opts out in a terminal.\n const shouldStart = args.start ?? !ctx.jsonMode;\n if (!shouldStart) {\n const reason = args.start === false ? 'no-start' : 'non-interactive';\n const note =\n reason === 'non-interactive'\n ? `Scaffolded only: the server was NOT started because this run is non-interactive (JSON output, a pipe, or an agent). Pass --start to run it, or run: ${command}`\n : `Scaffolded only (--no-start). Run: ${command}`;\n ctx.log(note);\n return ctx.succeed(\n {\n ...scaffold,\n server: {\n started: false,\n reason,\n note,\n command,\n url,\n port,\n host,\n exposed,\n },\n },\n ctx.ui.result({\n title: 'Harness ready',\n rows: [\n ['Directory', displayPath(shell.harnessDir, process.cwd())],\n ['URL', url],\n ['Started', 'no (scaffold only)'],\n ['Start', command],\n ],\n }),\n );\n }\n\n ctx.log(ctx.ui.dim(`Starting the harness on ${url} (${command})…`));\n // The catalog and publish status the harness shows, read with this CLI's\n // login and refreshed while the server runs; the harness never holds a token.\n const stopHostSnapshots =\n args.hostSnapshots === false\n ? () => undefined\n : startHostSnapshotRefresher({\n ctx,\n env: args.env ?? process.env,\n projectDir: loaded.projectDir,\n // A repo root names no Source of its own; its packages do, so a\n // repo whose packages all publish to one Source reads that one.\n ...(repo\n ? {\n fallbackSource: sharedPackageSource(\n repo.packages.map((pkg) => pkg.dir),\n ),\n }\n : {}),\n });\n const tail = createOutputTail();\n let exitCode: number;\n try {\n exitCode = await spawnServer({\n ctx,\n tail,\n bin: pm.bin,\n argv: execArgs(pm, 'next', serverArgs),\n cwd: shell.harnessDir,\n env: serverEnv,\n });\n } finally {\n stopHostSnapshots();\n }\n\n const data = {\n ...scaffold,\n server: { started: true, command, url, port, host, exposed, exitCode },\n };\n\n if (exitCode === 0) {\n return ctx.succeed(\n data,\n ctx.ui.result({ title: 'Harness stopped', rows: [['URL', url]] }),\n );\n }\n\n const ignoredBuilds = findIgnoredBuilds(tail.text());\n\n return ctx.failWith({\n code: 'dev_server_failed',\n message: `\"${command}\" exited with code ${exitCode}.`,\n hint:\n ignoredBuilds.length > 0\n ? ignoredBuildsHint(ignoredBuilds)\n : 'Read the Next output on stderr. If it cannot resolve @ekanos/harness ' +\n `or next, reinstall dependencies in ${loaded.projectDir}; if a route ` +\n `fails to compile, delete ${shell.harnessDir} and re-run \"ekanos dev\".`,\n // Transparent passthrough of Next's own exit code.\n exitCode,\n data,\n });\n}\n\n/**\n * Warn — never fail — when the lockfile resolves `@ekanos/sdk` or `@ekanos/ui`\n * more than once: the harness would mount its providers from one copy and the\n * project's hooks would read the other's, which throws at render time with a\n * message that points nowhere near the lockfile.\n */\nfunction warnOnDuplicateInstances(ctx: CliContext, projectDir: string): void {\n const scan = scanLockfileInstances(projectDir);\n if (scan.status === 'unreadable') {\n ctx.log(\n ctx.ui.dim(\n `Could not check ${scan.lockfile} for duplicate @ekanos/sdk copies: ${scan.reason}`,\n ),\n );\n return;\n }\n if (scan.status !== 'ok') return;\n const lines = describeDuplicates(scan.duplicates);\n if (lines.length === 0) return;\n\n ctx.warn(\n `WARNING: ${lines.join('; ')} (${scan.lockfile}). The harness and your ` +\n 'code may load different copies, and a provider from one is invisible ' +\n `to hooks from the other. ${DUPLICATE_INSTANCE_HINT}`,\n );\n}\n\nfunction spawnServer(params: {\n ctx: CliContext;\n tail: ReturnType<typeof createOutputTail>;\n bin: string;\n argv: string[];\n cwd: string;\n env: Record<string, string>;\n}): Promise<number> {\n return new Promise<number>((resolve, reject) => {\n const child = spawn(params.bin, params.argv, {\n cwd: params.cwd,\n env: { ...process.env, ...params.env },\n // stdin inherited so Next's own key handling works; stdout/stderr piped\n // so we can route them and keep OUR stdout reserved for the envelope.\n stdio: ['inherit', 'pipe', 'pipe'],\n });\n\n child.stdout?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n (params.ctx.jsonMode ? process.stderr : process.stdout).write(chunk);\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n process.stderr.write(chunk);\n });\n\n child.on('error', (error) => reject(error));\n child.on('close', (code) => resolve(code ?? 1));\n });\n}\n\n/**\n * The hostname to show a human. `127.0.0.1` is spelled `localhost` because\n * that is what people type; a wildcard bind is spelled `localhost` too, but\n * only after `exposed` has already been warned about — printing `0.0.0.0` as\n * a URL is not useful.\n */\nfunction displayHost(host: string): string {\n if (host === '127.0.0.1' || host === '0.0.0.0' || host === '::') {\n return 'localhost';\n }\n if (host === '::1') return '[::1]';\n return host;\n}\n\nfunction parseHost(raw: string | undefined): string {\n if (raw === undefined) return DEFAULT_HOST;\n\n const host = raw.trim();\n if (host.length === 0) {\n throw usageError(\n 'Invalid --host \"\".',\n `Pass an interface to bind, e.g. \"--host 0.0.0.0\" to expose the ` +\n `harness on your network, or omit it to bind ${DEFAULT_HOST}.`,\n );\n }\n return host;\n}\n\nfunction parsePort(raw: string | undefined): number {\n if (raw === undefined) return DEFAULT_PORT;\n\n const port = Number(raw);\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw usageError(\n `Invalid --port \"${raw}\".`,\n 'Pass an integer between 1 and 65535, e.g. \"--port 3100\".',\n );\n }\n return port;\n}\n\ninterface DevProject {\n projectDir: string;\n integrations: Array<{ slug: string; entry: string }>;\n primary: { slug: string };\n project: { sourceGlobs?: string[] | undefined };\n}\n\nfunction experienceProject(projectDir: string): DevProject {\n const { slug } = readExperienceProject(projectDir);\n return {\n projectDir,\n // An experience registers no integration of its own with the harness; its\n // integrations come from ekanos.json through /__ekanos/api.\n integrations: [],\n primary: { slug },\n project: {},\n };\n}\n\nfunction repoProject(repo: RepoDiscovery): DevProject {\n return {\n projectDir: repo.root,\n integrations: [],\n primary: { slug: path.basename(repo.root) },\n // The shell's stylesheet scans integrations/ already; experiences/ is the\n // other half of a repo.\n project: { sourceGlobs: ['experiences/**/*.{ts,tsx}'] },\n };\n}\n\ninterface ExperienceStartup {\n lines: string[];\n overrides: Array<{ integration: string; path: string; via: 'file' | 'env' }>;\n}\n\n/**\n * Resolve every integration with the harness the project installed, print where each\n * came from, and refuse to start when an integration cannot be served (a pin the\n * resolver cannot satisfy is a startup failure, not a blank widget later).\n */\nasync function resolveExperienceIntegrations(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<ExperienceStartup> {\n const env = args.env ?? process.env;\n const resolver = await (args.loadResolver ?? loadHarnessResolver)(projectDir);\n\n const catalog = await (\n args.fetchCatalog ?? (() => tryFetchCatalog(ctx, args, projectDir))\n )();\n writeSessionCatalog(projectDir, catalog);\n\n const contractsDir = args.contractsDir ?? env.EKANOS_CONTRACTS_DIR;\n const resolution = await resolver.resolveIntegrations({\n projectRoot: projectDir,\n env,\n ...(contractsDir ? { contractsDir: path.resolve(contractsDir) } : {}),\n catalog,\n });\n const lines = resolver.formatProvenanceLines(resolution as never);\n for (const line of lines) ctx.log(line);\n for (const notice of resolution.notices) ctx.warn(notice);\n\n if (resolution.errors.length > 0) {\n throw preconditionError(\n `${resolution.errors.length} integration${resolution.errors.length === 1 ? '' : 's'} could not be resolved: ${resolution.errors\n .map((e) => e.message)\n .join(' | ')}`,\n 'Fix the pin in ekanos.json (or run \"ekanos sync\"), or remove the bad override in ekanos.local.json, then re-run \"ekanos dev\".',\n );\n }\n return { lines, overrides: resolution.overrides };\n}\n\n/** The dev's Source catalog when a session exists; null (offline) otherwise. Never throws. */\nasync function tryFetchCatalog(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<SourceCatalog | null> {\n try {\n const env = resolveAuthEnvironment(\n ctx,\n undefined,\n args.env ?? process.env,\n {\n projectDir,\n },\n );\n let session = requireSession(env);\n // The harness's Source switcher, when it picked one; the host refuses a\n // Source the developer no longer holds a seat on.\n const resolved = await resolveSourceTarget(env, session, {\n source: readSourceSelection(projectDir) ?? undefined,\n dir: projectDir,\n });\n session = resolved.session;\n let result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n if (result.status === 'unauthorized') {\n session = await refreshStoredSession(env, session);\n result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n }\n return result.status === 'ok' ? result.catalog : null;\n } catch {\n ctx.log(\n ctx.ui.dim(\n 'No CLI session: integrations resolve offline (registry integrations fixtures-only, overrides unverified). Run \"ekanos login\" to enable develop-aware live mode.',\n ),\n );\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAEL,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,mB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M,QAAQ,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE;YACvD,MAAM,QAAE,mBAAmB,CAAC,UAAU,CAAC,mCAAI,SAAS;YACpD,GAAG,EAAE,UAAU;SAChB,CAAC,CAAC;QACH,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC3B,IAAI,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;YACnE,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;YACrC,OAAO,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;gBAC/D,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;eAAO,CAAC;QACP,GAAG,CAAC,GAAG,CACL,GAAG,CAAC,EAAE,CAAC,GAAG,CACR,iKAAiK,CAClK,CACF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { type SourceCatalog } from '@ekanos/integration-schema';\nimport {\n type RepoDiscovery,\n discoverRepo,\n isRepoRoot,\n} from '@ekanos/integration-schema/repo';\nimport { spawn } from 'node:child_process';\nimport * as path from 'node:path';\n\nimport {\n requireSession,\n resolveAuthEnvironment,\n refreshStoredSession,\n} from '../auth/session';\nimport { fetchSourceCatalog } from '../catalog-api';\nimport { assertHarnessCompatible } from '../compatibility';\nimport type { CliContext } from '../context';\nimport {\n type HarnessResolver,\n detectKind,\n loadHarnessResolver,\n readExperienceProject,\n writeSessionCatalog,\n} from '../dev-experience';\nimport { preconditionError, usageError } from '../errors';\nimport {\n BUILD_CACHE_DIR,\n HARNESS_DIR,\n HARNESS_PACKAGE,\n SHELL_REGISTRY_FILENAME,\n assertShellDirIsOurs,\n bootstrapHarnessConfig,\n ensureGitignoreEntry,\n missingDependencies,\n readInstalledHarness,\n scaffoldShell,\n} from '../harness-scaffold';\nimport {\n readSourceSelection,\n sharedPackageSource,\n startHostSnapshotRefresher,\n} from '../host-snapshots';\nimport {\n DUPLICATE_INSTANCE_HINT,\n describeDuplicates,\n scanLockfileInstances,\n} from '../lockfile-instances';\nimport {\n detectPackageManager,\n execArgs,\n formatCommand,\n installCommand,\n} from '../package-manager';\nimport {\n createOutputTail,\n findIgnoredBuilds,\n ignoredBuildsHint,\n} from '../pnpm-builds';\nimport { loadProject } from '../project';\nimport { resolveSourceTarget } from '../source-target';\nimport { displayPath } from '../ui';\nimport { announceUpdate, checkForUpdate } from '../update-notice';\nimport { findWorkspaceRoot } from '../workspace-root';\n\nexport interface DevArgs {\n /** Project directory (contains ekanos.json). Defaults to cwd. */\n dir: string;\n /** Port for the dev server. */\n port?: string;\n /**\n * Interface to bind. Defaults to loopback — see `resolveHost`. Anything\n * else is an explicit, warned-about decision to expose the harness.\n *\n * NOTE: unrelated to the Ekanos HOST the update notice checks against —\n * this is the local bind address for `next dev`, never an Ekanos origin.\n */\n host?: string;\n /** Rewrite every generated file even when its bytes already match. */\n force: boolean;\n /**\n * Explicit `--start` / `--no-start`. Undefined means \"decide from the\n * output mode\": a JSON caller is an agent or a pipe and must not be handed\n * a process that never exits.\n */\n start?: boolean;\n env?: Record<string, string | undefined>;\n /** Experience projects: an offline directory of contracts (`--contracts-dir`). */\n contractsDir?: string;\n /** Test seams. */\n loadResolver?: (projectDir: string) => Promise<HarnessResolver>;\n fetchCatalog?: () => Promise<SourceCatalog | null>;\n /**\n * Keep `.ekanos/catalog.json` and `.ekanos/publish-status.json` fresh while\n * the server runs. On by default; tests turn it off.\n */\n hostSnapshots?: boolean;\n}\n\nconst DEFAULT_PORT = 3100;\n\n/**\n * Loopback, NOT Next's default.\n *\n * `next dev` binds 0.0.0.0 unless told otherwise, so the harness would be\n * reachable by anyone on the same network — a coffee-shop Wi-Fi, a shared\n * office VLAN — while we printed \"http://localhost:3100\" and implied\n * otherwise. It renders a partner's integration with their fixtures and, in\n * live mode, whatever their vendor API returns; there is no auth in front of\n * any of it. Binding loopback by default costs a partner nothing and makes\n * exposure a thing they ask for.\n */\nconst DEFAULT_HOST = '127.0.0.1';\n\n/** Addresses that are only reachable from this machine. */\nconst LOOPBACK_HOSTS = new Set(['127.0.0.1', '::1', 'localhost']);\n\n/**\n * Set for the dev server when `--host` binds beyond loopback. The shell's\n * API routes (`@ekanos/harness/api`) refuse non-loopback `Host` headers\n * unless this is `1`: they hold the partner's local OAuth credentials and\n * run handlers on request, so exposing them has to be a decision — this one,\n * made after the warning below — rather than a side effect of the bind.\n */\nconst EXPOSED_ENV = 'EKANOS_HARNESS_EXPOSED';\n\n/** Where the harness generates, and reads, local dev credentials. */\nconst LOCAL_SECRETS_PATH = path.join('.ekanos', 'local-secrets.json');\n\n/**\n * `dev` — scaffold the local harness shell into the partner's project, then\n * run it with their own Next.\n *\n * The shape of this verb follows from one rule: we must be able to ship a\n * harness bugfix as an `@ekanos/harness` version bump that a partner picks up\n * with `pnpm up`, with zero edits to any file they own. So everything under\n * `.ekanos/` is generated, gitignored and rewritten freely, `harness.config.ts`\n * at the project root is written once and never touched again, and all actual\n * harness behaviour lives in the installed package.\n *\n * Two idempotency properties matter and are both tested: a second run produces\n * byte-identical files and rewrites nothing (so Next's watcher stays quiet),\n * and `.gitignore` never grows a duplicate line.\n */\nexport async function runDev(ctx: CliContext, args: DevArgs): Promise<number> {\n // At a repo root one harness serves every package; anywhere else the\n // project is a single integration or experience, exactly as before.\n const repo = isRepoRoot(path.resolve(args.dir))\n ? discoverRepo(path.resolve(args.dir))\n : null;\n const experience =\n repo === null && detectKind(path.resolve(args.dir)) === 'experience';\n const loaded: DevProject = repo\n ? repoProject(repo)\n : experience\n ? experienceProject(path.resolve(args.dir))\n : loadProject(args.dir);\n const port = parsePort(args.port);\n const host = parseHost(args.host);\n const exposed = !LOOPBACK_HOSTS.has(host);\n const pm = detectPackageManager(loaded.projectDir);\n\n const notice = await checkForUpdate({ env: args.env ?? process.env });\n announceUpdate(ctx, notice, { env: args.env ?? process.env });\n\n // Fail before writing anything: the shell declares no dependencies of its\n // own, so a missing one would otherwise surface as an opaque Next\n // resolution error minutes later.\n const missing = missingDependencies(loaded.projectDir);\n if (missing.length > 0) {\n throw preconditionError(\n `${missing.length} package${missing.length === 1 ? '' : 's'} the ` +\n `harness needs ${missing.length === 1 ? 'is' : 'are'} not installed ` +\n `in ${loaded.projectDir}: ${missing.join(', ')}.`,\n `Run \"${installCommand(pm, missing)}\" in ${loaded.projectDir}, then ` +\n 're-run \"ekanos dev\".',\n );\n }\n\n warnOnDuplicateInstances(ctx, loaded.projectDir);\n\n const harness = readInstalledHarness(loaded.projectDir);\n const harnessVersion = harness?.version;\n if (!harnessVersion) {\n throw preconditionError(\n `${HARNESS_PACKAGE} is installed but declares no version.`,\n `Reinstall it with \"${installCommand(pm, [HARNESS_PACKAGE])}\" in ` +\n `${loaded.projectDir}, then re-run \"ekanos dev\".`,\n );\n }\n\n // The templates ship with the CLI and the code they import ships with the\n // harness, so a partner can upgrade one without the other. Name that\n // mismatch here rather than letting it surface later as a module-resolution\n // error inside a shell we cheerfully certified as current.\n assertHarnessCompatible({\n harnessVersion,\n harnessManifest: harness?.manifest,\n installHint: (spec) => installCommand(pm, [spec]),\n });\n\n // Validate the shell target BEFORE writing anything at all. Bootstrapping\n // harness.config.ts first and only then discovering that .ekanos/harness is\n // a file or someone else's tree would leave the project half-scaffolded.\n assertShellDirIsOurs(path.join(loaded.projectDir, HARNESS_DIR), args.force);\n\n // An experience has no integration to register, so it gets no\n // project-root registry: the shell carries its own empty one.\n if (repo) {\n for (const problem of repo.problems) {\n ctx.warn(`${problem.where}: ${problem.message}`);\n }\n }\n\n // A repo's integration packages each keep their own harness.config.ts; the\n // repo shell's registry imports them.\n const repoConfigs = repo\n ? repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) =>\n bootstrapHarnessConfig(pkg.dir, loadProject(pkg.dir).integrations),\n )\n : [];\n const config = repo\n ? {\n bootstrapped: repoConfigs.some((result) => result.bootstrapped),\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : experience\n ? {\n bootstrapped: false,\n configPath: path.join(\n loaded.projectDir,\n HARNESS_DIR,\n SHELL_REGISTRY_FILENAME,\n ),\n }\n : bootstrapHarnessConfig(loaded.projectDir, loaded.integrations);\n // A package inside a workspace resolves `next` and the harness from the\n // workspace root's node_modules (pnpm symlinks them there), so Turbopack's\n // root has to be that root, not the package.\n const turbopackRoot = findWorkspaceRoot(loaded.projectDir);\n if (turbopackRoot !== loaded.projectDir) {\n ctx.log(\n ctx.ui.dim(\n `Workspace package: Turbopack uses the workspace root ${displayPath(turbopackRoot, process.cwd())}.`,\n ),\n );\n }\n const shell = scaffoldShell({\n projectDir: loaded.projectDir,\n turbopackRoot,\n slug: loaded.primary.slug,\n harnessVersion,\n force: args.force,\n sourceGlobs: loaded.project.sourceGlobs,\n ...(experience\n ? { experienceEntry: readExperienceProject(loaded.projectDir).entry }\n : {}),\n ...(repo\n ? {\n repo: {\n integrations: repo.packages\n .filter((pkg) => pkg.kind === 'integration')\n .map((pkg) => ({ name: pkg.name, dir: pkg.relDir })),\n experiences: repo.packages\n .filter((pkg) => pkg.kind === 'experience')\n .map((pkg) => ({\n name: pkg.name,\n dir: pkg.relDir,\n entry: readExperienceProject(pkg.dir).entry,\n })),\n },\n }\n : {}),\n });\n const gitignoreUpdated = ensureGitignoreEntry(loaded.projectDir);\n\n if (shell.stale) {\n ctx.log(\n `Regenerating ${HARNESS_DIR} — ${shell.staleReasons.join('; ')}. ` +\n `Nothing you own changed; ${config.configPath} is untouched.`,\n );\n }\n if (shell.buildCacheCleared) {\n ctx.log(\n ` removed ${HARNESS_DIR}/${BUILD_CACHE_DIR} (Next's cache from the previous shell)`,\n );\n }\n\n if (config.bootstrapped) {\n ctx.log(` created harness.config.ts (yours — edit it, we never will)`);\n }\n for (const file of shell.created) ctx.log(` created ${HARNESS_DIR}/${file}`);\n for (const file of shell.updated) ctx.log(` updated ${HARNESS_DIR}/${file}`);\n if (gitignoreUpdated) ctx.log(' updated .gitignore (.ekanos/)');\n ctx.log(\n ` live-mode OAuth: the harness generates ${LOCAL_SECRETS_PATH} on first ` +\n 'use — fill it in and follow \"Local OAuth\" on the Activation surface.',\n );\n\n let integrations: ExperienceStartup | null = null;\n if (repo) {\n // Each experience package resolves its own integrations through the repo\n // server; the session catalog is shared from the repo root.\n writeSessionCatalog(\n loaded.projectDir,\n await tryFetchCatalog(ctx, args, loaded.projectDir),\n );\n for (const pkg of repo.packages) {\n ctx.log(` ${pkg.kind} ${pkg.name} v${pkg.version} (${pkg.relDir})`);\n }\n } else if (experience) {\n integrations = await resolveExperienceIntegrations(\n ctx,\n args,\n loaded.projectDir,\n );\n }\n\n // `--hostname` is passed ALWAYS, never left to Next's default, so the URL\n // we print is the URL that is actually served.\n const serverArgs = ['dev', '--port', String(port), '--hostname', host];\n const serverEnv: Record<string, string> = exposed\n ? { [EXPOSED_ENV]: '1' }\n : {};\n const command =\n (exposed ? `${EXPOSED_ENV}=1 ` : '') +\n formatCommand(pm.bin, execArgs(pm, 'next', serverArgs));\n const url = `http://${displayHost(host)}:${port}`;\n\n const scaffold = {\n kind: repo ? 'repo' : experience ? 'experience' : 'integration',\n ...(repo\n ? {\n packages: repo.packages.map((pkg) => ({\n name: pkg.name,\n kind: pkg.kind,\n dir: pkg.relDir,\n })),\n }\n : {}),\n ...(integrations\n ? {\n overrides: integrations.overrides,\n publishBlocked: integrations.overrides.length > 0,\n }\n : {}),\n slug: loaded.primary.slug,\n // An experience lists the integrations it depends on (provenance lines);\n // an integration project lists its own slugs.\n integrations: integrations\n ? integrations.lines\n : repo\n ? repo.packages\n .filter((p) => p.kind === 'integration')\n .map((p) => p.name)\n : loaded.integrations.map((i) => i.slug),\n projectDir: loaded.projectDir,\n turbopackRoot,\n harnessDir: shell.harnessDir,\n harnessVersion,\n previousVersion: shell.previousVersion,\n previousMarker: shell.previousMarker,\n stale: shell.stale,\n staleReasons: shell.staleReasons,\n buildCacheCleared: shell.buildCacheCleared,\n sourceGlobs: loaded.project.sourceGlobs ?? [],\n created: shell.created,\n updated: shell.updated,\n unchanged: shell.unchanged,\n configBootstrapped: config.bootstrapped,\n configPath: config.configPath,\n gitignoreUpdated,\n ...(notice ? { toolchain: notice } : {}),\n };\n\n if (exposed) {\n ctx.warn(\n `WARNING: --host ${host} exposes the harness beyond this machine. It ` +\n 'has no authentication, and it renders your fixtures and — in live ' +\n 'mode — real responses from your vendor API. Its API routes hold the ' +\n `client secret from ${LOCAL_SECRETS_PATH}, the tokens onTokens stored, ` +\n 'and run your handlers on request; they refuse non-loopback callers ' +\n `unless ${EXPOSED_ENV}=1, which this sets. Anyone who can reach ` +\n `${url} can read and run all of it. Omit --host to bind ${DEFAULT_HOST}.`,\n );\n }\n\n // A JSON caller is an agent or a pipe. Handing it a dev server that never\n // exits would hang its tool call forever and it would never see the\n // envelope, so JSON mode scaffolds and reports the command instead of\n // running it. `--start` overrides; `--no-start` opts out in a terminal.\n const shouldStart = args.start ?? !ctx.jsonMode;\n if (!shouldStart) {\n const reason = args.start === false ? 'no-start' : 'non-interactive';\n const note =\n reason === 'non-interactive'\n ? `Scaffolded only: the server was NOT started because this run is non-interactive (JSON output, a pipe, or an agent). Pass --start to run it, or run: ${command}`\n : `Scaffolded only (--no-start). Run: ${command}`;\n ctx.log(note);\n return ctx.succeed(\n {\n ...scaffold,\n server: {\n started: false,\n reason,\n note,\n command,\n url,\n port,\n host,\n exposed,\n },\n },\n ctx.ui.result({\n title: 'Harness ready',\n rows: [\n ['Directory', displayPath(shell.harnessDir, process.cwd())],\n ['URL', url],\n ['Started', 'no (scaffold only)'],\n ['Start', command],\n ],\n }),\n );\n }\n\n ctx.log(ctx.ui.dim(`Starting the harness on ${url} (${command})…`));\n // The catalog and publish status the harness shows, read with this CLI's\n // login and refreshed while the server runs; the harness never holds a token.\n const stopHostSnapshots =\n args.hostSnapshots === false\n ? () => undefined\n : startHostSnapshotRefresher({\n ctx,\n env: args.env ?? process.env,\n projectDir: loaded.projectDir,\n // A repo root names no Source of its own; its packages do, so a\n // repo whose packages all publish to one Source reads that one.\n ...(repo\n ? {\n fallbackSource: sharedPackageSource(\n repo.packages.map((pkg) => pkg.dir),\n ),\n }\n : {}),\n });\n const tail = createOutputTail();\n let exitCode: number;\n try {\n exitCode = await spawnServer({\n ctx,\n tail,\n bin: pm.bin,\n argv: execArgs(pm, 'next', serverArgs),\n cwd: shell.harnessDir,\n env: serverEnv,\n });\n } finally {\n stopHostSnapshots();\n }\n\n const data = {\n ...scaffold,\n server: { started: true, command, url, port, host, exposed, exitCode },\n };\n\n if (exitCode === 0) {\n return ctx.succeed(\n data,\n ctx.ui.result({ title: 'Harness stopped', rows: [['URL', url]] }),\n );\n }\n\n const ignoredBuilds = findIgnoredBuilds(tail.text());\n\n return ctx.failWith({\n code: 'dev_server_failed',\n message: `\"${command}\" exited with code ${exitCode}.`,\n hint:\n ignoredBuilds.length > 0\n ? ignoredBuildsHint(ignoredBuilds)\n : 'Read the Next output on stderr. If it cannot resolve @ekanos/harness ' +\n `or next, reinstall dependencies in ${loaded.projectDir}; if a route ` +\n `fails to compile, delete ${shell.harnessDir} and re-run \"ekanos dev\".`,\n // Transparent passthrough of Next's own exit code.\n exitCode,\n data,\n });\n}\n\n/**\n * Warn — never fail — when the lockfile resolves `@ekanos/sdk` or `@ekanos/ui`\n * more than once: the harness would mount its providers from one copy and the\n * project's hooks would read the other's, which throws at render time with a\n * message that points nowhere near the lockfile.\n */\nfunction warnOnDuplicateInstances(ctx: CliContext, projectDir: string): void {\n const scan = scanLockfileInstances(projectDir);\n if (scan.status === 'unreadable') {\n ctx.log(\n ctx.ui.dim(\n `Could not check ${scan.lockfile} for duplicate @ekanos/sdk copies: ${scan.reason}`,\n ),\n );\n return;\n }\n if (scan.status !== 'ok') return;\n const lines = describeDuplicates(scan.duplicates);\n if (lines.length === 0) return;\n\n ctx.warn(\n `WARNING: ${lines.join('; ')} (${scan.lockfile}). The harness and your ` +\n 'code may load different copies, and a provider from one is invisible ' +\n `to hooks from the other. ${DUPLICATE_INSTANCE_HINT}`,\n );\n}\n\nfunction spawnServer(params: {\n ctx: CliContext;\n tail: ReturnType<typeof createOutputTail>;\n bin: string;\n argv: string[];\n cwd: string;\n env: Record<string, string>;\n}): Promise<number> {\n return new Promise<number>((resolve, reject) => {\n const child = spawn(params.bin, params.argv, {\n cwd: params.cwd,\n env: { ...process.env, ...params.env },\n // stdin inherited so Next's own key handling works; stdout/stderr piped\n // so we can route them and keep OUR stdout reserved for the envelope.\n stdio: ['inherit', 'pipe', 'pipe'],\n });\n\n child.stdout?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n (params.ctx.jsonMode ? process.stderr : process.stdout).write(chunk);\n });\n child.stderr?.on('data', (chunk: Buffer) => {\n params.tail.push(chunk);\n process.stderr.write(chunk);\n });\n\n child.on('error', (error) => reject(error));\n child.on('close', (code) => resolve(code ?? 1));\n });\n}\n\n/**\n * The hostname to show a human. `127.0.0.1` is spelled `localhost` because\n * that is what people type; a wildcard bind is spelled `localhost` too, but\n * only after `exposed` has already been warned about — printing `0.0.0.0` as\n * a URL is not useful.\n */\nfunction displayHost(host: string): string {\n if (host === '127.0.0.1' || host === '0.0.0.0' || host === '::') {\n return 'localhost';\n }\n if (host === '::1') return '[::1]';\n return host;\n}\n\nfunction parseHost(raw: string | undefined): string {\n if (raw === undefined) return DEFAULT_HOST;\n\n const host = raw.trim();\n if (host.length === 0) {\n throw usageError(\n 'Invalid --host \"\".',\n `Pass an interface to bind, e.g. \"--host 0.0.0.0\" to expose the ` +\n `harness on your network, or omit it to bind ${DEFAULT_HOST}.`,\n );\n }\n return host;\n}\n\nfunction parsePort(raw: string | undefined): number {\n if (raw === undefined) return DEFAULT_PORT;\n\n const port = Number(raw);\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw usageError(\n `Invalid --port \"${raw}\".`,\n 'Pass an integer between 1 and 65535, e.g. \"--port 3100\".',\n );\n }\n return port;\n}\n\ninterface DevProject {\n projectDir: string;\n integrations: Array<{ slug: string; entry: string }>;\n primary: { slug: string };\n project: { sourceGlobs?: string[] | undefined };\n}\n\nfunction experienceProject(projectDir: string): DevProject {\n const { slug } = readExperienceProject(projectDir);\n return {\n projectDir,\n // An experience registers no integration of its own with the harness; its\n // integrations come from ekanos.json through /__ekanos/api.\n integrations: [],\n primary: { slug },\n project: {},\n };\n}\n\nfunction repoProject(repo: RepoDiscovery): DevProject {\n return {\n projectDir: repo.root,\n integrations: [],\n primary: { slug: path.basename(repo.root) },\n // The shell's stylesheet scans integrations/ already; experiences/ is the\n // other half of a repo.\n project: { sourceGlobs: ['experiences/**/*.{ts,tsx}'] },\n };\n}\n\ninterface ExperienceStartup {\n lines: string[];\n overrides: Array<{ integration: string; path: string; via: 'file' | 'env' }>;\n}\n\n/**\n * Resolve every integration with the harness the project installed, print where each\n * came from, and refuse to start when an integration cannot be served (a pin the\n * resolver cannot satisfy is a startup failure, not a blank widget later).\n */\nasync function resolveExperienceIntegrations(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<ExperienceStartup> {\n const env = args.env ?? process.env;\n const resolver = await (args.loadResolver ?? loadHarnessResolver)(projectDir);\n\n const catalog = await (\n args.fetchCatalog ?? (() => tryFetchCatalog(ctx, args, projectDir))\n )();\n writeSessionCatalog(projectDir, catalog);\n\n const contractsDir = args.contractsDir ?? env.EKANOS_CONTRACTS_DIR;\n const resolution = await resolver.resolveIntegrations({\n projectRoot: projectDir,\n env,\n ...(contractsDir ? { contractsDir: path.resolve(contractsDir) } : {}),\n catalog,\n });\n const lines = resolver.formatProvenanceLines(resolution as never);\n for (const line of lines) ctx.log(line);\n for (const notice of resolution.notices) ctx.warn(notice);\n\n if (resolution.errors.length > 0) {\n throw preconditionError(\n `${resolution.errors.length} integration${resolution.errors.length === 1 ? '' : 's'} could not be resolved: ${resolution.errors\n .map((e) => e.message)\n .join(' | ')}`,\n 'Fix the pin in ekanos.json (or run \"ekanos sync\"), or remove the bad override in ekanos.local.json, then re-run \"ekanos dev\".',\n );\n }\n return { lines, overrides: resolution.overrides };\n}\n\n/** The dev's Source catalog when a session exists; null (offline) otherwise. Never throws. */\nasync function tryFetchCatalog(\n ctx: CliContext,\n args: DevArgs,\n projectDir: string,\n): Promise<SourceCatalog | null> {\n try {\n const env = resolveAuthEnvironment(\n ctx,\n undefined,\n args.env ?? process.env,\n {\n projectDir,\n },\n );\n let session = requireSession(env);\n // The harness's Source switcher, when it picked one; the host refuses a\n // Source the developer no longer holds a seat on.\n const resolved = await resolveSourceTarget(env, session, {\n source: readSourceSelection(projectDir) ?? undefined,\n dir: projectDir,\n });\n session = resolved.session;\n let result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n if (result.status === 'unauthorized') {\n session = await refreshStoredSession(env, session);\n result = await fetchSourceCatalog(env.host, session.accessToken, {\n source: resolved.source,\n });\n }\n return result.status === 'ok' ? result.catalog : null;\n } catch {\n ctx.log(\n ctx.ui.dim(\n 'No CLI session: integrations resolve offline (registry integrations fixtures-only, overrides unverified). Run \"ekanos login\" to enable develop-aware live mode.',\n ),\n );\n return null;\n }\n}\n"]}
@@ -337,7 +337,7 @@ export async function prepareIntegrationSubmission(ctx, args) {
337
337
  host: env.host,
338
338
  session,
339
339
  });
340
- announceUpdate(ctx, notice);
340
+ announceUpdate(ctx, notice, { env: args.env });
341
341
  // The host would reject a build from a CLI it has declared unsupported
342
342
  // anyway (see the wire contract in `toolchain-api.ts`) — refuse here with a
343
343
  // hint naming the fix, rather than let the submission round-trip fail with