@spec0/cli 0.4.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +3 -2
  2. package/dist/commands/api/changelog.d.ts.map +1 -1
  3. package/dist/commands/api/changelog.js +10 -7
  4. package/dist/commands/api/changelog.js.map +1 -1
  5. package/dist/commands/api/delete.d.ts +10 -0
  6. package/dist/commands/api/delete.d.ts.map +1 -0
  7. package/dist/commands/api/delete.js +72 -0
  8. package/dist/commands/api/delete.js.map +1 -0
  9. package/dist/commands/api/index.d.ts.map +1 -1
  10. package/dist/commands/api/index.js +2 -0
  11. package/dist/commands/api/index.js.map +1 -1
  12. package/dist/commands/api/list.d.ts.map +1 -1
  13. package/dist/commands/api/list.js +10 -7
  14. package/dist/commands/api/list.js.map +1 -1
  15. package/dist/commands/api/show.d.ts +5 -2
  16. package/dist/commands/api/show.d.ts.map +1 -1
  17. package/dist/commands/api/show.js +80 -18
  18. package/dist/commands/api/show.js.map +1 -1
  19. package/dist/commands/auth.d.ts +5 -1
  20. package/dist/commands/auth.d.ts.map +1 -1
  21. package/dist/commands/auth.js +49 -31
  22. package/dist/commands/auth.js.map +1 -1
  23. package/dist/commands/ci/generate.d.ts.map +1 -1
  24. package/dist/commands/ci/generate.js +10 -7
  25. package/dist/commands/ci/generate.js.map +1 -1
  26. package/dist/commands/log.d.ts.map +1 -1
  27. package/dist/commands/log.js +10 -5
  28. package/dist/commands/log.js.map +1 -1
  29. package/dist/commands/mcp.d.ts +7 -1
  30. package/dist/commands/mcp.d.ts.map +1 -1
  31. package/dist/commands/mcp.js +135 -29
  32. package/dist/commands/mcp.js.map +1 -1
  33. package/dist/commands/mock/create.d.ts.map +1 -1
  34. package/dist/commands/mock/create.js +10 -7
  35. package/dist/commands/mock/create.js.map +1 -1
  36. package/dist/commands/mock/delete.d.ts +11 -0
  37. package/dist/commands/mock/delete.d.ts.map +1 -0
  38. package/dist/commands/mock/delete.js +65 -0
  39. package/dist/commands/mock/delete.js.map +1 -0
  40. package/dist/commands/mock/index.d.ts.map +1 -1
  41. package/dist/commands/mock/index.js +2 -0
  42. package/dist/commands/mock/index.js.map +1 -1
  43. package/dist/commands/mock/list.d.ts.map +1 -1
  44. package/dist/commands/mock/list.js +10 -7
  45. package/dist/commands/mock/list.js.map +1 -1
  46. package/dist/commands/mock/show.d.ts.map +1 -1
  47. package/dist/commands/mock/show.js +10 -7
  48. package/dist/commands/mock/show.js.map +1 -1
  49. package/dist/commands/mock/url.d.ts.map +1 -1
  50. package/dist/commands/mock/url.js +12 -5
  51. package/dist/commands/mock/url.js.map +1 -1
  52. package/dist/commands/publish.js +2 -2
  53. package/dist/commands/publish.js.map +1 -1
  54. package/dist/commands/pull.d.ts.map +1 -1
  55. package/dist/commands/pull.js +12 -5
  56. package/dist/commands/pull.js.map +1 -1
  57. package/dist/commands/push.d.ts.map +1 -1
  58. package/dist/commands/push.js +5 -0
  59. package/dist/commands/push.js.map +1 -1
  60. package/dist/commands/search.d.ts.map +1 -1
  61. package/dist/commands/search.js +13 -9
  62. package/dist/commands/search.js.map +1 -1
  63. package/dist/commands/status.d.ts.map +1 -1
  64. package/dist/commands/status.js +10 -5
  65. package/dist/commands/status.js.map +1 -1
  66. package/dist/commands/sync-status.d.ts.map +1 -1
  67. package/dist/commands/sync-status.js +10 -7
  68. package/dist/commands/sync-status.js.map +1 -1
  69. package/dist/commands/team/create.d.ts.map +1 -1
  70. package/dist/commands/team/create.js +11 -10
  71. package/dist/commands/team/create.js.map +1 -1
  72. package/dist/commands/team/delete.d.ts.map +1 -1
  73. package/dist/commands/team/delete.js +11 -8
  74. package/dist/commands/team/delete.js.map +1 -1
  75. package/dist/commands/team/list.d.ts.map +1 -1
  76. package/dist/commands/team/list.js +11 -9
  77. package/dist/commands/team/list.js.map +1 -1
  78. package/dist/index.js +4 -0
  79. package/dist/index.js.map +1 -1
  80. package/dist/lib/api-client.d.ts +12 -2
  81. package/dist/lib/api-client.d.ts.map +1 -1
  82. package/dist/lib/api-client.js +65 -14
  83. package/dist/lib/api-client.js.map +1 -1
  84. package/dist/lib/config.d.ts +11 -0
  85. package/dist/lib/config.d.ts.map +1 -1
  86. package/dist/lib/config.js +14 -0
  87. package/dist/lib/config.js.map +1 -1
  88. package/dist/lib/errors.d.ts +46 -0
  89. package/dist/lib/errors.d.ts.map +1 -0
  90. package/dist/lib/errors.js +99 -0
  91. package/dist/lib/errors.js.map +1 -0
  92. package/dist/lib/http-trace.d.ts +37 -0
  93. package/dist/lib/http-trace.d.ts.map +1 -0
  94. package/dist/lib/http-trace.js +101 -0
  95. package/dist/lib/http-trace.js.map +1 -0
  96. package/dist/lib/output.d.ts +4 -0
  97. package/dist/lib/output.d.ts.map +1 -1
  98. package/dist/lib/output.js +8 -0
  99. package/dist/lib/output.js.map +1 -1
  100. package/dist/lib/platform-defaults.d.ts +29 -4
  101. package/dist/lib/platform-defaults.d.ts.map +1 -1
  102. package/dist/lib/platform-defaults.js +34 -4
  103. package/dist/lib/platform-defaults.js.map +1 -1
  104. package/package.json +6 -6
