@lotics/cli 0.156.5 → 0.157.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/dist/src/cli.js +146 -10
- package/docs/cli_reference.md +2 -2
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -47534,6 +47534,18 @@ function createFileRelay(wrapperOrigin, now = Date.now) {
|
|
|
47534
47534
|
};
|
|
47535
47535
|
}
|
|
47536
47536
|
|
|
47537
|
+
// src/dev/rpc_label.ts
|
|
47538
|
+
function rpcLabel(op, payload) {
|
|
47539
|
+
const p = payload;
|
|
47540
|
+
const alias = typeof p?.alias === "string" && p.alias.length > 0 ? p.alias : null;
|
|
47541
|
+
if (!alias) return op;
|
|
47542
|
+
const isCount = op === "query" && p?.count === true;
|
|
47543
|
+
return `${op} ${alias}${isCount ? " (count)" : ""}`;
|
|
47544
|
+
}
|
|
47545
|
+
function concurrencyNote(concurrent) {
|
|
47546
|
+
return concurrent > 1 ? ` \xB7 ${concurrent} in flight` : "";
|
|
47547
|
+
}
|
|
47548
|
+
|
|
47537
47549
|
// src/dev/server.ts
|
|
47538
47550
|
var DEFAULT_PORT = 5174;
|
|
47539
47551
|
var DEFAULT_VITE_PORT = 5173;
|
|
@@ -47605,6 +47617,7 @@ async function startDevServer(args) {
|
|
|
47605
47617
|
"last-modified",
|
|
47606
47618
|
"content-disposition"
|
|
47607
47619
|
];
|
|
47620
|
+
let inFlight = 0;
|
|
47608
47621
|
const server = http.createServer(async (req, res) => {
|
|
47609
47622
|
const url2 = req.url ?? "/";
|
|
47610
47623
|
const pathname = url2.split("?")[0];
|
|
@@ -47617,9 +47630,19 @@ async function startDevServer(args) {
|
|
|
47617
47630
|
return;
|
|
47618
47631
|
}
|
|
47619
47632
|
if (req.method === "POST" && url2 === "/_rpc") {
|
|
47633
|
+
let counted = false;
|
|
47634
|
+
const release = () => {
|
|
47635
|
+
if (counted) {
|
|
47636
|
+
counted = false;
|
|
47637
|
+
inFlight--;
|
|
47638
|
+
}
|
|
47639
|
+
};
|
|
47620
47640
|
try {
|
|
47621
47641
|
const body = await readJson(req);
|
|
47622
47642
|
const startedAt2 = Date.now();
|
|
47643
|
+
inFlight++;
|
|
47644
|
+
counted = true;
|
|
47645
|
+
const concurrent = inFlight;
|
|
47623
47646
|
const result = await dispatchRpc(
|
|
47624
47647
|
args.client,
|
|
47625
47648
|
{
|
|
@@ -47628,9 +47651,9 @@ async function startDevServer(args) {
|
|
|
47628
47651
|
payload: body.payload
|
|
47629
47652
|
},
|
|
47630
47653
|
{ commentsEnabled: args.commentsEnabled }
|
|
47631
|
-
);
|
|
47654
|
+
).finally(release);
|
|
47632
47655
|
const ms = Date.now() - startedAt2;
|
|
47633
|
-
process.stderr.write(`[rpc] ${body.op} ${ms}ms
|
|
47656
|
+
process.stderr.write(`[rpc] ${rpcLabel(body.op, body.payload)} ${ms}ms${concurrencyNote(concurrent)}
|
|
47634
47657
|
`);
|
|
47635
47658
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
47636
47659
|
res.end(
|
|
@@ -47639,6 +47662,7 @@ async function startDevServer(args) {
|
|
|
47639
47662
|
)
|
|
47640
47663
|
);
|
|
47641
47664
|
} catch (err2) {
|
|
47665
|
+
release();
|
|
47642
47666
|
const message2 = err2 instanceof Error ? err2.message : String(err2);
|
|
47643
47667
|
process.stderr.write(`[rpc] ERROR ${message2}
|
|
47644
47668
|
`);
|
|
@@ -48165,6 +48189,35 @@ function canonicalJson(value2) {
|
|
|
48165
48189
|
};
|
|
48166
48190
|
return JSON.stringify(normalize(value2));
|
|
48167
48191
|
}
|
|
48192
|
+
var REGEX_MAY_FOLLOW = /* @__PURE__ */ new Set([
|
|
48193
|
+
"return",
|
|
48194
|
+
"typeof",
|
|
48195
|
+
"case",
|
|
48196
|
+
"in",
|
|
48197
|
+
"of",
|
|
48198
|
+
"delete",
|
|
48199
|
+
"void",
|
|
48200
|
+
"instanceof",
|
|
48201
|
+
"new",
|
|
48202
|
+
"do",
|
|
48203
|
+
"else",
|
|
48204
|
+
"yield",
|
|
48205
|
+
"await",
|
|
48206
|
+
"throw"
|
|
48207
|
+
]);
|
|
48208
|
+
function opensRegex(out, at2) {
|
|
48209
|
+
let k = at2 - 1;
|
|
48210
|
+
while (k >= 0 && (out[k] === " " || out[k] === "\n" || out[k] === " " || out[k] === "\r")) k--;
|
|
48211
|
+
if (k < 0) return true;
|
|
48212
|
+
const prev = out[k];
|
|
48213
|
+
if ("=(,:[!&|?{;+-*%>~^".includes(prev)) return true;
|
|
48214
|
+
if (/[A-Za-z0-9_$]/.test(prev)) {
|
|
48215
|
+
let s = k;
|
|
48216
|
+
while (s >= 0 && /[A-Za-z0-9_$]/.test(out[s])) s--;
|
|
48217
|
+
return REGEX_MAY_FOLLOW.has(out.slice(s + 1, k + 1).join(""));
|
|
48218
|
+
}
|
|
48219
|
+
return false;
|
|
48220
|
+
}
|
|
48168
48221
|
function codeWithoutComments(sourceText) {
|
|
48169
48222
|
const out = sourceText.split("");
|
|
48170
48223
|
const n = sourceText.length;
|
|
@@ -48206,12 +48259,33 @@ function codeWithoutComments(sourceText) {
|
|
|
48206
48259
|
i2 = j < n ? j + 1 : n;
|
|
48207
48260
|
continue;
|
|
48208
48261
|
}
|
|
48262
|
+
if (c === "/" && opensRegex(out, i2)) {
|
|
48263
|
+
let j = i2 + 1;
|
|
48264
|
+
let inClass = false;
|
|
48265
|
+
while (j < n) {
|
|
48266
|
+
const ch = sourceText[j];
|
|
48267
|
+
if (ch === "\\") {
|
|
48268
|
+
j += 2;
|
|
48269
|
+
continue;
|
|
48270
|
+
}
|
|
48271
|
+
if (ch === "\n") break;
|
|
48272
|
+
if (ch === "[") inClass = true;
|
|
48273
|
+
else if (ch === "]") inClass = false;
|
|
48274
|
+
else if (ch === "/" && !inClass) {
|
|
48275
|
+
j++;
|
|
48276
|
+
break;
|
|
48277
|
+
}
|
|
48278
|
+
j++;
|
|
48279
|
+
}
|
|
48280
|
+
i2 = j;
|
|
48281
|
+
continue;
|
|
48282
|
+
}
|
|
48209
48283
|
i2++;
|
|
48210
48284
|
}
|
|
48211
48285
|
return out.join("");
|
|
48212
48286
|
}
|
|
48213
48287
|
var ALIAS_CALL_HOOKS = {
|
|
48214
|
-
queries: ["useQuery", "usePaginatedQuery", "useInfiniteQuery", "useFieldOptions"],
|
|
48288
|
+
queries: ["useQuery", "usePaginatedQuery", "useInfiniteQuery", "useCount", "useFieldOptions"],
|
|
48215
48289
|
workflows: ["useWorkflow"],
|
|
48216
48290
|
agents: ["useAgentRun"]
|
|
48217
48291
|
};
|
|
@@ -72924,6 +72998,72 @@ function warnAboutDevLink(projectDir, command) {
|
|
|
72924
72998
|
);
|
|
72925
72999
|
}
|
|
72926
73000
|
}
|
|
73001
|
+
var KIT_PACKAGES = ["@lotics/ui", "@lotics/app-sdk"];
|
|
73002
|
+
function installedKitVersion(projectDir, pkg2) {
|
|
73003
|
+
try {
|
|
73004
|
+
const manifest = path10.join(projectDir, "node_modules", ...pkg2.split("/"), "package.json");
|
|
73005
|
+
const parsed = JSON.parse(fs8.readFileSync(manifest, "utf-8"));
|
|
73006
|
+
const version2 = parsed.version;
|
|
73007
|
+
return typeof version2 === "string" ? version2 : null;
|
|
73008
|
+
} catch {
|
|
73009
|
+
return null;
|
|
73010
|
+
}
|
|
73011
|
+
}
|
|
73012
|
+
async function publishedKitVersion(pkg2) {
|
|
73013
|
+
const controller = new AbortController();
|
|
73014
|
+
const timeout = setTimeout(() => controller.abort(), 3e3);
|
|
73015
|
+
timeout.unref();
|
|
73016
|
+
try {
|
|
73017
|
+
const response = await fetch(`https://registry.npmjs.org/${pkg2}/latest`, {
|
|
73018
|
+
signal: controller.signal
|
|
73019
|
+
});
|
|
73020
|
+
if (!response.ok) return null;
|
|
73021
|
+
const data2 = await response.json();
|
|
73022
|
+
return data2.version ?? null;
|
|
73023
|
+
} catch {
|
|
73024
|
+
return null;
|
|
73025
|
+
} finally {
|
|
73026
|
+
clearTimeout(timeout);
|
|
73027
|
+
}
|
|
73028
|
+
}
|
|
73029
|
+
async function warnIfKitBehind(projectDir) {
|
|
73030
|
+
const checks = await Promise.all(
|
|
73031
|
+
KIT_PACKAGES.map(async (pkg2) => {
|
|
73032
|
+
const installed = installedKitVersion(projectDir, pkg2);
|
|
73033
|
+
if (!installed) return null;
|
|
73034
|
+
const latest = await publishedKitVersion(pkg2);
|
|
73035
|
+
if (!latest || !isNewerVersion(latest, installed)) return null;
|
|
73036
|
+
const behindMajor = (Number.parseInt(latest, 10) || 0) > (Number.parseInt(installed, 10) || 0);
|
|
73037
|
+
return { pkg: pkg2, installed, latest, behindMajor };
|
|
73038
|
+
})
|
|
73039
|
+
);
|
|
73040
|
+
const findings = checks.filter((c) => c !== null);
|
|
73041
|
+
if (findings.length === 0) return;
|
|
73042
|
+
const lines = findings.map(
|
|
73043
|
+
(f) => ` \u2022 ${f.pkg} ${f.installed} installed \xB7 ${f.latest} published` + (f.behindMajor ? " \u2014 a MAJOR behind" : "")
|
|
73044
|
+
);
|
|
73045
|
+
const majors = findings.filter((f) => f.behindMajor);
|
|
73046
|
+
if (majors.length > 0) {
|
|
73047
|
+
const install = `npm install ${majors.map((f) => `${f.pkg}@latest`).join(" ")}`;
|
|
73048
|
+
const migration = majors.some((f) => f.pkg === "@lotics/ui") ? `
|
|
73049
|
+
|
|
73050
|
+
Breaking changes are listed newest-first in
|
|
73051
|
+
node_modules/@lotics/ui/MIGRATION.md.` : "";
|
|
73052
|
+
console.error(
|
|
73053
|
+
`
|
|
73054
|
+
\u26A0 This app builds against a kit a major release behind:
|
|
73055
|
+
` + lines.join("\n") + migration + `
|
|
73056
|
+
|
|
73057
|
+
\`${install}\``
|
|
73058
|
+
);
|
|
73059
|
+
return;
|
|
73060
|
+
}
|
|
73061
|
+
console.error(
|
|
73062
|
+
`
|
|
73063
|
+
A newer kit is published \u2014 \`npm update ${findings.map((f) => f.pkg).join(" ")}\`:
|
|
73064
|
+
` + lines.join("\n")
|
|
73065
|
+
);
|
|
73066
|
+
}
|
|
72927
73067
|
function ensureAppVitestSetup(projectDir) {
|
|
72928
73068
|
const setupPath = path10.join(projectDir, VITEST_SETUP_FILENAME);
|
|
72929
73069
|
if (!fs8.existsSync(setupPath)) {
|
|
@@ -73343,6 +73483,7 @@ async function appDeploy(client, args) {
|
|
|
73343
73483
|
const called = calledAppAliases(sourceText);
|
|
73344
73484
|
warnIfDynamicAliases(called);
|
|
73345
73485
|
warnIfUndeclaredCapabilities(sourceText, meta3.capabilities);
|
|
73486
|
+
await warnIfKitBehind(projectDir);
|
|
73346
73487
|
warnIfProjectFootguns(projectDir, sourceText);
|
|
73347
73488
|
writeAppDts(projectDir, { workflows: meta3.workflows, queries: meta3.queries, agents: meta3.agents });
|
|
73348
73489
|
try {
|
|
@@ -73599,6 +73740,7 @@ async function appCheck(client, args = {}) {
|
|
|
73599
73740
|
live: app
|
|
73600
73741
|
});
|
|
73601
73742
|
reportPending(pending);
|
|
73743
|
+
await warnIfKitBehind(projectDir);
|
|
73602
73744
|
warnIfDynamicAliases(called);
|
|
73603
73745
|
warnIfUndeclaredCapabilities(sourceText, meta3.capabilities);
|
|
73604
73746
|
warnIfUnboundAliases(app, called);
|
|
@@ -73949,12 +74091,6 @@ function defineBlockKeys(config2) {
|
|
|
73949
74091
|
return keys3;
|
|
73950
74092
|
}
|
|
73951
74093
|
var REALTIME_SDK_FLOOR = "0.80.0";
|
|
73952
|
-
function installedAppSdkVersion(projectDir) {
|
|
73953
|
-
const manifest = path10.join(projectDir, "node_modules", "@lotics", "app-sdk", "package.json");
|
|
73954
|
-
if (!fs8.existsSync(manifest)) return null;
|
|
73955
|
-
const version2 = JSON.parse(fs8.readFileSync(manifest, "utf-8")).version;
|
|
73956
|
-
return typeof version2 === "string" ? version2 : null;
|
|
73957
|
-
}
|
|
73958
74094
|
function isVersionBelow(version2, floor2) {
|
|
73959
74095
|
const parts = (value2) => value2.split(".").map((part) => parseInt(part, 10) || 0);
|
|
73960
74096
|
const [major, minor, patch] = parts(version2);
|
|
@@ -73965,7 +74101,7 @@ function isVersionBelow(version2, floor2) {
|
|
|
73965
74101
|
}
|
|
73966
74102
|
function warnIfProjectFootguns(projectDir, sourceText) {
|
|
73967
74103
|
const lines = [];
|
|
73968
|
-
const sdkVersion =
|
|
74104
|
+
const sdkVersion = installedKitVersion(projectDir, "@lotics/app-sdk");
|
|
73969
74105
|
if (sdkVersion !== null && isVersionBelow(sdkVersion, REALTIME_SDK_FLOOR)) {
|
|
73970
74106
|
lines.push(
|
|
73971
74107
|
[
|
package/docs/cli_reference.md
CHANGED
|
@@ -45,7 +45,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
45
45
|
| `lotics upgrade` | Take the installed package's next version for the app in this directory (`app_id` from the local manifest — and the WORKSPACE from the same manifest, exactly as `lotics app *` does, so the command that knows which workspace it belongs to never rides the ambient profile). Announces its target on stderr before acting. **Applies the version it PREVIEWED**, not "latest" re-resolved server-side, so a release landing mid-command cannot install a contract whose diff was never checked. **Previews first and applies only a CLEAN upgrade**: a breaking contract change, a locally modified artifact, binding drift, or bundled knowledge needing consent (all FOUR sources the preview returns) is reported per item and REFUSED with exit 1, because each resolves by choosing what to keep and a guess discards work nobody asked to lose. Already-current is a no-op that says so. On success it names the new version and the changelog, and points at `lotics app pull` to bring the checkout in step. The resolutions flow for a conflicted upgrade stays in `opctl` — that case needs a person, and the person is an operator. |
|
|
46
46
|
| `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. |
|
|
47
47
|
| `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. |
|
|
48
|
-
| `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 the app serves that the source names nowhere, 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). 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. |
|
|
48
|
+
| `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 the app serves that the source names nowhere, 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. |
|
|
49
49
|
| `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. |
|
|
50
50
|
| `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. |
|
|
51
51
|
| `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. |
|
|
@@ -53,7 +53,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
53
53
|
| `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. |
|
|
54
54
|
| `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. |
|
|
55
55
|
| `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. |
|
|
56
|
-
| `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. **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. |
|
|
56
|
+
| `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. |
|
|
57
57
|
| `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. |
|
|
58
58
|
| `lotics xlsx <subcmd>` | Local .xlsx read/write/edit using the bundled `@lotics/xlsx` engine (no auth, no network). 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 subcommand whose trailing args are ALL flags (`xlsx read`, `docx read`, `docx append-paragraph`/`insert-paragraph`/`delete-block`) **rejects a `--flag` it does not know** — `parseArgs` files an unrecognised token as a positional, so a mistyped flag would otherwise arrive as inert text and the command would report success without it (`--with-formats` then reads as proof the file carries no styles). Subcommands whose trailing arg is CONTENT (`xlsx set-cell`, `docx replace-text`) are deliberately exempt from the FLAG check: a value may legitimately begin with `--`, and there a typo is indistinguishable from data. 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. 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). |
|
|
59
59
|
| `lotics docx <subcmd>` | Local .docx read/write/edit using the bundled `@lotics/docx` engine (OOXML round-trip surface only — no ProseMirror baggage). 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. |
|