@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.
Files changed (70) hide show
  1. package/README.md +21 -1
  2. package/dist/cli.js +27 -22
  3. package/dist/commands/cancel.js +1 -1
  4. package/dist/commands/compile.js +1 -1
  5. package/dist/commands/docs.js +1 -1
  6. package/dist/commands/drain-worker.js +1 -1
  7. package/dist/commands/endpoints.js +1 -1
  8. package/dist/commands/fixture.js +3 -3
  9. package/dist/commands/hook.js +1 -1
  10. package/dist/commands/index.js +6 -6
  11. package/dist/commands/init.js +9 -7
  12. package/dist/commands/login.js +5 -16
  13. package/dist/commands/run.js +19 -8
  14. package/dist/commands/secrets-list.js +2 -2
  15. package/dist/commands/status.js +4 -4
  16. package/dist/commands/test.d.ts +2 -0
  17. package/dist/commands/test.js +2 -2
  18. package/dist/commands/types.js +1 -1
  19. package/dist/commands/watch.js +1 -1
  20. package/dist/commands/workflows.js +3 -3
  21. package/dist/execution/executor.js +6 -3
  22. package/dist/execution/sdk-alias.js +1 -1
  23. package/dist/execution/ts-loader.d.ts +2 -0
  24. package/dist/execution/ts-loader.js +13 -0
  25. package/dist/fixtures/compiler.d.ts +7 -5
  26. package/dist/fixtures/compiler.js +10 -6
  27. package/dist/llm-context/llms-full.txt +1077 -387
  28. package/dist/llm-context/llms.txt +38 -37
  29. package/dist/local-executor/index.js +6 -5
  30. package/dist/local-executor/job-runner.js +6 -5
  31. package/dist/local-executor/materializer.d.ts +5 -0
  32. package/dist/local-executor/materializer.js +22 -1
  33. package/dist/local-executor/output-streamer.js +1 -1
  34. package/dist/local-executor/picker.js +1 -1
  35. package/dist/local-executor/to-event-payload.d.ts +16 -0
  36. package/dist/local-executor/to-event-payload.js +21 -0
  37. package/dist/local-executor/workflow-lock.d.ts +4 -3
  38. package/dist/local-executor/workflow-lock.js +0 -0
  39. package/dist/lockfile/generator.js +11 -6
  40. package/dist/lockfile/hasher.js +1 -1
  41. package/dist/remote/client.d.ts +4 -0
  42. package/dist/remote/client.js +1 -1
  43. package/dist/remote/encryption.d.ts +1 -1
  44. package/dist/remote/encryption.js +1 -1
  45. package/dist/remote/history.js +2 -2
  46. package/dist/remote/oauth.js +1 -1
  47. package/dist/remote/oidc-discovery.js +1 -1
  48. package/dist/remote/output/streaming.js +1 -1
  49. package/dist/remote/output/summary.js +1 -1
  50. package/dist/remote/prod-defaults.d.ts +18 -0
  51. package/dist/remote/prod-defaults.js +23 -0
  52. package/dist/remote/secret-upload.d.ts +20 -0
  53. package/dist/remote/secret-upload.js +58 -0
  54. package/dist/remote/uploader.js +1 -1
  55. package/dist/templates/index.js +1 -1
  56. package/dist/templates/package-json.js +1 -1
  57. package/dist/templates/workflows/pr-checks.js +3 -2
  58. package/dist/templates/workflows/pr-checks.ts +4 -2
  59. package/dist/test-runner/dry-run.js +1 -1
  60. package/dist/test-runner/index.js +4 -4
  61. package/dist/test-runner/job-executor.js +1 -1
  62. package/dist/test-runner/output-formatter.js +1 -1
  63. package/dist/test-runner/payload-builder.js +2 -2
  64. package/dist/test-runner/rule-evaluator.js +1 -1
  65. package/dist/test-runner/step-context.js +6 -2
  66. package/dist/types.d.ts +17 -1
  67. package/dist/types.js +1 -0
  68. package/dist/workflows/pr-checks.ts +4 -2
  69. package/package.json +13 -9
  70. package/sbom.spdx.json +1328 -8436
