@kici-dev/compiler 0.1.26 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/cli-banner.d.ts +6 -3
  2. package/dist/cli-banner.js +13 -5
  3. package/dist/cli.js +66 -43
  4. package/dist/commands/check-mode.d.ts +1 -1
  5. package/dist/commands/compile.js +3 -3
  6. package/dist/commands/index.d.ts +5 -1
  7. package/dist/commands/index.js +6 -3
  8. package/dist/commands/init.js +1 -1
  9. package/dist/commands/local-trust-root.d.ts +6 -0
  10. package/dist/commands/local-trust-root.js +52 -0
  11. package/dist/commands/local.d.ts +39 -0
  12. package/dist/commands/local.js +137 -0
  13. package/dist/commands/login.d.ts +2 -0
  14. package/dist/commands/login.js +40 -0
  15. package/dist/commands/logout.js +7 -0
  16. package/dist/commands/preview.js +1 -1
  17. package/dist/commands/run-banner.d.ts +31 -0
  18. package/dist/commands/run-banner.js +25 -0
  19. package/dist/commands/run-routed.d.ts +53 -0
  20. package/dist/commands/run-routed.js +176 -0
  21. package/dist/commands/run.d.ts +0 -17
  22. package/dist/commands/run.js +7 -50
  23. package/dist/commands/secrets-list.d.ts +2 -2
  24. package/dist/commands/secrets-list.js +4 -4
  25. package/dist/commands/types.d.ts +3 -3
  26. package/dist/commands/types.js +4 -4
  27. package/dist/execution/executor.js +7 -7
  28. package/dist/generators/secrets-dts.d.ts +9 -9
  29. package/dist/generators/secrets-dts.js +12 -12
  30. package/dist/llm-context/llms-architecture.txt +2 -2
  31. package/dist/llm-context/llms-cli.txt +674 -340
  32. package/dist/llm-context/llms-features.txt +334 -336
  33. package/dist/llm-context/llms-full.txt +1207 -892
  34. package/dist/llm-context/llms-getting-started.txt +7 -15
  35. package/dist/llm-context/llms-patterns.txt +5 -23
  36. package/dist/llm-context/llms-providers.txt +10 -1
  37. package/dist/llm-context/llms-sdk.txt +12 -12
  38. package/dist/llm-context/llms.txt +5 -5
  39. package/dist/local-executor/secret-loader.d.ts +1 -1
  40. package/dist/local-plane/orchestrator-process.d.ts +65 -0
  41. package/dist/local-plane/orchestrator-process.js +115 -0
  42. package/dist/local-plane/paths.d.ts +39 -0
  43. package/dist/local-plane/paths.js +54 -0
  44. package/dist/local-plane/plane-manager.d.ts +151 -0
  45. package/dist/local-plane/plane-manager.js +340 -0
  46. package/dist/local-plane/plane-seed.d.ts +76 -0
  47. package/dist/local-plane/plane-seed.js +59 -0
  48. package/dist/local-plane/plane-trigger.d.ts +62 -0
  49. package/dist/local-plane/plane-trigger.js +97 -0
  50. package/dist/local-plane/platform-attach.d.ts +53 -0
  51. package/dist/local-plane/platform-attach.js +111 -0
  52. package/dist/local-plane/postgres.d.ts +44 -0
  53. package/dist/local-plane/postgres.js +165 -0
  54. package/dist/local-plane/resolve-plane.d.ts +37 -0
  55. package/dist/local-plane/resolve-plane.js +76 -0
  56. package/dist/local-plane/run-follow.d.ts +41 -0
  57. package/dist/local-plane/run-follow.js +104 -0
  58. package/dist/local-plane/scaler-config.d.ts +54 -0
  59. package/dist/local-plane/scaler-config.js +114 -0
  60. package/dist/local-plane/secret-seed.d.ts +59 -0
  61. package/dist/local-plane/secret-seed.js +112 -0
  62. package/dist/local-plane/source-provider.d.ts +43 -0
  63. package/dist/local-plane/source-provider.js +165 -0
  64. package/dist/local-plane/trusted-routing.d.ts +32 -0
  65. package/dist/local-plane/trusted-routing.js +47 -0
  66. package/dist/lockfile/generator.js +7 -7
  67. package/dist/remote/dashboard-client.d.ts +7 -7
  68. package/dist/remote/dashboard-client.js +7 -7
  69. package/dist/remote/platform-client.d.ts +1 -1
  70. package/dist/remote/secret-loader.d.ts +18 -0
  71. package/dist/{local-executor → remote}/secret-loader.js +4 -4
  72. package/dist/remote/secret-upload.d.ts +1 -1
  73. package/dist/remote/secret-upload.js +2 -2
  74. package/dist/remote/uploader.d.ts +1 -1
  75. package/dist/remote/uploader.js +2 -2
  76. package/dist/templates/agents-md.d.ts +1 -1
  77. package/dist/templates/agents-md.js +2 -2
  78. package/dist/templates/package-json.js +1 -1
  79. package/dist/test-runner/job-executor.js +1 -1
  80. package/dist/test-runner/runs-on-display.d.ts +9 -0
  81. package/dist/{local-executor → test-runner}/runs-on-display.js +1 -1
  82. package/dist/test-runner/step-context.d.ts +1 -1
  83. package/dist/test-runner/step-context.js +2 -2
  84. package/dist/types.d.ts +6 -6
  85. package/package.json +7 -4
  86. package/sbom.spdx.json +9884 -1459
  87. package/dist/local-executor/dag-scheduler.js +0 -183
  88. package/dist/local-executor/index.js +0 -378
  89. package/dist/local-executor/job-runner.js +0 -411
  90. package/dist/local-executor/materializer.js +0 -132
  91. package/dist/local-executor/output-streamer.js +0 -168
  92. package/dist/local-executor/payload-generator.js +0 -138
  93. package/dist/local-executor/picker.js +0 -109
  94. package/dist/local-executor/to-event-payload.js +0 -21
  95. package/dist/local-executor/types.js +0 -2
  96. package/dist/local-executor/workflow-lock.js +0 -0
@@ -441,7 +441,7 @@ The dashboard is a browser SPA on top of the same `/api/v1/*` surface, so anythi
441
441
 
442
442
  - **Auth & identity:** `/cli/exchange-token`, `/pats`, `/user`, `/identity-links`, `/github-oauth`, `/invites`, `/invites/pending`, `/invites/:inviteId/{accept,decline}`
443
443
  - **Org & membership:** `/orgs`, `/orgs/:customerId`, `/orgs/:customerId/{members,roles,api-keys,orchestrator-keys,service-accounts,billing,trust-policies}`
444
- - **Workflows & runs:** `/orgs/:customerId/{runs,registrations,workflows,held-runs,environments,secrets,global-workflows}`
444
+ - **Workflows & runs:** `/orgs/:customerId/{runs,registrations,workflows,held-runs,contexts,secrets,global-workflows}`
445
445
  - **Webhooks & event log:** `/orgs/:customerId/{sources,webhook-endpoints,event-log}`
446
446
  - **Diagnostics & activity:** `/orgs/:customerId/{diagnostics,activity,access-log}`
447
447
 
@@ -565,15 +565,6 @@ Compile workflows from `.kici/workflows/` to `kici.lock.json`.
565
565
  kici compile [options]
566
566
  ```
567
567
 
568
- **Options:**
569
-
570
- | Option | Default | Description |
571
- | ------------------- | ------- | -------------------------------------------- |
572
- | `--check` | `false` | Validate workflows without writing lock file |
573
- | `--watch` | `false` | Watch for changes and recompile |
574
- | `--kici-dir <path>` | `.kici` | Path to .kici directory |
575
- | `--verbose` | `false` | Detailed output |
576
-
577
568
  **Examples:**
578
569
 
579
570
  ```bash
@@ -606,69 +597,21 @@ The `--check` flag is useful in CI pipelines and pre-commit hooks. It validates
606
597
 
607
598
  ### kici run
608
599
 
609
- Execute workflows locally or remotely. The `run` command has two subcommands: `local` for direct execution without infrastructure, and `remote` for fixture-based execution through an orchestrator.
610
-
611
- #### kici run local
612
-
613
- Execute workflows locally without orchestrator infrastructure. Compiles workflows, matches triggers against the specified event, expands matrices, and runs jobs with DAG-based parallel scheduling.
614
-
615
- ```bash
616
- kici run local [event] [options]
617
- ```
618
-
619
- **Arguments:**
600
+ Execute workflows locally or remotely. A bare `kici run [event]` performs a real routed run with this machine as the ephemeral agent; the `remote` subcommand runs fixtures through an orchestrator.
620
601
 
621
- | Argument | Required | Description |
622
- | -------- | ---------------------- | ------------------------------------------------ |
623
- | `event` | when `--pick` is unset | Event type (e.g., `push`, `pr:open`, `schedule`) |
602
+ #### kici run <event> --local
624
603
 
625
- **Options:**
604
+ Run a workflow on this machine as a real routed dispatch. `kici run <event> --local` compiles your workflows, matches triggers against the specified event, expands matrices, and executes the matched jobs — this machine joins as an ephemeral agent through the warm local dev plane. No orchestrator deployment is required.
626
605
 