@@ -0,0 +1,99 @@
1
+ /**
2
+ * One place to turn a failed platform call into a diagnosable error.
3
+ *
4
+ * Before this, command catch-blocks printed a bare `(err as Error).message` —
5
+ * e.g. `api list failed: Not Found` — with no HTTP status, no URL, and no hint
6
+ * about which org/base was targeted. A developer literally could not tell what
7
+ * went wrong. `failApi` classifies the error into a stable exit code and surfaces:
8
+ *
9
+ * - the server's own message (from the response body when present),
10
+ * - the HTTP status (or a network label when the request never completed),
11
+ * - the method + URL that failed,
12
+ * - the active org + API base, and
13
+ * - a code-specific hint.
14
+ *
15
+ * In `--output json|yaml` mode the request/org context rides in `details` so the
16
+ * document stays a single clean object; in text mode it is appended to the
17
+ * message so a human sees it inline.
18
+ */
19
+ import { errorStatusCode, errorRequestInfo, extractErrorMessage } from "./api-client.js";
20
+ import { ExitCode, exitCodeForHttpStatus } from "./exit-codes.js";
21
+ import { fail } from "./output/index.js";
22
+ const HINTS = {
23
+ [ExitCode.AUTH_MISSING]: "Run 'spec0 auth login', or refresh SPEC0_TOKEN.",
24
+ [ExitCode.PERMISSION_DENIED]: "Your account lacks permission for this resource.",
25
+ [ExitCode.NOT_FOUND]: "Check the name/id, or confirm SPEC0_API_URL points at the right backend.",
26
+ [ExitCode.CONFLICT]: "A resource with that name/version already exists.",
27
+ [ExitCode.VALIDATION]: "The request was rejected as invalid — see the message above.",
28
+ [ExitCode.RATE_LIMITED]: "Rate limit hit — wait a moment and retry.",
29
+ [ExitCode.SERVER_ERROR]: "Server error — retry shortly; if it persists, contact support.",
30
+ [ExitCode.NETWORK_ERROR]: "Could not reach the platform. Check connectivity, then SPEC0_API_URL (run 'spec0 doctor').",
31
+ };
32
+ /**
33
+ * Best-effort label for a request that never produced an HTTP response.
34
+ * `got` puts the code on the error itself; the SDK uses `fetch`, which wraps the
35
+ * real cause (so the visible message is an unhelpful "fetch failed" and the code
36
+ * lives on `err.cause`). Check both.
37
+ */
38
+ function networkLabel(err) {
39
+ // A `fetch` timeout/cancellation is a DOMException with no `code` — it
40
+ // identifies itself by `name` ("TimeoutError" / "AbortError") instead.
41
+ const name = err?.name ?? err?.cause?.name;
42
+ if (name === "TimeoutError")
43
+ return "timed out";
44
+ if (name === "AbortError")
45
+ return "request aborted";
46
+ const code = err?.code ?? err?.cause?.code;
47
+ if (!code)
48
+ return undefined;
49
+ if (code === "ECONNREFUSED")
50
+ return "connection refused";
51
+ if (code === "ENOTFOUND" || code === "EAI_AGAIN")
52
+ return "host not found";
53
+ if (code === "ETIMEDOUT" || code === "ETIME")
54
+ return "timed out";
55
+ return code;
56
+ }
57
+ /**
58
+ * Pure classification of a failed platform call into an exit code, message,
59
+ * hint and structured details. Separated from `failApi` so it can be unit
60
+ * tested without `process.exit`.
61
+ */
62
+ export function buildApiError(err, info, format = "text") {
63
+ const status = errorStatusCode(err);
64
+ const code = exitCodeForHttpStatus(status);
65
+ const netLabel = status === undefined ? networkLabel(err) : undefined;
66
+ const serverMsg = extractErrorMessage(err);
67
+ const base = serverMsg ?? netLabel ?? err?.message ?? String(err);
68
+ const { method, url } = errorRequestInfo(err);
69
+ const statusPart = status !== undefined ? `HTTP ${status}` : undefined;
70
+ let message = `${info.action} failed: ${base}` + (statusPart ? ` (${statusPart})` : "");
71
+ const requestLine = url ? `${method ?? "GET"} ${url}` : undefined;
72
+ if (format === "text") {
73
+ const extra = [
74
+ requestLine ? ` ${requestLine}` : undefined,
75
+ info.org ? ` org: ${info.org}` : undefined,
76
+ ].filter(Boolean);
77
+ if (extra.length)
78
+ message += "\n" + extra.join("\n");
79
+ }
80
+ return {
81
+ code,
82
+ message,
83
+ hint: HINTS[code],
84
+ details: {
85
+ ...(status !== undefined ? { status } : {}),
86
+ ...(requestLine ? { request: requestLine } : {}),
87
+ ...(info.org ? { org: info.org } : {}),
88
+ ...(info.apiUrl ? { apiUrl: info.apiUrl } : {}),
89
+ },
90
+ };
91
+ }
92
+ /**
93
+ * Report a failed platform call and exit. Never returns.
94
+ */
95
+ export function failApi(ctx, err, info) {
96
+ const report = buildApiError(err, info, ctx.format);
97
+ fail(ctx, report.code, report.message, { hint: report.hint, details: report.details });
98
+ }
99
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAsB,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAsB,MAAM,mBAAmB,CAAC;AAW7D,MAAM,KAAK,GAA2C;IACpD,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,iDAAiD;IAC1E,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,kDAAkD;IAChF,CAAC,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M,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3C,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAkB,EAAE,GAAY,EAAE,IAAqB;IAC7E,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AACzF,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * HTTP instrumentation: a default request timeout (always on) plus opt-in
3
+ * `--verbose` request tracing.
4
+ *
5
+ * The CLI talks to the platform over two transports: raw `got` (see
6
+ * `api-client.ts`) and the generated `@spec0/sdk-public-platform`, which issues
7
+ * calls through the global `fetch`. Neither had a timeout, so a silently
8
+ * dropped connection could hang the CLI forever, and neither printed anything,
9
+ * so a failing command could not show *which URL* it hit.
10
+ *
11
+ * `installHttpInstrumentation()` wraps the global `fetch` once at startup to
12
+ * - apply a default timeout (combined with any signal the SDK already passes,
13
+ * so cancellation still works), and
14
+ * - trace each request/response when `--verbose` is on.
15
+ * `got` gets the same timeout via its own options and calls `traceRequest` /
16
+ * `traceResponse` from its hooks.
17
+ *
18
+ * All trace output goes to **stderr** so stdout stays a clean single document
19
+ * for `--output json|yaml` consumers.
20
+ */
21
+ /**
22
+ * Default per-request timeout in milliseconds. Override with
23
+ * `SPEC0_HTTP_TIMEOUT_MS`; falls back to 30s for any unset/invalid value.
24
+ */
25
+ export declare function httpTimeoutMs(): number;
26
+ /** Enable/disable `--verbose` request tracing. */
27
+ export declare function setHttpTrace(on: boolean): void;
28
+ export declare function httpTraceEnabled(): boolean;
29
+ export declare function traceRequest(method: string, url: string): void;
30
+ export declare function traceResponse(status: number, url: string): void;
31
+ export declare function traceError(method: string, url: string, message: string): void;
32
+ /**
33
+ * Wrap the global `fetch` once (covers all SDK calls) to apply the default
34
+ * timeout and trace when verbose. Idempotent; safe to call at startup.
35
+ */
36
+ export declare function installHttpInstrumentation(): void;
37
+ //# sourceMappingURL=http-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-trace.d.ts","sourceRoot":"","sources":["../../src/lib/http-trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAED,kDAAkD;AAClD,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE9C;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAMD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7E;AAgBD;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CA2BjD"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * HTTP instrumentation: a default request timeout (always on) plus opt-in
3
+ * `--verbose` request tracing.
4
+ *
5
+ * The CLI talks to the platform over two transports: raw `got` (see
6
+ * `api-client.ts`) and the generated `@spec0/sdk-public-platform`, which issues
7
+ * calls through the global `fetch`. Neither had a timeout, so a silently
8
+ * dropped connection could hang the CLI forever, and neither printed anything,
9
+ * so a failing command could not show *which URL* it hit.
10
+ *
11
+ * `installHttpInstrumentation()` wraps the global `fetch` once at startup to
12
+ * - apply a default timeout (combined with any signal the SDK already passes,
13
+ * so cancellation still works), and
14
+ * - trace each request/response when `--verbose` is on.
15
+ * `got` gets the same timeout via its own options and calls `traceRequest` /
16
+ * `traceResponse` from its hooks.
17
+ *
18
+ * All trace output goes to **stderr** so stdout stays a clean single document
19
+ * for `--output json|yaml` consumers.
20
+ */
21
+ import chalk from "chalk";
22
+ const DEFAULT_TIMEOUT_MS = 30_000;
23
+ let enabled = false;
24
+ let installed = false;
25
+ /**
26
+ * Default per-request timeout in milliseconds. Override with
27
+ * `SPEC0_HTTP_TIMEOUT_MS`; falls back to 30s for any unset/invalid value.
28
+ */
29
+ export function httpTimeoutMs() {
30
+ const raw = process.env.SPEC0_HTTP_TIMEOUT_MS;
31
+ const n = raw ? Number(raw) : NaN;
32
+ return Number.isFinite(n) && n > 0 ? n : DEFAULT_TIMEOUT_MS;
33
+ }
34
+ /** Enable/disable `--verbose` request tracing. */
35
+ export function setHttpTrace(on) {
36
+ enabled = on;
37
+ }
38
+ export function httpTraceEnabled() {
39
+ return enabled;
40
+ }
41
+ function line(text) {
42
+ process.stderr.write(chalk.gray(text.endsWith("\n") ? text : `${text}\n`));
43
+ }
44
+ export function traceRequest(method, url) {
45
+ if (enabled)
46
+ line(`→ ${method} ${url}`);
47
+ }
48
+ export function traceResponse(status, url) {
49
+ if (enabled)
50
+ line(`← ${status} ${url}`);
51
+ }
52
+ export function traceError(method, url, message) {
53
+ if (enabled)
54
+ line(`✗ ${method} ${url} — ${message}`);
55
+ }
56
+ /**
57
+ * Combine the SDK's own abort signal (if any) with a timeout signal so a hung
58
+ * request fails fast while explicit cancellation still works.
59
+ */
60
+ function withTimeout(init) {
61
+ const timeout = AbortSignal.timeout(httpTimeoutMs());
62
+ const existing = init?.signal ?? undefined;
63
+ const signal = existing && typeof AbortSignal.any === "function"
64
+ ? AbortSignal.any([existing, timeout])
65
+ : (existing ?? timeout);
66
+ return { ...init, signal };
67
+ }
68
+ /**
69
+ * Wrap the global `fetch` once (covers all SDK calls) to apply the default
70
+ * timeout and trace when verbose. Idempotent; safe to call at startup.
71
+ */
72
+ export function installHttpInstrumentation() {
73
+ if (installed)
74
+ return;
75
+ const original = globalThis.fetch;
76
+ if (typeof original !== "function")
77
+ return;
78
+ globalThis.fetch = (async (input, init) => {
79
+ const method = init?.method ??
80
+ (typeof input === "object" && input !== null && "method" in input
81
+ ? input.method
82
+ : "GET");
83
+ const url = typeof input === "string"
84
+ ? input
85
+ : input instanceof URL
86
+ ? input.toString()
87
+ : input.url;
88
+ traceRequest(method, url);
89
+ try {
90
+ const res = await original(input, withTimeout(init));
91
+ traceResponse(res.status, url);
92
+ return res;
93
+ }
94
+ catch (err) {
95
+ traceError(method, url, err.message);
96
+ throw err;
97
+ }
98
+ });
99
+ installed = true;
100
+ }
101
+ //# sourceMappingURL=http-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-trace.js","sourceRoot":"","sources":["../../src/lib/http-trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,IAAI,OAAO,GAAG,KAAK,CAAC;AACpB,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CA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GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAiB,CAAC;IACnB,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC"}
@@ -27,6 +27,10 @@ export declare function formatPublishText(output: {
27
27
  versionUnchanged?: boolean;
28
28
  versionUnchangedHint?: string;
29
29
  created?: boolean;
30
+ governanceWarnings?: Array<{
31
+ section?: string;
32
+ message?: string;
33
+ }>;
30
34
  }): string;
