@ekanos/cli 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +13 -13
  2. package/dist/auth/credential-store.d.ts +1 -1
  3. package/dist/auth/credential-store.js +3 -2
  4. package/dist/auth/credential-store.js.map +1 -1
  5. package/dist/auth/device-flow.d.ts +1 -1
  6. package/dist/auth/device-flow.js +11 -10
  7. package/dist/auth/device-flow.js.map +1 -1
  8. package/dist/auth/{fusion-api.d.ts → ekanos-api.d.ts} +9 -9
  9. package/dist/auth/{fusion-api.js → ekanos-api.js} +28 -28
  10. package/dist/auth/ekanos-api.js.map +1 -0
  11. package/dist/auth/session.d.ts +5 -5
  12. package/dist/auth/session.js +21 -11
  13. package/dist/auth/session.js.map +1 -1
  14. package/dist/banner.d.ts +1 -1
  15. package/dist/banner.js +4 -13
  16. package/dist/banner.js.map +1 -1
  17. package/dist/bin.js.map +1 -1
  18. package/dist/commands/dev.d.ts +2 -2
  19. package/dist/commands/dev.js +11 -3
  20. package/dist/commands/dev.js.map +1 -1
  21. package/dist/commands/init.js +72 -30
  22. package/dist/commands/init.js.map +1 -1
  23. package/dist/commands/login.d.ts +1 -1
  24. package/dist/commands/login.js +28 -17
  25. package/dist/commands/login.js.map +1 -1
  26. package/dist/commands/logout.js +31 -5
  27. package/dist/commands/logout.js.map +1 -1
  28. package/dist/commands/publish.d.ts +2 -2
  29. package/dist/commands/publish.js +28 -15
  30. package/dist/commands/publish.js.map +1 -1
  31. package/dist/commands/sources.js +26 -16
  32. package/dist/commands/sources.js.map +1 -1
  33. package/dist/commands/status.d.ts +1 -1
  34. package/dist/commands/status.js +56 -45
  35. package/dist/commands/status.js.map +1 -1
  36. package/dist/commands/test.js +15 -5
  37. package/dist/commands/test.js.map +1 -1
  38. package/dist/commands/upgrade.js +86 -54
  39. package/dist/commands/upgrade.js.map +1 -1
  40. package/dist/commands/use.js +11 -3
  41. package/dist/commands/use.js.map +1 -1
  42. package/dist/commands/validate.js +21 -3
  43. package/dist/commands/validate.js.map +1 -1
  44. package/dist/commands/whoami.d.ts +1 -1
  45. package/dist/commands/whoami.js +17 -7
  46. package/dist/commands/whoami.js.map +1 -1
  47. package/dist/compatibility.js.map +1 -1
  48. package/dist/context.js +10 -3
  49. package/dist/context.js.map +1 -1
  50. package/dist/delegate.js.map +1 -1
  51. package/dist/did-you-mean.js +26 -15
  52. package/dist/did-you-mean.js.map +1 -1
  53. package/dist/exit-codes.d.ts +10 -10
  54. package/dist/findings-renderer.js +6 -4
  55. package/dist/findings-renderer.js.map +1 -1
  56. package/dist/generated/fa-free-names.d.ts +1 -1
  57. package/dist/generated/fa-free-names.js +1 -1
  58. package/dist/generated/fa-free-names.js.map +1 -1
  59. package/dist/harness-scaffold.d.ts +1 -1
  60. package/dist/harness-scaffold.js +4 -2
  61. package/dist/harness-scaffold.js.map +1 -1
  62. package/dist/icon-findings.d.ts +1 -1
  63. package/dist/icon-findings.js +2 -2
  64. package/dist/icon-findings.js.map +1 -1
  65. package/dist/index.js +2 -2
  66. package/dist/index.js.map +1 -1
  67. package/dist/merge-manifest.js.map +1 -1
  68. package/dist/pack.js +1 -1
  69. package/dist/pack.js.map +1 -1
  70. package/dist/project-checks.js.map +1 -1
  71. package/dist/project.d.ts +7 -84
  72. package/dist/project.js +3 -3
  73. package/dist/project.js.map +1 -1
  74. package/dist/publish-api.d.ts +5 -5
  75. package/dist/publish-api.js +27 -33
  76. package/dist/publish-api.js.map +1 -1
  77. package/dist/safe-fs.js.map +1 -1
  78. package/dist/schema-skew.js.map +1 -1
  79. package/dist/source-locator.js.map +1 -1
  80. package/dist/sources-api.d.ts +3 -3
  81. package/dist/sources-api.js +11 -14
  82. package/dist/sources-api.js.map +1 -1
  83. package/dist/templates.js.map +1 -1
  84. package/dist/test-report.js.map +1 -1
  85. package/dist/toolchain-api.d.ts +4 -4
  86. package/dist/toolchain-api.js +1 -1
  87. package/dist/toolchain-api.js.map +1 -1
  88. package/dist/toolchain-resolve.js.map +1 -1
  89. package/dist/toolchain.d.ts +5 -5
  90. package/dist/ui.d.ts +36 -0
  91. package/dist/ui.js +79 -10
  92. package/dist/ui.js.map +1 -1
  93. package/dist/update-notice.d.ts +1 -1
  94. package/dist/update-notice.js.map +1 -1
  95. package/dist/validate-findings.js.map +1 -1
  96. package/dist/wizard.js.map +1 -1
  97. package/package.json +15 -20
  98. package/templates/AGENTS.md.tmpl +13 -8
  99. package/templates/CLAUDE.md.tmpl +1 -1
  100. package/templates/claude-skill.md.tmpl +2 -2
  101. package/templates/harness/next.config.mjs.tmpl +1 -1
  102. package/templates/package.json.tmpl +6 -5
  103. package/templates/pnpm-workspace.yaml.tmpl +8 -0
  104. package/templates/skills/build-integration/SKILL.md +3 -3
  105. package/templates/skills/build-integration/references/api-wiring.md +2 -2
  106. package/templates/skills/build-integration/references/widget-design.md +1 -1
  107. package/dist/auth/fusion-api.js.map +0 -1
package/dist/ui.d.ts CHANGED
@@ -31,9 +31,27 @@ export interface Glyphs {
31
31
  err: string;
32
32
  warn: string;
33
33
  info: string;
34
+ /** The result-block title marker — the same `◇` the clack wizard draws. */
35
+ step: string;
34
36
  }
35
37
  /** One row of `ui.keyValue`. */
36
38
  export type KeyValueRow = readonly [key: string, value: string];
