@kici-dev/compiler 0.1.26 → 0.1.27
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/dist/cli-banner.d.ts +6 -3
- package/dist/cli-banner.js +13 -5
- package/dist/cli.js +66 -43
- package/dist/commands/check-mode.d.ts +1 -1
- package/dist/commands/compile.js +3 -3
- package/dist/commands/index.d.ts +5 -1
- package/dist/commands/index.js +6 -3
- package/dist/commands/init.js +1 -1
- package/dist/commands/local-trust-root.d.ts +6 -0
- package/dist/commands/local-trust-root.js +52 -0
- package/dist/commands/local.d.ts +39 -0
- package/dist/commands/local.js +137 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +40 -0
- package/dist/commands/logout.js +7 -0
- package/dist/commands/preview.js +1 -1
- package/dist/commands/run-banner.d.ts +31 -0
- package/dist/commands/run-banner.js +25 -0
- package/dist/commands/run-routed.d.ts +53 -0
- package/dist/commands/run-routed.js +176 -0
- package/dist/commands/run.d.ts +0 -17
- package/dist/commands/run.js +7 -50
- package/dist/commands/secrets-list.d.ts +2 -2
- package/dist/commands/secrets-list.js +4 -4
- package/dist/commands/types.d.ts +3 -3
- package/dist/commands/types.js +4 -4
- package/dist/execution/executor.js +7 -7
- package/dist/generators/secrets-dts.d.ts +9 -9
- package/dist/generators/secrets-dts.js +12 -12
- package/dist/llm-context/llms-architecture.txt +2 -2
- package/dist/llm-context/llms-cli.txt +674 -340
- package/dist/llm-context/llms-features.txt +334 -336
- package/dist/llm-context/llms-full.txt +1207 -892
- package/dist/llm-context/llms-getting-started.txt +7 -15
- package/dist/llm-context/llms-patterns.txt +5 -23
- package/dist/llm-context/llms-providers.txt +10 -1
- package/dist/llm-context/llms-sdk.txt +12 -12
- package/dist/llm-context/llms.txt +5 -5
- package/dist/local-executor/secret-loader.d.ts +1 -1
- package/dist/local-plane/orchestrator-process.d.ts +65 -0
- package/dist/local-plane/orchestrator-process.js +115 -0
- package/dist/local-plane/paths.d.ts +39 -0
- package/dist/local-plane/paths.js +54 -0
- package/dist/local-plane/plane-manager.d.ts +151 -0
- package/dist/local-plane/plane-manager.js +340 -0
- package/dist/local-plane/plane-seed.d.ts +76 -0
- package/dist/local-plane/plane-seed.js +59 -0
- package/dist/local-plane/plane-trigger.d.ts +62 -0
- package/dist/local-plane/plane-trigger.js +97 -0
- package/dist/local-plane/platform-attach.d.ts +53 -0
- package/dist/local-plane/platform-attach.js +111 -0
- package/dist/local-plane/postgres.d.ts +44 -0
- package/dist/local-plane/postgres.js +165 -0
- package/dist/local-plane/resolve-plane.d.ts +37 -0
- package/dist/local-plane/resolve-plane.js +76 -0
- package/dist/local-plane/run-follow.d.ts +41 -0
- package/dist/local-plane/run-follow.js +104 -0
- package/dist/local-plane/scaler-config.d.ts +54 -0
- package/dist/local-plane/scaler-config.js +114 -0
- package/dist/local-plane/secret-seed.d.ts +59 -0
- package/dist/local-plane/secret-seed.js +112 -0
- package/dist/local-plane/source-provider.d.ts +43 -0
- package/dist/local-plane/source-provider.js +165 -0
- package/dist/local-plane/trusted-routing.d.ts +32 -0
- package/dist/local-plane/trusted-routing.js +47 -0
- package/dist/lockfile/generator.js +7 -7
- package/dist/remote/dashboard-client.d.ts +7 -7
- package/dist/remote/dashboard-client.js +7 -7
- package/dist/remote/platform-client.d.ts +1 -1
- package/dist/remote/secret-loader.d.ts +18 -0
- package/dist/{local-executor → remote}/secret-loader.js +4 -4
- package/dist/remote/secret-upload.d.ts +1 -1
- package/dist/remote/secret-upload.js +2 -2
- package/dist/remote/uploader.d.ts +1 -1
- package/dist/remote/uploader.js +2 -2
- package/dist/templates/agents-md.d.ts +1 -1
- package/dist/templates/agents-md.js +2 -2
- package/dist/templates/package-json.js +1 -1
- package/dist/test-runner/job-executor.js +1 -1
- package/dist/test-runner/runs-on-display.d.ts +9 -0
- package/dist/{local-executor → test-runner}/runs-on-display.js +1 -1
- package/dist/test-runner/step-context.d.ts +1 -1
- package/dist/test-runner/step-context.js +2 -2
- package/dist/types.d.ts +6 -6
- package/package.json +7 -4
- package/sbom.spdx.json +9884 -1459
- package/dist/local-executor/dag-scheduler.js +0 -183
- package/dist/local-executor/index.js +0 -378
- package/dist/local-executor/job-runner.js +0 -411
- package/dist/local-executor/materializer.js +0 -132
- package/dist/local-executor/output-streamer.js +0 -168
- package/dist/local-executor/payload-generator.js +0 -138
- package/dist/local-executor/picker.js +0 -109
- package/dist/local-executor/to-event-payload.js +0 -21
- package/dist/local-executor/types.js +0 -2
- package/dist/local-executor/workflow-lock.js +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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
164
|
-
}
|
|
165
|
-
//#endregion
|
|
166
|
-
export { displayLocalSummary, formatLocalJsonResult, formatLocalJunitResult };
|
|
167
|
-
|
|
168
|
-
//# sourceMappingURL=output-streamer.js.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,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,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
|
|
Binary file
|