31
35
  export declare function formatGitHubAnnotation(file: string, line: number, level: "error" | "warning", message: string): string;
32
36
  //# sourceMappingURL=output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,wBAAgB,cAAc,CAAC,MAAM,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE,GAAG,MAAM,CAsBT;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAA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B,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpE,GAAG,MAAM,CA2CT;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,GACd,MAAM,CAER"}
@@ -56,6 +56,14 @@ export function formatPublishText(output) {
56
56
  chalk.yellow(output.versionUnchangedHint ??
57
57
  `Spec changed but version is still ${output.version}. Pass --semver to auto-bump.`));
58
58
  }
59
+ const warnings = output.governanceWarnings ?? [];
60
+ if (warnings.length > 0) {
61
+ lines.push("");
62
+ lines.push(chalk.yellow(`⚠ ${warnings.length} governance warning${warnings.length === 1 ? "" : "s"}:`));
63
+ for (const w of warnings) {
64
+ lines.push(chalk.yellow(` [${w.section ?? "policy"}] ${w.message ?? ""}`));
65
+ }
66
+ }
59
67
  return lines.join("\n");
60
68
  }
61
69
  export function formatGitHubAnnotation(file, line, level, message) {
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,UAAU,cAAc,CAAC,MAI9B;IACC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC;IAC3C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IAClD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,IAAI,GAAG,KAA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AC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;IACjD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CACR,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,MAAM,sBAAsB,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAC5F,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,IAAI,QAAQ,KAAK,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,IAAY,EACZ,IAAY,EACZ,KAA0B,EAC1B,OAAe;IAEf,OAAO,KAAK,KAAK,SAAS,IAAI,SAAS,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;AAClF,CAAC"}
@@ -8,20 +8,45 @@
8
8
  * lint, search, registry, …). Stored on login as `org.apiUrl` and used by
