@kici-dev/compiler 0.1.16 → 0.1.17

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 (136) hide show
  1. package/dist/auth/headless-detect.js +1 -1
  2. package/dist/cli-banner.js +1 -1
  3. package/dist/cli.js +56 -19
  4. package/dist/commands/approve.js +1 -1
  5. package/dist/commands/compile.js +5 -3
  6. package/dist/commands/diagnostics.d.ts +7 -0
  7. package/dist/commands/diagnostics.js +58 -0
  8. package/dist/commands/docs.js +1 -1
  9. package/dist/commands/drain-worker.js +1 -1
  10. package/dist/commands/endpoints.js +1 -1
  11. package/dist/commands/fixture.js +1 -1
  12. package/dist/commands/held-run-client.js +1 -1
  13. package/dist/commands/held-run-resolve.js +1 -1
  14. package/dist/commands/hook.js +1 -1
  15. package/dist/commands/index.d.ts +16 -4
  16. package/dist/commands/index.js +10 -4
  17. package/dist/commands/init.js +2 -2
  18. package/dist/commands/login.d.ts +0 -2
  19. package/dist/commands/login.js +1 -3
  20. package/dist/commands/logout.js +1 -1
  21. package/dist/commands/orchestrators.d.ts +25 -0
  22. package/dist/commands/orchestrators.js +115 -0
  23. package/dist/commands/org.js +1 -1
  24. package/dist/commands/reject.js +1 -1
  25. package/dist/commands/run.d.ts +2 -9
  26. package/dist/commands/run.js +256 -315
  27. package/dist/commands/runs/cancel.d.ts +6 -0
  28. package/dist/commands/runs/cancel.js +32 -0
  29. package/dist/commands/runs/list.d.ts +6 -0
  30. package/dist/commands/runs/list.js +49 -0
  31. package/dist/commands/runs/logs.d.ts +7 -0
  32. package/dist/commands/runs/logs.js +67 -0
  33. package/dist/commands/runs/rerun.d.ts +5 -0
  34. package/dist/commands/runs/rerun.js +21 -0
  35. package/dist/commands/runs/show.d.ts +5 -0
  36. package/dist/commands/runs/show.js +65 -0
  37. package/dist/commands/secrets-list.d.ts +7 -9
  38. package/dist/commands/secrets-list.js +40 -64
  39. package/dist/commands/test.d.ts +4 -0
  40. package/dist/commands/test.js +1 -1
  41. package/dist/commands/types.d.ts +3 -5
  42. package/dist/commands/types.js +13 -37
  43. package/dist/commands/verify-attestation.d.ts +12 -0
  44. package/dist/commands/verify-attestation.js +69 -0
  45. package/dist/commands/watch.js +1 -1
  46. package/dist/commands/workflows.js +14 -34
  47. package/dist/errors/capability-gap.js +1 -1
  48. package/dist/errors/formatter.js +1 -1
  49. package/dist/errors/index.js +1 -1
  50. package/dist/execution/executor.js +1 -1
  51. package/dist/execution/index.js +1 -1
  52. package/dist/execution/sdk-alias.js +1 -1
  53. package/dist/execution/ts-loader.js +1 -1
  54. package/dist/fixtures/compiler.js +1 -1
  55. package/dist/fixtures/defaults/index.js +1 -1
  56. package/dist/format.js +1 -1
  57. package/dist/generators/secrets-dts.js +2 -2
  58. package/dist/hooks/detector.js +1 -1
  59. package/dist/hooks/index.js +1 -1
  60. package/dist/hooks/installer.js +1 -1
  61. package/dist/hooks/templates.js +1 -1
  62. package/dist/index.js +1 -1
  63. package/dist/llm-context/llms-full.txt +1047 -132
  64. package/dist/llm-context/llms.txt +4 -1
  65. package/dist/local-executor/dag-scheduler.js +1 -1
  66. package/dist/local-executor/index.js +1 -1
  67. package/dist/local-executor/job-runner.js +37 -16
  68. package/dist/local-executor/materializer.js +1 -1
  69. package/dist/local-executor/output-streamer.js +1 -1
  70. package/dist/local-executor/payload-generator.js +1 -1
  71. package/dist/local-executor/picker.js +1 -1
  72. package/dist/local-executor/secret-loader.js +1 -1
  73. package/dist/local-executor/to-event-payload.js +1 -1
  74. package/dist/local-executor/types.js +1 -1
  75. package/dist/local-executor/workflow-lock.js +0 -0
  76. package/dist/lockfile/generator.d.ts +7 -5
  77. package/dist/lockfile/generator.js +21 -18
  78. package/dist/lockfile/hash-files.js +1 -1
  79. package/dist/lockfile/hasher.js +1 -1
  80. package/dist/lockfile/index.js +1 -1
  81. package/dist/lockfile/purity-analyzer.js +1 -1
  82. package/dist/postinstall.js +1 -1
  83. package/dist/provenance-trust-root.d.ts +14 -0
  84. package/dist/provenance-trust-root.js +49 -0
  85. package/dist/remote/config.d.ts +6 -2
  86. package/dist/remote/config.js +7 -4
  87. package/dist/remote/dashboard-client.d.ts +92 -0
  88. package/dist/remote/dashboard-client.js +168 -0
  89. package/dist/remote/encryption.js +3 -4
  90. package/dist/remote/history.js +1 -1
  91. package/dist/remote/oauth.js +1 -1
  92. package/dist/remote/oidc-discovery.js +1 -1
  93. package/dist/remote/output/json.js +1 -1
  94. package/dist/remote/output/junit.js +1 -1
  95. package/dist/remote/output/streaming.js +1 -1
  96. package/dist/remote/output/summary.js +1 -1
  97. package/dist/remote/platform-client.d.ts +142 -0
  98. package/dist/remote/platform-client.js +187 -0
  99. package/dist/remote/prod-defaults.js +1 -1
  100. package/dist/remote/render.d.ts +11 -0
  101. package/dist/remote/render.js +48 -0
  102. package/dist/remote/secret-upload.js +1 -1
  103. package/dist/remote/uploader.d.ts +9 -0
  104. package/dist/remote/uploader.js +51 -4
  105. package/dist/templates/agents-md.d.ts +1 -1
  106. package/dist/templates/agents-md.js +8 -3
  107. package/dist/templates/index.js +1 -1
  108. package/dist/templates/package-json.js +4 -5
  109. package/dist/templates/tsconfig-json.js +1 -1
  110. package/dist/templates/workflows/hello-world.js +2 -2
  111. package/dist/templates/workflows/hello-world.ts +1 -1
  112. package/dist/templates/workflows/pr-checks.js +3 -3
  113. package/dist/templates/workflows/pr-checks.ts +2 -2
  114. package/dist/test-runner/dry-run.js +1 -1
  115. package/dist/test-runner/event-types.js +1 -1
  116. package/dist/test-runner/git-detector.js +1 -1
  117. package/dist/test-runner/index.js +1 -1
  118. package/dist/test-runner/job-executor.js +1 -1
  119. package/dist/test-runner/output-formatter.js +1 -1
  120. package/dist/test-runner/payload-builder.js +1 -1
  121. package/dist/test-runner/rule-evaluator.js +1 -1
  122. package/dist/test-runner/secrets-file.js +1 -1
  123. package/dist/test-runner/step-context.js +10 -6
  124. package/dist/types.d.ts +8 -5
  125. package/dist/types.js +2 -1
  126. package/dist/validation/index.js +1 -1
  127. package/dist/validation/validator.js +1 -1
  128. package/dist/workflows/hello-world.ts +1 -1
  129. package/dist/workflows/pr-checks.ts +2 -2
  130. package/package.json +5 -4
  131. package/sbom.spdx.json +68 -38
  132. package/dist/commands/cancel.js +0 -124
  133. package/dist/commands/status.js +0 -212
  134. package/dist/remote/client.js +0 -203
  135. package/dist/remote/observer.js +0 -174
  136. /package/dist/{chunk-gOLHoazu.js → chunk-BTugEXQM.js} +0 -0
