@cavelon/cli 0.1.16 → 0.1.18

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 (34) hide show
  1. package/README.md +35 -4
  2. package/dist/agent-env.js +1 -0
  3. package/dist/agents.js +2 -0
  4. package/dist/commands/db.js +45 -9
  5. package/dist/commands/limits-set.js +11 -1
  6. package/dist/commands/limits.js +7 -1
  7. package/dist/commands/setup.js +3 -3
  8. package/dist/database-limits.js +46 -0
  9. package/dist/database-queries.js +101 -8
  10. package/dist/mcp-entry.js +3 -3
  11. package/dist/native-approval/kilo-server.js +33 -0
  12. package/dist/native-approval/kilo-tui.js +13 -0
  13. package/dist/native-approval/omp-extension.js +8 -0
  14. package/dist/native-approval/opencode-server.js +2 -2
  15. package/dist/native-approval/opencode-tui.js +2 -2
  16. package/dist/native-approval/pi-extension.js +5 -3
  17. package/dist/native-approval/profile.js +16 -9
  18. package/dist/native-assets/THIRD-PARTY-NOTICES +18 -0
  19. package/dist/native-assets/kilo-server.mjs +39719 -0
  20. package/dist/native-assets/kilo-tui.mjs +26477 -0
  21. package/dist/native-assets/manifest.json +31 -9
  22. package/dist/native-assets/omp-extension.mjs +30729 -0
  23. package/dist/native-assets/opencode-server.mjs +7541 -122
  24. package/dist/native-assets/opencode-tui.mjs +7531 -112
  25. package/dist/native-assets/pi-extension.mjs +7552 -128
  26. package/dist/native-clients.js +217 -1
  27. package/dist/native-install.js +41 -16
  28. package/dist/omp-config.js +85 -0
  29. package/dist/setup-agents.js +15 -6
  30. package/dist/skills/cavelon-authoring/SKILL.md +12 -1
  31. package/dist/skills/cavelon-testing/SKILL.md +2 -1
  32. package/dist/workflow-queries.js +23 -1
  33. package/dist/yaml-config.js +215 -0
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -21,11 +21,12 @@ in Windows PowerShell. With Python, `uvx cavelon` runs the same executable from
21
21
  PyPI, and `uv tool install cavelon` or `pipx install cavelon` installs it. Then
22
22
  `cavelon setup` sets up your coding agents and logs you in.
23
23
 
24
- Version 0.1.16 adds OpenCode and Pi with bundled native approval dialogs and
25
- Qwen Code CLI with native settings, skills and person-terminal confirmation:
24
+ Version 0.1.17 adds Cline, Kilo, Goose and OMP to the OpenCode, Pi and Qwen
25
+ Code integrations. Each has native settings and four skills; guarded changes
26
+ use the qualified client dialog or the person’s own terminal:
26
27
 
27
28
  ```bash
28
- cavelon setup --agents opencode,pi,qwen
29
+ cavelon setup --agents opencode,pi,qwen,cline,kilo,goose,omp
29
30
  ```
30
31
 