9
9
  * `createOrgApiClient` / `createApiClient`.
10
10
  *
11
- * Defaults below match local dev (Next :3000, Spring :8080 + context path). Override both for
11
+ * Defaults below match local dev (Next :3000, backend :8080 at the host root). Override both for
12
12
  * staging/production. `SPEC0_API_URL` should align with `NEXT_PUBLIC_API_BASE_URL` in
13
- * api-management-ui, not the Next.js site origin alone.
13
+ * the web UI, not the Next.js site origin alone.
14
14
  *
15
15
  * Legacy: `PLATFORM_APP_URL` / `PLATFORM_API_URL` are still accepted as fallbacks.
16
16
  */
17
17
  /** Next.js / browser app — CLI auth (`/cli-auth`) and push output links. */
18
18
  export declare const DEFAULT_PLATFORM_APP_URL = "https://app.spec0.io";
19
19
  /**
20
- * Spring Boot API base (include servlet context path if your deploy uses one).
20
+ * Backend API base. The platform serves at the host root, so this is a bare host
21
+ * with no path suffix; the SDK and raw call sites append their own service paths.
21
22
  */
22
- export declare const DEFAULT_PLATFORM_API_URL = "https://api.spec0.io/api-management";
23
+ export declare const DEFAULT_PLATFORM_API_URL = "https://api.spec0.io";
24
+ /**
25
+ * Canonical MCP (Model Context Protocol) server endpoint. This is the single
26
+ * Streamable HTTP endpoint that MCP clients (Cursor, Claude) connect to over
27
+ * HTTP POST. A bearer token is optional: anonymous access exposes the public
28
+ * docs tools, and an authenticated token unlocks the org-scoped tools. It is a
29
+ * different surface from the REST API base, so it has its own default and its
30
+ * own override env var.
31
+ */
32
+ export declare const DEFAULT_PLATFORM_MCP_URL = "https://api.spec0.io/mcp";
23
33
  /** Web app origin for auth + UI links — never used as the REST base. */