@@ -1,203 +0,0 @@
1
- import "../chunk-gOLHoazu.js";
2
- import { toErrorMessage } from "@kici-dev/core";
3
- //#region src/remote/client.ts
4
- /**
5
- * REST client for communicating with the KiCI orchestrator.
6
- *
7
- * Provides typed methods for triggering test runs, cancelling runs,
8
- * managing uploads, and checking run status.
9
- */
10
- var AuthenticationError = class extends Error {
11
- constructor(message = "Invalid API key. Run `kici login` to authenticate.") {
12
- super(message);
13
- this.name = "AuthenticationError";
14
- }
15
- };
16
- var AccessDeniedError = class extends Error {
17
- constructor(message = "Access denied") {
18
- super(message);
19
- this.name = "AccessDeniedError";
20
- }
21
- };
22
- var NotFoundError = class extends Error {
23
- constructor(message = "Resource not found") {
24
- super(message);
25
- this.name = "NotFoundError";
26
- }
27
- };
28
- var ServerError = class extends Error {
29
- constructor(message = "Server error", statusCode) {
30
- super(message);
31
- this.statusCode = statusCode;
32
- this.name = "ServerError";
33
- }
34
- };
35
- var ConnectionError = class extends Error {
36
- constructor(message, endpoint) {
37
- super(message);
38
- this.endpoint = endpoint;
39
- this.name = "ConnectionError";
40
- }
41
- };
42
- /**
43
- * REST client for the KiCI orchestrator API.
44
- *
45
- * Handles authentication, request formatting, and typed response parsing
46
- * for all test-trigger and upload operations.
47
- */
48
- var OrchestratorClient = class {
49
- baseUrl;
50
- token;
51
- cachedCapabilities;
52
- constructor(config) {
53
- this.baseUrl = config.endpoint.replace(/\/+$/, "");
54
- this.token = config.token;
55
- }
56
- /**
57
- * Fetch the orchestrator's capability manifest.
58
- *
59
- * Never throws — on any failure (old orchestrator returning 404, network
60
- * error, malformed JSON) it returns an empty manifest. Callers use the
61
- * returned fields to format actionable capability-gap errors and treat
62
- * missing fields as "unknown".
63
- *
64
- * Memoised per client instance so repeated calls in a single CLI session
65
- * hit the orchestrator once.
66
- */
67
- async getCapabilities() {
68
- if (!this.cachedCapabilities) this.cachedCapabilities = this.fetchCapabilities();
69
- return this.cachedCapabilities;
70
- }
71
- async fetchCapabilities() {
72
- const url = `${this.baseUrl}/api/v1/capabilities`;
73
- try {
74
- const response = await fetch(url);
75
- if (!response.ok) return {};
76
- const body = await response.json();
77
- return {
78
- orchestratorVersion: typeof body.orchestratorVersion === "string" ? body.orchestratorVersion : void 0,
79
- protocolVersion: typeof body.protocolVersion === "number" ? body.protocolVersion : void 0,
80
- minProtocolVersion: typeof body.minProtocolVersion === "number" ? body.minProtocolVersion : void 0
81
- };
82
- } catch {
83
- return {};
84
- }
85
- }
86
- /**
87
- * Trigger a test run on the orchestrator.
88
- *
89
- * POST /api/v1/test/trigger
90
- */
91
- async triggerTest(input) {
92
- return await (await this.request("/api/v1/test/trigger", {
93
- method: "POST",
94
- body: JSON.stringify(input)
95
- })).json();
96
- }
97
- /**
98
- * Cancel a running test run.
99
- *
100
- * POST /api/v1/test/cancel
101
- */
102
- async cancelTest(runId) {
103
- return await (await this.request("/api/v1/test/cancel", {
104
- method: "POST",
105
- body: JSON.stringify({ runId })
106
- })).json();
107
- }
108
- /**
109
- * Initialize an upload and get a pre-signed URL.
110
- *
111
- * POST /api/v1/uploads/init
112
- */
113
- async initUpload(opts) {
114
- return await (await this.request("/api/v1/uploads/init", {
115
- method: "POST",
116
- body: JSON.stringify(opts)
117
- })).json();
118
- }
119
- /**
120
- * Get the status of an upload.
121
- *
122
- * GET /api/v1/uploads/:uploadId/status
123
- */
124
- async getUploadStatus(uploadId) {
125
- return await (await this.request(`/api/v1/uploads/${uploadId}/status`, { method: "GET" })).json();
126
- }
127
- /**
128
- * List workflow registrations for an organization.
129
- *
130
- * GET /api/v1/orgs/:orgId/registrations
131
- */
132
- async getRegistrations(orgId, filters) {
133
- const query = new URLSearchParams(filters).toString();
134
- const path = `/api/v1/orgs/${orgId}/registrations${query ? `?${query}` : ""}`;
135
- return await (await this.request(path, { method: "GET" })).json();
136
- }
137
- /**
138
- * Get the status of a test run (polling fallback).
139
- *
140
- * GET /api/v1/test/runs/:runId
141
- */
142
- async getRunStatus(runId) {
143
- return await (await this.request(`/api/v1/test/runs/${runId}`, { method: "GET" })).json();
144
- }
145
- /**
146
- * Get logs for a test run.
147
- *
148
- * GET /api/v1/test/runs/:runId/logs
149
- */
150
- async getRunLogs(runId, jobFilter) {
151
- const query = jobFilter ? `?job=${encodeURIComponent(jobFilter)}` : "";
152
- return await (await this.request(`/api/v1/test/runs/${runId}/logs${query}`, { method: "GET" })).json();
153
- }
154
- /**
155
- * Make an authenticated request to the orchestrator.
156
- * Handles error classification and connection errors.
157
- */
158
- async request(path, init) {
159
- const url = `${this.baseUrl}${path}`;
160
- let response;
161
- try {
162
- response = await fetch(url, {
163
- ...init,
164
- headers: {
165
- "Content-Type": "application/json",
166
- Authorization: `Bearer ${this.token}`,
167
- ...init.headers
168
- }
169
- });
170
- } catch (err) {
171
- const message = toErrorMessage(err);
172
- throw new ConnectionError(`Failed to connect to orchestrator at ${this.baseUrl}: ${message}`, this.baseUrl);
173
- }
174
- if (response.ok) return response;
175
- if (response.status === 401) throw new AuthenticationError();
176
- if (response.status === 403) {
177
- let detail = "Access denied";
178
- try {
179
- const body = await response.json();
180
- if (body.error) detail = body.error;
181
- } catch {}
182
- throw new AccessDeniedError(detail);
183
- }
184
- if (response.status === 404) throw new NotFoundError();
185
- if (response.status >= 500) {
186
- let detail = `Server error (${response.status})`;
187
- try {
188
- const body = await response.json();
189
- if (body.error) detail = `${body.error} (${response.status})`;
190
- } catch {}
191
- throw new ServerError(`${detail}. The orchestrator may be temporarily unavailable -- try again in a moment.`, response.status);
192
- }
193
- let bodyText = "";
194
- try {
195
- bodyText = await response.text();
196
- } catch {}
197
- throw new Error(`Request failed with status ${response.status}: ${bodyText}`);
198
- }
199
- };
200
- //#endregion
201
- export { AuthenticationError, ConnectionError, NotFoundError, OrchestratorClient, ServerError };
202
-
203
- //# sourceMappingURL=client.js.map
@@ -1,174 +0,0 @@
1
- import "../chunk-gOLHoazu.js";
2
- import WebSocket from "ws";
3
- //#region src/remote/observer.ts
4
- /**
5
- * WebSocket observer client for real-time run streaming.
6
- *
7
- * Connects to the orchestrator's observer WS endpoint, subscribes to a
8
- * specific run, and relays real-time events (logs, step changes, status
9
- * updates, completion) to registered callbacks.
10
- *
11
- * Features:
12
- * - Auto-reconnect with lastSeenSequence for backfill (up to 5 attempts)
13
- * - Promise-based waitForCompletion()
14
- * - Clean disconnect
15
- */
16
- var ObserverClient = class {
17
- ws = null;
18
- lastSeenSequence = 0;
19
- reconnectAttempts = 0;
20
- intentionalDisconnect = false;
21
- initialConnectCompleted = false;
22
- reconnectTimer = null;
23
- completionResolve = null;
24
- completionReject = null;
25
- completionResult = null;
26
- config;
27
- constructor(config) {
28
- this.config = {
29
- maxReconnectAttempts: 5,
30
- reconnectDelayMs: 1e3,
31
- ...config
32
- };
33
- }
34
- /**
35
- * Connect to the observer endpoint and send the subscribe message.
36
- * Resolves when the WS connection is open and subscribe is sent.
37
- */
38
- connect() {
39
- return new Promise((resolve, reject) => {
40
- this.intentionalDisconnect = false;
41
- this.doConnect(resolve, reject);
42
- });
43
- }
44
- /**
45
- * Returns a promise that resolves when the run completes.
46
- * If the run already completed (from a prior observe.complete),
47
- * resolves immediately.
48
- */
49
- waitForCompletion() {
50
- if (this.completionResult) return Promise.resolve(this.completionResult);
51
- return new Promise((resolve, reject) => {
52
- this.completionResolve = resolve;
53
- this.completionReject = reject;
54
- });
55
- }
56
- /**
57
- * Gracefully disconnect from the observer endpoint.
58
- */
59
- disconnect() {
60
- this.intentionalDisconnect = true;
61
- if (this.reconnectTimer) {
62
- clearTimeout(this.reconnectTimer);
63
- this.reconnectTimer = null;
64
- }
65
- if (this.ws) {
66
- this.ws.close(1e3, "Observer disconnect");
67
- this.ws = null;
68
- }
69
- if (this.completionReject) {
70
- this.completionReject(/* @__PURE__ */ new Error("Observer disconnected"));
71
- this.completionResolve = null;
72
- this.completionReject = null;
73
- }
74
- }
75
- /** Current lastSeenSequence (for testing). */
76
- getLastSeenSequence() {
77
- return this.lastSeenSequence;
78
- }
79
- doConnect(onConnected, onFailed) {
80
- try {
81
- this.ws = new WebSocket(this.config.observeUrl);
82
- } catch (err) {
83
- const error = err instanceof Error ? err : new Error(String(err));
84
- if (onFailed) onFailed(error);
85
- else this.config.onError(error);
86
- return;
87
- }
88
- this.ws.on("open", () => {
89
- const subscribeMsg = {
90
- type: "observe.subscribe",
91
- runId: this.config.runId,
92
- token: this.config.token
93
- };
94
- if (this.lastSeenSequence > 0) subscribeMsg.lastSeenSequence = this.lastSeenSequence;
95
- this.ws.send(JSON.stringify(subscribeMsg));
96
- this.initialConnectCompleted = true;
97
- this.reconnectAttempts = 0;
98
- if (onConnected) onConnected();
99
- });
100
- this.ws.on("message", (data) => {
101
- this.handleMessage(data);
102
- });
103
- this.ws.on("close", (_code) => {
104
- this.ws = null;
105
- if (!this.intentionalDisconnect) this.scheduleReconnect();
106
- });
107
- this.ws.on("error", (err) => {
108
- if (onFailed) {
109
- onFailed(err);
110
- onFailed = void 0;
111
- onConnected = void 0;
112
- } else this.config.onError(err);
113
- });
114
- }
115
- handleMessage(data) {
116
- let msg;
117
- try {
118
- msg = JSON.parse(data.toString());
119
- } catch {
120
- return;
121
- }
122
- if (typeof msg.sequence === "number") this.lastSeenSequence = msg.sequence;
123
- switch (msg.type) {
124
- case "observe.log":
125
- this.config.onLog(msg);
126
- break;
127
- case "observe.step":
128
- this.config.onStep(msg);
129
- break;
130
- case "observe.status":
131
- this.config.onStatus(msg);
132
- break;
133
- case "observe.complete": {
134
- const completeMsg = msg;
135
- this.completionResult = completeMsg;
136
- this.config.onComplete(completeMsg);
137
- if (this.completionResolve) {
138
- this.completionResolve(completeMsg);
139
- this.completionResolve = null;
140
- this.completionReject = null;
141
- }
142
- break;
143
- }
144
- case "error": {
145
- const error = new Error(msg.message || "Observer error");
146
- this.config.onError(error);
147
- break;
148
- }
149
- }
150
- }
151
- scheduleReconnect() {
152
- if (!this.initialConnectCompleted) return;
153
- if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
154
- const error = /* @__PURE__ */ new Error(`Observer connection lost after ${this.config.maxReconnectAttempts} reconnection attempts`);
155
- this.config.onError(error);
156
- if (this.completionReject) {
157
- this.completionReject(error);
158
- this.completionResolve = null;
159
- this.completionReject = null;
160
- }
161
- return;
162
- }
163
- this.reconnectAttempts++;
164
- process.stderr.write(`Reconnecting to observer (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})...\n`);
165
- this.reconnectTimer = setTimeout(() => {
166
- this.reconnectTimer = null;
167
- if (!this.intentionalDisconnect) this.doConnect();
168
- }, this.config.reconnectDelayMs);
169
- }
170
- };
171
- //#endregion
172
- export { ObserverClient };
173
-
174
- //# sourceMappingURL=observer.js.map
File without changes