@lotics/cli 0.182.0 → 0.184.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/AGENTS.md CHANGED
@@ -5,7 +5,7 @@ conventions are, and where the traps are.
5
5
 
6
6
  | Read | For |
7
7
  |---|---|
8
- | `lotics --help` | The verb inventory (§ COMMANDS) and global flags. Authoritative; never stale. |
8
+ | `lotics --help` | The verb inventory (§ COMMANDS) and global flags. The verb LIST is generated and never stale; the prose beside each verb is hand-written, so where it disagrees with `docs/cli_reference.md`, the reference wins. |
9
9
  | `lotics tools` · `lotics tools <name>` | The agent tool registry and one tool's full JSON Schema. |
10
10
  | `lotics docs` · `lotics docs <area>` | Every reference the packages installed beside the project actually ship — `@lotics/app-sdk`, `@lotics/ui` and the document engines each carry their own, and this index only covers THIS package. Discovered by looking, not by a list, so it reports the installed VERSION of each: a doc always describes the code that is really there. |
11
11
  | [docs/building_an_app.md](./docs/building_an_app.md) | The SEQUENCE — scaffold, model, types, queries, workflows, screens, ship — and the deploy-free inner loop. The other references describe contracts; this one is the order they go in and why. Read it once before starting an app. |
@@ -29,7 +29,8 @@ Several capabilities exist **only** as commands and appear nowhere in `lotics to
29
29
  file and running a bound app agent are the two that most often get mistaken for missing. Concluding
30
30
  "the platform can't do X" from the tool list alone is a mistake; check both.
31
31
 
32
- ⚠️ **`lotics <subcommand> --help` prints the generic top-level help.** It does not describe the
32
+ ⚠️ **`lotics <subcommand> --help` prints the generic top-level help**, except `lotics report --help`
33
+ and a bare `lotics auth` / `xlsx` / `docx`, which print their own. It does not describe the
33
34
  subcommand, so an unhelpful response there is *not* evidence the subcommand is absent. To find out
34
35
  whether something exists, read `lotics --help` § COMMANDS — the whole section, not a narrow grep.
35
36
 
@@ -37,8 +38,9 @@ whether something exists, read `lotics --help` § COMMANDS — the whole section
37
38
 
38
39
  - **Scope is resolved per invocation.** `LOTICS_ORG` / `LOTICS_WORKSPACE` (or `LOTICS_API_KEY`) scope a
39
40
  single call without changing the active org or a directory pin — the safe way to touch one tenant
40
- from a shell serving many. Every command echoes its resolved target to **stderr** (`lotics → <org> /
41
- <workspace>`); read it back before trusting a write. Resolution precedence is in README § Organizations.
41
+ from a shell serving many. Every command that resolves a workspace echoes its target to **stderr**
42
+ (`lotics → <org> / <workspace>`); read it back before trusting a write. `file preview <fil_…>` is
43
+ the one credentialed command with no echo. Resolution precedence is in README § Organizations.
42
44
  - **Large payloads bypass `ARG_MAX`** — `lotics run <tool> @args.json` or piped stdin. A leading `@` is
43
45
  unambiguously a file path (JSON args start with `{`).
44
46
  - **stdout is the payload, stderr is the narration.** Progress, status lines, and the target echo go to
@@ -48,7 +50,8 @@ whether something exists, read `lotics --help` § COMMANDS — the whole section
48
50
  (`run_app_workflow`, `run_app_agent`, `run_app_query`). An `app` command exists only for work no
49
51
  tool call can do: scaffold, build, typecheck, serve, or read and push a local file.
50
52
  - **Exit codes are assertable, and they report the WORK rather than the call.** `lotics run` exits
51
- non-zero when the result's own envelope carries a failed `status` (`error`/`failed`/`cancelled`),
53
+ non-zero when a `run_app_workflow` or `run_app_agent` result's own envelope carries a failed
54
+ `status` (`error`/`failed`/`cancelled`) — any other tool's top-level status is data and exits 0 —
52
55
  so `lotics run … && next-step` cannot walk past a refused run; `workspace doctor` exits non-zero on
53
56
  findings. An unrecognized status exits 0 — the list is an allowlist of failure, so a status added
54
57
  later never turns a working script red — and a parked run (`awaiting_input`) is not a failure.
@@ -88,11 +91,11 @@ whether something exists, read `lotics --help` § COMMANDS — the whole section
88
91
  | `queries`, `capabilities` | the manifest | `app deploy` — re-synced on every one (an absent `capabilities` block turns them all OFF) |
89
92
  | `knowledge` | the manifest | nothing, until the app is published as a starter — it declares which docs ship with it |
90
93
  | `workflows` | the workflow row's verified contract | `app workflow set`, which type-checks the BODY against your declaration and refuses a schema the body cannot satisfy |
91
- | `agents` | the app row | **nothing.** It is a mirror: `app codegen` re-silvers it from the app, and an agent is changed with `set_app_agent` |
94
+ | `agents` | `inputs`/`outputs`: the manifest. Everything else: the app row | `app agent set`, and `app deploy`, which pushes a diverged `inputs`/`outputs` before it ships. The rest is a mirror `app codegen` re-silvers, changed with `set_app_agent` |
92
95
 
93
- `agents` is the one that bites, because editing a mirror still retypes `useAgentRun` — green
94
- locally, unchanged in production. `app codegen` reverts such an edit and `app deploy` refuses while
95
- the two disagree. An agent's PROSE is not in the manifest at all: it lives in
96
- `src/agents/<alias>.md` and is pushed by `app agent set`.
96
+ `agents` is the one that bites, because the two halves of the same block behave differently:
97
+ editing `tool_names` or `knowledge_doc_ids` still retypes `useAgentRun` — green locally, unchanged
98
+ in production, and reverted by the next `app codegen`. An agent's PROSE is not in the manifest at
99
+ all: it lives in `src/agents/<alias>.md` and is pushed by `app agent set`.
97
100
  - **OAuth connections.** Attaching a connected account is web-only; the CLI can list them.
98
101
  - **Anything needing a browser.** `app dev` and `file preview` shell out to a local Chrome.
package/README.md CHANGED
@@ -70,7 +70,7 @@ irm https://lotics.ai/install.ps1 | iex # Windows PowerShell — no No
70
70
  Re-run whichever installer you used; `npm install -g @lotics/cli@latest` updates an npm install.
71
71
  The CLI names the right one for the copy you are running when it sees a newer version.
72
72
 
73
- The CLI checks for updates once per day and prompts when a new version is available.
73
+ The CLI checks for updates once per day and prints a note on stderr, naming the right installer, when a new version is available.
74
74
 
75
75
  ## Authentication
76
76
 
@@ -94,7 +94,7 @@ lotics auth api-key # interactive prompt
94
94
  lotics auth api-key ltk_... # registers the key's org as a profile (now active)
95
95
  ```
96
96
 
97
- Run `lotics auth logout [<name|id>]` to remove a profile (default: the active org), or `lotics auth logout --all` to wipe the store.
97
+ Run `lotics auth logout [<name|id>]` to remove a profile (default: the active org), or `lotics auth logout --all` to wipe the store. Inside a pinned directory the bare form removes the **pin**, not a profile — name the org to remove its credential.
98
98
 
99
99
  ## Organizations
100
100
 
@@ -120,7 +120,7 @@ lotics workspace select wks_... # records the workspace in the local pin
120
120
 
121
121
  Each worktree resolves independently; switching the global default in another shell leaves pinned worktrees untouched. `.lotics/` should be gitignored.
122
122
 
123
- Every command names its target before it acts — `lotics → <org> / <workspace>` on **stderr**, so stdout stays clean for piping. When nothing in the directory or environment chose the org and it came from the machine-wide default, the line says so and prints the `--local` command to pin — that default is the one another shell can move between two of your commands. `lotics auth whoami` reports the same resolution on demand, including which source won.
123
+ Every command that resolves a workspace names its target before it acts — `lotics → <org> / <workspace>` on **stderr**, so stdout stays clean for piping. When nothing in the directory or environment chose the org and it came from the machine-wide default, the line says so and prints the `--local` command to pin — that default is the one another shell can move between two of your commands. `lotics auth whoami` reports the same resolution on demand, including which source won.
124
124
 
125
125
  ### Resolution precedence
126
126
 
@@ -334,7 +334,8 @@ lotics run run_app_agent '{...}' --json # full run summary to stdou
334
334
  # A run that outlives the call's bounded wait keeps going server-side; read it with
335
335
  lotics run get_app_agent_run '{"app_id":"app_abc","run_id":"run_..."}'
336
336
 
337
- # Dev-link @lotics/ui to a monorepo checkout for ONE command — nothing is written to disk
337
+ # Dev-link @lotics/ui to a monorepo checkout for ONE command — nothing hand-written is touched
338
+ # (the matching tsc `paths` land in the CLI's own .lotics/tsconfig.link.json)
338
339
  LOTICS_UI_SRC=/abs/monorepo/packages/ui/src lotics app dev
339
340
  LOTICS_UI_SRC=/abs/monorepo/packages/ui/src lotics app deploy -m "..." # warns: bundles YOUR kit copy
340
341
  lotics app dev # unset ⇒ @lotics/ui resolves from node_modules again
package/dist/src/cli.js CHANGED
@@ -44516,14 +44516,13 @@ var LoticsClient = class {
44516
44516
  return this.request("POST", "/v1/apps", body);
44517
44517
  }
44518
44518
  /**
44519
- * Retire (or `undo` un-retire) a registry package (backs `lotics app
44520
- * unpublish` — the endpoint/audit action keep the `retire` name to avoid API
44521
- * churn). Retiring refuses NEW installs and hides the package from non-owning
44522
- * orgs; existing installations keep working and may still upgrade. Owner-org
44523
- * admin-only.
44519
+ * Take a starter off the shelf, or `undo` to put it back (backs `opctl
44520
+ * starter unpublish`). It hides from non-owning orgs and can no longer be
44521
+ * copied; copies already made are unaffected — they never linked back.
44522
+ * Owner-org admin-only.
44524
44523
  */
44525
- async retirePackage(package_id, body) {
44526
- return this.request("POST", `/v1/packages/${encodeURIComponent(package_id)}/retire`, body);
44524
+ async unpublishStarter(starter_id, body) {
44525
+ return this.request("POST", `/v1/starters/${encodeURIComponent(starter_id)}/unpublish`, body);
44527
44526
  }
44528
44527
  /**
44529
44528
  * Edit a starter's registry listing — the name and description a stranger
@@ -44532,13 +44531,12 @@ var LoticsClient = class {
44532
44531
  * A version is an immutable snapshot; the listing is not. Omit a field to
44533
44532
  * leave it, pass `description: null` to clear it. Owner-org admin-only.
44534
44533
  */
44535
- async editPackageListing(package_id, body) {
44536
- return this.request("POST", `/v1/packages/${encodeURIComponent(package_id)}/listing`, body);
44534
+ async editStarterListing(starter_id, body) {
44535
+ return this.request("POST", `/v1/starters/${encodeURIComponent(starter_id)}/listing`, body);
44537
44536
  }
44538
44537
  // --- Starters (registry reads + copies) ---
44539
- // Authoring is server-side: apps via the publish job (`requestStarterPublish`),
44540
- // content starters via the `publish_content`/`release_content` tools. There is
44541
- // no client-side create-package / upload-bundle path.
44538
+ // Authoring is server-side, through the publish job (`requestStarterPublish`).
44539
+ // There is no client-side create-starter / upload-bundle path.
44542
44540
  /**
44543
44541
  * The starters this organization can copy — Lotics-reviewed ones plus its own,
44544
44542
  * never a catalogue of everything published. The server returns exactly what
@@ -44597,12 +44595,25 @@ var LoticsClient = class {
44597
44595
  * Fetch a registry starter's metadata (`latest_version` and the Lotics-backed
44598
44596
  * `is_official` trust badge). Admin-only; cross-tenant by id.
44599
44597
  */
44600
- async getPackage(package_id) {
44601
- return this.request("GET", `/v1/packages/${encodeURIComponent(package_id)}`);
44598
+ async getStarter(starter_id) {
44599
+ return this.request("GET", `/v1/starters/${encodeURIComponent(starter_id)}`);
44602
44600
  }
44603
- /** Version history newest-first (no contract payloads) — backs `opctl package show`. Admin-only. */
44604
- async listPackageVersions(package_id) {
44605
- return this.request("GET", `/v1/packages/${encodeURIComponent(package_id)}/versions`);
44601
+ /** Version history newest-first (no contract payloads) — backs `opctl starter show`. Admin-only. */
44602
+ async listStarterVersions(starter_id) {
44603
+ return this.request("GET", `/v1/starters/${encodeURIComponent(starter_id)}/versions`);
44604
+ }
44605
+ /**
44606
+ * One version's contract — what a copy of it is supposed to produce. The
44607
+ * history above omits it (heavy per row); this is the read that carries it,
44608
+ * so a check compares a copy against the declaration itself rather than
44609
+ * against a description of it. Admin-only; cross-tenant by id like
44610
+ * `getStarter`.
44611
+ */
44612
+ async getStarterVersion(starter_id, version2) {
44613
+ return this.request(
44614
+ "GET",
44615
+ `/v1/starters/${encodeURIComponent(starter_id)}/versions/${encodeURIComponent(String(version2))}`
44616
+ );
44606
44617
  }
44607
44618
  /**
44608
44619
  * Workspace-wide dangling-reference sweep — active app/workflow artifacts
@@ -44671,13 +44682,13 @@ var LoticsClient = class {
44671
44682
  const fields = table.fields.flatMap((field) => {
44672
44683
  if (field === null || typeof field !== "object") return [];
44673
44684
  const f = field;
44674
- if (typeof f.key !== "string" || typeof f.name !== "string") return [];
44685
+ if (typeof f.key !== "string" || typeof f.name !== "string" || typeof f.type !== "string") return [];
44675
44686
  const options = Array.isArray(f.options) ? f.options.flatMap((opt) => {
44676
44687
  if (opt === null || typeof opt !== "object") return [];
44677
44688
  const o = opt;
44678
44689
  return typeof o.key === "string" && typeof o.name === "string" ? [{ id: o.key, label: o.name }] : [];
44679
44690
  }) : void 0;
44680
- return [{ id: f.key, name: f.name, ...options && options.length > 0 ? { options } : {} }];
44691
+ return [{ id: f.key, name: f.name, type: f.type, ...options && options.length > 0 ? { options } : {} }];
44681
44692
  });
44682
44693
  return { id: table.id, name: table.name, fields };
44683
44694
  })
@@ -45431,6 +45442,25 @@ function resolveContext(flags, appWorkspaceId) {
45431
45442
  const envOrg = process.env.LOTICS_ORG;
45432
45443
  const envWorkspace = process.env.LOTICS_WORKSPACE;
45433
45444
  const wsOverride = flags.workspace ?? envWorkspace;
45445
+ if (flags.org) {
45446
+ if (flags.apiKey) {
45447
+ throw new Error("Pass --org or --api-key, not both \u2014 they name two different credentials.");
45448
+ }
45449
+ const resolved = resolveProfileByNameOrId(loadGlobalConfig()?.profiles ?? {}, flags.org);
45450
+ if (!resolved) {
45451
+ throw new Error(
45452
+ `--org "${flags.org}" matches no saved credential. Run "lotics org" to list, or "lotics auth api-key <key>" to add one.`
45453
+ );
45454
+ }
45455
+ const [orgId, profile] = resolved;
45456
+ return {
45457
+ apiKey: profile.api_key,
45458
+ orgId,
45459
+ orgName: profile.org_name,
45460
+ workspaceId: wsOverride ?? profile.workspace_id,
45461
+ source: "flag_org"
45462
+ };
45463
+ }
45434
45464
  if (flags.apiKey) {
45435
45465
  return { apiKey: flags.apiKey, workspaceId: wsOverride, source: "flag" };
45436
45466
  }
@@ -45681,7 +45711,7 @@ function resultSideEffects(result) {
45681
45711
  }
45682
45712
 
45683
45713
  // src/version.ts
45684
- var VERSION = "0.182.0";
45714
+ var VERSION = "0.184.0";
45685
45715
 
45686
45716
  // src/timezone.ts
45687
45717
  function machineTimezone() {
@@ -45892,7 +45922,8 @@ var COMMANDS = [
45892
45922
  " lotics starter list Starters you can copy into this workspace. Works with",
45893
45923
  " NO account \u2014 it then lists the published shelf, so you",
45894
45924
  " can decide whether to copy one or build before signing up",
45895
- " lotics starter show <starter_id> What one carries: tables, docs, templates, sample data",
45925
+ " lotics starter show <starter_id> Its name, description, current version, tile and trust",
45926
+ " standing \u2014 read it before copying one you did not publish",
45896
45927
  " lotics starter init <starter_id> Copy it in \u2014 schema, templates, knowledge docs,",
45897
45928
  " sample records and its apps, deployed on Lotics. A",
45898
45929
  " COPY: everything it creates is yours outright, with",
@@ -45915,7 +45946,7 @@ var COMMANDS = [
45915
45946
  {
45916
45947
  verbs: ["docs"],
45917
45948
  help: [
45918
- " lotics docs List the reference docs of the INSTALLED packages",
45949
+ " lotics docs List the reference docs the npm packages in node_modules ship",
45919
45950
  " lotics docs <area> Print one (e.g. 'lotics docs ai')"
45920
45951
  ]
45921
45952
  },
@@ -45967,8 +45998,10 @@ var COMMANDS = [
45967
45998
  " shipping: agent schemas vs the live app, workflow",
45968
45999
  " declarations and BODIES vs what is live, aliases",
45969
46000
  " the code calls but nothing bound, undeclared",
45970
- " capabilities, query drift. Exits 1 on what a",
45971
- " deploy would refuse, so CI can gate on it",
46001
+ " capabilities, query drift. Plus the one rule no",
46002
+ " deploy runs: a concrete id or an id-shaped",
46003
+ " placeholder in source a starter would ship.",
46004
+ " Exits 1 on any of it, so CI can gate on it",
45972
46005
  " lotics app workflow set <alias> Push the edited src/workflows/<alias>.ts body",
45973
46006
  " through set_app_workflow (server verifies)",
45974
46007
  " lotics app workflow pull Rewrite src/workflows/*.ts from the server",
@@ -46464,10 +46497,10 @@ export default defineConfig({
46464
46497
  // openly at the asset layer \u2014 the map would expose the very source the gate
46465
46498
  // exists to protect. Source maps aren't needed to run the app.
46466
46499
  sourcemap: false,
46467
- // Top-level await (package projects' generated .lotics/app_fields.ts
46468
- // resolves the installation binding at module load) needs es2022 \u2014 Vite's
46469
- // default 'modules' baseline is es2020 and esbuild hard-fails TLA there.
46470
- // Dev already transforms at esnext, so this only aligns the prod build.
46500
+ // Vite's default 'modules' baseline is es2020, which is older than the
46501
+ // browsers a Lotics app is served to and older than what dev already
46502
+ // transforms at (esnext). Pinned so the prod build does not silently
46503
+ // down-level past a feature the dev server accepted.
46471
46504
  target: "es2022",
46472
46505
  },
46473
46506
  server: {
@@ -46490,10 +46523,10 @@ export default defineConfig({
46490
46523
  },
46491
46524
  test: {
46492
46525
  environment: "jsdom",
46493
- // Global test setup, run before every test file (empty until an author fills it)
46494
- // collects. A package-linked app's generated .lotics/app_fields.ts awaits it
46495
- // at module load; without the stub that network call throws under jsdom and
46496
- // every test that imports the app graph fails to collect. See vitest.setup.ts.
46526
+ // Global test setup, run before every test file. Ships empty \u2014 the slot is
46527
+ // the author's (custom matchers, a fetch stub, timezone pinning). It must
46528
+ // EXIST either way: setupFiles naming a missing file makes vitest fail to
46529
+ // load every test. See vitest.setup.ts.
46497
46530
  setupFiles: ["./${VITEST_SETUP_FILENAME}"],
46498
46531
  // RN packages ship Flow (\`import typeof\`) in their native source, reached
46499
46532
  // transitively by RN-Web components (pickers, calendars, anything touching
@@ -46861,18 +46894,12 @@ declare module "*.css";
46861
46894
  {
46862
46895
  path: "src/harness.test.ts",
46863
46896
  content: `import { describe, test, expect } from "vitest";
46864
- import { getAppBinding } from "@lotics/app-sdk";
46865
46897
 
46866
46898
  /**
46867
46899
  * The one test the scaffold seeds, and it is about the TEST SETUP rather than
46868
46900
  * about your app \u2014 so editing src/App.tsx can never break it, and \`npm test\`
46869
- * never has to be green over zero tests.
46870
- *
46871
- * What it pins: tests run under jsdom, and vitest.setup.ts's echo stub answers
46872
- * for \`getAppBinding\`. That second one is the whole reason the setup file
46873
- * exists: a package-linked app's generated .lotics/app_fields.ts awaits it while
46874
- * a test file is still COLLECTING, so without the stub every test fails before
46875
- * any of them runs \u2014 including pure logic tests that never touch a field id.
46901
+ * never has to be green over zero tests. It imports nothing of yours and
46902
+ * nothing generated, so it passes on a fresh clone before any codegen has run.
46876
46903
  *
46877
46904
  * Delete it once you have tests of your own, or keep it; it costs nothing.
46878
46905
  */
@@ -46880,13 +46907,6 @@ describe("test harness", () => {
46880
46907
  test("runs in a DOM", () => {
46881
46908
  expect(typeof document).toBe("object");
46882
46909
  });
46883
-
46884
- test("resolves the app binding from the setup stub, so the app graph collects", async () => {
46885
- const binding = await getAppBinding();
46886
- // The echo stub answers any alias with a self-identifying ':test:' id \u2014 one
46887
- // that can never be mistaken for a real fld_\u2026 from the workspace.
46888
- expect(binding.fields["anything.at.all"]).toContain(":test:");
46889
- });
46890
46910
  });
46891
46911
  `
46892
46912
  },
@@ -71267,6 +71287,203 @@ function checkWorkflowBodies(tsApi, aliases) {
71267
71287
  }));
71268
71288
  }
71269
71289
 
71290
+ // ../../node_modules/nanoid/index.js
71291
+ import { webcrypto as crypto3 } from "node:crypto";
71292
+ var POOL_SIZE_MULTIPLIER = 128;
71293
+ var pool;
71294
+ var poolOffset;
71295
+ function fillPool(bytes) {
71296
+ if (bytes < 0) throw new RangeError("Wrong ID size");
71297
+ try {
71298
+ if (!pool || pool.length < bytes) {
71299
+ pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
71300
+ crypto3.getRandomValues(pool);
71301
+ poolOffset = 0;
71302
+ } else if (poolOffset + bytes > pool.length) {
71303
+ crypto3.getRandomValues(pool);
71304
+ poolOffset = 0;
71305
+ }
71306
+ } catch (e) {
71307
+ pool = void 0;
71308
+ throw e;
71309
+ }
71310
+ poolOffset += bytes;
71311
+ }
71312
+ function random(bytes) {
71313
+ fillPool(bytes |= 0);
71314
+ return pool.subarray(poolOffset - bytes, poolOffset);
71315
+ }
71316
+ function customRandom(alphabet, defaultSize, getRandom) {
71317
+ let safeByteCutoff = 256 - 256 % alphabet.length;
71318
+ if (safeByteCutoff === 256) {
71319
+ let mask = alphabet.length - 1;
71320
+ return (size2 = defaultSize) => {
71321
+ if (!size2) return "";
71322
+ let id = "";
71323
+ while (true) {
71324
+ let bytes = getRandom(size2);
71325
+ let i2 = size2;
71326
+ while (i2--) {
71327
+ id += alphabet[bytes[i2] & mask];
71328
+ if (id.length >= size2) return id;
71329
+ }
71330
+ }
71331
+ };
71332
+ }
71333
+ let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
71334
+ return (size2 = defaultSize) => {
71335
+ if (!size2) return "";
71336
+ let id = "";
71337
+ while (true) {
71338
+ let bytes = getRandom(step);
71339
+ let i2 = step;
71340
+ while (i2--) {
71341
+ if (bytes[i2] < safeByteCutoff) {
71342
+ id += alphabet[bytes[i2] % alphabet.length];
71343
+ if (id.length >= size2) return id;
71344
+ }
71345
+ }
71346
+ }
71347
+ };
71348
+ }
71349
+ function customAlphabet(alphabet, size2 = 21) {
71350
+ return customRandom(alphabet, size2, random);
71351
+ }
71352
+
71353
+ // ../shared/src/id.ts
71354
+ var ID_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
71355
+ var ID_LENGTH = 12;
71356
+ var nanoid3 = customAlphabet(ID_ALPHABET, ID_LENGTH);
71357
+ function generatePrefixedId(prefix) {
71358
+ return `${prefix}_${nanoid3()}`;
71359
+ }
71360
+ var RECORD_ID_PATTERN = new RegExp(`^rec_[${ID_ALPHABET}]{${ID_LENGTH}}$`);
71361
+ function generateWorkspaceId() {
71362
+ return generatePrefixedId("wsp");
71363
+ }
71364
+ function generateTableId() {
71365
+ return generatePrefixedId("tbl");
71366
+ }
71367
+ function generateGroupId() {
71368
+ return generatePrefixedId("grp");
71369
+ }
71370
+ function generateAppId() {
71371
+ return generatePrefixedId("app");
71372
+ }
71373
+ function generateDocumentTemplateId() {
71374
+ return generatePrefixedId("dtl");
71375
+ }
71376
+
71377
+ // ../shared/src/table_field_keys.ts
71378
+ var nanoid4 = customAlphabet(ID_ALPHABET, 6);
71379
+ function generateFieldKey() {
71380
+ return `fld_${nanoid4()}`;
71381
+ }
71382
+ function generateOptionKey() {
71383
+ return `opt_${nanoid4()}`;
71384
+ }
71385
+
71386
+ // ../shared/src/concrete_ids.ts
71387
+ function bodyWidth(id) {
71388
+ return id.length - id.indexOf("_") - 1;
71389
+ }
71390
+ var GENERATED_BODY_WIDTH = /* @__PURE__ */ new Map([
71391
+ ["tbl", bodyWidth(generateTableId())],
71392
+ ["fld", bodyWidth(generateFieldKey())],
71393
+ ["opt", bodyWidth(generateOptionKey())],
71394
+ ["dtl", bodyWidth(generateDocumentTemplateId())],
71395
+ ["grp", bodyWidth(generateGroupId())],
71396
+ ["wsp", bodyWidth(generateWorkspaceId())],
71397
+ ["app", bodyWidth(generateAppId())]
71398
+ ]);
71399
+ function widthOf(prefix) {
71400
+ const width = GENERATED_BODY_WIDTH.get(prefix);
71401
+ if (width === void 0) throw new Error(`concrete_ids: no generator registered for ${prefix}_`);
71402
+ return width;
71403
+ }
71404
+ var SCHEMA_PREFIXES = ["tbl", "fld", "opt", "dtl", "grp"];
71405
+ var SHORTEST_SCHEMA_BODY = Math.min(...SCHEMA_PREFIXES.map(widthOf));
71406
+ var CONCRETE_ID_SCAN = new RegExp(
71407
+ `(?<![0-9A-Za-z])(?:${SCHEMA_PREFIXES.join("|")})_[0-9A-Za-z]{${SHORTEST_SCHEMA_BODY},}`,
71408
+ "g"
71409
+ );
71410
+ var WORKSPACE_ID_SCAN = new RegExp(
71411
+ `(?<![0-9A-Za-z])(?:organization-(?:[0-9a-z]+-)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|wsp_[0-9A-Za-z]{${widthOf("wsp")}}(?![0-9A-Za-z])|app_[0-9A-Za-z]{${widthOf("app")}}(?![0-9A-Za-z])|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})`,
71412
+ "g"
71413
+ );
71414
+ var ID_PLACEHOLDER_SCAN = new RegExp(
71415
+ `(["'\`])((?:${SCHEMA_PREFIXES.join("|")})_[0-9A-Za-z]+)\\1`,
71416
+ "g"
71417
+ );
71418
+ function isGeneratedIdBody(id) {
71419
+ const underscore = id.indexOf("_");
71420
+ if (underscore === -1) return true;
71421
+ return /[0-9A-Z]/.test(id.slice(underscore + 1));
71422
+ }
71423
+ function isBelowGeneratedWidth(token) {
71424
+ const underscore = token.indexOf("_");
71425
+ const width = GENERATED_BODY_WIDTH.get(token.slice(0, underscore));
71426
+ if (width === void 0) return false;
71427
+ return token.length - underscore - 1 < width;
71428
+ }
71429
+ var SCAN_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".html", ".css", ".json"];
71430
+ var SCAN_FILE_MAX_BYTES = 1024 * 1024;
71431
+ function normalizeScanPath(path13) {
71432
+ return path13.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\/+/, "");
71433
+ }
71434
+ function hasScannableExtension(path13) {
71435
+ return SCAN_EXTENSIONS.some((ext) => path13.endsWith(ext));
71436
+ }
71437
+ function isConcreteIdScanPath(path13) {
71438
+ const name2 = normalizeScanPath(path13);
71439
+ if (name2.endsWith(".md")) return true;
71440
+ if (!name2.startsWith("src/")) return false;
71441
+ if (name2.startsWith("src/workflows/")) return false;
71442
+ return hasScannableExtension(name2);
71443
+ }
71444
+ function isTestFile(path13) {
71445
+ return /\.(?:test|spec)\.[cm]?[jt]sx?$/.test(path13);
71446
+ }
71447
+ function isIdPlaceholderScanPath(path13) {
71448
+ const name2 = normalizeScanPath(path13);
71449
+ if (isTestFile(name2)) return false;
71450
+ if (name2.endsWith(".md")) return true;
71451
+ if (name2 === "package.json") return true;
71452
+ if (!name2.startsWith("src/")) return false;
71453
+ return hasScannableExtension(name2);
71454
+ }
71455
+ function firstLines(text, pattern, keep, into) {
71456
+ text.split("\n").forEach((line, index) => {
71457
+ for (const match2 of line.matchAll(pattern)) {
71458
+ const id = match2[2] ?? match2[0];
71459
+ if (!keep(id) || into.has(id)) continue;
71460
+ into.set(id, index + 1);
71461
+ }
71462
+ });
71463
+ return into;
71464
+ }
71465
+ function toFindings(path13, rule, lines) {
71466
+ return [...lines].map(([id, line]) => ({ path: path13, line, id, rule }));
71467
+ }
71468
+ function scanFileForConcreteIds(path13, text) {
71469
+ if (!isConcreteIdScanPath(path13)) return [];
71470
+ const lines = firstLines(text, CONCRETE_ID_SCAN, () => true, /* @__PURE__ */ new Map());
71471
+ firstLines(text, WORKSPACE_ID_SCAN, isGeneratedIdBody, lines);
71472
+ return toFindings(path13, "concrete", lines);
71473
+ }
71474
+ function scanFileForIdPlaceholders(path13, text) {
71475
+ if (!isIdPlaceholderScanPath(path13)) return [];
71476
+ const lines = firstLines(text, ID_PLACEHOLDER_SCAN, isBelowGeneratedWidth, /* @__PURE__ */ new Map());
71477
+ return toFindings(path13, "placeholder", lines);
71478
+ }
71479
+ function scanFileForIds(path13, text) {
71480
+ const concrete = scanFileForConcreteIds(path13, text);
71481
+ const seen = new Set(concrete.map((finding) => finding.id));
71482
+ return [...concrete, ...scanFileForIdPlaceholders(path13, text).filter((f) => !seen.has(f.id))].sort(
71483
+ (a, b) => a.line - b.line || (a.id < b.id ? -1 : 1)
71484
+ );
71485
+ }
71486
+
71270
71487
  // ../shared/src/agent_instructions.ts
71271
71488
  function agentFilePath(alias) {
71272
71489
  return `src/agents/${alias}.md`;
@@ -72599,6 +72816,44 @@ function readAppSourceText(projectDir) {
72599
72816
  walk2(srcDir);
72600
72817
  return parts.join("\n");
72601
72818
  }
72819
+ var ARCHIVE_EXCLUDES = ["node_modules", "dist", ".lotics", "*.tsbuildinfo", ".git"];
72820
+ function isArchiveExcluded(name2) {
72821
+ return ARCHIVE_EXCLUDES.some(
72822
+ (pattern) => pattern.startsWith("*") ? name2.endsWith(pattern.slice(1)) : name2 === pattern
72823
+ );
72824
+ }
72825
+ function scanProjectForIds(projectDir) {
72826
+ const findings = [];
72827
+ const walk2 = (dir) => {
72828
+ for (const entry of fs8.readdirSync(dir, { withFileTypes: true })) {
72829
+ if (isArchiveExcluded(entry.name)) continue;
72830
+ const full = path9.join(dir, entry.name);
72831
+ if (entry.isDirectory()) {
72832
+ walk2(full);
72833
+ continue;
72834
+ }
72835
+ if (!entry.isFile()) continue;
72836
+ const rel = path9.relative(projectDir, full).split(path9.sep).join("/");
72837
+ if (!isConcreteIdScanPath(rel) && !isIdPlaceholderScanPath(rel)) continue;
72838
+ if (fs8.statSync(full).size > SCAN_FILE_MAX_BYTES) continue;
72839
+ findings.push(...scanFileForIds(rel, fs8.readFileSync(full, "utf8")));
72840
+ }
72841
+ };
72842
+ walk2(projectDir);
72843
+ return findings.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.line - b.line);
72844
+ }
72845
+ function reportPortabilityIds(findings) {
72846
+ if (findings.length === 0) return;
72847
+ console.error(
72848
+ `
72849
+ \u2717 ${findings.length} id${findings.length === 1 ? "" : "s"} here cannot survive a copy into another workspace:`
72850
+ );
72851
+ for (const finding of findings) {
72852
+ console.error(
72853
+ finding.rule === "concrete" ? ` ${finding.path}:${finding.line} \u2014 ${finding.id} is this workspace's own id; address it through the generated .lotics/app_fields aliases (F/OPT), or in prose name the thing by alias.` : ` ${finding.path}:${finding.line} \u2014 ${finding.id} is id-shaped but no generator could have minted it; publish resolves every id against the app's footprint and refuses this one, so write a stand-in that is not id-shaped.`
72854
+ );
72855
+ }
72856
+ }
72602
72857
  async function appDeploy(client, args) {
72603
72858
  const projectDir = path9.resolve(args.projectDir ?? process.cwd());
72604
72859
  const meta3 = readAppMeta(projectDir);
@@ -72647,16 +72902,7 @@ async function appDeploy(client, args) {
72647
72902
  try {
72648
72903
  note("Packaging source...");
72649
72904
  await runTar(
72650
- [
72651
- "-czf",
72652
- tmpSource,
72653
- "--exclude=node_modules",
72654
- "--exclude=dist",
72655
- "--exclude=.lotics",
72656
- "--exclude=*.tsbuildinfo",
72657
- "--exclude=.git",
72658
- "."
72659
- ],
72905
+ ["-czf", tmpSource, ...ARCHIVE_EXCLUDES.map((pattern) => `--exclude=${pattern}`), "."],
72660
72906
  projectDir
72661
72907
  );
72662
72908
  note("Packaging dist...");
@@ -72831,10 +73077,14 @@ async function appCheck(client, args = {}) {
72831
73077
  warnIfProjectFootguns(projectDir, sourceText);
72832
73078
  warnIfUnbranded(app);
72833
73079
  warnIfUndescribed(app);
72834
- if (!nothingPending(pending)) {
73080
+ const unportable = scanProjectForIds(projectDir);
73081
+ reportPortabilityIds(unportable);
73082
+ if (!nothingPending(pending) || unportable.length > 0) {
72835
73083
  process.exit(1);
72836
73084
  }
72837
- console.error("Checked the app's bindings, capabilities and agent schemas \u2014 nothing blocking.");
73085
+ console.error(
73086
+ "Checked the app's bindings, capabilities, agent schemas and id portability \u2014 nothing blocking."
73087
+ );
72838
73088
  }
72839
73089
  async function pushPendingBindings(client, projectDir, pending) {
72840
73090
  const plan = [
@@ -74085,7 +74335,7 @@ async function starterList(client) {
74085
74335
  description: s.description,
74086
74336
  tags: [
74087
74337
  s.is_official ? "official" : null,
74088
- s.owned_by_caller === true ? "yours" : null
74338
+ s.owned_by_caller ? "yours" : null
74089
74339
  ].filter((t) => t !== null)
74090
74340
  }))
74091
74341
  );
@@ -74093,19 +74343,17 @@ async function starterList(client) {
74093
74343
  lotics starter init <starter_id> Copy one into this workspace`);
74094
74344
  }
74095
74345
  async function starterShow(client, starter_id) {
74096
- const starter = await client.getPackage(starter_id);
74346
+ const starter = await client.getStarter(starter_id);
74097
74347
  console.log(`${starter.name} (${starter.id})`);
74098
74348
  if (starter.description) console.log(starter.description);
74099
74349
  console.log(
74100
74350
  `
74101
- version ${starter.latest_version}
74102
- trust ${starter.is_official ? "official \u2014 reviewed by Lotics" : starter.owned_by_caller === true ? "your organization's own" : "not copyable from this organization"}`
74351
+ version ${starter.latest_version}
74352
+ trust ${starter.is_official ? "official \u2014 reviewed by Lotics" : starter.owned_by_caller ? "your organization's own" : "not copyable from this organization"}`
74103
74353
  );
74104
- if (starter.icon !== void 0) {
74105
- console.log(`icon ${starter.icon ?? "none \u2014 copies show a generic tile"}`);
74106
- }
74354
+ console.log(`icon ${starter.icon ?? "none \u2014 the shelf shows a generic tile"}`);
74107
74355
  if (starter.retired_at !== null) {
74108
- console.log(`retired ${starter.retired_at} \u2014 can no longer be copied`);
74356
+ console.log(`unpublished ${starter.retired_at} \u2014 can no longer be copied`);
74109
74357
  }
74110
74358
  }
74111
74359
  function reportKnowledgeWarnings(warnings) {
@@ -74119,26 +74367,15 @@ function reportKnowledgeWarnings(warnings) {
74119
74367
  answering from nowhere. Create them with those names, or edit the agent.`
74120
74368
  );
74121
74369
  }
74122
- function instantiateBody(args) {
74123
- return {
74124
- ...args.noSampleData === true ? { no_sample_data: true } : {},
74125
- ...args.adopt === true ? { adopt: true } : {},
74126
- build_on_server: true
74127
- };
74128
- }
74129
74370
  async function starterInit(client, args) {
74130
- const starter = await client.getPackage(args.starter_id);
74371
+ const starter = await client.getStarter(args.starter_id);
74131
74372
  note(
74132
74373
  `Copying ${starter.name}${starter.is_official ? " (official)" : ""} into this workspace\u2026`
74133
74374
  );
74134
- const result = await client.instantiateStarter(args.starter_id, instantiateBody(args));
74135
- if (!Array.isArray(result.apps)) {
74136
- throw new Error(
74137
- `This Lotics server predates this CLI and reported nothing about the copy's apps.
74138
- The copy itself landed \u2014 open it with "lotics auth web" \u2014 and retry once the platform
74139
- deploy completes. Do NOT copy again.`
74140
- );
74141
- }
74375
+ const result = await client.instantiateStarter(args.starter_id, {
74376
+ ...args.noSampleData === true ? { no_sample_data: true } : {},
74377
+ ...args.adopt === true ? { adopt: true } : {}
74378
+ });
74142
74379
  const tables = Object.keys(result.binding.entities ?? {}).sort();
74143
74380
  const knowledgeDocs = Object.keys(result.binding.knowledge ?? {}).sort();
74144
74381
  const templates = Object.keys(result.binding.templates ?? {}).sort();
@@ -74152,24 +74389,10 @@ async function starterInit(client, args) {
74152
74389
  error: app.error
74153
74390
  }));
74154
74391
  note(
74155
- ` Created ${tables.length} table${tables.length === 1 ? "" : "s"}, ${templates.length} template${templates.length === 1 ? "" : "s"}, ${knowledgeDocs.length} knowledge doc${knowledgeDocs.length === 1 ? "" : "s"}, ${records} sample record${records === 1 ? "" : "s"}${apps.length > 0 ? `, ${apps.length} app${apps.length === 1 ? "" : "s"}` : ""}.`
74392
+ ` Created ${tables.length} table${tables.length === 1 ? "" : "s"}, ${templates.length} template${templates.length === 1 ? "" : "s"}, ${knowledgeDocs.length} knowledge doc${knowledgeDocs.length === 1 ? "" : "s"}, ${records} sample record${records === 1 ? "" : "s"}, ${apps.length} app${apps.length === 1 ? "" : "s"}.`
74156
74393
  );
74157
74394
  reportKnowledgeWarnings(result.knowledge_warnings);
74158
- const base = {
74159
- starter_id: args.starter_id,
74160
- starter_name: starter.name,
74161
- version: result.version,
74162
- app_ids: Object.fromEntries(apps.map((app) => [app.alias, app.app_id])),
74163
- apps,
74164
- created
74165
- };
74166
- if (apps.length === 0) {
74167
- note(`
74168
- Done \u2014 these are yours now, with no link back to the starter.`);
74169
- noteCopiedContent(templates, knowledgeDocs);
74170
- return { ...base, signin_url: null };
74171
- }
74172
- if (starter.owned_by_caller !== true) {
74395
+ if (!starter.owned_by_caller) {
74173
74396
  warn(
74174
74397
  `
74175
74398
  ${starter.name} is the publisher's code \u2014 its apps, workflows and agents \u2014 and runs in
@@ -74207,9 +74430,11 @@ ${failed.length} app${failed.length === 1 ? "" : "s"} landed without a version:
74207
74430
  signInUrl = null;
74208
74431
  }
74209
74432
  note(
74210
- `
74433
+ (apps.length > 0 && failed.length === apps.length ? `
74434
+ ${starter.name} landed, but none of its ${apps.length} app${apps.length === 1 ? "" : "s"} is live.
74435
+ ` : `
74211
74436
  Done \u2014 ${starter.name} is live and yours.
74212
-
74437
+ `) + `
74213
74438
  Edit anything: the tables, the apps, the templates, the docs. There is no link
74214
74439
  back to the starter and nothing to upgrade \u2014 this is your workspace now.
74215
74440
  Change an app's code: lotics app pull <app_id> (then lotics app deploy -m "<what changed>")
@@ -74228,7 +74453,15 @@ Done \u2014 ${starter.name} is live and yours.
74228
74453
  Open it \u2014 one-time sign-in link, expires in 15 minutes:
74229
74454
  ${signInUrl}`);
74230
74455
  }
74231
- return { ...base, signin_url: signInUrl };
74456
+ return {
74457
+ starter_id: args.starter_id,
74458
+ starter_name: starter.name,
74459
+ version: result.version,
74460
+ app_ids: Object.fromEntries(apps.map((app) => [app.alias, app.app_id])),
74461
+ apps,
74462
+ created,
74463
+ signin_url: signInUrl
74464
+ };
74232
74465
  }
74233
74466
  async function starterFixturesCapture(client, args) {
74234
74467
  const projectDir = path10.resolve(args.projectDir ?? process.cwd());
@@ -103472,6 +103705,7 @@ function requireClient(flags, appWorkspaceId) {
103472
103705
  };
103473
103706
  }
103474
103707
  var SOURCE_LABELS = {
103708
+ flag_org: "--org flag",
103475
103709
  flag: "--api-key flag",
103476
103710
  env_key: "LOTICS_API_KEY env",
103477
103711
  env_org: "LOTICS_ORG env",
@@ -103582,7 +103816,7 @@ async function main() {
103582
103816
  console.error(
103583
103817
  `--version prints this CLI's version and takes no argument; it cannot be combined with a command.
103584
103818
  The CLI version: lotics --version
103585
- A package version to take: operator-only for now \u2014 \`lotics upgrade\` takes the next release.`
103819
+ A starter's version: a copy always takes the latest; there is no flag for an older one.`
103586
103820
  );
103587
103821
  process.exit(1);
103588
103822
  }
@@ -103606,7 +103840,7 @@ async function main() {
103606
103840
  const email3 = flags.email ?? (process.stdin.isTTY ? await prompt("Email: ") : "");
103607
103841
  if (!email3) {
103608
103842
  console.error(
103609
- "This machine has no Lotics credential yet, so `start` needs an email to create one:\n lotics setup " + starterId + " --email you@company.com"
103843
+ "This machine has no Lotics credential yet, so `setup` needs an email to create one:\n lotics setup " + starterId + " --email you@company.com"
103610
103844
  );
103611
103845
  process.exit(1);
103612
103846
  }
@@ -114,7 +114,7 @@ export interface FileUploadResult {
114
114
  error: string;
115
115
  }>;
116
116
  }
117
- /** One finding from a package publish/release extract. */
117
+ /** One finding from the extract behind a starter publish. */
118
118
  export interface ExtractFinding {
119
119
  severity: "error" | "warning" | "info";
120
120
  area: string;
@@ -140,7 +140,7 @@ export interface StarterPublishRequest {
140
140
  color?: string;
141
141
  }
142
142
  export interface StarterPublishPreview {
143
- /** The starter this would release into, or null when it would mint one. */
143
+ /** The starter this would publish into, or null when it would mint one. */
144
144
  starter_id: string | null;
145
145
  starter_name: string;
146
146
  version: number;
@@ -149,7 +149,7 @@ export interface StarterPublishPreview {
149
149
  app_id: string;
150
150
  name: string;
151
151
  }>;
152
- /** Empty on a release — its aliases froze at v1. */
152
+ /** Empty after v1 — the aliases froze there. */
153
153
  renamable_aliases: {
154
154
  entities: string[];
155
155
  fields: string[];
@@ -182,7 +182,55 @@ export interface StarterPublish {
182
182
  started_at: string | null;
183
183
  finished_at: string | null;
184
184
  }
185
- /** Advisory knowledge warnings surfaced by install/upgrade (never block). */
185
+ /**
186
+ * A published version's contract — the artifact set a copy of it creates.
187
+ *
188
+ * Narrowed to what a caller CHECKING a copy reads back. The authoritative shape
189
+ * is `packageContractSchema`, which lives in `@lotics/shared` — a specifier a
190
+ * published `.d.ts` cannot resolve, so it is declared here rather than imported,
191
+ * the same trade the publish shapes above make.
192
+ */
193
+ export interface StarterVersionContract {
194
+ /**
195
+ * One table per entity, scaffolded under `label`, with the columns it
196
+ * declares — a copy whose table landed with the right NAME and the wrong
197
+ * columns is the failure a table-name check cannot see.
198
+ */
199
+ entities: Array<{
200
+ alias: string;
201
+ label: string;
202
+ fields: Array<{
203
+ alias: string;
204
+ label: string;
205
+ type: string;
206
+ }>;
207
+ }>;
208
+ templates: Array<{
209
+ alias: string;
210
+ label: string;
211
+ }>;
212
+ apps: Array<{
213
+ alias: string;
214
+ name: string;
215
+ /** The named queries the app's shipped source invokes. */
216
+ queries: Array<{
217
+ alias: string;
218
+ /** Param name → declaration. `required` defaults to TRUE when absent. */
219
+ params?: Record<string, {
220
+ required?: boolean;
221
+ }>;
222
+ }>;
223
+ }>;
224
+ /** The knowledge docs the starter ships, keyed by alias. */
225
+ knowledge: Record<string, {
226
+ name: string;
227
+ }>;
228
+ /** Sample rows per entity alias — `row_count` is the contract's own count of them. */
229
+ fixtures: Record<string, {
230
+ row_count: number;
231
+ }>;
232
+ }
233
+ /** Advisory knowledge warnings surfaced by a copy (never block). */
186
234
  export interface KnowledgeWarnings {
187
235
  /** `knowledge_expects` doc names with no matching workspace doc. */
188
236
  missing_expected_docs: string[];
@@ -406,13 +454,12 @@ export declare class LoticsClient {
406
454
  current_version_id: string | null;
407
455
  }>;
408
456
  /**
409
- * Retire (or `undo` un-retire) a registry package (backs `lotics app
410
- * unpublish` — the endpoint/audit action keep the `retire` name to avoid API
411
- * churn). Retiring refuses NEW installs and hides the package from non-owning
412
- * orgs; existing installations keep working and may still upgrade. Owner-org
413
- * admin-only.
457
+ * Take a starter off the shelf, or `undo` to put it back (backs `opctl
458
+ * starter unpublish`). It hides from non-owning orgs and can no longer be
459
+ * copied; copies already made are unaffected — they never linked back.
460
+ * Owner-org admin-only.
414
461
  */
415
- retirePackage(package_id: string, body: {
462
+ unpublishStarter(starter_id: string, body: {
416
463
  undo: boolean;
417
464
  }): Promise<{
418
465
  id: string;
@@ -426,7 +473,7 @@ export declare class LoticsClient {
426
473
  * A version is an immutable snapshot; the listing is not. Omit a field to
427
474
  * leave it, pass `description: null` to clear it. Owner-org admin-only.
428
475
  */
429
- editPackageListing(package_id: string, body: {
476
+ editStarterListing(starter_id: string, body: {
430
477
  name?: string;
431
478
  description?: string | null;
432
479
  icon?: string | null;
@@ -437,11 +484,8 @@ export declare class LoticsClient {
437
484
  id: string;
438
485
  name: string;
439
486
  description: string | null;
440
- icon?: string | null;
441
- /** Optional for the same reason as `getPackage`'s: an older server omits it. */
442
- theme?: {
443
- color?: string | null;
444
- } | null;
487
+ icon: string | null;
488
+ theme: Record<string, unknown> | null;
445
489
  }>;
446
490
  /**
447
491
  * The starters this organization can copy — Lotics-reviewed ones plus its own,
@@ -454,7 +498,7 @@ export declare class LoticsClient {
454
498
  description: string | null;
455
499
  latest_version: number;
456
500
  is_official: boolean;
457
- owned_by_caller?: boolean;
501
+ owned_by_caller: boolean;
458
502
  }>>;
459
503
  /**
460
504
  * Copy a starter into the current workspace.
@@ -469,12 +513,6 @@ export declare class LoticsClient {
469
513
  version?: number;
470
514
  no_sample_data?: boolean;
471
515
  adopt?: boolean;
472
- /**
473
- * An echo for the rollout window: a server one release behind deploys
474
- * only when asked, and this CLI cannot build a copy itself. Drop it once
475
- * no such server is a rollback target.
476
- */
477
- build_on_server?: boolean;
478
516
  }): Promise<{
479
517
  /** Each app's deploy, in contract order. `error` set and `deployed` null when one did not land. */
480
518
  apps: Array<{
@@ -491,9 +529,7 @@ export declare class LoticsClient {
491
529
  version: number;
492
530
  binding: Record<string, Record<string, string>>;
493
531
  sample_record_ids: Record<string, string[]>;
494
- knowledge_warnings: {
495
- missing_expected_docs: string[];
496
- };
532
+ knowledge_warnings: KnowledgeWarnings;
497
533
  }>;
498
534
  /**
499
535
  * Which starter this app is the origin of. 404 when it has published none.
@@ -536,37 +572,40 @@ export declare class LoticsClient {
536
572
  * Fetch a registry starter's metadata (`latest_version` and the Lotics-backed
537
573
  * `is_official` trust badge). Admin-only; cross-tenant by id.
538
574
  */
539
- getPackage(package_id: string): Promise<{
575
+ getStarter(starter_id: string): Promise<{
540
576
  id: string;
541
577
  name: string;
542
578
  description: string | null;
543
579
  latest_version: number;
544
580
  is_official: boolean;
545
581
  retired_at: string | null;
546
- /** Absent from a pre-deploy server — treat undefined as not-owned (the badge under-claims, never over-claims). */
547
- owned_by_caller?: boolean;
548
- /**
549
- * The shelf tile, which every copy's app inherits.
550
- *
551
- * Optional for the same reason `owned_by_caller` is: a server that predates
552
- * the field answers without it, and a CLI newer than the deployment it is
553
- * talking to must read that as "not stated" rather than "not set".
554
- */
555
- icon?: string | null;
556
- theme?: Record<string, unknown> | null;
582
+ /** Whether the CALLING org owns it — the copy-time trust badge, without exposing the owner's org id. */
583
+ owned_by_caller: boolean;
584
+ /** The shelf tile. Null = unset; a copy's app tiles come from the contract. */
585
+ icon: string | null;
586
+ theme: Record<string, unknown> | null;
557
587
  created_at: string;
558
588
  updated_at: string;
559
589
  }>;
560
- /** Version history newest-first (no contract payloads) — backs `opctl package show`. Admin-only. */
561
- listPackageVersions(package_id: string): Promise<{
590
+ /** Version history newest-first (no contract payloads) — backs `opctl starter show`. Admin-only. */
591
+ listStarterVersions(starter_id: string): Promise<{
562
592
  versions: Array<{
563
593
  version: number;
564
594
  changelog: string | null;
565
- channel: "release" | "dev";
566
- yanked_at: string | null;
567
595
  created_at: string;
568
596
  }>;
569
597
  }>;
598
+ /**
599
+ * One version's contract — what a copy of it is supposed to produce. The
600
+ * history above omits it (heavy per row); this is the read that carries it,
601
+ * so a check compares a copy against the declaration itself rather than
602
+ * against a description of it. Admin-only; cross-tenant by id like
603
+ * `getStarter`.
604
+ */
605
+ getStarterVersion(starter_id: string, version: number): Promise<{
606
+ version: number;
607
+ contract: StarterVersionContract;
608
+ }>;
570
609
  /**
571
610
  * Workspace-wide dangling-reference sweep — active app/workflow artifacts
572
611
  * whose prefixed schema ids no longer resolve. Backs
@@ -617,6 +656,7 @@ export declare class LoticsClient {
617
656
  fields: Array<{
618
657
  id: string;
619
658
  name: string;
659
+ type: string;
620
660
  options?: Array<{
621
661
  id: string;
622
662
  label: string;
@@ -324,14 +324,13 @@ export class LoticsClient {
324
324
  return this.request("POST", "/v1/apps", body);
325
325
  }
326
326
  /**
327
- * Retire (or `undo` un-retire) a registry package (backs `lotics app
328
- * unpublish` — the endpoint/audit action keep the `retire` name to avoid API
329
- * churn). Retiring refuses NEW installs and hides the package from non-owning
330
- * orgs; existing installations keep working and may still upgrade. Owner-org
331
- * admin-only.
327
+ * Take a starter off the shelf, or `undo` to put it back (backs `opctl
328
+ * starter unpublish`). It hides from non-owning orgs and can no longer be
329
+ * copied; copies already made are unaffected — they never linked back.
330
+ * Owner-org admin-only.
332
331
  */
333
- async retirePackage(package_id, body) {
334
- return this.request("POST", `/v1/packages/${encodeURIComponent(package_id)}/retire`, body);
332
+ async unpublishStarter(starter_id, body) {
333
+ return this.request("POST", `/v1/starters/${encodeURIComponent(starter_id)}/unpublish`, body);
335
334
  }
336
335
  /**
337
336
  * Edit a starter's registry listing — the name and description a stranger
@@ -340,13 +339,12 @@ export class LoticsClient {
340
339
  * A version is an immutable snapshot; the listing is not. Omit a field to
341
340
  * leave it, pass `description: null` to clear it. Owner-org admin-only.
342
341
  */
343
- async editPackageListing(package_id, body) {
344
- return this.request("POST", `/v1/packages/${encodeURIComponent(package_id)}/listing`, body);
342
+ async editStarterListing(starter_id, body) {
343
+ return this.request("POST", `/v1/starters/${encodeURIComponent(starter_id)}/listing`, body);
345
344
  }
346
345
  // --- Starters (registry reads + copies) ---
347
- // Authoring is server-side: apps via the publish job (`requestStarterPublish`),
348
- // content starters via the `publish_content`/`release_content` tools. There is
349
- // no client-side create-package / upload-bundle path.
346
+ // Authoring is server-side, through the publish job (`requestStarterPublish`).
347
+ // There is no client-side create-starter / upload-bundle path.
350
348
  /**
351
349
  * The starters this organization can copy — Lotics-reviewed ones plus its own,
352
350
  * never a catalogue of everything published. The server returns exactly what
@@ -399,12 +397,22 @@ export class LoticsClient {
399
397
  * Fetch a registry starter's metadata (`latest_version` and the Lotics-backed
400
398
  * `is_official` trust badge). Admin-only; cross-tenant by id.
401
399
  */
402
- async getPackage(package_id) {
403
- return this.request("GET", `/v1/packages/${encodeURIComponent(package_id)}`);
400
+ async getStarter(starter_id) {
401
+ return this.request("GET", `/v1/starters/${encodeURIComponent(starter_id)}`);
404
402
  }
405
- /** Version history newest-first (no contract payloads) — backs `opctl package show`. Admin-only. */
406
- async listPackageVersions(package_id) {
407
- return this.request("GET", `/v1/packages/${encodeURIComponent(package_id)}/versions`);
403
+ /** Version history newest-first (no contract payloads) — backs `opctl starter show`. Admin-only. */
404
+ async listStarterVersions(starter_id) {
405
+ return this.request("GET", `/v1/starters/${encodeURIComponent(starter_id)}/versions`);
406
+ }
407
+ /**
408
+ * One version's contract — what a copy of it is supposed to produce. The
409
+ * history above omits it (heavy per row); this is the read that carries it,
410
+ * so a check compares a copy against the declaration itself rather than
411
+ * against a description of it. Admin-only; cross-tenant by id like
412
+ * `getStarter`.
413
+ */
414
+ async getStarterVersion(starter_id, version) {
415
+ return this.request("GET", `/v1/starters/${encodeURIComponent(starter_id)}/versions/${encodeURIComponent(String(version))}`);
408
416
  }
409
417
  /**
410
418
  * Workspace-wide dangling-reference sweep — active app/workflow artifacts
@@ -484,7 +492,7 @@ export class LoticsClient {
484
492
  if (field === null || typeof field !== "object")
485
493
  return [];
486
494
  const f = field;
487
- if (typeof f.key !== "string" || typeof f.name !== "string")
495
+ if (typeof f.key !== "string" || typeof f.name !== "string" || typeof f.type !== "string")
488
496
  return [];
489
497
  const options = Array.isArray(f.options)
490
498
  ? f.options.flatMap((opt) => {
@@ -496,7 +504,7 @@ export class LoticsClient {
496
504
  : [];
497
505
  })
498
506
  : undefined;
499
- return [{ id: f.key, name: f.name, ...(options && options.length > 0 ? { options } : {}) }];
507
+ return [{ id: f.key, name: f.name, type: f.type, ...(options && options.length > 0 ? { options } : {}) }];
500
508
  });
501
509
  return { id: table.id, name: table.name, fields };
502
510
  }));
@@ -236,7 +236,8 @@ actually carries, not what the source says it should.
236
236
 
237
237
  ```
238
238
  npm run typecheck && npm run lint && npm test
239
- lotics app check # every pre-flight a deploy runs, without building or shipping
239
+ lotics app check # every pre-flight a deploy runs, without building or shipping,
240
+ # plus the portability gate a starter publish applies
240
241
  lotics app deploy -m "<what changed + why>"
241
242
  ```
242
243
 
@@ -24,7 +24,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
24
24
  | `lotics run <tool> --json '<json>'` | Execute a tool (full JSON output) |
25
25
  | `lotics run <tool>` — **file cells** | A file in a tool's result carries its `fil_…` id and metadata and **no `url`**, on every tool and in both output modes. That is not a broken file — this surface resolves no URL for a cell. Reach the bytes with `lotics file download <file_id>`, which takes the id straight from the cell; the text output says so whenever a result carries one. |
26
26
  | — | **Every tool is invoked here, including the ones that RUN something** (`run_app_workflow`, `run_app_agent`, `run_app_query`). What stays an `app` command is work no tool call can do — scaffold, build, typecheck, serve, or read and push a local file. |
27
- | — | **The exit code reports the WORK, not just the call.** A result whose envelope carries a failed `status` (`error`/`failed`/`cancelled`) exits non-zero and prints `<tool> → <status>: <message>` to stderr, so `lotics run … && next-step` cannot walk past a refused run. The rule is an allowlist of FAILURE — an unrecognized status exits 0, so a status added later never turns a working script red. A parked run (`awaiting_input`) is not a failure: it is waiting for an answer and the work is still live. Only a TOP-LEVEL `status` counts; one inside the data belongs to the data. |
27
+ | — | **The exit code reports the WORK, not just the call — for the two tools that RUN one.** `run_app_workflow` and `run_app_agent` whose envelope carries a failed `status` (`error`/`failed`/`cancelled`) exit non-zero and print `<tool> → <status>: <message>` to stderr, so `lotics run … && next-step` cannot walk past a refused run. The rule is an allowlist of FAILURE — an unrecognized status exits 0, so a status added later never turns a working script red. A parked run (`awaiting_input`) is not a failure: it is waiting for an answer and the work is still live. Only a TOP-LEVEL `status` counts; one inside the data belongs to the data. Any OTHER tool's `status` — `press_button`'s included — is data, and exits 0. |
28
28
  | `lotics run <tool> --print-created` | Report the records the call created, grouped by table, with a paste-ready `delete_records` per table and the mandatory caveat naming what cannot be auto-undone (external integrations, notifications, possible sub-workflows). Works for any tool that returns a `side_effects` block, not workflows alone. |
29
29
  | `lotics run <tool> --cleanup` | Implies `--print-created`, then runs those deletes — harvested records **only**, never files / external calls / notifications. **Not a rollback**; a rollback is structurally impossible here. A partial cleanup exits non-zero so a script cannot read it as success. |
30
30
  | `lotics upload <file\|dir...>` · `--stdin` · `--base64` · `--url <url>` | Upload files/directories via multipart POST to /v1/files. A directory expands to its immediate files; `--as <name>` renames a single upload. **Three alternative byte sources, for a caller that never had the bytes on disk** — an attachment decoded in memory, a generated document, a signed download link — each mutually exclusive with the others and with a path argument: `--stdin` takes raw bytes on stdin, `--base64` takes base64 on stdin (the shape attachments arrive in), `--url <url>` fetches the URL first. `--stdin`/`--base64` REQUIRE `--as`, because stdin carries no filename and the mime type is derived from it; `--url` falls back to `Content-Disposition` then the URL's last path segment. `--base64` decodes STRICTLY — `Buffer.from(s, "base64")` silently skips invalid characters and truncates on bad padding, so a corrupted pipe would otherwise store a short file that only fails when a human opens it. The `--url` fetch happens in the CLI, not the server: the URL comes from the operator running the command, so routing it through the backend would add an SSRF surface to buy what `curl` already does. |
@@ -43,13 +43,13 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
43
43
  | `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` — 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). **There is one form, and that is what makes a starter's source portable**: the keys are slugified DISPLAY NAMES and a starter carries its labels verbatim, so running codegen in a copy's own workspace emits the same keys pointing at that workspace's ids — no binding fetched at load, no prebuilt bundle to keep in step. 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. 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). **Re-silvers `package.json#lotics.agents`** from the live app row whenever its `inputs`/`outputs` disagree, then rewrites the agent `.d.ts` from the refreshed block: that block is a mirror AND the offline seed for `useAgentRun` typings, so a stale copy types the app against an agent that does not exist. The write is surgical and order-preserving, so it changes only the fields that actually differ. A hand edit to that block is therefore reverted — it never changed the agent anyway; to change one, `set_app_agent`. |
44
44
  | `lotics setup <starter_id> [--email <addr>] [--json]` | **The whole first run, in one command.** Creates an account when this machine has no credential (the same call `auth signup` makes — `--name` and `--timezone` apply), then does exactly what `starter init` does, then prints the one-time sign-in link. It exists because the two-command form has a seam where the FIRST command exists only to produce a credential for the second, and a caller pasting a prompt has to get both right. **`--email` is only for creating an account**: with a credential already resolvable it is REFUSED rather than obeyed, because the two can name different organizations and preferring either one silently copies a starter into an org the caller did not name — the message says how to do each thing on purpose. Without it, `setup` copies into the account you already have and is a pure alias for `starter init`. A path positional is accepted and IGNORED with a warning — nothing is written to disk any more — so a prompt written for an older CLI still runs. **`--json` prints one object on stdout and nothing else** — `organization_id`, `workspace_id`, `app_ids` (alias → id), `apps` (each app's `version_number`, or its `error`), `signin_url`, and `created` — which NAMES what landed (`tables`, `templates` and `knowledge_docs` are alias arrays; `sample_records` is a row count, since rows are not named things). Aliases rather than counts because the next question is about a particular artifact: a copied template carries the publisher's wording and a copied knowledge doc describes how they work, so "which of these should be mine?" is the conversation a copy starts, and a count cannot begin it. Plus a `warnings` array carrying everything the prose form would have said out of band — an unbindable knowledge doc, a sign-in link that could not be minted, the publisher's-code disclosure, an app that landed without a version. A warning is never merely silenced: when the command fails with an error before it can emit, the ones it had collected go to stderr alongside it. Reachable with no install: `npx -y @lotics/cli setup …`. |
45
45
  | `lotics starter list` | **Works with no account**, and that is the point: whether to copy a starter or build from scratch is decided before one exists, so requiring a key would mean signing up to learn the answer was no. Unauthenticated it lists what Lotics publishes (`GET /v1/starters/official`, public). Authenticated it is the org shelf — The starters this organization can copy — Lotics-reviewed ones plus its own, each with at least one released version. Deliberately NOT a catalogue of everything published: the server returns exactly what a copy would be allowed to take, so the list can never offer something that then refuses. Admin-only. |
46
- | `lotics starter show <starter_id>` | One starter's name, description, current version and trust standing (`official` — reviewed by Lotics; `your organization's own`). Read it before copying a starter you did not publish. |
47
- | `lotics starter init <starter_id>` | **Copy a starter into this workspace.** Server-side it scaffolds the tables and fields, creates the document templates and knowledge docs, inserts the sample records, creates every app the starter carries and materializes each one's queries, workflows and agents onto it — then deploys each app from the dist the starter was published with, rewriting the publisher's sentinel field keys to this workspace's. No build runs anywhere, nothing is written to this machine, and nothing here needs node: the apps are live when the command returns. **What you get is yours outright**: ordinary apps plus ordinary tables, with no link back to the starter, nothing pinned, and nothing to upgrade. Edit any of it — `lotics app pull <app_id>` is how an app's code is edited afterwards. **The publisher's code runs in your workspace as you** — its apps, workflows and agents — which is why provenance is the gate: **copyable only if the starter is Lotics-reviewed or your own organization published it**, enforced server-side; the disclosure is printed (and carried in `--json`'s `warnings`) whenever the starter is not your own. **Refuses a workspace that already has tables** unless `--adopt`: scaffold matches an entity by DISPLAY NAME, so a starter declaring `Contacts` would bind to yours. An app whose deploy failed is reported by name with its reason and the exit is non-zero, but the copy is complete around it — the tables, the records and the app row exist — so it must not be run again; the publisher fixes the starter and it is copied into a fresh workspace. The sign-in link lands on the app when there is one, else on the workspace's app list. `--json` prints one object on stdout instead of progress (the shape is under `lotics setup`). `--no-sample-data` skips the sample records; with them, the created record ids are reported — they are ordinary records, delete them whenever. Resolves and ANNOUNCES its workspace first (`lotics → <org> / <workspace>` on stderr). Admin-only. Authoring the registry (`opctl starter publish/unpublish`) stays operator-only. |
48
- | `lotics starter fixtures capture [--entity <alias> ...] [--limit <n>]` | **(authoring)** Write this app's live records into the project as `fixtures/<entity-alias>.json` — the sample data a starter carries, so a copy lands with something in it. Run from an app project; the app id comes from its manifest. The alias-keyed shape is produced server-side, because the aliases are minted when the starter is extracted and exist nowhere a project can read them. `--entity` is repeatable and comma-separated; omitted, every table the app declares is captured. **Capture a linked set in ONE call** — a link between two rows only resolves within a single capture, so taking companies and contacts separately drops the edge between them (it says so when it happens). `--limit` bounds rows per table (default 10, max 200). **READ WHAT IT WROTE before committing**: these rows are created verbatim in every workspace that copies the starter, so a real customer name, price or address captured here is published. Files, formulas, rollups, lookups and autonumbers are never captured — the platform writes those. Admin-only; writes nothing to the workspace. |
46
+ | `lotics starter show <starter_id>` | One starter's name, description, current version, shelf tile and trust standing (`official` — reviewed by Lotics; `your organization's own`; otherwise `not copyable from this organization`), plus the date it was unpublished once it has been. Read it before copying a starter you did not publish. Admin-only, and readable by id from any org — but an unpublished starter 404s for every org except the one that published it. |
47
+ | `lotics starter init <starter_id>` | **Copy a starter into this workspace.** Server-side it scaffolds the tables and fields, creates the document templates and knowledge docs, inserts the sample records, creates every app the starter carries and materializes each one's queries, workflows and agents onto it — then deploys each app from the dist the starter was published with, rewriting the publisher's sentinel field keys to this workspace's. No build runs anywhere, nothing is written to this machine, and nothing here needs node: the apps are live when the command returns. **What you get is yours outright**: ordinary apps plus ordinary tables, with no link back to the starter, nothing pinned, and nothing to upgrade. Edit any of it — `lotics app pull <app_id>` is how an app's code is edited afterwards. **The publisher's code runs in your workspace as you** — its apps, workflows and agents — which is why provenance is the gate: **copyable only if the starter is Lotics-reviewed or your own organization published it**, enforced server-side; the disclosure is printed (and carried in `--json`'s `warnings`) whenever the starter is not your own. **Refuses a workspace that already has tables** unless `--adopt`: scaffold matches an entity by DISPLAY NAME, so a starter declaring `Contacts` would bind to yours. An app whose deploy failed is reported by name with its reason and the exit is non-zero, but the copy is complete around it — the tables, the records and the app row exist — so it must not be run again; the publisher fixes the starter and it is copied into a fresh workspace. The sign-in link lands on the app when there is one, else on the workspace's app list. `--json` prints one object on stdout instead of progress (the shape is under `lotics setup`). `--no-sample-data` skips the sample records, and a copy that ADOPTS an existing table writes none either — that table already holds real rows, and the fixture set links to itself, so it is all-or-nothing; with them, how many landed is reported. They are ordinary records, delete them whenever. Resolves and ANNOUNCES its workspace first (`lotics → <org> / <workspace>` on stderr). Admin-only. Authoring the registry (`opctl starter publish/unpublish`) stays operator-only. |
48
+ | `lotics starter fixtures capture [--entity <alias> ...] [--limit <n>]` | **(authoring)** Write this app's live records into the project as `fixtures/<entity-alias>.json` — the sample data a starter carries, so a copy lands with something in it. Run from an app project; the app id comes from its manifest. The alias-keyed shape is produced server-side, because the aliases are minted when the starter is extracted and exist nowhere a project can read them. `--entity` is repeatable and comma-separated; omitted, every table the app declares is captured. **Capture a linked set in ONE call** — a link between two rows only resolves within a single capture, so taking companies and contacts separately drops the edge between them (it says so when it happens). `--limit` bounds rows per table (default 10, max 200 — a higher one is clamped, not refused). **A captured row is written into a copy exactly as it reads here**: a cell the origin left empty stays empty, because the copy's inserts do not apply field defaults. **READ WHAT IT WROTE before committing**: these rows are created verbatim in every workspace that copies the starter, so a real customer name, price or address captured here is published. Files, formulas, rollups, lookups and autonumbers are never captured — the platform writes those. Admin-only; writes nothing to the workspace. |
49
49
  | `lotics upgrade` | Update this CLI in place. Runs the same installer a person would, chosen by how THIS copy arrived: an npm install upgrades through npm, a script install re-runs the script — the runtime knows which (the executable is compiled, the npm bin runs under node), so nobody has to. It downloads nothing itself; resolving a version, verifying the checksum and replacing a running executable already exist in the installers, and a second copy of that inside the binary would be a second thing to get right. Replacing the binary while it runs is safe — a rename leaves the running image mapped on unix, and on Windows the installer moves the old aside precisely because the file is in use. Already current is a no-op that says so. Needs no auth. |
50
50
  | `lotics docs` \| `lotics docs <area>` | The index of the reference docs, **resolved out of the packages installed beside this project** — never carried by this CLI. **Both levels are discovered by looking**: every `@lotics/*` package carrying an `AGENTS.md` or a `docs/` in any `node_modules/@lotics` from the current directory UPWARD (nearest wins, so a hoisted root copy never shadows the one a project's own imports resolve to), and within each, every area it actually ships. Titles come from each file's own `# heading` and the version from the installed `package.json`, so a doc OR a whole package added upstream appears with no change to this CLI, and a skewed install is visible rather than reassuring. A package's index is named after the package (`lotics docs ui`), never `index`. `@lotics/app-sdk`, `@lotics/ui` and `@lotics/cli` sort first as a reading ORDER, not a filter. Both the index and `<area>` print to **stdout** — the index is the payload of a bare `lotics docs`, so `lotics docs | grep -i excel` works — with only the provenance line on stderr, so `lotics docs ai > ai.md` is the doc alone; a name two packages share is refused with both qualified forms (`lotics docs ui/templates`) rather than resolved silently. Needs no auth. Outside a project only `@lotics/cli`'s own resolve, and it says so. |
51
51
  | `lotics report '<json>'` \| `lotics report @report.json` | File a report with the Lotics team about what got in your way. **Covers the classes telemetry structurally cannot see**: a capability that does not exist (no command ran, so nothing was recorded), a command that exited 0 having done the wrong thing, an error whose message did not name the remedy, and anything that made authoring slower than it should be. **A frame, not a paragraph** — `{goal, actual, expected?, tried?, wanted?}`, `goal` and `actual` required, unknown keys dropped rather than refused. **No severity or category.** Ingest is inline JSON, `@file`, or `-` for stdin. A bare sentence is refused with the frame printed beside it, so the fix is one step; a bare invocation prints the frame BEFORE asking for a credential, since someone whose key will not resolve is exactly who has something to report. **Not spooled**: unlike telemetry it posts inline, prints whether it landed, and exits non-zero if it did not, echoing the report back so a failed send never loses it. Runs regardless of `LOTICS_TELEMETRY` — invoking it IS the consent that passive collection needs an opt-in for — but with telemetry off there are no recorded commands to attach, and it says so rather than implying context it does not have. Requires auth. Never paste records, file contents, or credentials. |
52
- | `lotics app check` | Every pre-flight `deploy` runs, WITHOUT building or shipping. **First, whether this project is even based on the served version** — the one thing a deploy REFUSES outright rather than pushing (the server 409s a stale `prev_version_id`), and the one finding that invalidates every other: a stale tree and the live app are two different apps, so comparing them reports nothing trustworthy. Stale exits 1 naming both versions and stops before the rest; a project with no stamp at all — or an app with no version yet — is a first deploy, not a conflict. `deploy` runs the SAME assertion off the app row it already fetched, so a stale tree fails before it pushes a binding or builds, instead of after the upload arrives and the server 409s. Then: the manifest's agent schemas against the live app row, every binding a deploy would push, aliases the source calls that nothing bound (queries, workflows AND agents), bindings this bundle stopped calling (the same transition — and the same baseline — `deploy` reports, so the two cannot disagree), capability-gated SDK calls the manifest doesn't declare, a missing icon/theme, a missing app `description` (it heads the capability catalog the chat agent reads every turn, and its absence has no other symptom), a `vite.config.ts` that never defines `global`/`__DEV__`, a `window.open` in the app's own source, and an INSTALLED `@lotics/app-sdk` below the version that understands the host's realtime push — read from `node_modules`, not the dependency range, because a caret is minor-locked below 1.0 so `^0.79.x` can never resolve `0.80` and `npm update` does nothing (all three fail ONLY in the deployed app — dev bundles with esbuild and production with rollup, so typecheck, lint, build and `app dev` are all green while react-native-web reads `global.cancelAnimationFrame` as a free variable and the sandboxed iframe drops a popup silently), an agent holding `run_app_query`/`run_app_workflow` with an EMPTY `query_aliases`/`workflow_aliases` (the tool is the capability, the alias list is the reach — empty means every call it makes is refused while the run still COMPLETES, so it surfaces as a model ignoring its prompt; read off the live row, never the manifest, which mirrors those fields but is pushed by no verb), and a notice for any alias the source computes at runtime (invisible to every check here and to `--prune`'s unbind guard). **And whether the kit this app builds against has fallen behind what is published** — `@lotics/ui` and `@lotics/app-sdk`, read from `node_modules` for the same reason as the floor check above: a range keeps accepting, so an app pinned `^44.x` reads healthy for a year, and even an in-range one sits on the lockfile's older patch until `npm update` (never `npm install`, which honours the lock). A MAJOR behind is loud and names the packages actually behind — plus `@lotics/ui`'s `MIGRATION.md`, when ui is one of them, since it is the only half that keeps one; anything smaller is one quiet line, because a warning that fires on every deploy is one the reader stops seeing. The registry lookup is bounded and every failure — offline, slow, private — is silence: a version check must never become a new way for a deploy to fail. Adds no rule of its own — each finding is the same helper `deploy` calls, so a green check means a deploy will not complain. **Exits 1 on what a `deploy` would REFUSE or PUSH** — an agent schema that disagrees with the live app, and any binding the project has ahead of the app (an edited workflow body or declaration, edited agent prose, a changed query). Both are things a deploy would act on, so CI gating on a green check means a deploy has nothing left to do; genuine advisories (capabilities, branding, a runtime-computed alias, orphaned bindings) stay advisory and never fail it. |
52
+ | `lotics app check` | Every pre-flight `deploy` runs, WITHOUT building or shipping. **First, whether this project is even based on the served version** — the one thing a deploy REFUSES outright rather than pushing (the server 409s a stale `prev_version_id`), and the one finding that invalidates every other: a stale tree and the live app are two different apps, so comparing them reports nothing trustworthy. Stale exits 1 naming both versions and stops before the rest; a project with no stamp at all — or an app with no version yet — is a first deploy, not a conflict. `deploy` runs the SAME assertion off the app row it already fetched, so a stale tree fails before it pushes a binding or builds, instead of after the upload arrives and the server 409s. Then: the manifest's agent schemas against the live app row, every binding a deploy would push, aliases the source calls that nothing bound (queries, workflows AND agents), bindings this bundle stopped calling (the same transition — and the same baseline — `deploy` reports, so the two cannot disagree), capability-gated SDK calls the manifest doesn't declare, a missing icon/theme, a missing app `description` (it heads the capability catalog the chat agent reads every turn, and its absence has no other symptom), a `vite.config.ts` that never defines `global`/`__DEV__`, a `window.open` in the app's own source, and an INSTALLED `@lotics/app-sdk` below the version that understands the host's realtime push — read from `node_modules`, not the dependency range, because a caret is minor-locked below 1.0 so `^0.79.x` can never resolve `0.80` and `npm update` does nothing (all three fail ONLY in the deployed app — dev bundles with esbuild and production with rollup, so typecheck, lint, build and `app dev` are all green while react-native-web reads `global.cancelAnimationFrame` as a free variable and the sandboxed iframe drops a popup silently), an agent whose capability and its reach disagree, in EITHER direction, over any of the five declaration-bound tools (`run_app_query`/`run_app_workflow` against `query_aliases`/`workflow_aliases`; `grep_knowledge`/`read_knowledge`/`list_knowledge` against `knowledge_doc_ids`) — the tool is the capability, the list is the reach, and a tool with no reach means every call it makes is refused while the run still COMPLETES, so it surfaces as a model ignoring its prompt; read off the live row, never the manifest, which mirrors those fields but is pushed by no verb, and a notice for any alias the source computes at runtime (invisible to every check here and to `--prune`'s unbind guard). **And whether the kit this app builds against has fallen behind what is published** — `@lotics/ui` and `@lotics/app-sdk`, read from `node_modules` for the same reason as the floor check above: a range keeps accepting, so an app pinned `^44.x` reads healthy for a year, and even an in-range one sits on the lockfile's older patch until `npm update` (never `npm install`, which honours the lock). A MAJOR behind is loud and names the packages actually behind — plus `@lotics/ui`'s `MIGRATION.md`, when ui is one of them, since it is the only half that keeps one; anything smaller is one quiet line, because a warning that fires on every deploy is one the reader stops seeing. The registry lookup is bounded and every failure — offline, slow, private — is silence: a version check must never become a new way for a deploy to fail. Every deploy finding is the same helper `deploy` calls, so a green check means a deploy will not complain. **And the PORTABILITY gate, which is the one rule `check` runs that a deploy does not** — the ids an app cannot carry into another workspace, over the working tree, with the same exclusions the deploy tar applies. Two rules. **An id this workspace MINTED**, written into `src/`, a `.md` or the app's own docs — it resolves to nothing in a copy, and in prose it is an instruction the copier's agent follows; this is the one a `starter publish` also refuses, on the uploaded archive. **And an id-shaped STAND-IN** too short for the generator that mints its prefix (`"opt_X"`, `"fld_a"` — quoted or in a code span, so a bare `opt_in` stays legal, and never in a test file), which only `check` runs, and which additionally reads a workflow body and the manifest: those two are exempt from the first rule because a publish INVERTS a real id there, and it cannot invert a fake — so without this a stand-in survives until the publish resolves it against the app's footprint, on somebody else's machine. Each is reported as `<file>:<line> — <id>` with the one edit that fixes it. This gate reads only the files, but the command around it still needs a resolvable credential and the live app row, so it is not an offline check. **Exits 1 on that and on what a `deploy` would REFUSE or PUSH** — an agent schema that disagrees with the live app, and any binding the project has ahead of the app (an edited workflow body or declaration, edited agent prose, a changed query). Both are things a deploy would act on, so CI gating on a green check means a deploy has nothing left to do; genuine advisories (capabilities, branding, a runtime-computed alias, orphaned bindings) stay advisory and never fail it. |
53
53
  | `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. |
54
54
  | `lotics app agent set <alias>` | Push `src/agents/<alias>.md` — plus `inputs`/`outputs` when `package.json#lotics.agents.<alias>` declares them — through `set_app_agent`. The agent mirror of `app workflow set`, and the deploy-free authoring path for an agent's prose and its typed edges. **It sends only those fields.** Everything else is absent, and absent means unchanged, so a declaration this CLI does not model cannot be reverted by a push from a checkout that predates it — the chat authoring agent's `knowledge_doc_ids`, another operator's `query_aliases` grant. To change one of those, call `set_app_agent` with just that field (`lotics run set_app_agent '{"app_id":…,"alias":…,"tool_names":[…]}'` — it merges), then `app pull` to bring the manifest back in step. **CREATES the alias when the app has not bound one yet**, so a new agent is authored the same way a new workflow is: write the prose, declare the typed half, push. A create needs the prose file (an agent without instructions is not an agent); it is gated on nothing else, because what keeps a binding alive is a `useAppAgentRun("<alias>")` call site in the shipped bundle — a deploy prunes an agent the bundle never names, manifest entry or not. The prose push is a conditional write against the fingerprint this project last saw, so it is refused rather than allowed to overwrite prose someone else changed. Clear error + non-zero exit when there is no prose file and nothing declared to push instead, when a create has no prose to create from, or when the file is empty once the header is stripped. |
55
55
  | `lotics app query set <alias>` \| `--all` | Push `package.json#lotics.queries` (`{ ast, params? }` per alias) to `apps.queries` through `set_app_query` — **the only author of a query binding**, the mirror of `app workflow set`. A deploy pushes a DRIFTED declaration through this same verb before it ships (see `app deploy`), so this is the explicit single-alias path, not the only way a query reaches the app. The **server** validates each one exactly as it always did (alias identifier, workspace-only tables, resolvable fields, declared params). `--all` pushes every declared alias, alias-sorted, stopping at the first failure and naming what already landed. Clear error + non-zero exit on an alias absent from the manifest or a validation failure. **The declaration's fields MERGE**, so the manifest is not a snapshot: deleting `params` from an alias and pushing leaves the live params exactly where they were, because an absent key means "unchanged". Clear one with `params: null`, or replace the map with the set you want. |
@@ -57,7 +57,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
57
57
  | `lotics app workflow check [alias]` | Check the editable workflow bodies locally, no auth / no network, in the **server's own order** — parse, then type-check. **Parse** runs `parseWorkflowJs` from `@lotics/shared` (the SAME module `verifyWorkflow` calls, never a second implementation) over the stripped body `set` would upload, with `toolNames: undefined` (the CLI ships no tool registry, so tool-name resolution stays a server check while every shape/scope rule runs here). A body the subset rejects reports **that error alone** and skips the compiler — it never reaches the server's compiler either, so tsc's opinion of it is noise. **Type-check** then builds an **isolated** `ts.Program` per alias from exactly that alias's `{body, globals}` pair — mirroring the server, which verifies one body at a time — so the per-alias ambient `trigger` never collides and `trigger.app_workflow.inputs` is checked against the right alias. All aliases run in ONE node process (N programs, not N `tsc` spawns), with the SAME compile options the server uses at set-time verify (lib `es2022` with no DOM, target ES2022, strict, NodeNext, `types:[]`, skipLibCheck) and the app's OWN `typescript` (resolved from its `node_modules`, never bundled into the CLI). What the compiler sees is the **checked source**, not the file: `rewriteAccumulatorAppends` from `@lotics/shared` — the SAME transform the server applies before its set-time compile — is applied in memory, so a pulled body's canonical `out = concat(out, [item])` accumulator checks green here exactly as it saves there, and the body on disk is never rewritten. Reports `<file>:<line>:<col> - <TS####\|subset>` at the **physical** line in `src/workflows/<alias>.ts`, so an editor jump lands on the offending code (these are deliberately NOT `set`'s body-relative numbers — `set` prints no file path, so there is no format to agree with); exits non-zero if any alias fails. Green is honest but not total: `set` additionally resolves names, lints and structurally validates against the live workspace — passes that need its tables and tool schemas, so they cannot run offline, and the success line says so. A bound alias with no body file yet warns + skips; a body with no globals errors (naming `lotics app codegen`, which refreshes types WITHOUT touching the body — a pull would overwrite it). **It also keeps the types honest.** Each alias's `.lotics/workflows/<alias>.globals.d.ts` carries a `// lotics:declaration <hash>` stamp of the manifest declaration it was rendered from; `check` compares it to `package.json#lotics.workflows.<alias>` and, when they differ, re-renders that alias's dts from the LOCAL declaration before compiling. Without it the verdict was confidently wrong in the exact case an author needs it — declare an input, run `check`, and get `TS2339: Property 'x' does not exist` pointing at your body for a schema the types have never been told about. The server renders a dts from a SUPPLIED declaration, so this works before the manifest has ever been deployed, which is when it matters (the order is edit → check → set). This is the ONE thing `check` uses the API for: it is skipped entirely when the stamps match (the common case, so `check` stays instant and offline), and with no credentials or a failed fetch it WARNS and checks against the older types rather than blocking. A file written before the stamp existed reads as unknown, never as matching, so a pre-existing checkout heals on its first run. |
58
58
  | `lotics app subdomain <new-subdomain>` | Rename the app's public `<slug>.lotics.app` address via `PUT /v1/apps/{id}/subdomain`. app_id comes from the local `package.json` manifest; the chosen slug must be a valid DNS label and free; the old address stops resolving. |
59
59
  | `lotics app rename "<new name>"` | Change the app's display name (launcher/title) via the `update_app` tool. app_id comes from the local `package.json` manifest; the public address (`subdomain`) and code (`deploy`) are unchanged. |
60
- | `lotics app dev [path] [--port=N] [--vite-port=N] [--view-as=<member_id>]` | Spawn Vite dev server + an RPC-forwarding HTTP server. The wrapper page embeds the iframe with `sandbox="allow-scripts allow-same-origin"` matching production; postMessage ops (query / workflow / members / context / upload / openExternal / urlState / agentRun) are forwarded to api.lotics.ai using the CLI's API key — file bytes move in **both** directions through the dev server's own relays, never browser↔storage: dev runs against the PROD bucket, whose CORS admits `https://*.lotics.app` and not `http://localhost:<port>`, so a direct browser transfer is blocked — no upload could complete and no preview engine (PDF/Word/Excel all FETCH the bytes) could read a file. `upload` mints a presigned URL and PUTs it **to `PUT /_upload/<file_id>`** (`dev/upload_relay.ts`) from the wrapper page — same-origin, so no preflight and no CORS — and Node forwards it on; every presigned `url`/`thumbnail_url`/`preview_url` on a **file object** in an RPC result is rewritten to **`GET /_file/<token>`** (`dev/file_relay.ts`, absolute — the iframe would resolve a relative path against Vite), which streams the bytes back with `Range` passthrough (206s intact, so PDF seeking works) and an `Access-Control-Allow-Origin` for the Vite origin (the one cross-origin hop left is OUR response to allow). Neither relay ever takes a destination from the client — it gets a `file_id`/token and transfers only to/from a URL it minted or observed itself, so there is no client-controlled target and no SSRF surface. A URL in a record's own text cell is NOT rewritten. Production is unchanged (direct-to-storage, no bytes through the API server); `openExternal` and `urlState.get/set` are handled locally (the latter read/write the wrapper page's own address bar — `set` writes in place via `replaceState` and browser back/forward broadcast a `url-state` message back, so `useUrlState` survives refresh and is shareable in the dev loop; in-app *routing* is the app's own (the iframe owns its url via `@lotics/app-sdk/router`), and the wrapper bakes the saved screen (`_loc`) into the iframe src on load so a refresh restores it, mirroring production); `agentRun` (streaming) is proxied through `POST /_agent_run`, which opens the run's SSE with the CLI key and pipes chunks back to the iframe (`stream-chunk`* → `stream-end`), so `useAgentRun` works in the dev loop just like production; `context` resolves the viewer (`member_id` from `cli/whoami` + `comments_enabled` from the local manifest) and fetches the installation's stored `config` live from the app row, so `useConfig()` renders the same values as production. `--view-as` (global flag; also `LOTICS_VIEW_AS`) threads `x-view-as-member-id` so `is_current_member` + `context` resolve to that member — **admin key only** (the server 403s a non-admin), writes stay attributed to the key owner. Hot reload via Vite; full DevTools / Playwright access via plain localhost. **Every forwarded op logs one line naming its ALIAS** — `[rpc] query applicants 231ms` — and `query applicants (count)` for a count request, which is a SECOND full execution of the same query rather than a cheap lookup. When requests overlap the line carries `· N in flight`. That number is the one to watch: the server bounds how many app queries run at once, so requests past the bound wait and the wait lands inside each request's own duration — a burst reads as "every query got slower", which looks like a slow database and is not one. A screen firing its list plus three facet counts on one keystroke shows up here as eight lines over one or two aliases; see `@lotics/app-sdk` `docs/data_fetching.md` (`useCount`, and handing `usePaginatedQuery` a `total`) and `docs/queries.md` §10 for collapsing them. **Holds no realtime connection** — push belongs to the product frontend, so an app previewed here never updates on an external write (a CLI run, another tab, an agent): reload to see it. Deliberate rather than missing, since the alternative is a second implementation of the channel in the wrapper page, and a blanket poll here would hide an app whose queries do not declare their tables — the one mistake the real host punishes. The startup banner says `realtime: off` so this is visible without reading this table. The dev-optimizer pre-bundle list (`optimizeDeps.include`, load-bearing for dev) is imported from `@lotics/ui/vite` (`loticsOptimizeDeps`) rather than hardcoded in the scaffold, so it tracks the installed `@lotics/ui` and can never go stale. Binds **loopback only** (`127.0.0.1`) — `/_rpc` dispatches with the developer's API key, so a socket on every interface would hand anyone on the network full read/write on the workspace. |
60
+ | `lotics app dev [path] [--port=N] [--vite-port=N] [--view-as=<member_id>]` | Spawn Vite dev server + an RPC-forwarding HTTP server. The wrapper page embeds the iframe with `sandbox="allow-scripts allow-same-origin"` matching production; postMessage ops (query / workflow / members / context / upload / openExternal / urlState / agentRun) are forwarded to api.lotics.ai using the CLI's API key — file bytes move in **both** directions through the dev server's own relays, never browser↔storage: dev runs against the PROD bucket, whose CORS admits `https://*.lotics.app` and not `http://localhost:<port>`, so a direct browser transfer is blocked — no upload could complete and no preview engine (PDF/Word/Excel all FETCH the bytes) could read a file. `upload` mints a presigned URL and PUTs it **to `PUT /_upload/<file_id>`** (`dev/upload_relay.ts`) from the wrapper page — same-origin, so no preflight and no CORS — and Node forwards it on; every presigned `url`/`thumbnail_url`/`preview_url` on a **file object** in an RPC result is rewritten to **`GET /_file/<token>`** (`dev/file_relay.ts`, absolute — the iframe would resolve a relative path against Vite), which streams the bytes back with `Range` passthrough (206s intact, so PDF seeking works) and an `Access-Control-Allow-Origin` for the Vite origin (the one cross-origin hop left is OUR response to allow). Neither relay ever takes a destination from the client — it gets a `file_id`/token and transfers only to/from a URL it minted or observed itself, so there is no client-controlled target and no SSRF surface. A URL in a record's own text cell is NOT rewritten. Production is unchanged (direct-to-storage, no bytes through the API server); `openExternal` and `urlState.get/set` are handled locally (the latter read/write the wrapper page's own address bar — `set` writes in place via `replaceState` and browser back/forward broadcast a `url-state` message back, so `useUrlState` survives refresh and is shareable in the dev loop; in-app *routing* is the app's own (the iframe owns its url via `@lotics/app-sdk/router`), and the wrapper bakes the saved screen (`_loc`) into the iframe src on load so a refresh restores it, mirroring production); `agentRun` (streaming) is proxied through `POST /_agent_run`, which opens the run's SSE with the CLI key and pipes chunks back to the iframe (`stream-chunk`* → `stream-end`), so `useAgentRun` works in the dev loop just like production; `context` resolves the viewer (`member_id` from `cli/whoami` + `comments_enabled` from the local manifest) and fetches the app's stored `config` live from the app row, so `useConfig()` renders the same values as production. `--view-as` (global flag; also `LOTICS_VIEW_AS`) threads `x-view-as-member-id` so `is_current_member` + `context` resolve to that member — **admin key only** (the server 403s a non-admin), writes stay attributed to the key owner. Hot reload via Vite; full DevTools / Playwright access via plain localhost. **Every forwarded op logs one line naming its ALIAS** — `[rpc] query applicants 231ms` — and `query applicants (count)` for a count request, which is a SECOND full execution of the same query rather than a cheap lookup. When requests overlap the line carries `· N in flight`. That number is the one to watch: the server bounds how many app queries run at once, so requests past the bound wait and the wait lands inside each request's own duration — a burst reads as "every query got slower", which looks like a slow database and is not one. A screen firing its list plus three facet counts on one keystroke shows up here as eight lines over one or two aliases; see `@lotics/app-sdk` `docs/data_fetching.md` (`useCount`, and handing `usePaginatedQuery` a `total`) and `docs/queries.md` §10 for collapsing them. **Holds no realtime connection** — push belongs to the product frontend, so an app previewed here never updates on an external write (a CLI run, another tab, an agent): reload to see it. Deliberate rather than missing, since the alternative is a second implementation of the channel in the wrapper page, and a blanket poll here would hide an app whose queries do not declare their tables — the one mistake the real host punishes. The startup banner says `realtime: off` so this is visible without reading this table. The dev-optimizer pre-bundle list (`optimizeDeps.include`, load-bearing for dev) is imported from `@lotics/ui/vite` (`loticsOptimizeDeps`) rather than hardcoded in the scaffold, so it tracks the installed `@lotics/ui` and can never go stale. Binds **loopback only** (`127.0.0.1`) — `/_rpc` dispatches with the developer's API key, so a socket on every interface would hand anyone on the network full read/write on the workspace. |
61
61
  | `LOTICS_UI_SRC=<abs path to packages/ui/src>` (env, not a command) | Dev-link `@lotics/ui` to a monorepo checkout for the length of ONE command, **for every tool at once**. The app's `vite.config.ts` gets its whole `resolve` block from the kit (`resolve: loticsResolve()` — `@lotics/ui/vite`), which reads the variable at call time and adds the `@lotics/ui/*` → working-copy alias, so kit edits go live under `lotics app dev` (HMR) and bundle under `lotics app deploy`. In the same breath, every command that regenerates types (`create`/`pull`/`dev`/`deploy`/`codegen`, all via `writeAppDts`) writes **`.lotics/tsconfig.link.json`** — the matching `paths`, which the app's `tsconfig.json` `extends` — so `tsc`, vitest, eslint and your EDITOR resolve the same copy Vite does. Unset ⇒ every one of them goes back to `node_modules`, and the generated file is rewritten inert. **Why `paths` and not `npm link`:** the kit ships un-built `.tsx`, so a kit file outside `node_modules` resolves its OWN `react`/`react-native` from the monorepo — two copies in one program and every shared type stops matching ("Two different types with this name exist, but they are unrelated"). The generated file therefore also pins every peer @lotics/ui declares to the APP's copy, types-package first (`react` → `@types/react`; pinning the runtime package instead strands tsc on a `.js` with no declarations). The pin set is derived from the installed kit's `peerDependencies`, so it tracks the kit rather than rotting. **Nothing hand-written is touched** — the generated file lives in `.lotics/` (the CLI's own dir) and no config is edited by regex. Identical for a monorepo app and an EXTERNAL one (e.g. `~/lotics_apps`). `app deploy` still warns whenever the variable is set — that the bundle carries kit code from your working copy, or that the app's config predates `loticsResolve()` and never reads it, so the PUBLISHED kit is going out. An app whose `tsconfig.json` already `extends` something else is told rather than rewritten: add `./.lotics/tsconfig.link.json` to the array yourself. |
62
62
  | `lotics xlsx <subcmd>` | Local .xlsx read/write/edit using the bundled `@lotics/xlsx` engine (no auth, no network). `write` takes its JSON inline, as `@file`, or piped on stdin, ingested exactly as `run` ingests tool args. 14 named subcommands (read, write, set-cell, clear-range, merge, unmerge, add-sheet, delete-sheet, rename-sheet, insert-rows, delete-rows, insert-cols, delete-cols, set-style) + `batch` for applying multiple of the same 14 ops in a single parse/export cycle. `read` also takes `--sheet <name>` (limit output to one sheet — unknown name fails with the available list) and `--range <sheet>!<A1:G60>` (limit to a cell window; the `<sheet>!` prefix is optional when `--sheet` supplies the sheet, a single cell like `S1!B2` is a 1×1 window) to trim a large workbook's JSON — the output shape is unchanged, only the `sheets` array and each sheet's `cells` map are filtered. **`read` reports formatting back, so a generated file is verifiable through this path** rather than by unzipping OOXML: each cell carries `numFmt` when the file gave it one, and `--with-format` adds the resolved `style`. The asymmetry is deliberate — a parsed cell's style is *never* absent (every cell resolves to at least a font — size, name, colour), so emitting it by default would put three noise keys on every plain cell and make “is this styled?” unanswerable by presence; `numFmt` is genuinely absent on an unformatted cell, so it needs no flag. **`write` takes sheet-level `colWidths` (`{"A":34}`) and `rowHeights` (`{"1":44}`)** — without them every column is the default width and a human-facing workbook is unreadable no matter what the cells say. Both are written *pinned* (`customWidth`/`customHeight`), so Excel does not auto-fit them away, and both apply to a row/column that holds no cells (a spacer row's height survives). Keys are a bare column letter and a bare row number, bounded by Excel's grid (`A`…`XFD`, `1`…`1048576`): a key outside it, or a cell ref like `A1` where a column letter belongs, is **rejected** rather than resolved to something adjacent — past the grid the reference is written into the file verbatim, addressing a cell that cannot exist. Unknown **sheet** properties are rejected on the same terms as unknown cell properties — a silently-ignored `columnWidths` typo is a file that looks written and is not. **A `--flag` a subcommand does not know is refused by name** (`--with-formats` would otherwise read as proof the file carries no styles). `xlsx` and `docx` own their whole tail: a global flag's NAME means nothing there, so `xlsx delete-rows f.xlsx S1 5 3 --force` is refused rather than run, and `xlsx set-cell f.xlsx S1!A1 -v` writes the value `-v`. Subcommands whose trailing arg is CONTENT (`xlsx set-cell`, `docx replace-text`, `docx append-paragraph`/`insert-paragraph`) are deliberately exempt: a value may legitimately begin with `-` or `--`, and there a typo is indistinguishable from data. `--help` is the one spelling still reserved everywhere. They are covered instead by arity — **every fixed-shape subcommand refuses an argument past the last one it reads**, whatever it looks like, because the likeliest source is a flag the caller believes exists and these commands write in place. Arity rather than a leading `--` is the discriminator, since a sheet name may legitimately begin with one. **A cell VALUE is read as the type the caller stated, on both JSON surfaces.** `write`'s `cells` and `batch`'s `set-cell` `value` take the same union — a bare `string | number | boolean | null`, or a `{value, formula, numFmt, style}` object — and honour it: a JSON string writes a text cell, digits and all, so `"0071000512345"` (MST, số tài khoản, số vận đơn) keeps its leading zeros and `"1234567890123456789"` keeps its last two digits, neither of which survives being re-read as characters. The one reading applied to a BARE string is a leading `=`, which is a formula — the only way to write one in the shorthand form; `{"value": "=SUM(A1)"}` is the stated literal, and how a cell that must hold the text `=x` is expressed, on either surface. `value` is a literal on the object form of BOTH surfaces — `formula` is the key that says otherwise — and a literal beginning with `=` is **written as asked and named in a stderr warning**, since it is the one literal indistinguishable from a mistake: it renders in a viewer exactly like the formula the caller probably meant, computes nothing, and is skipped by every SUM over the column. The object form also carries `numFmt` and `style` per cell in `batch`, the same as in `write`. The `set-cell` POSITIONAL is different because a shell argument carries no type: there the characters are read for what they denote (`TRUE` → boolean, digits → number), stopped by two things — the target cell's number format being Text (`@`), and a zero-padded digit string, which stays text whatever the target format says (a deliberate divergence from Excel: losing a leading zero is unrecoverable, while a text cell in a number column is visible). Every subcommand that can introduce a formula (`write`, `set-cell`, `batch`) **evaluates it and writes the cached value**, so a generated formula does not read back blank: Excel and Sheets recalculate on open, but parsers — including this CLI's `read` and the rest of the platform — take the cached `<v>`. A formula the engine cannot evaluate still gets written, with a stderr warning naming the cells, rather than silently leaving a hole where a number belongs. Atomic in-place write (temp file + rename). |
63
63
  | `lotics docx <subcmd>` | Local .docx read/write/edit using the bundled `@lotics/docx` engine (OOXML round-trip surface only — no ProseMirror baggage). `write` takes its JSON inline, as `@file`, or piped on stdin, ingested exactly as `run` ingests tool args. Subcommands: read, write, append-paragraph, insert-paragraph, delete-block, replace-text, batch. A legacy `.doc` (Word 97–2003 OLE2 binary) is detected in `loadFile` and routed through `@lotics/ooxml`'s `loadDocxFromBuffer` (which re-emits it as real OOXML) before reading — so `lotics docx read` works on a `.doc`, not just a `.docx`. Opaque blocks (tables, custom XML) preserved verbatim. Atomic in-place write. **`replace-text` matches across run boundaries** — Word splits a run at every formatting change, so a `{{marker}}` routinely lands split — and reads straight THROUGH marks that occupy no place in the sentence (`w:proofErr`, `w:footnoteReference`, endnote/comment refs + ranges, `w:bookmarkStart`/`End`, `w:lastRenderedPageBreak`). `w:proofErr` is the one that decides whether this works in practice — Word brackets every word its dictionary rejects, so on non-English text it lands between nearly every pair of runs. It still refuses to join across anything that occupies space in the text — `w:br`, `w:tab`, `w:sym`, a drawing, or any tag not on that allowlist — because the joined string does not represent the glyph and a match there would rewrite text the caller never saw. The SAME rule applies inside a table cell as outside it — both run one `replaceInParagraph` over paragraphs found at any depth, so a marker split by a line break is refused in both rather than rewritten in the cell and skipped in the body under a success message. Zero matches is always a hard error, never a silent no-op, and when the words ARE on the page the error names the block and the splitting mark (`The text IS present at block 1, split by w:br …`) rather than claiming the text is absent. |
@@ -86,8 +86,10 @@ format handles display.
86
86
  At generate time, `data` must provide a key for **every** marker — pass `""` for fields
87
87
  that should render blank; a missing key fails with the full list of missing markers.
88
88
 
89
- To add markers/loops/conditionals to the uploaded file from the CLI: `word_replace_text`,
90
- `word_insert_loop`, `word_insert_conditional` (and their `remove_*` counterparts).
89
+ To read the uploaded file before marking it: `word_get_content`, `word_find_text`,
90
+ `word_get_table_data`. To add markers/loops/conditionals: `word_replace_text`,
91
+ `word_insert_loop`, `word_insert_conditional` — unmarking is `word_replace_text` putting the
92
+ plain text back.
91
93
 
92
94
  ### Email (`create_email_template`)
93
95
 
@@ -70,10 +70,10 @@ that member's agent.
70
70
  Docs are not injected wholesale. The agent works the corpus like a filesystem, and all three
71
71
  verbs respect access + activation, so only docs the caller may use ever surface.
72
72
 
73
- 1. **`list_knowledge`** — `ls`. The corpus as a folder tree: name, id, folder, and a truncated
74
- description. No bodies.
73
+ 1. **`list_knowledge`** — `ls`. The corpus as a flat list: id, name, tags, and a truncated
74
+ description; `tag` narrows it. No bodies.
75
75
  2. **`grep_knowledge`** — `grep -rn`. Match across every readable doc (or one doc, or one
76
- folder), returning **doc, line number, and the matching line**. It runs inside Postgres,
76
+ tag), returning **doc, line number, and the matching line**. It runs inside Postgres,
77
77
  so only matching lines cross the wire.
78
78
  3. **`read_knowledge`** — `cat` / `sed -n 'X,Yp'`. Read a doc whole or by line range, to see
79
79
  the context around a hit.
@@ -221,7 +221,7 @@ statement about discovery, so it cannot silently break an app that depends on a
221
221
  Reach for it instead of `rm` whenever the material still matters: last year's tariff schedule, a
222
222
  handbook a newer one replaced, the raw source a curated doc was written from.
223
223
 
224
- ## Package-managed knowledge
224
+ ## Knowledge from a starter
225
225
 
226
226
  A knowledge doc can also arrive with a **starter** — a published snapshot of a workspace setup
227
227
  that carries a corpus of docs (and document templates) along with it. Copying a starter creates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/cli",
3
- "version": "0.182.0",
3
+ "version": "0.184.0",
4
4
  "description": "Lotics SDK and CLI for AI agents",
5
5
  "type": "module",
6
6
  "bin": {