39
+ /** One row of `ui.result`: a dim label and a value, or several values stacked under one label. */
40
+ export type ResultRow = readonly [
41
+ label: string,
42
+ value: string | readonly string[]
43
+ ];
44
+ export type ResultTone = 'ok' | 'warn' | 'err';
45
+ /** What every command's successful human-mode ending is built from. */
46
+ export interface ResultBlock {
47
+ /** The one-line outcome: "Signed in", "Submitted", … Title case, no verb prefix, no period. */
48
+ title: string;
49
+ /** Defaults to `ok` (green marker). `warn` for a result that succeeded but needs attention. */
50
+ tone?: ResultTone;
51
+ rows?: readonly ResultRow[];
52
+ /** Secondary prose, dim, set apart from the rows by a blank line. Keep it short. */
53
+ notes?: readonly string[];
54
+ }
37
55
  export interface CodeframeOptions {
38
56
  /** Not rendered directly — callers already print `file:line` above/around this. Kept for future use and self-documentation at call sites. */
39
57
  file?: string;
@@ -58,6 +76,13 @@ export interface Ui {
58
76
  section(title: string): string;
59
77
  /** Aligned `key value` rows, 2-space gutter, keys dimmed. */
60
78
  keyValue(rows: readonly KeyValueRow[]): string;
79
+ /**
80
+ * THE success renderer: a marker + bold title line, then aligned
81
+ * `label value` rows indented under it, labels dim. A multi-value row
82
+ * stacks its values under one label. Plain strings throughout, so a
83
+ * monochrome terminal gets exactly the same layout minus the color.
84
+ */
85
+ result(block: ResultBlock): string;
61
86
  /** A header-having, left/right-aligned table with no box-drawing. */
62
87
  table(headers: readonly string[], rows: readonly (readonly (string | number)[])[]): string;
63
88
  /** A `→ ` prefixed, accent-colored hint line. */
@@ -73,3 +98,14 @@ export interface Ui {
73
98
  badge(text: string, kind?: BadgeKind): string;
74
99
  }
75
100
  export declare function createUi(probe: ColorProbe): Ui;
101
+ /**
102
+ * A host URL as a person would say it: `https://x.site` -> `x.site`. The
103
+ * scheme only stays when it carries information (plain `http://`, as in a
104
+ * local sandbox) or when the string is not a URL at all.
105
+ */
106
+ export declare function shortHost(host: string): string;
107
+ /** A path relative to `cwd` when it sits inside it, `~/…` under home, else as given. */
108
+ export declare function displayPath(target: string, cwd: string, home?: string | undefined): string;
109
+ /** `412ms` below a second, `1.2s` above, `2m 05s` past a minute. */
110
+ export declare function formatDuration(ms: number): string;
111
+ export declare function pluralize(count: number, noun: string): string;
package/dist/ui.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as path from 'node:path';
1
2
  import pc from 'picocolors';
2
3
  /**
3
4
  * The one color-on/off decision for the whole CLI. True only when the
@@ -33,8 +34,20 @@ function unicodeSupported(env) {
33
34
  return false;
34
35
  return true;
35
36
  }
36
- const UNICODE_GLYPHS = { ok: '✓', err: '✖', warn: '▲', info: '●' };
37
- const ASCII_GLYPHS = { ok: 'ok', err: 'x', warn: '!', info: '*' };
37
+ const UNICODE_GLYPHS = {
38
+ ok: '✓',
39
+ err: '✖',
40
+ warn: '▲',
41
+ info: '●',
42
+ step: '◇',
43
+ };
44
+ const ASCII_GLYPHS = {
45
+ ok: 'ok',
46
+ err: 'x',
47
+ warn: '!',
48
+ info: '*',
49
+ step: 'o',
50
+ };
38
51
  /** Right-pad (left-align) a cell to `width`, ignoring color codes in length math is the CALLER's job — pad before coloring, never after. */
39
52
  function padCell(text, width, align) {
40
53
  return align === 'right' ? text.padStart(width) : text.padEnd(width);
@@ -67,6 +80,24 @@ export function createUi(probe) {
67
80
  .map(([key, value]) => `${dim(key.padEnd(keyWidth))} ${value}`)
68
81
  .join('\n');
69
82
  },
83
+ result(block) {
84
+ var _a, _b;
85
+ const paint = { ok, warn, err }[(_a = block.tone) !== null && _a !== void 0 ? _a : 'ok'];
86
+ const lines = [`${paint(glyphs.step)} ${bold(block.title)}`];
87
+ const rows = (_b = block.rows) !== null && _b !== void 0 ? _b : [];
88
+ const labelWidth = Math.max(0, ...rows.map(([label]) => label.length));
89
+ for (const [label, value] of rows) {
90
+ const values = typeof value === 'string' ? [value] : value;
91
+ values.forEach((line, index) => {
92
+ const gutter = (index === 0 ? label : '').padEnd(labelWidth);
93
+ lines.push(` ${dim(gutter)} ${line}`.trimEnd());
94
+ });
95
+ }
96
+ if (block.notes && block.notes.length > 0) {
97
+ lines.push('', ...block.notes.map((note) => ` ${dim(note)}`));
98
+ }
99
+ return lines.join('\n');
100
+ },
70
101
  table(headers, rows) {
71
102
  const columnCount = headers.length;
72
103
  const isNumeric = (value) => typeof value === 'number' ||
@@ -74,15 +105,9 @@ export function createUi(probe) {
74
105
  const aligns = Array.from({ length: columnCount }, (_, col) => rows.length > 0 && rows.every((row) => { var _a; return isNumeric((_a = row[col]) !== null && _a !== void 0 ? _a : ''); })
75
106
  ? 'right'
76
107
  : 'left');
77
- const widths = Array.from({ length: columnCount }, (_, col) => {
78
- var _a, _b;
79
- return Math.max((_b = (_a = headers[col]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0, ...rows.map((row) => { var _a; return String((_a = row[col]) !== null && _a !== void 0 ? _a : '').length; }));
80
- });
108
+ const widths = Array.from({ length: columnCount }, (_, col) => { var _a; var _b; return Math.max((_b = (_a = headers[col]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0, ...rows.map((row) => { var _a; return String((_a = row[col]) !== null && _a !== void 0 ? _a : '').length; })); });
81
109
  const headerLine = headers
82
- .map((header, col) => {
83
- var _a, _b;
84
- return dim(padCell(header.toUpperCase(), (_a = widths[col]) !== null && _a !== void 0 ? _a : 0, (_b = aligns[col]) !== null && _b !== void 0 ? _b : 'left'));
85
- })
110
+ .map((header, col) => { var _a, _b; return dim(padCell(header.toUpperCase(), (_a = widths[col]) !== null && _a !== void 0 ? _a : 0, (_b = aligns[col]) !== null && _b !== void 0 ? _b : 'left')); })
86
111
  .join(' ');
87
112
  const bodyLines = rows.map((row) => row
88
113
  .map((cell, col) => { var _a, _b; return padCell(String(cell), (_a = widths[col]) !== null && _a !== void 0 ? _a : 0, (_b = aligns[col]) !== null && _b !== void 0 ? _b : 'left'); })
@@ -129,4 +154,48 @@ export function createUi(probe) {
129
154
  },
130
155
  };
131
156
  }
157
+ /**
158
+ * A host URL as a person would say it: `https://x.site` -> `x.site`. The
159
+ * scheme only stays when it carries information (plain `http://`, as in a
160
+ * local sandbox) or when the string is not a URL at all.
161
+ */
162
+ export function shortHost(host) {
163
+ let url;
164
+ try {
165
+ url = new URL(host);
166
+ }
167
+ catch (_a) {
168
+ return host;
169
+ }
170
+ const bare = url.pathname === '/' && !url.search && !url.hash;
171
+ return url.protocol === 'https:' && bare ? url.host : host;
172
+ }
173
+ /** A path relative to `cwd` when it sits inside it, `~/…` under home, else as given. */
174
+ export function displayPath(target, cwd, home = process.env.HOME) {
175
+ const relative = path.relative(cwd, target);
176
+ if (relative === '')
177
+ return '.';
178
+ if (!relative.startsWith('..') && !path.isAbsolute(relative))
179
+ return relative;
180
+ if (home) {
181
+ const underHome = path.relative(home, target);
182
+ if (!underHome.startsWith('..') && !path.isAbsolute(underHome)) {
183
+ return `~/${underHome}`;
184
+ }
185
+ }
186
+ return target;
187
+ }
188
+ /** `412ms` below a second, `1.2s` above, `2m 05s` past a minute. */
189
+ export function formatDuration(ms) {
190
+ if (ms < 1000)
191
+ return `${Math.round(ms)}ms`;
192
+ if (ms < 60000)
193
+ return `${(ms / 1000).toFixed(1)}s`;
194
+ const minutes = Math.floor(ms / 60000);
195
+ const seconds = Math.round((ms % 60000) / 1000);
196
+ return `${minutes}m ${String(seconds).padStart(2, '0')}s`;
197
+ }
198
+ export function pluralize(count, noun) {
199
+ return `${count} ${noun}${count === 1 ? '' : 's'}`;
200
+ }
132
201
  //# sourceMappingURL=ui.js.map
package/dist/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAuB5B;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAEtB,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,GAAG,CAAC,WAAW,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAC1E,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAEtC,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CACvB,GAAiD;;IAEjD,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAEtC,MAAM,MAAM,GAAG,MAAA,MAAA,MAAA,GAAG,CAAC,IAAI,mCAAI,GAAG,CAAC,MAAM,mCAAI,GAAG,CAAC,QAA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BACjC,MAAM,IAAI,GAAG,MAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;gBAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;gBACpC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;gBAC/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAE9C,IAAI,CAAC,IAAI,CACP,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE,CAC/E,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAED,KAAK,CAAC,IAAY,EAAE,OAAkB,KAAK;YACzC,MAAM,OAAO,GAAG,IAAI,IAAI,GAAG,CAAC;YAE5B,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,KAAK;oBACR,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;gBACtB,KAAK,MAAM;oBACT,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvB,KAAK,QAAQ;oBACX,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;gBACzB;oBACE,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import pc from 'picocolors';\n\n/**\n * The CLI's sole style layer. Every color, glyph, and human-output component\n * lives here — nothing else in this package may `import 'picocolors'` or\n * write a raw ANSI escape (the gradient banner in `banner.ts` is the one\n * documented exception: it paints a true-color gradient picocolors cannot\n * express, but even it asks THIS module's `colorsEnabled` for the on/off\n * decision, so there is exactly one gate).\n *\n * Everything here renders plain strings. Printing is still `CliContext`'s\n * job (`ctx.log`) — this module never touches a stream directly, so the\n * stdout-purity invariant in `context.ts` cannot be bypassed by a stray\n * color call.\n */\n\n/** What `colorsEnabled` needs to know to decide — never the real stream. */\nexport interface ColorProbe {\n /** Whether the destination (stderr, always — see `context.ts`) is a TTY. */\n isTTY: boolean;\n env: Readonly<Record<string, string | undefined>>;\n}\n\n/**\n * The one color-on/off decision for the whole CLI. True only when the\n * stream is a real terminal AND `NO_COLOR` is unset AND `TERM` is not\n * `\"dumb\"` — EXCEPT `FORCE_COLOR`, which overrides everything else on when\n * set to anything other than `\"0\"` (matching the de facto convention: Node,\n * chalk, and picocolors itself all treat a defined-and-nonzero `FORCE_COLOR`\n * as \"yes, even if you don't think you can\").\n */\nexport function colorsEnabled(probe: ColorProbe): boolean {\n const { env } = probe;\n\n if (env.FORCE_COLOR !== undefined && env.FORCE_COLOR !== '0') return true;\n if (env.NO_COLOR !== undefined) return false;\n if (env.TERM === 'dumb') return false;\n\n return probe.isTTY;\n}\n\n/**\n * Whether the destination can render the box-drawing/Unicode glyphs this\n * module prefers. Deliberately simple: a \"dumb\" terminal never can, and a\n * locale that names a non-UTF-8 charset can't be trusted to either. Anything\n * else — including an unset locale, which is the common case for CI/agent\n * environments — is assumed capable rather than guessed at further.\n */\nfunction unicodeSupported(\n env: Readonly<Record<string, string | undefined>>,\n): boolean {\n if (env.TERM === 'dumb') return false;\n\n const locale = env.LANG ?? env.LC_ALL ?? env.LC_CTYPE ?? '';\n if (locale && !/utf-?8/i.test(locale)) return false;\n\n return true;\n}\n\nexport interface Glyphs {\n ok: string;\n err: string;\n warn: string;\n info: string;\n}\n\nconst UNICODE_GLYPHS: Glyphs = { ok: '✓', err: '✖', warn: '▲', info: '●' };\nconst ASCII_GLYPHS: Glyphs = { ok: 'ok', err: 'x', warn: '!', info: '*' };\n\n/** One row of `ui.keyValue`. */\nexport type KeyValueRow = readonly [key: string, value: string];\n\nexport interface CodeframeOptions {\n /** Not rendered directly — callers already print `file:line` above/around this. Kept for future use and self-documentation at call sites. */\n file?: string;\n /** 1-indexed line to highlight. */\n line: number;\n /** The full source text of `file`. */\n source: string;\n /** Lines of context above/below the target line. Defaults to 2. */\n contextLines?: number;\n}\n\nexport type BadgeKind = 'dim' | 'accent' | 'warn' | 'err';\n\nexport interface Ui {\n readonly colors: boolean;\n readonly glyphs: Glyphs;\n\n err(text: string): string;\n warn(text: string): string;\n ok(text: string): string;\n accent(text: string): string;\n dim(text: string): string;\n bold(text: string): string;\n\n /** A dim, uppercased section header. */\n section(title: string): string;\n /** Aligned `key value` rows, 2-space gutter, keys dimmed. */\n keyValue(rows: readonly KeyValueRow[]): string;\n /** A header-having, left/right-aligned table with no box-drawing. */\n table(\n headers: readonly string[],\n rows: readonly (readonly (string | number)[])[],\n ): string;\n /** A `→ ` prefixed, accent-colored hint line. */\n hint(text: string): string;\n /**\n * THE closing line of any failure path: a blank line, then a dim\n * `→ <why>: ` (or bare `→ `) followed by the bold remediation command.\n */\n nextAction(cmd: string, why?: string): string;\n /** A Prisma/Vite-style source snippet around one line. */\n codeframe(opts: CodeframeOptions): string;\n /** A bracketed, dim-by-default tag: `[gate · 2h ago]`. */\n badge(text: string, kind?: BadgeKind): string;\n}\n\n/** Right-pad (left-align) a cell to `width`, ignoring color codes in length math is the CALLER's job — pad before coloring, never after. */\nfunction padCell(text: string, width: number, align: 'left' | 'right'): string {\n return align === 'right' ? text.padStart(width) : text.padEnd(width);\n}\n\nexport function createUi(probe: ColorProbe): Ui {\n const colors = colorsEnabled(probe);\n const c = pc.createColors(colors);\n const glyphs = unicodeSupported(probe.env) ? UNICODE_GLYPHS : ASCII_GLYPHS;\n\n const err = (text: string) => c.red(text);\n const warn = (text: string) => c.yellow(text);\n const ok = (text: string) => c.green(text);\n const accent = (text: string) => c.cyan(text);\n const dim = (text: string) => c.dim(text);\n const bold = (text: string) => c.bold(text);\n\n return {\n colors,\n glyphs,\n err,\n warn,\n ok,\n accent,\n dim,\n bold,\n\n section(title: string): string {\n return dim(title.toUpperCase());\n },\n\n keyValue(rows: readonly KeyValueRow[]): string {\n const keyWidth = Math.max(0, ...rows.map(([key]) => key.length));\n\n return rows\n .map(([key, value]) => `${dim(key.padEnd(keyWidth))} ${value}`)\n .join('\\n');\n },\n\n table(\n headers: readonly string[],\n rows: readonly (readonly (string | number)[])[],\n ): string {\n const columnCount = headers.length;\n const isNumeric = (value: string | number) =>\n typeof value === 'number' ||\n (value.trim() !== '' && !Number.isNaN(Number(value)));\n\n const aligns: Array<'left' | 'right'> = Array.from(\n { length: columnCount },\n (_, col) =>\n rows.length > 0 && rows.every((row) => isNumeric(row[col] ?? ''))\n ? 'right'\n : 'left',\n );\n\n const widths = Array.from({ length: columnCount }, (_, col) =>\n Math.max(\n headers[col]?.length ?? 0,\n ...rows.map((row) => String(row[col] ?? '').length),\n ),\n );\n\n const headerLine = headers\n .map((header, col) =>\n dim(\n padCell(\n header.toUpperCase(),\n widths[col] ?? 0,\n aligns[col] ?? 'left',\n ),\n ),\n )\n .join(' ');\n\n const bodyLines = rows.map((row) =>\n row\n .map((cell, col) =>\n padCell(String(cell), widths[col] ?? 0, aligns[col] ?? 'left'),\n )\n .join(' '),\n );\n\n return [headerLine, ...bodyLines].join('\\n');\n },\n\n hint(text: string): string {\n return accent(`→ ${text}`);\n },\n\n nextAction(cmd: string, why?: string): string {\n const prefix = why ? `→ ${why}: ` : '→ ';\n return `\\n${dim(prefix)}${bold(cmd)}`;\n },\n\n codeframe(opts: CodeframeOptions): string {\n const contextLines = opts.contextLines ?? 2;\n const lines = opts.source.split('\\n');\n const start = Math.max(1, opts.line - contextLines);\n const end = Math.min(lines.length, opts.line + contextLines);\n const gutterWidth = String(end).length;\n\n const rows: string[] = [];\n for (let n = start; n <= end; n += 1) {\n const isTarget = n === opts.line;\n const text = lines[n - 1] ?? '';\n const marker = isTarget ? '>' : ' ';\n const lineNo = String(n).padStart(gutterWidth);\n const rendered = isTarget ? bold(text) : text;\n\n rows.push(\n `${isTarget ? accent(marker) : marker} ${dim(lineNo)} ${dim('│')} ${rendered}`,\n );\n }\n\n return rows.join('\\n');\n },\n\n badge(text: string, kind: BadgeKind = 'dim'): string {\n const wrapped = `[${text}]`;\n\n switch (kind) {\n case 'err':\n return err(wrapped);\n case 'warn':\n return warn(wrapped);\n case 'accent':\n return accent(wrapped);\n default:\n return dim(wrapped);\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAuB5B;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAEtB,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,GAAG,CAAC,WAAW,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAC1E,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAEtC,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CACvB,GAAiD;;IAEjD,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAEtC,MAAM,MAAM,qBAAG,GAAG,CAAC,IAAI,mCAAI,GAAG,CAAC,MAAM,mCAAI,GAAG,CAAC,QAAQ,mCAAI,EAAE,CAAC;IAC5D,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpD,OAAO,IAAI,CAAC;AACd,CAAC;AAWD,MAAM,cAAc,GAAW;IAC7B,EAA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AAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,KAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACjD,OAAO,GAAG,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,IAAY;IACnD,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACrD,CAAC","sourcesContent":["import * as path from 'node:path';\nimport pc from 'picocolors';\n\n/**\n * The CLI's sole style layer. Every color, glyph, and human-output component\n * lives here — nothing else in this package may `import 'picocolors'` or\n * write a raw ANSI escape (the gradient banner in `banner.ts` is the one\n * documented exception: it paints a true-color gradient picocolors cannot\n * express, but even it asks THIS module's `colorsEnabled` for the on/off\n * decision, so there is exactly one gate).\n *\n * Everything here renders plain strings. Printing is still `CliContext`'s\n * job (`ctx.log`) — this module never touches a stream directly, so the\n * stdout-purity invariant in `context.ts` cannot be bypassed by a stray\n * color call.\n */\n\n/** What `colorsEnabled` needs to know to decide — never the real stream. */\nexport interface ColorProbe {\n /** Whether the destination (stderr, always — see `context.ts`) is a TTY. */\n isTTY: boolean;\n env: Readonly<Record<string, string | undefined>>;\n}\n\n/**\n * The one color-on/off decision for the whole CLI. True only when the\n * stream is a real terminal AND `NO_COLOR` is unset AND `TERM` is not\n * `\"dumb\"` — EXCEPT `FORCE_COLOR`, which overrides everything else on when\n * set to anything other than `\"0\"` (matching the de facto convention: Node,\n * chalk, and picocolors itself all treat a defined-and-nonzero `FORCE_COLOR`\n * as \"yes, even if you don't think you can\").\n */\nexport function colorsEnabled(probe: ColorProbe): boolean {\n const { env } = probe;\n\n if (env.FORCE_COLOR !== undefined && env.FORCE_COLOR !== '0') return true;\n if (env.NO_COLOR !== undefined) return false;\n if (env.TERM === 'dumb') return false;\n\n return probe.isTTY;\n}\n\n/**\n * Whether the destination can render the box-drawing/Unicode glyphs this\n * module prefers. Deliberately simple: a \"dumb\" terminal never can, and a\n * locale that names a non-UTF-8 charset can't be trusted to either. Anything\n * else — including an unset locale, which is the common case for CI/agent\n * environments — is assumed capable rather than guessed at further.\n */\nfunction unicodeSupported(\n env: Readonly<Record<string, string | undefined>>,\n): boolean {\n if (env.TERM === 'dumb') return false;\n\n const locale = env.LANG ?? env.LC_ALL ?? env.LC_CTYPE ?? '';\n if (locale && !/utf-?8/i.test(locale)) return false;\n\n return true;\n}\n\nexport interface Glyphs {\n ok: string;\n err: string;\n warn: string;\n info: string;\n /** The result-block title marker — the same `◇` the clack wizard draws. */\n step: string;\n}\n\nconst UNICODE_GLYPHS: Glyphs = {\n ok: '✓',\n err: '✖',\n warn: '▲',\n info: '●',\n step: '◇',\n};\nconst ASCII_GLYPHS: Glyphs = {\n ok: 'ok',\n err: 'x',\n warn: '!',\n info: '*',\n step: 'o',\n};\n\n/** One row of `ui.keyValue`. */\nexport type KeyValueRow = readonly [key: string, value: string];\n\n/** One row of `ui.result`: a dim label and a value, or several values stacked under one label. */\nexport type ResultRow = readonly [\n label: string,\n value: string | readonly string[],\n];\n\nexport type ResultTone = 'ok' | 'warn' | 'err';\n\n/** What every command's successful human-mode ending is built from. */\nexport interface ResultBlock {\n /** The one-line outcome: \"Signed in\", \"Submitted\", … Title case, no verb prefix, no period. */\n title: string;\n /** Defaults to `ok` (green marker). `warn` for a result that succeeded but needs attention. */\n tone?: ResultTone;\n rows?: readonly ResultRow[];\n /** Secondary prose, dim, set apart from the rows by a blank line. Keep it short. */\n notes?: readonly string[];\n}\n\nexport interface CodeframeOptions {\n /** Not rendered directly — callers already print `file:line` above/around this. Kept for future use and self-documentation at call sites. */\n file?: string;\n /** 1-indexed line to highlight. */\n line: number;\n /** The full source text of `file`. */\n source: string;\n /** Lines of context above/below the target line. Defaults to 2. */\n contextLines?: number;\n}\n\nexport type BadgeKind = 'dim' | 'accent' | 'warn' | 'err';\n\nexport interface Ui {\n readonly colors: boolean;\n readonly glyphs: Glyphs;\n\n err(text: string): string;\n warn(text: string): string;\n ok(text: string): string;\n accent(text: string): string;\n dim(text: string): string;\n bold(text: string): string;\n\n /** A dim, uppercased section header. */\n section(title: string): string;\n /** Aligned `key value` rows, 2-space gutter, keys dimmed. */\n keyValue(rows: readonly KeyValueRow[]): string;\n /**\n * THE success renderer: a marker + bold title line, then aligned\n * `label value` rows indented under it, labels dim. A multi-value row\n * stacks its values under one label. Plain strings throughout, so a\n * monochrome terminal gets exactly the same layout minus the color.\n */\n result(block: ResultBlock): string;\n /** A header-having, left/right-aligned table with no box-drawing. */\n table(\n headers: readonly string[],\n rows: readonly (readonly (string | number)[])[],\n ): string;\n /** A `→ ` prefixed, accent-colored hint line. */\n hint(text: string): string;\n /**\n * THE closing line of any failure path: a blank line, then a dim\n * `→ <why>: ` (or bare `→ `) followed by the bold remediation command.\n */\n nextAction(cmd: string, why?: string): string;\n /** A Prisma/Vite-style source snippet around one line. */\n codeframe(opts: CodeframeOptions): string;\n /** A bracketed, dim-by-default tag: `[gate · 2h ago]`. */\n badge(text: string, kind?: BadgeKind): string;\n}\n\n/** Right-pad (left-align) a cell to `width`, ignoring color codes in length math is the CALLER's job — pad before coloring, never after. */\nfunction padCell(text: string, width: number, align: 'left' | 'right'): string {\n return align === 'right' ? text.padStart(width) : text.padEnd(width);\n}\n\nexport function createUi(probe: ColorProbe): Ui {\n const colors = colorsEnabled(probe);\n const c = pc.createColors(colors);\n const glyphs = unicodeSupported(probe.env) ? UNICODE_GLYPHS : ASCII_GLYPHS;\n\n const err = (text: string) => c.red(text);\n const warn = (text: string) => c.yellow(text);\n const ok = (text: string) => c.green(text);\n const accent = (text: string) => c.cyan(text);\n const dim = (text: string) => c.dim(text);\n const bold = (text: string) => c.bold(text);\n\n return {\n colors,\n glyphs,\n err,\n warn,\n ok,\n accent,\n dim,\n bold,\n\n section(title: string): string {\n return dim(title.toUpperCase());\n },\n\n keyValue(rows: readonly KeyValueRow[]): string {\n const keyWidth = Math.max(0, ...rows.map(([key]) => key.length));\n\n return rows\n .map(([key, value]) => `${dim(key.padEnd(keyWidth))} ${value}`)\n .join('\\n');\n },\n\n result(block: ResultBlock): string {\n const paint = { ok, warn, err }[block.tone ?? 'ok'];\n const lines = [`${paint(glyphs.step)} ${bold(block.title)}`];\n const rows = block.rows ?? [];\n const labelWidth = Math.max(0, ...rows.map(([label]) => label.length));\n\n for (const [label, value] of rows) {\n const values = typeof value === 'string' ? [value] : value;\n values.forEach((line, index) => {\n const gutter = (index === 0 ? label : '').padEnd(labelWidth);\n lines.push(` ${dim(gutter)} ${line}`.trimEnd());\n });\n }\n\n if (block.notes && block.notes.length > 0) {\n lines.push('', ...block.notes.map((note) => ` ${dim(note)}`));\n }\n\n return lines.join('\\n');\n },\n\n table(\n headers: readonly string[],\n rows: readonly (readonly (string | number)[])[],\n ): string {\n const columnCount = headers.length;\n const isNumeric = (value: string | number) =>\n typeof value === 'number' ||\n (value.trim() !== '' && !Number.isNaN(Number(value)));\n\n const aligns: Array<'left' | 'right'> = Array.from(\n { length: columnCount },\n (_, col) =>\n rows.length > 0 && rows.every((row) => isNumeric(row[col] ?? ''))\n ? 'right'\n : 'left',\n );\n\n const widths = Array.from({ length: columnCount }, (_, col) =>\n Math.max(\n headers[col]?.length ?? 0,\n ...rows.map((row) => String(row[col] ?? '').length),\n ),\n );\n\n const headerLine = headers\n .map((header, col) =>\n dim(\n padCell(\n header.toUpperCase(),\n widths[col] ?? 0,\n aligns[col] ?? 'left',\n ),\n ),\n )\n .join(' ');\n\n const bodyLines = rows.map((row) =>\n row\n .map((cell, col) =>\n padCell(String(cell), widths[col] ?? 0, aligns[col] ?? 'left'),\n )\n .join(' '),\n );\n\n return [headerLine, ...bodyLines].join('\\n');\n },\n\n hint(text: string): string {\n return accent(`→ ${text}`);\n },\n\n nextAction(cmd: string, why?: string): string {\n const prefix = why ? `→ ${why}: ` : '→ ';\n return `\\n${dim(prefix)}${bold(cmd)}`;\n },\n\n codeframe(opts: CodeframeOptions): string {\n const contextLines = opts.contextLines ?? 2;\n const lines = opts.source.split('\\n');\n const start = Math.max(1, opts.line - contextLines);\n const end = Math.min(lines.length, opts.line + contextLines);\n const gutterWidth = String(end).length;\n\n const rows: string[] = [];\n for (let n = start; n <= end; n += 1) {\n const isTarget = n === opts.line;\n const text = lines[n - 1] ?? '';\n const marker = isTarget ? '>' : ' ';\n const lineNo = String(n).padStart(gutterWidth);\n const rendered = isTarget ? bold(text) : text;\n\n rows.push(\n `${isTarget ? accent(marker) : marker} ${dim(lineNo)} ${dim('│')} ${rendered}`,\n );\n }\n\n return rows.join('\\n');\n },\n\n badge(text: string, kind: BadgeKind = 'dim'): string {\n const wrapped = `[${text}]`;\n\n switch (kind) {\n case 'err':\n return err(wrapped);\n case 'warn':\n return warn(wrapped);\n case 'accent':\n return accent(wrapped);\n default:\n return dim(wrapped);\n }\n },\n };\n}\n\n/**\n * A host URL as a person would say it: `https://x.site` -> `x.site`. The\n * scheme only stays when it carries information (plain `http://`, as in a\n * local sandbox) or when the string is not a URL at all.\n */\nexport function shortHost(host: string): string {\n let url: URL;\n try {\n url = new URL(host);\n } catch {\n return host;\n }\n\n const bare = url.pathname === '/' && !url.search && !url.hash;\n return url.protocol === 'https:' && bare ? url.host : host;\n}\n\n/** A path relative to `cwd` when it sits inside it, `~/…` under home, else as given. */\nexport function displayPath(\n target: string,\n cwd: string,\n home: string | undefined = process.env.HOME,\n): string {\n const relative = path.relative(cwd, target);\n if (relative === '') return '.';\n if (!relative.startsWith('..') && !path.isAbsolute(relative)) return relative;\n\n if (home) {\n const underHome = path.relative(home, target);\n if (!underHome.startsWith('..') && !path.isAbsolute(underHome)) {\n return `~/${underHome}`;\n }\n }\n\n return target;\n}\n\n/** `412ms` below a second, `1.2s` above, `2m 05s` past a minute. */\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;\n\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return `${minutes}m ${String(seconds).padStart(2, '0')}s`;\n}\n\nexport function pluralize(count: number, noun: string): string {\n return `${count} ${noun}${count === 1 ? '' : 's'}`;\n}\n"]}
@@ -10,7 +10,7 @@ export interface ToolchainNoticeData {
10
10
  }
11
11
  export interface CheckForUpdateParams {
12
12
  env: Record<string, string | undefined>;
13
- /** An already-resolved Fusion host/session, when the caller has one handy. */
13
+ /** An already-resolved Ekanos host/session, when the caller has one handy. */
14
14
  host?: string;
15
15
  session?: {
16
16
  accessToken: string;
@@ -1 +1 @@
1
- {"version":3,"file":"update-notice.js","sourceRoot":"","sources":["../src/update-notice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;;;;GAWG;AAEH,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,kFAAkF;AAClF,MAAM,WAAW,GAAG,IAAI,CAAC;AAgBzB,SAAS,SAAS,CAAC,GAAuC;IACxD,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,GAAuC;IACxD,IAAI,CAAC;QACH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CAAC,GAAG,0BAA0B,CACvD,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { CredentialStore, resolveEkanosHome } from './auth/credential-store';\nimport { cliVersion, compareVersions } from './compatibility';\nimport type { CliContext } from './context';\nimport type { ToolchainVersions } from './toolchain';\nimport { resolveToolchainTarget } from './toolchain-resolve';\n\n/**\n * The proactive, NEVER-mutating \"your CLI is behind\" notice. Runs on\n * `validate`, `dev`, `publish` and `status` — the verbs a partner (or an\n * agent acting for one) runs constantly — so staleness is discovered on the\n * next ordinary command instead of only when something breaks.\n *\n * The one rule that governs every line of this file: this check must be\n * INVISIBLE on failure. A partner offline, a flaky registry, a host that\n * predates this endpoint — none of that may add meaningful latency, change a\n * verb's exit code, or so much as touch the JSON envelope's `ok` field.\n * Every failure path below resolves to `null` (\"say nothing\"), never a throw.\n */\n\nconst CACHE_FILENAME = 'update-check.json';\nconst CACHE_DIR_MODE = 0o700;\nconst CACHE_FILE_MODE = 0o600;\nconst TTL_MS = 24 * 60 * 60 * 1000;\n/** The hard ceiling on this check's total network time, whatever else happens. */\nconst DEADLINE_MS = 1500;\n\nexport interface ToolchainNoticeData {\n status: 'behind' | 'unsupported';\n current: { cli: string };\n target: ToolchainVersions;\n upgradeCommand: 'ekanos upgrade';\n}\n\ninterface CacheFile {\n checkedAt: number;\n target: ToolchainVersions;\n minimum?: ToolchainVersions;\n source: 'host' | 'npm';\n}\n\nfunction cachePath(env: Record<string, string | undefined>): string {\n return path.join(resolveEkanosHome(env), '.ekanos', CACHE_FILENAME);\n}\n\nfunction readCache(env: Record<string, string | undefined>): CacheFile | null {\n try {\n const raw = fs.readFileSync(cachePath(env), 'utf8');\n const parsed: unknown = JSON.parse(raw);\n return isCacheFile(parsed) ? parsed : null;\n } catch {\n // Missing, unreadable, or corrupt — all read as \"no cache\", never an\n // error. This check is a courtesy, not a source of truth.\n return null;\n }\n}\n\nfunction writeCache(\n env: Record<string, string | undefined>,\n file: CacheFile,\n): void {\n const target = cachePath(env);\n try {\n fs.mkdirSync(path.dirname(target), {\n recursive: true,\n mode: CACHE_DIR_MODE,\n });\n const tmp = `${target}.${process.pid}.tmp`;\n fs.writeFileSync(tmp, JSON.stringify(file), { mode: CACHE_FILE_MODE });\n fs.renameSync(tmp, target);\n } catch {\n // Best-effort. The next run simply re-checks — this is a cache, not a\n // durable record.\n }\n}\n\nfunction isCacheFile(value: unknown): value is CacheFile {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Partial<CacheFile>;\n return (\n typeof candidate.checkedAt === 'number' &&\n typeof candidate.target === 'object' &&\n candidate.target !== null &&\n (candidate.source === 'host' || candidate.source === 'npm')\n );\n}\n\n/**\n * The one host/session this check will ever try, resolved WITHOUT any of the\n * throwing machinery in `auth/session.ts` — `resolveHost` is built to demand\n * an answer (a usage error naming the ambiguity) because a real command needs\n * one; this check needs an answer only if one is obvious, and silence\n * otherwise. Exactly one stored host is \"obvious\"; zero or several are not,\n * and this never prompts or guesses to resolve that ambiguity — it just\n * falls back to the npm registry, same as no session at all.\n */\nfunction bestEffortHostSession(\n env: Record<string, string | undefined>,\n): { host: string; session: { accessToken: string } } | null {\n try {\n const store = new CredentialStore({ home: resolveEkanosHome(env) });\n const hosts = store.hosts();\n if (hosts.length !== 1) return null;\n const session = store.read(hosts[0]!);\n return session ? { host: hosts[0]!, session } : null;\n } catch {\n return null;\n }\n}\n\nfunction withDeadline<T>(promise: Promise<T>, ms: number): Promise<T | null> {\n return new Promise((resolve) => {\n let settled = false;\n const timer = setTimeout(() => {\n if (!settled) {\n settled = true;\n resolve(null);\n }\n }, ms);\n // A rejection is a failure like any other here — resolve to null rather\n // than letting it become an unhandled rejection.\n promise.then(\n (value) => {\n if (!settled) {\n settled = true;\n clearTimeout(timer);\n resolve(value);\n }\n },\n () => {\n if (!settled) {\n settled = true;\n clearTimeout(timer);\n resolve(null);\n }\n },\n );\n });\n}\n\nexport interface CheckForUpdateParams {\n env: Record<string, string | undefined>;\n /** An already-resolved Fusion host/session, when the caller has one handy. */\n host?: string;\n session?: { accessToken: string } | null;\n}\n\n/**\n * Resolve whether this CLI is behind, respecting the 24h cache and the hard\n * `EKANOS_NO_UPDATE_CHECK` opt-out. Returns null whenever there is nothing to\n * say — current, unresolvable, or any failure along the way.\n */\nexport async function checkForUpdate(\n params: CheckForUpdateParams,\n): Promise<ToolchainNoticeData | null> {\n if (params.env.EKANOS_NO_UPDATE_CHECK) return null;\n\n const cached = readCache(params.env);\n const now = Date.now();\n\n let target: ToolchainVersions;\n let minimum: ToolchainVersions | undefined;\n\n if (cached && now - cached.checkedAt < TTL_MS) {\n target = cached.target;\n minimum = cached.minimum;\n } else {\n const auth =\n params.host && params.session\n ? { host: params.host, session: params.session }\n : bestEffortHostSession(params.env);\n\n const resolution = await withDeadline(\n resolveToolchainTarget({\n host: auth?.host,\n session: auth?.session,\n timeoutMs: DEADLINE_MS,\n }),\n DEADLINE_MS,\n );\n\n if (!resolution || resolution.status !== 'ok') return null;\n\n target = resolution.target;\n minimum = resolution.source === 'host' ? resolution.minimum : undefined;\n\n writeCache(params.env, {\n checkedAt: now,\n target,\n minimum,\n source: resolution.source,\n });\n }\n\n const current = cliVersion();\n if (compareVersions(current, target.cli) >= 0) return null;\n\n const status =\n minimum && compareVersions(current, minimum.cli) < 0\n ? 'unsupported'\n : 'behind';\n\n return {\n status,\n current: { cli: current },\n target,\n upgradeCommand: 'ekanos upgrade',\n };\n}\n\n/**\n * Surface a notice, if any. Human mode gets one stderr line; every mode gets\n * the `claude-code-hint` stderr line so an agent parsing stderr for that\n * marker sees it regardless of `--json`. NEVER writes to stdout — the JSON\n * envelope's caller is responsible for embedding `notice` under a `toolchain`\n * key in its own `data`, per the envelope docs in `context.ts`.\n */\nexport function announceUpdate(\n ctx: CliContext,\n notice: ToolchainNoticeData | null,\n): void {\n if (!notice) return;\n\n if (!ctx.jsonMode) {\n ctx.warn(\n notice.status === 'unsupported'\n ? `ekanos: @ekanos/cli ${notice.current.cli} is below the version ` +\n `this host requires (${notice.target.cli}). Run \"ekanos upgrade\".`\n : `ekanos: a newer @ekanos/cli is available (${notice.current.cli} ` +\n `→ ${notice.target.cli}). Run \"ekanos upgrade\".`,\n );\n }\n\n ctx.emitClaudeCodeHint({ tool: 'ekanos', toolchain: notice });\n}\n"]}
1
+ {"version":3,"file":"update-notice.js","sourceRoot":"","sources":["../src/update-notice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;;;;GAWG;AAEH,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,kFAAkF;AAClF,MAAM,WAAW,GAAG,IAAI,CAAC;AAgBzB,SAAS,SAAS,CAAC,GAAuC;IACxD,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,GAAuC;IACxD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QACpD,MAAM,MAAM,GAAY,IAAI,CAAC,K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E,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { CredentialStore, resolveEkanosHome } from './auth/credential-store';\nimport { cliVersion, compareVersions } from './compatibility';\nimport type { CliContext } from './context';\nimport type { ToolchainVersions } from './toolchain';\nimport { resolveToolchainTarget } from './toolchain-resolve';\n\n/**\n * The proactive, NEVER-mutating \"your CLI is behind\" notice. Runs on\n * `validate`, `dev`, `publish` and `status` — the verbs a partner (or an\n * agent acting for one) runs constantly — so staleness is discovered on the\n * next ordinary command instead of only when something breaks.\n *\n * The one rule that governs every line of this file: this check must be\n * INVISIBLE on failure. A partner offline, a flaky registry, a host that\n * predates this endpoint — none of that may add meaningful latency, change a\n * verb's exit code, or so much as touch the JSON envelope's `ok` field.\n * Every failure path below resolves to `null` (\"say nothing\"), never a throw.\n */\n\nconst CACHE_FILENAME = 'update-check.json';\nconst CACHE_DIR_MODE = 0o700;\nconst CACHE_FILE_MODE = 0o600;\nconst TTL_MS = 24 * 60 * 60 * 1000;\n/** The hard ceiling on this check's total network time, whatever else happens. */\nconst DEADLINE_MS = 1500;\n\nexport interface ToolchainNoticeData {\n status: 'behind' | 'unsupported';\n current: { cli: string };\n target: ToolchainVersions;\n upgradeCommand: 'ekanos upgrade';\n}\n\ninterface CacheFile {\n checkedAt: number;\n target: ToolchainVersions;\n minimum?: ToolchainVersions;\n source: 'host' | 'npm';\n}\n\nfunction cachePath(env: Record<string, string | undefined>): string {\n return path.join(resolveEkanosHome(env), '.ekanos', CACHE_FILENAME);\n}\n\nfunction readCache(env: Record<string, string | undefined>): CacheFile | null {\n try {\n const raw = fs.readFileSync(cachePath(env), 'utf8');\n const parsed: unknown = JSON.parse(raw);\n return isCacheFile(parsed) ? parsed : null;\n } catch {\n // Missing, unreadable, or corrupt — all read as \"no cache\", never an\n // error. This check is a courtesy, not a source of truth.\n return null;\n }\n}\n\nfunction writeCache(\n env: Record<string, string | undefined>,\n file: CacheFile,\n): void {\n const target = cachePath(env);\n try {\n fs.mkdirSync(path.dirname(target), {\n recursive: true,\n mode: CACHE_DIR_MODE,\n });\n const tmp = `${target}.${process.pid}.tmp`;\n fs.writeFileSync(tmp, JSON.stringify(file), { mode: CACHE_FILE_MODE });\n fs.renameSync(tmp, target);\n } catch {\n // Best-effort. The next run simply re-checks — this is a cache, not a\n // durable record.\n }\n}\n\nfunction isCacheFile(value: unknown): value is CacheFile {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Partial<CacheFile>;\n return (\n typeof candidate.checkedAt === 'number' &&\n typeof candidate.target === 'object' &&\n candidate.target !== null &&\n (candidate.source === 'host' || candidate.source === 'npm')\n );\n}\n\n/**\n * The one host/session this check will ever try, resolved WITHOUT any of the\n * throwing machinery in `auth/session.ts` — `resolveHost` is built to demand\n * an answer (a usage error naming the ambiguity) because a real command needs\n * one; this check needs an answer only if one is obvious, and silence\n * otherwise. Exactly one stored host is \"obvious\"; zero or several are not,\n * and this never prompts or guesses to resolve that ambiguity — it just\n * falls back to the npm registry, same as no session at all.\n */\nfunction bestEffortHostSession(\n env: Record<string, string | undefined>,\n): { host: string; session: { accessToken: string } } | null {\n try {\n const store = new CredentialStore({ home: resolveEkanosHome(env) });\n const hosts = store.hosts();\n if (hosts.length !== 1) return null;\n const session = store.read(hosts[0]!);\n return session ? { host: hosts[0]!, session } : null;\n } catch {\n return null;\n }\n}\n\nfunction withDeadline<T>(promise: Promise<T>, ms: number): Promise<T | null> {\n return new Promise((resolve) => {\n let settled = false;\n const timer = setTimeout(() => {\n if (!settled) {\n settled = true;\n resolve(null);\n }\n }, ms);\n // A rejection is a failure like any other here — resolve to null rather\n // than letting it become an unhandled rejection.\n promise.then(\n (value) => {\n if (!settled) {\n settled = true;\n clearTimeout(timer);\n resolve(value);\n }\n },\n () => {\n if (!settled) {\n settled = true;\n clearTimeout(timer);\n resolve(null);\n }\n },\n );\n });\n}\n\nexport interface CheckForUpdateParams {\n env: Record<string, string | undefined>;\n /** An already-resolved Ekanos host/session, when the caller has one handy. */\n host?: string;\n session?: { accessToken: string } | null;\n}\n\n/**\n * Resolve whether this CLI is behind, respecting the 24h cache and the hard\n * `EKANOS_NO_UPDATE_CHECK` opt-out. Returns null whenever there is nothing to\n * say — current, unresolvable, or any failure along the way.\n */\nexport async function checkForUpdate(\n params: CheckForUpdateParams,\n): Promise<ToolchainNoticeData | null> {\n if (params.env.EKANOS_NO_UPDATE_CHECK) return null;\n\n const cached = readCache(params.env);\n const now = Date.now();\n\n let target: ToolchainVersions;\n let minimum: ToolchainVersions | undefined;\n\n if (cached && now - cached.checkedAt < TTL_MS) {\n target = cached.target;\n minimum = cached.minimum;\n } else {\n const auth =\n params.host && params.session\n ? { host: params.host, session: params.session }\n : bestEffortHostSession(params.env);\n\n const resolution = await withDeadline(\n resolveToolchainTarget({\n host: auth?.host,\n session: auth?.session,\n timeoutMs: DEADLINE_MS,\n }),\n DEADLINE_MS,\n );\n\n if (!resolution || resolution.status !== 'ok') return null;\n\n target = resolution.target;\n minimum = resolution.source === 'host' ? resolution.minimum : undefined;\n\n writeCache(params.env, {\n checkedAt: now,\n target,\n minimum,\n source: resolution.source,\n });\n }\n\n const current = cliVersion();\n if (compareVersions(current, target.cli) >= 0) return null;\n\n const status =\n minimum && compareVersions(current, minimum.cli) < 0\n ? 'unsupported'\n : 'behind';\n\n return {\n status,\n current: { cli: current },\n target,\n upgradeCommand: 'ekanos upgrade',\n };\n}\n\n/**\n * Surface a notice, if any. Human mode gets one stderr line; every mode gets\n * the `claude-code-hint` stderr line so an agent parsing stderr for that\n * marker sees it regardless of `--json`. NEVER writes to stdout — the JSON\n * envelope's caller is responsible for embedding `notice` under a `toolchain`\n * key in its own `data`, per the envelope docs in `context.ts`.\n */\nexport function announceUpdate(\n ctx: CliContext,\n notice: ToolchainNoticeData | null,\n): void {\n if (!notice) return;\n\n if (!ctx.jsonMode) {\n ctx.warn(\n notice.status === 'unsupported'\n ? `ekanos: @ekanos/cli ${notice.current.cli} is below the version ` +\n `this host requires (${notice.target.cli}). Run \"ekanos upgrade\".`\n : `ekanos: a newer @ekanos/cli is available (${notice.current.cli} ` +\n `→ ${notice.target.cli}). Run \"ekanos upgrade\".`,\n );\n }\n\n ctx.emitClaudeCodeHint({ tool: 'ekanos', toolchain: notice });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validate-findings.js","sourceRoot":"","sources":["../src/validate-findings.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAqB;IAErB,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,WAAW,GAA+B,EAAE,CAAC;IAEnD,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,WAAW,CAAC,SAAS,EACrB,MAAM,CAAC,UAAU,CAClB,CAAC;QAEF,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;YACd,QAAQ,CAAC,IAAI,CACX,GAAG,yBAAyB,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9C,IAAI,EAAE,WAAW,CAAC,SAAS;aAC5B,CAAC,CACH,CAAC;YACF,QAAQ,CAAC,IAAI,CACX,GAAG,4BAA4B,CAC7B,WAAW,EACX,MAAM,CAAC,UAAgC,CACxC,CACF,CAAC;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OAAO;QAC7C,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;QACtE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;QACL;YACE,KAAK,EAAE,2BAA2B;YAClC,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,WAAW,CAAC,SAAS;YAC3B,OAAO,EACL,kCAAkC,cAAc,aAAa;gBAC7D,wCAAwC,WAAW,CAAC,IAAI,UAAU;gBAClE,SAAS,QAAQ,sCAAsC;gBACvD,oEAAoE;gBACpE,mDAAmD;YACrD,IAAI,EACF,wDAAwD;gBACxD,GAAG,WAAW,CAAC,SAAS,6BAA6B,cAAc,IAAI;SAC1E;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n DefinitionCollisionInput,\n Finding,\n} from '@ekanos/integration-schema';\nimport {\n collectCollisionFindings,\n collectDefinitionFindings,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { preconditionError } from './errors';\nimport { collectIconFindings } from './icon-findings';\nimport { loadDefinition } from './load-definition';\nimport type { LoadedProject } from './project';\nimport {\n collectDocsFindings,\n collectHostCompilerRulesFindings,\n collectProjectFindings,\n} from './project-checks';\n\n/**\n * The full findings pass shared by `validate` (which reports them) and\n * `publish` (which refuses to submit on any error-severity finding). One\n * implementation so the publish gate can never drift from what `validate`\n * checks — a project that validates clean is, by construction, a project that\n * publish will accept locally.\n *\n * NOTE on schema skew: an earlier version of this function rewrote the\n * unrecognized-key hint when the project's `@ekanos/integration-schema` was\n * newer than the CLI's (see `schema-skew.ts`). That rewrite was dead code —\n * `assertSchemaNotSkewed` throws PRECONDITION_FAILED before either `validate`\n * or `publish` ever calls this function in that state, so a project-newer\n * finding can never reach here to be rewritten, and the precondition error\n * already names both versions and points at the fix. It was removed rather\n * than kept \"just in case\": if a future caller ever makes validate proceed\n * under skew instead of failing fast, THAT is when a rewrite here becomes\n * necessary again, and it should be reintroduced with a real caller driving\n * it, not tests that fake their own reachability.\n */\nexport async function collectAllFindings(\n loaded: LoadedProject,\n): Promise<Finding[]> {\n const findings: Finding[] = [];\n const definitions: DefinitionCollisionInput[] = [];\n\n for (const integration of loaded.integrations) {\n const result = await loadDefinition(\n integration.entryPath,\n loaded.projectDir,\n );\n\n if (result.ok) {\n findings.push(\n ...collectDefinitionFindings(result.definition, {\n file: integration.entryPath,\n }),\n );\n findings.push(\n ...collectSlugAgreementFindings(\n integration,\n result.definition as { slug?: unknown },\n ),\n );\n findings.push(\n ...collectVersionAgreementFindings(\n integration,\n result.definition as { version?: unknown },\n loaded.projectDir,\n ),\n );\n definitions.push(result.definition as DefinitionCollisionInput);\n continue;\n }\n\n if (result.kind === 'rejected') {\n // The module loaded but the SDK/schema rejected the definition at import\n // time — surface it as a validation finding rather than a crash.\n findings.push({\n check: 'definition.load',\n severity: 'error',\n file: integration.entryPath,\n message: result.message,\n hint:\n 'Fix the integration definition so defineIntegration() accepts it, ' +\n 'then re-run validate.',\n });\n continue;\n }\n\n // A genuine module-load failure is a precondition, not a finding.\n throw preconditionError(\n `Could not load the integration definition for \"${integration.slug}\": ` +\n result.message,\n 'Ensure the entry module and its installed dependencies load under ' +\n 'Node, then re-run validate.',\n );\n }\n\n // Cross-checks only mean something with more than one definition in hand.\n findings.push(...collectCollisionFindings(definitions));\n findings.push(...collectProjectFindings(loaded.projectDir));\n findings.push(...collectDocsFindings(loaded.project, loaded.projectDir));\n findings.push(...collectIconFindings(loaded.projectDir));\n findings.push(...collectHostCompilerRulesFindings(loaded.projectDir));\n\n return findings;\n}\n\n/**\n * `ekanos.json` and the definition each carry a slug, and nothing compared\n * them: a project could declare `something-else` while the definition said\n * `repo-activity` and validate would report `{ ok: true, findings: [] }`.\n *\n * That is the identifier every surface addresses the integration by — the\n * harness route, the product slug, the widget id prefix, the MCP server — so\n * two sources of truth disagreeing is not a style question. It is an error,\n * not a warning, for the same reason a silent default is worse than a loud\n * one: the failure it causes shows up somewhere else entirely.\n */\nfunction collectSlugAgreementFindings(\n integration: { slug: string; entry: string; entryPath: string },\n definition: { slug?: unknown },\n): Finding[] {\n const declared = definition.slug;\n if (typeof declared !== 'string' || declared === integration.slug) return [];\n\n return [\n {\n check: 'project.slug-agreement',\n severity: 'error',\n file: integration.entryPath,\n message:\n `ekanos.json declares slug \"${integration.slug}\" for this entry, but ` +\n `the definition says \"${declared}\". The slug addresses the ` +\n 'integration everywhere — its harness route, its product record, its ' +\n 'widget ids — so the two must agree.',\n hint:\n `Change one to match the other: either set \"slug\": \"${declared}\" in ` +\n `ekanos.json, or pass slug: '${integration.slug}' to ` +\n 'defineIntegration().',\n },\n ];\n}\n\n/**\n * `package.json`'s `version` field and the `version` `defineIntegration()`\n * declares are two more independent sources of truth for the same fact —\n * this project shipped weather@0.1.1 with a package.json bump, but the\n * declaration itself still said 0.1.0. Generated seeds embed the\n * DECLARATION's version in their header, so a stale declaration produces a\n * seed that looks stale even though the package itself moved on.\n *\n * WARN, not error, unlike slug agreement: a mismatched version is a quality\n * signal a partner should fix, not a broken cross-reference that breaks\n * something else at runtime, so it must not block `publish`. And a project\n * with no package.json, or a package.json with no `version` field, has\n * nothing to compare the declaration against — skip rather than warn on\n * absence.\n */\nexport function collectVersionAgreementFindings(\n integration: { slug: string; entry: string; entryPath: string },\n definition: { version?: unknown },\n projectDir: string,\n): Finding[] {\n const declared = definition.version;\n if (typeof declared !== 'string') return [];\n\n const manifestPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(manifestPath)) return [];\n\n let manifest: unknown;\n try {\n manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\n } catch {\n // Malformed package.json is npm's problem to report, not a validate\n // finding — nothing here can compare against an unparseable manifest.\n return [];\n }\n\n const packageVersion =\n typeof manifest === 'object' && manifest !== null\n ? (manifest as { version?: unknown }).version\n : undefined;\n if (typeof packageVersion !== 'string' || packageVersion === declared) {\n return [];\n }\n\n return [\n {\n check: 'project.version-agreement',\n severity: 'warn',\n file: integration.entryPath,\n message:\n `package.json declares version \"${packageVersion}\", but the ` +\n `defineIntegration() declaration for \"${integration.slug}\" still ` +\n `says \"${declared}\". Generated seed headers embed the ` +\n \"declaration's version, so a stale declaration ships stale-looking \" +\n 'metadata even though the package itself moved on.',\n hint:\n `Update the \"version\" passed to defineIntegration() in ` +\n `${integration.entryPath} to match package.json's \"${packageVersion}\".`,\n },\n ];\n}\n"]}
1
+ {"version":3,"file":"validate-findings.js","sourceRoot":"","sources":["../src/validate-findings.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAqB;IAErB,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,WAAW,GAA+B,EAAE,CAAC;IAEnD,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,WAAW,CAAC,SAAS,EACrB,MAAM,CAAC,UAAU,CAClB,CAAC;QAEF,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;YACd,QAAQ,CAAC,IAAI,CACX,GAAG,yBAAyB,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9C,IAAI,EAAE,WAAW,CAAC,SAAS;aAC5B,CAAC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,MAAM,cAAc,GAClB,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI;QAC/C,CAAC,CAAE,QAAkC,CAAC,OAAO;QAC7C,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;QACtE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;QACL;YACE,KAAK,EAAE,2BAA2B;YAClC,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,WAAW,CAAC,SAAS;YAC3B,OAAO,EACL,kCAAkC,cAAc,aAAa;gBAC7D,wCAAwC,WAAW,CAAC,IAAI,UAAU;gBAClE,SAAS,QAAQ,sCAAsC;gBACvD,oEAAoE;gBACpE,mDAAmD;YACrD,IAAI,EACF,wDAAwD;gBACxD,GAAG,WAAW,CAAC,SAAS,6BAA6B,cAAc,IAAI;SAC1E;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n DefinitionCollisionInput,\n Finding,\n} from '@ekanos/integration-schema';\nimport {\n collectCollisionFindings,\n collectDefinitionFindings,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { preconditionError } from './errors';\nimport { collectIconFindings } from './icon-findings';\nimport { loadDefinition } from './load-definition';\nimport type { LoadedProject } from './project';\nimport {\n collectDocsFindings,\n collectHostCompilerRulesFindings,\n collectProjectFindings,\n} from './project-checks';\n\n/**\n * The full findings pass shared by `validate` (which reports them) and\n * `publish` (which refuses to submit on any error-severity finding). One\n * implementation so the publish gate can never drift from what `validate`\n * checks — a project that validates clean is, by construction, a project that\n * publish will accept locally.\n *\n * NOTE on schema skew: an earlier version of this function rewrote the\n * unrecognized-key hint when the project's `@ekanos/integration-schema` was\n * newer than the CLI's (see `schema-skew.ts`). That rewrite was dead code —\n * `assertSchemaNotSkewed` throws PRECONDITION_FAILED before either `validate`\n * or `publish` ever calls this function in that state, so a project-newer\n * finding can never reach here to be rewritten, and the precondition error\n * already names both versions and points at the fix. It was removed rather\n * than kept \"just in case\": if a future caller ever makes validate proceed\n * under skew instead of failing fast, THAT is when a rewrite here becomes\n * necessary again, and it should be reintroduced with a real caller driving\n * it, not tests that fake their own reachability.\n */\nexport async function collectAllFindings(\n loaded: LoadedProject,\n): Promise<Finding[]> {\n const findings: Finding[] = [];\n const definitions: DefinitionCollisionInput[] = [];\n\n for (const integration of loaded.integrations) {\n const result = await loadDefinition(\n integration.entryPath,\n loaded.projectDir,\n );\n\n if (result.ok) {\n findings.push(\n ...collectDefinitionFindings(result.definition, {\n file: integration.entryPath,\n }),\n );\n findings.push(\n ...collectSlugAgreementFindings(\n integration,\n result.definition as { slug?: unknown },\n ),\n );\n findings.push(\n ...collectVersionAgreementFindings(\n integration,\n result.definition as { version?: unknown },\n loaded.projectDir,\n ),\n );\n definitions.push(result.definition as DefinitionCollisionInput);\n continue;\n }\n\n if (result.kind === 'rejected') {\n // The module loaded but the SDK/schema rejected the definition at import\n // time — surface it as a validation finding rather than a crash.\n findings.push({\n check: 'definition.load',\n severity: 'error',\n file: integration.entryPath,\n message: result.message,\n hint:\n 'Fix the integration definition so defineIntegration() accepts it, ' +\n 'then re-run validate.',\n });\n continue;\n }\n\n // A genuine module-load failure is a precondition, not a finding.\n throw preconditionError(\n `Could not load the integration definition for \"${integration.slug}\": ` +\n result.message,\n 'Ensure the entry module and its installed dependencies load under ' +\n 'Node, then re-run validate.',\n );\n }\n\n // Cross-checks only mean something with more than one definition in hand.\n findings.push(...collectCollisionFindings(definitions));\n findings.push(...collectProjectFindings(loaded.projectDir));\n findings.push(...collectDocsFindings(loaded.project, loaded.projectDir));\n findings.push(...collectIconFindings(loaded.projectDir));\n findings.push(...collectHostCompilerRulesFindings(loaded.projectDir));\n\n return findings;\n}\n\n/**\n * `ekanos.json` and the definition each carry a slug, and nothing compared\n * them: a project could declare `something-else` while the definition said\n * `repo-activity` and validate would report `{ ok: true, findings: [] }`.\n *\n * That is the identifier every surface addresses the integration by — the\n * harness route, the product slug, the widget id prefix, the MCP server — so\n * two sources of truth disagreeing is not a style question. It is an error,\n * not a warning, for the same reason a silent default is worse than a loud\n * one: the failure it causes shows up somewhere else entirely.\n */\nfunction collectSlugAgreementFindings(\n integration: { slug: string; entry: string; entryPath: string },\n definition: { slug?: unknown },\n): Finding[] {\n const declared = definition.slug;\n if (typeof declared !== 'string' || declared === integration.slug) return [];\n\n return [\n {\n check: 'project.slug-agreement',\n severity: 'error',\n file: integration.entryPath,\n message:\n `ekanos.json declares slug \"${integration.slug}\" for this entry, but ` +\n `the definition says \"${declared}\". The slug addresses the ` +\n 'integration everywhere — its harness route, its product record, its ' +\n 'widget ids — so the two must agree.',\n hint:\n `Change one to match the other: either set \"slug\": \"${declared}\" in ` +\n `ekanos.json, or pass slug: '${integration.slug}' to ` +\n 'defineIntegration().',\n },\n ];\n}\n\n/**\n * `package.json`'s `version` field and the `version` `defineIntegration()`\n * declares are two more independent sources of truth for the same fact —\n * this project shipped weather@0.1.1 with a package.json bump, but the\n * declaration itself still said 0.1.0. Generated seeds embed the\n * DECLARATION's version in their header, so a stale declaration produces a\n * seed that looks stale even though the package itself moved on.\n *\n * WARN, not error, unlike slug agreement: a mismatched version is a quality\n * signal a partner should fix, not a broken cross-reference that breaks\n * something else at runtime, so it must not block `publish`. And a project\n * with no package.json, or a package.json with no `version` field, has\n * nothing to compare the declaration against — skip rather than warn on\n * absence.\n */\nexport function collectVersionAgreementFindings(\n integration: { slug: string; entry: string; entryPath: string },\n definition: { version?: unknown },\n projectDir: string,\n): Finding[] {\n const declared = definition.version;\n if (typeof declared !== 'string') return [];\n\n const manifestPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(manifestPath)) return [];\n\n let manifest: unknown;\n try {\n manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\n } catch {\n // Malformed package.json is npm's problem to report, not a validate\n // finding — nothing here can compare against an unparseable manifest.\n return [];\n }\n\n const packageVersion =\n typeof manifest === 'object' && manifest !== null\n ? (manifest as { version?: unknown }).version\n : undefined;\n if (typeof packageVersion !== 'string' || packageVersion === declared) {\n return [];\n }\n\n return [\n {\n check: 'project.version-agreement',\n severity: 'warn',\n file: integration.entryPath,\n message:\n `package.json declares version \"${packageVersion}\", but the ` +\n `defineIntegration() declaration for \"${integration.slug}\" still ` +\n `says \"${declared}\". Generated seed headers embed the ` +\n \"declaration's version, so a stale declaration ships stale-looking \" +\n 'metadata even though the package itself moved on.',\n hint:\n `Update the \"version\" passed to defineIntegration() in ` +\n `${integration.entryPath} to match package.json's \"${packageVersion}\".`,\n },\n ];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"wizard.js","sourceRoot":"","sources":["../src/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAyC1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,6DAA6D,CAC9D,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,KAAK,CAAC,KAAK;QACT,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,KAAK,CAAC,OAAO;QACX,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,KAAK;QACjB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,OAAO;QACZ,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,QAAQ,CAAC,KAAK;QACZ,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO;QACL,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QACrD,OAAO;YACL,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;YACpC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;SACnC,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,SAAS,CACvB,GAAe,EACf,QAAkC,EAAE;;IAEpC,MAAM,UAAU,GAAG,MAAA,KAAK,CAAC,UAAU,mCAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,WAAW,IAAI,UAAU,CAAC;AACxD,CAAC","sourcesContent":["import * as clack from '@clack/prompts';\n\nimport type { CliContext } from './context';\nimport { EXIT_CODES } from './exit-codes';\n\n/**\n * The clack-powered wizard seam.\n *\n * This is the ONE file in the package that imports `@clack/prompts` — `ui.ts`\n * stays prompt-free (its color/glyph tokens gate a PLAIN string renderer with\n * no interactivity of its own), and this module is the seam any future\n * prompt-driven command shares rather than each wiring clack directly. Thin,\n * named wrappers rather than a re-export of the clack namespace so a test can\n * `vi.mock('@clack/prompts')` and assert call order without its target\n * (`init`, `login`, …) needing to know clack exists underneath.\n *\n * A command reaches for this seam instead of `ui.ts`'s plain renderer only\n * when `canWizard()` below says yes — human mode AND a real stdout TTY AND a\n * real stdin TTY, all three, checked fresh for that command's own streams.\n * Anything less (JSON mode, a piped stream, a non-interactive stdin) falls\n * back to the plain renderer; this seam never partially renders.\n */\n\nexport interface WizardSpinner {\n start(message?: string): void;\n stop(message?: string): void;\n}\n\nexport interface Wizard {\n intro(title: string): void;\n outro(message: string): void;\n /** A block of pre-formatted, copy-pasteable text — clack draws a box around it. */\n note(message: string, title?: string): void;\n cancel(message: string): void;\n /** Passthrough of clack's cancel-symbol check, for a future prompt-based command. */\n isCancel(value: unknown): boolean;\n /**\n * A spinner pre-wired to exit cleanly on ctrl-c — see `exitCancelled` for\n * why this cannot simply throw and let `run()`'s try/catch take it from\n * there the way every other refusal in this CLI does.\n */\n spinner(): WizardSpinner;\n}\n\n/**\n * The ONE non-throwing exit path in this package. Every other refusal is a\n * `CliError` that `run()`'s top-level try/catch turns into `ctx.fail(...)` —\n * clean by construction, because it always has a live call stack to unwind\n * back to. A ctrl-c while a `wizard.spinner()` is running cannot take that\n * path: `@clack/prompts`' spinner registers its OWN `process.on('SIGINT', …)`\n * listener for the lifetime of `start()`..`stop()`, and Node only runs its\n * default exit-on-SIGINT behaviour when NO listener is registered — so\n * without an explicit exit here, ctrl-c would silently stop the spinner's\n * animation and otherwise do nothing, leaving `login`'s device-code poll\n * (which can legitimately run for minutes) spinning in the background with\n * no way back to a prompt.\n *\n * So this mirrors `ctx.fail`'s OUTPUT contract by hand — stderr only, an\n * `Error: …` / `Hint: …` pair, never a stack trace — and exits with the same\n * code a plain usage error would (`EXIT_CODES.USAGE`), matching every other\n * clean-refusal path in the CLI. Exported so tests can assert on it without\n * a real `process.exit` ending the test run.\n */\nexport function exitCancelled(): void {\n process.stderr.write(\n 'Error: Cancelled.\\nHint: Re-run the command to try again.\\n',\n );\n process.exit(EXIT_CODES.USAGE);\n}\n\nexport const wizard: Wizard = {\n intro(title) {\n clack.intro(title);\n },\n outro(message) {\n clack.outro(message);\n },\n note(message, title) {\n clack.note(message, title);\n },\n cancel(message) {\n clack.cancel(message);\n },\n isCancel(value) {\n return clack.isCancel(value);\n },\n spinner() {\n const s = clack.spinner({ onCancel: exitCancelled });\n return {\n start: (message) => s.start(message),\n stop: (message) => s.stop(message),\n };\n },\n};\n\n/**\n * Whether a clack-powered wizard flow may run for this invocation.\n *\n * Mirrors `publish.ts`'s `canPrompt`, with one addition: `ctx.jsonMode` alone\n * is not enough (`--no-json` forces human mode even against a piped stdout,\n * and says nothing about stdin), so this needs BOTH streams confirmed\n * interactive, not just one:\n *\n * - stdout a real TTY: clack renders to stdout (unlike the rest of this\n * CLI's human output, which is stderr-only — see `ui.ts`'s docs), and\n * `ctx.jsonMode` false does not by itself guarantee stdout is a terminal.\n * - stdin a real TTY: clack reads keypresses from it interactively. A\n * closed or non-interactive stdin (a cron job, a wrapper script) can\n * never resolve an interactive prompt, the same reason `publish`'s y/N\n * confirm gates on it.\n *\n * Anything else falls back to the plain, existing human-mode rendering —\n * never a hang.\n */\nexport function canWizard(\n ctx: CliContext,\n probe: { stdinIsTTY?: boolean } = {},\n): boolean {\n const stdinIsTTY = probe.stdinIsTTY ?? process.stdin.isTTY === true;\n return !ctx.jsonMode && ctx.stdoutIsTTY && stdinIsTTY;\n}\n"]}
1
+ {"version":3,"file":"wizard.js","sourceRoot":"","sources":["../src/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAyC1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,6DAA6D,CAC9D,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,KAAK,CAAC,KAAK;QACT,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,KAAK,CAAC,OAAO;QACX,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,KAAK;QACjB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,OAAO;QACZ,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,QAAQ,CAAC,KAAK;QACZ,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO;QACL,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QACrD,OAAO;YACL,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;YACpC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;SACnC,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,SAAS,CACvB,GAAe,EACf,KAAK,GAA6B,EAAE;;IAEpC,MAAM,UAAU,SAAG,KAAK,CAAC,UAAU,mCAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,WAAW,IAAI,UAAU,CAAC;AACxD,CAAC","sourcesContent":["import * as clack from '@clack/prompts';\n\nimport type { CliContext } from './context';\nimport { EXIT_CODES } from './exit-codes';\n\n/**\n * The clack-powered wizard seam.\n *\n * This is the ONE file in the package that imports `@clack/prompts` — `ui.ts`\n * stays prompt-free (its color/glyph tokens gate a PLAIN string renderer with\n * no interactivity of its own), and this module is the seam any future\n * prompt-driven command shares rather than each wiring clack directly. Thin,\n * named wrappers rather than a re-export of the clack namespace so a test can\n * `vi.mock('@clack/prompts')` and assert call order without its target\n * (`init`, `login`, …) needing to know clack exists underneath.\n *\n * A command reaches for this seam instead of `ui.ts`'s plain renderer only\n * when `canWizard()` below says yes — human mode AND a real stdout TTY AND a\n * real stdin TTY, all three, checked fresh for that command's own streams.\n * Anything less (JSON mode, a piped stream, a non-interactive stdin) falls\n * back to the plain renderer; this seam never partially renders.\n */\n\nexport interface WizardSpinner {\n start(message?: string): void;\n stop(message?: string): void;\n}\n\nexport interface Wizard {\n intro(title: string): void;\n outro(message: string): void;\n /** A block of pre-formatted, copy-pasteable text — clack draws a box around it. */\n note(message: string, title?: string): void;\n cancel(message: string): void;\n /** Passthrough of clack's cancel-symbol check, for a future prompt-based command. */\n isCancel(value: unknown): boolean;\n /**\n * A spinner pre-wired to exit cleanly on ctrl-c — see `exitCancelled` for\n * why this cannot simply throw and let `run()`'s try/catch take it from\n * there the way every other refusal in this CLI does.\n */\n spinner(): WizardSpinner;\n}\n\n/**\n * The ONE non-throwing exit path in this package. Every other refusal is a\n * `CliError` that `run()`'s top-level try/catch turns into `ctx.fail(...)` —\n * clean by construction, because it always has a live call stack to unwind\n * back to. A ctrl-c while a `wizard.spinner()` is running cannot take that\n * path: `@clack/prompts`' spinner registers its OWN `process.on('SIGINT', …)`\n * listener for the lifetime of `start()`..`stop()`, and Node only runs its\n * default exit-on-SIGINT behaviour when NO listener is registered — so\n * without an explicit exit here, ctrl-c would silently stop the spinner's\n * animation and otherwise do nothing, leaving `login`'s device-code poll\n * (which can legitimately run for minutes) spinning in the background with\n * no way back to a prompt.\n *\n * So this mirrors `ctx.fail`'s OUTPUT contract by hand — stderr only, an\n * `Error: …` / `Hint: …` pair, never a stack trace — and exits with the same\n * code a plain usage error would (`EXIT_CODES.USAGE`), matching every other\n * clean-refusal path in the CLI. Exported so tests can assert on it without\n * a real `process.exit` ending the test run.\n */\nexport function exitCancelled(): void {\n process.stderr.write(\n 'Error: Cancelled.\\nHint: Re-run the command to try again.\\n',\n );\n process.exit(EXIT_CODES.USAGE);\n}\n\nexport const wizard: Wizard = {\n intro(title) {\n clack.intro(title);\n },\n outro(message) {\n clack.outro(message);\n },\n note(message, title) {\n clack.note(message, title);\n },\n cancel(message) {\n clack.cancel(message);\n },\n isCancel(value) {\n return clack.isCancel(value);\n },\n spinner() {\n const s = clack.spinner({ onCancel: exitCancelled });\n return {\n start: (message) => s.start(message),\n stop: (message) => s.stop(message),\n };\n },\n};\n\n/**\n * Whether a clack-powered wizard flow may run for this invocation.\n *\n * Mirrors `publish.ts`'s `canPrompt`, with one addition: `ctx.jsonMode` alone\n * is not enough (`--no-json` forces human mode even against a piped stdout,\n * and says nothing about stdin), so this needs BOTH streams confirmed\n * interactive, not just one:\n *\n * - stdout a real TTY: clack renders to stdout (unlike the rest of this\n * CLI's human output, which is stderr-only — see `ui.ts`'s docs), and\n * `ctx.jsonMode` false does not by itself guarantee stdout is a terminal.\n * - stdin a real TTY: clack reads keypresses from it interactively. A\n * closed or non-interactive stdin (a cron job, a wrapper script) can\n * never resolve an interactive prompt, the same reason `publish`'s y/N\n * confirm gates on it.\n *\n * Anything else falls back to the plain, existing human-mode rendering —\n * never a hang.\n */\nexport function canWizard(\n ctx: CliContext,\n probe: { stdinIsTTY?: boolean } = {},\n): boolean {\n const stdinIsTTY = probe.stdinIsTTY ?? process.stdin.isTTY === true;\n return !ctx.jsonMode && ctx.stdoutIsTTY && stdinIsTTY;\n}\n"]}
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@ekanos/cli",
3
- "version": "0.3.2",
4
- "type": "module",
5
- "description": "The Ekanos partner toolchain CLI: scaffold, validate, and test a Fusion integration against the published @ekanos packages. Agent-native — every verb speaks JSON with a stable exit-code taxonomy.",
6
- "license": "MIT",
7
- "bugs": {
8
- "email": "npm@govastly.com"
9
- },
3
+ "version": "0.3.4",
4
+ "description": "The Ekanos partner toolchain CLI: scaffold, validate, and test an Ekanos integration against the published @ekanos packages. Agent-native — every verb speaks JSON with a stable exit-code taxonomy.",
10
5
  "keywords": [
6
+ "cli",
11
7
  "ekanos",
12
8
  "fusion",
13
- "integration",
14
- "cli"
9
+ "integration"
15
10
  ],
11
+ "bugs": {
12
+ "email": "npm@govastly.com"
13
+ },
14
+ "license": "MIT",
16
15
  "bin": {
17
16
  "ekanos": "./dist/bin.js"
18
17
  },
@@ -22,6 +21,7 @@
22
21
  "README.md",
23
22
  "LICENSE"
24
23
  ],
24
+ "type": "module",
25
25
  "exports": {
26
26
  ".": {
27
27
  "types": "./dist/index.d.ts",
@@ -33,30 +33,25 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@clack/prompts": "1.7.0",
36
- "@ekanos/integration-schema": "0.3.0",
36
+ "@ekanos/integration-schema": "0.4.0",
37
37
  "esbuild": "0.28.1",
38
38
  "picocolors": "1.1.1"
39
39
  },
40
- "peerDependencies": {
41
- "zod": "^3.25.76"
42
- },
43
40
  "devDependencies": {
44
- "@kit/eslint-config": "0.2.0",
45
- "@kit/prettier-config": "0.1.0",
46
41
  "@kit/tsconfig": "0.1.0",
47
42
  "@types/node": "25.0.1",
48
- "typescript": "^5.9.3",
43
+ "typescript": "^7.0.2",
49
44
  "vitest": "4.1.10",
50
- "zod": "3.25.76"
45
+ "zod": "4.6.5"
46
+ },
47
+ "peerDependencies": {
48
+ "zod": "^3.25.76 || ^4.0.0"
51
49
  },
52
- "prettier": "@kit/prettier-config",
53
50
  "scripts": {
54
51
  "build": "tsc -p tsconfig.build.json && node scripts/rewrite-esm-specifiers.mjs",
55
52
  "check:fa-free-names": "node scripts/generate-fa-free-names.mjs",
56
53
  "clean": "git clean -xdf .turbo node_modules dist",
57
- "format": "prettier --check \"**/*.{ts,tsx}\"",
58
54
  "generate:fa-free-names": "node scripts/generate-fa-free-names.mjs --write",
59
- "lint": "eslint .",
60
55
  "typecheck": "tsc --noEmit",
61
56
  "test": "vitest run --config vitest.config.ts"
62
57
  },
@@ -1,6 +1,6 @@
1
1
  # __DISPLAY_NAME__ — an Ekanos integration
2
2
 
3
- This project is a **Fusion integration** built with `@ekanos/sdk`. This file is
3
+ This project is a **Ekanos integration** built with `@ekanos/sdk`. This file is
4
4
  the authoring contract: everything an agent needs to build, test, and publish
5
5
  it without fetching external documentation. The `@ekanos/sdk` README (in
6
6
  `node_modules/@ekanos/sdk/README.md` after install) is the long-form version;
@@ -164,7 +164,12 @@ your slug at discovery.
164
164
 
165
165
  Declared with kebab-case ids. The transport validates `payloadSchema` before
166
166
  your handler runs and owns signature verification (`signature: { header,
167
- secretName }` or `'none'`) — never verify a signature in the handler.
167
+ secretName, scheme? }` or `'none'`) — never verify a signature in the handler.
168
+ Omit `scheme` for a plain HMAC-SHA256 body digest; declare one for keyed or
169
+ timestamped headers (Stripe/Calendly: `{ format: 'keyed', digestKey: 'v1',
170
+ timestampKey: 't', signedPayload: '{timestamp}.{body}' }`) or SHA-1
171
+ (`{ algorithm: 'sha1' }`). The README's `signature.scheme` table has the
172
+ common providers.
168
173
 
169
174
  Webhook results: `{ status: 'processed' }` (done), `{ status: 'ignored' }`
170
175
  (valid but irrelevant — the sender must not retry), or **throw** (retryable
@@ -307,7 +312,7 @@ system. Available modules (import individually, e.g. `@ekanos/ui/button`):
307
312
  `ai-prompt-input`, plus the stylesheets `styles.css` / `tokens.css` /
308
313
  `theme.css` / `base.css`. Icons are Font Awesome glyph names via
309
314
  `@ekanos/ui/icon`. This generated shell loads Font Awesome **Free**
310
- (`@fortawesome/fontawesome-free`) — a much smaller set than the Pro kit Fusion
315
+ (`@fortawesome/fontawesome-free`) — a much smaller set than the Pro kit Ekanos
311
316
  itself runs — so a name that's Pro-only (or just mistyped) renders a
312
317
  circle-question disc instead of vanishing, and dev builds `console.warn` once
313
318
  per name to catch it before a screenshot review does. `fa-light` / `fa-duotone`
@@ -320,7 +325,7 @@ it looking like anything in particular.
320
325
 
321
326
  ## Live mode — real API calls, locally
322
327
 
323
- The harness (`npx ekanos dev`) mocks FUSION, not your vendor. **You do not
328
+ The harness (`npx ekanos dev`) mocks EKANOS, not your vendor. **You do not
324
329
  need mock data to develop against the real API**, and never claim otherwise:
325
330
  the dev toolbar has a fixtures ⇄ live switch per integration, and in live
326
331
  mode your widgets' real query functions — calling `useIntegrationFetch()` —
@@ -336,7 +341,7 @@ Live mode is opt-in per integration. Add a `live` block to the entry in
336
341
 
337
342
  ```ts
338
343
  live: {
339
- // Fusion-side state widgets read before calling anything — what your
344
+ // Ekanos-side state widgets read before calling anything — what your
340
345
  // host route would have returned. Everything NOT seeded runs its real
341
346
  // query function against the real network.
342
347
  seeds: [{ queryKey: settingsKey, data: MY_SETTINGS }],
@@ -349,7 +354,7 @@ vendor from the browser (every vendor call is server-side behind `ctx.fetch`,
349
354
  the OAuth shape): the harness then opens in Live API, and nothing fires at the
350
355
  vendor until the user acts. A choice made at the toolbar always wins.
351
356
 
352
- There is still no Fusion database or auth in either mode. What differs is
357
+ There is still no Ekanos database or auth in either mode. What differs is
353
358
  who answers `/api/integrations/<slug>/…`:
354
359
 
355
360
  - **Fixtures**: your fixtures do, in the browser. Storage, secrets and the
@@ -468,9 +473,9 @@ carries an imperative `hint`; treat hints as remediation instructions.
468
473
  | `ekanos validate` | Parse ekanos.json + load the definition + run every finding pass. Findings land in `data.findings`, each with severity and a hint |
469
474
  | `ekanos dev` | Scaffold `.ekanos/harness` and run the integration in a local Next dev shell (loopback by default) |
470
475
  | `ekanos test` | Run this project's test script through its package manager |
471
- | `ekanos login --host <url>` | Device-flow login to a Fusion deployment (stores the host for later verbs) |
476
+ | `ekanos login --host <url>` | Device-flow login to an Ekanos deployment (stores the host for later verbs) |
472
477
  | `ekanos status` | Login state for the resolved host + this project's submissions |
473
- | `ekanos sources` | List every Fusion source you hold a developer/admin seat on, marking this project's current target |
478
+ | `ekanos sources` | List every Ekanos source you hold a developer/admin seat on, marking this project's current target |
474
479
  | `ekanos use <source-slug>` | Set this project's publish target — refuses (`forbidden`) a slug you hold no seat on |
475
480
  | `ekanos publish` | Validate, pack (whitelist: ekanos.json, package.json, README.md, src/), verify the target, and submit. Refuses on any error-severity finding |
476
481
  | `ekanos upgrade` | Move this project's toolchain to a coherent target version, with verify-and-rollback |
@@ -1,6 +1,6 @@
1
1
  # __DISPLAY_NAME__
2
2
 
3
- This project is an Ekanos integration for the Fusion platform — read
3
+ This project is an Ekanos integration for the Ekanos platform — read
4
4
  [AGENTS.md](./AGENTS.md) for the full authoring contract before changing code.
5
5
  The toolchain is `npx ekanos <verb>` (init, validate, dev, test, login,
6
6
  status, publish, upgrade); every verb supports `--json` and a stable
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ekanos
3
- description: Build, iterate on, validate, and publish this Fusion integration with the ekanos CLI. Use for any change to the integration definition, widgets, tools, webhooks, schedules, or tests, and for publishing to a Fusion host.
3
+ description: Build, iterate on, validate, and publish this Ekanos integration with the ekanos CLI. Use for any change to the integration definition, widgets, tools, webhooks, schedules, or tests, and for publishing to an Ekanos host.
4
4
  ---
5
5
 
6
6
  # Working on this Ekanos integration
@@ -35,7 +35,7 @@ in the same commit when the live API disagrees.
35
35
  `--source <slug>` explicitly to `publish`. Never pass `--yes` to get past
36
36
  an ambiguous-target error you have not actually resolved — `--yes` is
37
37
  consent to a target you already chose, not a way to silence the check.
38
- 7. `npx ekanos publish --source <slug>` — submits to the Fusion host (refuses
38
+ 7. `npx ekanos publish --source <slug>` — submits to the Ekanos host (refuses
39
39
  while any error-severity finding remains, and refuses `forbidden` if you
40
40
  hold no seat on that source).
41
41
 
@@ -23,7 +23,7 @@ const config = {
23
23
  turbopack: {
24
24
  root: projectRoot,
25
25
  resolveAlias: {
26
- // A widget written for the real Fusion host imports
26
+ // A widget written for the real Ekanos host imports
27
27
  // `useTeamAccountWorkspace()` to read `account.slug`. That module
28
28
  // reaches Supabase, which the harness deliberately does not have, so
29
29
  // this points the specifier at the shape-identical mock @ekanos/harness