@kici-dev/compiler 0.1.26 → 0.2.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 (199) hide show
  1. package/dist/auth/headless-detect.d.ts +14 -5
  2. package/dist/auth/headless-detect.js +50 -9
  3. package/dist/cli-banner.d.ts +6 -3
  4. package/dist/cli-banner.js +13 -5
  5. package/dist/cli.js +180 -48
  6. package/dist/commands/check-mode.d.ts +1 -1
  7. package/dist/commands/compile.js +31 -7
  8. package/dist/commands/diagnostics.js +14 -2
  9. package/dist/commands/doctor.d.ts +64 -0
  10. package/dist/commands/doctor.js +413 -0
  11. package/dist/commands/endpoints.js +6 -0
  12. package/dist/commands/fixture.js +13 -0
  13. package/dist/commands/hook.js +3 -2
  14. package/dist/commands/index.d.ts +13 -1
  15. package/dist/commands/index.js +10 -3
  16. package/dist/commands/init-host-os.d.ts +34 -0
  17. package/dist/commands/init-host-os.js +44 -0
  18. package/dist/commands/init.d.ts +4 -0
  19. package/dist/commands/init.js +160 -37
  20. package/dist/commands/local-trust-root.d.ts +6 -0
  21. package/dist/commands/local-trust-root.js +52 -0
  22. package/dist/commands/local.d.ts +65 -0
  23. package/dist/commands/local.js +206 -0
  24. package/dist/commands/login.d.ts +2 -0
  25. package/dist/commands/login.js +41 -1
  26. package/dist/commands/logout.js +7 -0
  27. package/dist/commands/notifications.d.ts +61 -0
  28. package/dist/commands/notifications.js +274 -0
  29. package/dist/commands/preview.js +9 -2
  30. package/dist/commands/run-banner.d.ts +31 -0
  31. package/dist/commands/run-banner.js +25 -0
  32. package/dist/commands/run-routed.d.ts +53 -0
  33. package/dist/commands/run-routed.js +185 -0
  34. package/dist/commands/run.d.ts +0 -17
  35. package/dist/commands/run.js +44 -58
  36. package/dist/commands/runs/artifacts/download.d.ts +24 -0
  37. package/dist/commands/runs/artifacts/download.js +154 -0
  38. package/dist/commands/runs/artifacts/list.d.ts +5 -0
  39. package/dist/commands/runs/artifacts/list.js +47 -0
  40. package/dist/commands/runs/cancel.js +2 -2
  41. package/dist/commands/runs/list.js +8 -2
  42. package/dist/commands/secrets-list.d.ts +2 -2
  43. package/dist/commands/secrets-list.js +4 -4
  44. package/dist/commands/types.d.ts +3 -3
  45. package/dist/commands/types.js +4 -4
  46. package/dist/commands/verify-attestation.d.ts +3 -1
  47. package/dist/commands/verify-attestation.js +18 -7
  48. package/dist/errors/formatter.d.ts +14 -1
  49. package/dist/errors/formatter.js +13 -3
  50. package/dist/errors/index.d.ts +2 -1
  51. package/dist/errors/index.js +3 -2
  52. package/dist/errors/source-location.d.ts +20 -0
  53. package/dist/errors/source-location.js +45 -0
  54. package/dist/execution/executor.js +32 -12
  55. package/dist/fixtures/defaults/index.js +2 -1
  56. package/dist/generators/secrets-dts.d.ts +9 -9
  57. package/dist/generators/secrets-dts.js +12 -12
  58. package/dist/llm-context/llms-architecture.txt +50 -21
  59. package/dist/llm-context/llms-cli.txt +2667 -1454
  60. package/dist/llm-context/llms-features.txt +484 -414
  61. package/dist/llm-context/llms-full.txt +6703 -4687
  62. package/dist/llm-context/llms-getting-started.txt +311 -55
  63. package/dist/llm-context/llms-patterns.txt +17 -29
  64. package/dist/llm-context/llms-providers.txt +10 -1
  65. package/dist/llm-context/llms-sdk-runtime.txt +2013 -0
  66. package/dist/llm-context/llms-sdk.txt +596 -2157
  67. package/dist/llm-context/llms.txt +31 -17
  68. package/dist/local-plane/orchestrator-process.d.ts +70 -0
  69. package/dist/local-plane/orchestrator-process.js +129 -0
  70. package/dist/local-plane/os-mismatch-hint.d.ts +16 -0
  71. package/dist/local-plane/os-mismatch-hint.js +34 -0
  72. package/dist/local-plane/paths.d.ts +39 -0
  73. package/dist/local-plane/paths.js +54 -0
  74. package/dist/local-plane/plane-liveness.d.ts +68 -0
  75. package/dist/local-plane/plane-liveness.js +145 -0
  76. package/dist/local-plane/plane-manager.d.ts +193 -0
  77. package/dist/local-plane/plane-manager.js +480 -0
  78. package/dist/local-plane/plane-seed.d.ts +76 -0
  79. package/dist/local-plane/plane-seed.js +59 -0
  80. package/dist/local-plane/plane-trigger.d.ts +71 -0
  81. package/dist/local-plane/plane-trigger.js +110 -0
  82. package/dist/local-plane/platform-attach.d.ts +53 -0
  83. package/dist/local-plane/platform-attach.js +107 -0
  84. package/dist/local-plane/port-holder.d.ts +78 -0
  85. package/dist/local-plane/port-holder.js +227 -0
  86. package/dist/local-plane/postgres.d.ts +56 -0
  87. package/dist/local-plane/postgres.js +187 -0
  88. package/dist/local-plane/resolve-plane.d.ts +37 -0
  89. package/dist/local-plane/resolve-plane.js +76 -0
  90. package/dist/local-plane/run-follow.d.ts +61 -0
  91. package/dist/local-plane/run-follow.js +151 -0
  92. package/dist/local-plane/scaler-config.d.ts +68 -0
  93. package/dist/local-plane/scaler-config.js +132 -0
  94. package/dist/local-plane/secret-seed.d.ts +59 -0
  95. package/dist/local-plane/secret-seed.js +112 -0
  96. package/dist/local-plane/source-provider.d.ts +43 -0
  97. package/dist/local-plane/source-provider.js +159 -0
  98. package/dist/local-plane/trusted-routing.d.ts +32 -0
  99. package/dist/local-plane/trusted-routing.js +47 -0
  100. package/dist/lockfile/generator.d.ts +14 -1
  101. package/dist/lockfile/generator.js +103 -37
  102. package/dist/lockfile/index.d.ts +3 -1
  103. package/dist/lockfile/index.js +3 -2
  104. package/dist/lockfile/purity-diagnostics.d.ts +31 -0
  105. package/dist/lockfile/purity-diagnostics.js +52 -0
  106. package/dist/postinstall.js +2 -1
  107. package/dist/remote/artifact-extract.d.ts +8 -0
  108. package/dist/remote/artifact-extract.js +58 -0
  109. package/dist/remote/config.d.ts +21 -3
  110. package/dist/remote/config.js +24 -5
  111. package/dist/remote/dashboard-client.d.ts +46 -9
  112. package/dist/remote/dashboard-client.js +54 -11
  113. package/dist/remote/fs-case.d.ts +21 -0
  114. package/dist/remote/fs-case.js +45 -0
  115. package/dist/remote/history.d.ts +9 -3
  116. package/dist/remote/history.js +79 -10
  117. package/dist/remote/local-repo-identity.d.ts +1 -1
  118. package/dist/remote/local-repo-identity.js +2 -1
  119. package/dist/remote/notifications-client.d.ts +149 -0
  120. package/dist/remote/notifications-client.js +103 -0
  121. package/dist/remote/oauth.d.ts +13 -0
  122. package/dist/remote/oauth.js +31 -5
  123. package/dist/remote/output/summary.js +76 -14
  124. package/dist/remote/platform-client.d.ts +1 -1
  125. package/dist/remote/render.js +30 -9
  126. package/dist/{local-executor → remote}/secret-loader.d.ts +1 -1
  127. package/dist/{local-executor → remote}/secret-loader.js +4 -4
  128. package/dist/remote/secret-upload.d.ts +1 -1
  129. package/dist/remote/secret-upload.js +2 -2
  130. package/dist/remote/uploader.d.ts +1 -1
  131. package/dist/remote/uploader.js +7 -6
  132. package/dist/templates/agents-md.d.ts +1 -1
  133. package/dist/templates/agents-md.js +8 -8
  134. package/dist/templates/index.d.ts +1 -1
  135. package/dist/templates/index.js +2 -2
  136. package/dist/templates/package-json.d.ts +15 -0
  137. package/dist/templates/package-json.js +26 -5
  138. package/dist/test-runner/dry-run.d.ts +2 -1
  139. package/dist/test-runner/dry-run.js +18 -1
  140. package/dist/test-runner/event-types.d.ts +2 -0
  141. package/dist/test-runner/event-types.js +3 -0
  142. package/dist/test-runner/job-executor.d.ts +1 -0
  143. package/dist/test-runner/job-executor.js +82 -44
  144. package/dist/test-runner/output-formatter.d.ts +5 -2
  145. package/dist/test-runner/output-formatter.js +6 -4
  146. package/dist/test-runner/payload-builder.d.ts +7 -1
  147. package/dist/test-runner/payload-builder.js +11 -2
  148. package/dist/test-runner/rule-evaluator.d.ts +7 -3
  149. package/dist/test-runner/rule-evaluator.js +13 -12
  150. package/dist/{local-executor → test-runner}/runs-on-display.js +1 -1
  151. package/dist/test-runner/step-context.d.ts +23 -5
  152. package/dist/test-runner/step-context.js +29 -119
  153. package/dist/types.d.ts +26 -7
  154. package/dist/types.js +4 -2
  155. package/dist/validation/index.d.ts +2 -0
  156. package/dist/validation/index.js +2 -1
  157. package/dist/validation/typecheck.d.ts +28 -0
  158. package/dist/validation/typecheck.js +110 -0
  159. package/dist/validation/validator.d.ts +9 -4
  160. package/dist/validation/validator.js +38 -44
  161. package/package.json +13 -13
  162. package/sbom.spdx.json +9311 -1528
  163. package/dist/assets/api-TJJVHrjC.json +0 -118
  164. package/dist/assets/descriptor-BTtjzN9L.json +0 -1382
  165. package/dist/assets/package-BpQF9kR8.json +0 -74
  166. package/dist/assets/package-Ceo2h27X.json +0 -89
  167. package/dist/assets/source_context-D0atuL28.json +0 -20
  168. package/dist/assets/type-BFqO8SCZ.json +0 -202
  169. package/dist/commands/cancel.d.ts +0 -22
  170. package/dist/commands/detect-package-manager.d.ts +0 -42
  171. package/dist/commands/held-run-resolve.d.ts +0 -50
  172. package/dist/commands/status.d.ts +0 -34
  173. package/dist/commands/test.d.ts +0 -88
  174. package/dist/errors/codes.d.ts +0 -25
  175. package/dist/local-executor/dag-scheduler.d.ts +0 -44
  176. package/dist/local-executor/dag-scheduler.js +0 -183
  177. package/dist/local-executor/index.d.ts +0 -23
  178. package/dist/local-executor/index.js +0 -378
  179. package/dist/local-executor/job-runner.d.ts +0 -47
  180. package/dist/local-executor/job-runner.js +0 -411
  181. package/dist/local-executor/materializer.d.ts +0 -44
  182. package/dist/local-executor/materializer.js +0 -132
  183. package/dist/local-executor/output-streamer.d.ts +0 -31
  184. package/dist/local-executor/output-streamer.js +0 -168
  185. package/dist/local-executor/payload-generator.d.ts +0 -16
  186. package/dist/local-executor/payload-generator.js +0 -138
  187. package/dist/local-executor/picker.d.ts +0 -33
  188. package/dist/local-executor/picker.js +0 -109
  189. package/dist/local-executor/to-event-payload.d.ts +0 -16
  190. package/dist/local-executor/to-event-payload.js +0 -21
  191. package/dist/local-executor/types.d.ts +0 -93
  192. package/dist/local-executor/types.js +0 -2
  193. package/dist/local-executor/workflow-lock.d.ts +0 -82
  194. package/dist/local-executor/workflow-lock.js +0 -0
  195. package/dist/package-F7UXSDHW.json +0 -74
  196. package/dist/remote/client.d.ts +0 -210
  197. package/dist/remote/observer.d.ts +0 -81
  198. package/dist/test-runner/summary.d.ts +0 -7
  199. /package/dist/{local-executor → test-runner}/runs-on-display.d.ts +0 -0
