@lotics/cli 0.103.0 → 0.105.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
@@ -197,7 +197,7 @@ lotics knowledge rm kdc_... # archive
197
197
  ```bash
198
198
  # Scaffold / pull / deploy a Vite+React+TS app project
199
199
  lotics app create "Sales Desk" # scaffold + deploy v1
200
- lotics app pull app_... # bootstrap an existing app locally
200
+ lotics app pull app_... # bootstrap an existing app locally (incl. .lotics/*)
201
201
  lotics app deploy -m "Add quote drawer" # build + upload a new version
202
202
  lotics app versions # deploy history: version, when, who, -m message (* = live)
203
203
  lotics app versions app_... # ...for any app, without pulling it first
@@ -205,6 +205,8 @@ lotics app versions app_... # ...for any app, without pulling it
205
205
  # Regenerate .lotics/* WITHOUT a deploy: the .d.ts type companions (always) +
206
206
  # the runtime app_fields.ts (when authenticated) — F/OPT maps that address
207
207
  # fields + select options by stable display-name aliases instead of opaque ids.
208
+ # `app pull` writes both too (a deploy archive can never carry app_fields.ts);
209
+ # use this after a rename, or when a pull ran offline.
208
210
  lotics app codegen # import { F, OPT } from "../.lotics/app_fields"
209
211
 
210
212
  # Execute a bound app workflow end-to-end (inputs: inline / @file / stdin)
package/dist/src/cli.js CHANGED
@@ -35953,7 +35953,7 @@ var require_stream_readable = __commonJS({
35953
35953
  increasedAwaitDrain = false;
35954
35954
  var ret = dest.write(chunk);
35955
35955
  if (false === ret && !increasedAwaitDrain) {
35956
- if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf2(state.pipes, dest) !== -1) && !cleanedUp) {
35956
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf3(state.pipes, dest) !== -1) && !cleanedUp) {
35957
35957
  debug("false write response, pause", state.awaitDrain);
35958
35958
  state.awaitDrain++;
35959
35959
  increasedAwaitDrain = true;
@@ -36025,7 +36025,7 @@ var require_stream_readable = __commonJS({
36025
36025
  }
36026
36026
  return this;
36027
36027
  }
36028
- var index = indexOf2(state.pipes, dest);
36028
+ var index = indexOf3(state.pipes, dest);
36029
36029
  if (index === -1) return this;
36030
36030
  state.pipes.splice(index, 1);
36031
36031
  state.pipesCount -= 1;
@@ -36246,7 +36246,7 @@ var require_stream_readable = __commonJS({
36246
36246
  stream.emit("end");
36247
36247
  }
36248
36248
  }
36249
- function indexOf2(xs, x2) {
36249
+ function indexOf3(xs, x2) {
36250
36250
  for (var i2 = 0, l = xs.length; i2 < l; i2++) {
36251
36251
  if (xs[i2] === x2) return i2;
36252
36252
  }
@@ -47367,7 +47367,7 @@ function walk(node, visit) {
47367
47367
  }
47368
47368
 
47369
47369
  // src/generate_app_fields.ts
47370
- var HEADER = `// Auto-generated by 'lotics app codegen' (and app pull/dev/deploy).
47370
+ var HEADER = `// Auto-generated by 'lotics app codegen' and 'lotics app pull'.
47371
47371
  // DO NOT EDIT \u2014 regenerated from the workspace schema.
47372
47372
  //
47373
47373
  // Runtime field + option ids addressed by stable display-name aliases:
@@ -47486,7 +47486,7 @@ export type AppOptions = typeof OPT;
47486
47486
  }
47487
47487
 
47488
47488
  // src/generate_package_fields.ts
47489
- var HEADER2 = `// Auto-generated by 'lotics app codegen' (linked/published app; also app pull/dev/deploy).
47489
+ var HEADER2 = `// Auto-generated by 'lotics app codegen' and 'lotics app pull' (linked/published app).
47490
47490
  // DO NOT EDIT \u2014 regenerated from the installation's live binding.
47491
47491
  //
47492
47492
  // A package installation resolves F/OPT/ROLE at MODULE LOAD from its binding
@@ -70217,8 +70217,27 @@ export {};
70217
70217
  function workflowFilePath(projectDir, alias) {
70218
70218
  return path5.join(projectDir, WORKFLOWS_DIR, `${alias}.ts`);
70219
70219
  }
70220
+ var GLOBALS_SUFFIX = ".globals.d.ts";
70220
70221
  function workflowGlobalsPath(projectDir, alias) {
70221
- return path5.join(projectDir, WORKFLOW_GLOBALS_DIR, `${alias}.globals.d.ts`);
70222
+ return path5.join(projectDir, WORKFLOW_GLOBALS_DIR, `${alias}${GLOBALS_SUFFIX}`);
70223
+ }
70224
+ function pruneOrphanWorkflowGlobals(projectDir, declared) {
70225
+ const dir = path5.join(projectDir, WORKFLOW_GLOBALS_DIR);
70226
+ if (!fs4.existsSync(dir)) return [];
70227
+ const removed = [];
70228
+ for (const entry of fs4.readdirSync(dir)) {
70229
+ if (!entry.endsWith(GLOBALS_SUFFIX)) continue;
70230
+ const alias = entry.slice(0, -GLOBALS_SUFFIX.length);
70231
+ if (declared.has(alias)) continue;
70232
+ fs4.unlinkSync(path5.join(dir, entry));
70233
+ removed.push(alias);
70234
+ }
70235
+ return removed.sort();
70236
+ }
70237
+ function orphanWorkflowBodies(projectDir, declared) {
70238
+ const dir = path5.join(projectDir, WORKFLOWS_DIR);
70239
+ if (!fs4.existsSync(dir)) return [];
70240
+ return fs4.readdirSync(dir).filter((e) => e.endsWith(".ts") && !e.endsWith(".d.ts") && !e.endsWith(".test.ts")).map((e) => e.slice(0, -".ts".length)).filter((alias) => !declared.has(alias)).sort();
70222
70241
  }
70223
70242
  function writeWorkflowGlobals(projectDir, alias, dts) {
70224
70243
  const dir = path5.join(projectDir, WORKFLOW_GLOBALS_DIR);
@@ -70508,6 +70527,43 @@ function writeBindingAppFields(projectDir, binding) {
70508
70527
  ensureAppVitestSetup(projectDir);
70509
70528
  return file2;
70510
70529
  }
70530
+ async function writeGeneratedAppFields(client, projectDir, app, queries) {
70531
+ if (client.viewAsMemberId) {
70532
+ console.error(
70533
+ `\u26A0 Skipped .lotics/app_fields.ts \u2014 running with --view-as ${client.viewAsMemberId}. The schema is read as that member, so any table they cannot see would be silently missing from F/OPT. Re-run without --view-as to regenerate it.`
70534
+ );
70535
+ return;
70536
+ }
70537
+ try {
70538
+ if (app.package_id) {
70539
+ const binding = await client.appBinding(app.app_id);
70540
+ const fieldsPath = writeBindingAppFields(projectDir, binding);
70541
+ const count = Object.keys(binding.fields).length;
70542
+ console.error(
70543
+ `Wrote ${fieldsPath} (binding form \u2014 linked to package ${app.package_id}; ${count} field alias${count === 1 ? "" : "es"} resolved per-install)`
70544
+ );
70545
+ } else {
70546
+ const tableIds = resolveCodegenTableIds(projectDir, queries);
70547
+ const tables = await client.getWorkspaceSchema(tableIds);
70548
+ const fieldsPath = writeAppFields(projectDir, tables);
70549
+ console.error(
70550
+ `Wrote ${fieldsPath} (baked form \u2014 bespoke; ${tables.length} table${tables.length === 1 ? "" : "s"})`
70551
+ );
70552
+ }
70553
+ } catch (err2) {
70554
+ warnAppFieldsUnwritten(projectDir, err2);
70555
+ }
70556
+ }
70557
+ function warnAppFieldsUnwritten(projectDir, err2) {
70558
+ const reason = err2 instanceof Error ? err2.message : String(err2);
70559
+ if (fs4.existsSync(path5.join(projectDir, ".lotics", "app_fields.ts"))) {
70560
+ console.error(`\u26A0 Could not regenerate .lotics/app_fields.ts (${reason}). Kept the existing file.`);
70561
+ return;
70562
+ }
70563
+ console.error(
70564
+ `\u26A0 Could not generate .lotics/app_fields.ts (${reason}), and this project has none. Any source importing F/OPT will fail to build with 'Could not resolve "../../.lotics/app_fields"'. Run 'lotics app codegen' once you can reach the workspace.`
70565
+ );
70566
+ }
70511
70567
  function warnIfDeployingLinkedKit(projectDir) {
70512
70568
  const uiSrc = process.env.LOTICS_UI_SRC;
70513
70569
  if (!uiSrc) return;
@@ -70560,6 +70616,15 @@ async function appCodegen(args) {
70560
70616
  agents: meta3.agents
70561
70617
  });
70562
70618
  for (const p of dtsPaths) console.error(`Regenerated ${p}`);
70619
+ const declared = new Set(Object.keys(meta3.workflows ?? {}));
70620
+ for (const alias of pruneOrphanWorkflowGlobals(projectDir, declared)) {
70621
+ console.error(`Removed stale workflow types for ${alias} \u2014 no longer in package.json#lotics.workflows`);
70622
+ }
70623
+ for (const alias of orphanWorkflowBodies(projectDir, declared)) {
70624
+ console.error(
70625
+ `\u26A0 ${path5.join(WORKFLOWS_DIR, `${alias}.ts`)} is not declared in package.json#lotics.workflows \u2014 'workflow check' and 'workflow set' both skip it. Declare the alias or delete the file.`
70626
+ );
70627
+ }
70563
70628
  if (!args.client) {
70564
70629
  console.error(
70565
70630
  "Skipped .lotics/app_fields.ts \u2014 no workspace credentials resolved. Run authenticated (or set LOTICS_API_KEY) to regenerate field/option ids."
@@ -70568,23 +70633,14 @@ async function appCodegen(args) {
70568
70633
  }
70569
70634
  try {
70570
70635
  const app = await args.client.getApp(meta3.app_id);
70571
- if (app.package_id) {
70572
- const binding = await args.client.appBinding(meta3.app_id);
70573
- const fieldsPath = writeBindingAppFields(projectDir, binding);
70574
- const count = Object.keys(binding.fields).length;
70575
- console.error(
70576
- `Regenerated ${fieldsPath} (binding form \u2014 ${count} field alias${count === 1 ? "" : "es"} resolved per-install)`
70577
- );
70578
- } else {
70579
- const tableIds = resolveCodegenTableIds(projectDir, meta3.queries ?? {});
70580
- const tables = await args.client.getWorkspaceSchema(tableIds);
70581
- const fieldsPath = writeAppFields(projectDir, tables);
70582
- console.error(`Regenerated ${fieldsPath} (${tables.length} table${tables.length === 1 ? "" : "s"})`);
70583
- }
70584
- } catch (err2) {
70585
- console.error(
70586
- `\u26A0 Could not regenerate .lotics/app_fields.ts (${err2 instanceof Error ? err2.message : String(err2)}). Kept the existing file.`
70636
+ await writeGeneratedAppFields(
70637
+ args.client,
70638
+ projectDir,
70639
+ { app_id: meta3.app_id, package_id: app.package_id },
70640
+ meta3.queries ?? {}
70587
70641
  );
70642
+ } catch (err2) {
70643
+ warnAppFieldsUnwritten(projectDir, err2);
70588
70644
  }
70589
70645
  await refreshWorkflowGlobals(args.client, projectDir, meta3.app_id, meta3.workflows ?? {});
70590
70646
  }
@@ -70777,6 +70833,12 @@ async function appPull(client, args) {
70777
70833
  queries: app.queries ?? {},
70778
70834
  agents: app.agents ?? {}
70779
70835
  });
70836
+ await writeGeneratedAppFields(
70837
+ client,
70838
+ targetPath,
70839
+ { app_id: app.id, package_id: app.package_id },
70840
+ app.queries ?? {}
70841
+ );
70780
70842
  const workflows = app.workflows ?? {};
70781
70843
  if (Object.keys(workflows).length > 0) {
70782
70844
  const written = await writeWorkflowFiles(client, targetPath, app.id, app.name, workflows);
@@ -89672,6 +89734,93 @@ function getAttr2(el, attr) {
89672
89734
  return attrs?.[`@_${attr}`];
89673
89735
  }
89674
89736
 
89737
+ // ../ooxml/src/schema_order.ts
89738
+ var PPR_ORDER = [
89739
+ "w:pStyle",
89740
+ "w:keepNext",
89741
+ "w:keepLines",
89742
+ "w:pageBreakBefore",
89743
+ "w:framePr",
89744
+ "w:widowControl",
89745
+ "w:numPr",
89746
+ "w:suppressLineNumbers",
89747
+ "w:pBdr",
89748
+ "w:shd",
89749
+ "w:tabs",
89750
+ "w:suppressAutoHyphens",
89751
+ "w:kinsoku",
89752
+ "w:wordWrap",
89753
+ "w:overflowPunct",
89754
+ "w:topLinePunct",
89755
+ "w:autoSpaceDE",
89756
+ "w:autoSpaceDN",
89757
+ "w:bidi",
89758
+ "w:adjustRightInd",
89759
+ "w:snapToGrid",
89760
+ "w:spacing",
89761
+ "w:ind",
89762
+ "w:contextualSpacing",
89763
+ "w:mirrorIndents",
89764
+ "w:suppressOverlap",
89765
+ "w:jc",
89766
+ "w:textDirection",
89767
+ "w:textAlignment",
89768
+ "w:textboxTightWrap",
89769
+ "w:outlineLvl",
89770
+ "w:divId",
89771
+ "w:cnfStyle",
89772
+ "w:rPr",
89773
+ "w:sectPr",
89774
+ "w:pPrChange"
89775
+ ];
89776
+ var RPR_ORDER = [
89777
+ "w:rStyle",
89778
+ "w:rFonts",
89779
+ "w:b",
89780
+ "w:bCs",
89781
+ "w:i",
89782
+ "w:iCs",
89783
+ "w:caps",
89784
+ "w:smallCaps",
89785
+ "w:strike",
89786
+ "w:dstrike",
89787
+ "w:outline",
89788
+ "w:shadow",
89789
+ "w:emboss",
89790
+ "w:imprint",
89791
+ "w:noProof",
89792
+ "w:snapToGrid",
89793
+ "w:vanish",
89794
+ "w:webHidden",
89795
+ "w:color",
89796
+ "w:spacing",
89797
+ "w:w",
89798
+ "w:kern",
89799
+ "w:position",
89800
+ "w:sz",
89801
+ "w:szCs",
89802
+ "w:highlight",
89803
+ "w:u",
89804
+ "w:effect",
89805
+ "w:bdr",
89806
+ "w:shd",
89807
+ "w:fitText",
89808
+ "w:vertAlign",
89809
+ "w:rtl",
89810
+ "w:cs",
89811
+ "w:em",
89812
+ "w:lang",
89813
+ "w:eastAsianLayout",
89814
+ "w:specVanish",
89815
+ "w:oMath",
89816
+ "w:rPrChange"
89817
+ ];
89818
+ function indexOf2(order) {
89819
+ return new Map(order.map((tag, i2) => [tag, i2]));
89820
+ }
89821
+ var PPR_INDEX = indexOf2(PPR_ORDER);
89822
+ var RPR_INDEX = indexOf2(RPR_ORDER);
89823
+
89675
89824
  // ../ooxml/src/formatting.ts
89676
89825
  var formattingSchema = external_exports.object({
89677
89826
  bold: external_exports.boolean().optional(),
@@ -90536,23 +90685,25 @@ var DOCUMENT_RELS_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
90536
90685
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
90537
90686
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
90538
90687
  </Relationships>`;
90539
- var SECT_PR = {
90540
- "w:sectPr": [
90541
- { "w:pgSz": [], ":@": { "@_w:w": "12240", "@_w:h": "15840" } },
90542
- {
90543
- "w:pgMar": [],
90544
- ":@": {
90545
- "@_w:top": "1440",
90546
- "@_w:right": "1440",
90547
- "@_w:bottom": "1440",
90548
- "@_w:left": "1440",
90549
- "@_w:header": "720",
90550
- "@_w:footer": "720",
90551
- "@_w:gutter": "0"
90688
+ function buildDefaultSectPr() {
90689
+ return {
90690
+ "w:sectPr": [
90691
+ { "w:pgSz": [], ":@": { "@_w:w": "12240", "@_w:h": "15840" } },
90692
+ {
90693
+ "w:pgMar": [],
90694
+ ":@": {
90695
+ "@_w:top": "1440",
90696
+ "@_w:right": "1440",
90697
+ "@_w:bottom": "1440",
90698
+ "@_w:left": "1440",
90699
+ "@_w:header": "720",
90700
+ "@_w:footer": "720",
90701
+ "@_w:gutter": "0"
90702
+ }
90552
90703
  }
90553
- }
90554
- ]
90555
- };
90704
+ ]
90705
+ };
90706
+ }
90556
90707
  var DEFAULT_HEADING_SIZES = [32, 26, 24, 22, 20, 18];
90557
90708
  function escapeXmlAttr(value) {
90558
90709
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
@@ -90648,7 +90799,7 @@ function createBlankDocx(opts) {
90648
90799
  default_font: opts?.default_font,
90649
90800
  default_font_size: opts?.default_font_size
90650
90801
  }));
90651
- const bodyElements = [{ ...SECT_PR }];
90802
+ const bodyElements = [buildDefaultSectPr()];
90652
90803
  const documentAttrs = { ...DOCUMENT_ATTRS };
90653
90804
  if (opts?.page) setPageLayout(bodyElements, opts.page);
90654
90805
  return { zip, bodyElements, documentAttrs };
@@ -29,10 +29,10 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
29
29
  | `lotics knowledge update <id> [--from <file.md> \| --content <str>] [--name <n>] [--description <d>]` | Call `update_knowledge` with **only** the provided fields (a body from --from/--content becomes `content`; the tool diffs + CASes the content change internally, so the CLI passes no `expected_content_file_id`). At least one field required; --from and --content are mutually exclusive. |
30
30
  | `lotics knowledge rm <id>` | Archive the doc via `delete_knowledge` (`{ knowledge_doc_id }`). The REST execute path does not gate `needsApproval`, so this runs unattended. |
31
31
  | `lotics app create <name> [path]` | Scaffold a Vite+React+TS custom-code app project; POST /v1/apps; npm install; vite build; upload as v1 |
32
- | `lotics app pull <app_id> [path]` | Download source archive from R2 (presigned), extract, npm install, stamp package.json's `lotics` field. With no `[path]`: refresh the cwd IN PLACE when it's already this app's own project (its manifest `app_id` matches — the documented `cd <app> && lotics app pull` flow), else clone into an `<name>/` subdir; this avoids the stray nested `./<name>/` subdir a pull-from-inside-the-app used to drop. — `workflows` and `agents` are sourced from the live App row (NOT the archived manifest), so `set_app_workflow` / `set_app_agent` authoring survives the pull. Regenerates `.lotics/app_{workflows,queries,agents}.d.ts` so `useWorkflow` / `useQuery` / `useAgentRun` stay typed. Also writes one `src/workflows/<alias>.ts` per bound workflow (faithful body from `get_app_workflow`) and one `src/agents/<alias>.md` per bound agent (its instructions, straight off the live row) — so the prose an author actually edits lives in a file, and pull always overwrites it from live, leaving no second copy to drift. A legacy workflow alias with no rendered source, or an agent with no instructions, warns and is skipped. The stamped `lotics.agents` map carries the TYPED half only (`inputs`/`outputs`/`tool_names`/`model_id`/…) — an agent's prose lives solely in its `.md`, so there is never a second local copy to desync; a stale `instructions` left by an older CLI is inert and disappears on the next pull |
32
+ | `lotics app pull <app_id> [path]` | Download source archive from R2 (presigned), extract, npm install, stamp package.json's `lotics` field. With no `[path]`: refresh the cwd IN PLACE when it's already this app's own project (its manifest `app_id` matches — the documented `cd <app> && lotics app pull` flow), else clone into an `<name>/` subdir; this avoids the stray nested `./<name>/` subdir a pull-from-inside-the-app used to drop. — `workflows` and `agents` are sourced from the live App row (NOT the archived manifest), so `set_app_workflow` / `set_app_agent` authoring survives the pull. Regenerates `.lotics/app_{workflows,queries,agents}.d.ts` so `useWorkflow` / `useQuery` / `useAgentRun` stay typed, AND the runtime `.lotics/app_fields.ts` (the same linked-vs-bespoke branch `app codegen` runs, off the app row already fetched — see that row for the two forms). That one is not optional: `app deploy` tars source with `--exclude=.lotics`, so no archive can carry it, and a pulled project whose `src/` imports `F`/`OPT` would fail to build with `Could not resolve "../../.lotics/app_fields"` until `app codegen` was run by hand. The write NAMES the form and the reason, because an in-place pull can FLIP a project between them (`opctl app publish` links an origin, `package eject` unlinks it) and that changes what the module does at load. Skipped under `--view-as` (the schema is read as that member and silently drops tables they cannot see — a narrowed `F` map compiles and then throws at runtime, worse than the missing module). A binding/schema fetch failure is non-fatal and names the right recovery for what is on disk: an existing file is kept, an ABSENT one warns about the build error and points at `app codegen`. Pull GENERATES but never RECONCILES `.lotics/` — deleting a companion whose alias the manifest no longer declares is `app codegen`'s alone, since pull's authority is the server's alias set and a declared-but-not-yet-`set` alias is supported. Also writes one `src/workflows/<alias>.ts` per bound workflow (faithful body from `get_app_workflow`) and one `src/agents/<alias>.md` per bound agent (its instructions, straight off the live row) — so the prose an author actually edits lives in a file, and pull always overwrites it from live, leaving no second copy to drift. A legacy workflow alias with no rendered source, or an agent with no instructions, warns and is skipped. The stamped `lotics.agents` map carries the TYPED half only (`inputs`/`outputs`/`tool_names`/`model_id`/…) — an agent's prose lives solely in its `.md`, so there is never a second local copy to desync; a stale `instructions` left by an older CLI is inert and disappears on the next pull |
33
33
  | `lotics app deploy -m <message>` | **`-m` is REQUIRED** (CLI errors without a non-empty message) — each deploy is a version row read back by `lotics app versions`, so a blank message loses the audit trail. npm run build; tar source + dist; POST /v1/apps/{id}/versions multipart. Carries code + capabilities only — **neither queries nor workflow/agent bindings are a deploy concern** (`set_app_workflow` / `remove_app_workflow` own `apps.workflows`; the manifest's `workflows` map is a pulled reflection, read by `useWorkflow` codegen and by `app workflow set`, never written by a deploy). Deploy DOES send the manifest's `lotics.workflows` alias KEYS (not the bindings) as `workflow_aliases`, recorded on the version row so `remove_app_workflow` can refuse to unbind an alias the served version still declares. It also reports any `lotics.queries` alias whose declaration DIFFERS from the app's, naming both recoveries (`app query set --all` to push yours, `app pull` to adopt the app's) — a deploy no longer writes them, so the two are allowed to drift. After a successful deploy it **warns loudly about any alias the source CALLS that is NOT bound on the server** (a `getApp` diff via `warnIfUnboundAliases`) — since deploy never binds them, that would otherwise throw only at the app's first `useWorkflow` / `useAgentRun` call; the warning points to `lotics app workflow set` / `set_app_agent`. Advisory only (never fails the deploy). |
34
34
  | `lotics app versions [app_id]` | `GET /v1/apps/{id}/versions` — print deploy history newest-first (version number, timestamp, deployer name, build status, the `-m` message; `*` marks the currently-served version). app_id from the local manifest, or pass one to inspect any app without pulling it. Admin-only server-side (mirrors deploy + source download). Answers "what shipped, when, by whom" — e.g. whether a fix was live at an incident's time. The deploy pipeline already persisted all of this in `app_versions`; this is the read surface. Title → stderr, table → stdout (pipeable). |
35
- | `lotics app codegen [path]` | Regenerate `.lotics/*` from the manifest + workspace schema **without a deploy**. The three `.d.ts` companions (`app_{workflows,queries,agents}.d.ts`) are always rewritten (synchronous, no network). When credentials resolve, also rewrites the **runtime** `.lotics/app_fields.ts` — **branched on whether the app is a package installation** (`getApp().package_id` set, from `generate_package_fields.ts`): a **linked/published** app emits the BINDING form (`F`/`OPT`/`ROLE` resolved from the installation's LIVE binding — via `appBinding` / the `binding` RPC — at module load through `getAppBinding()` + top-level await, so the source stays portable across every install); a **bespoke** app emits the BAKED form (`generate_app_fields.ts`) — a real `.ts` exporting `F` (table→field→`"fld_…"`) + `OPT` (table→select-field→option→`"opt_…"`) keyed by display-name aliases, for the tables the app's queries reference (+ optional `package.json#lotics.codegen.tables` allowlist). Both forms share the `F`/`OPT` shape (contract aliases derive from the same slugified display names), so a published origin's deployed source compiles unchanged. Writing the BINDING form also heals the project's vitest setup (`ensureAppVitestSetup`, folded into the same write boundary): the binding form awaits `getAppBinding()` (a network call) at module load, so without a stub `npm test` fails to collect any test that imports the app graph — the heal writes `vitest.setup.ts` (mocks only `getAppBinding`, returning an echo binding: any alias → a self-identifying `fld:test:…`/`opt:test:…`/`grp:test:…` id) if absent, and warns the one-liner to add to `vite.config.ts`'s `test.setupFiles` if the wiring is missing (TS source isn't safely munged, mirroring `ensureAppTsconfig`'s JSONC-tsconfig warn). New scaffolds ship both. Also refreshes each bound workflow's `.lotics/workflows/<alias>.globals.d.ts` + re-wraps its EXISTING `src/workflows/<alias>.ts` body in the current envelope (strips + re-wraps; never re-fetches the body, so local edits survive). A getApp / binding / schema / dts-fetch failure is non-fatal (warns, keeps the last-generated files). |
35
+ | `lotics app codegen [path]` | Regenerate `.lotics/*` from the manifest + workspace schema **without a deploy**. The three `.d.ts` companions (`app_{workflows,queries,agents}.d.ts`) are always rewritten (synchronous, no network). When credentials resolve, also rewrites the **runtime** `.lotics/app_fields.ts` — **branched on whether the app is a package installation** (`getApp().package_id` set, from `generate_package_fields.ts`): a **linked/published** app emits the BINDING form (`F`/`OPT`/`ROLE` resolved from the installation's LIVE binding — via `appBinding` / the `binding` RPC — at module load through `getAppBinding()` + top-level await, so the source stays portable across every install); a **bespoke** app emits the BAKED form (`generate_app_fields.ts`) — a real `.ts` exporting `F` (table→field→`"fld_…"`) + `OPT` (table→select-field→option→`"opt_…"`) keyed by display-name aliases, for the tables the app's queries reference (+ optional `package.json#lotics.codegen.tables` allowlist). Both forms share the `F`/`OPT` shape (contract aliases derive from the same slugified display names), so a published origin's deployed source compiles unchanged. Writing the BINDING form also heals the project's vitest setup (`ensureAppVitestSetup`, folded into the same write boundary): the binding form awaits `getAppBinding()` (a network call) at module load, so without a stub `npm test` fails to collect any test that imports the app graph — the heal writes `vitest.setup.ts` (mocks only `getAppBinding`, returning an echo binding: any alias → a self-identifying `fld:test:…`/`opt:test:…`/`grp:test:…` id) if absent, and warns the one-liner to add to `vite.config.ts`'s `test.setupFiles` if the wiring is missing (TS source isn't safely munged, mirroring `ensureAppTsconfig`'s JSONC-tsconfig warn). New scaffolds ship both. Also refreshes each bound workflow's `.lotics/workflows/<alias>.globals.d.ts` + re-wraps its EXISTING `src/workflows/<alias>.ts` body in the current envelope (strips + re-wraps; never re-fetches the body, so local edits survive). **`.lotics/` is reconciled to the manifest, not merely added to** — a `<alias>.globals.d.ts` whose alias the manifest no longer declares is DELETED (that directory is read as the app's alias inventory, so a companion for a binding nobody can reach misreports what the app has). Only that exact filename shape is removed; anything else in the directory is left alone. The reconcile runs before the credential branch, so it happens offline too. The authored counterpart is never deleted — a `src/workflows/<alias>.ts` the manifest does not declare is NAMED instead (`check` and `set` both take their alias set from the manifest, so editing an undeclared body is a silent no-op). A getApp / binding / schema / dts-fetch failure is non-fatal (warns, keeps the last-generated files). |
36
36
  | `lotics app workflow run <alias> '<json>'` | Execute a bound app workflow end-to-end via `appWorkflow`. `app_id` comes from the local manifest; the alias must be bound (`set_app_workflow`). Inputs ingest exactly like `lotics run` (inline JSON / `@file` / stdin — bulk inputs bypass `ARG_MAX`). Prints the full `{status,message,data,files,side_effects}` JSON to stdout + a one-line summary to stderr; exits non-zero on `status:"error"` (assertable). `--print-created` (alias `--report-effects`) renders the honest post-run harvest (GAP-58): created records grouped by table, a paste-ready `lotics run delete_records …` per table, then the **mandatory caveat** naming what cannot be auto-undone (external integrations + notifications) and that sub-workflows may have run. `--cleanup` (DEFAULT OFF, implies the report) additionally runs the deletes for harvested records ONLY — never files / external / notifications. Neither is a rollback — a rollback is structurally impossible here. |
37
37
  | `lotics app workflow set <alias>` | Push the edited `src/workflows/<alias>.ts` body through `set_app_workflow` (the single author of `apps.workflows`). Reads the body from disk (header + `/// <reference>` + `export {};` marker + the `__workflow` wrapper all stripped) + the typed `inputs`/`outputs` **and the `description`** from `package.json#lotics.workflows.<alias>`; the **server** re-verifies the body and echoes the bound `outputs` (declared, else DERIVED from `return({ data })`). The `description` is the one line an agent reads when choosing between the app's aliases (the workflow counterpart to a query's) — authored in the manifest so it lives beside the body in version control and rides every push; omit it and the workflow keeps whatever description it already has, so a push can never blank one set elsewhere. When the manifest declared NO `outputs`, the DERIVED echo is written back into `package.json#lotics.workflows.<alias>.outputs` (a SURGICAL write — preserves `knowledge`/`config` and every other manifest field) and that alias's types are refreshed in place, so `useWorkflow("<alias>")`'s `result.data` is typed immediately with no hand-copy and no second `lotics app codegen`; an explicitly-declared `outputs` is authoritative and never overwritten. Deploy still never authors workflows — this is a CLI convenience over the existing tool. Clear error + non-zero exit on a missing file, an alias absent from the manifest, or a verify failure. |
38
38
  | `lotics app agent set <alias>` | Push the edited `src/agents/<alias>.md` instructions back through `set_app_agent` — the agent mirror of `app workflow set`, and the deploy-free authoring path for `apps.agents`. Reads the prose from disk (the `<!-- lotics: … -->` header stripped) and the typed fields (`inputs`/`outputs`/`tool_names`/`model_id`/`effort_level`/`knowledge_doc_ids`/`query_aliases`/`workflow_aliases`) from `package.json#lotics.agents.<alias>`, then sends them as ONE declaration. That assembly is the point: **`set_app_agent` REPLACES the declaration rather than patching it**, so a hand-built payload that sets one field silently drops the instructions, the output schema and the model pin — a silent, unrecoverable edit against a live prompt. Clear error + non-zero exit on a missing file, an alias absent from the manifest, or a file that is empty once the header is stripped (refusing to push an empty prompt). `app pull` writes the file; edit, then `set`. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/cli",
3
- "version": "0.103.0",
3
+ "version": "0.105.0",
4
4
  "description": "Lotics SDK and CLI for AI agents",
5
5
  "type": "module",
6
6
  "bin": {