@ekanos/cli 0.1.0 → 0.1.2

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 (47) hide show
  1. package/README.md +35 -4
  2. package/dist/auth/session.d.ts +25 -7
  3. package/dist/auth/session.js +88 -15
  4. package/dist/auth/session.js.map +1 -1
  5. package/dist/commands/init.d.ts +8 -1
  6. package/dist/commands/init.js +17 -3
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/login.d.ts +2 -0
  9. package/dist/commands/login.js +7 -0
  10. package/dist/commands/login.js.map +1 -1
  11. package/dist/commands/logout.d.ts +2 -0
  12. package/dist/commands/logout.js +3 -1
  13. package/dist/commands/logout.js.map +1 -1
  14. package/dist/commands/publish.d.ts +26 -0
  15. package/dist/commands/publish.js +196 -0
  16. package/dist/commands/publish.js.map +1 -0
  17. package/dist/commands/status.d.ts +28 -0
  18. package/dist/commands/status.js +146 -0
  19. package/dist/commands/status.js.map +1 -0
  20. package/dist/commands/validate.d.ts +3 -0
  21. package/dist/commands/validate.js +6 -69
  22. package/dist/commands/validate.js.map +1 -1
  23. package/dist/commands/whoami.d.ts +2 -0
  24. package/dist/commands/whoami.js +3 -1
  25. package/dist/commands/whoami.js.map +1 -1
  26. package/dist/errors.d.ts +2 -0
  27. package/dist/errors.js +9 -0
  28. package/dist/errors.js.map +1 -1
  29. package/dist/index.js +41 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/pack.d.ts +14 -0
  32. package/dist/pack.js +157 -0
  33. package/dist/pack.js.map +1 -0
  34. package/dist/project.d.ts +20 -22
  35. package/dist/project.js +43 -1
  36. package/dist/project.js.map +1 -1
  37. package/dist/publish-api.d.ts +103 -0
  38. package/dist/publish-api.js +202 -0
  39. package/dist/publish-api.js.map +1 -0
  40. package/dist/validate-findings.d.ts +10 -0
  41. package/dist/validate-findings.js +78 -0
  42. package/dist/validate-findings.js.map +1 -0
  43. package/package.json +2 -2
  44. package/templates/AGENTS.md.tmpl +247 -0
  45. package/templates/CLAUDE.md.tmpl +6 -0
  46. package/templates/claude-skill.md.tmpl +53 -0
  47. package/templates/package.json.tmpl +1 -0
package/dist/errors.js CHANGED
@@ -83,6 +83,15 @@ export function forbiddenError(message, hint) {
83
83
  hint,
84
84
  });
85
85
  }
86
+ /** A publish gate rejected the submission. Exit 10. */
87
+ export function gateFailedError(message, hint) {
88
+ return new CliError({
89
+ code: ERROR_CODES.GATE_FAILED,
90
+ exitCode: EXIT_CODES.GATE_FAILED,
91
+ message,
92
+ hint,
93
+ });
94
+ }
86
95
  /** A network operation failed (DNS, TLS, timeout, 5xx). Exit 8. */
87
96
  export function networkError(message, hint) {
88
97
  return new CliError({
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,GAGX,MAAM,cAAc,CAAC;AAEtB;;;;;;;GAOG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAKjC,YAAY,MAKX;QACC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvB,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,CAAC,OAAO,wCAAwC;gBACrE,uDAAuD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF;AAED,kEAAkE;AAClE,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,IAAY;IACtD,OAAO,IAAI,QAAQ,CAAC;QA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AED,qDAAqD;AACrD,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,IAAY;IAC1D,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,SAAS;QAC3B,QAAQ,EAAE,UAAU,CAAC,SAAS;QAC9B,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,IAAY;IACxD,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,OAAO;QACzB,QAAQ,EAAE,UAAU,CAAC,OAAO;QAC5B,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAI,KAAK,YAAY,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,QAAQ;QAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO;QACP,IAAI,EACF,wEAAwE;YACxE,4DAA4D;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n ERROR_CODES,\n EXIT_CODES,\n type ErrorCode,\n type ExitCode,\n} from './exit-codes';\n\n/**\n * The one error type every command path throws. It carries the three things\n * the envelope needs — a stable string `code`, a human `message`, and a\n * non-empty imperative `hint` — plus the numeric `exitCode` the process ends\n * with. Constructing one with an empty hint is a programming error and throws\n * immediately, which is what lets `context.fail()` guarantee the envelope's\n * \"every error has a hint\" invariant without a runtime check at the edge.\n */\nexport class CliError extends Error {\n readonly code: ErrorCode;\n readonly exitCode: ExitCode;\n readonly hint: string;\n\n constructor(params: {\n code: ErrorCode;\n exitCode: ExitCode;\n message: string;\n hint: string;\n }) {\n super(params.message);\n this.name = 'CliError';\n\n if (!params.hint || params.hint.trim().length === 0) {\n throw new Error(\n `CliError for \"${params.message}\" was constructed with an empty hint. ` +\n 'Every CLI error must carry an imperative remediation.',\n );\n }\n\n this.code = params.code;\n this.exitCode = params.exitCode;\n this.hint = params.hint;\n }\n}\n\n/** A usage error (unknown flag/command, bad argument). Exit 2. */\nexport function usageError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.USAGE,\n exitCode: EXIT_CODES.USAGE,\n message,\n hint,\n });\n}\n\n/** Validation produced error-severity findings. Exit 3. */\nexport function validationError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.VALIDATION,\n exitCode: EXIT_CODES.VALIDATION,\n message,\n hint,\n });\n}\n\n/** A precondition failure (missing tool, config, or file). Exit 9. */\nexport function preconditionError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.PRECONDITION_FAILED,\n exitCode: EXIT_CODES.PRECONDITION_FAILED,\n message,\n hint,\n });\n}\n\n/** An invalid-state failure (idempotency / ordering). Exit 7. */\nexport function invalidStateError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.INVALID_STATE,\n exitCode: EXIT_CODES.INVALID_STATE,\n message,\n hint,\n });\n}\n\n/** A not-found failure. Exit 6. */\nexport function notFoundError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NOT_FOUND,\n exitCode: EXIT_CODES.NOT_FOUND,\n message,\n hint,\n });\n}\n\n/** Authentication is required but absent or expired. Exit 4. */\nexport function authRequiredError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.AUTH_REQUIRED,\n exitCode: EXIT_CODES.AUTH_REQUIRED,\n message,\n hint,\n });\n}\n\n/** Authenticated, but the server refused. Exit 5. */\nexport function forbiddenError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.FORBIDDEN,\n exitCode: EXIT_CODES.FORBIDDEN,\n message,\n hint,\n });\n}\n\n/** A network operation failed (DNS, TLS, timeout, 5xx). Exit 8. */\nexport function networkError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NETWORK,\n exitCode: EXIT_CODES.NETWORK,\n message,\n hint,\n });\n}\n\n/**\n * Coerce anything thrown into a CliError. A thrown CliError passes through; a\n * plain Error becomes an INTERNAL (exit 1) with a generic-but-non-empty hint.\n */\nexport function toCliError(error: unknown): CliError {\n if (error instanceof CliError) return error;\n\n const message = error instanceof Error ? error.message : String(error);\n return new CliError({\n code: ERROR_CODES.INTERNAL,\n exitCode: EXIT_CODES.INTERNAL,\n message,\n hint:\n 'This is an internal CLI error. Re-run with --json to capture the full ' +\n 'envelope and report it at npm@govastly.com if it persists.',\n });\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,GAGX,MAAM,cAAc,CAAC;AAEtB;;;;;;;GAOG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAKjC,YAAY,MAKX;QACC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvB,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,CAAC,OAAO,wCAAwC;gBACrE,uDAAuD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF;AAED,kEAAkE;AAClE,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,IAAY;IACtD,OAAO,IAAI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AAC;AACL,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,IAAY;IAC1D,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,SAAS;QAC3B,QAAQ,EAAE,UAAU,CAAC,SAAS;QAC9B,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,IAAY;IAC3D,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,WAAW;QAC7B,QAAQ,EAAE,UAAU,CAAC,WAAW;QAChC,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,IAAY;IACxD,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,OAAO;QACzB,QAAQ,EAAE,UAAU,CAAC,OAAO;QAC5B,OAAO;QACP,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAI,KAAK,YAAY,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,WAAW,CAAC,QAAQ;QAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO;QACP,IAAI,EACF,wEAAwE;YACxE,4DAA4D;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n ERROR_CODES,\n EXIT_CODES,\n type ErrorCode,\n type ExitCode,\n} from './exit-codes';\n\n/**\n * The one error type every command path throws. It carries the three things\n * the envelope needs — a stable string `code`, a human `message`, and a\n * non-empty imperative `hint` — plus the numeric `exitCode` the process ends\n * with. Constructing one with an empty hint is a programming error and throws\n * immediately, which is what lets `context.fail()` guarantee the envelope's\n * \"every error has a hint\" invariant without a runtime check at the edge.\n */\nexport class CliError extends Error {\n readonly code: ErrorCode;\n readonly exitCode: ExitCode;\n readonly hint: string;\n\n constructor(params: {\n code: ErrorCode;\n exitCode: ExitCode;\n message: string;\n hint: string;\n }) {\n super(params.message);\n this.name = 'CliError';\n\n if (!params.hint || params.hint.trim().length === 0) {\n throw new Error(\n `CliError for \"${params.message}\" was constructed with an empty hint. ` +\n 'Every CLI error must carry an imperative remediation.',\n );\n }\n\n this.code = params.code;\n this.exitCode = params.exitCode;\n this.hint = params.hint;\n }\n}\n\n/** A usage error (unknown flag/command, bad argument). Exit 2. */\nexport function usageError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.USAGE,\n exitCode: EXIT_CODES.USAGE,\n message,\n hint,\n });\n}\n\n/** Validation produced error-severity findings. Exit 3. */\nexport function validationError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.VALIDATION,\n exitCode: EXIT_CODES.VALIDATION,\n message,\n hint,\n });\n}\n\n/** A precondition failure (missing tool, config, or file). Exit 9. */\nexport function preconditionError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.PRECONDITION_FAILED,\n exitCode: EXIT_CODES.PRECONDITION_FAILED,\n message,\n hint,\n });\n}\n\n/** An invalid-state failure (idempotency / ordering). Exit 7. */\nexport function invalidStateError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.INVALID_STATE,\n exitCode: EXIT_CODES.INVALID_STATE,\n message,\n hint,\n });\n}\n\n/** A not-found failure. Exit 6. */\nexport function notFoundError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NOT_FOUND,\n exitCode: EXIT_CODES.NOT_FOUND,\n message,\n hint,\n });\n}\n\n/** Authentication is required but absent or expired. Exit 4. */\nexport function authRequiredError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.AUTH_REQUIRED,\n exitCode: EXIT_CODES.AUTH_REQUIRED,\n message,\n hint,\n });\n}\n\n/** Authenticated, but the server refused. Exit 5. */\nexport function forbiddenError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.FORBIDDEN,\n exitCode: EXIT_CODES.FORBIDDEN,\n message,\n hint,\n });\n}\n\n/** A publish gate rejected the submission. Exit 10. */\nexport function gateFailedError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.GATE_FAILED,\n exitCode: EXIT_CODES.GATE_FAILED,\n message,\n hint,\n });\n}\n\n/** A network operation failed (DNS, TLS, timeout, 5xx). Exit 8. */\nexport function networkError(message: string, hint: string): CliError {\n return new CliError({\n code: ERROR_CODES.NETWORK,\n exitCode: EXIT_CODES.NETWORK,\n message,\n hint,\n });\n}\n\n/**\n * Coerce anything thrown into a CliError. A thrown CliError passes through; a\n * plain Error becomes an INTERNAL (exit 1) with a generic-but-non-empty hint.\n */\nexport function toCliError(error: unknown): CliError {\n if (error instanceof CliError) return error;\n\n const message = error instanceof Error ? error.message : String(error);\n return new CliError({\n code: ERROR_CODES.INTERNAL,\n exitCode: EXIT_CODES.INTERNAL,\n message,\n hint:\n 'This is an internal CLI error. Re-run with --json to capture the full ' +\n 'envelope and report it at npm@govastly.com if it persists.',\n });\n}\n"]}
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@ import { runDev } from './commands/dev.js';
3
3
  import { runInit } from './commands/init.js';
