@kici-dev/compiler 0.0.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.
- package/LICENSE +202 -0
- package/README.md +1 -6
- package/dist/assets/api-TJJVHrjC.json +118 -0
- package/dist/assets/descriptor-BTtjzN9L.json +1382 -0
- package/dist/assets/package-BpQF9kR8.json +74 -0
- package/dist/assets/package-Ceo2h27X.json +89 -0
- package/dist/assets/source_context-D0atuL28.json +20 -0
- package/dist/assets/type-BFqO8SCZ.json +202 -0
- package/dist/auth/headless-detect.d.ts +14 -0
- package/dist/auth/headless-detect.js +25 -0
- package/dist/chunk-gOLHoazu.js +4 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +193 -0
- package/dist/commands/cancel.d.ts +22 -0
- package/dist/commands/cancel.js +124 -0
- package/dist/commands/compile.d.ts +17 -0
- package/dist/commands/compile.js +99 -0
- package/dist/commands/docs.d.ts +26 -0
- package/dist/commands/docs.js +60 -0
- package/dist/commands/drain-worker.d.ts +19 -0
- package/dist/commands/drain-worker.js +45 -0
- package/dist/commands/endpoints.d.ts +53 -0
- package/dist/commands/endpoints.js +185 -0
- package/dist/commands/fixture.d.ts +14 -0
- package/dist/commands/fixture.js +104 -0
- package/dist/commands/hook.d.ts +20 -0
- package/dist/commands/hook.js +97 -0
- package/dist/commands/index.d.ts +33 -0
- package/dist/commands/index.js +20 -0
- package/dist/commands/init.d.ts +35 -0
- package/dist/commands/init.js +393 -0
- package/dist/commands/login.d.ts +23 -0
- package/dist/commands/login.js +144 -0
- package/dist/commands/logout.d.ts +18 -0
- package/dist/commands/logout.js +55 -0
- package/dist/commands/org.d.ts +27 -0
- package/dist/commands/org.js +126 -0
- package/dist/commands/run.d.ts +21 -0
- package/dist/commands/run.js +562 -0
- package/dist/commands/secrets-list.d.ts +16 -0
- package/dist/commands/secrets-list.js +85 -0
- package/dist/commands/status.d.ts +30 -0
- package/dist/commands/status.js +210 -0
- package/dist/commands/test.d.ts +61 -0
- package/dist/commands/test.js +220 -0
- package/dist/commands/types.d.ts +18 -0
- package/dist/commands/types.js +74 -0
- package/dist/commands/watch.d.ts +14 -0
- package/dist/commands/watch.js +97 -0
- package/dist/commands/workflows.d.ts +28 -0
- package/dist/commands/workflows.js +154 -0
- package/dist/comment-created.json +30 -0
- package/dist/create-branch.json +17 -0
- package/dist/delete-branch.json +15 -0
- package/dist/dispatch.json +15 -0
- package/dist/errors/capability-gap.d.ts +50 -0
- package/dist/errors/capability-gap.js +54 -0
- package/dist/errors/codes.d.ts +25 -0
- package/dist/errors/formatter.d.ts +32 -0
- package/dist/errors/formatter.js +35 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/index.js +4 -0
- package/dist/execution/executor.d.ts +61 -0
- package/dist/execution/executor.js +230 -0
- package/dist/execution/index.d.ts +4 -0
- package/dist/execution/index.js +3 -0
- package/dist/execution/sdk-alias.d.ts +33 -0
- package/dist/execution/sdk-alias.js +102 -0
- package/dist/fixtures/compiler.d.ts +47 -0
- package/dist/fixtures/compiler.js +177 -0
- package/dist/fixtures/defaults/comment-created.json +30 -0
- package/dist/fixtures/defaults/create-branch.json +17 -0
- package/dist/fixtures/defaults/delete-branch.json +15 -0
- package/dist/fixtures/defaults/dispatch.json +15 -0
- package/dist/fixtures/defaults/fork.json +19 -0
- package/dist/fixtures/defaults/index.d.ts +16 -0
- package/dist/fixtures/defaults/index.js +105 -0
- package/dist/fixtures/defaults/index.ts +145 -0
- package/dist/fixtures/defaults/pr-closed.json +28 -0
- package/dist/fixtures/defaults/pr-opened.json +27 -0
- package/dist/fixtures/defaults/pr-reopened.json +27 -0
- package/dist/fixtures/defaults/pr-synchronize.json +27 -0
- package/dist/fixtures/defaults/push.json +16 -0
- package/dist/fixtures/defaults/release-published.json +23 -0
- package/dist/fixtures/defaults/review-comment-created.json +36 -0
- package/dist/fixtures/defaults/review-submitted.json +35 -0
- package/dist/fixtures/defaults/star-created.json +15 -0
- package/dist/fixtures/defaults/status.json +26 -0
- package/dist/fixtures/defaults/tag-push.json +20 -0
- package/dist/fixtures/defaults/watch-started.json +15 -0
- package/dist/fixtures/defaults/workflow-run-completed.json +23 -0
- package/dist/fork.json +19 -0
- package/dist/format.d.ts +5 -0
- package/dist/format.js +20 -0
- package/dist/generators/secrets-dts.d.ts +29 -0
- package/dist/generators/secrets-dts.js +67 -0
- package/dist/hooks/detector.d.ts +39 -0
- package/dist/hooks/detector.js +133 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/installer.d.ts +24 -0
- package/dist/hooks/installer.js +328 -0
- package/dist/hooks/templates.d.ts +26 -0
- package/dist/hooks/templates.js +63 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/llm-context/llms-full.txt +9974 -0
- package/dist/llm-context/llms.txt +61 -0
- package/dist/local-executor/dag-scheduler.d.ts +44 -0
- package/dist/local-executor/dag-scheduler.js +183 -0
- package/dist/local-executor/index.d.ts +23 -0
- package/dist/local-executor/index.js +309 -0
- package/dist/local-executor/job-runner.d.ts +40 -0
- package/dist/local-executor/job-runner.js +307 -0
- package/dist/local-executor/output-streamer.d.ts +31 -0
- package/dist/local-executor/output-streamer.js +166 -0
- package/dist/local-executor/payload-generator.d.ts +16 -0
- package/dist/local-executor/payload-generator.js +138 -0
- package/dist/local-executor/picker.d.ts +33 -0
- package/dist/local-executor/picker.js +109 -0
- package/dist/local-executor/secret-loader.d.ts +18 -0
- package/dist/local-executor/secret-loader.js +105 -0
- package/dist/local-executor/types.d.ts +80 -0
- package/dist/local-executor/types.js +2 -0
- package/dist/local-executor/workflow-lock.d.ts +81 -0
- package/dist/local-executor/workflow-lock.js +0 -0
- package/dist/lockfile/generator.d.ts +39 -0
- package/dist/lockfile/generator.js +688 -0
- package/dist/lockfile/hash-files.d.ts +14 -0
- package/dist/lockfile/hash-files.js +50 -0
- package/dist/lockfile/hasher.d.ts +36 -0
- package/dist/lockfile/hasher.js +46 -0
- package/dist/lockfile/index.d.ts +3 -0
- package/dist/lockfile/index.js +4 -0
- package/dist/lockfile/purity-analyzer.d.ts +25 -0
- package/dist/lockfile/purity-analyzer.js +204 -0
- package/dist/package-F7UXSDHW.json +74 -0
- package/dist/postinstall.d.ts +9 -0
- package/dist/postinstall.js +60 -0
- package/dist/pr-closed.json +28 -0
- package/dist/pr-opened.json +27 -0
- package/dist/pr-reopened.json +27 -0
- package/dist/pr-synchronize.json +27 -0
- package/dist/push.json +16 -0
- package/dist/release-published.json +23 -0
- package/dist/remote/client.d.ts +204 -0
- package/dist/remote/client.js +203 -0
- package/dist/remote/config.d.ts +54 -0
- package/dist/remote/config.js +92 -0
- package/dist/remote/encryption.d.ts +35 -0
- package/dist/remote/encryption.js +87 -0
- package/dist/remote/history.d.ts +91 -0
- package/dist/remote/history.js +146 -0
- package/dist/remote/oauth.d.ts +65 -0
- package/dist/remote/oauth.js +302 -0
- package/dist/remote/observer.d.ts +81 -0
- package/dist/remote/observer.js +174 -0
- package/dist/remote/output/json.d.ts +13 -0
- package/dist/remote/output/json.js +36 -0
- package/dist/remote/output/junit.d.ts +18 -0
- package/dist/remote/output/junit.js +50 -0
- package/dist/remote/output/streaming.d.ts +57 -0
- package/dist/remote/output/streaming.js +124 -0
- package/dist/remote/output/summary.d.ts +39 -0
- package/dist/remote/output/summary.js +99 -0
- package/dist/remote/uploader.d.ts +87 -0
- package/dist/remote/uploader.js +197 -0
- package/dist/review-comment-created.json +36 -0
- package/dist/review-submitted.json +35 -0
- package/dist/star-created.json +15 -0
- package/dist/status.json +26 -0
- package/dist/tag-push.json +20 -0
- package/dist/templates/agents-md.d.ts +8 -0
- package/dist/templates/agents-md.js +130 -0
- package/dist/templates/index.d.ts +43 -0
- package/dist/templates/index.js +48 -0
- package/dist/templates/package-json.d.ts +18 -0
- package/dist/templates/package-json.js +34 -0
- package/dist/templates/tsconfig-json.d.ts +9 -0
- package/dist/templates/tsconfig-json.js +26 -0
- package/dist/templates/workflows/hello-world.d.ts +2 -0
- package/dist/templates/workflows/hello-world.js +16 -0
- package/dist/templates/workflows/hello-world.ts +21 -0
- package/dist/templates/workflows/pr-checks.d.ts +2 -0
- package/dist/templates/workflows/pr-checks.js +40 -0
- package/dist/templates/workflows/pr-checks.ts +57 -0
- package/dist/test-runner/dry-run.d.ts +12 -0
- package/dist/test-runner/dry-run.js +66 -0
- package/dist/test-runner/event-types.d.ts +86 -0
- package/dist/test-runner/event-types.js +330 -0
- package/dist/test-runner/git-detector.d.ts +15 -0
- package/dist/test-runner/git-detector.js +30 -0
- package/dist/test-runner/index.d.ts +13 -0
- package/dist/test-runner/index.js +11 -0
- package/dist/test-runner/job-executor.d.ts +48 -0
- package/dist/test-runner/job-executor.js +245 -0
- package/dist/test-runner/output-formatter.d.ts +47 -0
- package/dist/test-runner/output-formatter.js +92 -0
- package/dist/test-runner/payload-builder.d.ts +20 -0
- package/dist/test-runner/payload-builder.js +216 -0
- package/dist/test-runner/rule-evaluator.d.ts +14 -0
- package/dist/test-runner/rule-evaluator.js +31 -0
- package/dist/test-runner/secrets-file.d.ts +24 -0
- package/dist/test-runner/secrets-file.js +62 -0
- package/dist/test-runner/step-context.d.ts +15 -0
- package/dist/test-runner/step-context.js +140 -0
- package/dist/test-runner/summary.d.ts +7 -0
- package/dist/types.d.ts +525 -0
- package/dist/types.js +33 -0
- package/dist/validation/index.d.ts +3 -0
- package/dist/validation/index.js +3 -0
- package/dist/validation/validator.d.ts +26 -0
- package/dist/validation/validator.js +164 -0
- package/dist/watch-started.json +15 -0
- package/dist/workflow-run-completed.json +23 -0
- package/dist/workflows/hello-world.ts +21 -0
- package/dist/workflows/pr-checks.ts +57 -0
- package/hack/postinstall.mjs +105 -0
- package/package.json +60 -6
- package/sbom.spdx.json +10997 -0
- package/index.js +0 -3
|
@@ -0,0 +1,174 @@
|
|
|
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
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON output formatter for machine-readable results.
|
|
3
|
+
*
|
|
4
|
+
* Used with `--json` flag to produce structured output for CI integration.
|
|
5
|
+
*/
|
|
6
|
+
import type { RunResult } from './summary.js';
|
|
7
|
+
/**
|
|
8
|
+
* Format run results as structured JSON with 2-space indentation.
|
|
9
|
+
*
|
|
10
|
+
* @returns JSON string ready for stdout.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatJsonResult(results: RunResult[]): string;
|
|
13
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "../../chunk-gOLHoazu.js";
|
|
2
|
+
//#region src/remote/output/json.ts
|
|
3
|
+
/**
|
|
4
|
+
* Format run results as structured JSON with 2-space indentation.
|
|
5
|
+
*
|
|
6
|
+
* @returns JSON string ready for stdout.
|
|
7
|
+
*/
|
|
8
|
+
function formatJsonResult(results) {
|
|
9
|
+
const passed = results.filter((r) => r.status === "success").length;
|
|
10
|
+
const failed = results.filter((r) => r.status === "failed").length;
|
|
11
|
+
const cancelled = results.filter((r) => r.status === "cancelled").length;
|
|
12
|
+
const output = {
|
|
13
|
+
results: results.map((r) => ({
|
|
14
|
+
fixtureId: r.fixtureId,
|
|
15
|
+
runId: r.runId,
|
|
16
|
+
status: r.status,
|
|
17
|
+
totalDurationMs: r.totalDurationMs,
|
|
18
|
+
jobs: r.jobs.map((j) => ({
|
|
19
|
+
name: j.name,
|
|
20
|
+
status: j.status,
|
|
21
|
+
...j.durationMs !== void 0 && { durationMs: j.durationMs }
|
|
22
|
+
}))
|
|
23
|
+
})),
|
|
24
|
+
summary: {
|
|
25
|
+
passed,
|
|
26
|
+
failed,
|
|
27
|
+
cancelled,
|
|
28
|
+
total: results.length
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return JSON.stringify(output, null, 2);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { formatJsonResult };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JUnit XML output formatter for CI integration.
|
|
3
|
+
*
|
|
4
|
+
* Used with `--junit` flag to produce standard JUnit XML output that
|
|
5
|
+
* can be consumed by CI systems (Jenkins, GitLab, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Each fixture maps to a <testsuite>, each job maps to a <testcase>.
|
|
8
|
+
*/
|
|
9
|
+
import type { RunResult } from './summary.js';
|
|
10
|
+
/**
|
|
11
|
+
* Format run results as JUnit XML following the standard schema.
|
|
12
|
+
*
|
|
13
|
+
* @param results The run results to format.
|
|
14
|
+
* @param failureMessages Optional map of jobKey -> last lines of output for failure details.
|
|
15
|
+
* @returns Valid JUnit XML string.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatJunitResult(results: RunResult[], failureMessages?: Map<string, string>): string;
|
|
18
|
+
//# sourceMappingURL=junit.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "../../chunk-gOLHoazu.js";
|
|
2
|
+
//#region src/remote/output/junit.ts
|
|
3
|
+
/**
|
|
4
|
+
* Format run results as JUnit XML following the standard schema.
|
|
5
|
+
*
|
|
6
|
+
* @param results The run results to format.
|
|
7
|
+
* @param failureMessages Optional map of jobKey -> last lines of output for failure details.
|
|
8
|
+
* @returns Valid JUnit XML string.
|
|
9
|
+
*/
|
|
10
|
+
function formatJunitResult(results, failureMessages) {
|
|
11
|
+
const totalTests = results.reduce((sum, r) => sum + r.jobs.length, 0);
|
|
12
|
+
const totalFailures = results.reduce((sum, r) => sum + r.jobs.filter((j) => j.status === "failed").length, 0);
|
|
13
|
+
const totalTimeSeconds = results.reduce((sum, r) => sum + r.totalDurationMs / 1e3, 0);
|
|
14
|
+
const lines = [];
|
|
15
|
+
lines.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
|
16
|
+
lines.push(`<testsuites name="kici-test" tests="${totalTests}" failures="${totalFailures}" time="${totalTimeSeconds.toFixed(3)}">`);
|
|
17
|
+
for (const result of results) {
|
|
18
|
+
const suiteTests = result.jobs.length;
|
|
19
|
+
const suiteFailures = result.jobs.filter((j) => j.status === "failed").length;
|
|
20
|
+
const suiteTimeSeconds = result.totalDurationMs / 1e3;
|
|
21
|
+
lines.push(` <testsuite name="${escapeXml(result.fixtureId)}" tests="${suiteTests}" failures="${suiteFailures}" time="${suiteTimeSeconds.toFixed(3)}">`);
|
|
22
|
+
for (const job of result.jobs) {
|
|
23
|
+
const jobTimeSeconds = job.durationMs !== void 0 ? job.durationMs / 1e3 : 0;
|
|
24
|
+
if (job.status === "failed") {
|
|
25
|
+
const failureKey = `${result.fixtureId}:${job.name}`;
|
|
26
|
+
const failureText = failureMessages?.get(failureKey) ?? "Step failed";
|
|
27
|
+
lines.push(` <testcase name="${escapeXml(job.name)}" classname="${escapeXml(result.fixtureId)}" time="${jobTimeSeconds.toFixed(3)}">`);
|
|
28
|
+
lines.push(` <failure message="Step failed">${escapeXml(failureText)}</failure>`);
|
|
29
|
+
lines.push(" </testcase>");
|
|
30
|
+
} else if (job.status === "skipped") {
|
|
31
|
+
lines.push(` <testcase name="${escapeXml(job.name)}" classname="${escapeXml(result.fixtureId)}" time="${jobTimeSeconds.toFixed(3)}">`);
|
|
32
|
+
lines.push(" <skipped />");
|
|
33
|
+
lines.push(" </testcase>");
|
|
34
|
+
} else lines.push(` <testcase name="${escapeXml(job.name)}" classname="${escapeXml(result.fixtureId)}" time="${jobTimeSeconds.toFixed(3)}" />`);
|
|
35
|
+
}
|
|
36
|
+
lines.push(" </testsuite>");
|
|
37
|
+
}
|
|
38
|
+
lines.push("</testsuites>");
|
|
39
|
+
return lines.join("\n");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Escape special XML characters in a string.
|
|
43
|
+
*/
|
|
44
|
+
function escapeXml(text) {
|
|
45
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { formatJunitResult };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=junit.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real-time log streaming output formatter for CLI observer.
|
|
3
|
+
*
|
|
4
|
+
* Manages colored output for multi-job runs:
|
|
5
|
+
* - Assigns distinct colors per job name (cycling through a palette)
|
|
6
|
+
* - Formats log lines with colored job-name prefix
|
|
7
|
+
* - Prints step transition headers
|
|
8
|
+
* - Tracks elapsed time with in-place status updates
|
|
9
|
+
*/
|
|
10
|
+
export declare class StreamingFormatter {
|
|
11
|
+
/** Color assignment per job name. */
|
|
12
|
+
private readonly jobColors;
|
|
13
|
+
private colorIndex;
|
|
14
|
+
/** Track the current step per job to detect transitions. */
|
|
15
|
+
private readonly currentStep;
|
|
16
|
+
/** Start timestamp for elapsed time tracking. */
|
|
17
|
+
private startTime;
|
|
18
|
+
/** Elapsed timer interval reference. */
|
|
19
|
+
private elapsedTimer;
|
|
20
|
+
/** If true, suppress all streaming output. */
|
|
21
|
+
isQuiet: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Get or assign a color function for a job name.
|
|
24
|
+
*/
|
|
25
|
+
private getColor;
|
|
26
|
+
/**
|
|
27
|
+
* Format a log line with colored job-name prefix.
|
|
28
|
+
*
|
|
29
|
+
* If the step has changed since the last log for this job,
|
|
30
|
+
* a step header is emitted first.
|
|
31
|
+
*
|
|
32
|
+
* @returns The formatted line(s) to print, or empty string if quiet.
|
|
33
|
+
*/
|
|
34
|
+
formatLogLine(jobName: string, stepName: string, line: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Format a step lifecycle change.
|
|
37
|
+
*
|
|
38
|
+
* @returns The formatted status line, or empty string if quiet.
|
|
39
|
+
*/
|
|
40
|
+
formatStepChange(jobName: string, stepName: string, state: string, durationMs?: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Format a run status change.
|
|
43
|
+
*
|
|
44
|
+
* @returns The formatted status line, or empty string if quiet.
|
|
45
|
+
*/
|
|
46
|
+
formatStatusChange(status: string, jobName?: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Start the elapsed timer that updates a status line in-place.
|
|
49
|
+
* Uses \\r to overwrite the current line.
|
|
50
|
+
*/
|
|
51
|
+
startElapsedTimer(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Stop the elapsed timer and clear the status line.
|
|
54
|
+
*/
|
|
55
|
+
stopElapsedTimer(): void;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import "../../chunk-gOLHoazu.js";
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import { formatDuration } from "@kici-dev/shared";
|
|
4
|
+
//#region src/remote/output/streaming.ts
|
|
5
|
+
/**
|
|
6
|
+
* Real-time log streaming output formatter for CLI observer.
|
|
7
|
+
*
|
|
8
|
+
* Manages colored output for multi-job runs:
|
|
9
|
+
* - Assigns distinct colors per job name (cycling through a palette)
|
|
10
|
+
* - Formats log lines with colored job-name prefix
|
|
11
|
+
* - Prints step transition headers
|
|
12
|
+
* - Tracks elapsed time with in-place status updates
|
|
13
|
+
*/
|
|
14
|
+
/** Available color functions for job name assignment. */
|
|
15
|
+
const COLOR_PALETTE = [
|
|
16
|
+
pc.blue,
|
|
17
|
+
pc.green,
|
|
18
|
+
pc.yellow,
|
|
19
|
+
pc.magenta,
|
|
20
|
+
pc.cyan
|
|
21
|
+
];
|
|
22
|
+
var StreamingFormatter = class {
|
|
23
|
+
/** Color assignment per job name. */
|
|
24
|
+
jobColors = /* @__PURE__ */ new Map();
|
|
25
|
+
colorIndex = 0;
|
|
26
|
+
/** Track the current step per job to detect transitions. */
|
|
27
|
+
currentStep = /* @__PURE__ */ new Map();
|
|
28
|
+
/** Start timestamp for elapsed time tracking. */
|
|
29
|
+
startTime = Date.now();
|
|
30
|
+
/** Elapsed timer interval reference. */
|
|
31
|
+
elapsedTimer = null;
|
|
32
|
+
/** If true, suppress all streaming output. */
|
|
33
|
+
isQuiet = false;
|
|
34
|
+
/**
|
|
35
|
+
* Get or assign a color function for a job name.
|
|
36
|
+
*/
|
|
37
|
+
getColor(jobName) {
|
|
38
|
+
let color = this.jobColors.get(jobName);
|
|
39
|
+
if (!color) {
|
|
40
|
+
color = COLOR_PALETTE[this.colorIndex % COLOR_PALETTE.length];
|
|
41
|
+
this.colorIndex++;
|
|
42
|
+
this.jobColors.set(jobName, color);
|
|
43
|
+
}
|
|
44
|
+
return color;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Format a log line with colored job-name prefix.
|
|
48
|
+
*
|
|
49
|
+
* If the step has changed since the last log for this job,
|
|
50
|
+
* a step header is emitted first.
|
|
51
|
+
*
|
|
52
|
+
* @returns The formatted line(s) to print, or empty string if quiet.
|
|
53
|
+
*/
|
|
54
|
+
formatLogLine(jobName, stepName, line) {
|
|
55
|
+
if (this.isQuiet) return "";
|
|
56
|
+
const prefix = this.getColor(jobName)(`[${jobName}]`);
|
|
57
|
+
let output = "";
|
|
58
|
+
if (this.currentStep.get(jobName) !== stepName) {
|
|
59
|
+
this.currentStep.set(jobName, stepName);
|
|
60
|
+
output += `${prefix} ${pc.dim(`── Step: ${stepName} ──`)}\n`;
|
|
61
|
+
}
|
|
62
|
+
output += `${prefix} ${line}\n`;
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Format a step lifecycle change.
|
|
67
|
+
*
|
|
68
|
+
* @returns The formatted status line, or empty string if quiet.
|
|
69
|
+
*/
|
|
70
|
+
formatStepChange(jobName, stepName, state, durationMs) {
|
|
71
|
+
if (this.isQuiet) return "";
|
|
72
|
+
const prefix = this.getColor(jobName)(`[${jobName}]`);
|
|
73
|
+
const duration = durationMs !== void 0 ? ` (${formatDuration(durationMs)})` : "";
|
|
74
|
+
switch (state) {
|
|
75
|
+
case "running": return `${prefix} ▶ Step '${stepName}' started\n`;
|
|
76
|
+
case "success": return `${prefix} ${pc.green(`✓ Step '${stepName}' completed${duration}`)}\n`;
|
|
77
|
+
case "failed": return `${prefix} ${pc.red(`✗ Step '${stepName}' failed${duration}`)}\n`;
|
|
78
|
+
case "skipped": return `${prefix} ${pc.dim(`- Step '${stepName}' skipped`)}\n`;
|
|
79
|
+
default: return `${prefix} Step '${stepName}': ${state}${duration}\n`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Format a run status change.
|
|
84
|
+
*
|
|
85
|
+
* @returns The formatted status line, or empty string if quiet.
|
|
86
|
+
*/
|
|
87
|
+
formatStatusChange(status, jobName) {
|
|
88
|
+
if (this.isQuiet) return "";
|
|
89
|
+
switch (status) {
|
|
90
|
+
case "queued": return `${pc.dim("Queued...")}\n`;
|
|
91
|
+
case "running": return jobName ? `${pc.cyan(`Running: ${jobName}`)}\n` : `${pc.cyan("Running...")}\n`;
|
|
92
|
+
case "success": return `${pc.green("Run completed successfully")}\n`;
|
|
93
|
+
case "failed": return `${pc.red("Run failed")}\n`;
|
|
94
|
+
case "cancelled": return `${pc.yellow("Run cancelled")}\n`;
|
|
95
|
+
default: return `Status: ${status}\n`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Start the elapsed timer that updates a status line in-place.
|
|
100
|
+
* Uses \\r to overwrite the current line.
|
|
101
|
+
*/
|
|
102
|
+
startElapsedTimer() {
|
|
103
|
+
if (this.isQuiet) return;
|
|
104
|
+
this.startTime = Date.now();
|
|
105
|
+
this.elapsedTimer = setInterval(() => {
|
|
106
|
+
const elapsed = Date.now() - this.startTime;
|
|
107
|
+
process.stderr.write(`\r${pc.dim(`Elapsed: ${formatDuration(elapsed)}`)}`);
|
|
108
|
+
}, 1e3);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Stop the elapsed timer and clear the status line.
|
|
112
|
+
*/
|
|
113
|
+
stopElapsedTimer() {
|
|
114
|
+
if (this.elapsedTimer) {
|
|
115
|
+
clearInterval(this.elapsedTimer);
|
|
116
|
+
this.elapsedTimer = null;
|
|
117
|
+
process.stderr.write("\r\x1B[K");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
//#endregion
|
|
122
|
+
export { StreamingFormatter };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Completion summary output formatters.
|
|
3
|
+
*
|
|
4
|
+
* Renders summary tables, error highlights, and multi-fixture aggregates
|
|
5
|
+
* for display after run completion.
|
|
6
|
+
*/
|
|
7
|
+
/** Result of a single run (fixture execution). */
|
|
8
|
+
export interface RunResult {
|
|
9
|
+
fixtureId: string;
|
|
10
|
+
runId: string;
|
|
11
|
+
status: 'success' | 'failed' | 'cancelled';
|
|
12
|
+
totalDurationMs: number;
|
|
13
|
+
jobs: Array<{
|
|
14
|
+
name: string;
|
|
15
|
+
status: string;
|
|
16
|
+
durationMs?: number;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Format a summary table for a single run result.
|
|
21
|
+
*
|
|
22
|
+
* Renders a box-drawn table with job name, status, and duration.
|
|
23
|
+
* Status is colored: green for pass, red for fail, gray for skip.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatSummary(result: RunResult): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format an error highlight section showing the last lines of a failed step.
|
|
28
|
+
*
|
|
29
|
+
* @param failedJobName The name of the failed job.
|
|
30
|
+
* @param lastLines The last N lines of the failed step's output.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatErrorHighlight(failedJobName: string, lastLines: string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Format a multi-fixture summary aggregate.
|
|
35
|
+
*
|
|
36
|
+
* Shows counts: "Fixtures: N passed, M failed, T total"
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatMultiFixtureSummary(results: RunResult[]): string;
|
|
39
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import "../../chunk-gOLHoazu.js";
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import { formatDuration } from "@kici-dev/shared";
|
|
4
|
+
//#region src/remote/output/summary.ts
|
|
5
|
+
/**
|
|
6
|
+
* Completion summary output formatters.
|
|
7
|
+
*
|
|
8
|
+
* Renders summary tables, error highlights, and multi-fixture aggregates
|
|
9
|
+
* for display after run completion.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Format a summary table for a single run result.
|
|
13
|
+
*
|
|
14
|
+
* Renders a box-drawn table with job name, status, and duration.
|
|
15
|
+
* Status is colored: green for pass, red for fail, gray for skip.
|
|
16
|
+
*/
|
|
17
|
+
function formatSummary(result) {
|
|
18
|
+
const rows = result.jobs.map((job) => ({
|
|
19
|
+
name: job.name,
|
|
20
|
+
status: formatJobStatus(job.status),
|
|
21
|
+
statusRaw: job.status,
|
|
22
|
+
duration: job.durationMs !== void 0 ? formatDuration(job.durationMs) : "-"
|
|
23
|
+
}));
|
|
24
|
+
const nameWidth = Math.max(3, ...rows.map((r) => r.name.length));
|
|
25
|
+
const statusRawWidth = Math.max(6, ...rows.map((r) => statusTextLength(r.statusRaw)));
|
|
26
|
+
const durationWidth = Math.max(8, ...rows.map((r) => r.duration.length));
|
|
27
|
+
const lines = [];
|
|
28
|
+
lines.push(`\u250c${"─".repeat(nameWidth + 2)}\u252c${"─".repeat(statusRawWidth + 2)}\u252c${"─".repeat(durationWidth + 2)}\u2510`);
|
|
29
|
+
lines.push(`\u2502 ${"Job".padEnd(nameWidth)} \u2502 ${"Status".padEnd(statusRawWidth)} \u2502 ${"Duration".padEnd(durationWidth)} \u2502`);
|
|
30
|
+
lines.push(`\u251c${"─".repeat(nameWidth + 2)}\u253c${"─".repeat(statusRawWidth + 2)}\u253c${"─".repeat(durationWidth + 2)}\u2524`);
|
|
31
|
+
for (const row of rows) {
|
|
32
|
+
const statusPadding = statusRawWidth - statusTextLength(row.statusRaw);
|
|
33
|
+
lines.push(`\u2502 ${row.name.padEnd(nameWidth)} \u2502 ${row.status}${" ".repeat(statusPadding)} \u2502 ${row.duration.padEnd(durationWidth)} \u2502`);
|
|
34
|
+
}
|
|
35
|
+
lines.push(`\u2514${"─".repeat(nameWidth + 2)}\u2534${"─".repeat(statusRawWidth + 2)}\u2534${"─".repeat(durationWidth + 2)}\u2518`);
|
|
36
|
+
lines.push("");
|
|
37
|
+
const resultText = result.status === "success" ? pc.green("PASSED") : pc.red("FAILED");
|
|
38
|
+
lines.push(`Result: ${resultText} (${formatDuration(result.totalDurationMs)})`);
|
|
39
|
+
return lines.join("\n");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Format an error highlight section showing the last lines of a failed step.
|
|
43
|
+
*
|
|
44
|
+
* @param failedJobName The name of the failed job.
|
|
45
|
+
* @param lastLines The last N lines of the failed step's output.
|
|
46
|
+
*/
|
|
47
|
+
function formatErrorHighlight(failedJobName, lastLines) {
|
|
48
|
+
const truncated = lastLines.slice(-50);
|
|
49
|
+
const headerWidth = 40;
|
|
50
|
+
const header = `── Error: ${failedJobName} `;
|
|
51
|
+
const headerLine = pc.red(header + "─".repeat(Math.max(0, headerWidth - header.length)));
|
|
52
|
+
const footerLine = pc.red("─".repeat(headerWidth));
|
|
53
|
+
const lines = [];
|
|
54
|
+
lines.push(headerLine);
|
|
55
|
+
for (const line of truncated) lines.push(line);
|
|
56
|
+
lines.push(footerLine);
|
|
57
|
+
return lines.join("\n");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Format a multi-fixture summary aggregate.
|
|
61
|
+
*
|
|
62
|
+
* Shows counts: "Fixtures: N passed, M failed, T total"
|
|
63
|
+
*/
|
|
64
|
+
function formatMultiFixtureSummary(results) {
|
|
65
|
+
const passed = results.filter((r) => r.status === "success").length;
|
|
66
|
+
const failed = results.filter((r) => r.status === "failed").length;
|
|
67
|
+
const cancelled = results.filter((r) => r.status === "cancelled").length;
|
|
68
|
+
const total = results.length;
|
|
69
|
+
const parts = [];
|
|
70
|
+
if (passed > 0) parts.push(pc.green(`${passed} passed`));
|
|
71
|
+
if (failed > 0) parts.push(pc.red(`${failed} failed`));
|
|
72
|
+
if (cancelled > 0) parts.push(pc.yellow(`${cancelled} cancelled`));
|
|
73
|
+
parts.push(`${total} total`);
|
|
74
|
+
return `Fixtures: ${parts.join(", ")}`;
|
|
75
|
+
}
|
|
76
|
+
/** Format a job status with icon and color. */
|
|
77
|
+
function formatJobStatus(status) {
|
|
78
|
+
switch (status) {
|
|
79
|
+
case "success": return pc.green("✓ pass");
|
|
80
|
+
case "failed": return pc.red("✗ fail");
|
|
81
|
+
case "skipped": return pc.dim("- skip");
|
|
82
|
+
case "cancelled": return pc.yellow("! cancel");
|
|
83
|
+
default: return status;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Get the visual text length for a status (for padding). */
|
|
87
|
+
function statusTextLength(status) {
|
|
88
|
+
switch (status) {
|
|
89
|
+
case "success": return 6;
|
|
90
|
+
case "failed": return 6;
|
|
91
|
+
case "skipped": return 6;
|
|
92
|
+
case "cancelled": return 8;
|
|
93
|
+
default: return status.length;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { formatErrorHighlight, formatMultiFixtureSummary, formatSummary };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=summary.js.map
|