@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.
Files changed (221) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1 -6
  3. package/dist/assets/api-TJJVHrjC.json +118 -0
  4. package/dist/assets/descriptor-BTtjzN9L.json +1382 -0
  5. package/dist/assets/package-BpQF9kR8.json +74 -0
  6. package/dist/assets/package-Ceo2h27X.json +89 -0
  7. package/dist/assets/source_context-D0atuL28.json +20 -0
  8. package/dist/assets/type-BFqO8SCZ.json +202 -0
  9. package/dist/auth/headless-detect.d.ts +14 -0
  10. package/dist/auth/headless-detect.js +25 -0
  11. package/dist/chunk-gOLHoazu.js +4 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.js +193 -0
  14. package/dist/commands/cancel.d.ts +22 -0
  15. package/dist/commands/cancel.js +124 -0
  16. package/dist/commands/compile.d.ts +17 -0
  17. package/dist/commands/compile.js +99 -0
  18. package/dist/commands/docs.d.ts +26 -0
  19. package/dist/commands/docs.js +60 -0
  20. package/dist/commands/drain-worker.d.ts +19 -0
  21. package/dist/commands/drain-worker.js +45 -0
  22. package/dist/commands/endpoints.d.ts +53 -0
  23. package/dist/commands/endpoints.js +185 -0
  24. package/dist/commands/fixture.d.ts +14 -0
  25. package/dist/commands/fixture.js +104 -0
  26. package/dist/commands/hook.d.ts +20 -0
  27. package/dist/commands/hook.js +97 -0
  28. package/dist/commands/index.d.ts +33 -0
  29. package/dist/commands/index.js +20 -0
  30. package/dist/commands/init.d.ts +35 -0
  31. package/dist/commands/init.js +393 -0
  32. package/dist/commands/login.d.ts +23 -0
  33. package/dist/commands/login.js +144 -0
  34. package/dist/commands/logout.d.ts +18 -0
  35. package/dist/commands/logout.js +55 -0
  36. package/dist/commands/org.d.ts +27 -0
  37. package/dist/commands/org.js +126 -0
  38. package/dist/commands/run.d.ts +21 -0
  39. package/dist/commands/run.js +562 -0
  40. package/dist/commands/secrets-list.d.ts +16 -0
  41. package/dist/commands/secrets-list.js +85 -0
  42. package/dist/commands/status.d.ts +30 -0
  43. package/dist/commands/status.js +210 -0
  44. package/dist/commands/test.d.ts +61 -0
  45. package/dist/commands/test.js +220 -0
  46. package/dist/commands/types.d.ts +18 -0
  47. package/dist/commands/types.js +74 -0
  48. package/dist/commands/watch.d.ts +14 -0
  49. package/dist/commands/watch.js +97 -0
  50. package/dist/commands/workflows.d.ts +28 -0
  51. package/dist/commands/workflows.js +154 -0
  52. package/dist/comment-created.json +30 -0
  53. package/dist/create-branch.json +17 -0
  54. package/dist/delete-branch.json +15 -0
  55. package/dist/dispatch.json +15 -0
  56. package/dist/errors/capability-gap.d.ts +50 -0
  57. package/dist/errors/capability-gap.js +54 -0
  58. package/dist/errors/codes.d.ts +25 -0
  59. package/dist/errors/formatter.d.ts +32 -0
  60. package/dist/errors/formatter.js +35 -0
  61. package/dist/errors/index.d.ts +5 -0
  62. package/dist/errors/index.js +4 -0
  63. package/dist/execution/executor.d.ts +61 -0
  64. package/dist/execution/executor.js +230 -0
  65. package/dist/execution/index.d.ts +4 -0
  66. package/dist/execution/index.js +3 -0
  67. package/dist/execution/sdk-alias.d.ts +33 -0
  68. package/dist/execution/sdk-alias.js +102 -0
  69. package/dist/fixtures/compiler.d.ts +47 -0
  70. package/dist/fixtures/compiler.js +177 -0
  71. package/dist/fixtures/defaults/comment-created.json +30 -0
  72. package/dist/fixtures/defaults/create-branch.json +17 -0
  73. package/dist/fixtures/defaults/delete-branch.json +15 -0
  74. package/dist/fixtures/defaults/dispatch.json +15 -0
  75. package/dist/fixtures/defaults/fork.json +19 -0
  76. package/dist/fixtures/defaults/index.d.ts +16 -0
  77. package/dist/fixtures/defaults/index.js +105 -0
  78. package/dist/fixtures/defaults/index.ts +145 -0
  79. package/dist/fixtures/defaults/pr-closed.json +28 -0
  80. package/dist/fixtures/defaults/pr-opened.json +27 -0
  81. package/dist/fixtures/defaults/pr-reopened.json +27 -0
  82. package/dist/fixtures/defaults/pr-synchronize.json +27 -0
  83. package/dist/fixtures/defaults/push.json +16 -0
  84. package/dist/fixtures/defaults/release-published.json +23 -0
  85. package/dist/fixtures/defaults/review-comment-created.json +36 -0
  86. package/dist/fixtures/defaults/review-submitted.json +35 -0
  87. package/dist/fixtures/defaults/star-created.json +15 -0
  88. package/dist/fixtures/defaults/status.json +26 -0
  89. package/dist/fixtures/defaults/tag-push.json +20 -0
  90. package/dist/fixtures/defaults/watch-started.json +15 -0
  91. package/dist/fixtures/defaults/workflow-run-completed.json +23 -0
  92. package/dist/fork.json +19 -0
  93. package/dist/format.d.ts +5 -0
  94. package/dist/format.js +20 -0
  95. package/dist/generators/secrets-dts.d.ts +29 -0
  96. package/dist/generators/secrets-dts.js +67 -0
  97. package/dist/hooks/detector.d.ts +39 -0
  98. package/dist/hooks/detector.js +133 -0
  99. package/dist/hooks/index.d.ts +6 -0
  100. package/dist/hooks/index.js +5 -0
  101. package/dist/hooks/installer.d.ts +24 -0
  102. package/dist/hooks/installer.js +328 -0
  103. package/dist/hooks/templates.d.ts +26 -0
  104. package/dist/hooks/templates.js +63 -0
  105. package/dist/index.d.ts +12 -0
  106. package/dist/index.js +12 -0
  107. package/dist/llm-context/llms-full.txt +9974 -0
  108. package/dist/llm-context/llms.txt +61 -0
  109. package/dist/local-executor/dag-scheduler.d.ts +44 -0
  110. package/dist/local-executor/dag-scheduler.js +183 -0
  111. package/dist/local-executor/index.d.ts +23 -0
  112. package/dist/local-executor/index.js +309 -0
  113. package/dist/local-executor/job-runner.d.ts +40 -0
  114. package/dist/local-executor/job-runner.js +307 -0
  115. package/dist/local-executor/output-streamer.d.ts +31 -0
  116. package/dist/local-executor/output-streamer.js +166 -0
  117. package/dist/local-executor/payload-generator.d.ts +16 -0
  118. package/dist/local-executor/payload-generator.js +138 -0
  119. package/dist/local-executor/picker.d.ts +33 -0
  120. package/dist/local-executor/picker.js +109 -0
  121. package/dist/local-executor/secret-loader.d.ts +18 -0
  122. package/dist/local-executor/secret-loader.js +105 -0
  123. package/dist/local-executor/types.d.ts +80 -0
  124. package/dist/local-executor/types.js +2 -0
  125. package/dist/local-executor/workflow-lock.d.ts +81 -0
  126. package/dist/local-executor/workflow-lock.js +0 -0
  127. package/dist/lockfile/generator.d.ts +39 -0
  128. package/dist/lockfile/generator.js +688 -0
  129. package/dist/lockfile/hash-files.d.ts +14 -0
  130. package/dist/lockfile/hash-files.js +50 -0
  131. package/dist/lockfile/hasher.d.ts +36 -0
  132. package/dist/lockfile/hasher.js +46 -0
  133. package/dist/lockfile/index.d.ts +3 -0
  134. package/dist/lockfile/index.js +4 -0
  135. package/dist/lockfile/purity-analyzer.d.ts +25 -0
  136. package/dist/lockfile/purity-analyzer.js +204 -0
  137. package/dist/package-F7UXSDHW.json +74 -0
  138. package/dist/postinstall.d.ts +9 -0
  139. package/dist/postinstall.js +60 -0
  140. package/dist/pr-closed.json +28 -0
  141. package/dist/pr-opened.json +27 -0
  142. package/dist/pr-reopened.json +27 -0
  143. package/dist/pr-synchronize.json +27 -0
  144. package/dist/push.json +16 -0
  145. package/dist/release-published.json +23 -0
  146. package/dist/remote/client.d.ts +204 -0
  147. package/dist/remote/client.js +203 -0
  148. package/dist/remote/config.d.ts +54 -0
  149. package/dist/remote/config.js +92 -0
  150. package/dist/remote/encryption.d.ts +35 -0
  151. package/dist/remote/encryption.js +87 -0
  152. package/dist/remote/history.d.ts +91 -0
  153. package/dist/remote/history.js +146 -0
  154. package/dist/remote/oauth.d.ts +65 -0
  155. package/dist/remote/oauth.js +302 -0
  156. package/dist/remote/observer.d.ts +81 -0
  157. package/dist/remote/observer.js +174 -0
  158. package/dist/remote/output/json.d.ts +13 -0
  159. package/dist/remote/output/json.js +36 -0
  160. package/dist/remote/output/junit.d.ts +18 -0
  161. package/dist/remote/output/junit.js +50 -0
  162. package/dist/remote/output/streaming.d.ts +57 -0
  163. package/dist/remote/output/streaming.js +124 -0
  164. package/dist/remote/output/summary.d.ts +39 -0
  165. package/dist/remote/output/summary.js +99 -0
  166. package/dist/remote/uploader.d.ts +87 -0
  167. package/dist/remote/uploader.js +197 -0
  168. package/dist/review-comment-created.json +36 -0
  169. package/dist/review-submitted.json +35 -0
  170. package/dist/star-created.json +15 -0
  171. package/dist/status.json +26 -0
  172. package/dist/tag-push.json +20 -0
  173. package/dist/templates/agents-md.d.ts +8 -0
  174. package/dist/templates/agents-md.js +130 -0
  175. package/dist/templates/index.d.ts +43 -0
  176. package/dist/templates/index.js +48 -0
  177. package/dist/templates/package-json.d.ts +18 -0
  178. package/dist/templates/package-json.js +34 -0
  179. package/dist/templates/tsconfig-json.d.ts +9 -0
  180. package/dist/templates/tsconfig-json.js +26 -0
  181. package/dist/templates/workflows/hello-world.d.ts +2 -0
  182. package/dist/templates/workflows/hello-world.js +16 -0
  183. package/dist/templates/workflows/hello-world.ts +21 -0
  184. package/dist/templates/workflows/pr-checks.d.ts +2 -0
  185. package/dist/templates/workflows/pr-checks.js +40 -0
  186. package/dist/templates/workflows/pr-checks.ts +57 -0
  187. package/dist/test-runner/dry-run.d.ts +12 -0
  188. package/dist/test-runner/dry-run.js +66 -0
  189. package/dist/test-runner/event-types.d.ts +86 -0
  190. package/dist/test-runner/event-types.js +330 -0
  191. package/dist/test-runner/git-detector.d.ts +15 -0
  192. package/dist/test-runner/git-detector.js +30 -0
  193. package/dist/test-runner/index.d.ts +13 -0
  194. package/dist/test-runner/index.js +11 -0
  195. package/dist/test-runner/job-executor.d.ts +48 -0
  196. package/dist/test-runner/job-executor.js +245 -0
  197. package/dist/test-runner/output-formatter.d.ts +47 -0
  198. package/dist/test-runner/output-formatter.js +92 -0
  199. package/dist/test-runner/payload-builder.d.ts +20 -0
  200. package/dist/test-runner/payload-builder.js +216 -0
  201. package/dist/test-runner/rule-evaluator.d.ts +14 -0
  202. package/dist/test-runner/rule-evaluator.js +31 -0
  203. package/dist/test-runner/secrets-file.d.ts +24 -0
  204. package/dist/test-runner/secrets-file.js +62 -0
  205. package/dist/test-runner/step-context.d.ts +15 -0
  206. package/dist/test-runner/step-context.js +140 -0
  207. package/dist/test-runner/summary.d.ts +7 -0
  208. package/dist/types.d.ts +525 -0
  209. package/dist/types.js +33 -0
  210. package/dist/validation/index.d.ts +3 -0
  211. package/dist/validation/index.js +3 -0
  212. package/dist/validation/validator.d.ts +26 -0
  213. package/dist/validation/validator.js +164 -0
  214. package/dist/watch-started.json +15 -0
  215. package/dist/workflow-run-completed.json +23 -0
  216. package/dist/workflows/hello-world.ts +21 -0
  217. package/dist/workflows/pr-checks.ts +57 -0
  218. package/hack/postinstall.mjs +105 -0
  219. package/package.json +60 -6
  220. package/sbom.spdx.json +10997 -0
  221. package/index.js +0 -3
