orbit-code-ai 0.1.35 → 0.1.36

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 (2) hide show
  1. package/dist/cli.mjs +118 -55
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -83759,7 +83759,7 @@ async function printStartupScreen() {
83759
83759
  const sLen = ` ● ${sL} Ready — type /help to begin`.length;
83760
83760
  out.push(boxRow(sRow, W2, sLen));
83761
83761
  out.push(`${rgb(...BORDER)}╚${"═".repeat(W2 - 2)}╝${RESET}`);
83762
- out.push(` ${DIM}${rgb(...DIMCOL)}orbit-code ${RESET}${rgb(...ACCENT)}v${"0.1.35"}${RESET}`);
83762
+ out.push(` ${DIM}${rgb(...DIMCOL)}orbit-code ${RESET}${rgb(...ACCENT)}v${"0.1.36"}${RESET}`);
83763
83763
  out.push("");
83764
83764
  process.stdout.write(out.join(`
83765
83765
  `) + `
@@ -334266,7 +334266,7 @@ function getAnthropicEnvMetadata() {
334266
334266
  function getBuildAgeMinutes() {
334267
334267
  if (false)
334268
334268
  ;
334269
- const buildTime = new Date("2026-07-01T09:45:32.083Z").getTime();
334269
+ const buildTime = new Date("2026-07-01T10:12:07.638Z").getTime();
334270
334270
  if (isNaN(buildTime))
334271
334271
  return;
334272
334272
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -358683,7 +358683,7 @@ function buildPrimarySection() {
358683
358683
  }, undefined, false, undefined, this);
358684
358684
  return [{
358685
358685
  label: "Version",
358686
- value: "0.1.35"
358686
+ value: "0.1.36"
358687
358687
  }, {
358688
358688
  label: "Session name",
358689
358689
  value: nameValue
@@ -470794,7 +470794,7 @@ function WelcomeV2() {
470794
470794
  dimColor: true,
470795
470795
  children: [
470796
470796
  "v",
470797
- "0.1.35",
470797
+ "0.1.36",
470798
470798
  " "
470799
470799
  ]
470800
470800
  }, undefined, true, undefined, this)
@@ -470994,7 +470994,7 @@ function WelcomeV2() {
470994
470994
  dimColor: true,
470995
470995
  children: [
470996
470996
  "v",
470997
- "0.1.35",
470997
+ "0.1.36",
470998
470998
  " "
470999
470999
  ]
471000
471000
  }, undefined, true, undefined, this)
@@ -471220,7 +471220,7 @@ function AppleTerminalWelcomeV2(t0) {
471220
471220
  dimColor: true,
471221
471221
  children: [
471222
471222
  "v",
471223
- "0.1.35",
471223
+ "0.1.36",
471224
471224
  " "
471225
471225
  ]
471226
471226
  }, undefined, true, undefined, this);
@@ -471474,7 +471474,7 @@ function AppleTerminalWelcomeV2(t0) {
471474
471474
  dimColor: true,
471475
471475
  children: [
471476
471476
  "v",
471477
- "0.1.35",
471477
+ "0.1.36",
471478
471478
  " "
471479
471479
  ]
471480
471480
  }, undefined, true, undefined, this);
@@ -510010,6 +510010,35 @@ async function describeProcedure(conn, schema, name) {
510010
510010
  }
510011
510011
  return { schema, name, params, resultSet, resultSetUndescribable };
510012
510012
  }
510013
+ async function findProcedures(conn, name) {
510014
+ const bare = name.replace(/^.*\./, "");
510015
+ const rows = await runQuery(conn, `SELECT s.name AS [schema],
510016
+ p.name AS [name],
510017
+ CAST(ISNULL(OBJECTPROPERTY(p.object_id, 'IsEncrypted'), 0) AS INT) AS [isEncrypted],
510018
+ CAST(HAS_PERMS_BY_NAME(QUOTENAME(s.name) + N'.' + QUOTENAME(p.name),
510019
+ 'OBJECT', 'VIEW DEFINITION') AS INT) AS [canViewDef]
510020
+ FROM sys.procedures p
510021
+ JOIN sys.schemas s ON p.schema_id = s.schema_id
510022
+ WHERE p.name = @name
510023
+ ORDER BY CASE WHEN s.name = 'dbo' THEN 0 ELSE 1 END, s.name`, [{ name: "name", type: "NVarChar", value: bare }]);
510024
+ return rows.map((r) => ({
510025
+ schema: String(r.schema),
510026
+ name: String(r.name),
510027
+ isEncrypted: Number(r.isEncrypted) === 1,
510028
+ canViewDefinition: Number(r.canViewDef) === 1
510029
+ }));
510030
+ }
510031
+ async function getDbContext(conn) {
510032
+ const rows = await runQuery(conn, `SELECT DB_NAME() AS [database],
510033
+ SUSER_SNAME() AS [login],
510034
+ (SELECT COUNT(*) FROM sys.procedures) AS [visibleProcCount]`);
510035
+ const r = rows[0] ?? {};
510036
+ return {
510037
+ database: String(r.database ?? "(unknown)"),
510038
+ login: String(r.login ?? "(unknown)"),
510039
+ visibleProcCount: Number(r.visibleProcCount ?? 0)
510040
+ };
510041
+ }
510013
510042
  async function getProcedureDefinition(conn, schema, name) {
510014
510043
  const rows = await runQuery(conn, `SELECT OBJECT_DEFINITION(OBJECT_ID(@obj)) AS definition`, [{ name: "obj", type: "NVarChar", value: `${schema}.${name}` }]);
510015
510044
  const def2 = rows[0]?.definition;
@@ -510191,11 +510220,52 @@ ${params}
510191
510220
  First result set:
510192
510221
  ${cols}${GROUND}`;
510193
510222
  }
510223
+ async function resolveProc(conn, schema, name) {
510224
+ let matches;
510225
+ try {
510226
+ matches = await findProcedures(conn, name);
510227
+ } catch {
510228
+ return { schema, name };
510229
+ }
510230
+ if (matches.length === 0)
510231
+ return { schema, name };
510232
+ const exact = matches.find((m) => m.schema.toLowerCase() === schema.toLowerCase());
510233
+ const readable2 = matches.find((m) => m.canViewDefinition && !m.isEncrypted);
510234
+ const chosen = exact ?? readable2 ?? matches[0];
510235
+ return { schema: chosen.schema, name: chosen.name };
510236
+ }
510237
+ async function diagnoseMissingProc(conn, name) {
510238
+ let matches;
510239
+ let ctx;
510240
+ try {
510241
+ [matches, ctx] = await Promise.all([
510242
+ findProcedures(conn, name),
510243
+ getDbContext(conn)
510244
+ ]);
510245
+ } catch (e2) {
510246
+ return `Could not read "${name}", and the diagnostic query also failed: ${e2.message}. Ask the user to re-check the /sql connection.`;
510247
+ }
510248
+ const where = `database "${ctx.database}" as login "${ctx.login}" (${ctx.visibleProcCount} procedure(s) visible to this login)`;
510249
+ if (matches.length === 0) {
510250
+ return `No stored procedure named "${name}" is VISIBLE in ${where}. SQL Server hides objects a login has no permission on, so this means EITHER it does not exist in this database OR the connected login cannot see it. Do NOT tell the user the procedure "doesn't exist" — instead: (1) confirm the connection is on the right database (run /sql status); (2) confirm this login has VIEW DEFINITION / metadata access, or reconnect with a login that does. Then retry.`;
510251
+ }
510252
+ const lines = matches.map((m) => ` - ${m.schema}.${m.name}${m.isEncrypted ? " [WITH ENCRYPTION]" : ""}${m.canViewDefinition ? "" : " [login lacks VIEW DEFINITION]"}`).join(`
510253
+ `);
510254
+ const readable2 = matches.find((m) => m.canViewDefinition && !m.isEncrypted);
510255
+ const guidance = readable2 ? `It IS present and readable as ${readable2.schema}.${readable2.name} — re-run with that exact schema-qualified name.` : matches.some((m) => m.isEncrypted) ? `It exists but is defined WITH ENCRYPTION; its T-SQL cannot be read. Tell the user the source is unavailable.` : `It exists but login "${ctx.login}" lacks VIEW DEFINITION on it. Grant VIEW DEFINITION or reconnect with a privileged login.`;
510256
+ return `"${name}" was found in ${where}, under:
510257
+ ${lines}
510258
+
510259
+ ${guidance}`;
510260
+ }
510194
510261
  async function runSource(conn, schema, name) {
510195
- const def2 = await getProcedureDefinition(conn, schema, name);
510262
+ const r = await resolveProc(conn, schema, name);
510263
+ const def2 = await getProcedureDefinition(conn, r.schema, r.name);
510196
510264
  if (!def2) {
510197
- return `Could not read the source of ${schema}.${name}. Either it does not exist, or it is defined WITH ENCRYPTION (OBJECT_DEFINITION returns NULL for encrypted procedures). Do not guess its contents — tell the user it is unavailable.`;
510265
+ return await diagnoseMissingProc(conn, name);
510198
510266
  }
510267
+ schema = r.schema;
510268
+ name = r.name;
510199
510269
  const MAX = 24000;
510200
510270
  const body = def2.length > MAX ? `${def2.slice(0, MAX)}
510201
510271
  -- …[truncated; ${def2.length} chars total]…` : def2;
@@ -510265,42 +510335,39 @@ ${lines}
510265
510335
 
510266
510336
  These are ACTUAL values from the database. Use them exactly as returned — never alter, round, or invent field values. State only what appears above; if a value is not shown, say it is not shown.`;
510267
510337
  }
510268
- async function runTestData(conn, schema, name, caseHint) {
510269
- const def2 = await getProcedureDefinition(conn, schema, name);
510270
- if (!def2) {
510271
- return `Could not read the source of ${schema}.${name} (missing or WITH ENCRYPTION). Without the real T-SQL I cannot know which tables/columns to sample. Ask the user for the correct procedure name (try /sql procs) — do NOT guess test data.`;
510272
- }
510273
- const sp = await describeProcedure(conn, schema, name);
510274
- const params = sp.params.map((p) => ` - ${p.isOutput ? "OUT" : "IN "} @${p.name} : ${p.dataType}${p.maxLength ? `(${p.maxLength})` : ""}`).join(`
510275
- `) || " (no parameters)";
510276
- const MAX = 24000;
510277
- const body = def2.length > MAX ? `${def2.slice(0, MAX)}
510278
- -- …[truncated]…` : def2;
510338
+ function runTestData(appName, caseHint) {
510279
510339
  const wanted = caseHint || "happy";
510280
- return `Goal: produce REAL, runnable test-data for a "${wanted}" case, expressed as the application's input body.
510340
+ return `Goal: produce REAL, runnable "${wanted}" test-data for the ACE application "${appName}", expressed as the application's request input body.
510281
510341
 
510282
- Ground truth for ${schema}.${name} (live database):
510342
+ IMPORTANT: "${appName}" is an APPLICATION name (a project/folder in this workspace), NOT a stored procedure. One application typically calls one OR MORE stored procedures — you must find them ALL and gather test data for each.
510283
510343
 
510284
- Parameters (these are what the SP consumes — trace each back to a request-body field):
510285
- ${params}
510344
+ Do this, in order:
510286
510345
 
510287
- Actual T-SQL source:
510288
- \`\`\`sql
510289
- ${body}
510290
- \`\`\`
510346
+ 1. Locate the application in the workspace. Glob for its folder (e.g. \`**/${appName}/**\`); its ESQL lives under \`.../com/qiwa/esb/<appnamelowercase>/*.esql\` and its contract under \`.../${appName}/XSD&Swagger/\`.
510347
+ - If NO application named "${appName}" exists but a stored procedure by that name does, fall back to treating it as a single SP.
510291
510348
 
510292
- Do this, in order:
510293
- 1. From the T-SQL above, identify the driving table(s) and the WHERE/branch conditions the input parameters flow into. For a "${wanted}" case:
510294
- - happy → conditions that make the SP's main/success path return a row.
510295
- - error/not-found a key that does NOT exist, or values that hit the SP's empty-result / validation branch.
510296
- - boundary real extremes (e.g. longest value, min/max, nullable edges) drawn from the actual data.
510297
- 2. Write ONE read-only SELECT that pulls a REAL row supplying the parameter values for that case (e.g. \`SELECT TOP 1 <param-columns> FROM <table> WHERE <branch conditions>\`). It MUST be a single SELECT/CTE — no other statements.
510298
- 3. Run it by invoking the /sql skill with: query <your SELECT>
510299
- (This executes it against the live DB through the read-only gate and returns the actual rows.)
510300
- 4. Take the returned real values and map each SP parameter back to its request-body field by reading this project's ESQL (Grep the working directory for "${name}" to find the CALL and the field-to-parameter mapping) and the app's XSD (the input body field names).
510301
- 5. Return the finished input body (XML matching the app's request schema) with the concrete real values filled in, and show the exact SELECT you ran so the developer can see where each value came from.
510302
-
510303
- Data-handling notice (state this once to the user): these values are REAL data pulled from the connected database and may include personal/production data. Return them as-is; do not fabricate or substitute values. If the SELECT returns no rows, say so plainly — for a happy case it means no qualifying data exists; do not invent a row.`;
510349
+ 2. Read the app's REQUEST contract: its XSD (\`XSD&Swagger/XSD/${appName}.xsd\`) → the input-body field names and types; skim the msgflow/ESQL to see how the request is shaped.
510350
+
510351
+ 3. Enumerate EVERY stored procedure the app calls. Grep the app's ESQL for:
510352
+ - \`EXTERNAL NAME "<schema>.<proc>"\` (LANGUAGE DATABASE procedure declarations), and their CALL sites,
510353
+ - any PASSTHRU / Database-node inline SQL.
510354
+ Collect the real \`schema.proc\` for each. List them for the user before continuing.
510355
+
510356
+ 4. For EACH stored procedure found:
510357
+ a. Fetch its REAL T-SQL by invoking the /sql skill with: source <schema.proc>
510358
+ (If the source is unavailable encrypted or no VIEW DEFINITION say so for that SP and skip to the next; do not fabricate its logic.)
510359
+ b. From that source, identify the driving table(s) and the WHERE/branch conditions the SP's input parameters flow into, for a "${wanted}" case:
510360
+ - happy → values that make the SP's main/success path return a row.
510361
+ - error/not-found → a key that does NOT exist, or values that hit the empty-result / validation branch.
510362
+ - boundary → real extremes (longest value, min/max, nullable edges) drawn from the actual data.
510363
+ c. Write ONE read-only SELECT that pulls a REAL row supplying those parameter values, and run it by invoking the /sql skill with: query <your SELECT>
510364
+ (single SELECT/CTE only; it runs through the read-only gate and returns actual rows).
510365
+
510366
+ 5. Combine the real values from all the SPs and map them back onto the app's REQUEST input-body fields — trace each SP parameter to the request field that feeds it (via the ESQL field→parameter mapping) and use the XSD field names.
510367
+
510368
+ 6. Return the finished request input body (XML matching the app's request schema) with concrete REAL values filled in. Then, per SP, show the exact SELECT you ran so the developer can see exactly where each value came from.
510369
+
510370
+ Data-handling notice (state once): these are REAL values from the connected database and may include personal/production data. Return them as-is; never fabricate. If a SELECT returns no rows, say so plainly — for a happy case it means no qualifying data exists; do not invent a row. If the app calls no stored procedures at all, build the input body from the XSD types alone and clearly mark those values as synthetic (no DB row backs them).`;
510304
510371
  }
510305
510372
  async function handle(args) {
510306
510373
  const trimmed = args.trim();
@@ -510403,16 +510470,12 @@ Do NOT attempt to answer database questions — you have no connection or data.`
510403
510470
  }
510404
510471
  if (firstTok === "testdata" || firstTok === "test-data") {
510405
510472
  if (!restStr)
510406
- return "Usage: /sql testdata <schema.proc|AppName> [happy|error|boundary] [notes]";
510407
- const tokens = restStr.split(/\s+/);
510408
- const target = extractProcName(restStr) ?? tokens[0];
510409
- const { schema: schema2, name: name2 } = splitProc(target);
510410
- const caseHint = restStr.match(/\b(happy|error|not[- ]?found|boundary|edge)\b/i)?.[1] ?? "";
510411
- try {
510412
- return await runTestData(conn, schema2, name2, caseHint.toLowerCase());
510413
- } catch (e2) {
510414
- return `Failed to prepare test data for ${schema2}.${name2}: ${e2.message}`;
510415
- }
510473
+ return "Usage: /sql testdata <AppName> [happy|error|boundary] (AppName is the ACE application, not a stored procedure)";
510474
+ const caseMatch = restStr.match(/\b(happy|error|not[- ]?found|boundary|edge)\b/i);
510475
+ const caseHint = caseMatch?.[1]?.toLowerCase() ?? "";
510476
+ const withoutCase = caseMatch ? restStr.replace(caseMatch[0], " ") : restStr;
510477
+ const appName = withoutCase.trim().split(/\s+/)[0].replace(/[[\]"';,]/g, "");
510478
+ return runTestData(appName, caseHint);
510416
510479
  }
510417
510480
  const intent = inferIntent(trimmed);
510418
510481
  if (intent === "list" && !extractProcName(trimmed)) {
@@ -510443,7 +510506,7 @@ function registerSqlSkill() {
510443
510506
  registerBundledSkill({
510444
510507
  name: "sql",
510445
510508
  description: "Connect to a SQL Server database (read-only) to list/describe stored procedures, generate the ESQL SP call, verify how an ACE app calls an SP, or produce real test-data input for an application from live tables — all from live DB metadata and gated read-only SELECTs.",
510446
- whenToUse: "When the user asks about the SQL database, stored procedures (their inputs/outputs), wants an ESQL stored-procedure CALL generated from the DB, wants to verify SP parameters used inside an ACE application, or wants real test-data (a happy/error/boundary input body) for an application built from actual rows in the database.",
510509
+ whenToUse: "When the user asks about the SQL database, stored procedures (their inputs/outputs), wants an ESQL stored-procedure CALL generated from the DB, wants to verify SP parameters used inside an ACE application, or wants real test-data for an ACE APPLICATION (a happy/error/boundary request input body) discovering every SP the app calls and sampling actual rows from the database.",
510447
510510
  argumentHint: "connect|status|procs|describe|gen|verify|testdata|query … (or plain English)",
510448
510511
  userInvocable: true,
510449
510512
  allowedTools: ["Read", "Glob", "Grep"],
@@ -510475,7 +510538,7 @@ Subcommands (also understands plain English, e.g. "/sql details of the SP Get_Us
510475
510538
  - \`/sql source <schema.proc>\` — the actual T-SQL body of the procedure (read the real code).
510476
510539
  - \`/sql gen <schema.proc>\` — generate the ESQL PROCEDURE declaration + CALL.
510477
510540
  - \`/sql verify <schema.proc>\` — pull the real SP signature, then check how this project's ESQL calls it.
510478
- - \`/sql testdata <schema.proc|AppName> [happy|error|boundary] [notes]\` — read the SP's real T-SQL, pull a REAL matching row from the database, and return it as the application's input body.
510541
+ - \`/sql testdata <AppName> [happy|error|boundary]\` — for an ACE APPLICATION, find EVERY stored procedure it calls, read each SP's real T-SQL, pull REAL matching rows from the database, and return the application's request input body.
510479
510542
  - \`/sql query <SELECT …>\` — run one read-only SELECT (SELECT/CTE only, capped to ${READONLY_ROW_CAP} rows). Used by /sql testdata to fetch real rows.
510480
510543
 
510481
510544
  Metadata/verify/gen are read-only catalog lookups. \`testdata\`/\`query\` execute a single gated SELECT against real tables and return ACTUAL data (which may include personal/production data).`;
@@ -527130,7 +527193,7 @@ Usage: orbit --remote "your task description"`, () => gracefulShutdown(1));
527130
527193
  pendingHookMessages
527131
527194
  }, renderAndRun);
527132
527195
  }
527133
- }).version("0.1.35 (Orbit AI)", "-v, --version", "Output the version number");
527196
+ }).version("0.1.36 (Orbit AI)", "-v, --version", "Output the version number");
527134
527197
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
527135
527198
  program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
527136
527199
  if (canUserConfigureAdvisor()) {
@@ -527652,7 +527715,7 @@ if (false) {}
527652
527715
  async function main2() {
527653
527716
  const args = process.argv.slice(2);
527654
527717
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
527655
- console.log(`${"0.1.35"} (Orbit AI)`);
527718
+ console.log(`${"0.1.36"} (Orbit AI)`);
527656
527719
  return;
527657
527720
  }
527658
527721
  if (args.includes("--provider")) {
@@ -527756,4 +527819,4 @@ async function main2() {
527756
527819
  }
527757
527820
  main2();
527758
527821
 
527759
- //# debugId=29BC5C9893E4168464756E2164756E21
527822
+ //# debugId=AFCC06C9D77C087364756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orbit-code-ai",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "Orbit AI – Your AI-powered IBM ACE coding companion",
5
5
  "type": "module",
6
6
  "author": "moenawaf",