@kivacore/cli 0.0.0-stage → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +601 -2
  2. package/agent-loader.js +59762 -0
  3. package/agent-loader.js.map +7 -0
  4. package/docs/API.md +1500 -0
  5. package/docs/project-plan-goal-api.md +704 -0
  6. package/docs/project-plan-goal-openapi.yaml +979 -0
  7. package/docs/server-api.md +618 -0
  8. package/main.js +122785 -0
  9. package/main.js.map +7 -0
  10. package/package.json +59 -4
  11. package/pnpm-workspace.yaml +28 -0
  12. package/resources/browser-tools/browser-click.js +85 -0
  13. package/resources/browser-tools/browser-client.js +249 -0
  14. package/resources/browser-tools/browser-close.js +21 -0
  15. package/resources/browser-tools/browser-console.js +75 -0
  16. package/resources/browser-tools/browser-content.js +70 -0
  17. package/resources/browser-tools/browser-cookies.js +27 -0
  18. package/resources/browser-tools/browser-daemon.js +506 -0
  19. package/resources/browser-tools/browser-devtools.js +62 -0
  20. package/resources/browser-tools/browser-eval.js +28 -0
  21. package/resources/browser-tools/browser-fill.js +79 -0
  22. package/resources/browser-tools/browser-info.js +14 -0
  23. package/resources/browser-tools/browser-nav.js +58 -0
  24. package/resources/browser-tools/browser-network.js +93 -0
  25. package/resources/browser-tools/browser-preview.js +131 -0
  26. package/resources/browser-tools/browser-run-script.js +62 -0
  27. package/resources/browser-tools/browser-screenshot.js +28 -0
  28. package/resources/browser-tools/browser-select.js +66 -0
  29. package/resources/browser-tools/browser-snapshot.js +100 -0
  30. package/resources/browser-tools/browser-start.js +178 -0
  31. package/resources/browser-tools/browser-tabs.js +41 -0
  32. package/resources/browser-tools/browser-url.js +30 -0
  33. package/resources/browser-tools/browser-wait.js +54 -0
  34. package/resources/officecli/manifest.json +3 -0
  35. package/resources/pi-agent/assets/kiva-logo.svg +16 -0
  36. package/resources/pi-agent/commands/create-release.md +38 -0
  37. package/resources/pi-agent/extensions/answer.ts +543 -0
  38. package/resources/pi-agent/extensions/architect.ts +762 -0
  39. package/resources/pi-agent/extensions/browser-tools.ts +229 -0
  40. package/resources/pi-agent/extensions/context.ts +523 -0
  41. package/resources/pi-agent/extensions/control.ts +1788 -0
  42. package/resources/pi-agent/extensions/diff.ts +218 -0
  43. package/resources/pi-agent/extensions/files.ts +199 -0
  44. package/resources/pi-agent/extensions/goal.ts +759 -0
  45. package/resources/pi-agent/extensions/image-analysis.ts +478 -0
  46. package/resources/pi-agent/extensions/kiva-auth-tool.ts +322 -0
  47. package/resources/pi-agent/extensions/knowledge.ts +530 -0
  48. package/resources/pi-agent/extensions/loop.ts +463 -0
  49. package/resources/pi-agent/extensions/notify.ts +90 -0
  50. package/resources/pi-agent/extensions/pi-bash-live-view/LICENSE +21 -0
  51. package/resources/pi-agent/extensions/pi-bash-live-view/README.md +19 -0
  52. package/resources/pi-agent/extensions/pi-bash-live-view/index.ts +52 -0
  53. package/resources/pi-agent/extensions/pi-bash-live-view/package.json +61 -0
  54. package/resources/pi-agent/extensions/pi-bash-live-view/pty-execute.ts +97 -0
  55. package/resources/pi-agent/extensions/pi-bash-live-view/pty-kill.ts +25 -0
  56. package/resources/pi-agent/extensions/pi-bash-live-view/pty-session.ts +143 -0
  57. package/resources/pi-agent/extensions/pi-bash-live-view/spawn-helper.ts +37 -0
  58. package/resources/pi-agent/extensions/pi-bash-live-view/terminal-emulator.ts +476 -0
  59. package/resources/pi-agent/extensions/pi-bash-live-view/truncate.ts +68 -0
  60. package/resources/pi-agent/extensions/pi-bash-live-view/widget.ts +99 -0
  61. package/resources/pi-agent/extensions/pi-fff/README.md +152 -0
  62. package/resources/pi-agent/extensions/pi-fff/VENDORED_FROM.md +7 -0
  63. package/resources/pi-agent/extensions/pi-fff/package.json +53 -0
  64. package/resources/pi-agent/extensions/pi-fff/src/index.ts +820 -0
  65. package/resources/pi-agent/extensions/pi-mcp-adapter/CHANGELOG.md +192 -0
  66. package/resources/pi-agent/extensions/pi-mcp-adapter/LICENSE +21 -0
  67. package/resources/pi-agent/extensions/pi-mcp-adapter/README.md +296 -0
  68. package/resources/pi-agent/extensions/pi-mcp-adapter/app-bridge.bundle.js +67 -0
  69. package/resources/pi-agent/extensions/pi-mcp-adapter/cli.js +108 -0
  70. package/resources/pi-agent/extensions/pi-mcp-adapter/commands.ts +211 -0
  71. package/resources/pi-agent/extensions/pi-mcp-adapter/config.ts +227 -0
  72. package/resources/pi-agent/extensions/pi-mcp-adapter/consent-manager.ts +64 -0
  73. package/resources/pi-agent/extensions/pi-mcp-adapter/direct-tools.ts +301 -0
  74. package/resources/pi-agent/extensions/pi-mcp-adapter/errors.ts +219 -0
  75. package/resources/pi-agent/extensions/pi-mcp-adapter/glimpse-ui.ts +80 -0
  76. package/resources/pi-agent/extensions/pi-mcp-adapter/host-html-template.ts +427 -0
  77. package/resources/pi-agent/extensions/pi-mcp-adapter/index.ts +235 -0
  78. package/resources/pi-agent/extensions/pi-mcp-adapter/init.ts +324 -0
  79. package/resources/pi-agent/extensions/pi-mcp-adapter/lifecycle.ts +93 -0
  80. package/resources/pi-agent/extensions/pi-mcp-adapter/logger.ts +169 -0
  81. package/resources/pi-agent/extensions/pi-mcp-adapter/mcp-panel.ts +713 -0
  82. package/resources/pi-agent/extensions/pi-mcp-adapter/metadata-cache.ts +191 -0
  83. package/resources/pi-agent/extensions/pi-mcp-adapter/npx-resolver.ts +419 -0
  84. package/resources/pi-agent/extensions/pi-mcp-adapter/oauth-handler.ts +56 -0
  85. package/resources/pi-agent/extensions/pi-mcp-adapter/package.json +85 -0
  86. package/resources/pi-agent/extensions/pi-mcp-adapter/paths.ts +29 -0
  87. package/resources/pi-agent/extensions/pi-mcp-adapter/proxy-modes.ts +635 -0
  88. package/resources/pi-agent/extensions/pi-mcp-adapter/resource-tools.ts +17 -0
  89. package/resources/pi-agent/extensions/pi-mcp-adapter/server-manager.ts +330 -0
  90. package/resources/pi-agent/extensions/pi-mcp-adapter/state.ts +41 -0
  91. package/resources/pi-agent/extensions/pi-mcp-adapter/tool-metadata.ts +144 -0
  92. package/resources/pi-agent/extensions/pi-mcp-adapter/tool-registrar.ts +46 -0
  93. package/resources/pi-agent/extensions/pi-mcp-adapter/types.ts +367 -0
  94. package/resources/pi-agent/extensions/pi-mcp-adapter/ui-resource-handler.ts +145 -0
  95. package/resources/pi-agent/extensions/pi-mcp-adapter/ui-server.ts +623 -0
  96. package/resources/pi-agent/extensions/pi-mcp-adapter/ui-session.ts +384 -0
  97. package/resources/pi-agent/extensions/pi-mcp-adapter/ui-stream-types.ts +89 -0
  98. package/resources/pi-agent/extensions/pi-mcp-adapter/utils.ts +75 -0
  99. package/resources/pi-agent/extensions/plan.ts +1471 -0
  100. package/resources/pi-agent/extensions/prompt-editor.ts +1340 -0
  101. package/resources/pi-agent/extensions/prompt-url-widget.ts +175 -0
  102. package/resources/pi-agent/extensions/redraws.ts +24 -0
  103. package/resources/pi-agent/extensions/review.ts +2167 -0
  104. package/resources/pi-agent/extensions/server-auto-commit.ts +251 -0
  105. package/resources/pi-agent/extensions/soul.ts +183 -0
  106. package/resources/pi-agent/extensions/tasks.ts +300 -0
  107. package/resources/pi-agent/extensions/todos.ts +2176 -0
  108. package/resources/pi-agent/extensions/tps.ts +47 -0
  109. package/resources/pi-agent/extensions/whimsical.ts +474 -0
  110. package/resources/pi-agent/prompts/agent-system.md +57 -0
  111. package/resources/pi-agent/prompts/coder-system.md +164 -0
  112. package/resources/pi-agent/shared/askUserProtocol.ts +248 -0
  113. package/resources/pi-agent/shared/autoCommitMessage.ts +241 -0
  114. package/resources/pi-agent/shared/extensionLifecycle.ts +11 -0
  115. package/resources/pi-agent/shared/projectPlanGoal.ts +673 -0
  116. package/resources/pi-agent/skills/grill-me/SKILL.md +7 -0
  117. package/resources/pi-agent/skills/grill-me/agents/openai.yaml +5 -0
  118. package/resources/pi-agent/skills/grilling/SKILL.md +30 -0
  119. package/resources/pi-agent/skills/grilling/agents/openai.yaml +3 -0
  120. package/resources/pi-agent/skills/officecli/SKILL.md +417 -0
  121. package/resources/pi-agent/souls/boomer-parent.md +23 -0
  122. package/resources/pi-agent/souls/bro.md +22 -0
  123. package/resources/pi-agent/souls/catalog.ts +79 -0
  124. package/resources/pi-agent/souls/caveman.md +21 -0
  125. package/resources/pi-agent/souls/linkedin-influencer.md +60 -0
  126. package/resources/pi-agent/souls/master-yoda.md +22 -0
  127. package/resources/pi-agent/souls/noir-detective.md +24 -0
  128. package/resources/pi-agent/souls/nonsense-engineer.md +23 -0
  129. package/resources/pi-agent/souls/pirate.md +24 -0
  130. package/resources/pi-agent/souls/shakespeare.md +24 -0
  131. package/server-loader.js +90643 -0
  132. package/server-loader.js.map +7 -0
  133. package/tui-runtime.json +7 -0
  134. package/tui.mjs +1889 -0
  135. package/tui.mjs.map +7 -0