31
32
  See the [client install pages](https://github.com/goodguys-gmbh/cavelon-dev-kit/blob/main/docs/install/README.md)
@@ -122,7 +123,7 @@ Every command takes `--json` (one JSON document on stdout, errors included),
122
123
 
123
124
  | Command | Marked | What it does |
124
125
  |---|---|---|
125
- | `setup [--agents] [--yes] [--check] [--remove]` | changing (destructive) | Set up the coding agents on this computer (the plugin for Claude Code and Codex; the MCP server and skills in the user settings of Cursor, VS Code with GitHub Copilot, Gemini CLI and Kiro) and log in. `--check` reports what works, `--remove` undoes it. A person runs this; not an MCP tool. |
126
+ | `setup [--agents] [--yes] [--check] [--remove]` | changing (destructive) | Set up supported coding agents with their plugin or native MCP configuration and all four skills, then log in. `--check` reports what works, `--remove` undoes it. A person runs this; not an MCP tool. |
126
127
  | `login [--token-stdin]` | changing | Store a token for an instance. A person runs this. |
127
128
  | `logout [--all]` | changing | Delete the stored token. |
128
129
  | `whoami` | read-only | Owner or key, tenant (name, slug and id), role, where the credential came from, whether it may enter Platform mode and which tenants it reaches. |
@@ -204,6 +205,14 @@ release.
204
205
 
205
206
  ### Limits
206
207
 
208
+ `cavelon db instance` and `cavelon limits` show published database connection
209
+ and query caps, current counts, their source and platform defaults. Missing
210
+ counts on older instances are left out. An operator with `limits.manage`
211
+ uses a Platform-mode personal access token to preview an override with
212
+ `cavelon limits set database_queries_per_tenant 250 --tenant acme` and sends
213
+ it after the person's confirmation. `none` resets the override. Tenant Owners
214
+ cannot raise these caps. See [Database limits](https://github.com/goodguys-gmbh/cavelon-dev-kit/blob/main/docs/limits.md#database-connections-and-queries).
215
+
207
216
  `cavelon limits` shows what the instance allows this tenant, from the `limits`
208
217
  it publishes in `/api/v1/meta/capabilities`: upload size and file types, agent
209
218
  turns and tool calls, timeouts, rate limits, the licence's cap on solutions.
@@ -824,3 +833,25 @@ which copy of the package schema it used.
824
833
  In the working directory, only `init`, `pull` and `apply` write, as described
825
834
  in "Solution as code", and `artifacts export`, which writes the tar it
826
835
  downloads to a new file.
836
+
837
+ Version 0.1.17: `cavelon setup --agents cline` writes shared native user settings
838
+ and skills; `cavelon init --agents cline` copies project skills only. Guarded
839
+ changes use the person’s own terminal. See [Cline](../docs/install/cline.md)
840
+ for guarded launch, custom CLI paths and separate editor qualification.
841
+
842
+ Version 0.1.17: `cavelon setup --agents kilo` installs Kilo-native settings, skills
843
+ and bundled server/TUI plugins. CLI TUI changes ask a fresh native dialog;
844
+ editor/headless changes use the person’s terminal. See [Kilo](../docs/install/kilo.md)
845
+ for preserved configuration precedence, guarded launch and lifecycle.
846
+
847
+ Version 0.1.17: `cavelon setup --agents goose` writes Goose's native user YAML
848
+ extension and skills; project init copies shared skills only. The interactive
849
+ CLI uses its built-in person form. Headless runs cancel that form without a
850
+ change. System/additional config bindings and personal YAML are preserved.
851
+ See [Goose](../docs/install/goose.md) for paths, lifecycle and approval limits.
852
+
853
+ Version 0.1.17: `cavelon setup --agents omp` installs OMP's own native profile,
854
+ MCP entry, skills and bundled autoload extension. It preserves personal YAML
855
+ and supports fresh TUI approval; print/RPC calls use the person's terminal.
856
+ Use matching profile selection and a guarded launch. See
857
+ [OMP](../docs/install/omp.md) for lifecycle and qualification limits.
package/dist/agent-env.js CHANGED
@@ -14,6 +14,7 @@ export const AGENT_VARIABLES = [
14
14
  { variable: "TERM_PROGRAM", value: "kiro", agent: "Kiro" },
15
15
  { variable: "OPENCODE", agent: "OpenCode" },
16
16
  { variable: "PI_SESSION_ID", agent: "Pi" },
17
+ { variable: "AGENT_SESSION_ID", agent: "Goose or another agent exposing its session" },
17
18
  { variable: "GROK_AGENT", agent: "Grok Build" },
18
19
  { variable: "AI_AGENT", agent: "an agent that follows the AI_AGENT convention" },
19
20
  ];
package/dist/agents.js CHANGED
@@ -47,6 +47,8 @@ export const AGENTS = [
47
47
  agent("kiro", "Kiro", () => jsonServer(".kiro/settings/mcp.json")),
48
48
  ...NATIVE_CLIENTS.map(client => agent(client.name, client.label, () => {
49
49
  const config = client.project();
50
+ if (!config)
51
+ return undefined;
50
52
  return { ...config, entry: encodeMcpEntry(mcpCommand(), config.entryFormat, config.extra),
51
53
  others: [...otherPlatforms().map(p => encodeMcpEntry(mcpCommand(p), config.entryFormat, config.extra)), encodeMcpEntry(INSTALLED_MCP_COMMAND, config.entryFormat, config.extra)] };
52
54
  })),
@@ -7,6 +7,7 @@ import { callStable } from "../invoke.js";
7
7
  import { cavelonCommand, fill } from "../printed.js";
8
8
  import { isUuid } from "../session.js";
9
9
  import { accessFor, requirePersonForIdentityChoice } from "../access.js";
10
+ import { databaseLimitRows, databaseLimitsText } from "../database-limits.js";
10
11
  function reported(value) {
11
12
  if (value === undefined)
12
13
  return undefined;
@@ -124,13 +125,14 @@ function lastTest(c) {
124
125
  return `${c.last_test_outcome ?? "?"} (${c.last_test_at})`;
125
126
  }
126
127
  const filledBy = (p) => (!p.source || p.source === "model" ? "model" : p.source);
128
+ const typeOf = (p) => (p.list === true ? `list of ${p.type ?? "string"}` : (p.type ?? "string"));
127
129
  function parameterRows(parameters) {
128
130
  return parameters.map((p) => ({
129
131
  name: p.name,
130
132
  filled_by: filledBy(p),
131
- type: p.type ?? "string",
133
+ type: typeOf(p),
132
134
  required: p.required === false ? "no" : "yes",
133
- constraints: ["max_length", "pattern", "enum", "minimum", "maximum"]
135
+ constraints: ["max_items", "max_length", "pattern", "enum", "minimum", "maximum"]
134
136
  .filter((k) => p[k] !== undefined && p[k] !== null)
135
137
  .map((k) => `${k} ${JSON.stringify(p[k])}`)
136
138
  .join(", ") || null,
@@ -156,10 +158,11 @@ function firewallSentence(offer) {
156
158
  }
157
159
  export const dbInstance = {
158
160
  name: "db instance",
159
- summary: "What this instance offers for database connections: dialects, firewall addresses and write-query support where published.",
161
+ summary: "Database dialects, firewall addresses, write-query support and the tenant's caps and counts where published.",
160
162
  description: "Read it before a database connection is set up: a connection of a dialect the instance does not run can be saved, but\n" +
161
163
  "its test and queries answer unavailable, and the customer's database must let the instance's egress addresses in. An\n" +
162
- "instance older than this route says only its dialects, in its capabilities.",
164
+ "instance older than this route says only its dialects, in its capabilities.\n" +
165
+ "Published limits show current connection/query counts, effective caps, their source and the platform default; missing counts stay missing.",
163
166
  readOnly: true,
164
167
  idempotent: true,
165
168
  mcpTool: "db_instance",
@@ -181,6 +184,7 @@ export const dbInstance = {
181
184
  };
182
185
  }
183
186
  const firewall = firewallSentence(offer);
187
+ const counts = databaseLimitRows(offer.limits);
184
188
  return {
185
189
  data: { published: true, ...offer, firewall },
186
190
  text: [
@@ -193,6 +197,7 @@ export const dbInstance = {
193
197
  ]),
194
198
  "",
195
199
  firewall,
200
+ ...(counts.length ? ["", databaseLimitsText(counts)] : []),
196
201
  ...(offer.runnable_dialects.length ? [] : ["", "This instance runs no database dialect: a connection can be saved, but its test and queries answer unavailable."]),
197
202
  ].join("\n"),
198
203
  };
@@ -474,6 +479,31 @@ function typed(parameter, raw) {
474
479
  }
475
480
  return raw;
476
481
  }
482
+ function listValue(parameter, raw) {
483
+ const type = parameter.type ?? "string";
484
+ const at = `--value ${parameter.name}`;
485
+ let items;
486
+ try {
487
+ items = JSON.parse(raw);
488
+ }
489
+ catch {
490
+ items = undefined;
491
+ }
492
+ if (!Array.isArray(items)) {
493
+ const example = type === "integer" || type === "number" ? "[4711,4712]" : type === "date" ? '["2026-10-01","2026-10-02"]' : '["A-10023","A-10024"]';
494
+ throw usageError(`${at}: a list parameter takes a JSON array of ${type} values.`, `Give it as ${parameter.name}=${example}, quoted for your shell.`);
495
+ }
496
+ if (!items.length)
497
+ throw usageError(`${at}: must hold at least 1 item.`);
498
+ if (typeof parameter.max_items === "number" && items.length > parameter.max_items)
499
+ throw usageError(`${at}: must hold at most ${parameter.max_items} items.`);
500
+ items.forEach((item, index) => {
501
+ const fits = type === "integer" ? Number.isInteger(item) : type === "number" ? typeof item === "number" && Number.isFinite(item) : typeof item === "string";
502
+ if (!fits)
503
+ throw usageError(`${at}: item ${index + 1} ${item === null ? "is empty" : `is not ${type === "integer" ? "an integer" : type === "number" ? "a number" : type === "date" ? "a date (YYYY-MM-DD) string" : "a string"}`}.`);
504
+ });
505
+ return items;
506
+ }
477
507
  function runValues(query, given) {
478
508
  const values = {};
479
509
  for (const pair of given) {
@@ -483,9 +513,9 @@ function runValues(query, given) {
483
513
  const name = pair.slice(0, at);
484
514
  const parameter = query.parameters.find((p) => p.name === name);
485
515
  if (!parameter) {
486
- throw usageError(`${query.slug} has no parameter "${name}".`, `Its parameters: ${query.parameters.map((p) => `${p.name} (${filledBy(p)}, ${p.type ?? "string"})`).join(", ") || "none"}.`);
516
+ throw usageError(`${query.slug} has no parameter "${name}".`, `Its parameters: ${query.parameters.map((p) => `${p.name} (${filledBy(p)}, ${typeOf(p)})`).join(", ") || "none"}.`);
487
517
  }
488
- values[name] = typed(parameter, pair.slice(at + 1));
518
+ values[name] = parameter.list === true ? listValue(parameter, pair.slice(at + 1)) : typed(parameter, pair.slice(at + 1));
489
519
  }
490
520
  return values;
491
521
  }
@@ -495,7 +525,9 @@ export const dbTestRun = {
495
525
  summary: "Run a saved query once with the values given, identity parameters included; show what the model would see and the rows.",
496
526
  description: "Needs the tenant Owner's permission (database_connectors.test); it reads the customer's own data. Give each parameter\n" +
497
527
  "with --value name=value, those the platform fills from the signed-in visitor (end_user.*) too: that is how an\n" +
498
- "identity-scoped query is checked for one customer. The instance records the run (counts only) and audits it with your\n" +
528
+ "identity-scoped query is checked for one customer. A list parameter takes a JSON array (--value 'skus=[\"X-1\",\"X-2\"]'),\n" +
529
+ "one to max_items items of its type; the instance checks each item and names a refused one by position, never its value.\n" +
530
+ "The instance records the run (counts only; a list by its item count) and audits it with your\n" +
499
531
  "name. Where the instance publishes the matching needs_a_person_when restriction, the kit refuses an API key on an\n" +
500
532
  "end_user.* query before sending (exit 5): a person tests it in the Admin or with their personal access token. Ordinary queries\n" +
501
533
  "remain usable with an API key. On an older instance that omits the restriction, the server decides.\n" +
@@ -513,10 +545,14 @@ export const dbTestRun = {
513
545
  operations: ["POST /api/v1/database-connectors/queries/{query_id}/test-run"],
514
546
  positionals: [{ name: "query", description: "The query's tool slug or id.", required: true }],
515
547
  options: {
516
- value: { type: "string", multiple: true, value: "<name=value>", description: "One parameter's value, typed as the parameter's type." },
548
+ value: { type: "string", multiple: true, value: "<name=value>", description: "One parameter's value, typed as the parameter's type; a list parameter's is a JSON array." },
517
549
  rows: { type: "string", value: "<n>", description: `Show at most n rows in the text (default ${ROWS_SHOWN}); --json carries what the instance returned.` },
518
550
  },
519
- examples: ["cavelon db test-run order_status --value order_no=A-10023 --value email=ada@example.com", "cavelon db test-run stock --value sku=4711 --json"],
551
+ examples: [
552
+ "cavelon db test-run order_status --value order_no=A-10023 --value email=ada@example.com",
553
+ "cavelon db test-run stock --value sku=4711 --json",
554
+ `cavelon db test-run stock_of_skus --value 'skus=["X-1","X-2"]'`,
555
+ ],
520
556
  async run(ctx, input) {
521
557
  const query = await resolveQuery(ctx, positional(input, "query"));
522
558
  if (query.parameters.some(p => p.source?.startsWith("end_user."))) {
@@ -83,6 +83,14 @@ function findTarget(published, key, explicitTenant) {
83
83
  return limitTarget(key, limit, limit.tenant_change);
84
84
  if (limit.change)
85
85
  return limitTarget(key, limit, limit.change);
86
+ if (limit.tenant_change) {
87
+ throw new CavelonError(ExitCode.usage, {
88
+ code: "tenant_required",
89
+ message: `${key} changes one tenant's override. Nothing was sent.`,
90
+ hint: "Pass --tenant <id|slug> and use a personal access token in Platform mode of the role the published change names.",
91
+ details: { key, sent: false },
92
+ });
93
+ }
86
94
  if (limit.changeable_by !== "tenant_admin")
87
95
  throw operatorRefusal(limit, switchFor(published, key));
88
96
  throw notPublished(`This instance does not publish how to change ${key}, so nothing was sent.`, `It runs an older Cavelon version. A tenant admin changes ${limit.setting} in the Admin's settings. ` +
@@ -262,6 +270,8 @@ function anyOf(names, none = "a permission the instance does not name") {
262
270
  function adminPage(target) {
263
271
  if (target.flag)
264
272
  return FEATURE_FLAGS_PAGE;
273
+ if (target.change.field.startsWith("max_database_"))
274
+ return "the tenant's Limits section (Database connections and Database queries)";
265
275
  return target.scope === "one_tenant" ? TENANT_LIMITS_PAGE : RUN_CAPS_PAGE;
266
276
  }
267
277
  function permissionRefusal(principal, target) {
@@ -469,7 +479,7 @@ export const limitsSet = {
469
479
  "before sending. Without --confirm, shows the old and new value, the operation and who may run it, and changes nothing.\n" +
470
480
  "Also changes the tenant quotas in tenant_quotas.changes (the inference budget, the monthly Processing Step cap).\n" +
471
481
  "An operator's change (a run cap) is sent only with a personal access token in Platform mode of a role it names, without\n" +
472
- "X-Tenant-Id; --tenant <id|slug> then sets one tenant's own run cap. An environment or licence limit, a value out of bounds,\n" +
482
+ "X-Tenant-Id; --tenant <id|slug> then sets one tenant's override, including database connection/query caps. An environment or licence limit, a value out of bounds,\n" +
473
483
  "an instance that does not publish how to change the limit, and a credential without the permission or the role are refused\n" +
474
484
  "before anything is sent. Propose the change to the person; never raise a limit on your own.\n" +
475
485
  PERSON_CONFIRMS_HELP,
@@ -5,6 +5,7 @@ import { table } from "../format.js";
5
5
  import { branchConcurrency, branchConcurrencyText } from "../branches.js";
6
6
  import { bindsNow, bindsWhenText, changedBy, docsPage, formatQuota, formatQuotaValue, formatValue, isOperatorChange, readLimits, readQuotas, } from "../limits.js";
7
7
  import { cavelonCommand, fill } from "../printed.js";
8
+ import { databaseLimitsText, readDatabaseLimits } from "../database-limits.js";
8
9
  const SOURCE_ORDER = ["tenant", "platform", "licence"];
9
10
  const SOURCE_TITLE = {
10
11
  tenant: "Set by this tenant (its own settings)",
@@ -41,6 +42,7 @@ export const limits = {
41
42
  "A limit that binds only while another is on says so (the archive caps apply while archive uploads are on).\n" +
42
43
  "Branch concurrency: the width per node, the ceiling per process, and whether branches run concurrently (and which switch is off).\n" +
43
44
  "The tenant quotas include the monthly Processing Step cap with this billing month's use, where the instance publishes it.\n" +
45
+ "Database connection/query limits include current counts from the connector where published, including counts above a lowered cap.\n" +
44
46
  "A limit the instance does not list does not bind there. An instance older than the published limits lists none.",
45
47
  readOnly: true,
46
48
  idempotent: true,
@@ -74,6 +76,7 @@ export const limits = {
74
76
  if (unknown.length)
75
77
  ctx.warn(`This instance lists no limit ${unknown.join(", ")}; it does not bind here.`);
76
78
  const groups = groupBySource(values);
79
+ const databaseLimits = await readDatabaseLimits(ctx, values.map(value => value.key));
77
80
  const quotas = keys.length || source ? undefined : await readQuotas(ctx, published);
78
81
  const quotaValues = keys.length || source ? [] : (published.tenantQuotas?.values ?? []);
79
82
  const near = [
@@ -109,6 +112,8 @@ export const limits = {
109
112
  text += `\n\nBranch concurrency (fan-outs and Map loops):\n${branchConcurrencyText(branches)}`;
110
113
  if (!groups.length)
111
114
  text = keys.length || source ? "No published limit matches." : "This instance publishes no binding limit.";
115
+ if (databaseLimits.length)
116
+ text += `\n\n${databaseLimitsText(databaseLimits)}`;
112
117
  if (quotas || quotaValues.length) {
113
118
  const rows = [
114
119
  ...(quotas?.items ?? []).map((q) => ({ quota: q.key, use: quotaUse(q), state: typeof q.details.state === "string" ? q.details.state : "", close: q.near ? "close to the quota" : "" })),
@@ -132,7 +137,7 @@ export const limits = {
132
137
  text += `; ${owner.join(", ")} only a Tenant Owner (settings.manage)`;
133
138
  }
134
139
  if (operatorChangeable.length) {
135
- text += `\n\nAn operator changes ${operatorChangeable.join(", ")} with the same command and a personal access token in Platform mode of the role the change names; --tenant <id|slug> sets the tenant (one tenant's own run cap, its flag).`;
140
+ text += `\n\nAn operator changes ${operatorChangeable.join(", ")} with the same command and a personal access token in Platform mode of the role the change names; --tenant <id|slug> selects one tenant's override or flag.`;
136
141
  }
137
142
  const pages = [...new Set(values.map((v) => docsPage(v.docs)).filter(Boolean))];
138
143
  if (pages.length)
@@ -150,6 +155,7 @@ export const limits = {
150
155
  quota_values: quotaValues.map(({ near: isNear, ratio, ...q }) => ({ ...q, ratio, near: isNear })),
151
156
  near: near.map(({ text: _text, ...q }) => q),
152
157
  branch_concurrency: branches ?? null,
158
+ ...(databaseLimits.length ? { database_limits: databaseLimits } : {}),
153
159
  },
154
160
  text,
155
161
  };
@@ -239,7 +239,7 @@ async function runSetup(ctx, input) {
239
239
  next.push(`Or start a solution yourself in an empty folder: ${cavelonCommand("init")}`);
240
240
  }
241
241
  else if (!chosen.length) {
242
- next.push("No coding agent was found. Install one (Claude Code, Codex, Cursor, VS Code with GitHub Copilot, Gemini CLI or Kiro) and run cavelon setup again,", ` or name yours: ${cavelonCommand("setup", "--agents", "cursor")}`);
242
+ next.push(`No coding agent was found. Install one (${setupAgents(env).map(agent => agent.label).join(", ")}) and run cavelon setup again,`, ` or name yours: ${cavelonCommand("setup", "--agents", "cursor")}`);
243
243
  }
244
244
  }
245
245
  const lines = [];
@@ -413,7 +413,7 @@ export const setup = {
413
413
  storesTarget: true,
414
414
  tenantless: true,
415
415
  summary: "Set up your coding agents for Cavelon and log in, in one guided step.",
416
- description: "Finds Claude Code, Codex, Cursor, VS Code with GitHub Copilot, Gemini CLI, Kiro, OpenCode and Pi, shows what it will change for each, asks once\n" +
416
+ description: "Finds Claude Code, Codex, Cursor, VS Code with GitHub Copilot, Gemini CLI, Kiro, OpenCode, Pi, Qwen, Cline, Kilo, Goose and OMP, shows what it will change for each, asks once\n" +
417
417
  "and does it: Claude Code and Codex get the Cavelon plugin through their own plugin command, Gemini CLI the extension of this\n" +
418
418
  "release (or the files, when the release has none); the others get the `cavelon` MCP server in their user MCP configuration\n" +
419
419
  "and the skills in their user skills folder. It touches nothing else in those files and\n" +
@@ -431,7 +431,7 @@ export const setup = {
431
431
  type: "string",
432
432
  value: "<list>",
433
433
  multiple: true,
434
- description: "Only these agents: claude, codex, cursor, copilot, gemini, kiro, opencode, pi, qwen, or all (comma-separated). Default: every agent found.",
434
+ description: "Only these agents: claude, codex, cursor, copilot, gemini, kiro, opencode, pi, qwen, cline, kilo, or all (comma-separated). Default: every agent found.",
435
435
  },
436
436
  yes: { type: "boolean", short: "y", description: "Make the changes without asking." },
437
437
  check: { type: "boolean", description: "Report what is set up and working; change nothing." },
@@ -0,0 +1,46 @@
1
+ import { CavelonError } from "./errors.js";
2
+ import { table } from "./format.js";
3
+ const KEYS = {
4
+ connections: "database_connections_per_tenant",
5
+ queries: "database_queries_per_tenant",
6
+ };
7
+ function validLimit(value) {
8
+ if (!value || typeof value !== "object")
9
+ return false;
10
+ const item = value;
11
+ return Number.isInteger(item.limit) && item.limit >= 1 &&
12
+ Number.isInteger(item.current) && item.current >= 0 &&
13
+ Number.isInteger(item.platform_limit) && item.platform_limit >= 1 &&
14
+ (item.source === "platform" || item.source === "tenant");
15
+ }
16
+ export function databaseLimitRows(limits, keys) {
17
+ if (!limits || typeof limits !== "object")
18
+ return [];
19
+ const published = limits;
20
+ return Object.keys(KEYS).flatMap(name => {
21
+ const value = published[name];
22
+ const key = KEYS[name];
23
+ return validLimit(value) && (!keys || keys.includes(key)) ? [{ key, ...value }] : [];
24
+ });
25
+ }
26
+ export function databaseLimitsText(rows) {
27
+ return `Database limits and current counts:\n${table(rows.map(row => ({ ...row })), ["key", "current", "limit", "source", "platform_limit"])}`;
28
+ }
29
+ export async function readDatabaseLimits(ctx, keys) {
30
+ if (!keys.some(key => Object.values(KEYS).includes(key)))
31
+ return [];
32
+ try {
33
+ const response = await (await ctx.client()).get("/api/v1/database-connectors/instance", { allow: [403, 404] });
34
+ if (response.status !== 200) {
35
+ ctx.warn(`Database counts are unavailable (${response.status}); the published limits still stand.`);
36
+ return [];
37
+ }
38
+ return databaseLimitRows(response.data?.limits, keys);
39
+ }
40
+ catch (error) {
41
+ if (!(error instanceof CavelonError))
42
+ throw error;
43
+ ctx.warn("Database counts could not be read; the published limits still stand.");
44
+ return [];
45
+ }
46
+ }
@@ -47,6 +47,13 @@ export function parameterSchema(schema) {
47
47
  const parameters = querySchema(schema)?.properties?.parameters;
48
48
  return isObject(parameters) ? resolveRef(schema, parameters.items) : undefined;
49
49
  }
50
+ export function schemaKnowsLists(schema) {
51
+ const properties = parameterSchema(schema)?.properties;
52
+ return isObject(properties) && "list" in properties;
53
+ }
54
+ export const LIST_ITEM_TYPES = ["string", "integer", "number", "date"];
55
+ export const LIST_MAX_ITEMS_DEFAULT = 20;
56
+ export const CONFIRMATION_LIST_LIMIT = 20;
50
57
  export function schemaKnowsWrites(schema) {
51
58
  const kind = querySchema(schema)?.properties?.kind;
52
59
  return Array.isArray(kind?.enum) && kind.enum.includes("write");
@@ -73,7 +80,7 @@ const CONSTRAINTS_BY_TYPE = {
73
80
  const CONSTRAINTS = ["max_length", "pattern", "enum", "minimum", "maximum"];
74
81
  const problem = (code, message, at) => ({ code, message, ...(at ? { at } : {}) });
75
82
  const isNumber = (v) => typeof v === "number" && Number.isFinite(v);
76
- function parameterProblems(p, index, defaults) {
83
+ function parameterProblems(p, index, defaults, lists) {
77
84
  const name = typeof p.name === "string" ? p.name : `#${index + 1}`;
78
85
  const source = p.source ?? defaults.source;
79
86
  const type = typeof (p.type ?? defaults.type) === "string" ? String(p.type ?? defaults.type) : "string";
@@ -81,7 +88,10 @@ function parameterProblems(p, index, defaults) {
81
88
  const at = `parameters/${index}`;
82
89
  const said = (what) => `parameter '${name}': ${what}`;
83
90
  const set = CONSTRAINTS.filter((key) => p[key] !== undefined && p[key] !== null);
91
+ const maxItems = p.max_items !== undefined && p.max_items !== null;
84
92
  if (typeof source === "string" && source !== defaults.source) {
93
+ if (lists && (p.list === true || maxItems))
94
+ return [problem("parameter_context_list", said(`a context parameter (${source}) binds one value, never a list`), `${at}/${p.list === true ? "list" : "max_items"}`)];
85
95
  if (type !== "string")
86
96
  return [problem("parameter_context_not_string", said(`a context parameter (${source}) has type string`), `${at}/type`)];
87
97
  if (required === false)
@@ -94,6 +104,20 @@ function parameterProblems(p, index, defaults) {
94
104
  if (typeof p.description !== "string" || !p.description.trim()) {
95
105
  problems.push(problem("parameter_description_missing", said("the model needs a description of what to fill in"), at));
96
106
  }
107
+ if (lists && p.list !== true && maxItems) {
108
+ problems.push(problem("parameter_constraint_not_applicable", said("max_items applies to a list only"), `${at}/max_items`));
109
+ return problems;
110
+ }
111
+ if (lists && p.list === true) {
112
+ if (!LIST_ITEM_TYPES.includes(type)) {
113
+ problems.push(problem("parameter_list_type", said(`a list's items are a string, integer, number or date, not ${type}`), `${at}/type`));
114
+ return problems;
115
+ }
116
+ if (required === false) {
117
+ problems.push(problem("parameter_list_optional", said("a list parameter is always required"), `${at}/required`));
118
+ return problems;
119
+ }
120
+ }
97
121
  const misplaced = set.filter((key) => !(CONSTRAINTS_BY_TYPE[type] ?? []).includes(key));
98
122
  if (misplaced.length) {
99
123
  problems.push(problem("parameter_constraint_not_applicable", said(`${misplaced.join(", ")} does not apply to type ${type}`), `${at}/${misplaced[0]}`));
@@ -127,7 +151,8 @@ export function queryProblems(query, schema) {
127
151
  const repeated = [...new Set(names.filter((n, i) => names.indexOf(n) !== i))].sort((a, b) => a.localeCompare(b, "en"));
128
152
  if (repeated.length)
129
153
  problems.push(problem("parameter_names_repeat", `parameter names repeat: ${repeated.join(", ")}`, "parameters"));
130
- parameters.forEach((p, index) => problems.push(...parameterProblems(p, index, defaults)));
154
+ const lists = schemaKnowsLists(schema);
155
+ parameters.forEach((p, index) => problems.push(...parameterProblems(p, index, defaults, lists)));
131
156
  if (typeof query.sql_text === "string" && query.sql_text.trim()) {
132
157
  const found = bindNames(query.sql_text);
133
158
  const missing = found.filter((n) => !names.includes(n)).sort((a, b) => a.localeCompare(b, "en"));
@@ -139,6 +164,19 @@ export function queryProblems(query, schema) {
139
164
  ];
140
165
  problems.push(problem("bind_mismatch", `The SQL and its parameters disagree; ${parts.join("; ")}.`, "sql_text"));
141
166
  }
167
+ const listed = lists ? parameters.filter((p) => p.list === true && (p.source ?? defaults.source) === defaults.source && typeof p.name === "string").map((p) => p.name) : [];
168
+ const dialect = isObject(query.connection) && typeof query.connection.dialect === "string" ? query.connection.dialect : undefined;
169
+ const outside = dialect ? listOutsideIn(query.sql_text, dialect, listed) : undefined;
170
+ if (outside)
171
+ problems.push(problem("list_parameter_outside_in", `The list parameter :${outside} may stand only as IN (:${outside}) or NOT IN (:${outside}).`, "sql_text"));
172
+ }
173
+ const confirmation = querySchema(schema)?.properties?.requires_confirmation;
174
+ if (lists && schemaKnowsWrites(schema) && query.kind === "write" && confirmation && (query.requires_confirmation ?? confirmation.default) === true) {
175
+ parameters.forEach((p, index) => {
176
+ if (p.list !== true || (isNumber(p.max_items) ? p.max_items : LIST_MAX_ITEMS_DEFAULT) <= CONFIRMATION_LIST_LIMIT)
177
+ return;
178
+ problems.push(problem("list_too_long_to_confirm", `The confirmation card shows at most ${CONFIRMATION_LIST_LIMIT} values of a list, so a write that asks the person first takes max_items of at most ${CONFIRMATION_LIST_LIMIT}: ${String(p.name)}.`, `parameters/${index}/max_items`));
179
+ });
142
180
  }
143
181
  const context = parameters.some((p) => typeof p.source === "string" && p.source !== defaults.source);
144
182
  if (query.allows_anonymous === true && context) {
@@ -166,6 +204,36 @@ function closing(sql, start, quote, backslash) {
166
204
  }
167
205
  return undefined;
168
206
  }
207
+ function blockCommentEnd(sql, start, nested) {
208
+ let depth = 0;
209
+ for (let i = start; i < sql.length - 1;) {
210
+ const pair = sql.slice(i, i + 2);
211
+ if (pair === "/*") {
212
+ if (nested || depth === 0)
213
+ depth++;
214
+ i += 2;
215
+ }
216
+ else if (pair === "*/") {
217
+ depth--;
218
+ i += 2;
219
+ if (depth === 0)
220
+ return i;
221
+ }
222
+ else
223
+ i++;
224
+ }
225
+ return undefined;
226
+ }
227
+ function startsLineComment(sql, i, dialect) {
228
+ if (sql.startsWith("--", i))
229
+ return dialect !== "mysql" || i + 2 >= sql.length || /\s/.test(sql[i + 2]);
230
+ return dialect === "mysql" && sql[i] === "#";
231
+ }
232
+ function dollarTagAt(sql, i) {
233
+ const tag = /\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/y;
234
+ tag.lastIndex = i;
235
+ return tag.exec(sql)?.[0];
236
+ }
169
237
  function sqlTokens(sql, dialect) {
170
238
  const tokens = [];
171
239
  let i = 0;
@@ -177,20 +245,18 @@ function sqlTokens(sql, dialect) {
177
245
  }
178
246
  let end;
179
247
  let kind;
180
- if (sql.startsWith("--", i)) {
248
+ if (startsLineComment(sql, i, dialect)) {
181
249
  const newline = sql.indexOf("\n", i);
182
250
  end = newline === -1 ? sql.length : newline;
183
251
  kind = "comment";
184
252
  }
185
253
  else if (sql.startsWith("/*", i)) {
186
- const close = sql.indexOf("*/", i + 2);
187
- if (close === -1)
188
- return undefined;
189
- end = close + 2;
254
+ end = blockCommentEnd(sql, i, dialect === "postgresql");
190
255
  kind = "comment";
191
256
  }
192
257
  else if (char === "'") {
193
- end = closing(sql, i, "'", dialect === "mysql");
258
+ const escapePrefix = i > 0 && /[eE]/.test(sql[i - 1]) && (i < 2 || !/[\p{L}\p{N}]/u.test(sql[i - 2]));
259
+ end = closing(sql, i, "'", dialect === "mysql" || (dialect === "postgresql" && escapePrefix));
194
260
  kind = "string";
195
261
  }
196
262
  else if (char === '"') {
@@ -205,6 +271,12 @@ function sqlTokens(sql, dialect) {
205
271
  end = closing(sql, i, "]", false);
206
272
  kind = "identifier";
207
273
  }
274
+ else if (char === "$" && dialect === "postgresql" && dollarTagAt(sql, i)) {
275
+ const tag = dollarTagAt(sql, i);
276
+ const close = sql.indexOf(tag, i + tag.length);
277
+ end = close === -1 ? undefined : close + tag.length;
278
+ kind = "string";
279
+ }
208
280
  else if (WORD_START.test(char)) {
209
281
  end = i + 1;
210
282
  while (end < sql.length && WORD_PART.test(sql[end]))
@@ -304,6 +376,27 @@ export function isProcedureCall(sql, dialect) {
304
376
  const code = sqlTokens(sql, dialect)?.filter((t) => t.kind !== "comment");
305
377
  return isWord(code?.find((t) => !isSymbol(t, "(")), "EXEC", "EXECUTE");
306
378
  }
379
+ export function listOutsideIn(sql, dialect, listNames) {
380
+ if (!listNames.length)
381
+ return undefined;
382
+ const tokens = sqlTokens(sql, dialect);
383
+ if (!tokens)
384
+ return undefined;
385
+ const code = tokens.filter((t) => t.kind !== "comment");
386
+ const byStart = new Map(code.map((token, index) => [token.start, index]));
387
+ for (const match of sql.matchAll(BIND)) {
388
+ const name = match[1];
389
+ if (!listNames.includes(name))
390
+ continue;
391
+ const index = byStart.get(match.index);
392
+ if (index === undefined)
393
+ continue;
394
+ const placed = index >= 2 && isWord(code[index - 2], "IN") && isSymbol(code[index - 1], "(") && code[index + 1]?.kind === "word" && code[index + 1].text === name && isSymbol(code[index + 2], ")");
395
+ if (!placed)
396
+ return name;
397
+ }
398
+ return undefined;
399
+ }
307
400
  function settledTool(schema, tool) {
308
401
  const settled = settledForm(schema, schema.properties?.[TOOLS_SECTION], [tool]);
309
402
  return Array.isArray(settled) && isObject(settled[0]) ? settled[0] : tool;
package/dist/mcp-entry.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
2
  import { INSTALLED_MCP_COMMAND, mcpCommand } from "./mcp-command.js";
3
3
  export function encodeMcpEntry(command, format, extra = {}) {
4
- return format === "command-array" ? { ...extra, command: [command.command, ...command.args] } : { ...extra, command: command.command, args: command.args };
4
+ return format === "command-array" ? { ...extra, command: [command.command, ...command.args] } : { ...extra, [format === "goose-stdio" ? "cmd" : "command"]: command.command, args: command.args };
5
5
  }
6
6
  export function decodeMcpEntry(value, format) {
7
7
  if (!value || typeof value !== "object" || Array.isArray(value))
8
8
  return undefined;
9
9
  const entry = value;
10
- const words = format === "command-array" ? entry.command : [entry.command, ...(Array.isArray(entry.args) ? entry.args : [])];
11
- if (format === "command-args" && !Array.isArray(entry.args))
10
+ const words = format === "command-array" ? entry.command : [entry[format === "goose-stdio" ? "cmd" : "command"], ...(Array.isArray(entry.args) ? entry.args : [])];
11
+ if (format !== "command-array" && !Array.isArray(entry.args))
12
12
  return undefined;
13
13
  if (!Array.isArray(words) || !words.length || !words.every(word => typeof word === "string") || !words[0])
14
14
  return undefined;
@@ -0,0 +1,33 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { startOpenCodeServer } from "./opencode-server.js";
3
+ import { loadNativeRuntime, nativeEntryHash } from "./profile.js";
4
+ export async function startKiloServer(input, options) {
5
+ const server = await startOpenCodeServer(input, options, "kilo");
6
+ let effective;
7
+ return {
8
+ ...server,
9
+ async config(config) { effective = config; },
10
+ tool: Object.fromEntries(Object.entries(server.tool).map(([name, tool]) => [name, {
11
+ ...tool,
12
+ async execute(...args) {
13
+ const entry = effective?.mcp?.cavelon;
14
+ if (options.entryHash && (!entry || nativeEntryHash(entry) !== options.entryHash)) {
15
+ throw new Error("Kilo's effective Cavelon configuration differs from the owned entry; review its project, environment and managed policies before using the tools.");
16
+ }
17
+ return tool.execute(...args);
18
+ },
19
+ }])),
20
+ async "shell.env"(_input, output) {
21
+ output.env.CAVELON_AGENT = "1";
22
+ },
23
+ };
24
+ }
25
+ export default {
26
+ id: "cavelon.native-approval.kilo",
27
+ async server(input, options) {
28
+ const profile = options?.profile === undefined ? fileURLToPath(new URL("./profile.json", import.meta.url)) : options.profile;
29
+ if (typeof profile !== "string")
30
+ throw new Error("Cavelon native approval needs its setup profile.");
31
+ return startKiloServer(input, await loadNativeRuntime(profile, "kilo"));
32
+ },
33
+ };
@@ -0,0 +1,13 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { startOpenCodeTui } from "./opencode-tui.js";
3
+ import { loadNativeRuntime } from "./profile.js";
4
+ export const startKiloTui = (api, options) => startOpenCodeTui(api, options, "kilo");
5
+ export default {
6
+ id: "cavelon.native-approval.kilo",
7
+ async tui(api, options) {
8
+ const profile = options?.profile === undefined ? fileURLToPath(new URL("./profile.json", import.meta.url)) : options.profile;
9
+ if (typeof profile !== "string")
10
+ throw new Error("Cavelon native approval needs its setup profile.");
11
+ await startKiloTui(api, await loadNativeRuntime(profile, "kilo"));
12
+ },
13
+ };
@@ -0,0 +1,8 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { installPiExtension } from "./pi-extension.js";
3
+ import { loadNativeRuntime } from "./profile.js";
4
+ export default async function cavelon(omp) {
5
+ const runtime = await loadNativeRuntime(fileURLToPath(new URL("./profile.json", import.meta.url)), "omp");
6
+ process.env.CAVELON_AGENT = "1";
7
+ installPiExtension(omp, runtime, "omp");
8
+ }