24
34
  export declare function resolvedPlatformAppUrl(): string;
25
35
  /** Backend base for all CLI REST calls — never derived from the app URL. */
26
36
  export declare function resolvedPlatformApiUrl(): string;
37
+ /**
38
+ * Canonical MCP Streamable HTTP endpoint clients connect to. Override with
39
+ * `SPEC0_MCP_URL` (legacy `PLATFORM_MCP_URL` accepted as a fallback) for
40
+ * staging/self-hosted.
41
+ */
42
+ export declare function resolvedPlatformMcpUrl(): string;
43
+ /**
44
+ * MCP base used as the root for sibling MCP paths such as the health probe
45
+ * behind `spec0 mcp test`. With the single Streamable HTTP endpoint the URL is
46
+ * already the base, so for back-compat we only trim a legacy trailing `/sse`
47
+ * (older overrides may still carry it) and otherwise return the endpoint as-is.
48
+ * Derived from the same default/override as {@link resolvedPlatformMcpUrl} so
49
+ * the two never drift apart — e.g. `…/mcp` → `…/mcp/health`.
50
+ */
51
+ export declare function resolvedPlatformMcpBaseUrl(): string;
27
52
  //# sourceMappingURL=platform-defaults.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-defaults.d.ts","sourceRoot":"","sources":["../../src/lib/platform-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,wBAAwB,wCAAwC,CAAC;AAM9E,wEAAwE;AACxE,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAED,4EAA4E;AAC5E,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C"}