@@ -0,0 +1,28 @@
1
+ /**
2
+ * kici workflows list command
3
+ *
4
+ * Lists permanently registered workflows by querying the Platform API.
5
+ * Supports table output (default), JSON output, and stale filtering.
6
+ */
7
+ /** Options for the workflows list command. */
8
+ export interface WorkflowsListOptions {
9
+ /** Output as JSON */
10
+ json?: boolean;
11
+ /** Filter stale registrations (e.g., "30d", "7d", "24h") */
12
+ stale?: string;
13
+ /** Filter by trigger type */
14
+ triggerType?: string;
15
+ /** Filter by repository */
16
+ repo?: string;
17
+ }
18
+ /**
19
+ * List permanently registered workflows.
20
+ *
21
+ * Queries the Platform API for registrations, optionally filtering by trigger type,
22
+ * repository, or staleness. Displays results as a table or JSON.
23
+ *
24
+ * @param options - Command options
25
+ * @returns true on success, false on error
26
+ */
27
+ export declare function workflowsListCommand(options?: WorkflowsListOptions): Promise<boolean>;
28
+ //# sourceMappingURL=workflows.d.ts.map
@@ -0,0 +1,154 @@
1
+ import "../chunk-gOLHoazu.js";
2
+ import { loadGlobalConfig } from "../remote/config.js";
3
+ import { AuthenticationError, ConnectionError, OrchestratorClient, ServerError } from "../remote/client.js";
4
+ import { formatRelativeTime } from "../format.js";
5
+ import pc from "picocolors";
6
+ import { toErrorMessage } from "@kici-dev/shared";
7
+ //#region src/commands/workflows.ts
8
+ /**
9
+ * kici workflows list command
10
+ *
11
+ * Lists permanently registered workflows by querying the Platform API.
12
+ * Supports table output (default), JSON output, and stale filtering.
13
+ */
14
+ /**
15
+ * Parse a duration string like "30d", "7d", "24h", "2h" into milliseconds.
16
+ * Returns null if the string is not a valid duration.
17
+ */
18
+ function parseDuration(duration) {
19
+ const match = duration.match(/^(\d+)(d|h|m)$/);
20
+ if (!match) return null;
21
+ const value = parseInt(match[1], 10);
22
+ switch (match[2]) {
23
+ case "d": return value * 24 * 60 * 60 * 1e3;
24
+ case "h": return value * 60 * 60 * 1e3;
25
+ case "m": return value * 60 * 1e3;
26
+ default: return null;
27
+ }
28
+ }
29
+ /**
30
+ * List permanently registered workflows.
31
+ *
32
+ * Queries the Platform API for registrations, optionally filtering by trigger type,
33
+ * repository, or staleness. Displays results as a table or JSON.
34
+ *
35
+ * @param options - Command options
36
+ * @returns true on success, false on error
37
+ */
38
+ async function workflowsListCommand(options = {}) {
39
+ try {
40
+ const config = await loadGlobalConfig();
41
+ const token = config.pat ?? config.token;
42
+ if (!token) {
43
+ console.error(pc.red("Not authenticated. Run `kici login` to authenticate."));
44
+ return false;
45
+ }
46
+ const endpoint = config.platformEndpoint ?? config.endpoint;
47
+ if (!endpoint) {
48
+ console.error(pc.red("No endpoint configured. Run `kici login` to configure."));
49
+ return false;
50
+ }
51
+ const orgId = config.activeOrgId;
52
+ if (!orgId) {
53
+ console.error(pc.red("No organization selected. Run `kici org use <name>` to select one."));
54
+ return false;
55
+ }
56
+ const client = new OrchestratorClient({
57
+ endpoint,
58
+ token
59
+ });
60
+ const filters = {};
61
+ if (options.triggerType) filters.triggerType = options.triggerType;
62
+ if (options.repo) filters.repoIdentifier = options.repo;
63
+ let data;
64
+ try {
65
+ data = await client.getRegistrations(orgId, filters);
66
+ } catch (error) {
67
+ if (error instanceof AuthenticationError) {
68
+ console.error(pc.red("Authentication failed. Run `kici login` to re-authenticate."));
69
+ return false;
70
+ }
71
+ if (error instanceof ServerError && error.statusCode === 503) {
72
+ console.error(pc.red("No orchestrator connected. Ensure your orchestrator is running and connected."));
73
+ return false;
74
+ }
75
+ if (error instanceof ConnectionError) {
76
+ console.error(pc.red(`Connection failed: ${error.message}`));
77
+ return false;
78
+ }
79
+ throw error;
80
+ }
81
+ let registrations = data.registrations;
82
+ if (options.stale) {
83
+ const staleMs = parseDuration(options.stale);
84
+ if (staleMs === null) {
85
+ console.error(pc.red(`Invalid duration format: "${options.stale}". Use e.g., 30d, 7d, 24h`));
86
+ return false;
87
+ }
88
+ const now = Date.now();
89
+ registrations = registrations.filter((r) => {
90
+ if (r.lastTriggeredAt === null) return true;
91
+ return now - new Date(r.lastTriggeredAt).getTime() > staleMs;
92
+ });
93
+ }
94
+ if (options.json) {
95
+ console.log(JSON.stringify(registrations, null, 2));
96
+ return true;
97
+ }
98
+ if (registrations.length === 0) {
99
+ console.log(pc.yellow("No registered workflows found."));
100
+ return true;
101
+ }
102
+ const termWidth = process.stdout.columns || 100;
103
+ const headers = [
104
+ "WORKFLOW",
105
+ "REPO",
106
+ "TRIGGERS",
107
+ "LAST TRIGGERED"
108
+ ];
109
+ const rows = registrations.map((r) => [
110
+ r.workflowName,
111
+ r.repoIdentifier,
112
+ r.triggerTypes.join(", "),
113
+ r.lastTriggeredAt ? formatRelativeTime(r.lastTriggeredAt) : "Never"
114
+ ]);
115
+ const colWidths = headers.map((h, i) => {
116
+ const maxData = Math.max(...rows.map((r) => r[i].length));
117
+ return Math.max(h.length, maxData);
118
+ });
119
+ const totalGaps = (headers.length - 1) * 3;
120
+ const totalWidth = colWidths.reduce((a, b) => a + b, 0) + totalGaps;
121
+ if (totalWidth > termWidth) {
122
+ let excess = totalWidth - termWidth;
123
+ while (excess > 0) {
124
+ const maxIdx = colWidths.indexOf(Math.max(...colWidths));
125
+ const reduction = Math.min(excess, Math.max(0, colWidths[maxIdx] - headers[maxIdx].length));
126
+ if (reduction === 0) break;
127
+ colWidths[maxIdx] -= reduction;
128
+ excess -= reduction;
129
+ }
130
+ }
131
+ const headerLine = headers.map((h, i) => h.padEnd(colWidths[i])).join(" ");
132
+ console.log(pc.bold(headerLine));
133
+ for (const row of rows) {
134
+ const cells = row.map((cell, i) => {
135
+ const maxW = colWidths[i];
136
+ const padded = (cell.length > maxW ? cell.slice(0, maxW - 1) + "…" : cell).padEnd(maxW);
137
+ if (cell === "Never") return pc.dim(padded);
138
+ return padded;
139
+ });
140
+ console.log(cells.join(" "));
141
+ }
142
+ console.log("");
143
+ console.log(pc.gray(`Registry v${data.registryVersion}, last updated ${formatRelativeTime(data.registryUpdatedAt)}`));
144
+ return true;
145
+ } catch (err) {
146
+ const message = toErrorMessage(err);
147
+ console.error(pc.red(`Failed to list workflows: ${message}`));
148
+ return false;
149
+ }
150
+ }
151
+ //#endregion
152
+ export { workflowsListCommand };
153
+
154
+ //# sourceMappingURL=workflows.js.map
@@ -0,0 +1,30 @@
1
+ {
2
+ "action": "created",
3
+ "comment": {
4
+ "id": 1,
5
+ "body": "Looks good to me!",
6
+ "user": {
7
+ "login": "test-user"
8
+ },
9
+ "created_at": "2026-01-01T00:00:00Z"
10
+ },
11
+ "issue": {
12
+ "number": 42,
13
+ "title": "Test issue",
14
+ "state": "open",
15
+ "pull_request": {
16
+ "url": "https://api.github.com/repos/test-org/test-repo/pulls/42"
17
+ }
18
+ },
19
+ "repository": {
20
+ "name": "test-repo",
21
+ "full_name": "test-org/test-repo",
22
+ "owner": {
23
+ "login": "test-org"
24
+ },
25
+ "default_branch": "main"
26
+ },
27
+ "sender": {
28
+ "login": "test-user"
29
+ }
30
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "ref": "feature/new",
3
+ "ref_type": "branch",
4
+ "master_branch": "main",
5
+ "description": null,
6
+ "repository": {
7
+ "name": "test-repo",
8
+ "full_name": "test-org/test-repo",
9
+ "owner": {
10
+ "login": "test-org"
11
+ },
12
+ "default_branch": "main"
13
+ },
14
+ "sender": {
15
+ "login": "test-user"
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "ref": "feature/old",
3
+ "ref_type": "branch",
4
+ "repository": {
5
+ "name": "test-repo",
6
+ "full_name": "test-org/test-repo",
7
+ "owner": {
8
+ "login": "test-org"
9
+ },
10
+ "default_branch": "main"
11
+ },
12
+ "sender": {
13
+ "login": "test-user"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "action": "deploy",
3
+ "client_payload": {},
4
+ "repository": {
5
+ "name": "test-repo",
6
+ "full_name": "test-org/test-repo",
7
+ "owner": {
8
+ "login": "test-org"
9
+ },
10
+ "default_branch": "main"
11
+ },
12
+ "sender": {
13
+ "login": "test-user"
14
+ }
15
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Actionable error format for CLI-side capability gaps.
3
+ *
4
+ * When the CLI calls an orchestrator feature the orchestrator doesn't support
5
+ * (e.g. `kici status --logs` against an older orchestrator that lacks the
6
+ * `/runs/:runId/logs` endpoint), it should tell the operator:
7
+ * - which feature is missing,
8
+ * - the CLI's own version,
9
+ * - the orchestrator's advertised version (fetched from `/capabilities`,
10
+ * `undefined` if that fetch failed),
11
+ * - and how to resolve it.
12
+ *
13
+ * Every capability-gap error in the CLI flows through `formatCapabilityGapError`
14
+ * so the format stays consistent. Call sites either throw `CapabilityGapError`
15
+ * (caught at the command boundary and printed) or call the formatter directly.
16
+ */
17
+ export interface CapabilityGapInfo {
18
+ /** Short feature name, e.g. `log-streaming`. Shown verbatim in the error. */
19
+ feature: string;
20
+ /** CLI package version (from `KICI_VERSION` build constant). */
21
+ cliVersion: string;
22
+ /**
23
+ * Orchestrator's advertised version from `GET /api/v1/capabilities`.
24
+ * `undefined` when the capabilities probe itself failed (old orchestrator,
25
+ * network error, etc.) — the formatter prints `unknown` and notes the cause.
26
+ */
27
+ orchestratorVersion?: string;
28
+ /**
29
+ * Optional override for the trailing guidance paragraph. Default guidance
30
+ * tells the operator to upgrade the orchestrator and how to confirm its
31
+ * current version.
32
+ */
33
+ guidance?: string;
34
+ }
35
+ /**
36
+ * Error thrown by CLI code when a capability gap is detected. Command-level
37
+ * catchers format the attached `info` via `formatCapabilityGapError`.
38
+ */
39
+ export declare class CapabilityGapError extends Error {
40
+ readonly info: CapabilityGapInfo;
41
+ constructor(info: CapabilityGapInfo);
42
+ }
43
+ /**
44
+ * Produce the user-facing multi-line error string for a capability gap.
45
+ *
46
+ * The shape is stable (tests snapshot it). Colours come from picocolors and
47
+ * degrade gracefully in non-TTY output.
48
+ */
49
+ export declare function formatCapabilityGapError(info: CapabilityGapInfo): string;
50
+ //# sourceMappingURL=capability-gap.d.ts.map
@@ -0,0 +1,54 @@
1
+ import "../chunk-gOLHoazu.js";
2
+ import pc from "picocolors";
3
+ //#region src/errors/capability-gap.ts
4
+ /**
5
+ * Actionable error format for CLI-side capability gaps.
6
+ *
7
+ * When the CLI calls an orchestrator feature the orchestrator doesn't support
8
+ * (e.g. `kici status --logs` against an older orchestrator that lacks the
9
+ * `/runs/:runId/logs` endpoint), it should tell the operator:
10
+ * - which feature is missing,
11
+ * - the CLI's own version,
12
+ * - the orchestrator's advertised version (fetched from `/capabilities`,
13
+ * `undefined` if that fetch failed),
14
+ * - and how to resolve it.
15
+ *
16
+ * Every capability-gap error in the CLI flows through `formatCapabilityGapError`
17
+ * so the format stays consistent. Call sites either throw `CapabilityGapError`
18
+ * (caught at the command boundary and printed) or call the formatter directly.
19
+ */
20
+ const DEFAULT_GUIDANCE = "Upgrade the orchestrator to the latest KiCI release to enable this feature.\nRun `kici-admin version` on the orchestrator host to confirm the current version.";
21
+ /**
22
+ * Error thrown by CLI code when a capability gap is detected. Command-level
23
+ * catchers format the attached `info` via `formatCapabilityGapError`.
24
+ */
25
+ var CapabilityGapError = class extends Error {
26
+ info;
27
+ constructor(info) {
28
+ super(`Feature not supported: ${info.feature}`);
29
+ this.name = "CapabilityGapError";
30
+ this.info = info;
31
+ }
32
+ };
33
+ /**
34
+ * Produce the user-facing multi-line error string for a capability gap.
35
+ *
36
+ * The shape is stable (tests snapshot it). Colours come from picocolors and
37
+ * degrade gracefully in non-TTY output.
38
+ */
39
+ function formatCapabilityGapError(info) {
40
+ const orchLine = info.orchestratorVersion ? info.orchestratorVersion : "unknown (capabilities endpoint unreachable)";
41
+ const guidance = info.guidance ?? DEFAULT_GUIDANCE;
42
+ return [
43
+ pc.red(pc.bold(`Feature not supported by the orchestrator: ${info.feature}`)),
44
+ "",
45
+ ` CLI version: ${info.cliVersion}`,
46
+ ` Orchestrator version: ${orchLine}`,
47
+ "",
48
+ ...guidance.split("\n").map((line) => ` ${pc.dim(line)}`)
49
+ ].join("\n");
50
+ }
51
+ //#endregion
52
+ export { CapabilityGapError, formatCapabilityGapError };
53
+
54
+ //# sourceMappingURL=capability-gap.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Compiler error codes.
3
+ * Format: EXXX where X is a digit.
4
+ *
5
+ * E0XX - Configuration errors (file not found, invalid TypeScript)
6
+ * E1XX - Validation errors (DAG cycles, missing deps, matrix limits)
7
+ * E2XX - Lock file errors (serialization issues)
8
+ */
9
+ export declare const ErrorCodes: {
10
+ readonly E001: "Config file not found";
11
+ readonly E002: "Failed to compile TypeScript";
12
+ readonly E003: "Failed to load config module";
13
+ readonly E004: "Config does not export workflows";
14
+ readonly E101: "Job depends on non-existent job";
15
+ readonly E102: "Circular dependency detected";
16
+ readonly E103: "Job depends on itself";
17
+ readonly E104: "Static matrix exceeds 256 job limit";
18
+ readonly E105: "Invalid trigger configuration";
19
+ readonly E106: "Duplicate job name";
20
+ readonly E107: "Duplicate workflow name";
21
+ readonly E201: "Failed to write lock file";
22
+ readonly E202: "Failed to serialize workflow";
23
+ };
24
+ export type ErrorCode = keyof typeof ErrorCodes;
25
+ //# sourceMappingURL=codes.d.ts.map
@@ -0,0 +1,32 @@
1
+ /** Error code string (e.g., 'E001', 'E102'). */
2
+ type ErrorCode = string;
3
+ /** Source location for error reporting */
4
+ export interface SourceLocation {
5
+ readonly file: string;
6
+ readonly line: number;
7
+ readonly column: number;
8
+ }
9
+ /** Compiler error with all context */
10
+ export interface CompilerError {
11
+ readonly code: ErrorCode;
12
+ readonly message: string;
13
+ readonly location?: SourceLocation;
14
+ readonly suggestion?: string;
15
+ }
16
+ /**
17
+ * Format error in GNU standard format: file:line:column: error [CODE]: message
18
+ *
19
+ * Example output:
20
+ * .kici/workflows/ci.ts:15:3 error [E102]: Circular dependency detected
21
+ * Suggestion: Remove dependency 'build' -> 'test' -> 'build'
22
+ */
23
+ export declare function formatError(error: CompilerError): string;
24
+ /** Create a CompilerError and throw it */
25
+ export declare function compilerError(code: ErrorCode, message: string, options?: {
26
+ location?: SourceLocation;
27
+ suggestion?: string;
28
+ }): CompilerError;
29
+ /** Check if an error is a CompilerError (codes are E + digits, e.g. E001, E102) */
30
+ export declare function isCompilerError(error: unknown): error is CompilerError;
31
+ export {};
32
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1,35 @@
1
+ import "../chunk-gOLHoazu.js";
2
+ import pc from "picocolors";
3
+ //#region src/errors/formatter.ts
4
+ /**
5
+ * Format error in GNU standard format: file:line:column: error [CODE]: message
6
+ *
7
+ * Example output:
8
+ * .kici/workflows/ci.ts:15:3 error [E102]: Circular dependency detected
9
+ * Suggestion: Remove dependency 'build' -> 'test' -> 'build'
10
+ */
11
+ function formatError(error) {
12
+ const parts = [];
13
+ if (error.location) parts.push(pc.cyan(`${error.location.file}:${error.location.line}:${error.location.column}`));
14
+ parts.push(pc.red("error") + pc.gray(` [${error.code}]`) + ": " + error.message);
15
+ let output = parts.join(" ");
16
+ if (error.suggestion) output += "\n " + pc.dim(`Suggestion: ${error.suggestion}`);
17
+ return output;
18
+ }
19
+ /** Create a CompilerError and throw it */
20
+ function compilerError(code, message, options) {
21
+ return {
22
+ code,
23
+ message,
24
+ location: options?.location,
25
+ suggestion: options?.suggestion
26
+ };
27
+ }
28
+ /** Check if an error is a CompilerError (codes are E + digits, e.g. E001, E102) */
29
+ function isCompilerError(error) {
30
+ return typeof error === "object" && error !== null && "code" in error && "message" in error && typeof error.code === "string" && /^E\d+$/.test(error.code);
31
+ }
32
+ //#endregion
33
+ export { compilerError, formatError, isCompilerError };
34
+
35
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1,5 @@
1
+ export { formatError, compilerError, isCompilerError } from './formatter.js';
2
+ export type { SourceLocation, CompilerError } from './formatter.js';
3
+ export { CapabilityGapError, formatCapabilityGapError } from './capability-gap.js';
4
+ export type { CapabilityGapInfo } from './capability-gap.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import "../chunk-gOLHoazu.js";
2
+ import { compilerError, formatError, isCompilerError } from "./formatter.js";
3
+ import { CapabilityGapError, formatCapabilityGapError } from "./capability-gap.js";
4
+ export { CapabilityGapError, compilerError, formatCapabilityGapError, formatError, isCompilerError };
@@ -0,0 +1,61 @@
1
+ import type { WorkflowWithSource } from '../types.js';
2
+ /** Result of executing a config file */
3
+ export interface ExecutionResult {
4
+ /** Workflows exported from the config with source tracking */
5
+ workflows: WorkflowWithSource[];
6
+ /** Absolute path to the original config file */
7
+ configPath: string;
8
+ }
9
+ /** Result of discovering workflows from .kici/workflows/ directory */
10
+ export interface DiscoveryResult {
11
+ /** All workflows discovered from .kici/workflows/ with source tracking */
12
+ workflows: WorkflowWithSource[];
13
+ /** Absolute path to .kici/workflows/ directory */
14
+ workflowDir: string;
15
+ /** Absolute path to .kici/ directory */
16
+ kiciDir: string;
17
+ }
18
+ /**
19
+ * Execute a TypeScript config file and extract workflow definitions.
20
+ *
21
+ * Process:
22
+ * 1. Read TypeScript source from disk
23
+ * 2. Transform to ESM JavaScript via rolldown (in-memory)
24
+ * 3. Write temp file for Node.js dynamic import (required by ESM spec)
25
+ * 4. Dynamic import the compiled module
26
+ * 5. Extract and return workflow definitions
27
+ * 6. Clean up temp file
28
+ *
29
+ * @param configPath - Path to workflow file (relative or absolute)
30
+ * @returns Workflows exported from the config
31
+ * @throws CompilerError on file not found, TypeScript errors, or missing exports
32
+ */
33
+ export declare function executeConfig(configPath: string): Promise<ExecutionResult>;
34
+ /**
35
+ * Resolve the .kici directory path, handling the case where the user
36
+ * is already inside the .kici directory (or a subdirectory of it).
37
+ *
38
+ * Resolution order:
39
+ * 1. If the resolved path has a workflows/ subdirectory, use it directly
40
+ * 2. If CWD itself is named .kici and has workflows/, use CWD
41
+ * 3. Fall through to the original resolved path (downstream code will error)
42
+ *
43
+ * @param kiciDir - Path to .kici directory (defaults to '.kici')
44
+ * @returns Absolute path to the .kici directory
45
+ */
46
+ export declare function resolveKiciDir(kiciDir?: string): string;
47
+ /**
48
+ * Discover and execute all workflow files from .kici/workflows/ directory.
49
+ *
50
+ * Process:
51
+ * 1. Locate .kici/workflows/ directory (defaults to .kici relative to cwd)
52
+ * 2. Find all *.ts files in the directory
53
+ * 3. Execute each file to extract workflow definitions
54
+ * 4. Collect and return all workflows
55
+ *
56
+ * @param kiciDir - Path to .kici directory (defaults to '.kici' relative to cwd)
57
+ * @returns Discovery result with all workflows and directory paths
58
+ * @throws CompilerError if .kici/workflows/ doesn't exist or no workflows found
59
+ */
60
+ export declare function discoverWorkflows(kiciDir?: string): Promise<DiscoveryResult>;
61
+ //# sourceMappingURL=executor.d.ts.map