627
- | Option | Default | Description |
628
- | --------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
629
- | `-p, --pick` | `false` | Interactively pick a workflow + trigger (see below) |
630
- | `--workflow <name>` | none | Run only the specified workflow (mutex with `--pick`) |
631
- | `--job <name>` | none | Run only the specified job (and its dependencies) |
632
- | `--branch <name>` | detected | Override detected git branch |
633
- | `--sha <hash>` | detected | Override detected git SHA |
634
- | `--payload <path>` | none | Path to explicit event payload JSON file |
635
- | `--concurrency <n>` | CPU cores | Max parallel jobs **within one run** (job-level only). Cross-run [concurrency groups](https://docs.kici.dev/user/concurrency/) declared in `workflow({ concurrency: ... })` are enforced separately — see "Concurrency enforcement" below. |
636
- | `--keep-going` | `false` | Continue after job failure |
637
- | `--container` | `false` | Use Podman container isolation |
638
- | `--env <KEY=VALUE>` | none | Environment variable override (repeatable) |
639
- | `--input <KEY=VALUE>` | none | Typed workflow-dispatch input (repeatable) — coerced + validated against the workflow's `dispatch({ inputs })` schema, exposed as `ctx.dispatchInputs` (see [triggers → typed dispatch inputs](https://docs.kici.dev/user/sdk/triggers/#typed-dispatch-inputs)) |
640
- | `--files <path>` | git diff | Override changed file paths (repeatable, default: git diff) |
641
- | `--quiet` | `false` | Suppress streaming output (summary only) |
642
- | `--json` | `false` | Output structured JSON result |
643
- | `--junit <path>` | none | Output JUnit XML result to file |
644
- | `--debug` | `false` | Verbose internals |
645
- | `--kici-dir <path>` | `.kici` | Path to .kici directory |
646
- | `--in-place` | `false` | Run against the real working directory instead of an isolated tmp checkout (see "Execution isolation" below) |
647
- | `--keep` | `false` | Always retain the isolated tmp checkout (default: keep only on failure) |
648
- | `--check` | `false` | Run in [check mode](https://docs.kici.dev/user/idempotent-steps/): each step reports drift instead of applying; the run still exits 0 |
649
- | `--fail-on-drift` | `false` | In check mode, exit non-zero if any step reports drift (no effect without `--check`) |
650
-
651
- **Interactive workflow selection (`--pick` / `-p`):**
652
-
653
- When you do not remember the event arg for a workflow, pass `--pick` (or `-p`) to open an interactive picker. It lists every workflow with a compact summary of its triggers, lets you choose one, and (for multi-trigger workflows) prompts again for which trigger to simulate. The selected trigger is converted back into an event arg and fed through the normal pipeline.
606
+ `kici run local` (the old direct-execution subcommand) is retired: every run is now a real routed dispatch. Invoking `kici run local <event>` prints a hint pointing at `kici run <event> --local` and exits without running.
654
607
 
655
608
  ```bash
656
- # Open the picker across all triggerable workflows
657
- kici run local --pick
658
-
659
- # Scope the picker to a trigger family (e.g. only workflows that react to pr:*)
660
- kici run local pr:open --pick
609
+ kici run [event] --local [options]
661
610
  ```
662
611
 
663
- Rules:
664
-
665
- - `--pick` is mutually exclusive with `--workflow`. Passing both exits with code 2.
666
- - When `stdin` is not a TTY, `--pick` prints the available workflows and exits without running anything — fall back to `kici run local <event> --workflow <name>` in scripts.
667
- - Passing an event arg together with `--pick` narrows the picker to workflows that declare at least one trigger in that event family (e.g. `schedule --pick` shows only scheduled workflows).
668
-
669
612
  **Concurrency enforcement:**
670
613
 
671
- When the workflow declares a `concurrency` block, `kici run local` enforces it across concurrent local invocations on the same machine and user account. The behavior mirrors the orchestrator:
614
+ When the workflow declares a `concurrency` block, `kici run <event> --local` enforces it across concurrent local invocations on the same machine and user account. The behavior mirrors the orchestrator:
672
615
 
673
616
  - The `group` callback is evaluated against the simulated event (same `{ branch, event }` context that the agent sees), and the resulting key is used as the lock identity. Throwing from `group` aborts the workflow run with a clear error — there is no fallback to the workflow name.
674
617
  - `cancelInProgress: true` interrupts the holder via `SIGTERM`, then escalates to `SIGKILL` after a grace window if the holder does not exit, and proceeds with the new run.
@@ -682,7 +625,7 @@ The `SIGTERM`-to-`SIGKILL` grace window defaults to 30 000 ms. Override it with
682
625
 
683
626
  **Execution isolation:**
684
627
 
685
- By default, `kici run local` executes steps inside an **isolated tmp checkout** rather than against your real working directory. Any file a step writes, builds, or deletes — and any `git` mutation a step performs — lands in that throwaway copy, so casual local runs never touch your tree.
628
+ By default, `kici run <event> --local` executes steps inside an **isolated tmp checkout** rather than against your real working directory. Any file a step writes, builds, or deletes — and any `git` mutation a step performs — lands in that throwaway copy, so casual local runs never touch your tree.
686
629
 
687
630
  What gets materialized into the isolated checkout has full parity with what `kici run remote` reconstructs: your current working tree minus gitignored files, with `.kiciignore` applied to local changes, over a real `.git` directory. Concretely, the checkout is built from a clone pinned to your current `HEAD`, with your local overlay (modified, staged, and untracked-but-not-ignored files) copied on top and locally-deleted files removed. Workflows that read git metadata work because the `.git` directory is present and pinned to your `HEAD`.
688
631
 
@@ -692,8 +635,7 @@ Cleanup policy:
692
635
 
693
636
  - On a fully successful run, the isolated checkout is removed.
694
637
  - On failure, it is retained and its path is logged so you can inspect the failed state.
695
- - `--keep` always retains it, even on success.
696
- - Retained checkouts are garbage-collected after 72 hours by the next `kici run local` invocation — copy a checkout elsewhere if you need it longer.
638
+ - Retained checkouts are garbage-collected after 72 hours by the next `kici run <event> --local` invocation copy a checkout elsewhere if you need it longer.
697
639
 
698
640
  Set the `KICI_RUN_DIR` environment variable to place the isolated checkout under a base directory other than the system temp directory.
699
641
 
@@ -704,32 +646,23 @@ Pass `--in-place` to run against the real working directory instead — useful w
704
646
  **Examples:**
705
647
 
706
648
  ```bash
707
- # Run workflows matching a push event
708
- kici run local push
709
-
710
- # Run only a specific workflow
711
- kici run local push --workflow ci
649
+ # Run workflows matching a push event on this machine
650
+ kici run push --local
712
651
 
713
- # Run only a specific job (and its dependencies)
714
- kici run local push --job test
652
+ # Run a pull-request-open workflow locally
653
+ kici run pr:open --local
715
654
 
716
- # JSON output for CI scripting
717
- kici run local push --json
655
+ # Reuse the working tree instead of an isolated clone
656
+ kici run push --local --in-place
718
657
 
719
- # JUnit XML for CI integration
720
- kici run local push --junit results.xml
721
-
722
- # Quiet mode (summary only, no streaming)
723
- kici run local push --quiet
724
-
725
- # Override branch and SHA
726
- kici run local push --branch main --sha abc1234
658
+ # Force the throwaway/offline plane
659
+ kici run push --local --offline
727
660
 
728
661
  # Environment variable overrides
729
- kici run local push --env NODE_ENV=test --env CI=true
662
+ kici run push --local --env NODE_ENV=test --env CI=true
730
663
 
731
- # Continue running other jobs after one fails
732
- kici run local push --keep-going
664
+ # Quiet mode (summary only, no streaming)
665
+ kici run push --local --quiet
733
666
  ```
734
667
 
735
668
  **Exit codes:**
@@ -739,20 +672,13 @@ kici run local push --keep-going
739
672
  | 0 | All workflows succeeded |
740
673
  | 1 | One or more jobs failed |
741
674
 
742
- **Output formats:**
743
-
744
- - **Default:** Streaming job output during execution, followed by a tree-format summary with per-step timing
745
- - **`--json`:** Structured JSON with workflows, jobs, steps, timing, and matrix values
746
- - **`--junit <path>`:** Standard JUnit XML for CI integration (Jenkins, GitLab, etc.)
747
- - **`--quiet`:** Summary only, no streaming output during execution
748
-
749
675
  #### kici run remote
750
676
 
751
677
  Execute fixtures remotely through the full CI pipeline. Fixtures are defined in `.kici/tests/*.ts` using the `fixture()` factory function. Without arguments, lists available fixtures.
752
678
 
753
679
  Remote runs route through the Platform. Authenticate with a personal access token (`kici login`), then target an organization with `kici org use <org>` or the `--org` flag. The Platform relays the run to the org's orchestrator, while your working-tree overlay uploads directly to object storage — see [How the run is routed](https://docs.kici.dev/user/cli-reference/#how-the-run-is-routed) and [The two planes](https://docs.kici.dev/user/cli-reference/#the-two-planes) below.
754
680
 
755
- Like `kici run local`, `kici run remote` recompiles your workflows (`.kici/workflows` → `kici.lock.json`) before dispatching, so the orchestrator matches and dispatches against your current workflow definitions — a brand-new or edited workflow takes effect without a separate `kici compile`. A compile or validation error aborts the run before anything is uploaded.
681
+ Like `kici run <event> --local`, `kici run remote` recompiles your workflows (`.kici/workflows` → `kici.lock.json`) before dispatching, so the orchestrator matches and dispatches against your current workflow definitions — a brand-new or edited workflow takes effect without a separate `kici compile`. A compile or validation error aborts the run before anything is uploaded.
756
682
 
757
683
  The orchestrator must have **cache storage configured** (`KICI_STORAGE_TYPE` = `s3` or `filesystem`) with a dev-reachable upload endpoint so the CLI's direct upload succeeds; see the [testing guide](https://docs.kici.dev/user/testing-guide/) and [Storage layout](https://docs.kici.dev/operator/orchestrator/storage-layout/) for setup.
758
684
 
@@ -760,39 +686,6 @@ The orchestrator must have **cache storage configured** (`KICI_STORAGE_TYPE` = `
760
686
  kici run remote [fixture] [options]
761
687
  ```
762
688
 
763
- **Arguments:**
764
-
765
- | Argument | Required | Description |
766
- | --------- | -------- | ----------------------------------------------- |
767
- | `fixture` | no | Fixture name or glob pattern (omit to list all) |
768
-
769
- **Options:**
770
-
771
- | Option | Default | Description |
772
- | --------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
773
- | `--org <id>` | active | Target organization for this run (overrides `kici org use`) |
774
- | `--orchestrator <name>` | default | Target orchestrator cluster within the org (overrides the per-org default) |
775
- | `--all` | `false` | Run all fixtures |
776
- | `-p, --pick` | `false` | Interactively pick fixtures to run (multi-select; mutex with a fixture arg, `--all`, and `--workflow`) |
777
- | `--workflow <name>` | none | Run a specific workflow directly (bypass triggers) |
778
- | `--parallel` | `false` | Run multiple fixtures concurrently |
779
- | `--no-wait` | - | Fire and forget (print runIds, don't stream) |
780
- | `--quiet` | `false` | Minimal output (only final result) |
781
- | `--json` | `false` | Machine-readable JSON output |
782
- | `--junit <path>` | none | JUnit XML output to file for CI integration |
783
- | `--history` | `false` | Show table of recent test runs |
784
- | `--context <ctx.key=value>` | none | Inject a namespaced context secret, uploaded encrypted (repeatable) |
785
- | `--env <KEY=VALUE>` | none | Provide a per-run secret, uploaded encrypted (repeatable) — see [testing guide](https://docs.kici.dev/user/testing-guide/) |
786
- | `--input <KEY=VALUE>` | none | Typed workflow-dispatch input (repeatable) — validated + coerced + defaulted on the orchestrator from the lock descriptor, exposed as `ctx.dispatchInputs` (see [triggers → typed dispatch inputs](https://docs.kici.dev/user/sdk/triggers/#typed-dispatch-inputs)) |
787
- | `--target <selector>` | none | Narrow `runsOnAll` jobs to hosts matching this label selector (repeatable, AND-combined) |
788
- | `--target-allow-empty` | `false` | A `--target` that narrows a `runsOnAll` job to zero hosts skips it instead of failing |
789
- | `--debug` | `false` | Verbose internals |
790
- | `--kici-dir <path>` | `.kici` | Path to .kici directory |
791
- | `--routing-key <key>` | none | Override the routing key for this run (advanced; selecting the org normally suffices — see [How the run is routed](https://docs.kici.dev/user/cli-reference/#how-the-run-is-routed)) |
792
- | `--check` | `false` | Run in [check mode](https://docs.kici.dev/user/idempotent-steps/): each step reports drift instead of applying |
793
- | `--fail-on-drift` | `false` | In check mode, fail the run if any step reports drift (no effect without `--check`) |
794
- | `--approve-all, --yes` | `false` | Auto-approve every [approval gate](https://docs.kici.dev/user/approvals/) this run holds on (run-scoped; eligibility still enforced) |
795
-
796
689
  `--approve-all` works in `--json` / `--quiet` mode: the run still auto-approves each gate it holds on, and the auto-approve diagnostics are written to stderr so stdout stays a pure JSON (or summary-only) payload. Without `--approve-all`, a `--json` / `--quiet` run that hits a gate stays held and prints a one-line "run held; approve via the dashboard or `kici approve <run-id>`" notice to stderr per hold.
797
690
 
798
691
  **Examples:**
@@ -914,7 +807,7 @@ When an org has more than one connected orchestrator cluster, the CLI picks the
914
807
  - **Control plane** — run initiation, trigger, status, log retrieval, and cancellation flow from your machine through the Platform, which relays them over a WebSocket connection to the org's orchestrator. Logs are delivered by the CLI polling the Platform for log chunks (tracked by a monotonic line cursor) and run status until the run reaches a terminal state; there is no direct streaming socket to the orchestrator.
915
808
  - **Data plane** — your working-tree overlay tarball uploads **directly** from your machine to the orchestrator's object store via a presigned PUT URL. The overlay never passes through the Platform. This is why the orchestrator's object-store upload endpoint must be reachable from your machine; see [Storage layout](https://docs.kici.dev/operator/orchestrator/storage-layout/).
916
809
 
917
- An orchestrator with no Platform connection cannot serve remote runs — the Platform is the service that offers them. For executing workflow steps on your own machine without an orchestrator (no scaler, agents, or environments), use [`kici run local`](https://docs.kici.dev/user/cli-reference/#kici-run-local).
810
+ An orchestrator with no Platform connection cannot serve remote runs — the Platform is the service that offers them. For executing workflow steps on your own machine without an orchestrator (no scaler, agents, or environments), use [`kici run <event> --local`](https://docs.kici.dev/user/cli-reference/#kici-run-event---local).
918
811
 
919
812
  #### Fresh repos (no GitHub remote)
920
813
 
@@ -967,26 +860,6 @@ Preview which workflows match a trigger event (dry-run, no execution). Useful fo
967
860
  kici preview [event] [options]
968
861
  ```
969
862
 
970
- **Arguments:**
971
-
972
- | Argument | Required | Description |
973
- | -------- | -------- | ----------------------------------------------------------- |
974
- | `event` | no | Event type to preview (e.g., `push`, `pr:open`, `schedule`) |
975
-
976
- **Options:**
977
-
978
- | Option | Default | Description |
979
- | --------------------------- | ------- | ------------------------------------------------------------ |
980
- | `--workflow <name>` | none | Filter to specific workflow |
981
- | `--job <name>` | none | Filter to specific job |
982
- | `--branch <name>` | `main` | Override target branch for trigger matching |
983
- | `--sha <hash>` | none | Override commit SHA |
984
- | `--files <path>` | none | Simulate changed file path for trigger matching (repeatable) |
985
- | `--secret <key=value>` | none | Inject flat secret (repeatable) |
986
- | `--context <ctx.key=value>` | none | Inject context secret (repeatable) |
987
- | `--debug` | `false` | Verbose internals |
988
- | `--kici-dir <path>` | `.kici` | Path to .kici directory |
989
-
990
863
  **Examples:**
991
864
 
992
865
  ```bash
@@ -1013,7 +886,7 @@ kici preview push --files src/index.ts --files README.md
1013
886
  | 0 | Preview completed (including zero matches) |
1014
887
  | 1 | Error |
1015
888
 
1016
- **Migration from the old `test` command:** The dry-run preview command was renamed from `test` to `preview`. If you were using the old `test` command with a fixture name for remote fixture execution, use `kici run remote <fixture-name>` instead. For local workflow execution, use `kici run local <event>`.
889
+ **Migration from the old `test` command:** The dry-run preview command was renamed from `test` to `preview`. If you were using the old `test` command with a fixture name for remote fixture execution, use `kici run remote <fixture-name>` instead. For local workflow execution, use `kici run <event> --local`.
1017
890
 
1018
891
  ### kici login
1019
892
 
@@ -1029,16 +902,6 @@ After OAuth, the CLI exchanges the OIDC token for a personal access token (PAT)
1029
902
  kici login [options]
1030
903
  ```
1031
904
 
1032
- **Options:**
1033
-
1034
- | Option | Default | Description |
1035
- | --------------------------- | ------- | --------------------------------------------------- |
1036
- | `--token <key>` | none | API key for direct authentication (legacy) |
1037
- | `--device` | false | Force device authorization flow (headless/SSH) |
1038
- | `--platform-endpoint <url>` | none | Platform relay URL |
1039
- | `--oidc-issuer <url>` | none | OIDC issuer URL (selects a non-default environment) |
1040
- | `--routing-key <key>` | none | Routing key for webhook source identification |
1041
-
1042
905
  **Environment variables:**
1043
906
 
1044
907
  | Variable | Default | Description |
@@ -1124,12 +987,6 @@ Switch the active organization by name (case-insensitive) or ID.
1124
987
  kici org use <name>
1125
988
  ```
1126
989
 
1127
- **Arguments:**
1128
-
1129
- | Argument | Required | Description |
1130
- | -------- | -------- | ----------------------- |
1131
- | `name` | yes | Organization name or ID |
1132
-
1133
990
  **Examples:**
1134
991
 
1135
992
  ```bash
@@ -1165,14 +1022,6 @@ concurrency, and heartbeat age.
1165
1022
  kici diagnostics [options]
1166
1023
  ```
1167
1024
 
1168
- **Options:**
1169
-
1170
- | Option | Default | Description |
1171
- | --------------------- | ------- | --------------------------------------------------- |
1172
- | `--json` | `false` | Machine-readable JSON output |
1173
- | `--verbose` | `false` | Show extended per-agent fields (host, node, memory) |
1174
- | `--orchestrator <id>` | all | Scope the tree to one orchestrator connection id |
1175
-
1176
1025
  **Examples:**
1177
1026
 
1178
1027
  ```bash
@@ -1205,20 +1054,6 @@ branch, trigger, started, duration); pagination is reported at the bottom.
1205
1054
  kici runs list [options]
1206
1055
  ```
1207
1056
 
1208
- **Options:**
1209
-
1210
- | Option | Default | Description |
1211
- | ----------------------- | ------- | --------------------------------------------- |
1212
- | `--status <s>` | all | Filter by run status |
1213
- | `--workflow <w>` | all | Filter by workflow name |
1214
- | `--branch <b>` | all | Filter by branch/ref |
1215
- | `--repo <r>` | all | Filter by repository |
1216
- | `--trigger <t>` | all | Filter by trigger type |
1217
- | `--source <routingKey>` | all | Filter by source routing key |
1218
- | `--since <ts>` | none | Only runs since this ISO-8601 or epoch ms |
1219
- | `--page <n>` | `1` | Page number (server page size is fixed at 20) |
1220
- | `--json` | `false` | Machine-readable JSON output |
1221
-
1222
1057
  ```bash
1223
1058
  kici runs list
1224
1059
  kici runs list --status running
@@ -1230,16 +1065,12 @@ kici runs list --json | jq '.runs[].runId'
1230
1065
 
1231
1066
  Show a run's summary header plus its jobs-and-steps tree (name, status,
1232
1067
  duration, exit code). If the run id is not on the Platform but exists in your
1233
- local run history (from `kici run local`), the local record is shown instead.
1068
+ local run history (from `kici run <event> --local`), the local record is shown instead.
1234
1069
 
1235
1070
  ```bash
1236
1071
  kici runs show <run-id> [options]
1237
1072
  ```
1238
1073
 
1239
- | Option | Default | Description |
1240
- | -------- | ------- | ---------------------------- |
1241
- | `--json` | `false` | Machine-readable JSON output |
1242
-
1243
1074
  ```bash
1244
1075
  kici runs show abc123
1245
1076
  kici runs show abc123 --json
@@ -1253,12 +1084,6 @@ Print each job/step's log lines in order, with headers.
1253
1084
  kici runs logs <run-id> [options]
1254
1085
  ```
1255
1086
 
1256
- | Option | Default | Description |
1257
- | -------------- | ------- | -------------------------------------- |
1258
- | `--job <name>` | all | Only print logs for this job |
1259
- | `-f, --follow` | `false` | Tail logs for a live run until it ends |
1260
- | `--json` | `false` | Machine-readable JSON output |
1261
-
1262
1087
  ```bash
1263
1088
  kici runs logs abc123
1264
1089
  kici runs logs abc123 --job build
@@ -1274,10 +1099,6 @@ cooldown between reruns of the same run.
1274
1099
  kici runs rerun <run-id> [options]
1275
1100
  ```
1276
1101
 
1277
- | Option | Default | Description |
1278
- | -------- | ------- | ---------------------------- |
1279
- | `--json` | `false` | Machine-readable JSON output |
1280
-
1281
1102
  ```bash
1282
1103
  kici runs rerun abc123
1283
1104
  ```
@@ -1290,15 +1111,6 @@ Cancel a single run, or all in-progress runs on a branch.
1290
1111
  kici runs cancel [run-id] [options]
1291
1112
  ```
1292
1113
 
1293
- | Argument | Required | Description |
1294
- | -------- | -------- | ---------------- |
1295
- | `run-id` | no | Run ID to cancel |
1296
-
1297
- | Option | Default | Description |
1298
- | ----------------- | ------- | ------------------------------------------- |
1299
- | `--force` | `false` | Force cancel (kill immediately, skip hooks) |
1300
- | `--branch <name>` | none | Cancel all in-progress runs on this branch |
1301
-
1302
1114
  ```bash
1303
1115
  kici runs cancel abc123
1304
1116
  kici runs cancel abc123 --force
@@ -1319,19 +1131,6 @@ Approve a held [approval gate](https://docs.kici.dev/user/approvals/) so the run
1319
1131
  kici approve <run-id> [options]
1320
1132
  ```
1321
1133
 
1322
- **Arguments:**
1323
-
1324
- | Argument | Required | Description |
1325
- | -------- | -------- | ---------------------------------- |
1326
- | `run-id` | yes | Run ID holding the gate to approve |
1327
-
1328
- **Options:**
1329
-
1330
- | Option | Default | Description |
1331
- | ---------------- | ------- | ---------------------------------------------------- |
1332
- | `--job <name>` | none | Approve a held job (omit for a workflow-level hold) |
1333
- | `--step <index>` | none | Approve a held step by its index (used with `--job`) |
1334
-
1335
1134
  **Examples:**
1336
1135
 
1337
1136
  ```bash
@@ -1345,7 +1144,7 @@ kici approve abc123 --job deploy-production
1345
1144
  kici approve abc123 --job migrate-and-deploy --step 1
1346
1145
  ```
1347
1146
 
1348
- You must be eligible for at least one unsatisfied clause (a member of a named team, or a named user) and hold the `environments:write` or `ci_trust:write` permission. The command reports whether the element was released, how many clauses remain, or that it was rejected.
1147
+ You must be eligible for at least one unsatisfied clause (a member of a named team, or a named user) and hold the `contexts:write` or `ci_trust:write` permission. The command reports whether the element was released, how many clauses remain, or that it was rejected.
1349
1148
 
1350
1149
  ### kici reject
1351
1150
 
@@ -1355,20 +1154,6 @@ Reject a held [approval gate](https://docs.kici.dev/user/approvals/). A rejectio
1355
1154
  kici reject <run-id> --reason <text> [options]
1356
1155
  ```
1357
1156
 
1358
- **Arguments:**
1359
-
1360
- | Argument | Required | Description |
1361
- | -------- | -------- | --------------------------------- |
1362
- | `run-id` | yes | Run ID holding the gate to reject |
1363
-
1364
- **Options:**
1365
-
1366
- | Option | Default | Description |
1367
- | ----------------- | ------- | --------------------------------------------------- |
1368
- | `--reason <text>` | none | Required. Reason recorded with the rejection |
1369
- | `--job <name>` | none | Reject a held job (omit for a workflow-level hold) |
1370
- | `--step <index>` | none | Reject a held step by its index (used with `--job`) |
1371
-
1372
1157
  **Examples:**
1373
1158
 
1374
1159
  ```bash
@@ -1384,7 +1169,7 @@ List secret contexts available for test runs. Shows context names and key names
1384
1169
  kici secrets list
1385
1170
  ```
1386
1171
 
1387
- Each "context" corresponds to an environment configured on the orchestrator. The output lists every environment whose `allowLocalExecution` flag is `true` (the gate that lets CLI-initiated test runs resolve secrets through that environment), along with the secret key names reachable from the environment's bound scopes.
1172
+ Each context corresponds to a context configured on the orchestrator. The output lists every context whose `allowLocalExecution` flag is `true` (the gate that lets CLI-initiated test runs resolve secrets through that context), along with the secret key names reachable from the context's bound scopes.
1388
1173
 
1389
1174
  Only key names are shown — secret values are never returned over this endpoint.
1390
1175
 
@@ -1413,18 +1198,12 @@ See [Drive KiCI from your coding agent](https://docs.kici.dev/user/ai-agents/) f
1413
1198
 
1414
1199
  ### kici types
1415
1200
 
1416
- Generate TypeScript declaration files from orchestrator environment metadata. The generated `.d.ts` file augments the SDK's `KnownSecretKeys` and `EnvironmentSecrets` interfaces, providing compile-time autocomplete and type checking for secret key names.
1201
+ Generate TypeScript declaration files from orchestrator environment metadata. The generated `.d.ts` file augments the SDK's `KnownSecretKeys` and `ContextSecrets` interfaces, providing compile-time autocomplete and type checking for secret key names.
1417
1202
 
1418
1203
  ```bash
1419
1204
  kici types [options]
1420
1205
  ```
1421
1206
 
1422
- **Options:**
1423
-
1424
- | Option | Default | Description |
1425
- | ------------------- | ------- | ----------------------- |
1426
- | `--kici-dir <path>` | `.kici` | Path to .kici directory |
1427
-
1428
1207
  **Prerequisites:** Must be authenticated via `kici login`.
1429
1208
 
1430
1209
  **Output:** `.kici/types/secrets.d.ts`
@@ -1442,7 +1221,7 @@ kici types --kici-dir packages/app/.kici
1442
1221
  **How it works:**
1443
1222
 
1444
1223
  1. Fetches all environment metadata (environment names and secret key names) from the orchestrator
1445
- 2. Generates a `.d.ts` file that augments `@kici-dev/sdk`'s `KnownSecretKeys` and `EnvironmentSecrets` interfaces
1224
+ 2. Generates a `.d.ts` file that augments `@kici-dev/sdk`'s `KnownSecretKeys` and `ContextSecrets` interfaces
1446
1225
  3. Writes the file to `.kici/types/secrets.d.ts`
1447
1226
 
1448
1227
  After generating types, `ctx.secrets.get('MY_KEY')` and `ctx.secrets.expose('DB_HOST')` gain autocomplete and type checking in your IDE.
@@ -1461,20 +1240,8 @@ Generate a fixture template for an event type. Useful for creating custom test p
1461
1240
  kici fixture <event> [options]
1462
1241
  ```
1463
1242
 
1464
- **Arguments:**
1465
-
1466
- | Argument | Required | Description |
1467
- | -------- | -------- | ----------------------------- |
1468
- | `event` | yes | Event to generate fixture for |
1469
-
1470
1243
  **Valid events:** `pr:open`, `pr:sync`, `pr:close`, `pr:reopen`, `push`, `tag`, `comment`, `review`, `review_comment`, `release`, `dispatch`, `create`, `delete`, `status`, `workflow_run`, `fork`, `star`, `watch`, `kici_event`, `workflow_complete`, `job_complete`, `generic_webhook`, `schedule`, `lifecycle` (many support `:action` suffixes, e.g. `comment:edited`, `release:published`, `lifecycle:workflow_complete`). `webhook:<source>` is a shorthand alias for `generic_webhook:<source>`.
1471
1244
 
1472
- **Options:**
1473
-
1474
- | Option | Default | Description |
1475
- | ----------------- | ------- | ------------------------------- |
1476
- | `--output <path>` | stdout | Write to file instead of stdout |
1477
-
1478
1245
  **Examples:**
1479
1246
 
1480
1247
  ```bash
@@ -1503,19 +1270,6 @@ Initialize a `.kici/` directory with default workflow templates.
1503
1270
  kici init [options]
1504
1271
  ```
1505
1272
 
1506
- **Options:**
1507
-
1508
- | Option | Default | Description |
1509
- | ------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------- |
1510
- | `--force` | `false` | Overwrite existing `.kici/` directory |
1511
- | `--skip-install` | `false` | Create files without installing dependencies |
1512
- | `--package-manager <npm\|pnpm\|yarn>` | auto-detect | Force a package manager for the install step (default: detect from your repo) |
1513
- | `--mjs` | `false` | JavaScript-only mode (no TypeScript, no deps) |
1514
- | `--no-agents-md` | writes `AGENTS.md` | Skip writing `.kici/AGENTS.md` (the LLM authoring context file) |
1515
- | `--private-registry <url>` | none | Scaffold a workflow `registries:` entry pointing at `<url>` (e.g. CodeArtifact, GH Packages, Verdaccio) |
1516
- | `--private-registry-scope <scope>` | none | Optional npm package scope (e.g. `@my-org`) for the private registry |
1517
- | `--private-registry-secret <ref>` | `production:NPM_TOKEN` | Qualified secret reference (`env:NAME`) the private registry token comes from |
1518
-
1519
1273
  **Examples:**
1520
1274
 
1521
1275
  ```bash
@@ -1575,12 +1329,6 @@ Install a pre-commit hook that runs `kici compile` before each commit.
1575
1329
  kici hook install [options]
1576
1330
  ```
1577
1331
 
1578
- **Options:**
1579
-
1580
- | Option | Default | Description |
1581
- | ------- | ------- | ------------------------------------------ |
1582
- | `--git` | `false` | Use raw git hook (`.git/hooks/pre-commit`) |
1583
-
1584
1332
  **Examples:**
1585
1333
 
1586
1334
  ```bash
@@ -1607,12 +1355,6 @@ List all webhook entrypoints for the current project. Reads the compiled lock fi
1607
1355
  kici endpoints [options]
1608
1356
  ```
1609
1357
 
1610
- **Options:**
1611
-
1612
- | Option | Default | Description |
1613
- | ------------------- | ------- | ----------------------- |
1614
- | `--kici-dir <path>` | `.kici` | Path to .kici directory |
1615
-
1616
1358
  **Prerequisites:** Run `kici compile` first to generate the lock file.
1617
1359
 
1618
1360
  **Examples:**
@@ -1633,15 +1375,6 @@ List permanently registered workflows on the orchestrator.
1633
1375
  kici workflows list [options]
1634
1376
  ```
1635
1377
 
1636
- **Options:**
1637
-
1638
- | Option | Default | Description |
1639
- | ----------------------- | ------- | ---------------------------------------------- |
1640
- | `--json` | `false` | Output as JSON |
1641
- | `--stale <duration>` | none | Filter stale registrations (e.g., `30d`, `7d`) |
1642
- | `--trigger-type <type>` | none | Filter by trigger type |
1643
- | `--repo <repo>` | none | Filter by repository |
1644
-
1645
1378
  **Examples:**
1646
1379
 
1647
1380
  ```bash
@@ -1701,12 +1434,6 @@ Trigger graceful drain on a worker instance. Sends a POST request to the worker'
1701
1434
  kici admin drain-worker [options]
1702
1435
  ```
1703
1436
 
1704
- **Options:**
1705
-
1706
- | Option | Required | Description |
1707
- | ------------- | -------- | --------------------------------------------- |
1708
- | `--url <url>` | yes | Worker URL (e.g., `http://worker-host:10143`) |
1709
-
1710
1437
  **Examples:**
1711
1438
 
1712
1439
  ```bash
@@ -1734,21 +1461,6 @@ On success the output prints the **origin org** (the customer's public org id
1734
1461
  kici verify-attestation [artifact] --bundle <path-or-url> [--trust-root <url-or-file>] [options]
1735
1462
  ```
1736
1463
 
1737
- **Arguments:**
1738
-
1739
- | Argument | Required | Description |
1740
- | ------------ | -------- | --------------------------------------------------------------------- |
1741
- | `[artifact]` | no | Artifact path to digest-check against the attestation subject digest. |
1742
-
1743
- **Options:**
1744
-
1745
- | Option | Required | Description |
1746
- | ---------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- |
1747
- | `--bundle <path-or-url>` | yes | Path or `http(s)` URL to the attestation bundle JSON. |
1748
- | `--trust-root <url-or-file>` | no | Trusted issuer (see below). Defaults to the hosted KiCI platform. The token issuer is pinned to it, never taken from the token. |
1749
- | `--audience <aud>` | no | Expected token audience (defaults to the KiCI provenance audience). |
1750
- | `--json` | no | Print the structured verification result as JSON instead of human-readable output. |
1751
-
1752
1464
  **Trust root:** `--trust-root` defaults to the hosted KiCI platform's provenance issuer — the same platform you `kici login` against (see [Which trust root do I use?](https://docs.kici.dev/user/provenance/#which-trust-root-do-i-use)), so the common case needs no flag. The verifier never trusts the issuer named inside the token; supplying it out-of-band is what prevents a forged bundle from self-attesting. To override the default, pass `--trust-root` in one of two forms:
1753
1465
 
1754
1466
  - **Online — an HTTPS issuer URL.** The verifier fetches `<url>/.well-known/openid-configuration`, reads its `issuer` and `jwks_uri`, and fetches the JWKS. The token's `iss` is pinned to the discovery document's `issuer`.
@@ -1804,6 +1516,628 @@ the authoritative anchor.
1804
1516
  | 0 | Verified — signature, identity, build context (and digest, if checked) all pass |
1805
1517
  | 1 | Not verified, or an error (missing `--bundle`, unreadable bundle, unreachable trust root) |
1806
1518
 
1519
+ ## Command reference
1520
+
1521
+ The exhaustive, always-current list of every `kici` command with its arguments and options, generated from the CLI's command tree so it never drifts from the shipped binary. The sections above add concepts and worked examples; the reference below is the authoritative signature list.
1522
+
1523
+ <!-- BEGIN GENERATED: kici-commands (do not edit; run the doc generator) -->
1524
+
1525
+ ### `kici admin`
1526
+
1527
+ Operator-facing commands for running instances
1528
+
1529
+ Synopsis: `kici admin`
1530
+
1531
+ ### `kici admin drain-worker`
1532
+
1533
+ Trigger graceful drain on a worker instance
1534
+
1535
+ Synopsis: `kici admin drain-worker [options]`
1536
+
1537
+ **Options**
1538
+
1539
+ | Option | Default | Description |
1540
+ | ------------- | ------- | -------------------------------------------- |
1541
+ | `--url <url>` | | Worker URL (e.g., http://worker-host:<port>) |
1542
+
1543
+ ### `kici approve`
1544
+
1545
+ Approve a held approval gate for a run
1546
+
1547
+ Synopsis: `kici approve <run-id> [options]`
1548
+
1549
+ **Arguments**
1550
+
1551
+ | Argument | Required | Variadic | Description |
1552
+ | -------- | -------- | -------- | ------------------------------------- |
1553
+ | `run-id` | yes | no | Run ID whose approval gate to approve |
1554
+
1555
+ **Options**
1556
+
1557
+ | Option | Default | Description |
1558
+ | ---------------- | ------- | ------------------------------------------- |
1559
+ | `--job <name>` | | Approve the hold for a specific job |
1560
+ | `--step <index>` | | Approve a step-scoped hold (requires --job) |
1561
+
1562
+ ### `kici compile`
1563
+
1564
+ Compile workflows from .kici/workflows/ to kici.lock.json
1565
+
1566
+ Synopsis: `kici compile [options]`
1567
+
1568
+ **Options**
1569
+
1570
+ | Option | Default | Description |
1571
+ | ------------------- | ------- | -------------------------------------------- |
1572
+ | `--check` | `false` | Validate workflows without writing lock file |
1573
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
1574
+ | `--verbose` | `false` | Detailed output |
1575
+ | `--watch` | `false` | Watch for changes and recompile |
1576
+
1577
+ ### `kici diagnostics`
1578
+
1579
+ Show orchestrators, scalers, and agents (mirrors the dashboard Diagnostics page)
1580
+
1581
+ Synopsis: `kici diagnostics [options]`
1582
+
1583
+ **Options**
1584
+
1585
+ | Option | Default | Description |
1586
+ | --------------------- | ------- | ----------------------------------- |
1587
+ | `--json` | `false` | Output raw JSON |
1588
+ | `--verbose` | `false` | Show extended per-agent fields |
1589
+ | `--orchestrator <id>` | | Scope the tree to one connection id |
1590
+
1591
+ ### `kici docs`
1592
+
1593
+ Open the KiCI documentation site in the default browser
1594
+
1595
+ Synopsis: `kici docs [options]`
1596
+
1597
+ **Options**
1598
+
1599
+ | Option | Default | Description |
1600
+ | ----------- | ------- | ----------------------------------------------- |
1601
+ | `--no-open` | | Print the docs URL instead of opening a browser |
1602
+
1603
+ ### `kici docs llm`
1604
+
1605
+ Print KiCI LLM docs bundles. No topic prints the llms.txt index; <topic> prints a task bundle (e.g. sdk, cli, patterns, features, providers, architecture, getting-started); "full" prints the complete bundle.
1606
+
1607
+ Synopsis: `kici docs llm [topic] [options]`
1608
+
1609
+ **Arguments**
1610
+
1611
+ | Argument | Required | Variadic | Description |
1612
+ | -------- | -------- | -------- | ----------- |
1613
+ | `topic` | no | no | |
1614
+
1615
+ **Options**
1616
+
1617
+ | Option | Default | Description |
1618
+ | -------------- | ------- | -------------------------------------------- |
1619
+ | `--out <path>` | | Write the bundle to a file instead of stdout |
1620
+
1621
+ ### `kici endpoints`
1622
+
1623
+ List all webhook entrypoints for the current project
1624
+
1625
+ Synopsis: `kici endpoints [options]`
1626
+
1627
+ **Options**
1628
+
1629
+ | Option | Default | Description |
1630
+ | ------------------- | ------- | ----------------------- |
1631
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
1632
+
1633
+ ### `kici fixture`
1634
+
1635
+ Generate fixture template for event type
1636
+
1637
+ Synopsis: `kici fixture <event> [options]`
1638
+
1639
+ **Arguments**
1640
+
1641
+ | Argument | Required | Variadic | Description |
1642
+ | -------- | -------- | -------- | ------------------------------------------------------------------------------------------ |
1643
+ | `event` | yes | no | Event to generate fixture for (e.g., pr:open, push, schedule, lifecycle:workflow_complete) |
1644
+
1645
+ **Options**
1646
+
1647
+ | Option | Default | Description |
1648
+ | ----------------- | ------- | ------------------------------- |
1649
+ | `--output <path>` | | Write to file instead of stdout |
1650
+
1651
+ ### `kici hook`
1652
+
1653
+ Manage pre-commit hooks
1654
+
1655
+ Synopsis: `kici hook`
1656
+
1657
+ ### `kici hook install`
1658
+
1659
+ Install kici compile pre-commit hook
1660
+
1661
+ Synopsis: `kici hook install [options]`
1662
+
1663
+ **Options**
1664
+
1665
+ | Option | Default | Description |
1666
+ | ------- | ------- | ---------------------------------------- |
1667
+ | `--git` | `false` | Use raw git hook (.git/hooks/pre-commit) |
1668
+
1669
+ ### `kici init`
1670
+
1671
+ Initialize .kici/ directory with default workflows
1672
+
1673
+ Synopsis: `kici init [options]`
1674
+
1675
+ **Options**
1676
+
1677
+ | Option | Default | Description |
1678
+ | ---------------------------------- | ---------------------- | --------------------------------------------------------------------------- | --- | ------------------------------------------------------------------- |
1679
+ | `--force` | `false` | Overwrite existing .kici/ directory |
1680
+ | `--skip-install` | `false` | Create files without installing dependencies |
1681
+ | `--package-manager <npm | pnpm | yarn>` | | Force a package manager for the install step (default: auto-detect) |
1682
+ | `--mjs` | `false` | JavaScript-only mode (no TypeScript, no dependencies) |
1683
+ | `--no-agents-md` | | Skip writing .kici/AGENTS.md (LLM authoring context) |
1684
+ | `--private-registry <url>` | | Scaffold a workflow registries: entry pointing at <url> |
1685
+ | `--private-registry-scope <scope>` | | Optional npm package scope (e.g. @my-org) for the private registry |
1686
+ | `--private-registry-secret <ref>` | `production:NPM_TOKEN` | Qualified secret reference (env:NAME) the private registry token comes from |
1687
+ | `--use-verdaccio-local` | `false` | |
1688
+
1689
+ ### `kici local`
1690
+
1691
+ Manage the local dev orchestrator plane
1692
+
1693
+ Synopsis: `kici local`
1694
+
1695
+ ### `kici local attach`
1696
+
1697
+ Attach the local dev plane to the Platform (hybrid)
1698
+
1699
+ Synopsis: `kici local attach`
1700
+
1701
+ ### `kici local detach`
1702
+
1703
+ Detach the local dev plane from the Platform (offline)
1704
+
1705
+ Synopsis: `kici local detach`
1706
+
1707
+ ### `kici local down`
1708
+
1709
+ Stop the local dev plane
1710
+
1711
+ Synopsis: `kici local down`
1712
+
1713
+ ### `kici local logs`
1714
+
1715
+ Print the local dev plane orchestrator log path
1716
+
1717
+ Synopsis: `kici local logs`
1718
+
1719
+ ### `kici local status`
1720
+
1721
+ Show local dev plane status and control commands
1722
+
1723
+ Synopsis: `kici local status`
1724
+
1725
+ ### `kici local trust-root`
1726
+
1727
+ Export the offline dev-signed identity trust root ({ issuer, jwks }) to a file
1728
+
1729
+ Synopsis: `kici local trust-root <file>`
1730
+
1731
+ **Arguments**
1732
+
1733
+ | Argument | Required | Variadic | Description |
1734
+ | -------- | -------- | -------- | ---------------------------------------------------- |
1735
+ | `file` | yes | no | Output path for the { issuer, jwks } trust-root JSON |
1736
+
1737
+ ### `kici local up`
1738
+
1739
+ Start (or reuse) the local dev plane
1740
+
1741
+ Synopsis: `kici local up [options]`
1742
+
1743
+ **Options**
1744
+
1745
+ | Option | Default | Description |
1746
+ | ------------- | ------- | ---------------------------------------------------------------------------- |
1747
+ | `--offline` | `false` | Force the independent (offline) plane (does not clear the attachment record) |
1748
+ | `--connected` | `false` | Force the connected/hybrid plane (requires an attached, reachable Platform) |
1749
+
1750
+ ### `kici login`
1751
+
1752
+ Authenticate with KiCI via browser OAuth (default) or API key (--token)
1753
+
1754
+ Synopsis: `kici login [options]`
1755
+
1756
+ **Options**
1757
+
1758
+ | Option | Default | Description |
1759
+ | --------------------------- | ------- | ----------------------------------------------------------------------------------- |
1760
+ | `--token <key>` | | API key for direct authentication (legacy) |
1761
+ | `--device` | | Force device authorization flow (for headless/SSH environments) |
1762
+ | `--platform-endpoint <url>` | | Platform relay URL |
1763
+ | `--oidc-issuer <url>` | | OIDC issuer URL (defaults to the hosted KiCI IdP unless a flag/env selects another) |
1764
+ | `--routing-key <key>` | | Routing key for webhook source identification |
1765
+ | `--no-attach` | | Skip the post-login prompt to attach the local dev plane |
1766
+
1767
+ ### `kici logout`
1768
+
1769
+ Revoke PAT and clear local credentials
1770
+
1771
+ Synopsis: `kici logout`
1772
+
1773
+ ### `kici orchestrators`
1774
+
1775
+ Inspect the org's orchestrator clusters and pick a default for run remote
1776
+
1777
+ Synopsis: `kici orchestrators`
1778
+
1779
+ ### `kici orchestrators list`
1780
+
1781
+ List the connected orchestrator clusters for the active org
1782
+
1783
+ Synopsis: `kici orchestrators list [options]`
1784
+
1785
+ **Options**
1786
+
1787
+ | Option | Default | Description |
1788
+ | ------------ | ------- | ---------------------------------------------- |
1789
+ | `--org <id>` | | Target organization (overrides the active org) |
1790
+
1791
+ ### `kici orchestrators use`
1792
+
1793
+ Set the per-org default orchestrator cluster for run remote
1794
+
1795
+ Synopsis: `kici orchestrators use <name> [options]`
1796
+
1797
+ **Arguments**
1798
+
1799
+ | Argument | Required | Variadic | Description |
1800
+ | -------- | -------- | -------- | ------------------------- |
1801
+ | `name` | yes | no | Orchestrator cluster name |
1802
+
1803
+ **Options**
1804
+
1805
+ | Option | Default | Description |
1806
+ | ------------ | ------- | ---------------------------------------------- |
1807
+ | `--org <id>` | | Target organization (overrides the active org) |
1808
+
1809
+ ### `kici org`
1810
+
1811
+ Manage organizations
1812
+
1813
+ Synopsis: `kici org`
1814
+
1815
+ ### `kici org current`
1816
+
1817
+ Show current active organization
1818
+
1819
+ Synopsis: `kici org current`
1820
+
1821
+ ### `kici org list`
1822
+
1823
+ List organizations you belong to
1824
+
1825
+ Synopsis: `kici org list`
1826
+
1827
+ ### `kici org use`
1828
+
1829
+ Switch active organization
1830
+
1831
+ Synopsis: `kici org use <name>`
1832
+
1833
+ **Arguments**
1834
+
1835
+ | Argument | Required | Variadic | Description |
1836
+ | -------- | -------- | -------- | ----------------------- |
1837
+ | `name` | yes | no | Organization name or ID |
1838
+
1839
+ ### `kici pat`
1840
+
1841
+ Manage personal access tokens
1842
+
1843
+ Synopsis: `kici pat`
1844
+
1845
+ ### `kici pat create`
1846
+
1847
+ Mint a personal access token (use --agent for a coding-agent token)
1848
+
1849
+ Synopsis: `kici pat create [options]`
1850
+
1851
+ **Options**
1852
+
1853
+ | Option | Default | Description |
1854
+ | ----------------------- | ------- | ---------------------------------------------- |
1855
+ | `--name <name>` | | Token name (defaults to the agent label) |
1856
+ | `--agent` | `false` | Mint an agent-kind PAT for the KiCI MCP server |
1857
+ | `--expires-in-days <n>` | | Custom expiry in days |
1858
+
1859
+ ### `kici preview`
1860
+
1861
+ Preview which workflows match a trigger event (no execution)
1862
+
1863
+ Synopsis: `kici preview [event] [options]`
1864
+
1865
+ **Arguments**
1866
+
1867
+ | Argument | Required | Variadic | Description |
1868
+ | -------- | -------- | -------- | ----------------------------------------------------- |
1869
+ | `event` | no | no | Event type to preview (e.g., push, pr:open, schedule) |
1870
+
1871
+ **Options**
1872
+
1873
+ | Option | Default | Description |
1874
+ | --------------------------- | ------- | ------------------------------------------------------------ |
1875
+ | `--branch <name>` | | Override target branch for trigger matching (default: main) |
1876
+ | `--sha <hash>` | | Override commit SHA |
1877
+ | `--workflow <name>` | | Filter to specific workflow in display |
1878
+ | `--job <name>` | | Filter to specific job in display |
1879
+ | `--debug` | `false` | Verbose internals |
1880
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
1881
+ | `--files <path>` | | Simulate changed file path for trigger matching (repeatable) |
1882
+ | `--secret <key=value>` | | Inject flat secret (repeatable) |
1883
+ | `--context <ctx.key=value>` | | Inject context secret (repeatable) |
1884
+
1885
+ ### `kici reject`
1886
+
1887
+ Reject a held approval gate for a run
1888
+
1889
+ Synopsis: `kici reject <run-id> [options]`
1890
+
1891
+ **Arguments**
1892
+
1893
+ | Argument | Required | Variadic | Description |
1894
+ | -------- | -------- | -------- | ------------------------------------ |
1895
+ | `run-id` | yes | no | Run ID whose approval gate to reject |
1896
+
1897
+ **Options**
1898
+
1899
+ | Option | Default | Description |
1900
+ | ----------------- | ------- | ------------------------------------------ |
1901
+ | `--job <name>` | | Reject the hold for a specific job |
1902
+ | `--step <index>` | | Reject a step-scoped hold (requires --job) |
1903
+ | `--reason <text>` | | Reason for the rejection |
1904
+
1905
+ ### `kici run`
1906
+
1907
+ Execute workflows locally or remotely
1908
+
1909
+ Synopsis: `kici run [event] [options]`
1910
+
1911
+ **Arguments**
1912
+
1913
+ | Argument | Required | Variadic | Description |
1914
+ | -------- | -------- | -------- | ------------------------------------------------------ |
1915
+ | `event` | no | no | Event type for a routed local run (e.g. push, pr:open) |
1916
+
1917
+ **Options**
1918
+
1919
+ | Option | Default | Description |
1920
+ | ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
1921
+ | `--local` | `false` | Route the run with this machine as the ephemeral agent |
1922
+ | `--offline` | `false` | Force the throwaway/independent plane (offline) |
1923
+ | `--connected` | `false` | Force the connected/hybrid plane (requires attachment) |
1924
+ | `--in-place` | `false` | Reuse the working tree directly instead of an isolated clone |
1925
+ | `--trusted` | `false` | Route to the trusted fleet agent profile: steps see the ambient host env (minus the agent identity). Alias: --no-sandbox |
1926
+ | `--no-sandbox` | | Alias for --trusted (the bwrap sandbox is already off by default) |
1927
+ | `--env <KEY=VALUE>` | | Per-run secret (repeatable) |
1928
+ | `--payload <path>` | | Dispatch payload JSON { action?, client_payload? } for a routed dispatch run |
1929
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
1930
+ | `--quiet` | `false` | Suppress the banner + streaming output |
1931
+ | `--debug` | `false` | Verbose internals |
1932
+
1933
+ ### `kici run remote`
1934
+
1935
+ Execute fixtures remotely via orchestrator
1936
+
1937
+ Synopsis: `kici run remote [fixture] [options]`
1938
+
1939
+ **Arguments**
1940
+
1941
+ | Argument | Required | Variadic | Description |
1942
+ | --------- | -------- | -------- | ----------------------------------------------------- |
1943
+ | `fixture` | no | no | Fixture name or glob pattern (omit to list available) |
1944
+
1945
+ **Options**
1946
+
1947
+ | Option | Default | Description |
1948
+ | --------------------------- | ------- | ------------------------------------------------------------------------------------------- |
1949
+ | `--workflow <name>` | | Run a specific workflow directly (bypass triggers) |
1950
+ | `--all` | `false` | Run all available fixtures |
1951
+ | `-p, --pick` | `false` | Interactively pick fixtures to run |
1952
+ | `--parallel` | `false` | Run matching fixtures concurrently |
1953
+ | `--no-wait` | | Fire and forget (print runIds, don't stream) |
1954
+ | `--quiet` | `false` | Suppress output except final result |
1955
+ | `--json` | `false` | Output structured JSON result |
1956
+ | `--junit <path>` | | Output JUnit XML result |
1957
+ | `--history` | `false` | Show recent run history |
1958
+ | `--routing-key <key>` | | Override routing key for this run |
1959
+ | `--org <id>` | | Target organization (overrides the active org) |
1960
+ | `--orchestrator <name>` | | Target orchestrator cluster (overrides the per-org default) |
1961
+ | `--debug` | `false` | Verbose internals |
1962
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
1963
+ | `--context <ctx.key=value>` | | Inject a namespaced context secret, uploaded encrypted to the orchestrator (repeatable) |
1964
+ | `--env <KEY=VALUE>` | | Provide a per-run secret (repeatable); uploaded encrypted to the orchestrator |
1965
+ | `--check` | `false` | Run in check mode: report drift, change nothing |
1966
+ | `--fail-on-drift` | `false` | In check mode, exit non-zero if any step reports drift |
1967
+ | `--target <selector>` | | Narrow runsOnAll jobs to hosts matching this label selector (repeatable, AND-combined) |
1968
+ | `--target-allow-empty` | `false` | A --target that narrows a runsOnAll job to zero hosts skips it instead of failing |
1969
+ | `--input <KEY=VALUE>` | | Typed workflow-dispatch input (repeatable) |
1970
+ | `--yes, --approve-all` | `false` | Auto-approve every approval gate this run holds on (run-scoped; eligibility still enforced) |
1971
+
1972
+ ### `kici runs`
1973
+
1974
+ Inspect and manage execution runs
1975
+
1976
+ Synopsis: `kici runs`
1977
+
1978
+ ### `kici runs cancel`
1979
+
1980
+ Cancel a run, or all in-progress runs on a branch
1981
+
1982
+ Synopsis: `kici runs cancel [run-id] [options]`
1983
+
1984
+ **Arguments**
1985
+
1986
+ | Argument | Required | Variadic | Description |
1987
+ | -------- | -------- | -------- | ---------------- |
1988
+ | `run-id` | no | no | Run ID to cancel |
1989
+
1990
+ **Options**
1991
+
1992
+ | Option | Default | Description |
1993
+ | ----------------- | ------- | ------------------------------------------- |
1994
+ | `--force` | `false` | Force cancel (kill immediately, skip hooks) |
1995
+ | `--branch <name>` | | Cancel all in-progress runs on this branch |
1996
+
1997
+ ### `kici runs list`
1998
+
1999
+ List execution runs (mirrors the dashboard Runs page)
2000
+
2001
+ Synopsis: `kici runs list [options]`
2002
+
2003
+ **Options**
2004
+
2005
+ | Option | Default | Description |
2006
+ | ----------------------- | ------- | -------------------------------------- |
2007
+ | `--status <s>` | | Filter by status |
2008
+ | `--workflow <w>` | | Filter by workflow name |
2009
+ | `--branch <b>` | | Filter by branch/ref |
2010
+ | `--repo <r>` | | Filter by repository |
2011
+ | `--trigger <t>` | | Filter by trigger type |
2012
+ | `--source <routingKey>` | | Filter by source routing key |
2013
+ | `--since <ts>` | | Only runs since (ISO-8601 or epoch ms) |
2014
+ | `--page <n>` | | Page number |
2015
+ | `--json` | `false` | Output raw JSON |
2016
+
2017
+ ### `kici runs logs`
2018
+
2019
+ Print step logs for a run
2020
+
2021
+ Synopsis: `kici runs logs <run-id> [options]`
2022
+
2023
+ **Arguments**
2024
+
2025
+ | Argument | Required | Variadic | Description |
2026
+ | -------- | -------- | -------- | ----------- |
2027
+ | `run-id` | yes | no | Run ID |
2028
+
2029
+ **Options**
2030
+
2031
+ | Option | Default | Description |
2032
+ | -------------- | ------- | ------------------------ |
2033
+ | `--job <name>` | | Only logs for this job |
2034
+ | `-f, --follow` | `false` | Tail logs for a live run |
2035
+ | `--json` | `false` | Output raw JSON |
2036
+
2037
+ ### `kici runs rerun`
2038
+
2039
+ Re-trigger a run
2040
+
2041
+ Synopsis: `kici runs rerun <run-id> [options]`
2042
+
2043
+ **Arguments**
2044
+
2045
+ | Argument | Required | Variadic | Description |
2046
+ | -------- | -------- | -------- | --------------- |
2047
+ | `run-id` | yes | no | Run ID to rerun |
2048
+
2049
+ **Options**
2050
+
2051
+ | Option | Default | Description |
2052
+ | -------- | ------- | --------------- |
2053
+ | `--json` | `false` | Output raw JSON |
2054
+
2055
+ ### `kici runs show`
2056
+
2057
+ Show a run summary with its jobs and steps
2058
+
2059
+ Synopsis: `kici runs show <run-id> [options]`
2060
+
2061
+ **Arguments**
2062
+
2063
+ | Argument | Required | Variadic | Description |
2064
+ | -------- | -------- | -------- | ----------------- |
2065
+ | `run-id` | yes | no | Run ID to inspect |
2066
+
2067
+ **Options**
2068
+
2069
+ | Option | Default | Description |
2070
+ | -------- | ------- | --------------- |
2071
+ | `--json` | `false` | Output raw JSON |
2072
+
2073
+ ### `kici secrets`
2074
+
2075
+ Manage secrets
2076
+
2077
+ Synopsis: `kici secrets`
2078
+
2079
+ ### `kici secrets list`
2080
+
2081
+ List test-available secret contexts
2082
+
2083
+ Synopsis: `kici secrets list`
2084
+
2085
+ ### `kici types`
2086
+
2087
+ Generate TypeScript declarations for secret contexts
2088
+
2089
+ Synopsis: `kici types [options]`
2090
+
2091
+ **Options**
2092
+
2093
+ | Option | Default | Description |
2094
+ | ------------------- | ------- | ----------------------- |
2095
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
2096
+
2097
+ ### `kici verify-attestation`
2098
+
2099
+ Verify a KiCI provenance attestation bundle offline
2100
+
2101
+ Synopsis: `kici verify-attestation [artifact] [options]`
2102
+
2103
+ **Arguments**
2104
+
2105
+ | Argument | Required | Variadic | Description |
2106
+ | ---------- | -------- | -------- | ------------------------------------------------------------------------ |
2107
+ | `artifact` | no | no | Artifact path to digest-check against the attestation subject (optional) |
2108
+
2109
+ **Options**
2110
+
2111
+ | Option | Default | Description |
2112
+ | ---------------------------- | ------- | --------------------------------------------------------------------------------------------- |
2113
+ | `--bundle <path>` | | Path or URL to the attestation bundle JSON |
2114
+ | `--trust-root <url-or-file>` | | Trusted issuer URL, or a self-contained { issuer, jwks } file (default: hosted KiCI platform) |
2115
+ | `--audience <aud>` | | Expected token audience |
2116
+ | `--json` | `false` | Output structured JSON result |
2117
+
2118
+ ### `kici workflows`
2119
+
2120
+ Manage workflow registrations
2121
+
2122
+ Synopsis: `kici workflows`
2123
+
2124
+ ### `kici workflows list`
2125
+
2126
+ List permanently registered workflows
2127
+
2128
+ Synopsis: `kici workflows list [options]`
2129
+
2130
+ **Options**
2131
+
2132
+ | Option | Default | Description |
2133
+ | ----------------------- | ------- | ------------------------------------------ |
2134
+ | `--json` | `false` | Output as JSON |
2135
+ | `--stale <duration>` | | Filter stale registrations (e.g., 30d, 7d) |
2136
+ | `--trigger-type <type>` | | Filter by trigger type |
2137
+ | `--repo <repo>` | | Filter by repository |
2138
+
2139
+ <!-- END GENERATED: kici-commands -->
2140
+
1807
2141
  ## Workflow discovery
1808
2142
 
1809
2143
  The CLI discovers workflows by scanning `.kici/workflows/*.ts` (or `.mjs` in MJS mode). Each file should `export default` a single workflow:
@@ -1844,11 +2178,11 @@ All commands follow a consistent exit code convention:
1844
2178
 
1845
2179
  ## Debug output
1846
2180
 
1847
- Use `--debug` (on `kici run local`, `kici run remote`, `kici preview`) or `--verbose` (on `kici compile`) for detailed output:
2181
+ Use `--debug` (on `kici run <event> --local`, `kici run remote`, `kici preview`) or `--verbose` (on `kici compile`) for detailed output:
1848
2182
 
1849
2183
  ```bash
1850
2184
  # Shows trigger matching, rule evaluation, decision traces
1851
- kici run local push --debug
2185
+ kici run push --local --debug
1852
2186
 
1853
2187
  # Shows detailed compilation steps
1854
2188
  kici compile --verbose
@@ -2150,14 +2484,14 @@ Each workflow entry includes:
2150
2484
  | `contentHash` | SHA-256 of the raw workflow source mixed with `compileSchemaVersion` (and an `assetDigest` of declared `hashFiles` when present): `SHA-256(compileSchemaVersion + ":" + rawSource [+ "\0" + assetDigest])`. The orchestrator uses this as the source-tarball cache key and the agent re-computes it against the extracted source to detect drift. |
2151
2485
  | `compileSchemaVersion` | Compiler schema version used when computing `contentHash` (currently `5`). The hash input is line-ending-normalized (CRLF → LF) so a lock file produced on Linux matches the agent's hash on Windows where Git's `core.autocrlf=true` rewrites checked-out text to CRLF. Bumping the schema version invalidates every existing source cache entry even if source is unchanged, which is the correct behavior when the compile-time or runtime contract changes. |
2152
2486
  | `triggers` | Trigger definitions extracted from the workflow (used by the orchestrator for event matching). |
2153
- | `jobs` | Job definitions with scheduling metadata (runsOn, needs, matrix, environment, concurrency, container, checkout, gracePeriod, label routing, dynamic fields, etc.). |
2487
+ | `jobs` | Job definitions with scheduling metadata (runsOn, needs, matrix, contexts, concurrency, container, checkout, gracePeriod, label routing, dynamic fields, etc.). |
2154
2488
  | `rules` | Workflow-level conditional rules (optional). Stored as dynamic references since rule functions cannot be serialized. |
2155
2489
  | `description` | Optional workflow description. |
2156
2490
  | `hashFiles` | Declared glob patterns for extra files included in the content hash (optional). See [extra files in the content hash](https://docs.kici.dev/user/lock-file-and-drift/#extra-files-in-the-content-hash-hashfiles). |
2157
2491
  | `resolvedHashFiles` | Resolved file paths from `hashFiles` at compile time (optional). Recorded so the agent can verify without re-discovering. |
2158
2492
  | `contexts` | Secret contexts declared by the workflow (optional). The orchestrator validates access to each context before dispatch. |
2159
2493
  | `registries` | Private npm registry declarations the agent authenticates against before install (optional): `url`, `scope`, `tokenSecret` reference, `alwaysAuth`. Resolved token bytes never appear in the lock file. See [private registries](https://docs.kici.dev/user/private-registries/). |
2160
- | `installEnv` | Extra qualified secret refs (`<environment>:<secret-name>`) projected as env vars on the install subprocess for use with a committed `.kici/.npmrc` (optional). See [private registries](https://docs.kici.dev/user/private-registries/). |
2494
+ | `installEnv` | Extra qualified secret refs (`<context>:<secret-name>`) projected as env vars on the install subprocess for use with a committed `.kici/.npmrc` (optional). See [private registries](https://docs.kici.dev/user/private-registries/). |
2161
2495
  | `concurrency` | Workflow-level concurrency config: `hasGroup`, `cancelInProgress`, `max` (optional). See [concurrency groups](https://docs.kici.dev/user/concurrency/). |
2162
2496
  | `timeout` | Whole-run wall-clock timeout in milliseconds (optional). The orchestrator reads this at run creation to set the run deadline. |
2163
2497
  | Hook flags | Boolean flags (`hasOnCancel`, `hasCleanup`, `hasOnSuccess`, `hasOnFailure`) indicating which lifecycle hooks are defined. Job entries additionally have `hasBeforeStep` and `hasAfterStep`. |
@@ -2385,12 +2719,12 @@ export const pushWithSecrets = fixture('push-with-secrets', {
2385
2719
 
2386
2720
  This maps the `db` secret context to the `test-database` context, and `api` to `test-api-keys`.
2387
2721
 
2388
- This mapping is honored by **both** `kici run local` and `kici run remote`:
2722
+ This mapping is honored by **both** `kici run <event> --local` and `kici run remote`:
2389
2723
 
2390
- - For **`kici run local`** (see [`kici run local`](https://docs.kici.dev/user/cli-reference/#kici-run-local)), each named context is resolved from your local secret files (`.kici/.secrets`, `.env.local`, `secrets.yaml`, and `--env` flags).
2391
- - For **`kici run remote`**, each named context maps to an orchestrator **environment**, and the orchestrator resolves that environment's secrets for the run. The target environment must be flagged `allowLocalExecution: true` — mapping a context to a missing or non-test environment rejects the run (see [Secret contexts for testing](https://docs.kici.dev/user/testing-guide/#secret-contexts-for-testing) below).
2724
+ - For a local **`kici run <event> --local`** (see [`kici run <event> --local`](https://docs.kici.dev/user/cli-reference/#kici-run-event---local)), each named context is resolved from your local secret files (`.kici/.secrets`, `.env.local`, `secrets.yaml`, and `--env` flags).
2725
+ - For **`kici run remote`**, each named context maps to an orchestrator **context**, and the orchestrator resolves that context's secrets for the run. The target context must be flagged `allowLocalExecution: true` — mapping a context to a missing or non-test context rejects the run (see [Secret contexts for testing](https://docs.kici.dev/user/testing-guide/#secret-contexts-for-testing) below).
2392
2726
 
2393
- **A fixture `secrets:` mapping is fail-closed; a job's bound `environment:` is not.** The reject above applies only to the fixture `secrets:` mapping — an explicit request for that environment's secrets. A job's own bound `environment:` (`job('deploy', { environment: 'production', … })`) is treated differently on a test run: if it resolves to a non-test or unconfigured environment it is **skipped with a warning**, not rejected, so a job that deploys to production in real runs stays locally testable for its non-secret logic. `kici run remote` prints a warning naming the skipped environment(s), and the dashboard run view shows the same notice. See [Skip-on-test](https://docs.kici.dev/user/environments/#multiple-environments-per-job) in the environments guide.
2727
+ **A fixture `secrets:` mapping is fail-closed; a job's bound `context:` is not.** The reject above applies only to the fixture `secrets:` mapping — an explicit request for that context's secrets. A job's own bound `context:` (`job('deploy', { context: 'production', … })`) is treated differently on a test run: if it resolves to a non-test or unconfigured context it is **skipped with a warning**, not rejected, so a job that deploys to production in real runs stays locally testable for its non-secret logic. `kici run remote` prints a warning naming the skipped context(s), and the dashboard run view shows the same notice. See [Skip-on-test](https://docs.kici.dev/user/contexts/#multiple-contexts-per-job) in the contexts guide.
2394
2728
 
2395
2729
  ### Async fixtures
2396
2730
 
@@ -2525,14 +2859,14 @@ The goal of the test-secret model is to let test runs reach **test-only credenti
2525
2859
 
2526
2860
  ### CLI-uploaded local secrets
2527
2861
 
2528
- `kici run remote` collects the same local secret values that `kici run local` reads — `.kici/.secrets`, `.kici/.env.local`, `.kici/secrets.yaml`, and any `--env KEY=VALUE` flags — and uploads them **encrypted** to the orchestrator alongside the run. The orchestrator decrypts them only to inject them into the agent for that run; the control plane never sees the values.
2862
+ `kici run remote` collects the same local secret values that `kici run <event> --local` reads — `.kici/.secrets`, `.kici/.env.local`, `.kici/secrets.yaml`, and any `--env KEY=VALUE` flags — and uploads them **encrypted** to the orchestrator alongside the run. The orchestrator decrypts them only to inject them into the agent for that run; the control plane never sees the values.
2529
2863
 
2530
2864
  ```bash
2531
2865
  # Provide an ad-hoc test value for a single remote run
2532
2866
  kici run remote push-main --env KICI_DATABASE_URL=postgresql://localhost/test
2533
2867
  ```
2534
2868
 
2535
- `--env` provides a **flat** per-run override; `--context <ctx>.<KEY>=<value>` is its sibling for a **namespaced** per-run override, placing the value under the named context `ctx`. Both are uploaded **encrypted** and follow the same precedence rule below — a CLI-supplied value wins over the orchestrator test-environment secret on a key collision.
2869
+ `--env` provides a **flat** per-run override; `--context <ctx>.<KEY>=<value>` is its sibling for a **namespaced** per-run override, placing the value under the named context `ctx`. Both are uploaded **encrypted** and follow the same precedence rule below — a CLI-supplied value wins over the orchestrator test-context secret on a key collision.
2536
2870
 
2537
2871
  ```bash
2538
2872
  # Provide a namespaced per-run value under the 'db' context
@@ -2541,14 +2875,14 @@ kici run remote push-db --context db.KICI_DATABASE_URL=postgresql://localhost/te
2541
2875
 
2542
2876
  Because these values originate on your machine, they are the natural place to put throwaway test credentials without touching any orchestrator-stored secret.
2543
2877
 
2544
- ### Orchestrator test-environment secrets
2878
+ ### Orchestrator test-context secrets
2545
2879
 
2546
2880
  In addition to your uploaded values, the orchestrator resolves test-scoped secrets from its own store for a remote test run:
2547
2881
 
2548
- - The job's own declared `environment` contributes its resolved secrets (flat). Static strings and **pure dynamic functions** both participate: a pure `environment:` function (see [Dynamic values](https://docs.kici.dev/user/dynamic-values/)) is evaluated against the fixture's simulated event, and the resolved name is gated and resolved like a static one. Impure dynamic functions (those requiring an init job) are not evaluated for test runs — use a fixture `secrets:` mapping (or `--context`) to supply such a job's secrets.
2549
- - Each fixture `secrets: { ctx: envName }` mapping resolves the named environment's secrets under the namespaced context `ctx`.
2882
+ - The job's own declared `context` contributes its resolved secrets (flat). Static strings and **pure dynamic functions** both participate: a pure `context:` function (see [Dynamic values](https://docs.kici.dev/user/dynamic-values/)) is evaluated against the fixture's simulated event, and the resolved name is gated and resolved like a static one. Impure dynamic functions (those requiring an init job) are not evaluated for test runs — use a fixture `secrets:` mapping (or `--context`) to supply such a job's secrets.
2883
+ - Each fixture `secrets: { ctx: envName }` mapping resolves the named context's secrets under the namespaced context `ctx`.
2550
2884
 
2551
- Both paths are restricted to environments flagged `allowLocalExecution: true`. A production environment left at the default `false` is never resolvable for a test run.
2885
+ Both paths are restricted to contexts flagged `allowLocalExecution: true`. A production context left at the default `false` is never resolvable for a test run.
2552
2886
 
2553
2887
  ```typescript
2554
2888
  export const pushWithDb = fixture('push-db', {
@@ -2566,31 +2900,31 @@ step('migrate', async (ctx) => {
2566
2900
 
2567
2901
  ### Precedence: CLI values win
2568
2902
 
2569
- When a key exists in both sources, the **CLI-uploaded local value wins** over the orchestrator test-environment value. This makes a local override a per-run knob: set `--env KICI_DATABASE_URL=...` (or put it in `.kici/.secrets`) to shadow the test environment's value for just that run, without changing anything on the orchestrator.
2903
+ When a key exists in both sources, the **CLI-uploaded local value wins** over the orchestrator test-context value. This makes a local override a per-run knob: set `--env KICI_DATABASE_URL=...` (or put it in `.kici/.secrets`) to shadow the test context's value for just that run, without changing anything on the orchestrator.
2570
2904
 
2571
- ### Fail-closed on non-test environments
2905
+ ### Fail-closed on non-test contexts
2572
2906
 
2573
2907
  Test-run secret resolution is fail-closed:
2574
2908
 
2575
- - If a fixture maps a context to an environment that does not exist, the run is **rejected**.
2576
- - If a fixture maps a context to an environment whose `allowLocalExecution` is `false`, the run is **rejected**.
2577
- - The `allowLocalExecution` gate applies to **all** remote test runs: a run whose matched workflow targets an environment with the flag off is rejected, so a test run can never resolve production secrets.
2909
+ - If a fixture maps to a context that does not exist, the run is **rejected**.
2910
+ - If a fixture maps to a context whose `allowLocalExecution` is `false`, the run is **rejected**.
2911
+ - The `allowLocalExecution` gate applies to **all** remote test runs: a run whose matched workflow targets a context with the flag off is rejected, so a test run can never resolve production secrets.
2578
2912
 
2579
- ### The `allowLocalExecution` environment flag
2913
+ ### The `allowLocalExecution` context flag
2580
2914
 
2581
- Each environment carries an `allowLocalExecution` flag (default `false`) that controls test-run access to that environment and to its secrets. Production environments should leave it at `false`; create a dedicated test environment with `allowLocalExecution: true` that binds only test-only secret scopes for the contexts you want test runs to use.
2915
+ Each context carries an `allowLocalExecution` flag (default `false`) that controls test-run access to that context and to its secrets. Production contexts should leave it at `false`; create a dedicated test context with `allowLocalExecution: true` that binds only test-only secret scopes for the jobs you want test runs to use.
2582
2916
 
2583
2917
  The flag is set by the orchestrator operator, either via the CLI:
2584
2918
 
2585
2919
  ```bash
2586
- kici-admin environment set-policy --env test-database --allow-local-execution true
2920
+ kici-admin context set-policy --env test-database --allow-local-execution true
2587
2921
  ```
2588
2922
 
2589
- or via the dashboard's "Test runs" toggle on the environment detail page. `kici secrets list` only surfaces contexts whose owning environment has `allowLocalExecution: true`, so production environments are never advertised as test-accessible.
2923
+ or via the dashboard's "Test runs" toggle on the context detail page. `kici secrets list` only surfaces contexts whose `allowLocalExecution` is `true`, so production contexts are never advertised as test-accessible.
2590
2924
 
2591
2925
  ### Local execution as an alternative
2592
2926
 
2593
- `kici run local` resolves the same local secret files entirely on your machine and honors the fixture `secrets: { ... }` mapping to pick which local context backs each name (see [`kici run local`](https://docs.kici.dev/user/cli-reference/#kici-run-local)). Because the values never leave your machine, it's a good fit when you want to exercise secret-dependent steps without involving the orchestrator at all.
2927
+ `kici run <event> --local` resolves the same local secret files entirely on your machine and honors the fixture `secrets: { ... }` mapping to pick which local context backs each name (see [`kici run <event> --local`](https://docs.kici.dev/user/cli-reference/#kici-run-event---local)). Because the values never leave your machine, it's a good fit when you want to exercise secret-dependent steps without involving the orchestrator at all.
2594
2928
 
2595
2929
  ### Discovering available contexts
2596
2930