@kici-dev/compiler 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/headless-detect.js +1 -1
- package/dist/cli-banner.js +1 -1
- package/dist/cli.d.ts +9 -1
- package/dist/cli.js +251 -183
- package/dist/commands/approve.d.ts +23 -0
- package/dist/commands/approve.js +46 -0
- package/dist/commands/compile.js +6 -4
- package/dist/commands/diagnostics.d.ts +7 -0
- package/dist/commands/diagnostics.js +58 -0
- package/dist/commands/docs.js +3 -3
- package/dist/commands/drain-worker.js +1 -1
- package/dist/commands/endpoints.js +2 -2
- package/dist/commands/fixture.js +1 -1
- package/dist/commands/held-run-client.d.ts +26 -0
- package/dist/commands/held-run-client.js +98 -0
- package/dist/commands/held-run-resolve.d.ts +45 -0
- package/dist/commands/held-run-resolve.js +53 -0
- package/dist/commands/hook.js +2 -2
- package/dist/commands/index.d.ts +20 -4
- package/dist/commands/index.js +12 -4
- package/dist/commands/init.js +3 -3
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +1 -3
- package/dist/commands/logout.js +1 -1
- package/dist/commands/orchestrators.d.ts +25 -0
- package/dist/commands/orchestrators.js +115 -0
- package/dist/commands/org.js +1 -1
- package/dist/commands/reject.d.ts +25 -0
- package/dist/commands/reject.js +49 -0
- package/dist/commands/run.d.ts +2 -9
- package/dist/commands/run.js +257 -316
- package/dist/commands/runs/cancel.d.ts +6 -0
- package/dist/commands/runs/cancel.js +32 -0
- package/dist/commands/runs/list.d.ts +6 -0
- package/dist/commands/runs/list.js +49 -0
- package/dist/commands/runs/logs.d.ts +7 -0
- package/dist/commands/runs/logs.js +67 -0
- package/dist/commands/runs/rerun.d.ts +5 -0
- package/dist/commands/runs/rerun.js +21 -0
- package/dist/commands/runs/show.d.ts +5 -0
- package/dist/commands/runs/show.js +65 -0
- package/dist/commands/secrets-list.d.ts +7 -9
- package/dist/commands/secrets-list.js +40 -64
- package/dist/commands/test.d.ts +4 -0
- package/dist/commands/test.js +2 -2
- package/dist/commands/types.d.ts +3 -5
- package/dist/commands/types.js +14 -38
- package/dist/commands/verify-attestation.d.ts +12 -0
- package/dist/commands/verify-attestation.js +69 -0
- package/dist/commands/watch.js +2 -2
- package/dist/commands/workflows.js +14 -34
- package/dist/errors/capability-gap.js +1 -1
- package/dist/errors/formatter.js +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/execution/executor.js +3 -3
- package/dist/execution/index.js +1 -1
- package/dist/execution/sdk-alias.js +2 -2
- package/dist/execution/ts-loader.js +1 -1
- package/dist/fixtures/compiler.js +3 -3
- package/dist/fixtures/defaults/index.js +3 -3
- package/dist/format.js +1 -1
- package/dist/generators/secrets-dts.js +2 -2
- package/dist/hooks/detector.js +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/installer.js +2 -2
- package/dist/hooks/templates.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/llm-context/llms-full.txt +1180 -131
- package/dist/llm-context/llms.txt +6 -2
- package/dist/local-executor/dag-scheduler.js +1 -1
- package/dist/local-executor/index.js +2 -2
- package/dist/local-executor/job-runner.js +38 -17
- package/dist/local-executor/materializer.js +2 -2
- package/dist/local-executor/output-streamer.js +1 -1
- package/dist/local-executor/payload-generator.js +1 -1
- package/dist/local-executor/picker.js +1 -1
- package/dist/local-executor/secret-loader.js +2 -2
- package/dist/local-executor/to-event-payload.js +1 -1
- package/dist/local-executor/types.js +1 -1
- package/dist/local-executor/workflow-lock.js +0 -0
- package/dist/lockfile/generator.d.ts +7 -5
- package/dist/lockfile/generator.js +38 -23
- package/dist/lockfile/hash-files.js +2 -2
- package/dist/lockfile/hasher.js +1 -1
- package/dist/lockfile/index.js +1 -1
- package/dist/lockfile/purity-analyzer.js +1 -1
- package/dist/postinstall.js +2 -2
- package/dist/provenance-trust-root.d.ts +14 -0
- package/dist/provenance-trust-root.js +49 -0
- package/dist/remote/config.d.ts +6 -2
- package/dist/remote/config.js +8 -5
- package/dist/remote/dashboard-client.d.ts +92 -0
- package/dist/remote/dashboard-client.js +168 -0
- package/dist/remote/encryption.js +3 -4
- package/dist/remote/history.js +2 -2
- package/dist/remote/oauth.js +1 -1
- package/dist/remote/oidc-discovery.js +1 -1
- package/dist/remote/output/json.js +1 -1
- package/dist/remote/output/junit.js +1 -1
- package/dist/remote/output/streaming.js +1 -1
- package/dist/remote/output/summary.js +1 -1
- package/dist/remote/platform-client.d.ts +142 -0
- package/dist/remote/platform-client.js +187 -0
- package/dist/remote/prod-defaults.js +1 -1
- package/dist/remote/render.d.ts +11 -0
- package/dist/remote/render.js +48 -0
- package/dist/remote/secret-upload.js +1 -1
- package/dist/remote/uploader.d.ts +9 -0
- package/dist/remote/uploader.js +52 -5
- package/dist/templates/agents-md.d.ts +1 -1
- package/dist/templates/agents-md.js +8 -3
- package/dist/templates/index.js +2 -2
- package/dist/templates/package-json.js +4 -5
- package/dist/templates/tsconfig-json.js +1 -1
- package/dist/templates/workflows/hello-world.js +2 -2
- package/dist/templates/workflows/hello-world.ts +1 -1
- package/dist/templates/workflows/pr-checks.js +3 -3
- package/dist/templates/workflows/pr-checks.ts +2 -2
- package/dist/test-runner/dry-run.js +1 -1
- package/dist/test-runner/event-types.js +1 -1
- package/dist/test-runner/git-detector.js +2 -2
- package/dist/test-runner/index.js +1 -1
- package/dist/test-runner/job-executor.js +3 -3
- package/dist/test-runner/output-formatter.js +1 -1
- package/dist/test-runner/payload-builder.js +1 -1
- package/dist/test-runner/rule-evaluator.js +1 -1
- package/dist/test-runner/secrets-file.js +2 -2
- package/dist/test-runner/step-context.js +11 -7
- package/dist/types.d.ts +24 -6
- package/dist/types.js +2 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/validator.js +1 -1
- package/dist/workflows/hello-world.ts +1 -1
- package/dist/workflows/pr-checks.ts +2 -2
- package/package.json +5 -4
- package/sbom.spdx.json +68 -38
- package/dist/commands/cancel.js +0 -124
- package/dist/commands/status.js +0 -212
- package/dist/remote/client.js +0 -203
- package/dist/remote/observer.js +0 -174
- /package/dist/{chunk-gOLHoazu.js → chunk-BTugEXQM.js} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
|
+
import { DashboardClient, DashboardClientError } from "../remote/dashboard-client.js";
|
|
3
|
+
import { relativeTime } from "../remote/render.js";
|
|
4
|
+
import pc from "picocolors";
|
|
5
|
+
import { logger, toErrorMessage } from "@kici-dev/core";
|
|
6
|
+
//#region src/commands/diagnostics.ts
|
|
7
|
+
/** kici diagnostics — mirrors the dashboard Diagnostics page (infra tree). */
|
|
8
|
+
async function diagnosticsCommand(options = {}) {
|
|
9
|
+
try {
|
|
10
|
+
const client = await DashboardClient.load();
|
|
11
|
+
const [summary, infra] = await Promise.all([client.getDiagnosticsSummary(), client.getInfrastructure()]);
|
|
12
|
+
let orchestrators = infra.orchestrators;
|
|
13
|
+
if (options.orchestrator) orchestrators = orchestrators.filter((o) => o.connectionId === options.orchestrator);
|
|
14
|
+
if (options.json) {
|
|
15
|
+
console.log(JSON.stringify({
|
|
16
|
+
summary,
|
|
17
|
+
orchestrators,
|
|
18
|
+
alerts: infra.alerts
|
|
19
|
+
}, null, 2));
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
printSummary(summary);
|
|
23
|
+
printAlerts(infra.alerts);
|
|
24
|
+
if (orchestrators.length === 0) {
|
|
25
|
+
console.log(pc.gray("\nNo orchestrators connected."));
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
for (const o of orchestrators) printOrchestrator(o, options.verbose ?? false);
|
|
29
|
+
return true;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
logger.error(pc.red(err instanceof DashboardClientError ? err.message : toErrorMessage(err)));
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function printSummary(s) {
|
|
36
|
+
const m = s.executionMetrics;
|
|
37
|
+
console.log(pc.bold("\nDiagnostics") + pc.gray(` runs(24h)=${m.totalRuns} success=${m.successRate}% avg=${m.avgDurationSeconds}s queued=${m.queuedJobs} running=${m.runningJobs}` + (s.orphanedConnections > 0 ? ` orphaned=${s.orphanedConnections}` : "")));
|
|
38
|
+
}
|
|
39
|
+
function printAlerts(alerts) {
|
|
40
|
+
for (const a of alerts) {
|
|
41
|
+
const color = a.severity === "critical" ? pc.red : pc.yellow;
|
|
42
|
+
console.log(color(` ! [${a.type}] ${a.message}`));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function printOrchestrator(o, verbose) {
|
|
46
|
+
const hb = o.lastHeartbeat ? relativeTime(new Date(o.lastHeartbeat).toISOString()) : "—";
|
|
47
|
+
const head = pc.bold(o.clusterName ?? o.connectionId) + pc.gray(` [${o.connectionId}] keys=${o.routingKeys.join(",") || "—"} ${o.connected ? pc.green("connected") : pc.red("disconnected")} raft=${o.raftRole ?? "—"} hb=${hb}`);
|
|
48
|
+
console.log(`\n${head}`);
|
|
49
|
+
for (const sc of o.scalers) console.log(pc.gray(" └─ ") + `${sc.name} (${sc.type}) ${sc.activeAgents}/${sc.maxAgents} ` + pc.gray(`labels=${sc.labelSets.map((set) => set.join("+")).join(" | ") || "—"}`));
|
|
50
|
+
for (const ag of o.agents) {
|
|
51
|
+
const extra = verbose ? ` host=${ag.hostname ?? "—"} node=${ag.nodeVersion ?? "—"} mem=${ag.memoryUsedMb ?? "—"}MB` : "";
|
|
52
|
+
console.log(pc.gray(" • ") + `${ag.agentId} ` + pc.cyan(`[${ag.labels.join(",")}]`) + pc.gray(` ${ag.platform}/${ag.arch} jobs=${ag.activeJobs}/${ag.maxConcurrency} hb=${relativeTime(new Date(ag.lastHeartbeatAt).toISOString())}${extra}`));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { diagnosticsCommand };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=diagnostics.js.map
|
package/dist/commands/docs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import pc from "picocolors";
|
|
3
5
|
import { readFile, writeFile } from "node:fs/promises";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { logger, toErrorMessage } from "@kici-dev/core";
|
|
7
7
|
import open from "open";
|
|
8
8
|
//#region src/commands/docs.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
2
|
import { resolveKiciDir } from "../execution/executor.js";
|
|
3
3
|
import "../execution/index.js";
|
|
4
4
|
import { loadGlobalConfig } from "../remote/config.js";
|
|
5
|
+
import path from "node:path";
|
|
5
6
|
import pc from "picocolors";
|
|
6
7
|
import { readFile } from "node:fs/promises";
|
|
7
|
-
import path from "node:path";
|
|
8
8
|
import { logger, toErrorMessage } from "@kici-dev/core";
|
|
9
9
|
//#region src/commands/endpoints.ts
|
|
10
10
|
/**
|
package/dist/commands/fixture.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared HTTP plumbing for the `kici approve` / `kici reject` held-run
|
|
3
|
+
* commands. Resolves auth + endpoint from the global config (PAT preferred,
|
|
4
|
+
* API key fallback; Platform endpoint preferred, orchestrator fallback) and
|
|
5
|
+
* exposes thin list / approve / reject helpers against the Platform dashboard
|
|
6
|
+
* API.
|
|
7
|
+
*/
|
|
8
|
+
import type { HeldRunSummary } from './held-run-resolve.js';
|
|
9
|
+
/** Resolved auth context for a held-run command. */
|
|
10
|
+
export interface HeldRunContext {
|
|
11
|
+
endpoint: string;
|
|
12
|
+
token: string;
|
|
13
|
+
orgId: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the auth context, printing a clear error and returning null when the
|
|
17
|
+
* CLI is not authenticated / no active org is set.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveHeldRunContext(): Promise<HeldRunContext | null>;
|
|
20
|
+
/** List the held runs for a single run id. */
|
|
21
|
+
export declare function listHeldRunsForRun(ctx: HeldRunContext, runId: string): Promise<HeldRunSummary[]>;
|
|
22
|
+
/** POST an approve decision for a held run. Returns true on success. */
|
|
23
|
+
export declare function postApprove(ctx: HeldRunContext, heldRunId: string): Promise<boolean>;
|
|
24
|
+
/** POST a reject decision (with reason) for a held run. Returns true on success. */
|
|
25
|
+
export declare function postReject(ctx: HeldRunContext, heldRunId: string, reason: string): Promise<boolean>;
|
|
26
|
+
//# sourceMappingURL=held-run-client.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
|
+
import { loadGlobalConfig } from "../remote/config.js";
|
|
3
|
+
import pc from "picocolors";
|
|
4
|
+
import { logger } from "@kici-dev/core";
|
|
5
|
+
//#region src/commands/held-run-client.ts
|
|
6
|
+
/**
|
|
7
|
+
* Shared HTTP plumbing for the `kici approve` / `kici reject` held-run
|
|
8
|
+
* commands. Resolves auth + endpoint from the global config (PAT preferred,
|
|
9
|
+
* API key fallback; Platform endpoint preferred, orchestrator fallback) and
|
|
10
|
+
* exposes thin list / approve / reject helpers against the Platform dashboard
|
|
11
|
+
* API.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the auth context, printing a clear error and returning null when the
|
|
15
|
+
* CLI is not authenticated / no active org is set.
|
|
16
|
+
*/
|
|
17
|
+
async function resolveHeldRunContext() {
|
|
18
|
+
const config = await loadGlobalConfig();
|
|
19
|
+
const token = config.pat ?? config.token;
|
|
20
|
+
if (!token) {
|
|
21
|
+
logger.error(pc.red("Not authenticated. Run `kici login` to get started."));
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const endpoint = config.platformEndpoint ?? config.endpoint;
|
|
25
|
+
if (!endpoint) {
|
|
26
|
+
logger.error(pc.red("No endpoint configured. Run `kici login` to configure."));
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (!config.activeOrgId) {
|
|
30
|
+
logger.error(pc.red("No active organization. Run `kici org use <name>` to set one."));
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
endpoint,
|
|
35
|
+
token,
|
|
36
|
+
orgId: config.activeOrgId
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function authHeaders(token) {
|
|
40
|
+
return {
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
Authorization: `Bearer ${token}`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** List the held runs for a single run id. */
|
|
46
|
+
async function listHeldRunsForRun(ctx, runId) {
|
|
47
|
+
const url = `${ctx.endpoint}/api/v1/orgs/${ctx.orgId}/held-runs?runId=${encodeURIComponent(runId)}`;
|
|
48
|
+
const response = await fetch(url, {
|
|
49
|
+
method: "GET",
|
|
50
|
+
headers: authHeaders(ctx.token)
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) throw new Error(await describeError(response));
|
|
53
|
+
return (await response.json()).heldRuns ?? [];
|
|
54
|
+
}
|
|
55
|
+
/** POST an approve decision for a held run. Returns true on success. */
|
|
56
|
+
async function postApprove(ctx, heldRunId) {
|
|
57
|
+
const url = `${ctx.endpoint}/api/v1/orgs/${ctx.orgId}/held-runs/${heldRunId}/approve`;
|
|
58
|
+
const response = await fetch(url, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: authHeaders(ctx.token)
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
logger.error(pc.red(await describeError(response)));
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/** POST a reject decision (with reason) for a held run. Returns true on success. */
|
|
69
|
+
async function postReject(ctx, heldRunId, reason) {
|
|
70
|
+
const url = `${ctx.endpoint}/api/v1/orgs/${ctx.orgId}/held-runs/${heldRunId}/reject`;
|
|
71
|
+
const response = await fetch(url, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: authHeaders(ctx.token),
|
|
74
|
+
body: JSON.stringify({ reason })
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
logger.error(pc.red(await describeError(response)));
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/** Build a user-facing error string from a failed response. */
|
|
83
|
+
async function describeError(response) {
|
|
84
|
+
let detail;
|
|
85
|
+
try {
|
|
86
|
+
detail = (await response.json()).error;
|
|
87
|
+
} catch {}
|
|
88
|
+
switch (response.status) {
|
|
89
|
+
case 401: return "Authentication failed. Run `kici login` to re-authenticate.";
|
|
90
|
+
case 403: return `Access denied${detail ? `: ${detail}` : ""}.`;
|
|
91
|
+
case 404: return `Held run not found${detail ? `: ${detail}` : ""}.`;
|
|
92
|
+
default: return detail ?? `Request failed with status ${response.status}.`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { listHeldRunsForRun, postApprove, postReject, resolveHeldRunContext };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=held-run-client.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared held-run resolution for the `kici approve` / `kici reject` commands.
|
|
3
|
+
*
|
|
4
|
+
* Both commands first list the pending holds for a run, then resolve the one
|
|
5
|
+
* the user named via `--job` / `--step` (or the sole pending hold when there is
|
|
6
|
+
* exactly one and no filter is given). The resolution is a pure function so it
|
|
7
|
+
* can be unit-tested without HTTP.
|
|
8
|
+
*/
|
|
9
|
+
/** Hold scope, mirroring the engine `HoldScope` enum. */
|
|
10
|
+
export type HeldRunScope = 'workflow' | 'job' | 'step';
|
|
11
|
+
/** A pending-hold row as returned by `GET /orgs/:orgId/held-runs`. */
|
|
12
|
+
export interface HeldRunSummary {
|
|
13
|
+
id: string;
|
|
14
|
+
runId: string;
|
|
15
|
+
jobId?: string;
|
|
16
|
+
holdScope?: HeldRunScope;
|
|
17
|
+
stepIndex?: number | null;
|
|
18
|
+
status: string;
|
|
19
|
+
}
|
|
20
|
+
/** Filters supplied on the command line. */
|
|
21
|
+
export interface HeldRunFilter {
|
|
22
|
+
/** Match a hold by its job name. */
|
|
23
|
+
job?: string;
|
|
24
|
+
/** Match a step-scoped hold by its step index (compared as a string). */
|
|
25
|
+
step?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Resolution result: either a held-run id or a user-facing error message. */
|
|
28
|
+
export type ResolveResult = {
|
|
29
|
+
ok: true;
|
|
30
|
+
heldRunId: string;
|
|
31
|
+
hold: HeldRunSummary;
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the held-run id matching the filter from a list of pending holds.
|
|
38
|
+
*
|
|
39
|
+
* - `--step` requires `--job` and matches a `step`-scoped hold whose step index
|
|
40
|
+
* equals the given value.
|
|
41
|
+
* - `--job` alone matches a `job`/`workflow`-scoped hold for that job.
|
|
42
|
+
* - With no filter, the sole pending hold is used; ambiguity is an error.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveHeldRunId(holds: readonly HeldRunSummary[], filter: HeldRunFilter): ResolveResult;
|
|
45
|
+
//# sourceMappingURL=held-run-resolve.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
|
+
//#region src/commands/held-run-resolve.ts
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the held-run id matching the filter from a list of pending holds.
|
|
5
|
+
*
|
|
6
|
+
* - `--step` requires `--job` and matches a `step`-scoped hold whose step index
|
|
7
|
+
* equals the given value.
|
|
8
|
+
* - `--job` alone matches a `job`/`workflow`-scoped hold for that job.
|
|
9
|
+
* - With no filter, the sole pending hold is used; ambiguity is an error.
|
|
10
|
+
*/
|
|
11
|
+
function resolveHeldRunId(holds, filter) {
|
|
12
|
+
const pending = holds.filter((h) => h.status === "pending");
|
|
13
|
+
if (pending.length === 0) return {
|
|
14
|
+
ok: false,
|
|
15
|
+
error: "No pending approval holds found for this run."
|
|
16
|
+
};
|
|
17
|
+
if (filter.step !== void 0) {
|
|
18
|
+
if (!filter.job) return {
|
|
19
|
+
ok: false,
|
|
20
|
+
error: "--step requires --job to identify the held step."
|
|
21
|
+
};
|
|
22
|
+
return pickSingle(pending.filter((h) => h.holdScope === "step" && h.jobId === filter.job && String(h.stepIndex ?? "") === filter.step), `step ${filter.step} of job '${filter.job}'`);
|
|
23
|
+
}
|
|
24
|
+
if (filter.job !== void 0) return pickSingle(pending.filter((h) => h.jobId === filter.job && h.holdScope !== "step"), `job '${filter.job}'`);
|
|
25
|
+
if (pending.length > 1) return {
|
|
26
|
+
ok: false,
|
|
27
|
+
error: "Multiple pending holds for this run. Use --job <name> (and --step <index>) to choose one."
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
ok: true,
|
|
31
|
+
heldRunId: pending[0].id,
|
|
32
|
+
hold: pending[0]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function pickSingle(matches, label) {
|
|
36
|
+
if (matches.length === 0) return {
|
|
37
|
+
ok: false,
|
|
38
|
+
error: `No pending hold found for ${label}.`
|
|
39
|
+
};
|
|
40
|
+
if (matches.length > 1) return {
|
|
41
|
+
ok: false,
|
|
42
|
+
error: `Multiple pending holds match ${label}; cannot disambiguate.`
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
ok: true,
|
|
46
|
+
heldRunId: matches[0].id,
|
|
47
|
+
hold: matches[0]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { resolveHeldRunId };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=held-run-resolve.js.map
|
package/dist/commands/hook.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
2
|
import { detectHookTools, findGitDir } from "../hooks/detector.js";
|
|
3
3
|
import { installHook } from "../hooks/installer.js";
|
|
4
4
|
import "../hooks/index.js";
|
|
5
|
+
import path from "node:path";
|
|
5
6
|
import pc from "picocolors";
|
|
6
7
|
import { readFile } from "node:fs/promises";
|
|
7
|
-
import path from "node:path";
|
|
8
8
|
import { logger, toErrorMessage } from "@kici-dev/core";
|
|
9
9
|
import { select } from "@inquirer/prompts";
|
|
10
10
|
//#region src/commands/hook.ts
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -14,20 +14,36 @@ export { loginCommand } from './login.js';
|
|
|
14
14
|
export type { LoginOptions } from './login.js';
|
|
15
15
|
export { secretsListCommand } from './secrets-list.js';
|
|
16
16
|
export type { SecretsListOptions } from './secrets-list.js';
|
|
17
|
-
export {
|
|
18
|
-
export type {
|
|
17
|
+
export { runsListCommand } from './runs/list.js';
|
|
18
|
+
export type { RunsListOptions } from './runs/list.js';
|
|
19
|
+
export { runsShowCommand } from './runs/show.js';
|
|
20
|
+
export type { RunsShowOptions } from './runs/show.js';
|
|
21
|
+
export { runsLogsCommand } from './runs/logs.js';
|
|
22
|
+
export type { RunsLogsOptions } from './runs/logs.js';
|
|
23
|
+
export { runsRerunCommand } from './runs/rerun.js';
|
|
24
|
+
export type { RunsRerunOptions } from './runs/rerun.js';
|
|
25
|
+
export { runsCancelCommand } from './runs/cancel.js';
|
|
26
|
+
export type { RunsCancelOptions } from './runs/cancel.js';
|
|
19
27
|
export { typesCommand } from './types.js';
|
|
20
28
|
export type { TypesOptions } from './types.js';
|
|
21
29
|
export { endpointsCommand } from './endpoints.js';
|
|
22
30
|
export type { EndpointsOptions } from './endpoints.js';
|
|
31
|
+
export { diagnosticsCommand } from './diagnostics.js';
|
|
32
|
+
export type { DiagnosticsOptions } from './diagnostics.js';
|
|
23
33
|
export { orgListCommand, orgUseCommand, orgCurrentCommand } from './org.js';
|
|
34
|
+
export { orchestratorsListCommand, orchestratorsUseCommand } from './orchestrators.js';
|
|
35
|
+
export type { OrchestratorsOptions } from './orchestrators.js';
|
|
24
36
|
export { logoutCommand } from './logout.js';
|
|
25
|
-
export {
|
|
26
|
-
export type {
|
|
37
|
+
export { approveCommand } from './approve.js';
|
|
38
|
+
export type { ApproveOptions } from './approve.js';
|
|
39
|
+
export { rejectCommand } from './reject.js';
|
|
40
|
+
export type { RejectOptions } from './reject.js';
|
|
27
41
|
export { workflowsListCommand } from './workflows.js';
|
|
28
42
|
export type { WorkflowsListOptions } from './workflows.js';
|
|
29
43
|
export { drainWorkerCommand } from './drain-worker.js';
|
|
30
44
|
export type { DrainWorkerOptions } from './drain-worker.js';
|
|
31
45
|
export { docsCommand, docsLlmCommand } from './docs.js';
|
|
32
46
|
export type { DocsOptions, DocsLlmOptions } from './docs.js';
|
|
47
|
+
export { verifyAttestationCommand } from './verify-attestation.js';
|
|
48
|
+
export type { VerifyAttestationOptions } from './verify-attestation.js';
|
|
33
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/commands/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
2
|
import { compileCommand } from "./compile.js";
|
|
3
|
-
import {
|
|
3
|
+
import { approveCommand } from "./approve.js";
|
|
4
|
+
import { diagnosticsCommand } from "./diagnostics.js";
|
|
4
5
|
import { docsCommand, docsLlmCommand } from "./docs.js";
|
|
5
6
|
import { drainWorkerCommand } from "./drain-worker.js";
|
|
6
7
|
import { endpointsCommand } from "./endpoints.js";
|
|
@@ -12,9 +13,16 @@ import { runLocalCommand, runRemoteCommand } from "./run.js";
|
|
|
12
13
|
import { initCommand } from "./init.js";
|
|
13
14
|
import { loginCommand } from "./login.js";
|
|
14
15
|
import { secretsListCommand } from "./secrets-list.js";
|
|
15
|
-
import {
|
|
16
|
+
import { runsListCommand } from "./runs/list.js";
|
|
17
|
+
import { runsShowCommand } from "./runs/show.js";
|
|
18
|
+
import { runsLogsCommand } from "./runs/logs.js";
|
|
19
|
+
import { runsRerunCommand } from "./runs/rerun.js";
|
|
20
|
+
import { runsCancelCommand } from "./runs/cancel.js";
|
|
16
21
|
import { typesCommand } from "./types.js";
|
|
17
22
|
import { orgCurrentCommand, orgListCommand, orgUseCommand } from "./org.js";
|
|
23
|
+
import { orchestratorsListCommand, orchestratorsUseCommand } from "./orchestrators.js";
|
|
18
24
|
import { logoutCommand } from "./logout.js";
|
|
25
|
+
import { rejectCommand } from "./reject.js";
|
|
19
26
|
import { workflowsListCommand } from "./workflows.js";
|
|
20
|
-
|
|
27
|
+
import { verifyAttestationCommand } from "./verify-attestation.js";
|
|
28
|
+
export { approveCommand, compileCommand, diagnosticsCommand, docsCommand, docsLlmCommand, drainWorkerCommand, endpointsCommand, fixtureCommand, hookInstallCommand, initCommand, loginCommand, logoutCommand, orchestratorsListCommand, orchestratorsUseCommand, orgCurrentCommand, orgListCommand, orgUseCommand, rejectCommand, runLocalCommand, runRemoteCommand, runsCancelCommand, runsListCommand, runsLogsCommand, runsRerunCommand, runsShowCommand, secretsListCommand, testCommand, testDryRun, typesCommand, verifyAttestationCommand, watchCommand, workflowsListCommand };
|
package/dist/commands/init.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
2
|
import { agentsMdTemplate } from "../templates/agents-md.js";
|
|
3
3
|
import { tsconfigTemplate } from "../templates/tsconfig-json.js";
|
|
4
4
|
import { generatePackageJson } from "../templates/package-json.js";
|
|
@@ -7,9 +7,9 @@ import { detectHookTools, findGitDir } from "../hooks/detector.js";
|
|
|
7
7
|
import { installHook } from "../hooks/installer.js";
|
|
8
8
|
import "../hooks/index.js";
|
|
9
9
|
import { getTypeScriptPaths } from "../execution/sdk-alias.js";
|
|
10
|
+
import path from "node:path";
|
|
10
11
|
import pc from "picocolors";
|
|
11
12
|
import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
12
|
-
import path from "node:path";
|
|
13
13
|
import { initZx, logger, toErrorMessage } from "@kici-dev/core";
|
|
14
14
|
import { detectPackageManager, installBuildPolicyArgs, installCommand, parsePackageManager } from "@kici-dev/core/package-manager";
|
|
15
15
|
import { checkbox, confirm, select } from "@inquirer/prompts";
|
|
@@ -292,7 +292,7 @@ export default workflow('private-registry-example', {
|
|
|
292
292
|
],
|
|
293
293
|
jobs: [
|
|
294
294
|
job('build', {
|
|
295
|
-
runsOn: 'linux',
|
|
295
|
+
runsOn: 'kici:os:linux',
|
|
296
296
|
steps: [step('install', async () => { /* deps install with auth */ })],
|
|
297
297
|
}),
|
|
298
298
|
],
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export interface LoginOptions {
|
|
2
2
|
/** API key for non-interactive authentication */
|
|
3
3
|
token?: string;
|
|
4
|
-
/** Orchestrator URL for direct connection */
|
|
5
|
-
endpoint?: string;
|
|
6
4
|
/** Platform relay URL */
|
|
7
5
|
platformEndpoint?: string;
|
|
8
6
|
/** Routing key for webhook source identification */
|
package/dist/commands/login.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
2
|
import { getConfigPath, mergeGlobalConfig } from "../remote/config.js";
|
|
3
3
|
import { deviceFlow, exchangeTokenForPat, pkceFlow } from "../remote/oauth.js";
|
|
4
4
|
import "../remote/prod-defaults.js";
|
|
@@ -75,7 +75,6 @@ async function oauthLogin(options) {
|
|
|
75
75
|
patId: patResult.id,
|
|
76
76
|
patExpiresAt: patResult.expiresAt
|
|
77
77
|
};
|
|
78
|
-
if (options.endpoint) configUpdate.endpoint = options.endpoint;
|
|
79
78
|
if (options.platformEndpoint) configUpdate.platformEndpoint = options.platformEndpoint;
|
|
80
79
|
if (options.routingKey) configUpdate.routingKey = options.routingKey;
|
|
81
80
|
await mergeGlobalConfig(configUpdate);
|
|
@@ -117,7 +116,6 @@ async function legacyTokenLogin(options) {
|
|
|
117
116
|
return false;
|
|
118
117
|
}
|
|
119
118
|
const update = { token };
|
|
120
|
-
if (options.endpoint) update.endpoint = options.endpoint;
|
|
121
119
|
if (options.platformEndpoint) update.platformEndpoint = options.platformEndpoint;
|
|
122
120
|
if (options.routingKey) update.routingKey = options.routingKey;
|
|
123
121
|
await mergeGlobalConfig(update);
|
package/dist/commands/logout.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kici orchestrators commands
|
|
3
|
+
*
|
|
4
|
+
* Inspect the org's connected orchestrator clusters and pick a per-org default
|
|
5
|
+
* for `kici run remote`. `list` reads the Platform orchestrators index;
|
|
6
|
+
* `use <name>` records `config.defaultClusters[orgId]` so a developer with a
|
|
7
|
+
* preferred cluster types no `--orchestrator` flag.
|
|
8
|
+
*/
|
|
9
|
+
/** Options shared by the orchestrators subcommands. */
|
|
10
|
+
export interface OrchestratorsOptions {
|
|
11
|
+
/** Target organization id (overrides config.activeOrgId). */
|
|
12
|
+
org?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* List the org's connected orchestrator clusters, marking the per-org default.
|
|
16
|
+
*/
|
|
17
|
+
export declare function orchestratorsListCommand(options: OrchestratorsOptions): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Set the per-org default orchestrator cluster.
|
|
20
|
+
*
|
|
21
|
+
* Validates the cluster name against the org's connected clusters before
|
|
22
|
+
* writing it to `config.defaultClusters[orgId]`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function orchestratorsUseCommand(clusterName: string, options: OrchestratorsOptions): Promise<boolean>;
|
|
25
|
+
//# sourceMappingURL=orchestrators.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
|
+
import { loadGlobalConfig, mergeGlobalConfig } from "../remote/config.js";
|
|
3
|
+
import pc from "picocolors";
|
|
4
|
+
//#region src/commands/orchestrators.ts
|
|
5
|
+
/**
|
|
6
|
+
* kici orchestrators commands
|
|
7
|
+
*
|
|
8
|
+
* Inspect the org's connected orchestrator clusters and pick a per-org default
|
|
9
|
+
* for `kici run remote`. `list` reads the Platform orchestrators index;
|
|
10
|
+
* `use <name>` records `config.defaultClusters[orgId]` so a developer with a
|
|
11
|
+
* preferred cluster types no `--orchestrator` flag.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the authenticated config + the target org id, printing an actionable
|
|
15
|
+
* error and returning null when either is missing.
|
|
16
|
+
*/
|
|
17
|
+
async function resolveOrgContext(options) {
|
|
18
|
+
const config = await loadGlobalConfig();
|
|
19
|
+
if (!config.pat) {
|
|
20
|
+
console.error(pc.red("Not logged in. Run `kici login` first."));
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (!config.platformEndpoint) {
|
|
24
|
+
console.error(pc.red("No Platform endpoint configured. Run `kici login` to set up your Platform."));
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const orgId = options.org ?? config.activeOrgId;
|
|
28
|
+
if (!orgId) {
|
|
29
|
+
console.error(pc.red("No target organization. Select one with `kici org use <org>` or pass `--org <id>`."));
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
config,
|
|
34
|
+
orgId
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fetch the org's connected orchestrator clusters from the Platform index.
|
|
39
|
+
* Returns null on an auth/HTTP failure (after printing an error).
|
|
40
|
+
*/
|
|
41
|
+
async function fetchOrchestrators(config, orgId) {
|
|
42
|
+
const url = `${config.platformEndpoint}/api/v1/orgs/${orgId}/orchestrators`;
|
|
43
|
+
const response = await fetch(url, { headers: {
|
|
44
|
+
Authorization: `Bearer ${config.pat}`,
|
|
45
|
+
"Content-Type": "application/json"
|
|
46
|
+
} });
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
if (response.status === 401) {
|
|
49
|
+
console.error(pc.red("Authentication failed. Your token may be expired. Run `kici login` to re-authenticate."));
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
console.error(pc.red(`Failed to list orchestrators: HTTP ${response.status}`));
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return (await response.json()).orchestrators ?? [];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* List the org's connected orchestrator clusters, marking the per-org default.
|
|
59
|
+
*/
|
|
60
|
+
async function orchestratorsListCommand(options) {
|
|
61
|
+
const ctx = await resolveOrgContext(options);
|
|
62
|
+
if (!ctx) return false;
|
|
63
|
+
const orchestrators = await fetchOrchestrators(ctx.config, ctx.orgId);
|
|
64
|
+
if (orchestrators === null) return false;
|
|
65
|
+
if (orchestrators.length === 0) {
|
|
66
|
+
console.log(pc.gray("No orchestrators are connected for this organization."));
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
const defaultCluster = ctx.config.defaultClusters?.[ctx.orgId];
|
|
70
|
+
console.log(pc.bold("\nOrchestrators:\n"));
|
|
71
|
+
const names = orchestrators.map((o) => o.clusterName ?? "(unnamed)");
|
|
72
|
+
const nameWidth = Math.max(12, ...names.map((n) => n.length)) + 2;
|
|
73
|
+
for (const orch of orchestrators) {
|
|
74
|
+
const name = orch.clusterName ?? "(unnamed)";
|
|
75
|
+
const isDefault = orch.clusterName !== null && orch.clusterName === defaultCluster;
|
|
76
|
+
const marker = isDefault ? pc.green("* ") : " ";
|
|
77
|
+
const display = isDefault ? pc.bold(name) : name;
|
|
78
|
+
const version = orch.orchVersion ? pc.gray(`v${orch.orchVersion}`) : pc.gray("(unknown)");
|
|
79
|
+
console.log(` ${marker}${display.padEnd(nameWidth)} ${version}`);
|
|
80
|
+
}
|
|
81
|
+
console.log("");
|
|
82
|
+
console.log(pc.gray("Set a default with `kici orchestrators use <name>`."));
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Set the per-org default orchestrator cluster.
|
|
87
|
+
*
|
|
88
|
+
* Validates the cluster name against the org's connected clusters before
|
|
89
|
+
* writing it to `config.defaultClusters[orgId]`.
|
|
90
|
+
*/
|
|
91
|
+
async function orchestratorsUseCommand(clusterName, options) {
|
|
92
|
+
const ctx = await resolveOrgContext(options);
|
|
93
|
+
if (!ctx) return false;
|
|
94
|
+
const orchestrators = await fetchOrchestrators(ctx.config, ctx.orgId);
|
|
95
|
+
if (orchestrators === null) return false;
|
|
96
|
+
if (!orchestrators.find((o) => o.clusterName === clusterName)) {
|
|
97
|
+
console.error(pc.red(`Orchestrator cluster not found: ${clusterName}`));
|
|
98
|
+
const named = orchestrators.map((o) => o.clusterName).filter((n) => !!n);
|
|
99
|
+
if (named.length > 0) {
|
|
100
|
+
console.error(pc.gray("Connected clusters:"));
|
|
101
|
+
for (const n of named) console.error(pc.gray(` - ${n}`));
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
await mergeGlobalConfig({ defaultClusters: {
|
|
106
|
+
...ctx.config.defaultClusters ?? {},
|
|
107
|
+
[ctx.orgId]: clusterName
|
|
108
|
+
} });
|
|
109
|
+
console.log(pc.green(`Default orchestrator for ${ctx.orgId} set to: ${clusterName}`));
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { orchestratorsListCommand, orchestratorsUseCommand };
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=orchestrators.js.map
|
package/dist/commands/org.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kici reject command
|
|
3
|
+
*
|
|
4
|
+
* Rejects a held approval gate for a run (requires `--reason`). Resolves the
|
|
5
|
+
* held element by `--job` / `--step` (or the sole pending hold), then records
|
|
6
|
+
* the rejection via the Platform dashboard API (PAT auth).
|
|
7
|
+
*/
|
|
8
|
+
/** Options for the reject command. */
|
|
9
|
+
export interface RejectOptions {
|
|
10
|
+
/** Match a hold by its job name. */
|
|
11
|
+
job?: string;
|
|
12
|
+
/** Match a step-scoped hold by its step index. */
|
|
13
|
+
step?: string;
|
|
14
|
+
/** Required rejection reason. */
|
|
15
|
+
reason?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reject a held approval gate.
|
|
19
|
+
*
|
|
20
|
+
* @param runId - The run whose hold to reject.
|
|
21
|
+
* @param options - Job/step filters plus the required reason.
|
|
22
|
+
* @returns true on success, false on error.
|
|
23
|
+
*/
|
|
24
|
+
export declare function rejectCommand(runId: string, options?: RejectOptions): Promise<boolean>;
|
|
25
|
+
//# sourceMappingURL=reject.d.ts.map
|