package/README.md CHANGED
@@ -1 +1,21 @@
1
- TBD
1
+ # @kici-dev/compiler
2
+
3
+ Compiler and CLI for KiCI workflows. Compiles `.kici/workflows/*.ts` to a `kici.lock.json` file consumed by the orchestrator and agents, and runs workflows locally or against a remote orchestrator.
4
+
5
+ Part of [KiCI](https://kici.dev) — CI/CD workflows as TypeScript code: author them with full language power, dry-run them locally, and run them on your own infrastructure.
6
+
7
+ ## Install
8
+
9
+ Usually consumed through the [`kici`](https://www.npmjs.com/package/kici) wrapper CLI:
10
+
11
+ ```bash
12
+ npm install -g kici
13
+ ```
14
+
15
+ Direct install (`npm install --save-dev @kici-dev/compiler`) works too when you want the library API.
16
+
17
+ ## Links
18
+
19
+ - Documentation: <https://docs.kici.dev/user/cli-reference/>
20
+ - Source: <https://github.com/kici-dev/kici-public/tree/main/packages/compiler>
21
+ - License: Apache-2.0
package/dist/cli.js CHANGED
@@ -1,29 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import "./chunk-gOLHoazu.js";
3
3
  import { shouldSuppressBanner } from "./cli-banner.js";
4
- import { compileCommand } from "./commands/compile.js";
5
- import { watchCommand } from "./commands/watch.js";
6
- import { fixtureCommand } from "./commands/fixture.js";
7
- import { testCommand } from "./commands/test.js";
8
- import { runLocalCommand, runRemoteCommand } from "./commands/run.js";
9
- import { initCommand } from "./commands/init.js";
10
- import { hookInstallCommand } from "./commands/hook.js";
11
- import { loginCommand } from "./commands/login.js";
12
- import { secretsListCommand } from "./commands/secrets-list.js";
13
- import { statusCommand } from "./commands/status.js";
14
- import { typesCommand } from "./commands/types.js";
15
- import { endpointsCommand } from "./commands/endpoints.js";
16
- import { orgCurrentCommand, orgListCommand, orgUseCommand } from "./commands/org.js";
17
- import { logoutCommand } from "./commands/logout.js";
18
- import { cancelCommand } from "./commands/cancel.js";
19
- import { workflowsListCommand } from "./commands/workflows.js";
20
- import { drainWorkerCommand } from "./commands/drain-worker.js";
21
- import { docsCommand, docsLlmCommand } from "./commands/docs.js";
22
- import "./commands/index.js";
23
4
  import { Argument, Command, Option } from "commander";
24
5
  import pc from "picocolors";
25
6
  //#region src/cli.ts
26
- const version = "0.1.13";
7
+ const version = "0.1.15";
27
8
  const program = new Command();
28
9
  program.name("kici").description("KiCI workflow compiler").version(version);
29
10
  program.hook("preAction", (_thisCommand, actionCommand) => {
@@ -34,6 +15,7 @@ program.configureOutput({ outputError: (str, write) => {
34
15
  write(pc.red(str));
35
16
  } });
36
17
  program.command("compile").description("Compile workflows from .kici/workflows/ to kici.lock.json").option("--check", "Validate workflows without writing lock file", false).option("--kici-dir <path>", "Path to .kici directory", ".kici").option("--verbose", "Detailed output", false).option("--watch", "Watch for changes and recompile", false).action(async (options) => {
18
+ const { compileCommand, watchCommand } = await import("./commands/index.js");
37
19
  if (options.watch) await watchCommand({
38
20
  kiciDir: options.kiciDir,
39
21
  verbose: options.verbose
@@ -49,6 +31,7 @@ program.command("compile").description("Compile workflows from .kici/workflows/
49
31
  });
50
32
  const fixtureEventArg = new Argument("<event>", "Event to generate fixture for (e.g., pr:open, push, schedule, lifecycle:workflow_complete)");
51
33
  program.command("fixture").addArgument(fixtureEventArg).description("Generate fixture template for event type").option("--output <path>", "Write to file instead of stdout").action(async (event, options) => {
34
+ const { fixtureCommand } = await import("./commands/index.js");
52
35
  await fixtureCommand(event, options);
53
36
  });
54
37
  const runCommand = program.command("run").description("Execute workflows locally or remotely");
@@ -61,6 +44,7 @@ runCommand.command("local").argument("[event]", "Event type (e.g., push, pr:open
61
44
  console.error("Error: missing event argument. Pass an event or use --pick.");
62
45
  process.exit(2);
63
46
  }
47
+ const { runLocalCommand } = await import("./commands/index.js");
64
48
  const success = await runLocalCommand({
65
49
  event,
66
50
  pick: options.pick,
@@ -84,15 +68,21 @@ runCommand.command("local").argument("[event]", "Event type (e.g., push, pr:open
84
68
  });
85
69
  process.exit(success ? 0 : 1);
86
70
  });
87
- runCommand.command("remote").argument("[fixture]", "Fixture name or glob pattern (omit to list available)").description("Execute fixtures remotely via orchestrator").option("--workflow <name>", "Run a specific workflow directly (bypass triggers)").option("--all", "Run all available fixtures", false).option("--parallel", "Run matching fixtures concurrently", false).option("--no-wait", "Fire and forget (print runIds, don't stream)").option("--quiet", "Suppress output except final result", false).option("--json", "Output structured JSON result", false).option("--junit <path>", "Output JUnit XML result").option("--history", "Show recent run history", false).option("--routing-key <key>", "Override routing key for this run").option("--debug", "Verbose internals", false).option("--kici-dir <path>", "Path to .kici directory", ".kici").option("--secret <key=value>", "Inject flat secret (repeatable)", (val, prev) => [...prev, val], []).option("--context <ctx.key=value>", "Inject context secret (repeatable)", (val, prev) => [...prev, val], []).action(async (fixture, options) => {
88
- const success = await runRemoteCommand(fixture, options);
71
+ runCommand.command("remote").argument("[fixture]", "Fixture name or glob pattern (omit to list available)").description("Execute fixtures remotely via orchestrator").option("--workflow <name>", "Run a specific workflow directly (bypass triggers)").option("--all", "Run all available fixtures", false).option("--parallel", "Run matching fixtures concurrently", false).option("--no-wait", "Fire and forget (print runIds, don't stream)").option("--quiet", "Suppress output except final result", false).option("--json", "Output structured JSON result", false).option("--junit <path>", "Output JUnit XML result").option("--history", "Show recent run history", false).option("--routing-key <key>", "Override routing key for this run").option("--debug", "Verbose internals", false).option("--kici-dir <path>", "Path to .kici directory", ".kici").option("--context <ctx.key=value>", "Inject a namespaced context secret, uploaded encrypted to the orchestrator (repeatable)", (val, prev) => [...prev, val], []).option("--env <KEY=VALUE>", "Provide a per-run secret (repeatable); uploaded encrypted to the orchestrator", (val, prev) => [...prev, val], []).action(async (fixture, options) => {
72
+ const { runRemoteCommand } = await import("./commands/index.js");
73
+ const success = await runRemoteCommand(fixture, {
74
+ ...options,
75
+ envFlags: options.env
76
+ });
89
77
  process.exit(success ? 0 : 1);
90
78
  });
91
79
  program.command("test").argument("[event]", "Event type to preview (e.g., push, pr:open, schedule)").description("Preview which workflows match a trigger event (dry-run)").option("--branch <name>", "Override target branch for trigger matching (default: main)").option("--sha <hash>", "Override commit SHA").option("--workflow <name>", "Filter to specific workflow in display").option("--job <name>", "Filter to specific job in display").option("--debug", "Verbose internals", false).option("--kici-dir <path>", "Path to .kici directory", ".kici").option("--files <path>", "Simulate changed file path for trigger matching (repeatable)", (val, prev) => [...prev, val], []).option("--secret <key=value>", "Inject flat secret (repeatable)", (val, prev) => [...prev, val], []).option("--context <ctx.key=value>", "Inject context secret (repeatable)", (val, prev) => [...prev, val], []).action(async (event, options) => {
80
+ const { testCommand } = await import("./commands/index.js");
92
81
  const success = await testCommand(event, options);
93
82
  process.exit(success ? 0 : 1);
94
83
  });
95
84
  program.command("init").description("Initialize .kici/ directory with default workflows").option("--force", "Overwrite existing .kici/ directory", false).option("--skip-install", "Create files without installing dependencies", false).option("--package-manager <npm|pnpm|yarn>", "Force a package manager for the install step (default: auto-detect)").option("--mjs", "JavaScript-only mode (no TypeScript, no dependencies)", false).option("--no-agents-md", "Skip writing .kici/AGENTS.md (LLM authoring context)").option("--private-registry <url>", "Scaffold a workflow registries: entry pointing at <url>").option("--private-registry-scope <scope>", "Optional npm package scope (e.g. @my-org) for the private registry").option("--private-registry-secret <ref>", "Qualified secret reference (env:NAME) the private registry token comes from", "production:NPM_TOKEN").addOption(new Option("--use-verdaccio-local").default(false).hideHelp()).action(async (options) => {
85
+ const { initCommand } = await import("./commands/index.js");
96
86
  const success = await initCommand({
97
87
  ...options,
98
88
  noAgentsMd: options.agentsMd === false
@@ -100,6 +90,7 @@ program.command("init").description("Initialize .kici/ directory with default wo
100
90
  process.exit(success ? 0 : 1);
101
91
  });
102
92
  program.command("hook").description("Manage pre-commit hooks").command("install").description("Install kici compile pre-commit hook").option("--git", "Use raw git hook (.git/hooks/pre-commit)", false).action(async (options) => {
93
+ const { hookInstallCommand } = await import("./commands/index.js");
103
94
  const success = await hookInstallCommand({ git: options.git });
104
95
  process.exit(success ? 0 : 1);
105
96
  });
@@ -111,6 +102,7 @@ Environment variables:
111
102
  KICI_OIDC_ISSUER Override OIDC issuer URL
112
103
  KICI_OIDC_CLIENT_ID Override OIDC client ID
113
104
  `).action(async (options) => {
105
+ const { loginCommand } = await import("./commands/index.js");
114
106
  const success = await loginCommand({
115
107
  token: options.token,
116
108
  device: options.device,
@@ -121,27 +113,33 @@ Environment variables:
121
113
  process.exit(success ? 0 : 1);
122
114
  });
123
115
  program.command("logout").description("Revoke PAT and clear local credentials").action(async () => {
116
+ const { logoutCommand } = await import("./commands/index.js");
124
117
  const success = await logoutCommand();
125
118
  process.exit(success ? 0 : 1);
126
119
  });
127
120
  const orgCommand = program.command("org").description("Manage organizations");
128
121
  orgCommand.command("list").description("List organizations you belong to").action(async () => {
122
+ const { orgListCommand } = await import("./commands/index.js");
129
123
  const success = await orgListCommand();
130
124
  process.exit(success ? 0 : 1);
131
125
  });
132
126
  orgCommand.command("use").argument("<name>", "Organization name or ID").description("Switch active organization").action(async (name) => {
127
+ const { orgUseCommand } = await import("./commands/index.js");
133
128
  const success = await orgUseCommand(name);
134
129
  process.exit(success ? 0 : 1);
135
130
  });
136
131
  orgCommand.command("current").description("Show current active organization").action(async () => {
132
+ const { orgCurrentCommand } = await import("./commands/index.js");
137
133
  const success = await orgCurrentCommand();
138
134
  process.exit(success ? 0 : 1);
139
135
  });
140
136
  program.command("secrets").description("Manage secrets").command("list").description("List test-available secret contexts").option("--endpoint <url>", "Orchestrator URL override").action(async (options) => {
137
+ const { secretsListCommand } = await import("./commands/index.js");
141
138
  const success = await secretsListCommand({ endpoint: options.endpoint });
142
139
  process.exit(success ? 0 : 1);
143
140
  });
144
141
  program.command("status").argument("<run-id>", "Run ID to inspect").description("Show status and details of a test run").option("--logs", "Stream full log replay", false).option("--job <name>", "Filter logs to specific job").option("--json", "Output raw JSON", false).action(async (runId, options) => {
142
+ const { statusCommand } = await import("./commands/index.js");
145
143
  const success = await statusCommand(runId, {
146
144
  logs: options.logs,
147
145
  job: options.job,
@@ -150,6 +148,7 @@ program.command("status").argument("<run-id>", "Run ID to inspect").description(
150
148
  process.exit(success ? 0 : 1);
151
149
  });
152
150
  program.command("cancel").argument("[run-id]", "Run ID to cancel").description("Cancel a running workflow or all runs on a branch").option("--force", "Force cancel (kill immediately, skip hooks)", false).option("--branch <name>", "Cancel all in-progress runs on this branch").action(async (runId, options) => {
151
+ const { cancelCommand } = await import("./commands/index.js");
153
152
  const success = await cancelCommand(runId, {
154
153
  force: options.force,
155
154
  branch: options.branch
@@ -157,6 +156,7 @@ program.command("cancel").argument("[run-id]", "Run ID to cancel").description("
157
156
  process.exit(success ? 0 : 1);
158
157
  });
159
158
  program.command("types").description("Generate TypeScript declarations for secret contexts").option("--kici-dir <path>", "Path to .kici directory", ".kici").option("--endpoint <url>", "Orchestrator URL override").action(async (options) => {
159
+ const { typesCommand } = await import("./commands/index.js");
160
160
  const success = await typesCommand({
161
161
  kiciDir: options.kiciDir,
162
162
  endpoint: options.endpoint
@@ -164,10 +164,12 @@ program.command("types").description("Generate TypeScript declarations for secre
164
164
  process.exit(success ? 0 : 1);
165
165
  });
166
166
  program.command("endpoints").description("List all webhook entrypoints for the current project").option("--kici-dir <path>", "Path to .kici directory", ".kici").action(async (options) => {
167
+ const { endpointsCommand } = await import("./commands/index.js");
167
168
  const success = await endpointsCommand({ kiciDir: options.kiciDir });
168
169
  process.exit(success ? 0 : 1);
169
170
  });
170
171
  program.command("workflows").description("Manage workflow registrations").command("list").description("List permanently registered workflows").option("--json", "Output as JSON", false).option("--stale <duration>", "Filter stale registrations (e.g., 30d, 7d)").option("--trigger-type <type>", "Filter by trigger type").option("--repo <repo>", "Filter by repository").action(async (options) => {
172
+ const { workflowsListCommand } = await import("./commands/index.js");
171
173
  const success = await workflowsListCommand({
172
174
  json: options.json,
173
175
  stale: options.stale,
@@ -177,9 +179,11 @@ program.command("workflows").description("Manage workflow registrations").comman
177
179
  process.exit(success ? 0 : 1);
178
180
  });
179
181
  program.command("docs").description("Open the KiCI documentation site in the default browser").option("--no-open", "Print the docs URL instead of opening a browser").action(async (options) => {
182
+ const { docsCommand } = await import("./commands/index.js");
180
183
  const success = await docsCommand({ open: options.open });
181
184
  process.exit(success ? 0 : 1);
182
185
  }).command("llm").description("Print the bundled LLM context (llms-full.txt) to stdout").option("--index", "Print the curated llms.txt index instead of the full bundle", false).option("--out <path>", "Write the bundle to a file instead of stdout").action(async (options) => {
186
+ const { docsLlmCommand } = await import("./commands/index.js");
183
187
  const success = await docsLlmCommand({
184
188
  index: options.index,
185
189
  out: options.out
@@ -187,6 +191,7 @@ program.command("docs").description("Open the KiCI documentation site in the def
187
191
  process.exit(success ? 0 : 1);
188
192
  });
189
193
  program.command("admin").description("Operator-facing commands for running instances").command("drain-worker").description("Trigger graceful drain on a worker instance").requiredOption("--url <url>", "Worker URL (e.g., http://worker-host:<port>)").action(async (options) => {
194
+ const { drainWorkerCommand } = await import("./commands/index.js");
190
195
  const success = await drainWorkerCommand({ url: options.url });
191
196
  process.exit(success ? 0 : 1);
192
197
  });
@@ -1,7 +1,7 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import { loadGlobalConfig } from "../remote/config.js";
3
3
  import pc from "picocolors";
4
- import { logger, toErrorMessage } from "@kici-dev/shared";
4
+ import { logger, toErrorMessage } from "@kici-dev/core";
5
5
  //#region src/commands/cancel.ts
6
6
  /**
7
7
  * kici cancel command
@@ -11,8 +11,8 @@ import pc from "picocolors";
11
11
  import { existsSync } from "node:fs";
12
12
  import fs from "node:fs/promises";
13
13
  import path from "node:path";
14
+ import { logger, toErrorMessage } from "@kici-dev/core";
14
15
  import { execSync } from "node:child_process";
15
- import { logger, toErrorMessage } from "@kici-dev/shared";
16
16
  //#region src/commands/compile.ts
17
17
  /**
18
18
  * Read the existing lock file and return its lockfileHash, if present.
@@ -2,8 +2,8 @@ import "../chunk-gOLHoazu.js";
2
2
  import pc from "picocolors";
3
3
  import { readFile, writeFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
- import { logger, toErrorMessage } from "@kici-dev/shared";
6
5
  import { fileURLToPath } from "node:url";
6
+ import { logger, toErrorMessage } from "@kici-dev/core";
7
7
  import open from "open";
8
8
  //#region src/commands/docs.ts
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -1,6 +1,6 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import pc from "picocolors";
3
- import { logger, toErrorMessage } from "@kici-dev/shared";
3
+ import { logger, toErrorMessage } from "@kici-dev/core";
4
4
  //#region src/commands/drain-worker.ts
5
5
  /**
6
6
  * kici admin drain-worker command
@@ -5,7 +5,7 @@ import { loadGlobalConfig } from "../remote/config.js";
5
5
  import pc from "picocolors";
6
6
  import { readFile } from "node:fs/promises";
7
7
  import path from "node:path";
8
- import { logger, toErrorMessage } from "@kici-dev/shared";
8
+ import { logger, toErrorMessage } from "@kici-dev/core";
9
9
  //#region src/commands/endpoints.ts
10
10
  /**
11
11
  * kici endpoints command
@@ -1,10 +1,10 @@
1
1
  import "../chunk-gOLHoazu.js";
2
- import { getDefaultFixture } from "../fixtures/defaults/index.js";
3
- import { detectRepoFromGit } from "../test-runner/git-detector.js";
4
2
  import { parseEventArg } from "../test-runner/event-types.js";
3
+ import { detectRepoFromGit } from "../test-runner/git-detector.js";
4
+ import { getDefaultFixture } from "../fixtures/defaults/index.js";
5
5
  import pc from "picocolors";
6
6
  import { writeFile } from "node:fs/promises";
7
- import { logger } from "@kici-dev/shared";
7
+ import { logger } from "@kici-dev/core";
8
8
  //#region src/commands/fixture.ts
9
9
  /**
10
10
  * Fixture generation command
@@ -5,7 +5,7 @@ import "../hooks/index.js";
5
5
  import pc from "picocolors";
6
6
  import { readFile } from "node:fs/promises";
7
7
  import path from "node:path";
8
- import { logger, toErrorMessage } from "@kici-dev/shared";
8
+ import { logger, toErrorMessage } from "@kici-dev/core";
9
9
  import { select } from "@inquirer/prompts";
10
10
  //#region src/commands/hook.ts
11
11
  /**
@@ -1,20 +1,20 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import { compileCommand } from "./compile.js";
3
- import { watchCommand } from "./watch.js";
3
+ import { cancelCommand } from "./cancel.js";
4
+ import { docsCommand, docsLlmCommand } from "./docs.js";
5
+ import { drainWorkerCommand } from "./drain-worker.js";
6
+ import { endpointsCommand } from "./endpoints.js";
4
7
  import { fixtureCommand } from "./fixture.js";
8
+ import { hookInstallCommand } from "./hook.js";
9
+ import { watchCommand } from "./watch.js";
5
10
  import { testCommand, testDryRun } from "./test.js";
6
11
  import { runLocalCommand, runRemoteCommand } from "./run.js";
7
12
  import { initCommand } from "./init.js";
8
- import { hookInstallCommand } from "./hook.js";
9
13
  import { loginCommand } from "./login.js";
10
14
  import { secretsListCommand } from "./secrets-list.js";
11
15
  import { statusCommand } from "./status.js";
12
16
  import { typesCommand } from "./types.js";
13
- import { endpointsCommand } from "./endpoints.js";
14
17
  import { orgCurrentCommand, orgListCommand, orgUseCommand } from "./org.js";
15
18
  import { logoutCommand } from "./logout.js";
16
- import { cancelCommand } from "./cancel.js";
17
19
  import { workflowsListCommand } from "./workflows.js";
18
- import { drainWorkerCommand } from "./drain-worker.js";
19
- import { docsCommand, docsLlmCommand } from "./docs.js";
20
20
  export { cancelCommand, compileCommand, docsCommand, docsLlmCommand, drainWorkerCommand, endpointsCommand, fixtureCommand, hookInstallCommand, initCommand, loginCommand, logoutCommand, orgCurrentCommand, orgListCommand, orgUseCommand, runLocalCommand, runRemoteCommand, secretsListCommand, statusCommand, testCommand, testDryRun, typesCommand, watchCommand, workflowsListCommand };
@@ -1,19 +1,19 @@
1
1
  import "../chunk-gOLHoazu.js";
2
+ import { agentsMdTemplate } from "../templates/agents-md.js";
2
3
  import { tsconfigTemplate } from "../templates/tsconfig-json.js";
3
4
  import { generatePackageJson } from "../templates/package-json.js";
4
- import { agentsMdTemplate } from "../templates/agents-md.js";
5
5
  import { workflowPaths } from "../templates/index.js";
6
- import { getTypeScriptPaths } from "../execution/sdk-alias.js";
7
6
  import { detectHookTools, findGitDir } from "../hooks/detector.js";
8
7
  import { installHook } from "../hooks/installer.js";
9
8
  import "../hooks/index.js";
9
+ import { getTypeScriptPaths } from "../execution/sdk-alias.js";
10
10
  import pc from "picocolors";
11
11
  import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
12
12
  import path from "node:path";
13
- import { initZx, logger, toErrorMessage } from "@kici-dev/shared";
14
- import { detectPackageManager, installCommand, parsePackageManager } from "@kici-dev/shared/package-manager";
15
- import { $ } from "zx";
13
+ import { initZx, logger, toErrorMessage } from "@kici-dev/core";
14
+ import { detectPackageManager, installBuildPolicyArgs, installCommand, parsePackageManager } from "@kici-dev/core/package-manager";
16
15
  import { checkbox, confirm, select } from "@inquirer/prompts";
16
+ import { $ } from "zx";
17
17
  //#region src/commands/init.ts
18
18
  /**
19
19
  * kici init command
@@ -94,9 +94,11 @@ async function initCommand(options = {}) {
94
94
  await mkdir(path.join(kiciDir, "types"), { recursive: true });
95
95
  logger.info(pc.gray("Created .kici/types/ for generated type declarations"));
96
96
  if (!options.skipInstall) {
97
- const [bin, action] = installCommand(await resolvePackageManager(options.packageManager));
97
+ const pm = await resolvePackageManager(options.packageManager);
98
+ const [bin, action] = installCommand(pm);
99
+ const buildPolicyArgs = installBuildPolicyArgs(pm);
98
100
  logger.info(pc.gray(`Running ${bin} ${action}...`));
99
- await $`cd ${kiciDir} && ${bin} ${action}`;
101
+ await $`cd ${kiciDir} && ${bin} ${action} ${buildPolicyArgs}`;
100
102
  }
101
103
  }
102
104
  if (options.privateRegistry) await writePrivateRegistryScaffold(kiciDir, {
@@ -1,9 +1,10 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import { getConfigPath, mergeGlobalConfig } from "../remote/config.js";
3
3
  import { deviceFlow, exchangeTokenForPat, pkceFlow } from "../remote/oauth.js";
4
+ import "../remote/prod-defaults.js";
4
5
  import { isHeadless } from "../auth/headless-detect.js";
5
6
  import pc from "picocolors";
6
- import { toErrorMessage } from "@kici-dev/shared";
7
+ import { toErrorMessage } from "@kici-dev/core";
7
8
  import os from "node:os";
8
9
  import { createInterface } from "node:readline";
9
10
  //#region src/commands/login.ts
@@ -45,21 +46,9 @@ function checkPatExpiry(expiresAt) {
45
46
  * 4. Save PAT to global config
46
47
  */
47
48
  async function oauthLogin(options) {
48
- const platformUrl = options.platformEndpoint || process.env.KICI_PLATFORM_URL || "";
49
- const issuer = process.env.KICI_OIDC_ISSUER || "";
50
- const clientId = process.env.KICI_OIDC_CLIENT_ID || "";
51
- const missing = [];
52
- if (!platformUrl) missing.push("KICI_PLATFORM_URL");
53
- if (!issuer) missing.push("KICI_OIDC_ISSUER");
54
- if (!clientId) missing.push("KICI_OIDC_CLIENT_ID");
55
- if (missing.length > 0) {
56
- console.error(pc.red(`Error: missing required env var(s) for OAuth login: ${missing.join(", ")}`));
57
- console.error(pc.gray(" Set them to your Platform and IdP endpoints, for example:"));
58
- console.error(pc.gray(" export KICI_PLATFORM_URL=https://your-platform.example.com"));
59
- console.error(pc.gray(" export KICI_OIDC_ISSUER=https://your-idp.example.com"));
60
- console.error(pc.gray(" export KICI_OIDC_CLIENT_ID=<cli-client-id>"));
61
- return false;
62
- }
49
+ const platformUrl = options.platformEndpoint || process.env.KICI_PLATFORM_URL || "https://api.kici.dev";
50
+ const issuer = process.env.KICI_OIDC_ISSUER || "https://auth.kici.dev/realms/kici-internal";
51
+ const clientId = process.env.KICI_OIDC_CLIENT_ID || "kici-cli";
63
52
  console.log(pc.cyan("\n Step 1/4: Detecting environment..."));
64
53
  const browserCmdSet = !!process.env.KICI_BROWSER_CMD;
65
54
  const useDeviceFlow = options.device || !browserCmdSet && isHeadless();
@@ -1,20 +1,21 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import { resolveKiciDir } from "../execution/executor.js";
3
3
  import "../execution/index.js";
4
- import { loadGlobalConfig } from "../remote/config.js";
5
4
  import { AuthenticationError, ConnectionError, OrchestratorClient } from "../remote/client.js";
6
- import { compileFixtures, filterFixtures } from "../fixtures/compiler.js";
7
- import { createOverlayTarball, getSizeWarning, uploadTarball } from "../remote/uploader.js";
5
+ import { loadGlobalConfig } from "../remote/config.js";
6
+ import { RunHistory } from "../remote/history.js";
8
7
  import { ObserverClient } from "../remote/observer.js";
9
- import { StreamingFormatter } from "../remote/output/streaming.js";
10
- import { formatErrorHighlight, formatMultiFixtureSummary, formatSummary } from "../remote/output/summary.js";
8
+ import { buildEncryptedSecrets } from "../remote/secret-upload.js";
9
+ import { createOverlayTarball, getSizeWarning, uploadTarball } from "../remote/uploader.js";
11
10
  import { formatJsonResult } from "../remote/output/json.js";
12
11
  import { formatJunitResult } from "../remote/output/junit.js";
13
- import { RunHistory } from "../remote/history.js";
12
+ import { StreamingFormatter } from "../remote/output/streaming.js";
13
+ import { formatErrorHighlight, formatMultiFixtureSummary, formatSummary } from "../remote/output/summary.js";
14
+ import { compileFixtures, filterFixtures } from "../fixtures/compiler.js";
14
15
  import pc from "picocolors";
15
16
  import { readFile, writeFile } from "node:fs/promises";
16
17
  import path from "node:path";
17
- import { formatBytes, logger, toErrorMessage } from "@kici-dev/shared";
18
+ import { formatBytes, logger, toErrorMessage } from "@kici-dev/core";
18
19
  //#region src/commands/run.ts
19
20
  /**
20
21
  * Run a workflow locally using the local executor.
@@ -185,7 +186,7 @@ async function runSingleFixture(fixture, client, options, config, history) {
185
186
  let routingKey = options.routingKey ?? config.routingKey ?? "default";
186
187
  if (!hasRemote) {
187
188
  routingKey = `local:${path.basename(repoRoot)}`;
188
- logger.warn("No remote detected -- steps that use git commands will fail (no .git directory)");
189
+ if (!options.quiet) logger.warn("No remote detected -- steps that use git commands will fail (no .git directory)");
189
190
  }
190
191
  let inlineLockFile;
191
192
  if (!hasRemote) inlineLockFile = await readFile(path.join(kiciDir, "kici.lock.json"), "utf-8");
@@ -217,6 +218,7 @@ async function runSingleFixture(fixture, client, options, config, history) {
217
218
  };
218
219
  }
219
220
  if (!options.quiet) logger.info(pc.gray("Triggering test run..."));
221
+ const encrypted = await buildEncryptedSecrets(kiciDir, options.envFlags, options.context, upload.publicKey);
220
222
  const triggerResult = await client.triggerTest({
221
223
  fixtureId: fixture.id,
222
224
  event,
@@ -224,6 +226,10 @@ async function runSingleFixture(fixture, client, options, config, history) {
224
226
  uploadId: upload.uploadId,
225
227
  cliPublicKey: uploadResult.cliPublicKey.toString("base64"),
226
228
  secrets: opts.secrets,
229
+ ...encrypted && {
230
+ encryptedSecrets: encrypted.encryptedSecrets,
231
+ encryptedSecretsKey: encrypted.cliPublicKey
232
+ },
227
233
  workflowName: opts.workflowName,
228
234
  inlineLockFile,
229
235
  fullRepo: !hasRemote || void 0
@@ -516,6 +522,7 @@ async function runDirectWorkflow(workflowName, options) {
516
522
  const repoName = !hasRemote ? path.basename(repoRoot) : void 0;
517
523
  const payload = {};
518
524
  if (!hasRemote) payload.repository = { full_name: `local/${repoName}` };
525
+ const encrypted = await buildEncryptedSecrets(kiciDir, options.envFlags, options.context, upload.publicKey);
519
526
  const result = await client.triggerTest({
520
527
  fixtureId: `direct:${workflowName}`,
521
528
  event: {
@@ -526,6 +533,10 @@ async function runDirectWorkflow(workflowName, options) {
526
533
  routingKey,
527
534
  uploadId: upload.uploadId,
528
535
  cliPublicKey: directUploadResult.cliPublicKey.toString("base64"),
536
+ ...encrypted && {
537
+ encryptedSecrets: encrypted.encryptedSecrets,
538
+ encryptedSecretsKey: encrypted.cliPublicKey
539
+ },
529
540
  workflowName,
530
541
  inlineLockFile,
531
542
  fullRepo: !hasRemote || void 0
@@ -1,7 +1,7 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import { loadGlobalConfig } from "../remote/config.js";
3
3
  import pc from "picocolors";
4
- import { toErrorMessage } from "@kici-dev/shared";
4
+ import { toErrorMessage } from "@kici-dev/core";
5
5
  //#region src/commands/secrets-list.ts
6
6
  /**
7
7
  * List test-available secret contexts from the orchestrator.
@@ -47,7 +47,7 @@ async function secretsListCommand(options) {
47
47
  const contexts = ((await res.json()).environments ?? []).filter((e) => e.allow_local_execution);
48
48
  if (contexts.length === 0) {
49
49
  console.log(pc.yellow("No test-available secret contexts found."));
50
- console.log(pc.gray("Set allowLocalExecution=true on an environment to make its secrets available for test runs."));
50
+ console.log(pc.gray("Enable test runs (allowLocalExecution) on an environment to make its secrets available for test runs."));
51
51
  return true;
52
52
  }
53
53
  console.log(pc.bold("\nTest-available secret contexts:\n"));
@@ -1,12 +1,12 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import { formatCapabilityGapError } from "../errors/capability-gap.js";
3
- import { loadGlobalConfig } from "../remote/config.js";
4
3
  import { AuthenticationError, ConnectionError, NotFoundError, OrchestratorClient } from "../remote/client.js";
5
- import { StreamingFormatter } from "../remote/output/streaming.js";
4
+ import { loadGlobalConfig } from "../remote/config.js";
6
5
  import { RunHistory } from "../remote/history.js";
6
+ import { StreamingFormatter } from "../remote/output/streaming.js";
7
7
  import { observeCompletion } from "./run.js";
8
8
  import pc from "picocolors";
9
- import { formatDuration, logger, toErrorMessage } from "@kici-dev/shared";
9
+ import { formatDuration, logger, toErrorMessage } from "@kici-dev/core";
10
10
  //#region src/commands/status.ts
11
11
  /**
12
12
  * kici status command
@@ -15,7 +15,7 @@ import { formatDuration, logger, toErrorMessage } from "@kici-dev/shared";
15
15
  * Looks up local history first, then fetches from the orchestrator for
16
16
  * up-to-date status and logs.
17
17
  */
18
- const CLI_VERSION = "0.1.13";
18
+ const CLI_VERSION = "0.1.15";
19
19
  /**
20
20
  * Show status and details of a test run.
21
21
  *
@@ -32,6 +32,8 @@ export interface RemoteRunOptions extends TestOptions {
32
32
  routingKey?: string;
33
33
  /** Show recent run history */
34
34
  history?: boolean;
35
+ /** --env KEY=VALUE flag values, uploaded as per-run secrets. */
36
+ envFlags?: string[];
35
37
  }
36
38
  /** Result of a single remote fixture run */
37
39
  export interface RemoteRunResult {
@@ -2,14 +2,14 @@ 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 { displayDryRun } from "../test-runner/dry-run.js";
5
6
  import { parseEventArg } from "../test-runner/event-types.js";
6
7
  import { buildEventPayload } from "../test-runner/payload-builder.js";
7
- import { displayDryRun } from "../test-runner/dry-run.js";
8
8
  import { loadSecretsFile } from "../test-runner/secrets-file.js";
9
9
  import pc from "picocolors";
10
10
  import { readFile } from "node:fs/promises";
11
11
  import path from "node:path";
12
- import { logger, toErrorMessage } from "@kici-dev/shared";
12
+ import { logger, toErrorMessage } from "@kici-dev/core";
13
13
  import { matchAllWorkflows, normalizeRunsOn } from "@kici-dev/engine";
14
14
  //#region src/commands/test.ts
15
15
  /**
@@ -4,7 +4,7 @@ import { generateSecretsDts } from "../generators/secrets-dts.js";
4
4
  import pc from "picocolors";
5
5
  import fs from "node:fs/promises";
6
6
  import path from "node:path";
7
- import { toErrorMessage } from "@kici-dev/shared";
7
+ import { toErrorMessage } from "@kici-dev/core";
8
8
  //#region src/commands/types.ts
9
9
  /**
10
10
  * Generate TypeScript declarations for environment secrets.
@@ -4,7 +4,7 @@ import "../execution/index.js";
4
4
  import { compileCommand } from "./compile.js";
5
5
  import pc from "picocolors";
6
6
  import path from "node:path";
7
- import { logger, toErrorMessage } from "@kici-dev/shared";
7
+ import { logger, toErrorMessage } from "@kici-dev/core";
8
8
  import chokidar from "chokidar";
9
9
  //#region src/commands/watch.ts
10
10
  /** Debounce delay in milliseconds */
@@ -1,9 +1,9 @@
1
1
  import "../chunk-gOLHoazu.js";
2
- import { loadGlobalConfig } from "../remote/config.js";
3
- import { AuthenticationError, ConnectionError, OrchestratorClient, ServerError } from "../remote/client.js";
4
2
  import { formatRelativeTime } from "../format.js";
3
+ import { AuthenticationError, ConnectionError, OrchestratorClient, ServerError } from "../remote/client.js";
4
+ import { loadGlobalConfig } from "../remote/config.js";
5
5
  import pc from "picocolors";
6
- import { toErrorMessage } from "@kici-dev/shared";
6
+ import { toErrorMessage } from "@kici-dev/core";
7
7
  //#region src/commands/workflows.ts
8
8
  /**
9
9
  * kici workflows list command
@@ -1,6 +1,7 @@
1
1
  import "../chunk-gOLHoazu.js";
2
2
  import { compilerError } from "../errors/formatter.js";
3
3
  import "../errors/index.js";
4
+ import { ensureTsLoaderHook } from "./ts-loader.js";
4
5
  import { existsSync } from "node:fs";
5
6
  import fs from "node:fs/promises";
6
7
  import path from "node:path";
@@ -9,9 +10,10 @@ import { pathToFileURL } from "node:url";
9
10
  /**
10
11
  * Load a TypeScript workflow/config module by direct dynamic import.
11
12
  *
12
- * Relies on the shared `@kici-dev/shared/ts-loader-hook` ESM loader hook
13
- * registered by `packages/kici/bin/kici.js` (the same hook the agent registers
14
- * in its sandbox process). No Rolldown bundling: host-repo imports and
13
+ * Relies on the `@kici-dev/core/ts-loader-hook` ESM loader hook, registered
14
+ * lazily via `ensureTsLoaderHook()` just before the dynamic import (the same
15
+ * hook the agent registers in its sandbox process). No Rolldown bundling:
16
+ * host-repo imports and
15
17
  * transitive deps with dynamic import() resolve via Node's normal ESM loader
16
18
  * against the workspace's node_modules — the same module graph any other
17
19
  * `pnpm exec tsx` invocation would see. This keeps ops-style workflows (which
@@ -24,6 +26,7 @@ async function loadModule(entryPoint, errorContext) {
24
26
  hashBundleSource = await fs.readFile(entryPoint, "utf-8");
25
27
  } catch {}
26
28
  try {
29
+ ensureTsLoaderHook();
27
30
  return {
28
31
  module: await import(pathToFileURL(entryPoint).href + `?t=${Date.now()}`),
29
32
  hashBundleSource
@@ -2,7 +2,7 @@ import "../chunk-gOLHoazu.js";
2
2
  import { existsSync } from "node:fs";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
- import { logger } from "@kici-dev/shared";
5
+ import { logger } from "@kici-dev/core";
6
6
  //#region src/execution/sdk-alias.ts
7
7
  /**
8
8
  * SDK aliasing for development mode
@@ -0,0 +1,2 @@
1
+ export declare function ensureTsLoaderHook(): void;
2
+ //# sourceMappingURL=ts-loader.d.ts.map
@@ -0,0 +1,13 @@
1
+ import "../chunk-gOLHoazu.js";
2
+ import { register } from "node:module";
3
+ //#region src/execution/ts-loader.ts
4
+ let registered = false;
5
+ function ensureTsLoaderHook() {
6
+ if (registered) return;
7
+ registered = true;
8
+ register("@kici-dev/core/ts-loader-hook", import.meta.url);
9
+ }
10
+ //#endregion
11
+ export { ensureTsLoaderHook };
12
+
13
+ //# sourceMappingURL=ts-loader.js.map