4
4
  import { runLogin } from './commands/login.js';
5
5
  import { runLogout } from './commands/logout.js';
6
+ import { runPublish } from './commands/publish.js';
7
+ import { runStatus } from './commands/status.js';
6
8
  import { runTest } from './commands/test.js';
7
9
  import { runValidate } from './commands/validate.js';
8
10
  import { runWhoami } from './commands/whoami.js';
@@ -48,19 +50,38 @@ const COMMAND_SPECS = {
48
50
  whoami: {
49
51
  host: { type: 'string' },
50
52
  },
53
+ status: {
54
+ host: { type: 'string' },
55
+ dir: { type: 'string' },
56
+ },
57
+ publish: {
58
+ host: { type: 'string' },
59
+ source: { type: 'string' },
60
+ dir: { type: 'string' },
61
+ yes: { type: 'boolean' },
62
+ },
51
63
  };
52
64
  const COMMANDS = Object.keys(COMMAND_SPECS);
53
65
  const USAGE = [
54
66
  'Usage: ekanos <command> [options]',
55
67
  '',
56
68
  'Commands:',
57
- ' init Scaffold a new integration project (--slug <slug> --yes)',
69
+ ' init Scaffold a new integration project into ./<slug> (--slug <slug> --yes)',
58
70
  ' validate Validate ekanos.json + the integration definition (--json)',
59
71
  ' dev Scaffold .ekanos/harness and run it with your own Next',
60
72
  ' test Run the project test script via its package manager (--json)',
61
73
  ' login Authenticate against a Fusion host in a browser (--host <url>)',
62
74
  ' logout Revoke and delete the stored session (--host <url> | --all)',
63
75
  ' whoami Print the identity the stored session authenticates as',
76
+ " status Show login state and this project's submissions on the host",
77
+ ' publish Validate, pack and submit the integration to a Fusion host',
78
+ '',
79
+ 'Host resolution (logout, whoami, status, publish):',
80
+ ' --host, else EKANOS_HOST, else the "host" field in ekanos.json, else the',
81
+ ' sole stored login. "ekanos publish" saves host and source to ekanos.json.',
82
+ ' "ekanos login" never reads ekanos.json for a host (--host, else',
83
+ ' EKANOS_HOST, else the sole stored login) — it is the verb that creates',
84
+ ' credentials, so a committed file must never choose where they go.',
64
85
  '',
65
86
  'Global options:',
66
87
  ' --json Emit a single JSON envelope on stdout (auto-on when piped);',
@@ -130,7 +151,8 @@ export async function run(argv, options = {}) {
130
151
  case 'init':
131
152
  return runInit(ctx, {
132
153
  slug: parsed.flags.slug,
133
- dir,
154
+ dir: parsed.flags.dir,
155
+ cwd,
134
156
  force: parsed.flags.force === true,
135
157
  yes: parsed.flags.yes === true,
136
158
  });
@@ -150,17 +172,34 @@ export async function run(argv, options = {}) {
150
172
  return await runLogin(ctx, {
151
173
  host: parsed.flags.host,
152
174
  force: parsed.flags.force === true,
175
+ cwd,
153
176
  env,
154
177
  });
155
178
  case 'logout':
156
179
  return await runLogout(ctx, {
157
180
  host: parsed.flags.host,
158
181
  all: parsed.flags.all === true,
182
+ cwd,
159
183
  env,
160
184
  });
161
185
  case 'whoami':
162
186
  return await runWhoami(ctx, {
163
187
  host: parsed.flags.host,
188
+ cwd,
189
+ env,
190
+ });
191
+ case 'status':
192
+ return await runStatus(ctx, {
193
+ host: parsed.flags.host,
194
+ dir,
195
+ env,
196
+ });
197
+ case 'publish':
198
+ return await runPublish(ctx, {
199
+ host: parsed.flags.host,
200
+ source: parsed.flags.source,
201
+ dir,
202
+ yes: parsed.flags.yes === true,
164
203
  env,
165
204
  });
166
205
  default:
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGvD,MAAM,YAAY,GAAc;IAC9B,IAAI,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AAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,eAAe,CAAC,GAAe,EAAE,OAAe;;IACvD,MAAM,KAAK,GAAG,MAAA,aAAa,CAAC,OAAO,CAAC,mCAAI,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,iBAAiB,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;IAC/D,GAAG,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import * as fs from 'node:fs';\n\nimport { runDev } from './commands/dev';\nimport { runInit } from './commands/init';\nimport { runLogin } from './commands/login';\nimport { runLogout } from './commands/logout';\nimport { runTest } from './commands/test';\nimport { runValidate } from './commands/validate';\nimport { runWhoami } from './commands/whoami';\nimport { CliContext, type WriteStream } from './context';\nimport { toCliError, usageError } from './errors';\nimport { EXIT_CODES } from './exit-codes';\nimport { type FlagSpecs, parseArgv } from './parse-argv';\n\nexport { CliContext } from './context';\nexport { EXIT_CODES, ERROR_CODES } from './exit-codes';\nexport type { ExitCode, ErrorCode } from './exit-codes';\n\nconst GLOBAL_SPECS: FlagSpecs = {\n json: { type: 'boolean' },\n help: { type: 'boolean' },\n version: { type: 'boolean' },\n};\n\nconst COMMAND_SPECS: Record<string, FlagSpecs> = {\n init: {\n slug: { type: 'string' },\n dir: { type: 'string' },\n force: { type: 'boolean' },\n yes: { type: 'boolean' },\n },\n validate: {\n dir: { type: 'string' },\n },\n dev: {\n dir: { type: 'string' },\n port: { type: 'string' },\n host: { type: 'string' },\n force: { type: 'boolean' },\n start: { type: 'boolean' },\n },\n test: {\n dir: { type: 'string' },\n },\n login: {\n host: { type: 'string' },\n force: { type: 'boolean' },\n },\n logout: {\n host: { type: 'string' },\n all: { type: 'boolean' },\n },\n whoami: {\n host: { type: 'string' },\n },\n};\n\nconst COMMANDS = Object.keys(COMMAND_SPECS);\n\nconst USAGE = [\n 'Usage: ekanos <command> [options]',\n '',\n 'Commands:',\n ' init Scaffold a new integration project (--slug <slug> --yes)',\n ' validate Validate ekanos.json + the integration definition (--json)',\n ' dev Scaffold .ekanos/harness and run it with your own Next',\n ' test Run the project test script via its package manager (--json)',\n ' login Authenticate against a Fusion host in a browser (--host <url>)',\n ' logout Revoke and delete the stored session (--host <url> | --all)',\n ' whoami Print the identity the stored session authenticates as',\n '',\n 'Global options:',\n ' --json Emit a single JSON envelope on stdout (auto-on when piped);',\n ' --no-json forces the human-readable form',\n ' --version Print the CLI version',\n ' --help Show this help',\n].join('\\n');\n\nexport interface RunOptions {\n stdout?: WriteStream;\n stderr?: WriteStream;\n env?: Record<string, string | undefined>;\n cwd?: string;\n}\n\n/**\n * The single entry point. Resolves the agent-native envelope once, dispatches\n * to a verb, and guarantees exactly one terminal emission (success or error).\n * Returns the process exit code — `bin.ts` is the only place that calls\n * `process.exit`, so this stays fully testable.\n */\nexport async function run(\n argv: readonly string[],\n options: RunOptions = {},\n): Promise<number> {\n const jsonFlag = scanJsonFlag(argv);\n const ctx = new CliContext({\n jsonFlag,\n stdout: options.stdout,\n stderr: options.stderr,\n env: options.env,\n });\n const cwd = options.cwd ?? process.cwd();\n const env = options.env ?? process.env;\n\n try {\n // `--version` is global and verb-independent, so it is answered before the\n // command is even resolved: `ekanos --version` and `ekanos validate\n // --version` both report the tool's version and exit 0.\n if (scanFlagPresence(argv, 'version')) {\n return emitVersion(ctx);\n }\n\n const { command, rest } = splitCommand(argv);\n\n // Top-level help / no command.\n if (!command) {\n if (scanFlagPresence(rest, 'help') || argv.length === 0) {\n return emitHelp(ctx);\n }\n // A leading token that is not a command (e.g. `--nonsense`).\n ctx.emitClaudeCodeHint({\n tool: 'ekanos',\n error: 'unknown-command',\n commands: COMMANDS,\n usage: USAGE,\n });\n throw usageError(\n `Unknown command or flag \"${argv[0]}\".`,\n `Run one of: ${COMMANDS.join(', ')}. See \"ekanos --help\".`,\n );\n }\n\n if (!COMMANDS.includes(command)) {\n ctx.emitClaudeCodeHint({\n tool: 'ekanos',\n error: 'unknown-command',\n given: command,\n commands: COMMANDS,\n usage: USAGE,\n });\n throw usageError(\n `Unknown command \"${command}\".`,\n `Run one of: ${COMMANDS.join(', ')}. See \"ekanos --help\".`,\n );\n }\n\n const specs: FlagSpecs = { ...GLOBAL_SPECS, ...COMMAND_SPECS[command] };\n const parsed = parseArgv(rest, specs);\n\n if (parsed.flags.help === true) {\n return emitCommandHelp(ctx, command);\n }\n\n if (parsed.positionals.length > 0) {\n throw usageError(\n `\"${command}\" takes no positional arguments (got \"${parsed.positionals[0]}\").`,\n `Pass options as flags, e.g. \"--dir <path>\". See \"ekanos ${command} --help\".`,\n );\n }\n\n const dir = (parsed.flags.dir as string | undefined) ?? cwd;\n\n switch (command) {\n case 'init':\n return runInit(ctx, {\n slug: parsed.flags.slug as string | undefined,\n dir,\n force: parsed.flags.force === true,\n yes: parsed.flags.yes === true,\n });\n case 'validate':\n return await runValidate(ctx, { dir });\n case 'dev':\n return await runDev(ctx, {\n dir,\n port: parsed.flags.port as string | undefined,\n host: parsed.flags.host as string | undefined,\n force: parsed.flags.force === true,\n start: parsed.flags.start as boolean | undefined,\n });\n case 'test':\n return await runTest(ctx, { dir, passthrough: parsed.passthrough });\n case 'login':\n return await runLogin(ctx, {\n host: parsed.flags.host as string | undefined,\n force: parsed.flags.force === true,\n env,\n });\n case 'logout':\n return await runLogout(ctx, {\n host: parsed.flags.host as string | undefined,\n all: parsed.flags.all === true,\n env,\n });\n case 'whoami':\n return await runWhoami(ctx, {\n host: parsed.flags.host as string | undefined,\n env,\n });\n default:\n // Unreachable — COMMANDS gate above — but keeps the switch total.\n throw usageError(\n `Unknown command \"${command}\".`,\n `Run one of: ${COMMANDS.join(', ')}.`,\n );\n }\n } catch (error) {\n return ctx.fail(toCliError(error));\n }\n}\n\n/**\n * Presence of `--json` (or `--no-json`) BEFORE the first `--` passthrough.\n *\n * Tri-state on purpose. `undefined` means \"the user expressed no preference\",\n * which is what lets the context fall back to inferring the mode from a\n * non-TTY stdout or CLAUDECODE. Collapsing `--no-json` to `false` here would\n * make it indistinguishable from absence, and the flag could then never turn\n * JSON mode OFF in exactly the cases it exists for.\n */\nfunction scanJsonFlag(argv: readonly string[]): boolean | undefined {\n for (const token of argv) {\n if (token === '--') break;\n if (token === '--json') return true;\n if (token === '--no-json') return false;\n }\n return undefined;\n}\n\nfunction scanFlagPresence(argv: readonly string[], name: string): boolean {\n for (const token of argv) {\n if (token === '--') break;\n if (token === `--${name}`) return true;\n }\n return false;\n}\n\n/**\n * Split argv into the command (first bare token before `--`) and the rest\n * (everything else, order preserved, including global flags and the `--`\n * passthrough). Global flags are all booleans, so any bare token is the\n * command — no value-consumption ambiguity.\n */\nfunction splitCommand(argv: readonly string[]): {\n command: string | null;\n rest: string[];\n} {\n for (let i = 0; i < argv.length; i++) {\n const token = argv[i]!;\n if (token === '--') break;\n if (!token.startsWith('-')) {\n return {\n command: token,\n rest: [...argv.slice(0, i), ...argv.slice(i + 1)],\n };\n }\n }\n return { command: null, rest: [...argv] };\n}\n\n/**\n * The CLI's own version, read from the package manifest at runtime rather than\n * baked in by the build — one source of truth, so a release bump cannot leave\n * `--version` reporting a stale number. The path resolves identically from\n * `src/index.ts` and from the emitted `dist/index.js`, both of which sit one\n * directory below the package root.\n */\nfunction readVersion(): string {\n const manifest = new URL('../package.json', import.meta.url);\n const parsed: unknown = JSON.parse(fs.readFileSync(manifest, 'utf8'));\n\n return typeof parsed === 'object' &&\n parsed !== null &&\n 'version' in parsed &&\n typeof parsed.version === 'string'\n ? parsed.version\n : '0.0.0';\n}\n\nfunction emitVersion(ctx: CliContext): number {\n const version = readVersion();\n\n return ctx.succeed({ name: 'ekanos', version }, version);\n}\n\nfunction emitHelp(ctx: CliContext): number {\n ctx.emitClaudeCodeHint({\n tool: 'ekanos',\n commands: COMMANDS,\n usage: USAGE,\n exitCodes: EXIT_CODES,\n });\n return ctx.succeed({ usage: USAGE, commands: COMMANDS }, USAGE);\n}\n\nfunction emitCommandHelp(ctx: CliContext, command: string): number {\n const specs = COMMAND_SPECS[command] ?? {};\n const flags = Object.keys(specs).map((name) => `--${name}`);\n const help = `Usage: ekanos ${command} [${flags.join('] [')}]`;\n ctx.emitClaudeCodeHint({ tool: 'ekanos', command, flags });\n return ctx.succeed({ command, flags }, help);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EA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AAC;AAED,SAAS,eAAe,CAAC,GAAe,EAAE,OAAe;;IACvD,MAAM,KAAK,GAAG,MAAA,aAAa,CAAC,OAAO,CAAC,mCAAI,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,iBAAiB,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;IAC/D,GAAG,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import * as fs from 'node:fs';\n\nimport { runDev } from './commands/dev';\nimport { runInit } from './commands/init';\nimport { runLogin } from './commands/login';\nimport { runLogout } from './commands/logout';\nimport { runPublish } from './commands/publish';\nimport { runStatus } from './commands/status';\nimport { runTest } from './commands/test';\nimport { runValidate } from './commands/validate';\nimport { runWhoami } from './commands/whoami';\nimport { CliContext, type WriteStream } from './context';\nimport { toCliError, usageError } from './errors';\nimport { EXIT_CODES } from './exit-codes';\nimport { type FlagSpecs, parseArgv } from './parse-argv';\n\nexport { CliContext } from './context';\nexport { EXIT_CODES, ERROR_CODES } from './exit-codes';\nexport type { ExitCode, ErrorCode } from './exit-codes';\n\nconst GLOBAL_SPECS: FlagSpecs = {\n json: { type: 'boolean' },\n help: { type: 'boolean' },\n version: { type: 'boolean' },\n};\n\nconst COMMAND_SPECS: Record<string, FlagSpecs> = {\n init: {\n slug: { type: 'string' },\n dir: { type: 'string' },\n force: { type: 'boolean' },\n yes: { type: 'boolean' },\n },\n validate: {\n dir: { type: 'string' },\n },\n dev: {\n dir: { type: 'string' },\n port: { type: 'string' },\n host: { type: 'string' },\n force: { type: 'boolean' },\n start: { type: 'boolean' },\n },\n test: {\n dir: { type: 'string' },\n },\n login: {\n host: { type: 'string' },\n force: { type: 'boolean' },\n },\n logout: {\n host: { type: 'string' },\n all: { type: 'boolean' },\n },\n whoami: {\n host: { type: 'string' },\n },\n status: {\n host: { type: 'string' },\n dir: { type: 'string' },\n },\n publish: {\n host: { type: 'string' },\n source: { type: 'string' },\n dir: { type: 'string' },\n yes: { type: 'boolean' },\n },\n};\n\nconst COMMANDS = Object.keys(COMMAND_SPECS);\n\nconst USAGE = [\n 'Usage: ekanos <command> [options]',\n '',\n 'Commands:',\n ' init Scaffold a new integration project into ./<slug> (--slug <slug> --yes)',\n ' validate Validate ekanos.json + the integration definition (--json)',\n ' dev Scaffold .ekanos/harness and run it with your own Next',\n ' test Run the project test script via its package manager (--json)',\n ' login Authenticate against a Fusion host in a browser (--host <url>)',\n ' logout Revoke and delete the stored session (--host <url> | --all)',\n ' whoami Print the identity the stored session authenticates as',\n \" status Show login state and this project's submissions on the host\",\n ' publish Validate, pack and submit the integration to a Fusion host',\n '',\n 'Host resolution (logout, whoami, status, publish):',\n ' --host, else EKANOS_HOST, else the \"host\" field in ekanos.json, else the',\n ' sole stored login. \"ekanos publish\" saves host and source to ekanos.json.',\n ' \"ekanos login\" never reads ekanos.json for a host (--host, else',\n ' EKANOS_HOST, else the sole stored login) — it is the verb that creates',\n ' credentials, so a committed file must never choose where they go.',\n '',\n 'Global options:',\n ' --json Emit a single JSON envelope on stdout (auto-on when piped);',\n ' --no-json forces the human-readable form',\n ' --version Print the CLI version',\n ' --help Show this help',\n].join('\\n');\n\nexport interface RunOptions {\n stdout?: WriteStream;\n stderr?: WriteStream;\n env?: Record<string, string | undefined>;\n cwd?: string;\n}\n\n/**\n * The single entry point. Resolves the agent-native envelope once, dispatches\n * to a verb, and guarantees exactly one terminal emission (success or error).\n * Returns the process exit code — `bin.ts` is the only place that calls\n * `process.exit`, so this stays fully testable.\n */\nexport async function run(\n argv: readonly string[],\n options: RunOptions = {},\n): Promise<number> {\n const jsonFlag = scanJsonFlag(argv);\n const ctx = new CliContext({\n jsonFlag,\n stdout: options.stdout,\n stderr: options.stderr,\n env: options.env,\n });\n const cwd = options.cwd ?? process.cwd();\n const env = options.env ?? process.env;\n\n try {\n // `--version` is global and verb-independent, so it is answered before the\n // command is even resolved: `ekanos --version` and `ekanos validate\n // --version` both report the tool's version and exit 0.\n if (scanFlagPresence(argv, 'version')) {\n return emitVersion(ctx);\n }\n\n const { command, rest } = splitCommand(argv);\n\n // Top-level help / no command.\n if (!command) {\n if (scanFlagPresence(rest, 'help') || argv.length === 0) {\n return emitHelp(ctx);\n }\n // A leading token that is not a command (e.g. `--nonsense`).\n ctx.emitClaudeCodeHint({\n tool: 'ekanos',\n error: 'unknown-command',\n commands: COMMANDS,\n usage: USAGE,\n });\n throw usageError(\n `Unknown command or flag \"${argv[0]}\".`,\n `Run one of: ${COMMANDS.join(', ')}. See \"ekanos --help\".`,\n );\n }\n\n if (!COMMANDS.includes(command)) {\n ctx.emitClaudeCodeHint({\n tool: 'ekanos',\n error: 'unknown-command',\n given: command,\n commands: COMMANDS,\n usage: USAGE,\n });\n throw usageError(\n `Unknown command \"${command}\".`,\n `Run one of: ${COMMANDS.join(', ')}. See \"ekanos --help\".`,\n );\n }\n\n const specs: FlagSpecs = { ...GLOBAL_SPECS, ...COMMAND_SPECS[command] };\n const parsed = parseArgv(rest, specs);\n\n if (parsed.flags.help === true) {\n return emitCommandHelp(ctx, command);\n }\n\n if (parsed.positionals.length > 0) {\n throw usageError(\n `\"${command}\" takes no positional arguments (got \"${parsed.positionals[0]}\").`,\n `Pass options as flags, e.g. \"--dir <path>\". See \"ekanos ${command} --help\".`,\n );\n }\n\n const dir = (parsed.flags.dir as string | undefined) ?? cwd;\n\n switch (command) {\n case 'init':\n return runInit(ctx, {\n slug: parsed.flags.slug as string | undefined,\n dir: parsed.flags.dir as string | undefined,\n cwd,\n force: parsed.flags.force === true,\n yes: parsed.flags.yes === true,\n });\n case 'validate':\n return await runValidate(ctx, { dir });\n case 'dev':\n return await runDev(ctx, {\n dir,\n port: parsed.flags.port as string | undefined,\n host: parsed.flags.host as string | undefined,\n force: parsed.flags.force === true,\n start: parsed.flags.start as boolean | undefined,\n });\n case 'test':\n return await runTest(ctx, { dir, passthrough: parsed.passthrough });\n case 'login':\n return await runLogin(ctx, {\n host: parsed.flags.host as string | undefined,\n force: parsed.flags.force === true,\n cwd,\n env,\n });\n case 'logout':\n return await runLogout(ctx, {\n host: parsed.flags.host as string | undefined,\n all: parsed.flags.all === true,\n cwd,\n env,\n });\n case 'whoami':\n return await runWhoami(ctx, {\n host: parsed.flags.host as string | undefined,\n cwd,\n env,\n });\n case 'status':\n return await runStatus(ctx, {\n host: parsed.flags.host as string | undefined,\n dir,\n env,\n });\n case 'publish':\n return await runPublish(ctx, {\n host: parsed.flags.host as string | undefined,\n source: parsed.flags.source as string | undefined,\n dir,\n yes: parsed.flags.yes === true,\n env,\n });\n default:\n // Unreachable — COMMANDS gate above — but keeps the switch total.\n throw usageError(\n `Unknown command \"${command}\".`,\n `Run one of: ${COMMANDS.join(', ')}.`,\n );\n }\n } catch (error) {\n return ctx.fail(toCliError(error));\n }\n}\n\n/**\n * Presence of `--json` (or `--no-json`) BEFORE the first `--` passthrough.\n *\n * Tri-state on purpose. `undefined` means \"the user expressed no preference\",\n * which is what lets the context fall back to inferring the mode from a\n * non-TTY stdout or CLAUDECODE. Collapsing `--no-json` to `false` here would\n * make it indistinguishable from absence, and the flag could then never turn\n * JSON mode OFF in exactly the cases it exists for.\n */\nfunction scanJsonFlag(argv: readonly string[]): boolean | undefined {\n for (const token of argv) {\n if (token === '--') break;\n if (token === '--json') return true;\n if (token === '--no-json') return false;\n }\n return undefined;\n}\n\nfunction scanFlagPresence(argv: readonly string[], name: string): boolean {\n for (const token of argv) {\n if (token === '--') break;\n if (token === `--${name}`) return true;\n }\n return false;\n}\n\n/**\n * Split argv into the command (first bare token before `--`) and the rest\n * (everything else, order preserved, including global flags and the `--`\n * passthrough). Global flags are all booleans, so any bare token is the\n * command — no value-consumption ambiguity.\n */\nfunction splitCommand(argv: readonly string[]): {\n command: string | null;\n rest: string[];\n} {\n for (let i = 0; i < argv.length; i++) {\n const token = argv[i]!;\n if (token === '--') break;\n if (!token.startsWith('-')) {\n return {\n command: token,\n rest: [...argv.slice(0, i), ...argv.slice(i + 1)],\n };\n }\n }\n return { command: null, rest: [...argv] };\n}\n\n/**\n * The CLI's own version, read from the package manifest at runtime rather than\n * baked in by the build — one source of truth, so a release bump cannot leave\n * `--version` reporting a stale number. The path resolves identically from\n * `src/index.ts` and from the emitted `dist/index.js`, both of which sit one\n * directory below the package root.\n */\nfunction readVersion(): string {\n const manifest = new URL('../package.json', import.meta.url);\n const parsed: unknown = JSON.parse(fs.readFileSync(manifest, 'utf8'));\n\n return typeof parsed === 'object' &&\n parsed !== null &&\n 'version' in parsed &&\n typeof parsed.version === 'string'\n ? parsed.version\n : '0.0.0';\n}\n\nfunction emitVersion(ctx: CliContext): number {\n const version = readVersion();\n\n return ctx.succeed({ name: 'ekanos', version }, version);\n}\n\nfunction emitHelp(ctx: CliContext): number {\n ctx.emitClaudeCodeHint({\n tool: 'ekanos',\n commands: COMMANDS,\n usage: USAGE,\n exitCodes: EXIT_CODES,\n });\n return ctx.succeed({ usage: USAGE, commands: COMMANDS }, USAGE);\n}\n\nfunction emitCommandHelp(ctx: CliContext, command: string): number {\n const specs = COMMAND_SPECS[command] ?? {};\n const flags = Object.keys(specs).map((name) => `--${name}`);\n const help = `Usage: ekanos ${command} [${flags.join('] [')}]`;\n ctx.emitClaudeCodeHint({ tool: 'ekanos', command, flags });\n return ctx.succeed({ command, flags }, help);\n}\n"]}
package/dist/pack.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /** The server refuses archives over 5 MiB; fail fast on the client too. */
2
+ export declare const MAX_ARCHIVE_BYTES: number;
3
+ export interface PackedProject {
4
+ /** The gzipped tarball. */
5
+ archive: Buffer;
6
+ /** Project-relative POSIX paths, in the order they were packed. */
7
+ files: string[];
8
+ }
9
+ export declare function packProject(projectDir: string): PackedProject;
10
+ /**
11
+ * The whitelist walk. Exported for tests: the selection rules are the part
12
+ * with security consequences, so they are asserted directly.
13
+ */
14
+ export declare function selectProjectFiles(projectDir: string): string[];
package/dist/pack.js ADDED
@@ -0,0 +1,157 @@
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+ import * as zlib from 'node:zlib';
4
+ import { preconditionError, validationError } from './errors.js';
5
+ /**
6
+ * Deterministic project packing for `ekanos publish`.
7
+ *
8
+ * A minimal ustar writer over Node's built-ins — no `tar` dependency. The
9
+ * selection is deliberately a WHITELIST, not "everything minus a blocklist":
10
+ * the submission is reviewed by an operator and installed into Fusion, so the
11
+ * archive must contain exactly the files the toolchain knows about and
12
+ * nothing a working directory happens to hold.
13
+ *
14
+ * - `ekanos.json`, `package.json` (required)
15
+ * - `README.md` (when present)
16
+ * - everything under `src/`, recursively
17
+ *
18
+ * Excluded everywhere: dotfiles and dot-directories (which covers `.ekanos`,
19
+ * `.git`, `.env`), `node_modules`, and anything that is not a regular file
20
+ * (symlinks are skipped, not followed — a link pointing outside the project
21
+ * must never pull foreign bytes into a submission).
22
+ *
23
+ * Determinism: entries are sorted by path and every header carries a fixed
24
+ * mtime, so packing the same tree twice yields byte-identical archives and a
25
+ * stable sha256.
26
+ */
27
+ const BLOCK_SIZE = 512;
28
+ /** Fixed header mtime — determinism over provenance (the VCS owns history). */
29
+ const FIXED_MTIME_SECONDS = 0;
30
+ /** The server refuses archives over 5 MiB; fail fast on the client too. */
31
+ // 4 MiB — mirrors the server route's cap, which itself sits under Vercel's
32
+ // ~4.5 MB request-body ceiling so oversize is caught here with a clear error
33
+ // instead of by an opaque platform 413.
34
+ export const MAX_ARCHIVE_BYTES = 4 * 1024 * 1024;
35
+ export function packProject(projectDir) {
36
+ const files = selectProjectFiles(projectDir);
37
+ const blocks = [];
38
+ for (const relative of files) {
39
+ const absolute = path.join(projectDir, relative);
40
+ const content = fs.readFileSync(absolute);
41
+ blocks.push(tarHeader(relative, content.length));
42
+ blocks.push(content);
43
+ const remainder = content.length % BLOCK_SIZE;
44
+ if (remainder !== 0) {
45
+ blocks.push(Buffer.alloc(BLOCK_SIZE - remainder));
46
+ }
47
+ }
48
+ // End-of-archive: two zero blocks.
49
+ blocks.push(Buffer.alloc(BLOCK_SIZE * 2));
50
+ const archive = zlib.gzipSync(Buffer.concat(blocks), { level: 9 });
51
+ if (archive.length > MAX_ARCHIVE_BYTES) {
52
+ throw validationError(`The packed archive is ${archive.length} bytes, over the ` +
53
+ `${MAX_ARCHIVE_BYTES}-byte submission limit.`, 'Reduce the project to source only — large binary assets do not ' +
54
+ 'belong in an integration submission.');
55
+ }
56
+ return { archive, files };
57
+ }
58
+ /**
59
+ * The whitelist walk. Exported for tests: the selection rules are the part
60
+ * with security consequences, so they are asserted directly.
61
+ */
62
+ export function selectProjectFiles(projectDir) {
63
+ for (const required of ['ekanos.json', 'package.json']) {
64
+ if (!isRegularFile(path.join(projectDir, required))) {
65
+ throw preconditionError(`Cannot pack ${projectDir}: ${required} is missing.`, `Run "ekanos publish" from an integration project (or pass --dir), ` +
66
+ `and run "ekanos init" first if this is a new project.`);
67
+ }
68
+ }
69
+ const selected = ['ekanos.json', 'package.json'];
70
+ if (isRegularFile(path.join(projectDir, 'README.md'))) {
71
+ selected.push('README.md');
72
+ }
73
+ const srcDir = path.join(projectDir, 'src');
74
+ // lstat, not stat: `src` itself as a symlink must not pull a foreign tree
75
+ // into the archive — the same rule walk() applies to every entry inside.
76
+ if (fs.existsSync(srcDir) && fs.lstatSync(srcDir).isDirectory()) {
77
+ selected.push(...walk(projectDir, 'src'));
78
+ }
79
+ return selected.sort();
80
+ }
81
+ function walk(projectDir, relativeDir) {
82
+ const absoluteDir = path.join(projectDir, relativeDir);
83
+ const collected = [];
84
+ for (const entry of fs.readdirSync(absoluteDir, { withFileTypes: true })) {
85
+ if (entry.name.startsWith('.'))
86
+ continue;
87
+ if (entry.name === 'node_modules')
88
+ continue;
89
+ const relative = `${relativeDir}/${entry.name}`;
90
+ if (entry.isDirectory()) {
91
+ collected.push(...walk(projectDir, relative));
92
+ continue;
93
+ }
94
+ // Regular files only. `isFile()` is false for symlinks under
95
+ // `withFileTypes`, so a link — wherever it points — is skipped here.
96
+ if (entry.isFile()) {
97
+ collected.push(relative);
98
+ }
99
+ }
100
+ return collected;
101
+ }
102
+ function isRegularFile(absolute) {
103
+ try {
104
+ return fs.lstatSync(absolute).isFile();
105
+ }
106
+ catch (_a) {
107
+ return false;
108
+ }
109
+ }
110
+ /**
111
+ * One 512-byte ustar header. Long paths use the ustar `prefix` field
112
+ * (155 + '/' + 100); a path that fits neither is refused with a clear error
113
+ * rather than silently truncated.
114
+ */
115
+ function tarHeader(relativePath, size) {
116
+ const { name, prefix } = splitUstarPath(relativePath);
117
+ const header = Buffer.alloc(BLOCK_SIZE);
118
+ header.write(name, 0, 100, 'utf8');
119
+ writeOctal(header, 100, 8, 0o644); // mode
120
+ writeOctal(header, 108, 8, 0); // uid
121
+ writeOctal(header, 116, 8, 0); // gid
122
+ writeOctal(header, 124, 12, size);
123
+ writeOctal(header, 136, 12, FIXED_MTIME_SECONDS);
124
+ header.fill(' ', 148, 156); // checksum placeholder: eight spaces
125
+ header.write('0', 156, 1, 'utf8'); // typeflag: regular file
126
+ header.write('ustar', 257, 5, 'utf8');
127
+ header.write('00', 263, 2, 'utf8'); // version
128
+ header.write(prefix, 345, 155, 'utf8');
129
+ let checksum = 0;
130
+ for (const byte of header)
131
+ checksum += byte;
132
+ // Six octal digits, NUL, space — the historical checksum encoding.
133
+ header.write(`${checksum.toString(8).padStart(6, '0')}\0 `, 148, 8, 'latin1');
134
+ return header;
135
+ }
136
+ function splitUstarPath(relativePath) {
137
+ if (Buffer.byteLength(relativePath, 'utf8') <= 100) {
138
+ return { name: relativePath, prefix: '' };
139
+ }
140
+ // Split at a '/' so that name ≤ 100 bytes and prefix ≤ 155 bytes.
141
+ for (let i = relativePath.length - 1; i > 0; i--) {
142
+ if (relativePath[i] !== '/')
143
+ continue;
144
+ const prefix = relativePath.slice(0, i);
145
+ const name = relativePath.slice(i + 1);
146
+ if (Buffer.byteLength(name, 'utf8') <= 100 &&
147
+ Buffer.byteLength(prefix, 'utf8') <= 155) {
148
+ return { name, prefix };
149
+ }
150
+ }
151
+ throw validationError(`Cannot pack "${relativePath}": the path is too long for a tar entry.`, 'Shorten the file path (tar limits one segment to 100 bytes and the ' +
152
+ 'directory prefix to 155).');
153
+ }
154
+ function writeOctal(header, offset, length, value) {
155
+ header.write(`${value.toString(8).padStart(length - 1, '0')}\0`, offset, length, 'latin1');
156
+ }
157
+ //# sourceMappingURL=pack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack.js","sourceRoot":"","sources":["../src/pack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AASjD,MAAM,UAAU,WAAW,CAAC,UAAkB;IAC5C,MAAM,KAAK,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAE7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,I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AG,CAAC,CAAC,CAAC;QAEvC,IACE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG;YACtC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,GAAG,EACxC,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,eAAe,CACnB,gBAAgB,YAAY,0CAA0C,EACtE,qEAAqE;QACnE,2BAA2B,CAC9B,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAAc,EACd,MAAc,EACd,MAAc,EACd,KAAa;IAEb,MAAM,CAAC,KAAK,CACV,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,EAClD,MAAM,EACN,MAAM,EACN,QAAQ,CACT,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as zlib from 'node:zlib';\n\nimport { preconditionError, validationError } from './errors';\n\n/**\n * Deterministic project packing for `ekanos publish`.\n *\n * A minimal ustar writer over Node's built-ins — no `tar` dependency. The\n * selection is deliberately a WHITELIST, not \"everything minus a blocklist\":\n * the submission is reviewed by an operator and installed into Fusion, so the\n * archive must contain exactly the files the toolchain knows about and\n * nothing a working directory happens to hold.\n *\n * - `ekanos.json`, `package.json` (required)\n * - `README.md` (when present)\n * - everything under `src/`, recursively\n *\n * Excluded everywhere: dotfiles and dot-directories (which covers `.ekanos`,\n * `.git`, `.env`), `node_modules`, and anything that is not a regular file\n * (symlinks are skipped, not followed — a link pointing outside the project\n * must never pull foreign bytes into a submission).\n *\n * Determinism: entries are sorted by path and every header carries a fixed\n * mtime, so packing the same tree twice yields byte-identical archives and a\n * stable sha256.\n */\n\nconst BLOCK_SIZE = 512;\n\n/** Fixed header mtime — determinism over provenance (the VCS owns history). */\nconst FIXED_MTIME_SECONDS = 0;\n\n/** The server refuses archives over 5 MiB; fail fast on the client too. */\n// 4 MiB — mirrors the server route's cap, which itself sits under Vercel's\n// ~4.5 MB request-body ceiling so oversize is caught here with a clear error\n// instead of by an opaque platform 413.\nexport const MAX_ARCHIVE_BYTES = 4 * 1024 * 1024;\n\nexport interface PackedProject {\n /** The gzipped tarball. */\n archive: Buffer;\n /** Project-relative POSIX paths, in the order they were packed. */\n files: string[];\n}\n\nexport function packProject(projectDir: string): PackedProject {\n const files = selectProjectFiles(projectDir);\n\n const blocks: Buffer[] = [];\n\n for (const relative of files) {\n const absolute = path.join(projectDir, relative);\n const content = fs.readFileSync(absolute);\n\n blocks.push(tarHeader(relative, content.length));\n blocks.push(content);\n\n const remainder = content.length % BLOCK_SIZE;\n if (remainder !== 0) {\n blocks.push(Buffer.alloc(BLOCK_SIZE - remainder));\n }\n }\n\n // End-of-archive: two zero blocks.\n blocks.push(Buffer.alloc(BLOCK_SIZE * 2));\n\n const archive = zlib.gzipSync(Buffer.concat(blocks), { level: 9 });\n\n if (archive.length > MAX_ARCHIVE_BYTES) {\n throw validationError(\n `The packed archive is ${archive.length} bytes, over the ` +\n `${MAX_ARCHIVE_BYTES}-byte submission limit.`,\n 'Reduce the project to source only — large binary assets do not ' +\n 'belong in an integration submission.',\n );\n }\n\n return { archive, files };\n}\n\n/**\n * The whitelist walk. Exported for tests: the selection rules are the part\n * with security consequences, so they are asserted directly.\n */\nexport function selectProjectFiles(projectDir: string): string[] {\n for (const required of ['ekanos.json', 'package.json']) {\n if (!isRegularFile(path.join(projectDir, required))) {\n throw preconditionError(\n `Cannot pack ${projectDir}: ${required} is missing.`,\n `Run \"ekanos publish\" from an integration project (or pass --dir), ` +\n `and run \"ekanos init\" first if this is a new project.`,\n );\n }\n }\n\n const selected = ['ekanos.json', 'package.json'];\n\n if (isRegularFile(path.join(projectDir, 'README.md'))) {\n selected.push('README.md');\n }\n\n const srcDir = path.join(projectDir, 'src');\n // lstat, not stat: `src` itself as a symlink must not pull a foreign tree\n // into the archive — the same rule walk() applies to every entry inside.\n if (fs.existsSync(srcDir) && fs.lstatSync(srcDir).isDirectory()) {\n selected.push(...walk(projectDir, 'src'));\n }\n\n return selected.sort();\n}\n\nfunction walk(projectDir: string, relativeDir: string): string[] {\n const absoluteDir = path.join(projectDir, relativeDir);\n const collected: string[] = [];\n\n for (const entry of fs.readdirSync(absoluteDir, { withFileTypes: true })) {\n if (entry.name.startsWith('.')) continue;\n if (entry.name === 'node_modules') continue;\n\n const relative = `${relativeDir}/${entry.name}`;\n\n if (entry.isDirectory()) {\n collected.push(...walk(projectDir, relative));\n continue;\n }\n\n // Regular files only. `isFile()` is false for symlinks under\n // `withFileTypes`, so a link — wherever it points — is skipped here.\n if (entry.isFile()) {\n collected.push(relative);\n }\n }\n\n return collected;\n}\n\nfunction isRegularFile(absolute: string): boolean {\n try {\n return fs.lstatSync(absolute).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * One 512-byte ustar header. Long paths use the ustar `prefix` field\n * (155 + '/' + 100); a path that fits neither is refused with a clear error\n * rather than silently truncated.\n */\nfunction tarHeader(relativePath: string, size: number): Buffer {\n const { name, prefix } = splitUstarPath(relativePath);\n const header = Buffer.alloc(BLOCK_SIZE);\n\n header.write(name, 0, 100, 'utf8');\n writeOctal(header, 100, 8, 0o644); // mode\n writeOctal(header, 108, 8, 0); // uid\n writeOctal(header, 116, 8, 0); // gid\n writeOctal(header, 124, 12, size);\n writeOctal(header, 136, 12, FIXED_MTIME_SECONDS);\n header.fill(' ', 148, 156); // checksum placeholder: eight spaces\n header.write('0', 156, 1, 'utf8'); // typeflag: regular file\n header.write('ustar', 257, 5, 'utf8');\n header.write('00', 263, 2, 'utf8'); // version\n header.write(prefix, 345, 155, 'utf8');\n\n let checksum = 0;\n for (const byte of header) checksum += byte;\n\n // Six octal digits, NUL, space — the historical checksum encoding.\n header.write(`${checksum.toString(8).padStart(6, '0')}\\0 `, 148, 8, 'latin1');\n\n return header;\n}\n\nfunction splitUstarPath(relativePath: string): {\n name: string;\n prefix: string;\n} {\n if (Buffer.byteLength(relativePath, 'utf8') <= 100) {\n return { name: relativePath, prefix: '' };\n }\n\n // Split at a '/' so that name ≤ 100 bytes and prefix ≤ 155 bytes.\n for (let i = relativePath.length - 1; i > 0; i--) {\n if (relativePath[i] !== '/') continue;\n\n const prefix = relativePath.slice(0, i);\n const name = relativePath.slice(i + 1);\n\n if (\n Buffer.byteLength(name, 'utf8') <= 100 &&\n Buffer.byteLength(prefix, 'utf8') <= 155\n ) {\n return { name, prefix };\n }\n }\n\n throw validationError(\n `Cannot pack \"${relativePath}\": the path is too long for a tar entry.`,\n 'Shorten the file path (tar limits one segment to 100 bytes and the ' +\n 'directory prefix to 155).',\n );\n}\n\nfunction writeOctal(\n header: Buffer,\n offset: number,\n length: number,\n value: number,\n): void {\n header.write(\n `${value.toString(8).padStart(length - 1, '0')}\\0`,\n offset,\n length,\n 'latin1',\n );\n}\n"]}
package/dist/project.d.ts CHANGED
@@ -11,28 +11,6 @@ declare const IntegrationEntrySchema: z.ZodObject<{
11
11
  entry: string;
12
12
  }>;
13
13
  export type IntegrationEntry = z.infer<typeof IntegrationEntrySchema>;
14
- /**
15
- * `ekanos.json` — the project contract. Written by `init`, read by `validate`,
16
- * `dev` and `test`.
17
- *
18
- * Two shapes, because a project can hold more than one integration and the
19
- * single-integration form is what `init` writes and what most projects keep:
20
- *
21
- * ```json
22
- * { "slug": "acme-crm", "entry": "src/integration.ts" }
23
- *
24
- * { "integrations": [
25
- * { "slug": "acme-crm", "entry": "src/crm.ts" },
26
- * { "slug": "acme-billing", "entry": "src/billing.ts" }
27
- * ] }
28
- * ```
29
- *
30
- * A second integration used to be invisible to the CLI entirely — the harness
31
- * registry is an array and `collectCollisionFindings` exists precisely to
32
- * cross-check several definitions against each other, but `validate` could
33
- * only ever see one. Both forms normalise to the same list, so nothing
34
- * downstream has to know which was written.
35
- */
36
14
  export declare const EkanosProjectSchema: z.ZodEffects<z.ZodObject<{
37
15
  $schema: z.ZodOptional<z.ZodString>;
38
16
  slug: z.ZodOptional<z.ZodString>;
@@ -47,6 +25,18 @@ export declare const EkanosProjectSchema: z.ZodEffects<z.ZodObject<{
47
25
  slug: string;
48
26
  entry: string;
49
27
  }>, "many">>;
28
+ /**
29
+ * Written by the first successful `ekanos publish --source <slug>` so
30
+ * later publishes need no flag. Read only by `publish`.
31
+ */
32
+ source: z.ZodOptional<z.ZodString>;
33
+ /**
34
+ * The Fusion host this project publishes to — an http(s) origin, e.g.
35
+ * "https://app.example.com". Written by the first successful `ekanos
36
+ * publish` (alongside `source`), read by every host-taking verb as the
37
+ * fallback after `--host` and `EKANOS_HOST`.
38
+ */
39
+ host: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
50
40
  sourceGlobs: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, "many">>;
51
41
  }, "strict", z.ZodTypeAny, {
52
42
  slug?: string | undefined;
@@ -56,6 +46,8 @@ export declare const EkanosProjectSchema: z.ZodEffects<z.ZodObject<{
56
46
  slug: string;
57
47
  entry: string;
58
48
  }[] | undefined;
49
+ source?: string | undefined;
50
+ host?: string | undefined;
59
51
  sourceGlobs?: string[] | undefined;
60
52
  }, {
61
53
  slug?: string | undefined;
@@ -65,6 +57,8 @@ export declare const EkanosProjectSchema: z.ZodEffects<z.ZodObject<{
65
57
  slug: string;
66
58
  entry: string;
67
59
  }[] | undefined;
60
+ source?: string | undefined;
61
+ host?: string | undefined;
68
62
  sourceGlobs?: string[] | undefined;
69
63
  }>, {
70
64
  slug?: string | undefined;
@@ -74,6 +68,8 @@ export declare const EkanosProjectSchema: z.ZodEffects<z.ZodObject<{
74
68
  slug: string;
75
69
  entry: string;
76
70
  }[] | undefined;
71
+ source?: string | undefined;
72
+ host?: string | undefined;
77
73
  sourceGlobs?: string[] | undefined;
78
74
  }, {
79
75
  slug?: string | undefined;
@@ -83,6 +79,8 @@ export declare const EkanosProjectSchema: z.ZodEffects<z.ZodObject<{
83
79
  slug: string;
84
80
  entry: string;
85
81
  }[] | undefined;
82
+ source?: string | undefined;
83
+ host?: string | undefined;
86
84
  sourceGlobs?: string[] | undefined;
87
85
  }>;
88
86
  export type EkanosProject = z.infer<typeof EkanosProjectSchema>;
package/dist/project.js CHANGED
@@ -60,12 +60,54 @@ const IntegrationEntrySchema = z
60
60
  * only ever see one. Both forms normalise to the same list, so nothing
61
61
  * downstream has to know which was written.
62
62
  */
63
+ /**
64
+ * The Fusion source this project publishes to, by slug. Fusion source slugs
65
+ * are opaque server-side identifiers, so the only local claims are "one
66
+ * token, sanely sized" — the server resolves and authorizes it.
67
+ */
68
+ const SourceSlugSchema = z
69
+ .string()
70
+ .min(1, { message: 'source must not be empty.' })
71
+ .max(255, { message: 'source must be at most 255 characters.' })
72
+ .regex(/^\S+$/, { message: 'source must not contain whitespace.' });
73
+ /**
74
+ * The Fusion host this project publishes to. Origin-shaped: the same
75
+ * normalization the credential store applies (`normalizeHost`) accepts it, so
76
+ * "valid here" and "usable as a session key" cannot drift apart.
77
+ */
78
+ const HostSchema = z
79
+ .string()
80
+ .min(1, { message: 'host must not be empty.' })
81
+ .max(255, { message: 'host must be at most 255 characters.' })
82
+ .refine((value) => {
83
+ try {
84
+ const url = new URL(value);
85
+ return url.protocol === 'https:' || url.protocol === 'http:';
86
+ }
87
+ catch (_a) {
88
+ return false;
89
+ }
90
+ }, {
91
+ message: 'host must be a full http(s) origin, e.g. "https://app.example.com".',
92
+ });
63
93
  export const EkanosProjectSchema = z
64
94
  .object({
65
95
  $schema: z.string().optional(),
66
96
  slug: SlugSchema.optional(),
67
97
  entry: EntrySchema.optional(),
68
98
  integrations: z.array(IntegrationEntrySchema).optional(),
99
+ /**
100
+ * Written by the first successful `ekanos publish --source <slug>` so
101
+ * later publishes need no flag. Read only by `publish`.
102
+ */
103
+ source: SourceSlugSchema.optional(),
104
+ /**
105
+ * The Fusion host this project publishes to — an http(s) origin, e.g.
106
+ * "https://app.example.com". Written by the first successful `ekanos
107
+ * publish` (alongside `source`), read by every host-taking verb as the
108
+ * fallback after `--host` and `EKANOS_HOST`.
109
+ */
110
+ host: HostSchema.optional(),
69
111
  // There is deliberately no `harness` field. One existed, accepted by the
70
112
  // schema and read by nothing — the same accept-and-ignore that made
71
113
  // `sourceGlobs` cost a partner a silently unstyled integration. `.strict()`
@@ -157,7 +199,7 @@ export function loadProject(dir) {
157
199
  const where = first && first.path.length > 0 ? first.path.join('.') : '(root)';
158
200
  throw preconditionError(`${EKANOS_CONFIG_FILENAME} is invalid at "${where}": ${(_a = first === null || first === void 0 ? void 0 : first.message) !== null && _a !== void 0 ? _a : 'schema violation'}`, `Correct ${configPath} so it matches the ekanos.json schema ` +
159
201
  `({ slug, entry } or { integrations: [...] }, plus optional ` +
160
- `harness and sourceGlobs).`);
202
+ `source, host and sourceGlobs).`);
161
203
  }
162
204
  const project = result.data;
163
205
  const integrations = projectIntegrations(project).map((declared) => {