1
+ {"version":3,"file":"platform-defaults.d.ts","sourceRoot":"","sources":["../../src/lib/platform-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAMnE,wEAAwE;AACxE,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAED,4EAA4E;AAC5E,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD"}
@@ -8,18 +8,28 @@
8
8
  * lint, search, registry, …). Stored on login as `org.apiUrl` and used by
9
9
  * `createOrgApiClient` / `createApiClient`.
10
10
  *
11
- * Defaults below match local dev (Next :3000, Spring :8080 + context path). Override both for
11
+ * Defaults below match local dev (Next :3000, backend :8080 at the host root). Override both for
12
12
  * staging/production. `SPEC0_API_URL` should align with `NEXT_PUBLIC_API_BASE_URL` in
13
- * api-management-ui, not the Next.js site origin alone.
13
+ * the web UI, not the Next.js site origin alone.
14
14
  *
15
15
  * Legacy: `PLATFORM_APP_URL` / `PLATFORM_API_URL` are still accepted as fallbacks.
16
16
  */
17
17
  /** Next.js / browser app — CLI auth (`/cli-auth`) and push output links. */
18
18
  export const DEFAULT_PLATFORM_APP_URL = "https://app.spec0.io";
19
19
  /**
20
- * Spring Boot API base (include servlet context path if your deploy uses one).
20
+ * Backend API base. The platform serves at the host root, so this is a bare host
21
+ * with no path suffix; the SDK and raw call sites append their own service paths.
21
22
  */
