@kici-dev/compiler 0.6.0 → 0.6.1

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.
@@ -0,0 +1,2347 @@
1
+ # KiCI CLI: driving a deployed orchestrator
2
+
3
+ This bundle covers: Auth, org and orchestrator selection, runs, approvals, notifications, diagnostics, and the MCP server a coding agent connects to.
4
+
5
+ ## Drive KiCI from your coding agent
6
+
7
+ Source: https://docs.kici.dev/user/ai-agents/
8
+
9
+ KiCI ships a hosted **MCP server** so a coding agent (Claude Code, or any MCP
10
+ client) can drive your CI directly: trigger runs, read a structured result,
11
+ fetch the failing step's logs, cancel, and re-run — all under an agent identity
12
+ you control, org-scoped, and audited. There are no per-tool tokens to configure:
13
+ point the agent at one URL with one credential and it's done.
14
+
15
+ The MCP exposes only what you can already do yourself through the `kici` CLI and
16
+ the dashboard. It is not a new privileged surface — every tool maps to an
17
+ existing user-facing operation and is gated by the same permissions your role
18
+ grants.
19
+
20
+ ## 1. Mint an agent credential
21
+
22
+ The MCP accepts an **agent-kind credential** — and only an agent-kind one. It
23
+ can be either of two kinds:
24
+
25
+ - An **agent personal access token (PAT)** that you own — it acts as you, with
26
+ your provenance. The token is `kici_pat_…`.
27
+ - An **agent org API key** that belongs to your organization — a
28
+ provenance-carrying service account, independent of any one person. The key is
29
+ `kici_sk_…`.
30
+
31
+ Both drive the MCP identically. A non-agent token of either kind (a plain user
32
+ PAT, a plain org API key) is refused at the door.
33
+
34
+ **Option A — an agent PAT.** Mint one with the `kici` CLI (log in first with
35
+ `kici login`):
36
+
37
+ ```bash
38
+ kici pat create --agent --name "claude-code"
39
+ ```
40
+
41
+ The `--name` value is the **agent label**. It is recorded on every action the
42
+ agent takes, so your audit log shows exactly which agent did what (and on whose
43
+ behalf). The token is printed once — save it now; it cannot be retrieved later.
44
+
45
+ **Option B — an agent org API key.** Create one from the dashboard's
46
+ **Settings → API keys** tab: set the key's kind to **Agent** and give it an
47
+ agent name (the agent label). The same key can also be minted with
48
+ `kici-platform-admin user api-key create --org <id> --agent --agent-label <label>`.
49
+ Reach for an org agent key when the agent should act as a shared service account
50
+ rather than as a single user — for example, a long-lived CI bot that outlives any
51
+ individual's membership.
52
+
53
+ Whichever you pick, the credential carries provenance, not extra authority. Its
54
+ effective permissions are the matrix it was minted with, and that matrix can
55
+ never exceed the permissions of the person who created it — so you can scope an
56
+ agent credential **below** your own access (for example, read-only) and the agent
57
+ is held to that smaller set. Powerful operator capabilities (secret rotation,
58
+ agent and peer management, draining) are intentionally **not** exposed here. See
59
+ [the agent safety model](https://docs.kici.dev/user/ai-agents/#6-the-agent-safety-model) for how scoping and
60
+ confinement work.
61
+
62
+ ## 2. Point your coding agent at the MCP server
63
+
64
+ KiCI's hosted MCP server lives at one fixed URL:
65
+
66
+ ```
67
+ https://api.kici.dev/api/v1/mcp
68
+ ```
69
+
70
+ Configure your MCP client with that URL and your agent credential (the agent PAT
71
+ or the agent org key) as a Bearer credential. For Claude Code:
72
+
73
+ ```bash
74
+ claude mcp add --transport http kici https://api.kici.dev/api/v1/mcp \
75
+ --header "Authorization: Bearer <your-agent-credential>"
76
+ ```
77
+
78
+ That's the entire setup. The agent can now call the tools below.
79
+
80
+ ## 3. What the agent can do
81
+
82
+ **Read**
83
+
84
+ - `list_runs` — recent runs in your organization.
85
+ - `get_run` — the structured, provenance-tagged result of a run: the typed job
86
+ graph, per-step statuses and exit codes, durations, and a derived failure
87
+ category.
88
+ - `get_step_logs` — the log lines for a specific step.
89
+ - `list_workflows` — your registered workflows, optionally filtered by
90
+ `triggerType`, `repo`, or `stale` (only those not triggered within a duration
91
+ like `30d`).
92
+ - `list_orgs` — the organizations you belong to. Use it to discover the `orgId`
93
+ to pass to the other tools when you're a member of more than one.
94
+ - `list_secrets` — the secret scopes in your organization and the **key names**
95
+ each holds. Secret values are never returned — only the names.
96
+ - `list_orchestrators` — the connected orchestrator clusters your runs execute
97
+ on (cluster name, routing keys, version, scaler backends, health).
98
+ - `get_diagnostics` — your organization's execution metrics over the last 24
99
+ hours (run count, success rate, average duration, queued and running jobs)
100
+ plus per-orchestrator connection health.
101
+
102
+ **Drive**
103
+
104
+ - `trigger_run` — run a registered workflow ("run now").
105
+ - `rerun_run` — re-run a completed run.
106
+ - `cancel_run` — cancel an in-progress run.
107
+ - `approve_run` — approve a held approval gate for a run (name the run, plus
108
+ `job`/`step` to disambiguate when it has multiple holds). Requires
109
+ `runs:write` **and** the permission matching the hold's type — `ci_trust:write`
110
+ for a security hold, `contexts:admin` for a wait-timer hold, `contexts:write`
111
+ otherwise. That is the same rule the dashboard and the `kici` CLI answer to,
112
+ so an agent cannot release a hold a person with the same grants could not.
113
+ Grant agent credentials accordingly.
114
+ - `reject_run` — reject a held approval gate; a `reason` is required. Gated
115
+ identically to `approve_run`.
116
+ - `cancel_runs_by_branch` — cancel all in-progress runs on a branch (bounded —
117
+ up to 100 per call; a `truncated` flag tells the agent to re-invoke).
118
+
119
+ The tools cover the same developer operations you can drive yourself with the
120
+ `kici` CLI. Operations that are purely local to your machine (scaffolding,
121
+ compiling, running a workflow locally) or that mint credentials are
122
+ intentionally not exposed — the agent works against your deployed CI, not your
123
+ filesystem.
124
+
125
+ If you belong to a single organization, the org is resolved automatically. If
126
+ you belong to several, pass an `orgId` argument to any tool (use `list_orgs` to
127
+ find it).
128
+
129
+ ### Limits and pagination
130
+
131
+ The MCP server applies a few bounds so an agent loop can't overwhelm the shared
132
+ infrastructure. They are agent-visible — your agent gets a clear tool error and
133
+ should back off or page, never a silent truncation:
134
+
135
+ - **Per-token request limits.** Each agent token has its own ceiling, refreshed
136
+ every minute: **120 reads/minute** (listing and fetching runs, step logs, and
137
+ workflows) and **20 run actions/minute** (cancel, re-run, trigger, approve,
138
+ reject, cancel-by-branch). The two
139
+ budgets are independent. An over-limit call returns a tool error telling the
140
+ agent which kind of operation was throttled and how many seconds to wait
141
+ before retrying.
142
+ - **Paginated step logs.** `get_step_logs` returns log lines in pages. Pass a
143
+ `limit` to bound a page (capped server-side) and follow the returned
144
+ `nextCursor` (as `cursor` on the next call) to read more. A large step log is
145
+ paged, never silently cut off — when `nextCursor` is null you've reached the
146
+ end.
147
+ - **Bounded run results.** `get_run` returns the structured run result, which is
148
+ naturally bounded by workflow size. For a pathologically large run it returns a
149
+ tool error directing the agent to inspect specific steps with `get_step_logs`
150
+ instead.
151
+
152
+ ## 4. Why the structured result is agent-safe
153
+
154
+ Every tool returns a machine-first shape designed for an agent to reason over
155
+ without being misled by repository content. Each field that comes from your repo,
156
+ a contributor, or a process's output — workflow and job names, refs, error
157
+ messages, log lines, job outputs — is delivered **fenced** as untrusted data:
158
+ wrapped in a per-response, randomly-named delimiter (`⟦u:<nonce>⟧…⟦/u:<nonce>⟧`),
159
+ with the result prefixed by a notice that fenced text is data, never instructions.
160
+ KiCI-generated values (ids, statuses, exit codes, durations, the derived failure
161
+ category) are left plain. So an agent can keep user-controlled content out of its
162
+ instruction channel by treating anything inside a fence as data only. See
163
+ [Untrusted content and prompt injection](https://docs.kici.dev/user/ai-agents/#7-untrusted-content-and-prompt-injection)
164
+ for the full model.
165
+
166
+ Secret values are never returned — only the names of the secret keys a step
167
+ accessed.
168
+
169
+ ## 5. The audit guarantee
170
+
171
+ Because the MCP accepts only an agent-kind credential, **every action that flows
172
+ through it is agent-attributed by construction** — there is no path that produces
173
+ an untagged, human-looking action. Each read and each drive operation is recorded
174
+ in your orchestrator's access log under the acting identity plus the agent label,
175
+ so you always have a complete trail of what your agent did.
176
+
177
+ Inspect that trail with `kici-admin access-log list --json` (or
178
+ `kici-admin access-log show <id>` for one entry). The acting identity depends on
179
+ which credential you used:
180
+
181
+ - An **agent PAT** keeps `actor_type` as `user` and `actor_id` as your own
182
+ identity — the agent provenance rides in the actor metadata as `agentLabel`
183
+ (the `--name` you minted the PAT with) and `agentPatId`.
184
+ - An **agent org key** keeps `actor_type` as `api_key` and `actor_id` as the key
185
+ — the same `agentLabel` provenance rides in its actor metadata.
186
+
187
+ Either way the label is stored in a dedicated `agent_label` column on every such
188
+ row, so you can filter the access log down to just agent activity:
189
+
190
+ ```bash
191
+ # Every action a specific agent took, by its label:
192
+ kici-admin access-log list --agent-label "claude-code"
193
+
194
+ # Every agent-attributed action, across all agents:
195
+ kici-admin access-log list --agent-only
196
+ ```
197
+
198
+ In the dashboard, agent-driven activity is visually distinguished: the
199
+ [Activity](https://docs.kici.dev/user/dashboard/activity-and-dlq/#activity) log renders an **agent badge**
200
+ on every agent-attributed row, and a run's **Triggered by** shows the same badge
201
+ when an agent triggered or cancelled it — so an agent's footprint is obvious at a
202
+ glance, not buried in metadata.
203
+
204
+ ## 6. The agent safety model
205
+
206
+ KiCI treats a coding agent as a **least-privilege principal with its own token**,
207
+ not as an unscoped extension of you. Three properties make the agent
208
+ "confined and audited by construction":
209
+
210
+ **Least-privilege, capped at the creator.** An agent token is scoped when you
211
+ mint it. Leave the scope open and it inherits your role; narrow it and the agent
212
+ is held to that smaller set — its effective permissions are always the
213
+ **minimum** of your role and the token's scope. A token can never grant more than
214
+ you hold, so an agent cannot escalate beyond its creator.
215
+
216
+ **Repository scope comes along too.** If your role is restricted to a set of
217
+ repositories, an agent token you mint is restricted to the same set. Runs
218
+ outside it are simply not there: they are filtered out of `list_runs`,
219
+ `cancel_runs_by_branch` skips them, and naming one directly answers "not found"
220
+ — the same answer a run id that does not exist gets, so an agent cannot use the
221
+ tools to discover which repositories it is missing. Your organization's audit
222
+ log records the real reason. One thing to know when you choose which credential
223
+ to give an agent: this inheritance applies to a **personal** agent token. An
224
+ **organization** agent API key has no minting user's role to inherit from, so it
225
+ reaches every repository in the organization within its permission level — reach
226
+ for a personal agent token when repository scoping is what you want.
227
+
228
+ **Fail-closed denial, on every surface the token is used.** The scope is enforced
229
+ wherever the token acts — the MCP tools the agent drives **and** any direct API
230
+ call made with the raw token. When the agent attempts something outside its
231
+ scope (driving a run with a read-only token, reading members it wasn't granted),
232
+ the action is **refused fail-closed**: it does not run, nothing is changed, and a
233
+ clear "insufficient permission" error comes back. There is no fallback path that
234
+ quietly lets a denied action through.
235
+
236
+ **Every decision is audited — allowed and denied alike.** Allowed actions are
237
+ recorded in your access log under your identity plus the agent label, exactly as
238
+ described in [the audit guarantee](https://docs.kici.dev/user/ai-agents/#5-the-audit-guarantee). **Denials are audited
239
+ too:** each refused action lands a row in your organization's audit log carrying
240
+ the agent label and the permission that was required, so a confined agent's
241
+ attempts are as visible as its successes. You can see both what your agent did
242
+ and what it was stopped from doing.
243
+
244
+ **Execution stays confined.** Beyond authorization, the workloads an agent
245
+ triggers run under the same execution guardrails as any other run — label-based
246
+ routing decides where a job runs, and privileged (root) execution is gated and
247
+ verified, refused fail-closed when the guarantee can't be met.
248
+
249
+ Together these mean you can hand an agent a deliberately narrow token, point it
250
+ at KiCI, and trust that it can do exactly what you granted — no more — with a
251
+ complete, tamper-evident trail of every allow and every deny.
252
+
253
+ ## 7. Untrusted content and prompt injection
254
+
255
+ A run carries content KiCI does not vouch for — log lines, workflow and repository
256
+ names, error text, contributor names. An agent reading a run must treat that content
257
+ as **data**, never as instructions, or a crafted log line ("ignore previous
258
+ instructions and …") could hijack the agent.
259
+
260
+ KiCI defends this structurally:
261
+
262
+ - **Provenance tagging.** Every user- or process-controlled value is marked untrusted
263
+ at the API boundary; KiCI's own values (run ids, statuses, exit codes, commit hashes)
264
+ are trusted.
265
+ - **Fencing at the agent boundary.** When the MCP server returns a result, every
266
+ untrusted value is wrapped in a per-response, randomly-named fence
267
+ (`⟦u:<nonce>⟧…⟦/u:<nonce>⟧`) and the result is prefixed with a notice that fenced
268
+ text is data, never instructions. The fence name is random per response, so injected
269
+ content cannot forge a closing fence to break out.
270
+ - **No mutation.** KiCI never rewrites your log content — it fences and labels it. The
271
+ agent sees the true bytes inside the fence.
272
+
273
+ ### Safe integration pattern
274
+
275
+ An agent (or harness) consuming KiCI reads should treat anything inside a fence as
276
+ opaque data: quote it, summarize it, search it — but never execute it, follow it, or
277
+ let it redirect a tool call. Any action taken off the back of a read (re-run, cancel,
278
+ trigger) should be a deliberate decision from the trusted skeleton (statuses, exit
279
+ codes, the failure category), not from fenced content.
280
+
281
+ ### Sandboxing actions
282
+
283
+ Actions an agent drives through KiCI run under the agent's own least-privilege identity
284
+ and are audited; combine the fencing contract with that confinement so that even if a
285
+ log line tries to provoke an action, the action is bounded by the agent token's scope.
286
+
287
+ ---
288
+
289
+ ## CLI authentication
290
+
291
+ Source: https://docs.kici.dev/user/cli-auth/
292
+
293
+ The KiCI CLI supports three authentication methods: browser-based OAuth (default), device authorization flow (for headless environments), and API key paste (for CI/CD pipelines).
294
+
295
+ ## Authentication methods
296
+
297
+ ### Browser OAuth (default)
298
+
299
+ The default `kici login` flow:
300
+
301
+ 1. Opens your default browser to the KiCI identity provider
302
+ 2. You authenticate in the browser
303
+ 3. The CLI receives a token via localhost callback
304
+ 4. A personal access token (PAT) is created and stored locally
305
+
306
+ ```bash
307
+ kici login
308
+ ```
309
+
310
+ The CLI auto-detects headless environments (SSH sessions, CI runners, containers) and switches to device flow automatically. On WSL, `kici login` opens your Windows browser when Windows interop is reachable; if it is not (interop disabled, or the Windows drive not mounted), the CLI falls back to the device flow rather than waiting for a browser that cannot open.
311
+
312
+ ### Device flow (headless)
313
+
314
+ For environments without a browser (SSH, remote servers):
315
+
316
+ ```bash
317
+ kici login --device
318
+ ```
319
+
320
+ This displays a URL and a code. Open the URL on any device, enter the code, and authenticate. The CLI polls for completion.
321
+
322
+ ### API key paste
323
+
324
+ For CI/CD pipelines and automated environments, paste an API key directly:
325
+
326
+ ```bash
327
+ kici login --token kici_sk_abc123...
328
+ ```
329
+
330
+ The API key (starts with `kici_sk_`) is passed directly as the flag value and stored in your local config file.
331
+
332
+ ## kici logout
333
+
334
+ Revoke your PAT and clear local authentication:
335
+
336
+ ```bash
337
+ kici logout
338
+ ```
339
+
340
+ This:
341
+
342
+ 1. Revokes the PAT on the server (preventing further use)
343
+ 2. Detaches the local dev plane if it is attached, so a logged-out user is not left with a hybrid plane holding an orphaned orchestrator key
344
+ 3. Clears the auth fields from the local config file — the PAT, its id and expiry, your email, and the active organization
345
+ 4. Preserves the connection settings (per-org default clusters, Platform endpoint, orchestrator endpoint, OIDC issuer, routing key)
346
+
347
+ Server revocation is best-effort: if the network call fails, the local config is still cleared.
348
+
349
+ ## Organization management
350
+
351
+ ### List organizations
352
+
353
+ ```bash
354
+ kici org list
355
+ ```
356
+
357
+ Shows all organizations you belong to, with your role in each. The active organization is marked with an asterisk.
358
+
359
+ ### Switch active organization
360
+
361
+ ```bash
362
+ kici org use <name-or-id>
363
+ ```
364
+
365
+ Name matching is case-insensitive. You can also use the organization ID directly.
366
+
367
+ The active organization is both the scope for org-scoped commands (`kici runs list`, `kici diagnostics`, `kici secrets list`, …) **and** the default target for `kici run remote`. After `kici login` and `kici org use <org>`, `kici run remote` dispatches to that org through the Platform — that is the complete path to a remote run. Override the target for a single run with `kici run remote --org <id>`.
368
+
369
+ If an organization has more than one connected orchestrator cluster, set its default cluster once with `kici orchestrators use <name>` (list them with `kici orchestrators list`). `kici run remote` then targets that cluster unless you pass `--orchestrator <name>`. With a single connected orchestrator the cluster is selected automatically.
370
+
371
+ ### Show current organization
372
+
373
+ ```bash
374
+ kici org current
375
+ ```
376
+
377
+ Displays the currently active organization name and ID.
378
+
379
+ ## Auth status
380
+
381
+ `kici org current` shows your current login state and active organization:
382
+
383
+ ```bash
384
+ kici org current
385
+ ```
386
+
387
+ It reports whether you are logged in and which organization is active. PAT
388
+ expiry and the full list of your tokens are managed from the dashboard (see
389
+ "Dashboard management" below).
390
+
391
+ ## Personal access tokens
392
+
393
+ Personal access tokens (PATs) are created automatically when you log in via OAuth. You can also create and manage PATs through the dashboard.
394
+
395
+ ### How PATs work
396
+
397
+ - **User-scoped**: PATs work across all organizations you belong to
398
+ - **120-day default expiry**: Configurable when creating from the dashboard
399
+ - **Named per machine**: Each login creates a PAT named after the machine hostname
400
+ - **Permission inheritance**: PATs inherit your effective role permissions in each org
401
+
402
+ ### PATs vs API keys
403
+
404
+ | | Personal access tokens | API keys |
405
+ | ---------- | ---------------------- | --------------- |
406
+ | Scope | User (cross-org) | Organization |
407
+ | Prefix | `kici_pat_` | `kici_sk_` |
408
+ | Created by | CLI login or dashboard | Dashboard |
409
+ | Expiry | 120 days (default) | No expiry |
410
+ | Use case | Developer CLI access | CI/CD pipelines |
411
+
412
+ ### Dashboard management
413
+
414
+ Create, view, and revoke PATs from the dashboard:
415
+
416
+ 1. Click your avatar in the sidebar
417
+ 2. Select **Account settings**
418
+ 3. Navigate to the **Personal access tokens** tab
419
+
420
+ From here you can:
421
+
422
+ - Create PATs with custom names and expiry periods
423
+ - View active PATs with their prefixes and expiry dates
424
+ - Revoke PATs that are no longer needed
425
+
426
+ ## Reaching the Platform API directly
427
+
428
+ The Platform exposes a versioned REST API under `/api/v1/*`. The same endpoints back the dashboard SPA, the `kici` CLI, and any third-party automation. There is no separate "public" surface — the dashboard's API is the API.
429
+
430
+ ### Base URL
431
+
432
+ | Deployment | Base URL pattern |
433
+ | ----------- | ------------------------------------------------------------------------- |
434
+ | KiCI Cloud | `https://<your-platform-host>/api/v1/` |
435
+ | Self-hosted | `https://<orchestrator-host>/<deployment-slug>/api/v1/` (slug is optional |
436
+ | | — `KICI_BASE_PATH` may add a prefix when the Platform is reverse-proxied) |
437
+
438
+ `/api/v1/*` requires authentication (see below). `/health`, `/metrics`, and `/ws` (WebSocket) sit outside that prefix and have their own access posture (`/metrics` is meant for Prometheus scrape, not public exposure).
439
+
440
+ ### Authentication
441
+
442
+ Every request to `/api/v1/*` carries an `Authorization: Bearer <token>` header. The Platform routes on the prefix:
443
+
444
+ | Prefix | Token type | Created via | Scope |
445
+ | ----------- | ----------------------------- | --------------------------------------- | ---------------- |
446
+ | `kici_pat_` | Personal access token | `kici login` or dashboard | User (cross-org) |
447
+ | `kici_sk_` | User API key | Dashboard → Settings → API keys | Org |
448
+ | `kici_sa_` | Service account key | Dashboard → Settings → Service accounts | Org |
449
+ | (other) | OIDC JWT or opaque OIDC token | OIDC login (browser SPA) | User (cross-org) |
450
+
451
+ JWT and opaque OIDC tokens are validated against the configured OIDC issuer (JWKS for JWTs, the issuer's UserInfo endpoint for opaque ones). All `kici_*` tokens are validated by SHA-256 hash lookup against the Platform DB. See [RBAC: authentication methods](https://docs.kici.dev/architecture/security/rbac/#authentication-methods) for the full model.
452
+
453
+ > **Note:** `kici_ok_` keys are **not** for the HTTP API — they authenticate orchestrator-to-Platform WebSocket connections only. Use `kici_sk_` (or `kici_pat_`) for HTTP calls.
454
+
455
+ ### Permissions
456
+
457
+ Tokens authenticate; RBAC authorizes. Every org-scoped route runs `orgContextMiddleware` (verifies you are a member of the target org) followed by `requirePermission(resource, level)`. The 18 resources and 5 levels are documented in [RBAC](https://docs.kici.dev/architecture/security/rbac/#permission-model). User API keys carry their own permission matrix bounded above by the creator's effective permissions; PATs inherit the user's role permissions (or are capped further by their `scopes` field).
458
+
459
+ ### Configurable surfaces
460
+
461
+ The dashboard is a browser SPA on top of the same `/api/v1/*` surface, so anything you can configure in the dashboard you can configure over HTTP. The mounted route groups include:
462
+
463
+ - **Auth & identity:** `/cli/exchange-token`, `/pats`, `/user`, `/identity-links`, `/github-oauth`, `/invites`, `/invites/pending`, `/invites/:inviteId/{accept,decline}`
464
+ - **Org & membership:** `/orgs`, `/orgs/:customerId`, `/orgs/:customerId/{members,roles,api-keys,orchestrator-keys,service-accounts,billing,trust-policies}`
465
+ - **Workflows & runs:** `/orgs/:customerId/{runs,registrations,workflows,held-runs,contexts,secrets,global-workflows}`
466
+ - **Webhooks & event log:** `/orgs/:customerId/{sources,webhook-endpoints,event-log}`
467
+ - **Diagnostics & activity:** `/orgs/:customerId/{diagnostics,activity,access-log}`
468
+
469
+ The full route tree is the source of truth — every method, request schema, and response schema is enumerated server-side. There is currently no auto-generated OpenAPI spec; the typed `DashboardApiType` export is the canonical contract for TypeScript clients.
470
+
471
+ ### Calling the API
472
+
473
+ Two short examples — adapt the base URL and token to your deployment.
474
+
475
+ **curl (PAT or API key):**
476
+
477
+ ```bash
478
+ TOKEN="$(grep -E '^pat=' ~/.kici/config | cut -d= -f2)" # or paste a kici_sk_…
479
+ ORG="<your-org-id>"
480
+ curl -sS \
481
+ -H "Authorization: Bearer $TOKEN" \
482
+ "https://<orchestrator-host>/<deployment-slug>/api/v1/orgs/$ORG/runs?limit=5" | jq
483
+ ```
484
+
485
+ **Browser console (after dashboard login):**
486
+
487
+ ```js
488
+ const ns = Object.keys(localStorage).find((k) => k.startsWith('oidc.user:'));
489
+ const { access_token } = JSON.parse(localStorage.getItem(ns));
490
+ const res = await fetch('/<deployment-slug>/api/v1/orgs/<your-org-id>/runs?limit=5', {
491
+ headers: { Authorization: `Bearer ${access_token}` },
492
+ });
493
+ console.log(await res.json());
494
+ ```
495
+
496
+ ### Rate limits and body size
497
+
498
+ There is currently no per-token rate limit on `/api/v1/*`. A single global body-size cap applies to webhook ingress and dashboard API requests alike.
499
+
500
+ ### Audit trail
501
+
502
+ Every `/api/v1/*` mutation that touches tenant-plane data is recorded in the upstream tenant-plane audit log, stamped with the actor (user, API key, service account, or upstream operator on a break-glass support read). Reads on customer data go through the orchestrator over the WebSocket proxy and land in the orchestrator's `access_log` table. See [Audit log](https://docs.kici.dev/operator/security/audit-log/) for the orchestrator schema and the dashboard's "Activity" page for the federated view.
503
+
504
+ ## Token storage
505
+
506
+ The CLI stores authentication data in `~/.kici/config` with `0600` permissions (owner read/write only). The config file contains:
507
+
508
+ - PAT token, its server-side id, and its expiry date
509
+ - The email address from your OIDC token
510
+ - Active organization ID
511
+ - Per-org default orchestrator clusters
512
+ - Platform endpoint URL, orchestrator endpoint URL, and the OIDC issuer the PAT was minted against
513
+ - Routing key for webhook source identification
514
+ - API key, when you logged in with `--token`
515
+
516
+ ## Troubleshooting
517
+
518
+ ### Browser doesn't open
519
+
520
+ If `kici login` can't open a browser:
521
+
522
+ - Copy the authorization URL the CLI prints under `If it does not open, visit:` and open it in any browser — the CLI keeps waiting for the callback for up to 5 minutes (see [Browser callback never arrives](https://docs.kici.dev/user/cli-auth/#browser-callback-never-arrives) if it never lands)
523
+ - Use `kici login --device` for the device flow
524
+ - Or set the `KICI_BROWSER_CMD` environment variable to your browser command (e.g., `KICI_BROWSER_CMD='firefox {url}'`)
525
+
526
+ ### Browser callback never arrives
527
+
528
+ If the browser opens and you complete sign-in, but `kici login` keeps waiting:
529
+
530
+ - The CLI is waiting on a callback to `127.0.0.1`. A corporate firewall, an unusual loopback policy, or a WSL `portproxy` rule can block it.
531
+ - After 90 seconds of waiting the CLI prints a reminder that `kici login --device` needs no callback. It is safe to ignore if you are still signing in. After 5 minutes it gives up with `Authentication timed out after 5 minutes`.
532
+ - Retry with `kici login --device` — the device flow needs no local callback.
533
+ - If you must keep the browser flow, set `KICI_CALLBACK_PORT` to a fixed port your firewall allows.
534
+
535
+ ### Callback port already in use
536
+
537
+ If `KICI_CALLBACK_PORT` names a port something else is already listening on, `kici login` stops immediately and names the port instead of hanging or crashing.
538
+
539
+ It deliberately does **not** pick another port for you. A fixed port is something you set on purpose — usually because a firewall rule or a WSL `portproxy` entry allows exactly that one — so binding somewhere else would hand the browser a callback URL nothing can reach, and you would wait out the full 5-minute timeout instead of seeing a clear error.
540
+
541
+ Two ways forward:
542
+
543
+ - Free the port (stop whatever holds it) or point `KICI_CALLBACK_PORT` at a different free port your firewall allows.
544
+ - Run `kici login --device` — the device flow needs no local callback at all.
545
+
546
+ A port below 1024 fails the same way, with a permissions message rather than an "in use" one: those ports need elevated privileges. Pick a port above 1024. A value that is not a port number at all — non-numeric, negative, or above 65535 — is rejected before the login starts, naming the value you set.
547
+
548
+ ### Device code expired
549
+
550
+ This is the device flow's own expiry, not the browser flow's callback timeout above.
551
+
552
+ The device code is issued by the identity provider, which also sets how long it lives. The CLI prints the lifetime with the code (`Code expires in N minutes`) and polls until you approve or the code expires. On expiry it stops with `Device code expired`. If that happens:
553
+
554
+ - Run `kici login --device` again to get a new code
555
+ - Ensure you're using the correct URL displayed by the CLI
556
+
557
+ ### Expired PAT
558
+
559
+ If you see "Personal access token has expired":
560
+
561
+ - Run `kici login` to create a new PAT
562
+ - The old expired PAT is automatically superseded
563
+
564
+ ### "Not a member" errors
565
+
566
+ If authenticated commands return 403:
567
+
568
+ - Check your active org: `kici org current`
569
+ - List available orgs: `kici org list`
570
+ - Switch to the correct org: `kici org use <name>`
571
+
572
+ ### Connection refused
573
+
574
+ If the CLI can't reach the server:
575
+
576
+ - Verify the endpoint: check `~/.kici/config` for the correct URL
577
+ - Test connectivity: `curl <your-platform-url>/health`
578
+
579
+ ---
580
+
581
+ ## kici: account & org
582
+
583
+ Source: https://docs.kici.dev/user/cli/account-and-org/
584
+
585
+ ## Guide
586
+
587
+ ### kici login
588
+
589
+ Authenticate with KiCI via browser-based OAuth (default) or API key (`--token`).
590
+
591
+ By default, `kici login` opens your browser for OIDC authentication using PKCE. In headless environments (SSH, CI, containers), it automatically switches to the RFC 8628 device authorization flow where you visit a URL and enter a code.
592
+
593
+ The browser flow completes by receiving a callback on `127.0.0.1`. If that callback is blocked, pass `--device` to use the device flow instead — it needs no local callback. See [CLI authentication](https://docs.kici.dev/user/cli-auth/#browser-callback-never-arrives) for the full troubleshooting steps.
594
+
595
+ After OAuth, the CLI exchanges the OIDC token for a personal access token (PAT) stored in the config directory (`~/.kici/config` by default, overridable with `KICI_CONFIG_DIR`).
596
+
597
+ `kici login` targets the hosted KiCI Platform by default. To authenticate against another KiCI environment (staging, or a testing OIDC provider, for example), pass `--platform-endpoint` / `--oidc-issuer` or set `KICI_PLATFORM_URL` / `KICI_OIDC_ISSUER`. Login persists the platform endpoint and OIDC issuer it authenticated against alongside the PAT, so a saved PAT always matches its endpoint. Because the config describes one environment at a time, **switching the endpoint resets the active organization and default clusters** — re-run `kici org use <name>` after switching environments.
598
+
599
+ ```bash
600
+ kici login [options]
601
+ ```
602
+
603
+ **Environment variables:**
604
+
605
+ | Variable | Default | Description |
606
+ | --------------------- | -------------------------------------------- | ---------------------------------------------------------------------- |
607
+ | `KICI_PLATFORM_URL` | `https://api.kici.dev` | Platform API base URL (override to target another KiCI environment) |
608
+ | `KICI_OIDC_ISSUER` | `https://auth.kici.dev/realms/kici-internal` | OIDC issuer URL (override to target another KiCI environment) |
609
+ | `KICI_OIDC_CLIENT_ID` | `kici-cli` | OIDC client ID (override to target another KiCI environment) |
610
+ | `KICI_BROWSER_CMD` | uses `open` package | Custom browser command with `{url}` placeholder, or `none` to suppress |
611
+ | `KICI_CALLBACK_PORT` | random | Fixed port for OAuth PKCE callback server |
612
+ | `KICI_CONFIG_DIR` | `~/.kici` | Override config directory |
613
+
614
+ **Examples:**
615
+
616
+ ```bash
617
+ # Browser-based OAuth login (default)
618
+ kici login
619
+
620
+ # Force device flow (for SSH/headless)
621
+ kici login --device
622
+
623
+ # Legacy API key login
624
+ kici login --token kici_sk_abc123...
625
+
626
+ # Log in against another KiCI environment (e.g. a testing instance)
627
+ kici login --platform-endpoint https://platform.example.com \
628
+ --oidc-issuer https://auth.example.com/realms/kici-internal
629
+
630
+ # Suppress browser opening (print authorize URL to stdout)
631
+ KICI_BROWSER_CMD=none kici login
632
+
633
+ # Use custom browser command
634
+ KICI_BROWSER_CMD='firefox {url}' kici login
635
+
636
+ # Fixed callback port and custom config directory
637
+ KICI_CALLBACK_PORT=19876 KICI_CONFIG_DIR=/tmp/kici-test kici login
638
+ ```
639
+
640
+ **Headless detection:** The CLI checks, in order:
641
+
642
+ 1. SSH session — `SSH_CONNECTION`, `SSH_CLIENT`, or `SSH_TTY` set.
643
+ 2. CI — `CI`, `GITHUB_ACTIONS`, or `GITLAB_CI` set to anything other than the explicit opt-outs `0` and `false` (any case), so exporting `CI=0` on a desktop keeps the browser flow. An opt-out cancels that one marker only — `CI=false GITHUB_ACTIONS=true` still selects the device flow, and `GITHUB_ACTIONS=false` opts that marker out without affecting `CI`. See [Environment variables](https://docs.kici.dev/user/env-vars/#how-ci-is-interpreted) for the full convention.
644
+ 3. Container — `container` or `DOCKER_CONTAINER` set, or the `/run/.containerenv` / `/.dockerenv` sentinel files present.
645
+ 4. WSL — an interactive desktop, so **not** headless, but only when Windows interop is reachable: the browser flow opens your Windows browser and the localhost callback is normally reachable through WSL's localhost forwarding (a `portproxy` rule or firewall policy can still block it — pass `--device` if it does). When interop is unreachable (it is disabled, or the Windows drive is not mounted) no Windows browser can be launched, so WSL counts as headless and the device flow is used. The same applies when the interop check does not answer within a couple of seconds — the signature of a hung Windows drive mount — so a wedged mount falls back to the device flow instead of stalling the login.
646
+ 5. Linux without a display server — neither `DISPLAY` nor `WAYLAND_DISPLAY` set.
647
+
648
+ The first match wins, so an SSH session into WSL, or a container running on a WSL host, stays on the device flow.
649
+
650
+ ### kici logout
651
+
652
+ Revoke your personal access token on the server and clear local credentials.
653
+
654
+ If the server is unreachable, local credentials are still cleared (the PAT will expire automatically). Non-auth config fields (active org, default clusters, etc.) are preserved.
655
+
656
+ ```bash
657
+ kici logout
658
+ ```
659
+
660
+ **Examples:**
661
+
662
+ ```bash
663
+ # Log out and revoke PAT
664
+ kici logout
665
+ ```
666
+
667
+ ### kici init
668
+
669
+ Initialize a `.kici/` directory with default workflow templates.
670
+
671
+ ```bash
672
+ kici init [options]
673
+ ```
674
+
675
+ **Examples:**
676
+
677
+ ```bash
678
+ # Interactive initialization
679
+ kici init
680
+
681
+ # Overwrite existing setup
682
+ kici init --force
683
+
684
+ # Skip dependency install (faster, install manually later)
685
+ kici init --skip-install
686
+
687
+ # Force a specific package manager (default: detect from your repo)
688
+ kici init --package-manager pnpm
689
+
690
+ # JavaScript mode (no TypeScript)
691
+ kici init --mjs
692
+
693
+ # Integrate into the surrounding workspace (workflows can import sibling packages)
694
+ kici init --workspace
695
+
696
+ # Force a self-contained .kici/ even inside a workspace
697
+ kici init --standalone
698
+
699
+ # Skip writing the AGENTS.md LLM authoring context file
700
+ kici init --no-agents-md
701
+
702
+ # Scaffold a workflow registries entry for a private npm registry
703
+ kici init --private-registry https://npm.pkg.github.com/ \
704
+ --private-registry-scope @my-org \
705
+ --private-registry-secret production:GITHUB_PACKAGES_TOKEN
706
+ ```
707
+
708
+ **What it creates:**
709
+
710
+ ```
711
+ .kici/
712
+ workflows/
713
+ hello-world.ts # Minimal push workflow
714
+ pr-checks.ts # Comprehensive PR workflow
715
+ tests/
716
+ push-test.ts # Sample test fixture
717
+ types/ # Directory for generated type declarations (kici types)
718
+ package.json # Dependencies (@kici-dev/sdk)
719
+ tsconfig.json # TypeScript configuration (includes types/**/*.d.ts)
720
+ AGENTS.md # LLM authoring context (skip with --no-agents-md)
721
+ .kiciignore # Default exclusion patterns for test uploads
722
+ ```
723
+
724
+ `AGENTS.md` is written by default (the interactive prompt defaults to yes, and CI / non-interactive runs write it). An existing `.kici/AGENTS.md` is never overwritten, so hand edits survive a re-run.
725
+
726
+ In interactive mode (TTY), `kici init` prompts you to:
727
+
728
+ 1. Select which workflow templates to include
729
+ 2. Optionally install a pre-commit hook
730
+
731
+ **Host-OS runsOn:** the scaffolded workflows target `kici:os:<your OS>` — `kici init` detects the host operating system (like it detects the default branch) and writes `kici:os:linux`, `kici:os:macos`, or `kici:os:windows` so your very first `kici run push --local` dispatches on this machine. A workflow authored on one OS and run locally on another prints a hint naming the OS it wants versus the host it found.
732
+
733
+ **First run:** in interactive mode, after setup `kici init` offers to run the scaffolded workflow immediately (`kici run push --local`), defaulting to No. It is skipped in CI, non-interactive shells, `--mjs`, and `--skip-install` (where dependencies are not installed yet).
734
+
735
+ **Package manager:** the dependency install step uses the package manager detected for your repo — the `packageManager` field in the nearest `package.json` (Corepack convention), then a lockfile in the project root (`pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, `package-lock.json` → npm), then the package manager that invoked `kici` (`pnpm dlx` / `yarn dlx` / `npx`), defaulting to npm. Pass `--package-manager <npm|pnpm|yarn>` to override detection, or `--skip-install` to set up the files and install later yourself.
736
+
737
+ **Standalone vs workspace integration:** by default `kici init` scaffolds a self-contained `.kici/` with its own `package.json`. When run inside a pnpm, npm, or yarn workspace, it offers an **integrate** option (or pass `--workspace`): `.kici/` joins the workspace, `@kici-dev/sdk` is added to your workspace-root `package.json`, and your workflows can `import` your other workspace packages (e.g. shared build or deploy utilities). In this mode there is no `.kici/package.json` — the workspace root manages dependencies, and the root install resolves the SDK. Your workflows resolve sibling packages through the workspace-root `node_modules`: under npm and yarn every workspace member is hoisted there automatically, while pnpm links only your root's declared dependencies, so under pnpm add the package you want to import to your workspace-root `dependencies` (this is how KiCI's own repository imports its packages from workflows). Pass `--standalone` to force the self-contained layout even inside a workspace. In CI / non-interactive runs the default is standalone; use `--workspace` to opt in explicitly. `--workspace` and `--standalone` are mutually exclusive, and `--workspace` errors if no workspace is found at or above the current directory.
738
+
739
+ **Development mode:** When `KICI_DEV=true` or `package.json` has `"kici": { "development": true }`, the generated `package.json` uses prerelease-compatible version ranges (`>=0.0.1-0`) so npm resolves Verdaccio's prerelease builds.
740
+
741
+ ### kici org
742
+
743
+ Manage organization context. Requires a PAT (run `kici login` first).
744
+
745
+ #### kici org list
746
+
747
+ List organizations you belong to. The active org is marked with a star (`*`).
748
+
749
+ ```bash
750
+ kici org list
751
+ ```
752
+
753
+ **Example output:**
754
+
755
+ ```
756
+ Organizations:
757
+
758
+ * Personal (owner) abc123def456
759
+ My team (admin) xyz789ghi012
760
+ ```
761
+
762
+ #### kici org use
763
+
764
+ Switch the active organization by name (case-insensitive) or ID.
765
+
766
+ ```bash
767
+ kici org use <name>
768
+ ```
769
+
770
+ **Examples:**
771
+
772
+ ```bash
773
+ # Switch by name
774
+ kici org use "My team"
775
+
776
+ # Switch by ID
777
+ kici org use xyz789ghi012
778
+ ```
779
+
780
+ #### kici org current
781
+
782
+ Show the current active organization.
783
+
784
+ ```bash
785
+ kici org current
786
+ ```
787
+
788
+ ### kici pat create
789
+
790
+ Mint a personal access token under your own identity. Pass `--agent` to mint an
791
+ **agent-kind** PAT — the credential a coding agent points the KiCI MCP server at.
792
+
793
+ ```bash
794
+ kici pat create --agent --name "claude-code"
795
+ ```
796
+
797
+ - `--agent` marks the token as agent-kind. An agent PAT inherits your
798
+ permissions unchanged (it carries provenance, not extra authority) and is the
799
+ **only** credential the MCP server accepts.
800
+ - `--name <label>` sets the token name. For an agent PAT this is the **agent
801
+ label** recorded on every action the agent takes — required with `--agent`.
802
+ - `--expires-in-days <n>` overrides the default expiry.
803
+
804
+ The token is printed once — save it immediately; it cannot be retrieved later.
805
+ See [Drive KiCI from your coding agent](https://docs.kici.dev/user/ai-agents/) for the full setup.
806
+
807
+ **Prerequisites:** authenticate via `kici login` first.
808
+
809
+ ### kici secrets list
810
+
811
+ List secret contexts available for test runs. Shows context names and key names (not values).
812
+
813
+ ```bash
814
+ kici secrets list
815
+ ```
816
+
817
+ 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.
818
+
819
+ Only key names are shown — secret values are never returned over this endpoint.
820
+
821
+ **Prerequisites:** authenticate via `kici login` and select an active organization with `kici org use <name>`.
822
+
823
+ ### kici admin
824
+
825
+ Operator-facing commands for running instances.
826
+
827
+ #### kici admin drain-worker
828
+
829
+ Trigger graceful drain on a worker instance. Sends a POST request to the worker's `/drain` endpoint.
830
+
831
+ ```bash
832
+ kici admin drain-worker [options]
833
+ ```
834
+
835
+ **Examples:**
836
+
837
+ ```bash
838
+ # Drain a local worker
839
+ kici admin drain-worker --url http://localhost:10143
840
+
841
+ # Drain a remote worker
842
+ kici admin drain-worker --url http://worker-2.internal:10143
843
+ ```
844
+
845
+ **Exit codes:**
846
+
847
+ | Code | Meaning |
848
+ | ---- | ----------------------------------- |
849
+ | 0 | Drain request accepted |
850
+ | 1 | Error (unreachable or request fail) |
851
+
852
+ ### kici endpoints
853
+
854
+ List all webhook entrypoints for the current project. Reads the compiled lock file and displays webhook URLs grouped by type (git provider, generic webhooks, scheduled, event-driven).
855
+
856
+ ```bash
857
+ kici endpoints [options]
858
+ ```
859
+
860
+ **Prerequisites:** Run `kici compile` first to generate the lock file.
861
+
862
+ **Examples:**
863
+
864
+ ```bash
865
+ # List all webhook entrypoints
866
+ kici endpoints
867
+
868
+ # Custom .kici directory
869
+ kici endpoints --kici-dir packages/app/.kici
870
+ ```
871
+
872
+ ## Reference
873
+
874
+ <!-- BEGIN GENERATED: kici-account-and-org (do not edit; run the doc generator) -->
875
+
876
+ ### `kici admin`
877
+
878
+ Operator-facing commands for running instances
879
+
880
+ Synopsis: `kici admin`
881
+
882
+ ### `kici admin drain-worker`
883
+
884
+ Trigger graceful drain on a worker instance
885
+
886
+ Synopsis: `kici admin drain-worker [options]`
887
+
888
+ **Options**
889
+
890
+ | Option | Default | Description |
891
+ | ------------- | ------- | -------------------------------------------- |
892
+ | `--url <url>` | | Worker URL (e.g., http://worker-host:<port>) |
893
+
894
+ ### `kici endpoints`
895
+
896
+ List all webhook entrypoints for the current project
897
+
898
+ Synopsis: `kici endpoints [options]`
899
+
900
+ **Options**
901
+
902
+ | Option | Default | Description |
903
+ | ------------------- | ------- | ----------------------- |
904
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
905
+
906
+ ### `kici init`
907
+
908
+ Initialize .kici/ directory with default workflows
909
+
910
+ Synopsis: `kici init [options]`
911
+
912
+ **Options**
913
+
914
+ | Option | Default | Description |
915
+ | ---------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------- |
916
+ | `--force` | `false` | Overwrite existing .kici/ directory |
917
+ | `--skip-install` | `false` | Create files without installing dependencies |
918
+ | `--package-manager <npm | pnpm | yarn>` | | Force a package manager for the install step (default: auto-detect) |
919
+ | `--mjs` | `false` | JavaScript-only mode (no TypeScript, no dependencies) |
920
+ | `--workspace` | `false` | Integrate .kici/ into the detected pnpm/npm/yarn workspace so workflows can import sibling packages |
921
+ | `--standalone` | `false` | Force a self-contained .kici/ even inside a workspace |
922
+ | `--no-agents-md` | | Skip writing .kici/AGENTS.md (LLM authoring context) |
923
+ | `--private-registry <url>` | | Scaffold a workflow registries: entry pointing at <url> |
924
+ | `--private-registry-scope <scope>` | | Optional npm package scope (e.g. @my-org) for the private registry |
925
+ | `--private-registry-secret <ref>` | `production:NPM_TOKEN` | Qualified secret reference (env:NAME) the private registry token comes from |
926
+
927
+ ### `kici login`
928
+
929
+ Authenticate with KiCI via browser OAuth (default) or API key (--token)
930
+
931
+ Synopsis: `kici login [options]`
932
+
933
+ **Options**
934
+
935
+ | Option | Default | Description |
936
+ | --------------------------- | ------- | ----------------------------------------------------------------------------------- |
937
+ | `--token <key>` | | API key for direct authentication (legacy) |
938
+ | `--device` | | Force device authorization flow (for headless/SSH environments) |
939
+ | `--platform-endpoint <url>` | | Platform relay URL |
940
+ | `--oidc-issuer <url>` | | OIDC issuer URL (defaults to the hosted KiCI IdP unless a flag/env selects another) |
941
+ | `--routing-key <key>` | | Routing key for webhook source identification |
942
+ | `--no-attach` | | Skip the post-login prompt to attach the local dev plane |
943
+
944
+ ### `kici logout`
945
+
946
+ Revoke PAT and clear local credentials
947
+
948
+ Synopsis: `kici logout`
949
+
950
+ ### `kici orchestrators`
951
+
952
+ Inspect the org's orchestrator clusters and pick a default for run remote
953
+
954
+ Synopsis: `kici orchestrators`
955
+
956
+ ### `kici orchestrators list`
957
+
958
+ List the connected orchestrator clusters for the active org
959
+
960
+ Synopsis: `kici orchestrators list [options]`
961
+
962
+ **Options**
963
+
964
+ | Option | Default | Description |
965
+ | ------------ | ------- | ---------------------------------------------- |
966
+ | `--org <id>` | | Target organization (overrides the active org) |
967
+
968
+ ### `kici orchestrators use`
969
+
970
+ Set the per-org default orchestrator cluster for run remote
971
+
972
+ Synopsis: `kici orchestrators use <name> [options]`
973
+
974
+ **Arguments**
975
+
976
+ | Argument | Required | Variadic | Description |
977
+ | -------- | -------- | -------- | ------------------------- |
978
+ | `name` | yes | no | Orchestrator cluster name |
979
+
980
+ **Options**
981
+
982
+ | Option | Default | Description |
983
+ | ------------ | ------- | ---------------------------------------------- |
984
+ | `--org <id>` | | Target organization (overrides the active org) |
985
+
986
+ ### `kici org`
987
+
988
+ Manage organizations
989
+
990
+ Synopsis: `kici org`
991
+
992
+ ### `kici org current`
993
+
994
+ Show current active organization
995
+
996
+ Synopsis: `kici org current`
997
+
998
+ ### `kici org list`
999
+
1000
+ List organizations you belong to
1001
+
1002
+ Synopsis: `kici org list`
1003
+
1004
+ ### `kici org use`
1005
+
1006
+ Switch active organization
1007
+
1008
+ Synopsis: `kici org use <name>`
1009
+
1010
+ **Arguments**
1011
+
1012
+ | Argument | Required | Variadic | Description |
1013
+ | -------- | -------- | -------- | ----------------------- |
1014
+ | `name` | yes | no | Organization name or ID |
1015
+
1016
+ ### `kici pat`
1017
+
1018
+ Manage personal access tokens
1019
+
1020
+ Synopsis: `kici pat`
1021
+
1022
+ ### `kici pat create`
1023
+
1024
+ Mint a personal access token (use --agent for a coding-agent token)
1025
+
1026
+ Synopsis: `kici pat create [options]`
1027
+
1028
+ **Options**
1029
+
1030
+ | Option | Default | Description |
1031
+ | ----------------------- | ------- | ---------------------------------------------- |
1032
+ | `--name <name>` | | Token name (defaults to the agent label) |
1033
+ | `--agent` | `false` | Mint an agent-kind PAT for the KiCI MCP server |
1034
+ | `--expires-in-days <n>` | | Custom expiry in days |
1035
+
1036
+ ### `kici secrets`
1037
+
1038
+ Manage secrets
1039
+
1040
+ Synopsis: `kici secrets`
1041
+
1042
+ ### `kici secrets list`
1043
+
1044
+ List test-available secret contexts
1045
+
1046
+ Synopsis: `kici secrets list`
1047
+ <!-- END GENERATED: kici-account-and-org -->
1048
+
1049
+ ---
1050
+
1051
+ ## kici: notifications & diagnostics
1052
+
1053
+ Source: https://docs.kici.dev/user/cli/notifications-and-diagnostics/
1054
+
1055
+ ## Guide
1056
+
1057
+ ### kici notifications
1058
+
1059
+ Manage your organization's notification configuration — channels, subscriptions, and the Slack-identity roster — programmatically, under your PAT against the hosted Platform's org-scoped API. Requires a PAT (run `kici login` first) and an active org (`kici org use <name>`, or pass `--org <id>` to any subcommand). These are the same operations the dashboard Notifications tab performs.
1060
+
1061
+ Every `list` supports `--json` for machine-readable output.
1062
+
1063
+ #### kici notifications channels
1064
+
1065
+ Manage the destinations a notification is delivered to (Slack or email).
1066
+
1067
+ ```bash
1068
+ # List channels
1069
+ kici notifications channels list
1070
+ kici notifications channels list --json
1071
+
1072
+ # Add a Slack channel
1073
+ kici notifications channels add --type slack --name "alerts" \
1074
+ --connection <connectionId> --slack-channel <slackChannelId>
1075
+
1076
+ # Add an email channel
1077
+ kici notifications channels add --type email --name "email" \
1078
+ --from-name "KiCI CI" --reply-to ci@example.com
1079
+
1080
+ # Remove a channel
1081
+ kici notifications channels remove <channelId>
1082
+ ```
1083
+
1084
+ #### kici notifications subscriptions
1085
+
1086
+ Manage which runs notify which channel, with optional literal `--mentions` and digest accumulation.
1087
+
1088
+ ```bash
1089
+ # List subscriptions
1090
+ kici notifications subscriptions list
1091
+
1092
+ # Notify a channel on any failure across the org
1093
+ kici notifications subscriptions add --channel <channelId> --on-status failed
1094
+
1095
+ # Scope to a repo, mention people, and accumulate a digest over 30s
1096
+ kici notifications subscriptions add --channel <channelId> \
1097
+ --on-status failed --repo-glob 'my-org/*' \
1098
+ --mentions U012ABCDEF,U345GHIJKL --accumulate-for 30000
1099
+
1100
+ # Remove a subscription
1101
+ kici notifications subscriptions remove <subscriptionId>
1102
+ ```
1103
+
1104
+ Key options for `add`: `--level <run|job>` (default `run`), `--scope <org|team|user|actor>` (default `org`; `--scope-id` is required for `team`/`user`), `--on-status <csv>` (required), `--repo-glob` / `--workflow-glob` / `--job-glob`, `--mentions <csv>`, `--recipient-override <csv>`, `--on-failure-class <csv>`, `--accumulate-for <ms>`.
1105
+
1106
+ #### kici notifications roster
1107
+
1108
+ Manage the Slack-identity roster used for best-effort actor tagging — mapping the person who triggered a run to a Slack member id.
1109
+
1110
+ `roster add` requires the `notifications:admin` permission — it is the admin editor for the shared roster. To connect **your own** Slack account (no admin needed), use **Connect Slack** on the dashboard's personal Notifications tab, which runs Sign in with Slack; there is no CLI equivalent because the flow is browser-based.
1111
+
1112
+ ```bash
1113
+ # List roster entries
1114
+ kici notifications roster list
1115
+
1116
+ # Admin: map a contributor to their Slack member id (by id, email, or @handle)
1117
+ kici notifications roster add --connection <connectionId> \
1118
+ --subject-kind git_login --subject octocat \
1119
+ --input-form email --value octocat@example.com
1120
+
1121
+ # Remove a roster entry (admins; or your own connected entry)
1122
+ kici notifications roster remove <entryId>
1123
+ ```
1124
+
1125
+ ### kici verify-attestation
1126
+
1127
+ Verify a KiCI build-provenance attestation bundle offline. A bundle is the signed package a workflow step produces via `ctx.attestProvenance(...)`: a DSSE-wrapped SLSA in-toto statement, the ephemeral public key that signed it, and the KiCI identity token that anchors the build context. For the end-to-end attest → verify → view journey, see the [build provenance guide](https://docs.kici.dev/user/provenance/). Verification establishes the full chain — the identity token verifies against the trusted issuer's JWKS, the DSSE signature verifies against the bundled key, and the statement's build context must match the token's claims (a mismatch is a hard failure). When an `[artifact]` is given, its SHA-256 digest is also matched against the attestation subject.
1128
+
1129
+ On success the output prints the **origin org** (the customer's public org id — the authoritative "who built this" the platform vouches for) and a **source marker**. A `kici run remote` attestation is flagged unmistakably: its `repository`/`ref`/`sha` are caller-supplied from a local working-tree overlay, not a triggered VCS commit, so a verifier must treat those coordinates as org-asserted rather than VCS-verified. A normal triggered run carries the ordinary `triggered` source marker. See the [build provenance guide](https://docs.kici.dev/user/provenance/) for the full trust model.
1130
+
1131
+ ```bash
1132
+ kici verify-attestation [artifact] --bundle <path-or-url> [--trust-root <url-or-file>] [options]
1133
+ ```
1134
+
1135
+ **Trust root:** `--trust-root` defaults to your **configured orchestrator** — the orchestrator you `kici login` against, which owns the provenance signing key and publishes its own JWKS (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. When no orchestrator is configured, the default falls back to the hosted KiCI platform's provenance issuer so historical platform-signed bundles still verify. 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:
1136
+
1137
+ - **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`.
1138
+ - **Offline — a self-contained trust-root file.** A local JSON file with the issuer and JWKS inlined, so no network access is needed (air-gapped verification):
1139
+
1140
+ ```json
1141
+ {
1142
+ "issuer": "https://platform.example/issuer",
1143
+ "jwks": {
1144
+ "keys": [
1145
+ { "kty": "EC", "crv": "P-256", "x": "...", "y": "...", "alg": "ES256", "kid": "..." }
1146
+ ]
1147
+ }
1148
+ }
1149
+ ```
1150
+
1151
+ **Examples:**
1152
+
1153
+ ```bash
1154
+ # Default: verify against your configured orchestrator (no --trust-root needed)
1155
+ kici verify-attestation ./dist/app.tgz --bundle ./app.tgz.kici.json
1156
+
1157
+ # Override: verify a bundle against a specific issuer, digest-checking the artifact
1158
+ kici verify-attestation ./dist/app.tgz \
1159
+ --bundle ./app.tgz.kici.json \
1160
+ --trust-root https://platform.example/issuer
1161
+
1162
+ # Offline / air-gapped: verify against a self-contained trust-root file
1163
+ kici verify-attestation ./dist/app.tgz \
1164
+ --bundle ./app.tgz.kici.json \
1165
+ --trust-root ./kici-trust-root.json
1166
+
1167
+ # Machine-readable result for scripting
1168
+ kici verify-attestation --bundle ./app.tgz.kici.json \
1169
+ --trust-root https://platform.example/issuer --json
1170
+ ```
1171
+
1172
+ **Attestation origin marker.** On a PASS, the command surfaces when the identity
1173
+ token was minted relative to the build. A normal attestation prints no marker
1174
+ (the token was minted live). A **deferred** attestation prints an `ATTESTATION:
1175
+ deferred` line — the build facts were sealed at build time and the token was
1176
+ minted later, after a transient platform outage, bound to the frozen statement
1177
+ by its hash. An **offline-backfill** attestation prints an `ATTESTATION:
1178
+ offline-backfill` line — the run was ingested while the platform was down, so its
1179
+ run/job rows were backfilled before the token was minted. Both still verify
1180
+ (PASS); the marker discloses the temporal gap, and the organization id remains
1181
+ the authoritative anchor.
1182
+
1183
+ **Exit codes:**
1184
+
1185
+ | Code | Meaning |
1186
+ | ---- | ----------------------------------------------------------------------------------------- |
1187
+ | 0 | Verified — signature, identity, build context (and digest, if checked) all pass |
1188
+ | 1 | Not verified, or an error (missing `--bundle`, unreadable bundle, unreachable trust root) |
1189
+
1190
+ ### kici diagnostics
1191
+
1192
+ Show the orchestrators, scalers, and agents serving your organization — the
1193
+ terminal equivalent of the dashboard Infrastructure page. Reads the same
1194
+ org-scoped data the dashboard does, so it needs `kici login` and an active org
1195
+ (`kici org use <name>`).
1196
+
1197
+ The output has three parts: a one-line header (runs in the last 24h, success
1198
+ rate, average duration, queued/running job counts), any infrastructure alerts
1199
+ (only shown when present), and a tree of each orchestrator with its scalers and
1200
+ agents. Each agent line shows its labels, platform/architecture, active/maximum
1201
+ concurrency, and heartbeat age.
1202
+
1203
+ Alert lines are colored by severity — yellow for `warning`, red for `critical`.
1204
+ A severity this build does not recognize is colored red, so an alert from a
1205
+ newer Platform is never shown as less urgent than it might be.
1206
+
1207
+ ```bash
1208
+ kici diagnostics [options]
1209
+ ```
1210
+
1211
+ **Examples:**
1212
+
1213
+ ```bash
1214
+ # Show the full infrastructure tree
1215
+ kici diagnostics
1216
+
1217
+ # Extended per-agent detail
1218
+ kici diagnostics --verbose
1219
+
1220
+ # Only one orchestrator's scalers and agents
1221
+ kici diagnostics --orchestrator conn-abc123
1222
+
1223
+ # Machine-readable output
1224
+ kici diagnostics --json
1225
+ ```
1226
+
1227
+ ### kici doctor
1228
+
1229
+ Walk your KiCI setup end to end and print the exact next command for each
1230
+ problem found. Where `kici diagnostics` shows the org's infrastructure, `kici
1231
+ doctor` checks **your own setup**: it runs six checks in onboarding order —
1232
+ login (stored, unexpired credentials), active organization, a present, fresh,
1233
+ and committed lock file, a live token probe against the platform, a connected
1234
+ orchestrator for the org, and whether every workflow's `runsOn` labels are
1235
+ satisfiable by a connected agent or scaler. Each check reports pass/warn/fail
1236
+ with the fix command (e.g. `kici login`, `kici org use <name>`,
1237
+ `kici compile`), so the first failing row tells you exactly what to run next.
1238
+
1239
+ ```bash
1240
+ kici doctor [options]
1241
+ ```
1242
+
1243
+ **Examples:**
1244
+
1245
+ ```bash
1246
+ # Diagnose the full setup
1247
+ kici doctor
1248
+
1249
+ # Machine-readable result for scripting
1250
+ kici doctor --json
1251
+ ```
1252
+
1253
+ The command exits `0` when every check passes, `1` when any check warns, and
1254
+ `2` when any check fails, so it also works as a CI preflight.
1255
+
1256
+ ### kici report
1257
+
1258
+ Gather a diagnostic bundle to share when you report a problem. `kici doctor`
1259
+ tells you what is wrong; `kici report` packages the context somebody else needs
1260
+ to see it. The bundle holds your CLI, Node and orchestrator versions, your
1261
+ redacted configuration, and your project's workflow and lock-file state. With
1262
+ `--run` it also holds the failing run's detail and logs.
1263
+
1264
+ ```bash
1265
+ kici report [options]
1266
+ ```
1267
+
1268
+ The command writes a ZIP and prints its path and `sha256`. It does not send
1269
+ anything. Open the file and read it before you share it.
1270
+
1271
+ ```bash
1272
+ # Bundle your setup
1273
+ kici report
1274
+
1275
+ # Scope it to the run that failed, and say what went wrong
1276
+ kici report --run 8f3c1d2e --message "matrix job hangs on macOS"
1277
+
1278
+ # Choose the output path and attach your own metadata
1279
+ kici report -o /tmp/bug.zip --metadata ticket=1234 --metadata severity=high
1280
+ ```
1281
+
1282
+ **Redaction.** KiCI removes known secret shapes — API keys, tokens, `Authorization`
1283
+ headers, private keys, passwords in connection URLs — from configuration and
1284
+ from log text. This is best effort. A secret in a format KiCI does not
1285
+ recognize can survive, so review the bundle before you share it. `--no-redact`
1286
+ turns redaction off and prints a warning; use it only on a bundle you keep.
1287
+
1288
+ **Sending it privately.** Add `--upload` to send the bundle to KiCI over a
1289
+ one-time upload link. The bundle goes straight to KiCI storage, and the command
1290
+ prints a reference id to quote:
1291
+
1292
+ ```bash
1293
+ kici report --run 8f3c1d2e --upload --message "matrix job hangs on macOS"
1294
+ ```
1295
+
1296
+ Uploads are private, are kept for 90 days, and are yours to withdraw:
1297
+
1298
+ ```bash
1299
+ # See what you have sent
1300
+ kici report list
1301
+
1302
+ # Delete an uploaded bundle
1303
+ kici report withdraw <ref>
1304
+ ```
1305
+
1306
+ Anyone in your organization can upload a report. By default you see and
1307
+ withdraw your own; a member with the `support:admin` permission can manage
1308
+ every report in the organization.
1309
+
1310
+ ### kici feedback
1311
+
1312
+ `kici report` sends a problem with **your own runs** to KiCI privately. `kici
1313
+ feedback` covers the other case: a defect in KiCI itself that reproduces
1314
+ without your data, such as a documented flag that does not exist.
1315
+
1316
+ ```bash
1317
+ kici feedback
1318
+ ```
1319
+
1320
+ It prints what qualifies as a reportable discrepancy, what a report must
1321
+ carry, what must never appear in a public issue, and where to file it. The
1322
+ command reaches no network and files nothing.
1323
+
1324
+ ```bash
1325
+ # Open the prefilled issue form in your browser
1326
+ kici feedback --open
1327
+
1328
+ # Read the same contract as structured data
1329
+ kici feedback --json
1330
+ ```
1331
+
1332
+ `--json` exists for coding agents: KiCI is built to be driven by an LLM, and
1333
+ an agent can read the rules without parsing prose. One of those rules is that
1334
+ an agent drafts a report and a **person** decides to file it.
1335
+
1336
+ The full guide is [Reporting a discrepancy](https://docs.kici.dev/user/reporting-discrepancies/).
1337
+ A suspected vulnerability never goes in a public issue — follow the
1338
+ disclosure process in
1339
+ [SECURITY.md](https://github.com/kici-dev/kici-public/blob/main/SECURITY.md).
1340
+
1341
+ ## Reference
1342
+
1343
+ <!-- BEGIN GENERATED: kici-notifications-and-diagnostics (do not edit; run the doc generator) -->
1344
+
1345
+ ### `kici diagnostics`
1346
+
1347
+ Show orchestrators, scalers, and agents (mirrors the dashboard Infrastructure page)
1348
+
1349
+ Synopsis: `kici diagnostics [options]`
1350
+
1351
+ **Options**
1352
+
1353
+ | Option | Default | Description |
1354
+ | --------------------- | ------- | ----------------------------------- |
1355
+ | `--json` | `false` | Output raw JSON |
1356
+ | `--verbose` | `false` | Show extended per-agent fields |
1357
+ | `--orchestrator <id>` | | Scope the tree to one connection id |
1358
+
1359
+ ### `kici doctor`
1360
+
1361
+ Diagnose your KiCI setup and print the exact next command for each problem
1362
+
1363
+ Synopsis: `kici doctor [options]`
1364
+
1365
+ **Options**
1366
+
1367
+ | Option | Default | Description |
1368
+ | ------------------- | ------- | ---------------------------------- |
1369
+ | `--json` | `false` | Output raw JSON instead of a table |
1370
+ | `--kici-dir <path>` | `.kici` | Path to the .kici directory |
1371
+
1372
+ ### `kici feedback`
1373
+
1374
+ Print how to report a discrepancy between what KiCI advertises and what it does. Files nothing.
1375
+
1376
+ Synopsis: `kici feedback [options]`
1377
+
1378
+ **Options**
1379
+
1380
+ | Option | Default | Description |
1381
+ | -------- | ------- | ---------------------------------------------------- |
1382
+ | `--open` | | Open the prefilled issue form in the default browser |
1383
+ | `--json` | | Emit the reporting contract as JSON |
1384
+
1385
+ ### `kici notifications`
1386
+
1387
+ Manage the org's notification channels, subscriptions, and Slack roster
1388
+
1389
+ Synopsis: `kici notifications`
1390
+
1391
+ ### `kici notifications channels`
1392
+
1393
+ Manage notification channels (Slack / email)
1394
+
1395
+ Synopsis: `kici notifications channels`
1396
+
1397
+ ### `kici notifications channels add`
1398
+
1399
+ Add a notification channel
1400
+
1401
+ Synopsis: `kici notifications channels add [options]`
1402
+
1403
+ **Options**
1404
+
1405
+ | Option | Default | Description |
1406
+ | ---------------------- | ------- | ---------------------------------------------- |
1407
+ | `--type <slack | email>` | | Channel transport type |
1408
+ | `--name <name>` | | Channel display name |
1409
+ | `--connection <id>` | | Slack connection id (slack channels) |
1410
+ | `--slack-channel <id>` | | Slack channel id (slack channels) |
1411
+ | `--from-name <name>` | | Sender name (email channels) |
1412
+ | `--reply-to <email>` | | Reply-to address (email channels) |
1413
+ | `--org <id>` | | Target organization (overrides the active org) |
1414
+
1415
+ ### `kici notifications channels list`
1416
+
1417
+ List notification channels
1418
+
1419
+ Synopsis: `kici notifications channels list [options]`
1420
+
1421
+ **Options**
1422
+
1423
+ | Option | Default | Description |
1424
+ | ------------ | ------- | ---------------------------------------------- |
1425
+ | `--org <id>` | | Target organization (overrides the active org) |
1426
+ | `--json` | | Output as JSON |
1427
+
1428
+ ### `kici notifications channels remove`
1429
+
1430
+ Remove a notification channel
1431
+
1432
+ Synopsis: `kici notifications channels remove <id> [options]`
1433
+
1434
+ **Arguments**
1435
+
1436
+ | Argument | Required | Variadic | Description |
1437
+ | -------- | -------- | -------- | ----------- |
1438
+ | `id` | yes | no | Channel id |
1439
+
1440
+ **Options**
1441
+
1442
+ | Option | Default | Description |
1443
+ | ------------ | ------- | ---------------------------------------------- |
1444
+ | `--org <id>` | | Target organization (overrides the active org) |
1445
+
1446
+ ### `kici notifications roster`
1447
+
1448
+ Manage the Layer 1 Slack-identity roster (actor tagging)
1449
+
1450
+ Synopsis: `kici notifications roster`
1451
+
1452
+ ### `kici notifications roster add`
1453
+
1454
+ Add a Slack-identity roster entry
1455
+
1456
+ Synopsis: `kici notifications roster add [options]`
1457
+
1458
+ **Options**
1459
+
1460
+ | Option | Default | Description |
1461
+ | -------------------------------- | --------- | ---------------------------------------------- |
1462
+ | `--connection <id>` | | Slack connection id |
1463
+ | `--subject-kind <kici_user | git_login | email>` | | What the subject keys on |
1464
+ | `--subject <value>` | | The KiCI user sub, git login, or email |
1465
+ | `--value <slackIdEmailOrHandle>` | | Slack member id, email, or @handle |
1466
+ | `--input-form <id | username | email>` | `id` | How --value should be resolved |
1467
+ | `--org <id>` | | Target organization (overrides the active org) |
1468
+
1469
+ ### `kici notifications roster list`
1470
+
1471
+ List Slack-identity roster entries
1472
+
1473
+ Synopsis: `kici notifications roster list [options]`
1474
+
1475
+ **Options**
1476
+
1477
+ | Option | Default | Description |
1478
+ | ------------ | ------- | ---------------------------------------------- |
1479
+ | `--org <id>` | | Target organization (overrides the active org) |
1480
+ | `--json` | | Output as JSON |
1481
+
1482
+ ### `kici notifications roster remove`
1483
+
1484
+ Remove a Slack-identity roster entry
1485
+
1486
+ Synopsis: `kici notifications roster remove <id> [options]`
1487
+
1488
+ **Arguments**
1489
+
1490
+ | Argument | Required | Variadic | Description |
1491
+ | -------- | -------- | -------- | --------------- |
1492
+ | `id` | yes | no | Roster entry id |
1493
+
1494
+ **Options**
1495
+
1496
+ | Option | Default | Description |
1497
+ | ------------ | ------- | ---------------------------------------------- |
1498
+ | `--org <id>` | | Target organization (overrides the active org) |
1499
+
1500
+ ### `kici notifications subscriptions`
1501
+
1502
+ Manage notification subscriptions
1503
+
1504
+ Synopsis: `kici notifications subscriptions`
1505
+
1506
+ ### `kici notifications subscriptions add`
1507
+
1508
+ Add a notification subscription
1509
+
1510
+ Synopsis: `kici notifications subscriptions add [options]`
1511
+
1512
+ **Options**
1513
+
1514
+ | Option | Default | Description |
1515
+ | ---------------------------- | ------- | --------------------------------------------------- |
1516
+ | `--channel <id>` | | Target channel id |
1517
+ | `--on-status <csv>` | | Statuses to notify on (e.g. failed,success) |
1518
+ | `--level <run | job>` | `run` | Subscription granularity |
1519
+ | `--scope <org | team | user | actor>` | `org` | Subscription scope |
1520
+ | `--scope-id <id>` | | Scope id (required for team/user scope) |
1521
+ | `--repo-glob <glob>` | | Match runs whose repo matches this glob |
1522
+ | `--workflow-glob <glob>` | | Match runs whose workflow matches this glob |
1523
+ | `--job-glob <glob>` | | Match jobs matching this glob (job level) |
1524
+ | `--mentions <csv>` | | Literal Slack member/group ids or emails to mention |
1525
+ | `--recipient-override <csv>` | | Override the email recipient set |
1526
+ | `--on-failure-class <csv>` | | Only match these failure classes |
1527
+ | `--accumulate-for <ms>` | | Digest accumulation window in milliseconds |
1528
+ | `--org <id>` | | Target organization (overrides the active org) |
1529
+
1530
+ ### `kici notifications subscriptions list`
1531
+
1532
+ List notification subscriptions
1533
+
1534
+ Synopsis: `kici notifications subscriptions list [options]`
1535
+
1536
+ **Options**
1537
+
1538
+ | Option | Default | Description |
1539
+ | ------------ | ------- | ---------------------------------------------- |
1540
+ | `--org <id>` | | Target organization (overrides the active org) |
1541
+ | `--json` | | Output as JSON |
1542
+
1543
+ ### `kici notifications subscriptions remove`
1544
+
1545
+ Remove a notification subscription
1546
+
1547
+ Synopsis: `kici notifications subscriptions remove <id> [options]`
1548
+
1549
+ **Arguments**
1550
+
1551
+ | Argument | Required | Variadic | Description |
1552
+ | -------- | -------- | -------- | --------------- |
1553
+ | `id` | yes | no | Subscription id |
1554
+
1555
+ **Options**
1556
+
1557
+ | Option | Default | Description |
1558
+ | ------------ | ------- | ---------------------------------------------- |
1559
+ | `--org <id>` | | Target organization (overrides the active org) |
1560
+
1561
+ ### `kici report`
1562
+
1563
+ Gather a redacted diagnostic bundle to share when reporting an issue
1564
+
1565
+ Synopsis: `kici report [options]`
1566
+
1567
+ **Options**
1568
+
1569
+ | Option | Default | Description |
1570
+ | ------------------------ | ------- | ------------------------------------------------------------ |
1571
+ | `--run <id>` | | Scope the bundle to a failing run |
1572
+ | `-o, --output <path>` | | Where to write the bundle ZIP |
1573
+ | `--metadata <key=value>` | | Attach metadata (repeatable) |
1574
+ | `--no-redact` | | Do NOT redact secrets (prints a loud warning) |
1575
+ | `--upload` | | Upload the bundle privately to KiCI and print a reference id |
1576
+ | `--message <text>` | | Describe the problem (sent with --upload) |
1577
+ | `--email <address>` | | Contact address for follow-up (sent with --upload) |
1578
+ | `--kici-dir <path>` | `.kici` | Path to the .kici directory |
1579
+
1580
+ ### `kici report list`
1581
+
1582
+ List the issue reports you have uploaded
1583
+
1584
+ Synopsis: `kici report list [options]`
1585
+
1586
+ **Options**
1587
+
1588
+ | Option | Default | Description |
1589
+ | -------- | ------- | --------------- |
1590
+ | `--json` | `false` | Output raw JSON |
1591
+
1592
+ ### `kici report withdraw`
1593
+
1594
+ Withdraw an uploaded report and delete its bundle
1595
+
1596
+ Synopsis: `kici report withdraw <ref>`
1597
+
1598
+ **Arguments**
1599
+
1600
+ | Argument | Required | Variadic | Description |
1601
+ | -------- | -------- | -------- | -------------------------------------- |
1602
+ | `ref` | yes | no | Reference id of the report to withdraw |
1603
+
1604
+ ### `kici verify-attestation`
1605
+
1606
+ Verify a KiCI provenance attestation bundle offline
1607
+
1608
+ Synopsis: `kici verify-attestation [artifact] [options]`
1609
+
1610
+ **Arguments**
1611
+
1612
+ | Argument | Required | Variadic | Description |
1613
+ | ---------- | -------- | -------- | ------------------------------------------------------------------------ |
1614
+ | `artifact` | no | no | Artifact path to digest-check against the attestation subject (optional) |
1615
+
1616
+ **Options**
1617
+
1618
+ | Option | Default | Description |
1619
+ | ---------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
1620
+ | `--bundle <path>` | | Path or URL to the attestation bundle JSON |
1621
+ | `--trust-root <url-or-file>` | | Trusted issuer URL, or a self-contained { issuer, jwks } file (default: your configured orchestrator, else the hosted KiCI platform) |
1622
+ | `--audience <aud>` | | Expected token audience |
1623
+ | `--json` | `false` | Output structured JSON result |
1624
+
1625
+ <!-- END GENERATED: kici-notifications-and-diagnostics -->
1626
+
1627
+ ---
1628
+
1629
+ ## kici: runs & approvals
1630
+
1631
+ Source: https://docs.kici.dev/user/cli/runs-and-approvals/
1632
+
1633
+ ## Guide
1634
+
1635
+ ### kici run
1636
+
1637
+ 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.
1638
+
1639
+ #### kici run <event> --local
1640
+
1641
+ 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.
1642
+
1643
+ `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.
1644
+
1645
+ ```bash
1646
+ kici run [event] --local [options]
1647
+ ```
1648
+
1649
+ **Concurrency enforcement:**
1650
+
1651
+ A local run is a real routed dispatch, so a workflow's `concurrency` block is enforced by the local dev plane's own orchestrator — the same machinery a deployed orchestrator uses:
1652
+
1653
+ - The `group` callback is evaluated agent-side against the simulated event (the same `{ branch, event }` context the agent sees), and the resulting key is reported back to the plane's orchestrator before steps execute.
1654
+ - `cancelInProgress: true` supersedes the older run in the group; `false` queues the newer run behind it.
1655
+
1656
+ Coordination is scoped to that plane, whose state lives under `~/.kici/local/` — so enforcement is per-machine and per-user, and running the same workflow on two different machines does not serialize across them. That requires a deployed orchestrator.
1657
+
1658
+ **Execution isolation:**
1659
+
1660
+ 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.
1661
+
1662
+ 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`.
1663
+
1664
+ The checkout is a fresh temp directory named `kici-local-run-<random>` under the system temp directory (for example, `/tmp/kici-local-run-ab12cd`).
1665
+
1666
+ Cleanup policy:
1667
+
1668
+ - The isolated checkout is removed when the run finishes, whether it succeeded or failed.
1669
+ - A hard process death (SIGKILL, OOM kill) skips that cleanup. Leftovers older than a day are swept by the agent's own startup garbage collection, which every `kici run <event> --local` invocation triggers.
1670
+
1671
+ Set the `KICI_TMPDIR` environment variable to place the isolated checkout (and every other KiCI-created temp directory) under a base directory other than the system temp directory.
1672
+
1673
+ Secrets are always sourced from your real `.kici/` directory, not from the isolated checkout. Gitignored secret files (such as `.kici/.env.local` and `.kici/secrets.yaml`) are never copied into the checkout, so a step that reads a secret still gets it from the original location.
1674
+
1675
+ Pass `--in-place` to run against the real working directory instead — useful when you explicitly want in-tree execution. `--in-place` requires no git repository; the default isolated mode does, and fails with an actionable error pointing at `--in-place` when the directory is not a git repository.
1676
+
1677
+ **Examples:**
1678
+
1679
+ ```bash
1680
+ # Run workflows matching a push event on this machine
1681
+ kici run push --local
1682
+
1683
+ # Run a pull-request-open workflow locally
1684
+ kici run pr:open --local
1685
+
1686
+ # Reuse the working tree instead of an isolated clone
1687
+ kici run push --local --in-place
1688
+
1689
+ # Force the throwaway/offline plane
1690
+ kici run push --local --offline
1691
+
1692
+ # Environment variable overrides
1693
+ kici run push --local --env NODE_ENV=test --env CI=true
1694
+
1695
+ # Quiet mode (summary only, no streaming)
1696
+ kici run push --local --quiet
1697
+ ```
1698
+
1699
+ **Exit codes:**
1700
+
1701
+ | Code | Meaning |
1702
+ | ---- | ----------------------- |
1703
+ | 0 | All workflows succeeded |
1704
+ | 1 | One or more jobs failed |
1705
+
1706
+ #### kici run remote
1707
+
1708
+ 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.
1709
+
1710
+ 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/runs-and-approvals/#how-the-run-is-routed) and [The two planes](https://docs.kici.dev/user/cli/runs-and-approvals/#the-two-planes) below.
1711
+
1712
+ 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.
1713
+
1714
+ 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.
1715
+
1716
+ ```bash
1717
+ kici run remote [fixture] [options]
1718
+ ```
1719
+
1720
+ `--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.
1721
+
1722
+ **Examples:**
1723
+
1724
+ ```bash
1725
+ # List available fixtures
1726
+ kici run remote
1727
+
1728
+ # Run a single fixture against the active org
1729
+ kici run remote push-main
1730
+
1731
+ # Target a specific org for this run
1732
+ kici run remote push-main --org xyz789ghi012
1733
+
1734
+ # Target a specific orchestrator cluster within the org
1735
+ kici run remote push-main --orchestrator us-east
1736
+
1737
+ # Run all push-related fixtures
1738
+ kici run remote 'push-*'
1739
+
1740
+ # Run everything
1741
+ kici run remote --all
1742
+
1743
+ # Run a specific workflow directly (bypass trigger matching)
1744
+ kici run remote --workflow ci
1745
+
1746
+ # Quiet mode -- just pass/fail
1747
+ kici run remote push-main --quiet
1748
+
1749
+ # JSON output for scripting
1750
+ kici run remote push-main --json
1751
+
1752
+ # Fire and forget
1753
+ kici run remote push-main --no-wait
1754
+
1755
+ # View recent test run history
1756
+ kici run remote --history
1757
+
1758
+ # Interactively pick which fixtures to run (multi-select)
1759
+ kici run remote --pick
1760
+
1761
+ # Narrow runsOnAll jobs to a subset of the host roster
1762
+ kici run remote deploy --target role:web
1763
+
1764
+ # AND-combine repeated --target values (hosts must match every selector)
1765
+ kici run remote deploy --target role:web --target dc:eu
1766
+
1767
+ # Skip a runsOnAll job instead of failing it when the target matches no host
1768
+ kici run remote deploy --target role:gpu --target-allow-empty
1769
+ ```
1770
+
1771
+ **Interactive fixture selection (`--pick` / `-p`):**
1772
+
1773
+ Pass `--pick` (or `-p`) to open an interactive checkbox menu of the available
1774
+ fixtures. Toggle one or more with space, confirm with enter, and the selected
1775
+ fixtures run through the normal remote pipeline (honoring `--parallel`,
1776
+ `--no-wait`, and the other run flags). Notes:
1777
+
1778
+ - `--pick` is mutually exclusive with a fixture argument, `--all`, and
1779
+ `--workflow`. Passing any together exits with code 2.
1780
+ - When `stdin` is not a TTY, `--pick` prints the available fixtures and exits
1781
+ without running anything — pass a fixture name (or `--all`) in scripts.
1782
+
1783
+ #### Host narrowing with `--target`
1784
+
1785
+ `--target <selector>` is a runtime narrowing for `runsOnAll` jobs, analogous to
1786
+ Ansible's `--limit`. A `runsOnAll` job normally fans out to **every** roster host
1787
+ matching its predicate, one pinned execution per host. `--target` intersects that
1788
+ matched roster with a label selector, so the effective host set is
1789
+ `runsOnAll ∩ target`:
1790
+
1791
+ - **Narrow-only.** `--target` can only _remove_ hosts from the matched set, never
1792
+ add them. The widening dimension (OR across host groups) lives in the workflow's
1793
+ `runsOnAll`; `--target` only subtracts.
1794
+ - **Run-global, `runsOnAll`-only.** A single `--target` applies to every
1795
+ `runsOnAll` job in the run. Jobs pinned to a single host with `runsOn` are
1796
+ untouched.
1797
+ - **Repeatable and AND-combined.** Each `--target` value is its own selector; a
1798
+ host must satisfy **all** of them to survive the narrowing. Use a single value
1799
+ for an OR-style match within one selector and repeated values for AND.
1800
+ - **Selector syntax** matches `runsOn`: an exact label (`role:web`), a glob
1801
+ (`role:*`), or a regex (`/^box-0[1-3]$/`).
1802
+
1803
+ When `--target` narrows a `runsOnAll` job to zero hosts, the default is to **fail**
1804
+ the run (fail-loud — a typo in the selector shouldn't silently skip work). Pass
1805
+ `--target-allow-empty` to **skip** the zeroed job instead; the job records a
1806
+ `skipped` status, and any downstream job that needs it with `when: 'on-skip'` (or
1807
+ `when: 'always'`) still runs. See [Job dependencies](https://docs.kici.dev/user/sdk/core/#job-dependencies-needs)
1808
+ for the `when` gating model.
1809
+
1810
+ **Exit codes:**
1811
+
1812
+ | Code | Meaning |
1813
+ | ---- | ---------------------------- |
1814
+ | 0 | All matched workflows passed |
1815
+ | 1 | One or more workflows failed |
1816
+
1817
+ #### How the run is routed
1818
+
1819
+ A remote run is dispatched to your **active organization** — the one set with `kici org use <org>`, or overridden per-run with `--org <id>`. The org is resolved in this order:
1820
+
1821
+ 1. The `--org <id>` flag, if provided.
1822
+ 2. Otherwise the active org saved in your global config by `kici org use <org>`.
1823
+ 3. If neither is set, the command errors and asks you to select an org with `kici org use` or pass `--org`.
1824
+
1825
+ The orchestrator anchors the org without any manual webhook source: it auto-provisions a system-managed **remote source** (routing key `remote:<orgId>`) that maps to its bound organization, so even a zero-source org is immediately routable for remote runs. You never set a routing key for a remote run — selecting the org is enough.
1826
+
1827
+ When an org has more than one connected orchestrator cluster, the CLI picks the target cluster in this order:
1828
+
1829
+ 1. The `--orchestrator <name>` flag, if provided.
1830
+ 2. Otherwise the per-org default cluster, set with `kici orchestrators use <name>`.
1831
+ 3. If the org has exactly **one** connected orchestrator, it is auto-selected.
1832
+ 4. Otherwise the run errors with the list of connected clusters, and you pass `--orchestrator <name>` to choose one. Run `kici orchestrators list` to see the available cluster names.
1833
+
1834
+ #### The two planes
1835
+
1836
+ `kici run remote` uses two independent paths:
1837
+
1838
+ - **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.
1839
+ - **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/).
1840
+
1841
+ 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/runs-and-approvals/#kici-run-event---local).
1842
+
1843
+ #### Fresh repos (no GitHub remote)
1844
+
1845
+ `kici run remote` works even if the repo has never been pushed to GitHub. When no remote is detected:
1846
+
1847
+ - The entire repo content is uploaded (not just a diff overlay)
1848
+ - The lock file is sent inline (no GitHub API fetch)
1849
+ - Steps that use git commands will fail (no `.git` directory in the remote workspace)
1850
+ - Build cache (`__build__` jobs) is skipped for local repos
1851
+ - Environments must have `allowLocalExecution: true` to be accessible from local runs (default is `false`)
1852
+
1853
+ Destination routing is unchanged for fresh repos: the run still goes to your active org through the Platform.
1854
+
1855
+ For a detailed guide on writing fixtures, configuring secrets, and understanding the upload flow, see [Testing guide](https://docs.kici.dev/user/testing-guide/).
1856
+
1857
+ #### kici orchestrators
1858
+
1859
+ List the orchestrator clusters connected to an organization, and set the per-org default cluster used by `kici run remote`. Requires `kici login` and an active org (or pass `--org`).
1860
+
1861
+ ```bash
1862
+ kici orchestrators list [--org <id>]
1863
+ kici orchestrators use <clusterName> [--org <id>]
1864
+ ```
1865
+
1866
+ **`kici orchestrators list`** prints the org's connected orchestrator clusters, so you know what to pass to `--orchestrator` (or to `kici orchestrators use`).
1867
+
1868
+ **`kici orchestrators use <clusterName>`** sets the default orchestrator cluster for the org, stored per-org in your global config. Subsequent `kici run remote` invocations target that cluster unless overridden with `--orchestrator`.
1869
+
1870
+ **Examples:**
1871
+
1872
+ ```bash
1873
+ # List the active org's connected clusters
1874
+ kici orchestrators list
1875
+
1876
+ # List a specific org's clusters
1877
+ kici orchestrators list --org xyz789ghi012
1878
+
1879
+ # Set the default cluster for the active org
1880
+ kici orchestrators use us-east
1881
+
1882
+ # Set the default cluster for a specific org
1883
+ kici orchestrators use us-east --org xyz789ghi012
1884
+ ```
1885
+
1886
+ ### kici runs
1887
+
1888
+ Inspect and manage execution runs from the terminal — the equivalent of the
1889
+ dashboard Runs page. All `kici runs` subcommands read/write the same org-scoped
1890
+ data as the dashboard, so they require `kici login` and an active org
1891
+ (`kici org use <name>`).
1892
+
1893
+ #### kici runs list
1894
+
1895
+ List runs with optional filters. Output is a table (run id, workflow, status,
1896
+ branch, trigger, started, duration); pagination is reported at the bottom.
1897
+
1898
+ When no runs match, `kici runs list` checks whether any webhooks arrived
1899
+ recently. If deliveries came in but nothing produced a run, it prints a
1900
+ one-line summary ("3 webhooks received in the last hour, 0 matched") and
1901
+ suggests `kici preview push` to test your triggers locally — the fast way to
1902
+ find a misconfigured trigger. When nothing arrived it prints "No runs found."
1903
+ as before.
1904
+
1905
+ ```bash
1906
+ kici runs list [options]
1907
+ ```
1908
+
1909
+ ```bash
1910
+ kici runs list
1911
+ kici runs list --status running
1912
+ kici runs list --workflow ci --branch main
1913
+ kici runs list --json | jq '.runs[].runId'
1914
+ ```
1915
+
1916
+ #### kici runs show
1917
+
1918
+ Show a run's summary header plus its jobs-and-steps tree (name, status,
1919
+ duration, exit code). A run that never started a step also prints why: the
1920
+ run-level failure, and per job the reason it did not run — a job a
1921
+ [context](https://docs.kici.dev/user/contexts/#protection-rules) rejected names the context and the
1922
+ rule. Any approval hold on the run is listed too, with its context, hold type,
1923
+ status and reason. If the run id is not on the Platform but exists in your
1924
+ local run history (from `kici run <event> --local`), the local record is shown instead.
1925
+
1926
+ ```bash
1927
+ kici runs show <run-id> [options]
1928
+ ```
1929
+
1930
+ ```bash
1931
+ kici runs show abc123
1932
+ kici runs show abc123 --json
1933
+ ```
1934
+
1935
+ #### kici runs logs
1936
+
1937
+ Print each job/step's log lines in order, with headers.
1938
+
1939
+ ```bash
1940
+ kici runs logs <run-id> [options]
1941
+ ```
1942
+
1943
+ ```bash
1944
+ kici runs logs abc123
1945
+ kici runs logs abc123 --job build
1946
+ kici runs logs abc123 --follow
1947
+ ```
1948
+
1949
+ #### kici runs rerun
1950
+
1951
+ Re-trigger a completed run. Prints the new run id. The server enforces a short
1952
+ cooldown between reruns of the same run.
1953
+
1954
+ ```bash
1955
+ kici runs rerun <run-id> [options]
1956
+ ```
1957
+
1958
+ ```bash
1959
+ kici runs rerun abc123
1960
+ ```
1961
+
1962
+ #### kici runs cancel
1963
+
1964
+ Cancel a single run, or all in-progress runs on a branch.
1965
+
1966
+ ```bash
1967
+ kici runs cancel [run-id] [options]
1968
+ ```
1969
+
1970
+ ```bash
1971
+ kici runs cancel abc123
1972
+ kici runs cancel abc123 --force
1973
+ kici runs cancel --branch feature/wip
1974
+ ```
1975
+
1976
+ #### kici runs artifacts list
1977
+
1978
+ List the [artifacts](https://docs.kici.dev/user/sdk/artifacts/) a run uploaded — name, producing job,
1979
+ size, content hash, and creation time. An artifact whose stored object can no
1980
+ longer be reached is flagged `unavailable`.
1981
+
1982
+ ```bash
1983
+ kici runs artifacts list <run-id> [options]
1984
+ ```
1985
+
1986
+ ```bash
1987
+ kici runs artifacts list abc123
1988
+ kici runs artifacts list abc123 --json
1989
+ ```
1990
+
1991
+ #### kici runs artifacts download
1992
+
1993
+ Download a run's artifacts. Name one to fetch just that artifact; omit the name
1994
+ to download every artifact of the run. Each artifact extracts into its own
1995
+ `<name>/` directory by default.
1996
+
1997
+ ```bash
1998
+ kici runs artifacts download <run-id> [name] [options]
1999
+ ```
2000
+
2001
+ - `--archive` — save the raw `.tar.gz` as `<name>.tar.gz` instead of extracting.
2002
+ - `-o, --output <dir>` — write into `<dir>` instead of the current directory.
2003
+
2004
+ ```bash
2005
+ kici runs artifacts download abc123 bundle
2006
+ kici runs artifacts download abc123 bundle -o ./out
2007
+ kici runs artifacts download abc123 --archive
2008
+ kici runs artifacts download abc123
2009
+ ```
2010
+
2011
+ The download streams directly from object storage over a short-lived signed URL
2012
+ — the artifact bytes never pass through the KiCI Platform — and the content hash
2013
+ is verified end to end, so a corrupted or truncated transfer fails loudly rather
2014
+ than leaving a bad file on disk.
2015
+
2016
+ Artifacts expire after the orchestrator's configured retention. When you name a
2017
+ single artifact whose stored object is already gone, the command fails. When you
2018
+ download the whole run, such an artifact is reported as a warning and skipped so
2019
+ the remaining artifacts still land — the command fails only if every artifact of
2020
+ the run was unreachable. Any other failure (a rejected signed URL, a content-hash
2021
+ mismatch) stops the command immediately rather than continuing with the rest.
2022
+
2023
+ Artifact names are case-sensitive, so a single run can hold both `bundle` and
2024
+ `Bundle`. On a filesystem that ignores case in path lookups — macOS and Windows
2025
+ default to this, Linux does not — both would land on the same path, so
2026
+ downloading the whole run refuses before writing anything and names the pair.
2027
+ Fetch them one at a time into separate directories instead:
2028
+
2029
+ ```bash
2030
+ kici runs artifacts download abc123 bundle -o ./bundle-lower
2031
+ kici runs artifacts download abc123 Bundle -o ./bundle-upper
2032
+ ```
2033
+
2034
+ Naming a single artifact is never affected, and on a case-sensitive filesystem
2035
+ downloading the whole run still writes both.
2036
+
2037
+ Artifacts are packed relative to two roots: paths inside your repository and
2038
+ paths under the home directory. Repository-relative files land directly under
2039
+ `<name>/`; home-relative files land under `<name>/~home/`, so the two can never
2040
+ overwrite each other and nothing is ever written outside the output directory.
2041
+
2042
+ When `--json` is set on any of these commands, `kici` emits only the JSON
2043
+ document on stdout — the `kici v<version>` banner is suppressed — so the output
2044
+ is safe to pipe into `jq` or `JSON.parse`. The same holds for the other
2045
+ `--json` commands (`kici run remote --json`, `kici workflows list --json`) and
2046
+ for `--quiet`.
2047
+
2048
+ ### kici reject
2049
+
2050
+ Reject a held [approval gate](https://docs.kici.dev/user/approvals/). A rejection fails the held element and the run. A reason is required.
2051
+
2052
+ ```bash
2053
+ kici reject <run-id> --reason <text> [options]
2054
+ ```
2055
+
2056
+ **Examples:**
2057
+
2058
+ ```bash
2059
+ # Reject a held job with a reason
2060
+ kici reject abc123 --job deploy-production --reason "Wrong release branch"
2061
+ ```
2062
+
2063
+ ### kici approve
2064
+
2065
+ Approve a held [approval gate](https://docs.kici.dev/user/approvals/) so the run resumes. Identify the held element by run ID, optionally narrowed to a job and step.
2066
+
2067
+ ```bash
2068
+ kici approve <run-id> [options]
2069
+ ```
2070
+
2071
+ **Examples:**
2072
+
2073
+ ```bash
2074
+ # Approve a workflow-level hold
2075
+ kici approve abc123
2076
+
2077
+ # Approve a held job
2078
+ kici approve abc123 --job deploy-production
2079
+
2080
+ # Approve a held step (steps are addressed by index)
2081
+ kici approve abc123 --job migrate-and-deploy --step 1
2082
+ ```
2083
+
2084
+ You must be eligible for at least one unsatisfied clause (a member of a named team, or a named user) and hold the permission that matches the hold's type — `ci_trust:write` for a **security** hold, `contexts:admin` for a **wait-timer** hold, `contexts:write` for every other hold. The server enforces this, so the same rule applies to the dashboard and to an AI agent's tools. The command reports whether the element was released, how many clauses remain, or that it was rejected.
2085
+
2086
+ ## Reference
2087
+
2088
+ <!-- BEGIN GENERATED: kici-runs-and-approvals (do not edit; run the doc generator) -->
2089
+
2090
+ ### `kici approve`
2091
+
2092
+ Approve a held approval gate for a run
2093
+
2094
+ Synopsis: `kici approve <run-id> [options]`
2095
+
2096
+ **Arguments**
2097
+
2098
+ | Argument | Required | Variadic | Description |
2099
+ | -------- | -------- | -------- | ------------------------------------- |
2100
+ | `run-id` | yes | no | Run ID whose approval gate to approve |
2101
+
2102
+ **Options**
2103
+
2104
+ | Option | Default | Description |
2105
+ | -------------------- | ------- | -------------------------------------------------------------------------------------------- |
2106
+ | `--job <name>` | | Approve the hold for a specific job |
2107
+ | `--step <index>` | | Approve a step-scoped hold (requires --job) |
2108
+ | `--hold-type <type>` | | Approve the hold of this type (reviewer, timer, concurrency, security) — a job can carry two |
2109
+ | `--hold <id>` | | Approve one hold by its id, as listed when nothing else separates them |
2110
+
2111
+ ### `kici reject`
2112
+
2113
+ Reject a held approval gate for a run
2114
+
2115
+ Synopsis: `kici reject <run-id> [options]`
2116
+
2117
+ **Arguments**
2118
+
2119
+ | Argument | Required | Variadic | Description |
2120
+ | -------- | -------- | -------- | ------------------------------------ |
2121
+ | `run-id` | yes | no | Run ID whose approval gate to reject |
2122
+
2123
+ **Options**
2124
+
2125
+ | Option | Default | Description |
2126
+ | -------------------- | ------- | ------------------------------------------------------------------------------------------- |
2127
+ | `--job <name>` | | Reject the hold for a specific job |
2128
+ | `--step <index>` | | Reject a step-scoped hold (requires --job) |
2129
+ | `--hold-type <type>` | | Reject the hold of this type (reviewer, timer, concurrency, security) — a job can carry two |
2130
+ | `--hold <id>` | | Reject one hold by its id, as listed when nothing else separates them |
2131
+ | `--reason <text>` | | Reason for the rejection |
2132
+
2133
+ ### `kici run`
2134
+
2135
+ Execute workflows locally or remotely
2136
+
2137
+ Synopsis: `kici run [event] [options]`
2138
+
2139
+ **Arguments**
2140
+
2141
+ | Argument | Required | Variadic | Description |
2142
+ | -------- | -------- | -------- | ------------------------------------------------------ |
2143
+ | `event` | no | no | Event type for a routed local run (e.g. push, pr:open) |
2144
+
2145
+ **Options**
2146
+
2147
+ | Option | Default | Description |
2148
+ | ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
2149
+ | `--local` | `false` | Route the run with this machine as the ephemeral agent |
2150
+ | `--offline` | `false` | Force the throwaway/independent plane (offline) |
2151
+ | `--connected` | `false` | Force the connected/hybrid plane (requires attachment) |
2152
+ | `--in-place` | `false` | Reuse the working tree directly instead of an isolated clone |
2153
+ | `--trusted` | `false` | Route to the trusted fleet agent profile: steps see the ambient host env (minus the agent identity). Alias: --no-sandbox |
2154
+ | `--no-sandbox` | | Alias for --trusted (the bwrap sandbox is already off by default) |
2155
+ | `--env <KEY=VALUE>` | | Per-run secret (repeatable) |
2156
+ | `--payload <path>` | | Dispatch payload JSON { action?, client_payload? } for a routed dispatch run |
2157
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
2158
+ | `--quiet` | `false` | Suppress the banner + streaming output |
2159
+ | `--debug` | `false` | Verbose internals |
2160
+
2161
+ ### `kici run remote`
2162
+
2163
+ Execute fixtures remotely via orchestrator
2164
+
2165
+ Synopsis: `kici run remote [fixture] [options]`
2166
+
2167
+ **Arguments**
2168
+
2169
+ | Argument | Required | Variadic | Description |
2170
+ | --------- | -------- | -------- | ----------------------------------------------------- |
2171
+ | `fixture` | no | no | Fixture name or glob pattern (omit to list available) |
2172
+
2173
+ **Options**
2174
+
2175
+ | Option | Default | Description |
2176
+ | --------------------------- | ------- | ------------------------------------------------------------------------------------------- |
2177
+ | `--workflow <name>` | | Run a specific workflow directly (bypass triggers) |
2178
+ | `--all` | `false` | Run all available fixtures |
2179
+ | `-p, --pick` | `false` | Interactively pick fixtures to run |
2180
+ | `--parallel` | `false` | Run matching fixtures concurrently |
2181
+ | `--no-wait` | | Fire and forget (print runIds, don't stream) |
2182
+ | `--quiet` | `false` | Suppress output except final result |
2183
+ | `--json` | `false` | Output structured JSON result |
2184
+ | `--junit <path>` | | Output JUnit XML result |
2185
+ | `--history` | `false` | Show recent run history |
2186
+ | `--routing-key <key>` | | Override routing key for this run |
2187
+ | `--org <id>` | | Target organization (overrides the active org) |
2188
+ | `--orchestrator <name>` | | Target orchestrator cluster (overrides the per-org default) |
2189
+ | `--debug` | `false` | Verbose internals |
2190
+ | `--kici-dir <path>` | `.kici` | Path to .kici directory |
2191
+ | `--context <ctx.key=value>` | | Inject a namespaced context secret, uploaded encrypted to the orchestrator (repeatable) |
2192
+ | `--env <KEY=VALUE>` | | Provide a per-run secret (repeatable); uploaded encrypted to the orchestrator |
2193
+ | `--check` | `false` | Run in check mode: report drift, change nothing |
2194
+ | `--fail-on-drift` | `false` | In check mode, exit non-zero if any step reports drift |
2195
+ | `--target <selector>` | | Narrow runsOnAll jobs to hosts matching this label selector (repeatable, AND-combined) |
2196
+ | `--target-allow-empty` | `false` | A --target that narrows a runsOnAll job to zero hosts skips it instead of failing |
2197
+ | `--input <KEY=VALUE>` | | Typed workflow-dispatch input (repeatable) |
2198
+ | `--yes, --approve-all` | `false` | Auto-approve every approval gate this run holds on (run-scoped; eligibility still enforced) |
2199
+
2200
+ ### `kici runs`
2201
+
2202
+ Inspect and manage execution runs
2203
+
2204
+ Synopsis: `kici runs`
2205
+
2206
+ ### `kici runs artifacts`
2207
+
2208
+ List and download a run's artifacts
2209
+
2210
+ Synopsis: `kici runs artifacts`
2211
+
2212
+ ### `kici runs artifacts download`
2213
+
2214
+ Download one artifact, or all of them — extracts by default
2215
+
2216
+ Synopsis: `kici runs artifacts download <run-id> [name] [options]`
2217
+
2218
+ **Arguments**
2219
+
2220
+ | Argument | Required | Variadic | Description |
2221
+ | -------- | -------- | -------- | ---------------------------------------------------------- |
2222
+ | `run-id` | yes | no | Run ID whose artifacts to download |
2223
+ | `name` | no | no | Artifact name (omit to download every artifact of the run) |
2224
+
2225
+ **Options**
2226
+
2227
+ | Option | Default | Description |
2228
+ | -------------------- | ------- | --------------------------------------------- |
2229
+ | `--archive` | `false` | Save the raw .tar.gz instead of extracting |
2230
+ | `-o, --output <dir>` | | Output directory (default: current directory) |
2231
+
2232
+ ### `kici runs artifacts list`
2233
+
2234
+ List the artifacts a run uploaded
2235
+
2236
+ Synopsis: `kici runs artifacts list <run-id> [options]`
2237
+
2238
+ **Arguments**
2239
+
2240
+ | Argument | Required | Variadic | Description |
2241
+ | -------- | -------- | -------- | ------------------------------ |
2242
+ | `run-id` | yes | no | Run ID whose artifacts to list |
2243
+
2244
+ **Options**
2245
+
2246
+ | Option | Default | Description |
2247
+ | -------- | ------- | --------------- |
2248
+ | `--json` | `false` | Output raw JSON |
2249
+
2250
+ ### `kici runs cancel`
2251
+
2252
+ Cancel a run, or all in-progress runs on a branch
2253
+
2254
+ Synopsis: `kici runs cancel [run-id] [options]`
2255
+
2256
+ **Arguments**
2257
+
2258
+ | Argument | Required | Variadic | Description |
2259
+ | -------- | -------- | -------- | ---------------- |
2260
+ | `run-id` | no | no | Run ID to cancel |
2261
+
2262
+ **Options**
2263
+
2264
+ | Option | Default | Description |
2265
+ | ----------------- | ------- | ------------------------------------------- |
2266
+ | `--force` | `false` | Force cancel (kill immediately, skip hooks) |
2267
+ | `--branch <name>` | | Cancel all in-progress runs on this branch |
2268
+
2269
+ ### `kici runs list`
2270
+
2271
+ List execution runs (mirrors the dashboard Runs page)
2272
+
2273
+ Synopsis: `kici runs list [options]`
2274
+
2275
+ **Options**
2276
+
2277
+ | Option | Default | Description |
2278
+ | ----------------------- | ------- | --------------------------------------------------------- |
2279
+ | `--status <s>` | | Filter by status |
2280
+ | `--workflow <w>` | | Filter by workflow name |
2281
+ | `--branch <b>` | | Filter by branch/ref |
2282
+ | `--repo <r>` | | Filter by repository |
2283
+ | `--trigger <t>` | | Filter by trigger type |
2284
+ | `--source <routingKey>` | | Filter by source routing key |
2285
+ | `--since <ts>` | | Only runs since (ISO-8601 or epoch ms) |
2286
+ | `--cursor <cursor>` | | Keyset cursor for the next page (from a prior nextCursor) |
2287
+ | `--json` | `false` | Output raw JSON |
2288
+
2289
+ ### `kici runs logs`
2290
+
2291
+ Print step logs for a run
2292
+
2293
+ Synopsis: `kici runs logs <run-id> [options]`
2294
+
2295
+ **Arguments**
2296
+
2297
+ | Argument | Required | Variadic | Description |
2298
+ | -------- | -------- | -------- | ----------- |
2299
+ | `run-id` | yes | no | Run ID |
2300
+
2301
+ **Options**
2302
+
2303
+ | Option | Default | Description |
2304
+ | -------------- | ------- | ------------------------ |
2305
+ | `--job <name>` | | Only logs for this job |
2306
+ | `-f, --follow` | `false` | Tail logs for a live run |
2307
+ | `--json` | `false` | Output raw JSON |
2308
+
2309
+ ### `kici runs rerun`
2310
+
2311
+ Re-trigger a run
2312
+
2313
+ Synopsis: `kici runs rerun <run-id> [options]`
2314
+
2315
+ **Arguments**
2316
+
2317
+ | Argument | Required | Variadic | Description |
2318
+ | -------- | -------- | -------- | --------------- |
2319
+ | `run-id` | yes | no | Run ID to rerun |
2320
+
2321
+ **Options**
2322
+
2323
+ | Option | Default | Description |
2324
+ | -------- | ------- | --------------- |
2325
+ | `--json` | `false` | Output raw JSON |
2326
+
2327
+ ### `kici runs show`
2328
+
2329
+ Show a run summary with its jobs and steps, why a job did not run, and any approval hold
2330
+
2331
+ Synopsis: `kici runs show <run-id> [options]`
2332
+
2333
+ **Arguments**
2334
+
2335
+ | Argument | Required | Variadic | Description |
2336
+ | -------- | -------- | -------- | ----------------- |
2337
+ | `run-id` | yes | no | Run ID to inspect |
2338
+
2339
+ **Options**
2340
+
2341
+ | Option | Default | Description |
2342
+ | -------- | ------- | --------------- |
2343
+ | `--json` | `false` | Output raw JSON |
2344
+
2345
+ <!-- END GENERATED: kici-runs-and-approvals -->
2346
+
2347
+ ---