@@ -1,168 +0,0 @@
1
- import "../rolldown-runtime-ClRpJifh.js";
2
- import pc from "picocolors";
3
- import { logger } from "@kici-dev/core";
4
- //#region src/local-executor/output-streamer.ts
5
- /**
6
- * Output formatting for local execution: tree summary, JSON, JUnit XML.
7
- *
8
- * - displayLocalSummary: tree-format summary with per-step timing
9
- * - formatLocalJsonResult: structured JSON output
10
- * - formatLocalJunitResult: JUnit XML for CI integration
11
- */
12
- /**
13
- * Display tree-format execution summary to the console.
14
- *
15
- * Shows per-workflow, per-job, per-step timing and status.
16
- * Matrix values appear in the job name.
17
- */
18
- function displayLocalSummary(results) {
19
- const hasFailure = results.some((r) => r.status === "failure");
20
- const allSkipped = results.every((r) => r.status === "skipped");
21
- logger.info("");
22
- logger.info(pc.bold("=== EXECUTION SUMMARY ==="));
23
- logger.info("");
24
- const overallStatus = hasFailure ? pc.red("FAILED") : allSkipped ? pc.yellow("SKIPPED") : pc.green("SUCCESS");
25
- logger.info(`Status: ${overallStatus}`);
26
- logger.info("");
27
- for (const workflow of results) {
28
- logger.info(`Workflow: ${pc.bold(workflow.name)} (${workflow.durationMs}ms)`);
29
- for (const job of workflow.jobs) {
30
- const jobLabel = formatJobLabel(job);
31
- const jobIcon = statusIcon(job.status);
32
- logger.info(` ${jobIcon} ${jobLabel} (${job.durationMs}ms)`);
33
- if (job.ruleResults && job.ruleResults.length > 0) for (const rule of job.ruleResults) {
34
- const rIcon = rule.passed ? pc.green("[ok]") : pc.red("[fail]");
35
- logger.info(pc.gray(` ${rIcon} rule: ${rule.label}`));
36
- }
37
- for (const step of job.steps) {
38
- const sIcon = step.status === "success" ? pc.green("[ok]") : pc.red("[fail]");
39
- logger.info(` ${sIcon} ${step.name} (${step.durationMs}ms)`);
40
- if (step.error) logger.info(pc.red(` Error: ${step.error.message}`));
41
- }
42
- if (job.status === "cancelled") logger.info(pc.yellow(" (cancelled)"));
43
- else if (job.status === "skipped") logger.info(pc.yellow(" (skipped: dependency failed)"));
44
- }
45
- logger.info("");
46
- }
47
- const totalDuration = results.reduce((sum, r) => sum + r.durationMs, 0);
48
- logger.info(pc.gray(`Total duration: ${totalDuration}ms`));
49
- }
50
- /**
51
- * Format job label including matrix values if present.
52
- * e.g., "test (node18, ubuntu)" or just "lint"
53
- */
54
- function formatJobLabel(job) {
55
- if (job.matrixValues && Object.keys(job.matrixValues).length > 0) {
56
- const vals = Object.values(job.matrixValues).join(", ");
57
- if (job.name.includes("(")) return job.name;
58
- return `${job.name} (${vals})`;
59
- }
60
- return job.name;
61
- }
62
- /**
63
- * Get colored status icon for a job status.
64
- */
65
- function statusIcon(status) {
66
- switch (status) {
67
- case "success": return pc.green("[ok]");
68
- case "failure": return pc.red("[fail]");
69
- case "skipped": return pc.yellow("[skip]");
70
- case "cancelled": return pc.yellow("[cancel]");
71
- default: return pc.gray("[?]");
72
- }
73
- }
74
- /**
75
- * Format workflow execution results as structured JSON.
76
- *
77
- * @returns JSON string with 2-space indentation.
78
- */
79
- function formatLocalJsonResult(results) {
80
- const passed = results.filter((r) => r.status === "success").length;
81
- const failed = results.filter((r) => r.status === "failure").length;
82
- const skipped = results.filter((r) => r.status === "skipped").length;
83
- const totalDurationMs = results.reduce((sum, r) => sum + r.durationMs, 0);
84
- const output = {
85
- workflows: results.map((wf) => ({
86
- name: wf.name,
87
- status: wf.status,
88
- durationMs: wf.durationMs,
89
- jobs: wf.jobs.map((job) => ({
90
- name: job.name,
91
- status: job.status,
92
- durationMs: job.durationMs,
93
- ...job.matrixValues && Object.keys(job.matrixValues).length > 0 && { matrixValues: job.matrixValues },
94
- steps: job.steps.map((step) => ({
95
- name: step.name,
96
- status: step.status,
97
- durationMs: step.durationMs,
98
- ...step.error && { error: step.error.message },
99
- ...step.checkOutcome && { checkOutcome: step.checkOutcome },
100
- ...step.driftSummary && { driftSummary: step.driftSummary }
101
- })),
102
- ...job.ruleResults && job.ruleResults.length > 0 && { ruleResults: job.ruleResults.map((r) => ({
103
- label: r.label,
104
- passed: r.passed,
105
- durationMs: r.durationMs
106
- })) },
107
- ...job.error && { error: job.error.message }
108
- }))
109
- })),
110
- summary: {
111
- totalWorkflows: results.length,
112
- passed,
113
- failed,
114
- skipped,
115
- totalDurationMs
116
- }
117
- };
118
- return JSON.stringify(output, null, 2);
119
- }
120
- /**
121
- * Format workflow execution results as JUnit XML.
122
- *
123
- * Each workflow maps to a <testsuite>, each job maps to a <testcase>.
124
- * Failed jobs include failure message. Skipped/cancelled jobs use <skipped />.
125
- *
126
- * @returns Valid JUnit XML string.
127
- */
128
- function formatLocalJunitResult(results) {
129
- const totalTests = results.reduce((sum, r) => sum + r.jobs.length, 0);
130
- const totalFailures = results.reduce((sum, r) => sum + r.jobs.filter((j) => j.status === "failure").length, 0);
131
- const totalTimeSeconds = results.reduce((sum, r) => sum + r.durationMs / 1e3, 0);
132
- const lines = [];
133
- lines.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
134
- lines.push(`<testsuites name="kici-local" tests="${totalTests}" failures="${totalFailures}" time="${totalTimeSeconds.toFixed(3)}">`);
135
- for (const workflow of results) {
136
- const suiteTests = workflow.jobs.length;
137
- const suiteFailures = workflow.jobs.filter((j) => j.status === "failure").length;
138
- const suiteTimeSeconds = workflow.durationMs / 1e3;
139
- lines.push(` <testsuite name="${escapeXml(workflow.name)}" tests="${suiteTests}" failures="${suiteFailures}" time="${suiteTimeSeconds.toFixed(3)}">`);
140
- for (const job of workflow.jobs) {
141
- const jobTimeSeconds = job.durationMs / 1e3;
142
- const jobName = formatJobLabel(job);
143
- if (job.status === "failure") {
144
- const errorMsg = job.error?.message ?? "Job failed";
145
- lines.push(` <testcase name="${escapeXml(jobName)}" classname="${escapeXml(workflow.name)}" time="${jobTimeSeconds.toFixed(3)}">`);
146
- lines.push(` <failure message="${escapeXml(errorMsg)}">${escapeXml(errorMsg)}</failure>`);
147
- lines.push(" </testcase>");
148
- } else if (job.status === "skipped" || job.status === "cancelled") {
149
- lines.push(` <testcase name="${escapeXml(jobName)}" classname="${escapeXml(workflow.name)}" time="${jobTimeSeconds.toFixed(3)}">`);
150
- lines.push(" <skipped />");
151
- lines.push(" </testcase>");
152
- } else lines.push(` <testcase name="${escapeXml(jobName)}" classname="${escapeXml(workflow.name)}" time="${jobTimeSeconds.toFixed(3)}" />`);
153
- }
154
- lines.push(" </testsuite>");
155
- }
156
- lines.push("</testsuites>");
157
- return lines.join("\n");
158
- }
159
- /**
160
- * Escape special XML characters in a string.
161
- */
162
- function escapeXml(text) {
163
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
164
- }
165
- //#endregion
166
- export { displayLocalSummary, formatLocalJsonResult, formatLocalJunitResult };
167
-
168
- //# sourceMappingURL=output-streamer.js.map
@@ -1,16 +0,0 @@
1
- import type { SimulatedEvent } from '@kici-dev/engine';
2
- import type { RunLocalOptions } from './types.js';
3
- /**
4
- * Generate a SimulatedEvent from git state and CLI overrides.
5
- *
6
- * For push events: detects branch, SHA, and changed files from git.
7
- * For PR events: uses current branch as source, 'main' (or --branch) as target.
8
- * If --payload flag is provided, delegates to existing buildEventPayload.
9
- * Falls back gracefully when not in a git repository.
10
- *
11
- * @param event - Event argument string (e.g. 'push', 'pr:open')
12
- * @param options - CLI options with override fields
13
- * @returns Generated SimulatedEvent
14
- */
15
- export declare function generateEventPayload(event: string, options: RunLocalOptions): Promise<SimulatedEvent>;
16
- //# sourceMappingURL=payload-generator.d.ts.map
@@ -1,138 +0,0 @@
1
- import "../rolldown-runtime-ClRpJifh.js";
2
- import { parseEventArg } from "../test-runner/event-types.js";
3
- import { buildEventPayload } from "../test-runner/payload-builder.js";
4
- import { execSync } from "node:child_process";
5
- //#region src/local-executor/payload-generator.ts
6
- const ZERO_SHA = "0000000000000000000000000000000000000000";
7
- /**
8
- * Run a git command and return trimmed output, or null on failure.
9
- */
10
- function git(cmd) {
11
- try {
12
- return execSync(cmd, {
13
- encoding: "utf-8",
14
- stdio: [
15
- "pipe",
16
- "pipe",
17
- "pipe"
18
- ]
19
- }).trim();
20
- } catch {
21
- return null;
22
- }
23
- }
24
- /**
25
- * Detect current git branch name.
26
- */
27
- function detectBranch() {
28
- return git("git rev-parse --abbrev-ref HEAD");
29
- }
30
- /**
31
- * Detect current git HEAD SHA.
32
- */
33
- function detectSha() {
34
- return git("git rev-parse HEAD");
35
- }
36
- /**
37
- * Detect changed files from git diff (unstaged + staged, deduplicated).
38
- */
39
- function detectChangedFiles() {
40
- const unstaged = git("git diff --name-only HEAD");
41
- const staged = git("git diff --name-only --cached");
42
- const files = /* @__PURE__ */ new Set();
43
- if (unstaged) for (const f of unstaged.split("\n").filter(Boolean)) files.add(f);
44
- if (staged) for (const f of staged.split("\n").filter(Boolean)) files.add(f);
45
- return [...files];
46
- }
47
- /**
48
- * Generate a SimulatedEvent from git state and CLI overrides.
49
- *
50
- * For push events: detects branch, SHA, and changed files from git.
51
- * For PR events: uses current branch as source, 'main' (or --branch) as target.
52
- * If --payload flag is provided, delegates to existing buildEventPayload.
53
- * Falls back gracefully when not in a git repository.
54
- *
55
- * @param event - Event argument string (e.g. 'push', 'pr:open')
56
- * @param options - CLI options with override fields
57
- * @returns Generated SimulatedEvent
58
- */
59
- async function generateEventPayload(event, options) {
60
- if (options.payload) return buildEventPayload(event, {
61
- payload: options.payload,
62
- branch: options.branch,
63
- sha: options.sha,
64
- files: options.files
65
- });
66
- const eventType = parseEventArg(event);
67
- const detectedBranch = detectBranch() ?? "main";
68
- const detectedSha = detectSha() ?? ZERO_SHA;
69
- const changedFiles = options.files && options.files.length > 0 ? options.files : detectChangedFiles();
70
- const branch = options.branch ?? detectedBranch;
71
- const sha = options.sha ?? detectedSha;
72
- switch (eventType.type) {
73
- case "push": return {
74
- type: "push",
75
- payload: {
76
- ref: `refs/heads/${branch}`,
77
- after: sha,
78
- before: ZERO_SHA,
79
- head_commit: {
80
- id: sha,
81
- message: "local execution"
82
- },
83
- repository: { default_branch: "main" }
84
- },
85
- targetBranch: branch,
86
- changedFiles
87
- };
88
- case "pull_request": {
89
- const action = "action" in eventType ? eventType.action : "opened";
90
- const targetBranch = options.branch ?? "main";
91
- const sourceBranch = detectedBranch;
92
- return {
93
- type: "pull_request",
94
- action,
95
- payload: {
96
- action,
97
- number: 1,
98
- pull_request: {
99
- number: 1,
100
- head: {
101
- ref: sourceBranch,
102
- sha
103
- },
104
- base: { ref: targetBranch }
105
- },
106
- repository: { default_branch: "main" }
107
- },
108
- targetBranch,
109
- sourceBranch,
110
- changedFiles
111
- };
112
- }
113
- case "tag": return {
114
- type: "tag",
115
- payload: {
116
- ref: `refs/tags/${branch}`,
117
- after: sha,
118
- repository: { default_branch: "main" }
119
- },
120
- targetBranch: branch,
121
- changedFiles
122
- };
123
- default: {
124
- const action = "action" in eventType ? eventType.action : void 0;
125
- return {
126
- type: eventType.type,
127
- action,
128
- payload: { repository: { default_branch: "main" } },
129
- targetBranch: branch,
130
- changedFiles
131
- };
132
- }
133
- }
134
- }
135
- //#endregion
136
- export { generateEventPayload };
137
-
138
- //# sourceMappingURL=payload-generator.js.map
@@ -1,33 +0,0 @@
1
- /**
2
- * Interactive workflow picker for `kici run local --pick`.
3
- *
4
- * Lists every workflow with a summary of its triggers, lets the user pick one
5
- * (and a specific trigger when there are multiple), and returns the derived
6
- * event arg plus workflow name. The caller feeds these back into the standard
7
- * executeLocal pipeline so the run remains consistent with normal trigger
8
- * matching.
9
- */
10
- import type { Workflow } from '@kici-dev/sdk';
11
- export declare class PickerCancelledError extends Error {
12
- constructor(message: string);
13
- }
14
- export interface PickerOptions {
15
- /**
16
- * Optional event-arg filter. When set, restrict the workflow list to those
17
- * with at least one trigger whose derived event arg shares the same family
18
- * (e.g. `filterEvent: 'pr'` keeps any workflow with a `pr:*` trigger).
19
- */
20
- filterEvent?: string;
21
- }
22
- export interface PickerResult {
23
- event: string;
24
- workflow: string;
25
- }
26
- /**
27
- * Run the interactive picker.
28
- *
29
- * @throws PickerCancelledError when stdin is not a TTY, when no eligible
30
- * workflows exist, or when the user aborts one of the prompts.
31
- */
32
- export declare function runPicker(workflows: Workflow[], opts?: PickerOptions): Promise<PickerResult>;
33
- //# sourceMappingURL=picker.d.ts.map
@@ -1,109 +0,0 @@
1
- import "../rolldown-runtime-ClRpJifh.js";
2
- import { transformTriggers } from "../lockfile/generator.js";
3
- import { parseEventArg, triggerSummary, triggerToEventArg } from "../test-runner/event-types.js";
4
- import pc from "picocolors";
5
- import { logger } from "@kici-dev/core";
6
- import { select } from "@inquirer/prompts";
7
- //#region src/local-executor/picker.ts
8
- /**
9
- * Interactive workflow picker for `kici run local --pick`.
10
- *
11
- * Lists every workflow with a summary of its triggers, lets the user pick one
12
- * (and a specific trigger when there are multiple), and returns the derived
13
- * event arg plus workflow name. The caller feeds these back into the standard
14
- * executeLocal pipeline so the run remains consistent with normal trigger
15
- * matching.
16
- */
17
- var PickerCancelledError = class extends Error {
18
- constructor(message) {
19
- super(message);
20
- this.name = "PickerCancelledError";
21
- }
22
- };
23
- function workflowEntries(workflows) {
24
- return workflows.map((w) => ({
25
- name: w.name,
26
- triggers: transformTriggers(w.on)
27
- }));
28
- }
29
- function eventFamily(arg) {
30
- return arg.toLowerCase().split(":")[0] ?? "";
31
- }
32
- function filterFamily(arg) {
33
- try {
34
- const parsed = parseEventArg(arg);
35
- if (parsed.type === "pull_request") return "pr";
36
- return parsed.type;
37
- } catch {
38
- return eventFamily(arg);
39
- }
40
- }
41
- function triggerFamilies(trigger) {
42
- const head = eventFamily(triggerToEventArg(trigger));
43
- if (trigger._type === "generic_webhook") return ["webhook", "generic_webhook"];
44
- if (trigger._type === "workflow_complete") return [head, "lifecycle"];
45
- if (trigger._type === "job_complete") return [head, "lifecycle"];
46
- return [head];
47
- }
48
- function isStdinTty() {
49
- return Boolean(process.stdin.isTTY);
50
- }
51
- function printWorkflowList(entries) {
52
- logger.info(pc.bold("Available workflows:"));
53
- for (const entry of entries) {
54
- const summaries = entry.triggers.map(triggerSummary).join(", ") || "(no triggers)";
55
- logger.info(` ${pc.cyan(entry.name)} — ${summaries}`);
56
- }
57
- }
58
- /**
59
- * Run the interactive picker.
60
- *
61
- * @throws PickerCancelledError when stdin is not a TTY, when no eligible
62
- * workflows exist, or when the user aborts one of the prompts.
63
- */
64
- async function runPicker(workflows, opts = {}) {
65
- let entries = workflowEntries(workflows).filter((e) => e.triggers.length > 0);
66
- if (opts.filterEvent) {
67
- const family = filterFamily(opts.filterEvent);
68
- entries = entries.filter((e) => e.triggers.some((t) => triggerFamilies(t).includes(family)));
69
- }
70
- if (entries.length === 0) throw new PickerCancelledError(opts.filterEvent ? `No workflows with triggers matching "${opts.filterEvent}". Remove the event arg or pass a different one.` : "No workflows with triggers available to pick.");
71
- if (!isStdinTty()) {
72
- printWorkflowList(entries);
73
- throw new PickerCancelledError("Non-interactive environment: --pick requires a TTY. Pass --workflow <name> plus an event arg instead.");
74
- }
75
- let chosenWorkflow;
76
- try {
77
- const name = await select({
78
- message: "Select a workflow to run",
79
- choices: entries.map((e) => ({
80
- name: `${e.name} — ${e.triggers.map(triggerSummary).join(", ")}`,
81
- value: e.name
82
- }))
83
- });
84
- chosenWorkflow = entries.find((e) => e.name === name);
85
- } catch (err) {
86
- throw new PickerCancelledError(`Picker cancelled: ${err instanceof Error ? err.message : String(err)}`);
87
- }
88
- let trigger;
89
- if (chosenWorkflow.triggers.length === 1) trigger = chosenWorkflow.triggers[0];
90
- else try {
91
- trigger = await select({
92
- message: `Select a trigger for "${chosenWorkflow.name}"`,
93
- choices: chosenWorkflow.triggers.map((t) => ({
94
- name: triggerSummary(t),
95
- value: t
96
- }))
97
- });
98
- } catch (err) {
99
- throw new PickerCancelledError(`Picker cancelled: ${err instanceof Error ? err.message : String(err)}`);
100
- }
101
- return {
102
- event: triggerToEventArg(trigger),
103
- workflow: chosenWorkflow.name
104
- };
105
- }
106
- //#endregion
107
- export { PickerCancelledError, runPicker };
108
-
109
- //# sourceMappingURL=picker.js.map
@@ -1,16 +0,0 @@
1
- import type { SimulatedEvent } from '@kici-dev/engine';
2
- import type { EventPayload } from '@kici-dev/sdk';
3
- /**
4
- * Map a {@link SimulatedEvent} into the normalized SDK {@link EventPayload}
5
- * envelope that every user-authored dynamic function (dynamic job generators,
6
- * `concurrency.group()`) receives as its `event` argument.
7
- *
8
- * `SimulatedEvent` already carries the normalized fields (`type`, `action`,
9
- * `targetBranch`, …) alongside the raw provider body under `payload`, so the
10
- * single cast at this boundary is a deliberate type assertion over a
11
- * structurally-identical value: it asserts the discriminated-union view
12
- * without reshaping anything. Raw provider fields stay nested under
13
- * `payload.<field>`; normalized fields live at the top level.
14
- */
15
- export declare function toEventPayload(event: SimulatedEvent): EventPayload;
16
- //# sourceMappingURL=to-event-payload.d.ts.map
@@ -1,21 +0,0 @@
1
- import "../rolldown-runtime-ClRpJifh.js";
2
- //#region src/local-executor/to-event-payload.ts
3
- /**
4
- * Map a {@link SimulatedEvent} into the normalized SDK {@link EventPayload}
5
- * envelope that every user-authored dynamic function (dynamic job generators,
6
- * `concurrency.group()`) receives as its `event` argument.
7
- *
8
- * `SimulatedEvent` already carries the normalized fields (`type`, `action`,
9
- * `targetBranch`, …) alongside the raw provider body under `payload`, so the
10
- * single cast at this boundary is a deliberate type assertion over a
11
- * structurally-identical value: it asserts the discriminated-union view
12
- * without reshaping anything. Raw provider fields stay nested under
13
- * `payload.<field>`; normalized fields live at the top level.
14
- */
15
- function toEventPayload(event) {
16
- return event;
17
- }
18
- //#endregion
19
- export { toEventPayload };
20
-
21
- //# sourceMappingURL=to-event-payload.js.map
@@ -1,93 +0,0 @@
1
- import type { MatrixValues, Job } from '@kici-dev/sdk';
2
- import type { CheckMode } from '@kici-dev/engine';
3
- import type { JobResult } from '../test-runner/job-executor.js';
4
- /**
5
- * All CLI flags for `kici run local`.
6
- */
7
- export interface RunLocalOptions {
8
- /** Positional arg: event type (e.g. 'push', 'pr:open'). Optional when `pick` is true. */
9
- event?: string;
10
- /** --pick / -p: interactive workflow picker (derives event arg from the selected trigger) */
11
- pick?: boolean;
12
- /** --workflow filter: run only matching workflow */
13
- workflow?: string;
14
- /** --job filter: run only matching job (includes transitive deps) */
15
- job?: string;
16
- /** --branch override: override detected git branch */
17
- branch?: string;
18
- /** --sha override: override detected git SHA */
19
- sha?: string;
20
- /** --payload path: explicit event payload JSON file */
21
- payload?: string;
22
- /** --concurrency: max parallel jobs (default: os.availableParallelism()) */
23
- concurrency?: number;
24
- /** --keep-going: continue after job failure (default: false) */
25
- keepGoing?: boolean;
26
- /** --container: use Podman isolation (default: false) */
27
- container?: boolean;
28
- /** --env KEY=VALUE overrides (repeatable) */
29
- env?: string[];
30
- /** --input KEY=VALUE typed workflow-dispatch inputs (repeatable) */
31
- inputs?: string[];
32
- /** --quiet: minimal output */
33
- quiet?: boolean;
34
- /** --json: JSON output format */
35
- json?: boolean;
36
- /** --junit: path for JUnit XML report */
37
- junit?: string;
38
- /** --files: override changed file paths (repeatable) */
39
- files?: string[];
40
- /** --debug: verbose debug output */
41
- debug?: boolean;
42
- /** --kici-dir: path to .kici directory */
43
- kiciDir?: string;
44
- /** --in-place: run against the real working directory instead of an isolated tmp checkout */
45
- inPlace?: boolean;
46
- /** --keep: always retain the isolated tmp checkout (default: keep only on failure) */
47
- keep?: boolean;
48
- /**
49
- * Run mode resolved from --check / --fail-on-drift. Threads to the agent step
50
- * loop: `apply` (default) converges, `check` previews drift, `check-fail-on-drift`
51
- * previews drift and fails the run if any step reports drift. Defaults to `apply`.
52
- */
53
- checkMode?: CheckMode;
54
- }
55
- /**
56
- * A job after matrix expansion with resolved values.
57
- */
58
- export interface ResolvedJob {
59
- /** Original job definition */
60
- job: Job;
61
- /** Expanded name (e.g. 'test (node-18, linux)') */
62
- expandedName: string;
63
- /** Matrix values for this expansion (empty object if no matrix) */
64
- matrixValues: MatrixValues;
65
- /** Resolved dependency names (expanded names of upstream jobs) */
66
- resolvedNeeds: string[];
67
- }
68
- /**
69
- * Result for a single job execution in local mode.
70
- * Extends JobResult with matrix context and cancellation.
71
- */
72
- export interface LocalJobResult extends Omit<JobResult, 'status'> {
73
- /** Job completion status (adds 'cancelled' to base JobResult statuses) */
74
- status: 'success' | 'failure' | 'skipped' | 'cancelled';
75
- /** Matrix values if this job was part of a matrix expansion */
76
- matrixValues?: MatrixValues;
77
- /** Whether this job was cancelled (e.g. by AbortSignal) */
78
- cancelled?: boolean;
79
- }
80
- /**
81
- * Result of executing a workflow locally.
82
- */
83
- export interface WorkflowExecutionResult {
84
- /** Workflow name */
85
- name: string;
86
- /** Overall status */
87
- status: 'success' | 'failure' | 'skipped';
88
- /** Individual job results */
89
- jobs: LocalJobResult[];
90
- /** Total execution duration in milliseconds */
91
- durationMs: number;
92
- }
93
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +0,0 @@
1
- import "../rolldown-runtime-ClRpJifh.js";
2
- export {};
@@ -1,82 +0,0 @@
1
- /**
2
- * Workflow-level concurrency lock for `kici run local`.
3
- *
4
- * Enforces the SDK-declared `workflow.concurrency` block across concurrent
5
- * `kici run local` invocations on the same machine and user. Mirrors the
6
- * orchestrator semantics:
7
- *
8
- * - `group` callback evaluated against the simulated event, fails closed
9
- * on throw via {@link ConcurrencyKeyEvaluationError} (the caller aborts the
10
- * run rather than fall back to the workflow name).
11
- * - `cancelInProgress: true` interrupts the holder via SIGTERM, escalates
12
- * to SIGKILL after `KICI_LOCAL_LOCK_KILL_GRACE_MS` (default 30000ms).
13
- * - Otherwise contention waits in FIFO order on the underlying file lock.
14
- * - Stale locks (holder PID gone per `process.kill(pid, 0)`) are reclaimed.
15
- *
16
- * The lock primitive is `proper-lockfile` (atomic `mkdir` of a `.lock`
17
- * directory next to the metadata sidecar). The lock identity is
18
- * `sha256(workflowName + '\0' + groupKey)`, scoped to a per-user lock dir
19
- * (`$XDG_RUNTIME_DIR/kici-local-locks/` on Linux, else
20
- * `os.tmpdir()/kici-local-locks-<uid>/`).
21
- */
22
- import type { Workflow } from '@kici-dev/sdk';
23
- import type { SimulatedEvent } from '@kici-dev/engine';
24
- /** Sidecar metadata persisted next to the lock dir for diagnostics + reclamation. */
25
- export interface LockHolderMetadata {
26
- pid: number;
27
- startedAt: string;
28
- workflowName: string;
29
- groupKey: string;
30
- hostname: string;
31
- }
32
- /** Handle returned by {@link acquireWorkflowLock}. Caller MUST invoke `release()` in a `finally`. */
33
- export interface WorkflowLockHandle {
34
- release(): Promise<void>;
35
- }
36
- export interface AcquireWorkflowLockOptions {
37
- workflowName: string;
38
- workflow: Workflow;
39
- /** The simulated event mapped to the normalized envelope passed as `groupCtx.event`. */
40
- event: SimulatedEvent;
41
- /** Branch derived from the simulated event for `groupCtx.branch`. */
42
- branch: string;
43
- debug?: boolean;
44
- }
45
- /**
46
- * Thrown when the workflow's `concurrency.group()` function throws or rejects.
47
- * The caller surfaces this as a workflow failure (it does NOT fall back to the
48
- * workflow name as a key — fail-closed is the documented contract).
49
- */
50
- export declare class ConcurrencyKeyEvaluationError extends Error {
51
- readonly cause?: Error;
52
- readonly workflowName: string;
53
- constructor(workflowName: string, cause: unknown);
54
- }
55
- /** Module-level stub for `process.kill`, swappable by tests via {@link __setKillFnForTesting}. */
56
- type KillFn = (pid: number, signal?: string | number) => boolean;
57
- /** Test-only: swap the kill function so unit tests don't actually signal real PIDs. */
58
- export declare function __setKillFnForTesting(fn?: KillFn): void;
59
- /**
60
- * Resolve the per-user lock directory. Prefers `$XDG_RUNTIME_DIR/kici-local-locks/`
61
- * (Linux per-user runtime dir, mode 0700), else `os.tmpdir()/kici-local-locks-<uid>/`.
62
- *
63
- * Created with `mode: 0o700`. Falls through silently to the tmpdir form on EACCES/EROFS.
64
- */
65
- export declare function resolveLockDir(): Promise<string>;
66
- /**
67
- * Evaluate the workflow's concurrency `group` function against the simulated event.
68
- *
69
- * Returns `null` when the workflow has no `concurrency` block. Throws
70
- * {@link ConcurrencyKeyEvaluationError} when the group function throws or rejects.
71
- */
72
- export declare function resolveConcurrencyKey(workflow: Workflow, event: SimulatedEvent, branch: string): Promise<string | null>;
73
- /**
74
- * Acquire the workflow-level concurrency lock for a `kici run local` invocation.
75
- *
76
- * Returns `null` immediately when the workflow has no `concurrency` block (no
77
- * locking is performed). Otherwise blocks until the lock is held, then returns
78
- * a handle whose `release()` MUST be invoked in a `finally`.
79
- */
80
- export declare function acquireWorkflowLock(opts: AcquireWorkflowLockOptions): Promise<WorkflowLockHandle | null>;
81
- export {};
82
- //# sourceMappingURL=workflow-lock.d.ts.map