22
- export const DEFAULT_PLATFORM_API_URL = "https://api.spec0.io/api-management";
23
+ export const DEFAULT_PLATFORM_API_URL = "https://api.spec0.io";
24
+ /**
25
+ * Canonical MCP (Model Context Protocol) server endpoint. This is the single
26
+ * Streamable HTTP endpoint that MCP clients (Cursor, Claude) connect to over
27
+ * HTTP POST. A bearer token is optional: anonymous access exposes the public
28
+ * docs tools, and an authenticated token unlocks the org-scoped tools. It is a
29
+ * different surface from the REST API base, so it has its own default and its
30
+ * own override env var.
31
+ */
32
+ export const DEFAULT_PLATFORM_MCP_URL = "https://api.spec0.io/mcp";
23
33
  function normalizeOrigin(url) {
24
34
  return url.trim().replace(/\/$/, "");
25
35
  }
@@ -33,4 +43,24 @@ export function resolvedPlatformApiUrl() {
33
43
  const raw = (process.env.SPEC0_API_URL ?? process.env.PLATFORM_API_URL)?.trim();
34
44
  return normalizeOrigin(raw || DEFAULT_PLATFORM_API_URL);
35
45
  }
46
+ /**
47
+ * Canonical MCP Streamable HTTP endpoint clients connect to. Override with
48
+ * `SPEC0_MCP_URL` (legacy `PLATFORM_MCP_URL` accepted as a fallback) for
49
+ * staging/self-hosted.
50
+ */
51
+ export function resolvedPlatformMcpUrl() {
52
+ const raw = (process.env.SPEC0_MCP_URL ?? process.env.PLATFORM_MCP_URL)?.trim();
53
+ return normalizeOrigin(raw || DEFAULT_PLATFORM_MCP_URL);
54
+ }
55
+ /**
56
+ * MCP base used as the root for sibling MCP paths such as the health probe
57
+ * behind `spec0 mcp test`. With the single Streamable HTTP endpoint the URL is
58
+ * already the base, so for back-compat we only trim a legacy trailing `/sse`
59
+ * (older overrides may still carry it) and otherwise return the endpoint as-is.
60
+ * Derived from the same default/override as {@link resolvedPlatformMcpUrl} so
61
+ * the two never drift apart — e.g. `…/mcp` → `…/mcp/health`.
62
+ */
63
+ export function resolvedPlatformMcpBaseUrl() {
64
+ return resolvedPlatformMcpUrl().replace(/\/sse$/, "");
65
+ }
36
66
  //# sourceMappingURL=platform-defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-defaults.js","sourceRoot":"","sources":["../../src/lib/platform-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,qCAAqC,CAAC;AAE9E,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC;IAChF,OAAO,eAAe,CAAC,GAAG,IAAI,wBAAwB,CAAC,CAAC;AAC1D,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC;IAChF,OAAO,eAAe,CAAC,GAAG,IAAI,wBAAwB,CAAC,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"file":"platform-defaults.js","sourceRoot":"","sources":["../../src/lib/platform-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,4EAA4E;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
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Spec0 CLI — publish API specs, create mock servers, lint, and interact with the Spec0 platform",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -54,16 +54,16 @@
54
54
  },
55
55
  "homepage": "https://github.com/spec-0/cli#readme",
56
56
  "dependencies": {
57
- "@inquirer/prompts": "^7.2.0",
58
- "@spec0/sdk-public-platform": "^1.2.0",
57
+ "@inquirer/prompts": "^8.5.2",
58
+ "@spec0/sdk-public-platform": "^1.3.1",
59
59
  "@stoplight/spectral-core": "^1.22.0",
60
60
  "@stoplight/spectral-parsers": "^1.0.0",
61
61
  "@stoplight/spectral-rulesets": "^1.22.1",
62
62
  "chalk": "^5.3.0",
63
63
  "cli-table3": "^0.6.5",
64
- "commander": "^12.1.0",
64
+ "commander": "^14.0.3",
65
65
  "conf": "^13.0.0",
66
- "diff": "^7.0.0",
66
+ "diff": "^9.0.0",
67
67
  "got": "^14.4.1",
68
68
  "open": "^10.0.0",
69
69
  "ora": "^8.1.0",
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@commitlint/cli": "^20.5.0",
74
- "@commitlint/config-conventional": "^20.5.0",
74
+ "@commitlint/config-conventional": "^21.0.0",
75
75
  "@eslint/js": "^9.39.4",
76
76
  "@types/diff": "^7.0.0",
77
77
  "@types/jest": "^30.0.0",