package/README.md CHANGED
@@ -1,3 +1,602 @@
1
- # Temporary Holding Version
1
+ # @kivacore/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ KIVA API CLI.
4
+
5
+ CLI state files are stored under the active `.kiva/` scope.
6
+
7
+ - Local default: `./.kiva/`
8
+ - Global override: `~/.kiva/` via `-g` / `--global`
9
+
10
+ Tenant OpenAPI files are stored under `<settings-root>/tenans/<tenantId>/openapi.json`.
11
+ Pi agent state for `kiva work` and `kiva code` is stored under `<settings-root>/pi/`.
12
+ Knowledge-graph caches and vector indexes are stored under `<settings-root>/knowledge/<workspace-hash>/`.
13
+ Tracked repo knowledge lives in `kiva/knowledge/`.
14
+ `kiva tui` requires [Bun](https://bun.sh) installed locally. Its first launch downloads the terminal UI runtime into `~/.kiva/tui-runtime`.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install -g @kivacore/cli
20
+ ```
21
+
22
+ or
23
+
24
+ ```bash
25
+ pnpm add -g @kivacore/cli
26
+ ```
27
+
28
+ ## Updating
29
+
30
+ ```bash
31
+ kiva update # install the latest published version
32
+ kiva update --check # only report whether a newer version exists
33
+ ```
34
+
35
+ In a terminal, an outdated `kiva` asks to update before running a command and
36
+ does not continue until it is up to date. Agents, scripts and CI only get a
37
+ one-line notice on stderr. Set `KIVA_SKIP_UPDATE_CHECK=1` to skip the check.
38
+
39
+ ## AI provider for `kiva work` and `kiva code`
40
+
41
+ Once you are logged in (`kiva auth login`), both agents run on the Kiva AI
42
+ Gateway out of the box: no AI provider account or API key is needed. If you
43
+ have already set up your own provider it keeps working, and you can switch
44
+ between it and the gateway with the model picker. A Z.AI key of your own is
45
+ always used as-is instead of the gateway.
46
+
47
+ ## Agent skills
48
+
49
+ The Kiva skills for coding agents live in
50
+ [`kivacore/agent-skills`](https://github.com/Kivacore/agent-skills) and are
51
+ installed per folder. `kiva work`, `kiva code`, `kiva server`, `kiva tui`,
52
+ `kiva apps clone` and `kiva apps create --local-development` offer to install
53
+ them when the folder has none, and to update them when they are out of date.
54
+
55
+ ```bash
56
+ kiva agent-skills status # installed? current?
57
+ kiva agent-skills install # install into this folder
58
+ kiva agent-skills update # bring them to the latest version
59
+ ```
60
+
61
+ ## Authentication
62
+
63
+ Login with explicit client ID:
64
+
65
+ ```bash
66
+ kiva auth login --clientId "<your-client-id>"
67
+ ```
68
+
69
+ After a successful login, the client ID is saved in `~/.kiva/config.json` and reused by default.
70
+
71
+ Logout active account:
72
+
73
+ ```bash
74
+ kiva auth logout
75
+ ```
76
+
77
+ Work with accounts and tenants:
78
+
79
+ ```bash
80
+ kiva auth accounts list --json
81
+ kiva auth accounts use --userId "<user-id>" --json
82
+ kiva auth tenants list --userId "<user-id>" --json
83
+ kiva auth tenants use "<tenant-id-uuid-or-tenant-no>" --userId "<user-id>" --json
84
+ ```
85
+
86
+ ## Environments
87
+
88
+ The CLI ships with four built-in environments — `live`, `beta`, `alpha`, and `dev`
89
+ (aliases: `prod` → `live`, `local-development` → `dev`). Switch between them with
90
+ `kiva env use <id|name>`.
91
+
92
+ You can also register your own environments to target **self-hosted / on-premise**
93
+ Kiva deployments:
94
+
95
+ ```bash
96
+ kiva env list # built-ins + custom (builtIn flag)
97
+ kiva env add acme --url https://kiva.acme.internal --name "Acme"
98
+ kiva env use acme
99
+ kiva env update acme --url https://new.acme.internal # change url and/or --name
100
+ kiva env remove acme # if active, falls back to live
101
+ ```
102
+
103
+ Notes:
104
+
105
+ - The four built-ins are read-only — you can't add over, update, or remove them.
106
+ - Custom environments are saved in the active settings scope. For a machine-wide
107
+ environment, add it globally so every project sees it:
108
+
109
+ ```bash
110
+ kiva -g env add acme --url https://kiva.acme.internal
111
+ ```
112
+
113
+ - If your on-premise server uses a self-signed or internal-CA certificate, trust the
114
+ CA the standard Node way — no insecure flag is needed:
115
+
116
+ ```bash
117
+ NODE_EXTRA_CA_CERTS=/path/to/internal-ca.pem kiva env use acme
118
+ ```
119
+
120
+ ## Help
121
+
122
+ ```bash
123
+ kiva # active environment + command overview
124
+ kiva --help
125
+
126
+ # Environment, auth, and account
127
+ kiva env --help
128
+ kiva auth --help
129
+ kiva account --help
130
+
131
+ # AI agents
132
+ kiva work --help # Work Agent (interactive pi assistant)
133
+ kiva code --help # Coding Agent
134
+
135
+ # Data, schema, and query
136
+ kiva ds --help
137
+ kiva dsql --help
138
+ kiva studio --help
139
+ kiva discover --help
140
+
141
+ # Apps, automations, and custom agents
142
+ kiva apps --help
143
+ kiva automation --help
144
+ kiva agent --help # custom-agent CRUD for an app
145
+ kiva acl --help
146
+ kiva messaging --help
147
+
148
+ # Integrations, knowledge, and releases
149
+ kiva connect --help
150
+ kiva knowledge --help
151
+ kiva project-plan --help
152
+ kiva release --help
153
+
154
+ # Tools and runtime
155
+ kiva browser --help
156
+ kiva server --help
157
+ kiva tui --help
158
+ kiva curl --help
159
+ ```
160
+
161
+ ## Browser Automation
162
+
163
+ Browser automation via a persistent daemon that holds a raw CDP (Chrome DevTools Protocol) WebSocket connection. Works in both local mode (Chrome on `:9222`) and remote sandbox mode (Cloudflare Browser Rendering).
164
+
165
+ The daemon starts automatically on the first command and stays alive for 5 minutes of idle time. All commands share the same browser connection.
166
+
167
+ ```bash
168
+ # Session
169
+ kiva browser start # Start Chrome + daemon
170
+ kiva browser start --profile # Start with user's Chrome profile
171
+ kiva browser close # Stop daemon
172
+
173
+ # Navigation
174
+ kiva browser nav <url> # Navigate active tab
175
+ kiva browser nav <url> --new # Open in new tab
176
+
177
+ # Waiting
178
+ kiva browser wait --idle # Wait for network idle
179
+ kiva browser wait --selector "h1" # Wait for element to appear
180
+ kiva browser wait --url "**/dashboard" # Wait for URL pattern
181
+ kiva browser wait 2000 # Fixed delay
182
+
183
+ # Page snapshot and interaction
184
+ kiva browser snapshot # Interactive elements with refs (@e1, @e2, ...)
185
+ kiva browser snapshot --all # Include non-interactive elements
186
+ kiva browser click @e3 # Click by ref
187
+ kiva browser click 350 200 # Coordinate click (compositor-level)
188
+ kiva browser fill @e1 "value" # Clear + type into input
189
+ kiva browser select @e4 "Option" # Select dropdown option
190
+
191
+ # Inspection
192
+ kiva browser eval 'document.title' # Evaluate JavaScript
193
+ kiva browser screenshot # Viewport screenshot
194
+ kiva browser screenshot --full --base64 # Full page as base64
195
+ kiva browser info # URL, title, viewport, scroll
196
+ kiva browser console --level error # Console messages
197
+ kiva browser network --method POST # Network requests
198
+ kiva browser cookies --name "session" # Cookies
199
+ kiva browser content <url> # Extract readable markdown
200
+ kiva browser tabs # List/switch tabs
201
+
202
+ # CDP scripts
203
+ kiva browser run-script script.js # Run custom CDP script
204
+ ```
205
+
206
+ ## Knowledge Graph
207
+
208
+ Initialize and use the repo knowledge graph:
209
+
210
+ ```bash
211
+ kiva knowledge init
212
+ kiva knowledge generate-initial
213
+ kiva knowledge refresh
214
+ kiva knowledge locate "Working Agreement" --json
215
+ kiva knowledge section "knowledge#Working Agreement" --json
216
+ kiva knowledge refs "knowledge#Working Agreement" --json
217
+ kiva knowledge search "how should agents use this repo?" --json
218
+ kiva knowledge expand "Read [[Working Agreement]] before editing" --json
219
+ kiva knowledge check --json
220
+ kiva knowledge config --json
221
+ ```
222
+
223
+ ## Project Plan
224
+
225
+ The project plan is a repo-tracked work graph stored at `kiva/project-plan/project-plan.json`. It organizes work into phases, features, and tasks. A derived `PROJECT_PLAN.md` is always kept in sync. Features are also synced into the knowledge base features document when it exists.
226
+
227
+ Manage phases, features, and tasks:
228
+
229
+ ```bash
230
+ kiva project-plan show --json
231
+ kiva project-plan check --json
232
+ kiva project-plan ensure --json
233
+ kiva project-plan summary --json
234
+ kiva project-plan config --json
235
+
236
+ # Token-efficient slices (prefer over `show` for large plans)
237
+ kiva project-plan list-phases --json
238
+ kiva project-plan list-features --json
239
+ kiva project-plan list-tasks --status planned --limit 5 --json
240
+ kiva project-plan list-tasks --status in_progress --json
241
+ kiva project-plan list-tasks --phaseId "<phase-id>" --featureId "<feature-id>" --includeSummary true --json
242
+
243
+ # Phases
244
+ kiva project-plan upsert-phase --title "Core Features" --json
245
+ kiva project-plan upsert-phase --title "Testing" --slug "testing" --summary "Test coverage" --json
246
+
247
+ # Features
248
+ kiva project-plan upsert-feature --phaseId "<phase-id>" --title "Auth Flow" --json
249
+ kiva project-plan upsert-feature --phaseId "<phase-id>" --title "Data Export" --slug "data-export" --summary "CSV and JSON export" --json
250
+
251
+ # Tasks
252
+ kiva project-plan upsert-task --featureId "<feature-id>" --title "Implement OAuth2" --type new-implementation --assignee agent --json
253
+ kiva project-plan upsert-task --featureId "<feature-id>" --title "Fix token refresh" --type bug-fix --assignee agent --status in_progress --json
254
+ kiva project-plan get-task --taskId "<task-id>" --json
255
+ kiva project-plan set-task-status --taskId "<task-id>" --status done --json
256
+ kiva project-plan set-order --phaseId "<phase-id>" --order 1 --json
257
+
258
+ # Linked local subtasks
259
+ kiva project-plan create-linked-todo --taskId "<task-id>" --json
260
+ kiva project-plan create-linked-todo --taskId "<task-id>" --title "Step 1" --body "Details" --json
261
+ ```
262
+
263
+ Task types: `new-implementation`, `bug-fix`, `api-test`, `browser-automation-test`, `work`
264
+ Assignees: `agent`, `user`
265
+ Statuses: `planned`, `in_progress`, `blocked`, `done`
266
+
267
+ ## Release
268
+
269
+ Create versioned releases with changelog generation:
270
+
271
+ ```bash
272
+ kiva release status --json
273
+ kiva release new-version --json
274
+ kiva release new-version --bump major --json
275
+ kiva release new-version --version 2.0.0 --json
276
+ kiva release new-version --dryRun --json
277
+ kiva release new-version --skipChangelog --skipTag --json
278
+ kiva release new-version --skipGithubRelease --json
279
+ ```
280
+
281
+ The `new-version` command bumps the version in `package.json`, generates a categorized changelog from commit history, creates a git tag, and optionally publishes a GitHub release via `gh`.
282
+
283
+ ## Data Sources
284
+
285
+ Query data source items:
286
+
287
+ ```bash
288
+ kiva ds list base task --columns "id,name,status" --limit 10 --orderBy "created_on desc" --json
289
+ ```
290
+
291
+ Create, update, delete data source items:
292
+
293
+ ```bash
294
+ kiva ds create base task --data '{"name":"My Task","status":"open"}' --json
295
+ kiva ds update base task "<record-id>" --data '{"status":"done"}' --json
296
+ kiva ds delete base task "<record-id>" --json
297
+ ```
298
+
299
+ Add comments and file attachments to a record:
300
+
301
+ ```bash
302
+ kiva ds comments create base task "<record-id>" --message "Looks good" --json
303
+ kiva ds files upload base task "<record-id>" --file ./contract.pdf --json
304
+ ```
305
+
306
+ Batch create/update (max 50 items) and file input (`--from-file` supports `.json` and `.csv`):
307
+
308
+ ```bash
309
+ kiva ds create base task --data '[{"name":"Task 1"},{"name":"Task 2"}]' --json
310
+ kiva ds update base task --data '[{"id":"1","status":"done"},{"id":"2","status":"open"}]' --json
311
+ kiva ds create base task --from-file ./tasks.csv --json
312
+ kiva ds update base task --from-file ./tasks-update.json --json
313
+ ```
314
+
315
+ ## DSQL (Logical SQL)
316
+
317
+ Run read-only logical SQL against your data sources, generate queries from natural
318
+ language, inspect schemas, and manage saved custom queries.
319
+
320
+ ```bash
321
+ kiva dsql query "<sql>" --json
322
+ kiva dsql generate "open tasks assigned to me" --json
323
+ kiva dsql ask "how many tasks are open?" --json
324
+ kiva dsql schema app base --json
325
+ kiva dsql schema data-source base task --json
326
+ kiva dsql list-custom-query --appSlug base --json
327
+ kiva dsql create-custom-query --appSlug base --name "Open Tasks" --dsqlQuery "<sql>" --fields '<json>' --json
328
+ kiva dsql run-custom-query --queryId "<id>" --json
329
+ ```
330
+
331
+ ## OpenAPI Discovery
332
+
333
+ Download current tenant OpenAPI spec:
334
+
335
+ ```bash
336
+ kiva discover api --json
337
+ ```
338
+
339
+ Discover from downloaded tenant OpenAPI spec:
340
+
341
+ ```bash
342
+ kiva discover namespaces --json
343
+ kiva discover path /v1/users --json
344
+ kiva discover endpoint /v1/users/me --json
345
+ kiva discover endpoint [PUT]/v1/users/me/photo --json
346
+ kiva discover entity UserEntity --json
347
+ kiva discover search users,UserEntity --json
348
+ ```
349
+
350
+ ## Connectors
351
+
352
+ ```bash
353
+ kiva connect list-connectors --json
354
+ kiva connect get-connector <slug> --json
355
+ kiva connect get-action <slug> <actionKey> --json
356
+ kiva connect list-connections <slug> --json
357
+ kiva connect curl <slug> <endpoint> --json
358
+ kiva connect run-action <appSlug> <actionKey> --json
359
+ ```
360
+
361
+ ## Apps and Studio
362
+
363
+ List and manage apps:
364
+
365
+ ```bash
366
+ kiva apps list --json
367
+ kiva apps delete --appId "<app-id>" --json
368
+ kiva apps restore --appId "<app-id>" --json
369
+ ```
370
+
371
+ Manage dev studio data sources, fields, and enums:
372
+
373
+ ```bash
374
+ kiva studio list-data-sources --appSlug base --expand fields --json
375
+ kiva studio get-data-source --appSlug base --dataSourceSlug task --json
376
+ kiva studio create-data-source --appSlug base --title "Tasks" --name "task" --slug "task" --json
377
+ kiva studio update-data-source --appId "<app-id>" --dataSourceId "<data-source-id>" --data '{"title":"Tasks v2"}' --json
378
+ kiva studio delete-data-source --appId "<app-id>" --dataSourceSlug "task" --json
379
+ kiva studio bulk-create-data-sources --appId "<app-id>" --from-file ./data-sources.json --json
380
+ kiva studio list-fields --appSlug base --dataSourceSlug task --json
381
+ kiva studio get-field --appSlug base --dataSourceSlug task --fieldSlug status --json
382
+ kiva studio create-field --appId "<app-id>" --dataSourceId "<data-source-id>" --name "Status" --slug "status" --type "text" --json
383
+ kiva studio update-field --appId "<app-id>" --dataSourceId "<data-source-id>" --fieldId "<field-id>" --data '{"name":"Stage"}' --json
384
+ kiva studio delete-field --appId "<app-id>" --dataSourceId "<data-source-id>" --fieldSlug "status" --json
385
+ kiva studio create-fields-batch --appId "<app-id>" --dataSourceId "<data-source-id>" --data '[{"name":"Priority","slug":"priority","type":"text"}]' --json
386
+ kiva studio update-fields-batch --appId "<app-id>" --dataSourceId "<data-source-id>" --from-file ./fields-update.json --json
387
+ kiva studio delete-fields-batch --appId "<app-id>" --dataSourceId "<data-source-id>" --data '["field-1","field-2"]' --json
388
+ kiva studio list-enums --appId "<app-id>" --dataSourceId "<data-source-id>" --fieldId "<field-id>" --json
389
+ kiva studio create-enums --appId "<app-id>" --dataSourceId "<data-source-id>" --fieldId "<field-id>" --data '[{"name":"Open","sortOrder":1}]' --json
390
+ kiva studio update-enums --appId "<app-id>" --dataSourceId "<data-source-id>" --fieldId "<field-id>" --from-file ./enums-update.json --json
391
+ kiva studio delete-enums --appId "<app-id>" --dataSourceId "<data-source-id>" --fieldId "<field-id>" --data '["enum-1","enum-2"]' --json
392
+ ```
393
+
394
+ Tenant-wide search across data sources (returns `{ data, meta: { total, limit, offset } }`):
395
+
396
+ ```bash
397
+ # Fields, with multi-value filters and keyword
398
+ kiva studio search-fields --keyword email --json
399
+ kiva studio search-fields --dataSourceId "<id1>,<id2>" --type field-text,field-textarea --limit 50 --json
400
+ kiva studio search-fields --keyword status --offset 100 --limit 50 --json
401
+
402
+ # Enums, joined with data source / field / enum set
403
+ kiva studio search-enums --dataSourceId "<data-source-id>" --json
404
+ kiva studio search-enums --enumSetId "<enum-set-id>" --json
405
+ kiva studio search-enums --fieldId "<field-id>" --limit 200 --json
406
+
407
+ # Enum sets
408
+ kiva studio search-enum-sets --limit 50 --offset 0 --json
409
+ ```
410
+
411
+ ## Automations
412
+
413
+ Manage an app's automations and their triggers (trigger `--type` values are
414
+ kebab-case, e.g. `record-created`, `recurrence`, `webhook`).
415
+
416
+ ```bash
417
+ kiva automation list --appSlug base --json
418
+ kiva automation get --appId "<app-id>" --automationId "<id>" --json
419
+ kiva automation create --appSlug base --from-file ./automation.json --json
420
+ kiva automation create-trigger --appSlug base --automationId "<id>" --type record-created --json
421
+ kiva automation delete-trigger --appSlug base --automationId "<id>" --triggerId "<id>" --json
422
+ ```
423
+
424
+ ## Custom Agents
425
+
426
+ CRUD for an app's custom agents and their sub-resources (models, tools, data sources,
427
+ deployments, and more). Run `kiva agent --help` for the full resource list.
428
+
429
+ ```bash
430
+ kiva agent list --appSlug base --json
431
+ kiva agent create --appSlug base --name "Support Bot" --skillName "support" --json
432
+ kiva agent tools create --appSlug base --agentId "<id>" --toolType "<type>" --json
433
+ kiva agent deployments list --appSlug base --agentId "<id>" --json
434
+ ```
435
+
436
+ ## Access Control
437
+
438
+ Manage tenant roles, role queries, and user hierarchy units.
439
+
440
+ ```bash
441
+ kiva acl roles list --json
442
+ kiva acl roles create --slug "<slug>" --name "<name>" --json
443
+ kiva acl role-queries list --json
444
+ kiva acl hierarchy-units list --json
445
+ kiva acl hierarchy-units create --name "<name>" --json
446
+ ```
447
+
448
+ ## Messaging
449
+
450
+ Inspect tenant email accounts (non-credential info) and send email through them.
451
+
452
+ ```bash
453
+ kiva messaging accounts --json
454
+ kiva messaging email send --accountId "<id>" --json
455
+ ```
456
+
457
+ ## Account
458
+
459
+ Manage tenant brands, your own user profile, and tenant regional preferences.
460
+
461
+ ```bash
462
+ kiva account brands list --json
463
+ kiva account brands create --name "<name>" --json
464
+ kiva account user-profile get --json
465
+ kiva account user-profile update --firstname "<name>" --json
466
+ kiva account tenant-preferences get --json
467
+ kiva account tenant-preferences update --timeZone "<id>" --json
468
+ ```
469
+
470
+ ## Raw API Access
471
+
472
+ ```bash
473
+ kiva curl /users/me -i --json
474
+ kiva curl /dev/apps --json
475
+ ```
476
+
477
+ ## TUI
478
+
479
+ Launch the OpenTUI terminal UI (requires Bun):
480
+
481
+ ```bash
482
+ kiva tui
483
+ ```
484
+
485
+ ## Agent Server
486
+
487
+ Start the agent HTTP server:
488
+
489
+ ```bash
490
+ kiva server
491
+ kiva server --port 4000
492
+ kiva server --profile agent
493
+ kiva server --model anthropic/claude-sonnet-4-20250514 --thinking high
494
+ kiva server --auth "<bearer-token>"
495
+ kiva server --apiKey "<key>" --provider azure
496
+ ```
497
+
498
+ The server exposes REST endpoints for chat, models, knowledge, project-plan, release, files, and dev environment management. It also attaches a WebSocket PTY terminal at `WS /api/terminal` for interactive shell access.
499
+
500
+ For full endpoint documentation see [docs/API.md](docs/API.md).
501
+
502
+ ## Pi Agent and Coding Agent
503
+
504
+ Launch the scoped pi assistant and coding agent:
505
+
506
+ ```bash
507
+ # Interactive TUI
508
+ # First interactive launch opens the KIVA onboarding wizard if no provider is configured yet.
509
+ kiva work
510
+ kiva code
511
+
512
+ # Interactive TUI with an initial prompt
513
+ kiva work "Inspect the active tenant and list apps"
514
+ kiva code "Add a command to list my team dashboards"
515
+
516
+ # One-shot mode
517
+ kiva work --print "Which tenant am I using?"
518
+ kiva code --print --mode json "Summarize the CLI command surface in this repo"
519
+ ```
520
+
521
+ ### Built-in Agent Tools
522
+
523
+ When `kiva/knowledge/` exists, `kiva work`, `kiva code`, and `kiva server` load built-in knowledge tools:
524
+
525
+ - `kiva_knowledge_search`
526
+ - `kiva_knowledge_section`
527
+ - `kiva_knowledge_locate`
528
+ - `kiva_knowledge_refs`
529
+ - `kiva_knowledge_expand`
530
+ - `kiva_knowledge_check`
531
+
532
+ When `kiva/project-plan/project-plan.json` exists, the agents use project-plan CLI commands (`kiva project-plan show`, `set-task-status`, `create-linked-todo`, etc.) to read and update the canonical work graph.
533
+
534
+ The `todo` tool is always available with actions: `list`, `list-all`, `get`, `create`, `update`, `append`, `delete`, `claim`, `release`.
535
+
536
+ ### Slash Commands
537
+
538
+ Inside the interactive agent TUI:
539
+
540
+ ```bash
541
+ /login # browser or API-key provider chooser
542
+ /logout # remove saved provider configuration
543
+ /plan [task] # start a planning-only branch and keep the current plan in .kiva/plans/
544
+ /end-plan # leave the planning branch, summarize it, and return to the original branch
545
+ /plan-policy # show the effective planning-model policy and the resolved planning model
546
+ /read-only # enter read-only mode — write and edit tools are disabled
547
+ /end-read-only # exit read-only mode and resume normal operation
548
+ /tasks # browse the canonical project-plan phases, features, and tasks
549
+ /todos # interactive todo manager
550
+ /souls # list available agent "souls" (communication styles)
551
+ /soul <id> # switch the agent's soul (e.g. caveman, master-yoda, pirate) — takes effect next session
552
+ ```
553
+
554
+ #### Souls
555
+
556
+ A "soul" is a style-only prompt overlay that changes how the agent *talks* without changing what it *does*. Tool usage, Kiva CLI rules, and structured (`--json`) output are always preserved; souls only affect narrative prose.
557
+
558
+ Select a soul inside the pi agent (`kiva work` / `kiva code`) with `/soul <id>` and list available souls with `/souls`. The selection is persisted in `<settings-root>/config.json` (same scope as environment/auth) and takes effect on the next agent session.
559
+
560
+ Over HTTP (`kiva server`):
561
+
562
+ ```bash
563
+ curl http://localhost:3111/api/souls
564
+ curl -X POST http://localhost:3111/api/souls/select \
565
+ -H 'content-type: application/json' \
566
+ -d '{"soulId":"pirate"}'
567
+ ```
568
+
569
+ Full server API reference for **Soul**, **MCP**, and **Skill** endpoints: [`docs/server-api.md`](./docs/server-api.md).
570
+
571
+ Full REST API reference for the **Project Plan** and **Goal** endpoints: [`docs/project-plan-goal-api.md`](./docs/project-plan-goal-api.md) (machine-readable OpenAPI 3.1 spec: [`docs/project-plan-goal-openapi.yaml`](./docs/project-plan-goal-openapi.yaml)).
572
+
573
+ When running through `kiva server`, `/plan` can be sent through `/api/chat` as normal chat input. If clarification is needed, the server emits a synthetic `ask_user` client tool. Frontends using AI SDK `useChat` should render that tool and submit structured answers back with `addToolOutput`.
574
+
575
+ ### Planning-Model Policy
576
+
577
+ Optional planning-model policy for controlling which model is used during `/plan` sessions:
578
+
579
+ - Project config: `<project>/.pi/plan-policy.json`
580
+ - Global config: `~/.pi/agent/plan-policy.json`
581
+ - Project config takes precedence over global config
582
+
583
+ Example:
584
+
585
+ ```json
586
+ {
587
+ "models": [
588
+ { "model": "anthropic/claude-sonnet-4", "thinkingLevel": "high" },
589
+ "openai-codex/gpt-5.3-codex"
590
+ ],
591
+ "profiles": {
592
+ "codex-implementation": {
593
+ "match": "openai-codex/gpt-5.3-codex",
594
+ "models": [
595
+ { "model": "anthropic/claude-sonnet-4", "thinkingLevel": "medium" }
596
+ ]
597
+ }
598
+ }
599
+ }
600
+ ```
601
+
602
+ `match` is the exact implementation-time `provider/modelId` active when `/plan` starts. The `models` array is an ordered fallback chain. If no configured planning model resolves, `/plan` stays on the current session model.