@cavelon/cli 0.1.18 → 0.2.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.
package/README.md CHANGED
@@ -801,7 +801,7 @@ tools; a person runs them.
801
801
  ```json
802
802
  {
803
803
  "mcpServers": {
804
- "cavelon": { "command": "npx", "args": ["-y", "@cavelon/cli@0.1", "mcp"] }
804
+ "cavelon": { "command": "npx", "args": ["-y", "@cavelon/cli@0.2", "mcp"] }
805
805
  }
806
806
  }
807
807
  ```
@@ -213,10 +213,12 @@ export const dbLoginScript = {
213
213
  name: "db login-script", summary: "Print the instance's published read-only login SQL for a dialect or saved connection; no database is contacted.",
214
214
  description: "Needs database_connectors.view. The DBA replaces the script's password placeholder locally, outside the kit.\n" +
215
215
  "Only variants this instance publishes are offered; this build publishes read_only. Omitted inputs use its defaults.\n" +
216
- "For SQL Server, connection_limit_enforced is false; --schema scopes SELECT instead of granting db_datareader.",
216
+ "For SQL Server, connection_limit_enforced is false; --schema scopes SELECT instead of granting db_datareader.\n" +
217
+ "For Oracle, --schema names the one schema READ covers (omitted: the placeholder YOUR_SCHEMA); a profile sets the limit.",
217
218
  readOnly: true, idempotent: true, mcpTool: "db_login_script", operations: ["GET /api/v1/database-connectors/login-script", `GET ${CONNECTION}/login-script`],
218
219
  positionals: [{ name: "dialect", description: "Database dialect; omit only with --connection." }],
219
220
  options: {
221
+ dialect: { ...textOption("Database dialect, as the dialect argument; give one of the two.", "<dialect>"), cliOnly: true },
220
222
  connection: textOption("Use dialect, database, user and TLS from this saved connection (name or id).", "<connection>"),
221
223
  "database-name": textOption("Database the login may read (without --connection).", "<name>"),
222
224
  username: textOption("Database login name (without --connection).", "<name>"),
@@ -225,9 +227,17 @@ export const dbLoginScript = {
225
227
  "connection-limit": textOption("Connections to allow; omitted uses the instance's pool size times four.", "<n>"),
226
228
  "require-tls": textOption("MySQL REQUIRE SSL (true or false, without --connection).", "<true|false>"),
227
229
  },
228
- examples: ["cavelon db login-script postgresql --database-name shop --username cavelon_reader", "cavelon db login-script --connection shop-db --schema public"],
230
+ examples: [
231
+ "cavelon db login-script postgresql --database-name shop --username cavelon_reader",
232
+ "cavelon db login-script --dialect oracle --database-name SHOPPDB --username cavelon_ro --schema SHOP",
233
+ "cavelon db login-script --connection shop-db --schema public",
234
+ ],
229
235
  async run(ctx, input) {
230
- const dialect = positional(input, "dialect");
236
+ const argument = positional(input, "dialect");
237
+ const option = stringOption(input, "dialect");
238
+ if (argument !== undefined && option !== undefined)
239
+ throw usageError("Give the dialect once: as the argument or with --dialect, not both.");
240
+ const dialect = argument ?? option;
231
241
  const connectionRef = stringOption(input, "connection");
232
242
  if (Boolean(dialect) === Boolean(connectionRef))
233
243
  throw usageError("Give a dialect or --connection, exactly one.");
@@ -6,7 +6,7 @@ import { AGENTS, bundledSkills, generatedCopy, parseAgents, KNOWN_SKILL_ROOTS, s
6
6
  import { nativeClient, resolveNativeMcp, hasNativeApprovalAdapter } from "../native-clients.js";
7
7
  import { applyNativeInstallation, planNativeInstallation } from "../native-install.js";
8
8
  import { serverCommand } from "../setup-agents.js";
9
- import { encodeMcpEntry, isKitMcpEntry } from "../mcp-entry.js";
9
+ import { encodeMcpEntry, isCurrentMcpEntry, isKitMcpEntry } from "../mcp-entry.js";
10
10
  import { upsertJsoncEntry } from "../jsonc-config.js";
11
11
  import { CavelonError, ExitCode, usageError } from "../errors.js";
12
12
  import { confinedPath, realPath, within } from "../paths.js";
@@ -204,7 +204,7 @@ async function writeMcp(root, target, onlyExisting, env) {
204
204
  const selected = await resolveNativeMcp(config, root);
205
205
  if ("error" in selected)
206
206
  return { file: rel(root, selected.file), action: "skipped", reason: selected.error };
207
- if (selected.current !== undefined && isKitMcpEntry(selected.current, config.entryFormat, config.extra))
207
+ if (selected.current !== undefined && isCurrentMcpEntry(selected.current, config.entryFormat, config.extra))
208
208
  return { file: rel(root, selected.file), action: "unchanged" };
209
209
  const value = encodeMcpEntry(await serverCommand(env), config.entryFormat, config.extra);
210
210
  return applyBlock(root, selected.file, upsertJsoncEntry(selected.text, config.keys, value, { onlyExisting, matches: current => isKitMcpEntry(current, config.entryFormat, config.extra) }));
@@ -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, cline, kilo, or all (comma-separated). Default: every agent found.",
434
+ description: "Only these agents: claude, codex, cursor, copilot, gemini, kiro, opencode, pi, qwen, cline, kilo, goose, omp, 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." },
@@ -229,6 +229,23 @@ function startsLineComment(sql, i, dialect) {
229
229
  return dialect !== "mysql" || i + 2 >= sql.length || /\s/.test(sql[i + 2]);
230
230
  return dialect === "mysql" && sql[i] === "#";
231
231
  }
232
+ const ORACLE_DIALECT = "oracle";
233
+ const ORACLE_Q_CLOSERS = { "[": "]", "{": "}", "(": ")", "<": ">" };
234
+ function oracleQuoteAt(sql, i) {
235
+ const prefix = /[nN]?[qQ]'/y;
236
+ prefix.lastIndex = i;
237
+ const match = prefix.exec(sql);
238
+ if (!match || (i > 0 && /[\p{L}\p{N}_$#]/u.test(sql[i - 1])))
239
+ return 0;
240
+ return match[0].length;
241
+ }
242
+ function oracleQuoteEnd(sql, start) {
243
+ if (start >= sql.length || /\s/.test(sql[start]))
244
+ return undefined;
245
+ const closer = `${ORACLE_Q_CLOSERS[sql[start]] ?? sql[start]}'`;
246
+ const end = sql.indexOf(closer, start + 1);
247
+ return end === -1 ? undefined : end + closer.length;
248
+ }
232
249
  function dollarTagAt(sql, i) {
233
250
  const tag = /\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/y;
234
251
  tag.lastIndex = i;
@@ -254,6 +271,10 @@ function sqlTokens(sql, dialect) {
254
271
  end = blockCommentEnd(sql, i, dialect === "postgresql");
255
272
  kind = "comment";
256
273
  }
274
+ else if (dialect === ORACLE_DIALECT && oracleQuoteAt(sql, i)) {
275
+ end = oracleQuoteEnd(sql, i + oracleQuoteAt(sql, i));
276
+ kind = "string";
277
+ }
257
278
  else if (char === "'") {
258
279
  const escapePrefix = i > 0 && /[eE]/.test(sql[i - 1]) && (i < 2 || !/[\p{L}\p{N}]/u.test(sql[i - 2]));
259
280
  end = closing(sql, i, "'", dialect === "mysql" || (dialect === "postgresql" && escapePrefix));
@@ -376,6 +397,53 @@ export function isProcedureCall(sql, dialect) {
376
397
  const code = sqlTokens(sql, dialect)?.filter((t) => t.kind !== "comment");
377
398
  return isWord(code?.find((t) => !isSymbol(t, "(")), "EXEC", "EXECUTE");
378
399
  }
400
+ const READ_FORBIDDEN_WORDS = [
401
+ "INSERT", "UPDATE", "DELETE", "MERGE", "UPSERT", "INTO", "TRUNCATE", "DROP", "ALTER", "CREATE", "GRANT", "REVOKE", "COPY", "CALL", "EXEC", "EXECUTE",
402
+ "UPDLOCK", "XLOCK", "HOLDLOCK", "TABLOCKX",
403
+ ];
404
+ const LOCKING_AFTER_FOR = ["SHARE", "KEY", "NO", "UPDATE"];
405
+ const ORACLE_FORBIDDEN_WORDS = ["BEGIN", "DECLARE", "FUNCTION", "PROCEDURE", "PACKAGE", "PRAGMA", "COMMIT", "ROLLBACK", "SAVEPOINT", "HTTPURITYPE", "DBURITYPE", "XDBURITYPE"];
406
+ const ORACLE_FORBIDDEN_PREFIXES = ["DBMS_", "UTL_"];
407
+ function commonReadRefusal(code) {
408
+ return code.some((token, i) => {
409
+ if (token.kind !== "word")
410
+ return false;
411
+ const word = token.text.toUpperCase();
412
+ const next = code[i + 1];
413
+ return READ_FORBIDDEN_WORDS.includes(word) || (word === "FOR" && next?.kind === "word" && LOCKING_AFTER_FOR.includes(next.text.toUpperCase())) || (word === "LOCK" && isWord(next, "IN"));
414
+ });
415
+ }
416
+ export function oracleQueryProblem(sql, dialect, write) {
417
+ if (dialect !== ORACLE_DIALECT)
418
+ return undefined;
419
+ const tokens = sqlTokens(sql, dialect);
420
+ if (!tokens || tokens.some((t) => t.kind === "comment" && /^\/\*M?!/.test(t.text)))
421
+ return undefined;
422
+ const code = tokens.filter((t) => t.kind !== "comment");
423
+ if (code.some((t, i) => t.kind === "semicolon" && i !== code.length - 1))
424
+ return undefined;
425
+ if (write ? !isWord(code[0], "INSERT", "UPDATE", "DELETE") : !isWord(code.find((t) => !isSymbol(t, "(")), "SELECT", "WITH") || commonReadRefusal(code))
426
+ return undefined;
427
+ const refused = (message) => problem(write ? "write_statement_refused" : "forbidden_keyword", message, "sql_text");
428
+ for (const token of code) {
429
+ if (isSymbol(token, "@"))
430
+ return refused("The SQL may not reach another database: a database link (table@link) is not allowed.");
431
+ const name = token.kind === "word" ? token.text.toUpperCase() : token.kind === "identifier" ? token.text.slice(1, -1).replaceAll('""', '"').toUpperCase() : undefined;
432
+ if (name === undefined)
433
+ continue;
434
+ if (ORACLE_FORBIDDEN_WORDS.includes(name))
435
+ return refused(write ? `A write query may not hold ${name}.` : `The SQL may only read: ${name} is not allowed on Oracle.`);
436
+ if (ORACLE_FORBIDDEN_PREFIXES.some((prefix) => name.startsWith(prefix))) {
437
+ return refused(write
438
+ ? `A write query may not call ${token.text}: Oracle's supplied packages are refused.`
439
+ : `The SQL may not call ${token.text}: Oracle's DBMS_* and UTL_* packages reach the network, files or dynamic SQL.`);
440
+ }
441
+ if (write && (name === "RETURNING" || name === "RETURN")) {
442
+ return refused("On Oracle a write query may not hold RETURNING: its INTO needs output binds, which a write query does not have. Read the changed rows with a separate read query.");
443
+ }
444
+ }
445
+ return undefined;
446
+ }
379
447
  export function listOutsideIn(sql, dialect, listNames) {
380
448
  if (!listNames.length)
381
449
  return undefined;
@@ -477,6 +545,15 @@ export function checkQueryTools(disk, schema, baseline, connections) {
477
545
  message: `Query tool "${slug}": ${call.message}`,
478
546
  });
479
547
  }
548
+ const oracle = typeof query.sql_text === "string" ? oracleQueryProblem(query.sql_text, dialect, write) : undefined;
549
+ if (oracle) {
550
+ findings.push({
551
+ code: oracle.code,
552
+ severity: "warning",
553
+ ...locate(disk, `/${TOOLS_SECTION}/${index}/${QUERY_FIELD}/${oracle.at}`),
554
+ message: `Query tool "${slug}": ${oracle.message} The instance refuses it when the query is saved (${oracle.code}).`,
555
+ });
556
+ }
480
557
  const connection = isObject(query.connection) ? query.connection : undefined;
481
558
  if (write && connections?.some(c => c.name === connection?.name && c.dialect === dialect && c.allows_writes === false)) {
482
559
  findings.push({
@@ -1,5 +1,15 @@
1
- export const MCP_COMMAND = { command: "npx", args: ["-y", "@cavelon/cli@0.1", "mcp"] };
1
+ const RELEASE_LINE = "0.2";
2
+ export const EARLIER_RELEASE_LINES = ["0.1"];
3
+ const npx = (line) => ({ command: "npx", args: ["-y", `@cavelon/cli@${line}`, "mcp"] });
4
+ export const MCP_COMMAND = npx(RELEASE_LINE);
2
5
  export const INSTALLED_MCP_COMMAND = { command: "cavelon", args: ["mcp"] };
3
- export function mcpCommand(platform = process.platform) {
4
- return platform === "win32" ? { command: "cmd", args: ["/c", MCP_COMMAND.command, ...MCP_COMMAND.args] } : MCP_COMMAND;
6
+ export function mcpCommand(platform = process.platform, line = RELEASE_LINE) {
7
+ const command = line === RELEASE_LINE ? MCP_COMMAND : npx(line);
8
+ return platform === "win32" ? { command: "cmd", args: ["/c", command.command, ...command.args] } : command;
9
+ }
10
+ export function currentMcpCommands() {
11
+ return [INSTALLED_MCP_COMMAND, mcpCommand("linux"), mcpCommand("win32")];
12
+ }
13
+ export function kitMcpCommands() {
14
+ return [...currentMcpCommands(), ...EARLIER_RELEASE_LINES.flatMap(line => [mcpCommand("linux", line), mcpCommand("win32", line)])];
5
15
  }
package/dist/mcp-entry.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
- import { INSTALLED_MCP_COMMAND, mcpCommand } from "./mcp-command.js";
2
+ import { currentMcpCommands, kitMcpCommands } from "./mcp-command.js";
3
3
  export function encodeMcpEntry(command, format, extra = {}) {
4
4
  return format === "command-array" ? { ...extra, command: [command.command, ...command.args] } : { ...extra, [format === "goose-stdio" ? "cmd" : "command"]: command.command, args: command.args };
5
5
  }
@@ -15,7 +15,13 @@ export function decodeMcpEntry(value, format) {
15
15
  return { command: words[0], args: words.slice(1) };
16
16
  }
17
17
  export function isKitMcpEntry(value, format, extra = {}) {
18
+ return matchesAny(kitMcpCommands(), value, format, extra);
19
+ }
20
+ export function isCurrentMcpEntry(value, format, extra = {}) {
21
+ return matchesAny(currentMcpCommands(), value, format, extra);
22
+ }
23
+ function matchesAny(commands, value, format, extra) {
18
24
  if (!value || typeof value !== "object" || Array.isArray(value))
19
25
  return false;
20
- return [INSTALLED_MCP_COMMAND, mcpCommand("linux"), mcpCommand("win32")].some(command => isDeepStrictEqual(encodeMcpEntry(command, format, extra), value));
26
+ return commands.some(command => isDeepStrictEqual(encodeMcpEntry(command, format, extra), value));
21
27
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": 1,
3
- "version": "0.1.18",
3
+ "version": "0.2.0",
4
4
  "entries": {
5
5
  "omp": [
6
6
  "omp-extension.mjs"
@@ -9,6 +9,7 @@ import { runProgram } from "./run-program.js";
9
9
  import { KIT_VERSION } from "./version.js";
10
10
  import { NATIVE_CLIENTS, nativeClient, hasNativeApprovalAdapter, readNativeMcp, resolveNativeMcp } from "./native-clients.js";
11
11
  import { decodeMcpEntry, encodeMcpEntry, isKitMcpEntry } from "./mcp-entry.js";
12
+ import { kitMcpCommands } from "./mcp-command.js";
12
13
  import { removeJsoncEntry, upsertJsoncEntry } from "./jsonc-config.js";
13
14
  import { removeYamlEntry, upsertYamlEntry } from "./yaml-config.js";
14
15
  import { applyNativeInstallation, checkNativeInstallation, planNativeInstallation, removeNativeInstallation } from "./native-install.js";
@@ -117,14 +118,11 @@ async function isDirectory(dir) {
117
118
  export async function serverCommand(env, platform = process.platform) {
118
119
  return (await findProgram("cavelon", env, platform, [".exe"])) ? INSTALLED_MCP_COMMAND : mcpCommand(platform);
119
120
  }
120
- function knownCommands() {
121
- return [INSTALLED_MCP_COMMAND, mcpCommand("linux"), mcpCommand("win32")];
122
- }
123
121
  function jsonEntry(mcp, command) {
124
122
  return { ...mcp.extra, command: command.command, args: command.args };
125
123
  }
126
124
  function isOwnJsonEntry(mcp, value) {
127
- return knownCommands().some((c) => JSON.stringify(jsonEntry(mcp, c)) === JSON.stringify(value));
125
+ return kitMcpCommands().some((c) => JSON.stringify(jsonEntry(mcp, c)) === JSON.stringify(value));
128
126
  }
129
127
  function tomlBlock(command) {
130
128
  return ["[mcp_servers.cavelon]", `command = ${JSON.stringify(command.command)}`, `args = [${command.args.map((a) => JSON.stringify(a)).join(", ")}]`].join("\n");
@@ -340,7 +340,7 @@ says who does what on the instance.
340
340
  tool_type: database_query
341
341
  scope: tenant_local
342
342
  database_query:
343
- connection: { name: shop-db, dialect: postgresql } # by name only: never a host, user or password; postgresql, mysql or mssql
343
+ connection: { name: shop-db, dialect: postgresql } # by name only: never a host, user or password; postgresql, mysql, mssql or oracle
344
344
  sql_text: SELECT number, status, shipped_at FROM orders WHERE number = :order_no AND email = :email LIMIT 5
345
345
  parameters:
346
346
  - name: order_no
@@ -419,6 +419,16 @@ says who does what on the instance.
419
419
  reads (`procedure_definition_unreadable`, `procedure_definition_writes`):
420
420
  ask the person for a read-only login with `EXECUTE` and `VIEW DEFINITION`
421
421
  on procedures that read. Where a procedure is not needed, write a `SELECT`.
422
+ - **Oracle.** On an `oracle` connection the instance also refuses PL/SQL
423
+ (`BEGIN`, `DECLARE`, `WITH FUNCTION`), transaction control, `DBMS_*` and
424
+ `UTL_*` packages, `HTTPURITYPE` and database links (`table@link`):
425
+ `forbidden_keyword` in a read, `write_statement_refused` in a write, which
426
+ also may not hold `RETURNING`. Text in `q'[…]'` literals, strings and
427
+ comments is not SQL, and one trailing semicolon is accepted. Bound rows with
428
+ `FETCH FIRST n ROWS ONLY`. `cavelon validate` warns of these in one
429
+ `SELECT`/`WITH` read or `INSERT`/`UPDATE`/`DELETE` write; a PL/SQL block,
430
+ another first keyword or several statements get no local warning, and the
431
+ instance refuses them when it saves the query.
422
432
  - `cavelon explain <code>` explains every code the connector uses: what
423
433
  `validate` and the preview name, the codes of a failed call (`timeout`,
424
434
  `identity_required`, …) and of a connection test.
@@ -441,7 +451,8 @@ parameters and replace the SQL and write settings with:
441
451
  ```
442
452
 
443
453
  One `INSERT`, `UPDATE` or `DELETE`; `UPDATE`/`DELETE` need a parameterized
444
- `WHERE`. Upserts and `RETURNING`/`OUTPUT` are allowed, a leading `WITH` and
454
+ `WHERE`. Upserts and `RETURNING`/`OUTPUT` are allowed (not `RETURNING` on
455
+ Oracle), a leading `WITH` and
445
456
  multiple statements are not (`write_statement_refused`). On SQL Server one
446
457
  `EXEC` of a writing procedure is allowed, subject to the instance's
447
458
  `write_procedure_definition_refused` checks, including no transaction
@@ -132,8 +132,9 @@ use it when you parse the result.
132
132
  in the Admin; preserve `credential_required_for_target_change`.
133
133
  Older instances may lack these routes or keep management person-only;
134
134
  follow their published gate and direct a person to their dashboard.
135
- The dialects are `postgresql`, `mysql` and
136
- `mssql` (SQL Server). A SQL Server login that can write keeps the
135
+ The dialects are `postgresql`, `mysql`,
136
+ `mssql` (SQL Server) and `oracle`; an instance accepts those its OpenAPI
137
+ publishes. A SQL Server login that can write keeps the
137
138
  connection's queries from running (`write_privileges_unacknowledged`) until
138
139
  it may only read or the Owner acknowledges it in the Admin, so ask for a
139
140
  read-only login. A stored-procedure query (`EXEC`, SQL Server only) needs
@@ -180,6 +180,11 @@ the Admin. Then:
180
180
  identity parameters included; it shows what the model would see. A list
181
181
  parameter's value is a JSON array: `--value 'skus=["X-1","X-2"]'`. Never put
182
182
  a real customer's data into a test file.
183
+ - An Oracle query is test-run the same way. Save-time refusals of PL/SQL,
184
+ `DBMS_*`/`UTL_*` packages, database links or a write's `RETURNING`
185
+ (`forbidden_keyword`, `write_statement_refused`) come before any test run.
186
+ `cavelon validate` warns of them in one recognizable read or write; a PL/SQL
187
+ block or several statements are refused only by the instance, on save.
183
188
  - A read stored-procedure query (SQL Server) is test-run the same way; the
184
189
  instance refuses the run while the connection's login can write or the
185
190
  procedure's definition writes or cannot be read, with a code
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.1.18",
3
+ "version": "0.2.0",
4
4
  "description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",