@kici-dev/compiler 0.1.13 → 0.1.15
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/README.md +21 -1
- package/dist/cli.js +27 -22
- package/dist/commands/cancel.js +1 -1
- package/dist/commands/compile.js +1 -1
- package/dist/commands/docs.js +1 -1
- package/dist/commands/drain-worker.js +1 -1
- package/dist/commands/endpoints.js +1 -1
- package/dist/commands/fixture.js +3 -3
- package/dist/commands/hook.js +1 -1
- package/dist/commands/index.js +6 -6
- package/dist/commands/init.js +9 -7
- package/dist/commands/login.js +5 -16
- package/dist/commands/run.js +19 -8
- package/dist/commands/secrets-list.js +2 -2
- package/dist/commands/status.js +4 -4
- package/dist/commands/test.d.ts +2 -0
- package/dist/commands/test.js +2 -2
- package/dist/commands/types.js +1 -1
- package/dist/commands/watch.js +1 -1
- package/dist/commands/workflows.js +3 -3
- package/dist/execution/executor.js +6 -3
- package/dist/execution/sdk-alias.js +1 -1
- package/dist/execution/ts-loader.d.ts +2 -0
- package/dist/execution/ts-loader.js +13 -0
- package/dist/fixtures/compiler.d.ts +7 -5
- package/dist/fixtures/compiler.js +10 -6
- package/dist/llm-context/llms-full.txt +1077 -387
- package/dist/llm-context/llms.txt +38 -37
- package/dist/local-executor/index.js +6 -5
- package/dist/local-executor/job-runner.js +6 -5
- package/dist/local-executor/materializer.d.ts +5 -0
- package/dist/local-executor/materializer.js +22 -1
- package/dist/local-executor/output-streamer.js +1 -1
- package/dist/local-executor/picker.js +1 -1
- package/dist/local-executor/to-event-payload.d.ts +16 -0
- package/dist/local-executor/to-event-payload.js +21 -0
- package/dist/local-executor/workflow-lock.d.ts +4 -3
- package/dist/local-executor/workflow-lock.js +0 -0
- package/dist/lockfile/generator.js +11 -6
- package/dist/lockfile/hasher.js +1 -1
- package/dist/remote/client.d.ts +4 -0
- package/dist/remote/client.js +1 -1
- package/dist/remote/encryption.d.ts +1 -1
- package/dist/remote/encryption.js +1 -1
- 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/streaming.js +1 -1
- package/dist/remote/output/summary.js +1 -1
- package/dist/remote/prod-defaults.d.ts +18 -0
- package/dist/remote/prod-defaults.js +23 -0
- package/dist/remote/secret-upload.d.ts +20 -0
- package/dist/remote/secret-upload.js +58 -0
- package/dist/remote/uploader.js +1 -1
- package/dist/templates/index.js +1 -1
- package/dist/templates/package-json.js +1 -1
- package/dist/templates/workflows/pr-checks.js +3 -2
- package/dist/templates/workflows/pr-checks.ts +4 -2
- package/dist/test-runner/dry-run.js +1 -1
- package/dist/test-runner/index.js +4 -4
- package/dist/test-runner/job-executor.js +1 -1
- package/dist/test-runner/output-formatter.js +1 -1
- package/dist/test-runner/payload-builder.js +2 -2
- package/dist/test-runner/rule-evaluator.js +1 -1
- package/dist/test-runner/step-context.js +6 -2
- package/dist/types.d.ts +17 -1
- package/dist/types.js +1 -0
- package/dist/workflows/pr-checks.ts +4 -2
- package/package.json +13 -9
- package/sbom.spdx.json +1328 -8436
|
@@ -2,61 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
> KiCI is a TypeScript-native CI/CD workflow engine. Workflows are defined in TypeScript (not YAML), compiled into a portable lock file, and executed by self-hosted agents. The docs below cover the SDK, the CLI, workflow patterns, and the runtime architecture an LLM coding agent needs in order to author and test KiCI workflows.
|
|
4
4
|
|
|
5
|
-
The full markdown bundle of every page indexed here is available at https://kici.dev/llms-full.txt.
|
|
5
|
+
The full markdown bundle of every page indexed here is available at https://docs.kici.dev/llms-full.txt.
|
|
6
6
|
|
|
7
7
|
## Getting started
|
|
8
8
|
|
|
9
|
-
- [User guide](https://kici.dev/
|
|
10
|
-
- [Getting started with KiCI](https://kici.dev/
|
|
11
|
-
- [5-minute quickstart](https://kici.dev/
|
|
9
|
+
- [User guide](https://docs.kici.dev/user/): Writing and testing CI/CD workflows in TypeScript
|
|
10
|
+
- [Getting started with KiCI](https://docs.kici.dev/user/getting-started/): Install the SDK, write your first workflow, compile and test locally
|
|
11
|
+
- [5-minute quickstart](https://docs.kici.dev/user/quickstart/): Stand up a KiCI orchestrator + agent and run your first workflow
|
|
12
12
|
|
|
13
13
|
## Workflow patterns
|
|
14
14
|
|
|
15
|
-
- [Basic workflow patterns](https://kici.dev/
|
|
16
|
-
- [Conditionals & matrix patterns](https://kici.dev/
|
|
17
|
-
- [Integration patterns](https://kici.dev/
|
|
18
|
-
- [Pattern reference](https://kici.dev/
|
|
19
|
-
- [Scheduling & event patterns](https://kici.dev/
|
|
15
|
+
- [Basic workflow patterns](https://docs.kici.dev/user/patterns/basic/): Basic CI, PR-only / push-only filters, multiple triggers, manual-only workflows
|
|
16
|
+
- [Conditionals & matrix patterns](https://docs.kici.dev/user/patterns/conditionals-matrix/): Conditional execution with rules, matrix builds (static + dynamic), dynamic job generation
|
|
17
|
+
- [Integration patterns](https://docs.kici.dev/user/patterns/integrations/): Workflow chaining, generic webhooks, Stripe, self-hosted git forges, plain GitHub repos
|
|
18
|
+
- [Pattern reference](https://docs.kici.dev/user/patterns/reference/): Step context, examples repository, GitHub check run output — cross-cutting reference for all patterns
|
|
19
|
+
- [Scheduling & event patterns](https://docs.kici.dev/user/patterns/scheduling-and-events/): Nightly cron, workflow-complete-triggered deploys, custom event chaining
|
|
20
20
|
|
|
21
21
|
## SDK reference
|
|
22
22
|
|
|
23
|
-
- [
|
|
24
|
-
- [SDK reference:
|
|
25
|
-
- [
|
|
26
|
-
- [SDK reference:
|
|
27
|
-
- [SDK reference:
|
|
28
|
-
- [SDK reference:
|
|
29
|
-
- [SDK reference:
|
|
30
|
-
- [SDK reference](https://kici.dev/
|
|
23
|
+
- [Caching](https://docs.kici.dev/user/sdk/caching/): Cache files and directories across runs with declarative job/step cache or the imperative ctx.cache API
|
|
24
|
+
- [SDK reference: core](https://docs.kici.dev/user/sdk/core/): Factory functions (workflow, job, step) and authoring patterns: needs, output chaining, dynamic groups
|
|
25
|
+
- [Event payload reference](https://docs.kici.dev/user/sdk/event-payloads/): Generated schema of the normalized event envelope passed to rules and dynamic functions.
|
|
26
|
+
- [SDK reference: idempotent](https://docs.kici.dev/user/sdk/idempotent/): Idempotent helpers for declarative check / apply patterns inside workflow steps
|
|
27
|
+
- [SDK reference: rules, matrix, dynamic jobs](https://docs.kici.dev/user/sdk/rules-matrix-dynamic/): rule(), skip(), matrix builds (static + dynamic), and dynamicJob / dynamicGroup
|
|
28
|
+
- [SDK reference: runtime](https://docs.kici.dev/user/sdk/runtime/): Types index, StepContext, secrets, fixtures
|
|
29
|
+
- [SDK reference: triggers](https://docs.kici.dev/user/sdk/triggers/): GitHub event triggers, kiciEvent, workflowComplete, jobComplete, genericWebhook, schedule, lifecycle
|
|
30
|
+
- [SDK reference: validation & events](https://docs.kici.dev/user/sdk/validation-events/): validateDag(), event definitions, and event emission
|
|
31
|
+
- [SDK reference: waitFor](https://docs.kici.dev/user/sdk/wait-for/): Polling helpers for steps that pause until an external condition becomes true
|
|
32
|
+
- [SDK reference](https://docs.kici.dev/user/sdk-reference/): Complete API reference for @kici-dev/sdk -- workflows, jobs, steps, triggers, rules, matrix, validation, runtime
|
|
31
33
|
|
|
32
34
|
## CLI and authoring
|
|
33
35
|
|
|
34
|
-
- [CLI authentication](https://kici.dev/
|
|
35
|
-
- [CLI reference](https://kici.dev/
|
|
36
|
-
- [Lifecycle hooks](https://kici.dev/
|
|
37
|
-
- [Lock file and workflow drift](https://kici.dev/
|
|
38
|
-
- [Testing guide](https://kici.dev/
|
|
39
|
-
- [Workflow patterns](https://kici.dev/
|
|
36
|
+
- [CLI authentication](https://docs.kici.dev/user/cli-auth/): Authenticate the KiCI CLI with browser OAuth, device flow, or API key paste
|
|
37
|
+
- [CLI reference](https://docs.kici.dev/user/cli-reference/): All CLI commands: compile, run (local/remote), test, login, logout, org, status, cancel, secrets, types, fixture, init, hook, endpoints, workflows, docs, admin
|
|
38
|
+
- [Lifecycle hooks](https://docs.kici.dev/user/hooks/): SDK hook API for cancel, cleanup, success, failure, and step-level callbacks
|
|
39
|
+
- [Lock file and workflow drift](https://docs.kici.dev/user/lock-file-and-drift/): Keep the lock file in sync with your workflow source and avoid drift
|
|
40
|
+
- [Testing guide](https://docs.kici.dev/user/testing-guide/): Running remote test fixtures with kici run remote
|
|
41
|
+
- [Workflow patterns](https://docs.kici.dev/user/workflow-patterns/): Common patterns: monorepo builds, conditional jobs, dynamic matrices, generic webhooks, scheduling
|
|
40
42
|
|
|
41
43
|
## Workflow features
|
|
42
44
|
|
|
43
|
-
- [Concurrency groups](https://kici.dev/
|
|
44
|
-
- [Dashboard](https://kici.dev/
|
|
45
|
-
- [Dynamic values](https://kici.dev/
|
|
46
|
-
- [Environment variables](https://kici.dev/
|
|
47
|
-
- [Environments](https://kici.dev/
|
|
48
|
-
- [Event system](https://kici.dev/
|
|
49
|
-
- [Global workflows](https://kici.dev/
|
|
50
|
-
- [Private npm registries](https://kici.dev/
|
|
51
|
-
- [Secrets](https://kici.dev/
|
|
45
|
+
- [Concurrency groups](https://docs.kici.dev/user/concurrency/): Control parallel execution with auto-cancel and queue modes
|
|
46
|
+
- [Dashboard](https://docs.kici.dev/user/dashboard/)
|
|
47
|
+
- [Dynamic values](https://docs.kici.dev/user/dynamic-values/)
|
|
48
|
+
- [Environment variables](https://docs.kici.dev/user/env-vars/): KICI_* environment variable reference for the CLI
|
|
49
|
+
- [Environments](https://docs.kici.dev/user/environments/): Configure deployment environments with variables, secrets, and protection rules
|
|
50
|
+
- [Event system](https://docs.kici.dev/user/events/): How KiCI's event model works -- event types, the registration model, event matching, and circuit breaker protection
|
|
51
|
+
- [Global workflows](https://docs.kici.dev/user/global-workflows/): Cross-repo workflows that run on events from any repo in the same org
|
|
52
|
+
- [Private npm registries](https://docs.kici.dev/user/private-registries/): Authenticate `npm install` against private registries (CodeArtifact, GitHub Packages, Verdaccio, …) from a workflow's `.kici/package.json`
|
|
53
|
+
- [Secrets](https://docs.kici.dev/user/secrets/): How to access secrets in KiCI workflow steps
|
|
52
54
|
|
|
53
55
|
## Providers
|
|
54
56
|
|
|
55
|
-
- [GitHub App provider](https://kici.dev/
|
|
56
|
-
- [Universal-git provider](https://kici.dev/
|
|
57
|
+
- [GitHub App provider](https://docs.kici.dev/user/providers/github/): Connect KiCI to GitHub via a GitHub App — full Checks API, installation-token clones, and cross-org dispatch
|
|
58
|
+
- [Universal-git provider](https://docs.kici.dev/user/providers/universal-git/): Connect Forgejo, Gitea, Gogs, GitLab, or plain GitHub via webhook + PAT or SSH deploy key
|
|
57
59
|
|
|
58
60
|
## Architecture overview
|
|
59
61
|
|
|
60
|
-
- [Data flows](https://kici.dev/
|
|
61
|
-
- [
|
|
62
|
-
- [Architecture overview](https://kici.dev/docs/architecture/overview/): Three-tier relay model, package structure, and component responsibilities
|
|
62
|
+
- [Data flows](https://docs.kici.dev/architecture/data-flows/): End-to-end data flows through the KiCI three-tier architecture
|
|
63
|
+
- [Architecture overview](https://docs.kici.dev/architecture/overview/): Three-tier relay model, package structure, and component responsibilities
|
|
@@ -2,19 +2,19 @@ import "../chunk-gOLHoazu.js";
|
|
|
2
2
|
import { discoverWorkflows, resolveKiciDir } from "../execution/executor.js";
|
|
3
3
|
import "../execution/index.js";
|
|
4
4
|
import { transformTriggers } from "../lockfile/generator.js";
|
|
5
|
-
import { compileCommand } from "../commands/compile.js";
|
|
6
|
-
import { executeDag, resolveJobFilter } from "./dag-scheduler.js";
|
|
7
5
|
import { loadLocalSecrets } from "./secret-loader.js";
|
|
6
|
+
import { executeDag, resolveJobFilter } from "./dag-scheduler.js";
|
|
7
|
+
import { compileCommand } from "../commands/compile.js";
|
|
8
8
|
import { generateEventPayload } from "./payload-generator.js";
|
|
9
9
|
import { executeResolvedJob, resolveJobs } from "./job-runner.js";
|
|
10
10
|
import { displayLocalSummary, formatLocalJsonResult, formatLocalJunitResult } from "./output-streamer.js";
|
|
11
11
|
import { PickerCancelledError, runPicker } from "./picker.js";
|
|
12
|
-
import { materializeCheckout } from "./materializer.js";
|
|
12
|
+
import { gcStaleRunCheckouts, materializeCheckout } from "./materializer.js";
|
|
13
13
|
import { ConcurrencyKeyEvaluationError, acquireWorkflowLock } from "./workflow-lock.js";
|
|
14
14
|
import pc from "picocolors";
|
|
15
15
|
import { writeFile } from "node:fs/promises";
|
|
16
16
|
import path from "node:path";
|
|
17
|
-
import { logger } from "@kici-dev/
|
|
17
|
+
import { logger } from "@kici-dev/core";
|
|
18
18
|
import { matchAllWorkflows } from "@kici-dev/engine";
|
|
19
19
|
import os from "node:os";
|
|
20
20
|
//#region src/local-executor/index.ts
|
|
@@ -107,7 +107,7 @@ async function runOneMatchedWorkflow(workflow, ctx) {
|
|
|
107
107
|
lockHandle = await acquireWorkflowLock({
|
|
108
108
|
workflowName: workflow.name,
|
|
109
109
|
workflow,
|
|
110
|
-
event
|
|
110
|
+
event,
|
|
111
111
|
branch: deriveBranchForGroupCtx(event),
|
|
112
112
|
debug: options.debug
|
|
113
113
|
});
|
|
@@ -272,6 +272,7 @@ async function executeLocal(options) {
|
|
|
272
272
|
let materialized = null;
|
|
273
273
|
let execDir = repoRoot;
|
|
274
274
|
if (!options.inPlace) {
|
|
275
|
+
await gcStaleRunCheckouts(process.env.KICI_RUN_DIR ?? os.tmpdir());
|
|
275
276
|
materialized = await materializeCheckout(repoRoot, { runDir: process.env.KICI_RUN_DIR });
|
|
276
277
|
execDir = materialized.path;
|
|
277
278
|
logger.info(pc.gray(`running in ${execDir}`));
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "../chunk-gOLHoazu.js";
|
|
2
|
+
import { ensureTsLoaderHook } from "../execution/ts-loader.js";
|
|
2
3
|
import { formatter } from "../test-runner/output-formatter.js";
|
|
3
4
|
import { createStepContext } from "../test-runner/step-context.js";
|
|
4
5
|
import { createRuleContext, evaluateRules as evaluateRulesWithFormatting } from "../test-runner/rule-evaluator.js";
|
|
6
|
+
import { toEventPayload } from "./to-event-payload.js";
|
|
5
7
|
import path from "node:path";
|
|
6
8
|
import { pathToFileURL } from "node:url";
|
|
7
9
|
import { applyIncludeExclude, expandMatrix, isDynamicJobFn, setJobOutputsMap, setStepOutputsMap, setStepRefMap } from "@kici-dev/sdk";
|
|
@@ -21,7 +23,9 @@ import { applyIncludeExclude, expandMatrix, isDynamicJobFn, setJobOutputsMap, se
|
|
|
21
23
|
*/
|
|
22
24
|
async function resolveSdkSetters(kiciDir) {
|
|
23
25
|
if (kiciDir) try {
|
|
24
|
-
const
|
|
26
|
+
const sdkUrl = pathToFileURL(path.join(kiciDir, "node_modules", "@kici-dev", "sdk", "dist", "index.js")).href;
|
|
27
|
+
ensureTsLoaderHook();
|
|
28
|
+
const sdk = await import(sdkUrl);
|
|
25
29
|
return {
|
|
26
30
|
setStepOutputsMap: sdk.setStepOutputsMap,
|
|
27
31
|
setStepRefMap: sdk.setStepRefMap,
|
|
@@ -69,10 +73,7 @@ async function resolveJobs(workflow, event) {
|
|
|
69
73
|
$: (await import("zx")).$,
|
|
70
74
|
ctx: {
|
|
71
75
|
workflow: { name: workflow.name },
|
|
72
|
-
event:
|
|
73
|
-
type: event.type,
|
|
74
|
-
...event.payload
|
|
75
|
-
}
|
|
76
|
+
event: toEventPayload(event)
|
|
76
77
|
},
|
|
77
78
|
log: {
|
|
78
79
|
info: () => {},
|
|
@@ -36,4 +36,9 @@ export interface MaterializeOptions {
|
|
|
36
36
|
* @throws If `repoRoot` is not inside a git work tree
|
|
37
37
|
*/
|
|
38
38
|
export declare function materializeCheckout(repoRoot: string, opts?: MaterializeOptions): Promise<MaterializedCheckout>;
|
|
39
|
+
/**
|
|
40
|
+
* Collect stale retained checkouts under the run base. Invoked on every
|
|
41
|
+
* `kici run local`; never throws (the GC must not break the run).
|
|
42
|
+
*/
|
|
43
|
+
export declare function gcStaleRunCheckouts(base: string): Promise<string[]>;
|
|
39
44
|
//# sourceMappingURL=materializer.d.ts.map
|
|
@@ -2,9 +2,11 @@ import "../chunk-gOLHoazu.js";
|
|
|
2
2
|
import { selectOverlayFiles } from "../remote/uploader.js";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { logger } from "@kici-dev/core";
|
|
5
6
|
import { execSync } from "node:child_process";
|
|
6
7
|
import os from "node:os";
|
|
7
8
|
import { randomBytes } from "node:crypto";
|
|
9
|
+
import { gcStaleTmpDirs } from "@kici-dev/core/tmp-gc";
|
|
8
10
|
//#region src/local-executor/materializer.ts
|
|
9
11
|
/**
|
|
10
12
|
* Materialize an isolated tmp checkout of the repo for `kici run local`.
|
|
@@ -52,6 +54,25 @@ async function materializeCheckout(repoRoot, opts) {
|
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
57
|
+
* Checkouts retained for inspection (failed runs, --keep) stay around this
|
|
58
|
+
* long before the next `kici run local` invocation collects them.
|
|
59
|
+
*/
|
|
60
|
+
const RUN_CHECKOUT_GC_MAX_AGE_MS = 4320 * 60 * 1e3;
|
|
61
|
+
/** Matches the kici-run-<6 hex> dirs materializeCheckout creates — nothing else. */
|
|
62
|
+
const RUN_CHECKOUT_PATTERN = /^kici-run-[0-9a-f]{6}$/;
|
|
63
|
+
/**
|
|
64
|
+
* Collect stale retained checkouts under the run base. Invoked on every
|
|
65
|
+
* `kici run local`; never throws (the GC must not break the run).
|
|
66
|
+
*/
|
|
67
|
+
async function gcStaleRunCheckouts(base) {
|
|
68
|
+
return gcStaleTmpDirs({
|
|
69
|
+
base,
|
|
70
|
+
pattern: RUN_CHECKOUT_PATTERN,
|
|
71
|
+
maxAgeMs: RUN_CHECKOUT_GC_MAX_AGE_MS,
|
|
72
|
+
log: (m) => logger.debug(m)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
55
76
|
* Throw an actionable error if `repoRoot` is not a git work tree.
|
|
56
77
|
*/
|
|
57
78
|
function requireGitRepo(repoRoot) {
|
|
@@ -106,6 +127,6 @@ function shellQuote(value) {
|
|
|
106
127
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
107
128
|
}
|
|
108
129
|
//#endregion
|
|
109
|
-
export { materializeCheckout };
|
|
130
|
+
export { gcStaleRunCheckouts, materializeCheckout };
|
|
110
131
|
|
|
111
132
|
//# sourceMappingURL=materializer.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../chunk-gOLHoazu.js";
|
|
2
2
|
import pc from "picocolors";
|
|
3
|
-
import { logger } from "@kici-dev/
|
|
3
|
+
import { logger } from "@kici-dev/core";
|
|
4
4
|
//#region src/local-executor/output-streamer.ts
|
|
5
5
|
/**
|
|
6
6
|
* Output formatting for local execution: tree summary, JSON, JUnit XML.
|
|
@@ -2,7 +2,7 @@ import "../chunk-gOLHoazu.js";
|
|
|
2
2
|
import { transformTriggers } from "../lockfile/generator.js";
|
|
3
3
|
import { parseEventArg, triggerSummary, triggerToEventArg } from "../test-runner/event-types.js";
|
|
4
4
|
import pc from "picocolors";
|
|
5
|
-
import { logger } from "@kici-dev/
|
|
5
|
+
import { logger } from "@kici-dev/core";
|
|
6
6
|
import { select } from "@inquirer/prompts";
|
|
7
7
|
//#region src/local-executor/picker.ts
|
|
8
8
|
/**
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SimulatedEvent } from '@kici-dev/engine';
|
|
2
|
+
import type { EventPayload } from '@kici-dev/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Map a {@link SimulatedEvent} into the normalized SDK {@link EventPayload}
|
|
5
|
+
* envelope that every user-authored dynamic function (dynamic job generators,
|
|
6
|
+
* `concurrency.group()`) receives as its `event` argument.
|
|
7
|
+
*
|
|
8
|
+
* `SimulatedEvent` already carries the normalized fields (`type`, `action`,
|
|
9
|
+
* `targetBranch`, …) alongside the raw provider body under `payload`, so the
|
|
10
|
+
* single cast at this boundary is a deliberate type assertion over a
|
|
11
|
+
* structurally-identical value: it asserts the discriminated-union view
|
|
12
|
+
* without reshaping anything. Raw provider fields stay nested under
|
|
13
|
+
* `payload.<field>`; normalized fields live at the top level.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toEventPayload(event: SimulatedEvent): EventPayload;
|
|
16
|
+
//# sourceMappingURL=to-event-payload.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "../chunk-gOLHoazu.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
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* `os.tmpdir()/kici-local-locks-<uid>/`).
|
|
21
21
|
*/
|
|
22
22
|
import type { Workflow } from '@kici-dev/sdk';
|
|
23
|
+
import type { SimulatedEvent } from '@kici-dev/engine';
|
|
23
24
|
/** Sidecar metadata persisted next to the lock dir for diagnostics + reclamation. */
|
|
24
25
|
export interface LockHolderMetadata {
|
|
25
26
|
pid: number;
|
|
@@ -35,8 +36,8 @@ export interface WorkflowLockHandle {
|
|
|
35
36
|
export interface AcquireWorkflowLockOptions {
|
|
36
37
|
workflowName: string;
|
|
37
38
|
workflow: Workflow;
|
|
38
|
-
/** The simulated
|
|
39
|
-
event:
|
|
39
|
+
/** The simulated event mapped to the normalized envelope passed as `groupCtx.event`. */
|
|
40
|
+
event: SimulatedEvent;
|
|
40
41
|
/** Branch derived from the simulated event for `groupCtx.branch`. */
|
|
41
42
|
branch: string;
|
|
42
43
|
debug?: boolean;
|
|
@@ -68,7 +69,7 @@ export declare function resolveLockDir(): Promise<string>;
|
|
|
68
69
|
* Returns `null` when the workflow has no `concurrency` block. Throws
|
|
69
70
|
* {@link ConcurrencyKeyEvaluationError} when the group function throws or rejects.
|
|
70
71
|
*/
|
|
71
|
-
export declare function resolveConcurrencyKey(workflow: Workflow, event:
|
|
72
|
+
export declare function resolveConcurrencyKey(workflow: Workflow, event: SimulatedEvent, branch: string): Promise<string | null>;
|
|
72
73
|
/**
|
|
73
74
|
* Acquire the workflow-level concurrency lock for a `kici run local` invocation.
|
|
74
75
|
*
|
|
Binary file
|
|
@@ -5,11 +5,11 @@ import { resolveHashFiles } from "./hash-files.js";
|
|
|
5
5
|
import { analyzePurity } from "./purity-analyzer.js";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
|
-
import {
|
|
9
|
-
import { sha256 } from "@kici-dev/
|
|
10
|
-
import {
|
|
11
|
-
import { PackageManager, detectPackageManagerSync } from "@kici-dev/shared/package-manager";
|
|
8
|
+
import { getDynamicJobGroup, isDynamicFunction, isDynamicGroupRef, isDynamicJobFn, isStaticArray, isStaticObject, normalizeCacheSpecs } from "@kici-dev/sdk";
|
|
9
|
+
import { sha256 } from "@kici-dev/core";
|
|
10
|
+
import { PackageManager, detectPackageManagerSync } from "@kici-dev/core/package-manager";
|
|
12
11
|
import { validateResourceRequest } from "@kici-dev/engine";
|
|
12
|
+
import { execSync } from "node:child_process";
|
|
13
13
|
//#region src/lockfile/generator.ts
|
|
14
14
|
/**
|
|
15
15
|
* Detect git repository root by running `git rev-parse --show-toplevel`.
|
|
@@ -151,7 +151,8 @@ function transformWorkflow(workflow, sourceFile, exportRef, bundleSource, gitRoo
|
|
|
151
151
|
hasGroup: !!workflow.concurrency.group,
|
|
152
152
|
...workflow.concurrency.cancelInProgress !== void 0 && { cancelInProgress: workflow.concurrency.cancelInProgress },
|
|
153
153
|
...workflow.concurrency.max !== void 0 && { max: workflow.concurrency.max }
|
|
154
|
-
} }
|
|
154
|
+
} },
|
|
155
|
+
...workflow.timeout !== void 0 && { timeout: workflow.timeout }
|
|
155
156
|
};
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
@@ -528,6 +529,7 @@ function transformJob(job, configPath, index, gitRoot, uuidToName) {
|
|
|
528
529
|
rules: job.rules ? transformRules(job.rules, configPath, index) : void 0,
|
|
529
530
|
description: job.description,
|
|
530
531
|
...job.checkout !== void 0 && { checkout: job.checkout },
|
|
532
|
+
...job.cache !== void 0 && { cache: normalizeCacheSpecs(job.cache) },
|
|
531
533
|
...job.container !== void 0 && { container: job.container },
|
|
532
534
|
...environmentFields,
|
|
533
535
|
...envFields,
|
|
@@ -539,7 +541,9 @@ function transformJob(job, configPath, index, gitRoot, uuidToName) {
|
|
|
539
541
|
...job.beforeStep !== void 0 && { hasBeforeStep: true },
|
|
540
542
|
...job.afterStep !== void 0 && { hasAfterStep: true },
|
|
541
543
|
...job.gracePeriod !== void 0 && { gracePeriod: job.gracePeriod },
|
|
542
|
-
...job.
|
|
544
|
+
...job.timeout !== void 0 && { timeout: job.timeout },
|
|
545
|
+
...job.resources !== void 0 && { resources: job.resources },
|
|
546
|
+
...job.init !== void 0 && { init: job.init }
|
|
543
547
|
};
|
|
544
548
|
}
|
|
545
549
|
/**
|
|
@@ -603,6 +607,7 @@ function transformSteps(steps, gitRoot) {
|
|
|
603
607
|
hasOutputs: !!step.outputs && Object.keys(step.outputs).length > 0,
|
|
604
608
|
...step.continueOnError !== void 0 && { continueOnError: step.continueOnError },
|
|
605
609
|
...step.timeout !== void 0 && { timeout: step.timeout },
|
|
610
|
+
...step.cache !== void 0 && { cache: normalizeCacheSpecs(step.cache) },
|
|
606
611
|
...step._sourceLocation && { sourceLocation: {
|
|
607
612
|
file: makeRelativePath(step._sourceLocation.file, gitRoot),
|
|
608
613
|
line: step._sourceLocation.line,
|
package/dist/lockfile/hasher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../chunk-gOLHoazu.js";
|
|
2
|
-
import { normalizeLineEndings, sha256 } from "@kici-dev/
|
|
2
|
+
import { normalizeLineEndings, sha256 } from "@kici-dev/core";
|
|
3
3
|
//#region src/lockfile/hasher.ts
|
|
4
4
|
/**
|
|
5
5
|
* Compile schema version -- bump when compilation approach changes
|
package/dist/remote/client.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ export interface TestTriggerInput {
|
|
|
33
33
|
/** CLI's ephemeral public key (base64, SPKI/DER) for overlay decryption */
|
|
34
34
|
cliPublicKey?: string;
|
|
35
35
|
secrets?: Record<string, string>;
|
|
36
|
+
/** Base64 X25519+AES-GCM blob of the developer's local secrets ({flat, contexts}). */
|
|
37
|
+
encryptedSecrets?: string;
|
|
38
|
+
/** Base64 ephemeral CLI public key that encrypted `encryptedSecrets`. */
|
|
39
|
+
encryptedSecretsKey?: string;
|
|
36
40
|
workflowName?: string;
|
|
37
41
|
/** JSON-stringified lock file content for repos with no remote. */
|
|
38
42
|
inlineLockFile?: string;
|
package/dist/remote/client.js
CHANGED
package/dist/remote/history.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../chunk-gOLHoazu.js";
|
|
2
|
-
import { getConfigDir } from "./config.js";
|
|
3
2
|
import { formatRelativeTime } from "../format.js";
|
|
3
|
+
import { getConfigDir } from "./config.js";
|
|
4
4
|
import pc from "picocolors";
|
|
5
5
|
import fs from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { formatDuration } from "@kici-dev/
|
|
7
|
+
import { formatDuration } from "@kici-dev/core";
|
|
8
8
|
import picomatch from "picomatch";
|
|
9
9
|
//#region src/remote/history.ts
|
|
10
10
|
/**
|
package/dist/remote/oauth.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../chunk-gOLHoazu.js";
|
|
2
2
|
import { discoverOidcEndpoints } from "./oidc-discovery.js";
|
|
3
3
|
import pc from "picocolors";
|
|
4
|
+
import { toErrorMessage } from "@kici-dev/core";
|
|
4
5
|
import { exec } from "node:child_process";
|
|
5
|
-
import { toErrorMessage } from "@kici-dev/shared";
|
|
6
6
|
import { createHash, randomBytes } from "node:crypto";
|
|
7
7
|
import { createServer } from "node:http";
|
|
8
8
|
import open from "open";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../chunk-gOLHoazu.js";
|
|
2
2
|
import pc from "picocolors";
|
|
3
|
-
import { formatDuration } from "@kici-dev/
|
|
3
|
+
import { formatDuration } from "@kici-dev/core";
|
|
4
4
|
//#region src/remote/output/streaming.ts
|
|
5
5
|
/**
|
|
6
6
|
* Real-time log streaming output formatter for CLI observer.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production defaults for the `kici login` OAuth flow. When the matching
|
|
3
|
+
* env var (or the `--platform-endpoint` flag) is unset, login resolves
|
|
4
|
+
* these so a developer targeting the hosted KiCI Platform authenticates
|
|
5
|
+
* with no setup. Setting the env var overrides the default — staging E2E
|
|
6
|
+
* and self-hosted Platforms depend on that override path.
|
|
7
|
+
*
|
|
8
|
+
* Resolution is login-local: these are read into locals in `oauthLogin`,
|
|
9
|
+
* never written back into `process.env`, so the orchestrator's separate
|
|
10
|
+
* `wss://…/ws` meaning of `KICI_PLATFORM_URL` is unaffected.
|
|
11
|
+
*/
|
|
12
|
+
/** Platform API base URL — login POSTs to `${value}/api/v1/cli/exchange-token`. */
|
|
13
|
+
export declare const PROD_PLATFORM_URL = "https://api.kici.dev";
|
|
14
|
+
/** OIDC issuer for the hosted Platform's Keycloak realm. */
|
|
15
|
+
export declare const PROD_OIDC_ISSUER = "https://auth.kici.dev/realms/kici-internal";
|
|
16
|
+
/** Public OIDC client id registered for the `kici` CLI. */
|
|
17
|
+
export declare const PROD_OIDC_CLIENT_ID = "kici-cli";
|
|
18
|
+
//# sourceMappingURL=prod-defaults.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "../chunk-gOLHoazu.js";
|
|
2
|
+
//#region src/remote/prod-defaults.ts
|
|
3
|
+
/**
|
|
4
|
+
* Production defaults for the `kici login` OAuth flow. When the matching
|
|
5
|
+
* env var (or the `--platform-endpoint` flag) is unset, login resolves
|
|
6
|
+
* these so a developer targeting the hosted KiCI Platform authenticates
|
|
7
|
+
* with no setup. Setting the env var overrides the default — staging E2E
|
|
8
|
+
* and self-hosted Platforms depend on that override path.
|
|
9
|
+
*
|
|
10
|
+
* Resolution is login-local: these are read into locals in `oauthLogin`,
|
|
11
|
+
* never written back into `process.env`, so the orchestrator's separate
|
|
12
|
+
* `wss://…/ws` meaning of `KICI_PLATFORM_URL` is unaffected.
|
|
13
|
+
*/
|
|
14
|
+
/** Platform API base URL — login POSTs to `${value}/api/v1/cli/exchange-token`. */
|
|
15
|
+
const PROD_PLATFORM_URL = "https://api.kici.dev";
|
|
16
|
+
/** OIDC issuer for the hosted Platform's Keycloak realm. */
|
|
17
|
+
const PROD_OIDC_ISSUER = "https://auth.kici.dev/realms/kici-internal";
|
|
18
|
+
/** Public OIDC client id registered for the `kici` CLI. */
|
|
19
|
+
const PROD_OIDC_CLIENT_ID = "kici-cli";
|
|
20
|
+
//#endregion
|
|
21
|
+
export { PROD_OIDC_CLIENT_ID, PROD_OIDC_ISSUER, PROD_PLATFORM_URL };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=prod-defaults.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse `--context ctx.key=value` flag values into a nested
|
|
3
|
+
* `{ context: { key: value } }` map. The first `.` splits the context name
|
|
4
|
+
* from `key=value`; the first `=` splits key from value (values may contain
|
|
5
|
+
* `=`). Malformed entries (missing `.` or `=`, empty context/key) are skipped.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseContextFlags(flags: string[] | undefined): Record<string, Record<string, string>>;
|
|
8
|
+
/**
|
|
9
|
+
* Load the developer's local secrets (same sources as `kici run local`: the
|
|
10
|
+
* `.kici` secret files plus `--env` flat flags) and `--context` namespaced
|
|
11
|
+
* flags, and encrypt them to the orchestrator's per-upload X25519 public key.
|
|
12
|
+
* `--context` values override `.kici/.secrets` file contexts for the same key.
|
|
13
|
+
* Returns the base64 ciphertext and the ephemeral CLI public key the
|
|
14
|
+
* orchestrator needs to decrypt, or null when there is nothing to send.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildEncryptedSecrets(kiciDir: string, envFlags: string[] | undefined, contextFlags: string[] | undefined, orchestratorPublicKeyB64: string): Promise<{
|
|
17
|
+
encryptedSecrets: string;
|
|
18
|
+
cliPublicKey: string;
|
|
19
|
+
} | null>;
|
|
20
|
+
//# sourceMappingURL=secret-upload.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import "../chunk-gOLHoazu.js";
|
|
2
|
+
import { loadLocalSecrets } from "../local-executor/secret-loader.js";
|
|
3
|
+
import { encryptJson } from "@kici-dev/core";
|
|
4
|
+
//#region src/remote/secret-upload.ts
|
|
5
|
+
/**
|
|
6
|
+
* Parse `--context ctx.key=value` flag values into a nested
|
|
7
|
+
* `{ context: { key: value } }` map. The first `.` splits the context name
|
|
8
|
+
* from `key=value`; the first `=` splits key from value (values may contain
|
|
9
|
+
* `=`). Malformed entries (missing `.` or `=`, empty context/key) are skipped.
|
|
10
|
+
*/
|
|
11
|
+
function parseContextFlags(flags) {
|
|
12
|
+
const contexts = {};
|
|
13
|
+
for (const flag of flags ?? []) {
|
|
14
|
+
const dotIndex = flag.indexOf(".");
|
|
15
|
+
if (dotIndex === -1) continue;
|
|
16
|
+
const contextName = flag.slice(0, dotIndex).trim();
|
|
17
|
+
const rest = flag.slice(dotIndex + 1);
|
|
18
|
+
const eqIndex = rest.indexOf("=");
|
|
19
|
+
if (eqIndex === -1) continue;
|
|
20
|
+
const key = rest.slice(0, eqIndex).trim();
|
|
21
|
+
const value = rest.slice(eqIndex + 1).trim();
|
|
22
|
+
if (!contextName || !key) continue;
|
|
23
|
+
(contexts[contextName] ??= {})[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return contexts;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load the developer's local secrets (same sources as `kici run local`: the
|
|
29
|
+
* `.kici` secret files plus `--env` flat flags) and `--context` namespaced
|
|
30
|
+
* flags, and encrypt them to the orchestrator's per-upload X25519 public key.
|
|
31
|
+
* `--context` values override `.kici/.secrets` file contexts for the same key.
|
|
32
|
+
* Returns the base64 ciphertext and the ephemeral CLI public key the
|
|
33
|
+
* orchestrator needs to decrypt, or null when there is nothing to send.
|
|
34
|
+
*/
|
|
35
|
+
async function buildEncryptedSecrets(kiciDir, envFlags, contextFlags, orchestratorPublicKeyB64) {
|
|
36
|
+
const local = await loadLocalSecrets(kiciDir, envFlags);
|
|
37
|
+
const contexts = {};
|
|
38
|
+
for (const [ctxName, vals] of Object.entries(local.contexts)) contexts[ctxName] = { ...vals };
|
|
39
|
+
for (const [ctxName, vals] of Object.entries(parseContextFlags(contextFlags))) contexts[ctxName] = {
|
|
40
|
+
...contexts[ctxName] ?? {},
|
|
41
|
+
...vals
|
|
42
|
+
};
|
|
43
|
+
const hasFlat = Object.keys(local.flat).length > 0;
|
|
44
|
+
const hasContexts = Object.values(contexts).some((c) => Object.keys(c).length > 0);
|
|
45
|
+
if (!hasFlat && !hasContexts) return null;
|
|
46
|
+
const { ciphertextB64, senderPublicKeyB64 } = encryptJson({
|
|
47
|
+
flat: local.flat,
|
|
48
|
+
contexts
|
|
49
|
+
}, Buffer.from(orchestratorPublicKeyB64, "base64"));
|
|
50
|
+
return {
|
|
51
|
+
encryptedSecrets: ciphertextB64,
|
|
52
|
+
cliPublicKey: senderPublicKeyB64
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { buildEncryptedSecrets, parseContextFlags };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=secret-upload.js.map
|
package/dist/remote/uploader.js
CHANGED
|
@@ -2,8 +2,8 @@ import "../chunk-gOLHoazu.js";
|
|
|
2
2
|
import { encryptTarball } from "./encryption.js";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { formatBytes, sha256, sha256File } from "@kici-dev/core";
|
|
5
6
|
import { execSync } from "node:child_process";
|
|
6
|
-
import { formatBytes, sha256, sha256File } from "@kici-dev/shared";
|
|
7
7
|
import os from "node:os";
|
|
8
8
|
import picomatch from "picomatch";
|
|
9
9
|
import { create } from "tar";
|