@lotics/cli 0.104.0 → 0.106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/src/cli.js +161 -38
- package/docs/cli_reference.md +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ lotics knowledge rm kdc_... # archive
|
|
|
197
197
|
```bash
|
|
198
198
|
# Scaffold / pull / deploy a Vite+React+TS app project
|
|
199
199
|
lotics app create "Sales Desk" # scaffold + deploy v1
|
|
200
|
-
lotics app pull app_... # bootstrap an existing app locally
|
|
200
|
+
lotics app pull app_... # bootstrap an existing app locally (incl. .lotics/*)
|
|
201
201
|
lotics app deploy -m "Add quote drawer" # build + upload a new version
|
|
202
202
|
lotics app versions # deploy history: version, when, who, -m message (* = live)
|
|
203
203
|
lotics app versions app_... # ...for any app, without pulling it first
|
|
@@ -205,6 +205,8 @@ lotics app versions app_... # ...for any app, without pulling it
|
|
|
205
205
|
# Regenerate .lotics/* WITHOUT a deploy: the .d.ts type companions (always) +
|
|
206
206
|
# the runtime app_fields.ts (when authenticated) — F/OPT maps that address
|
|
207
207
|
# fields + select options by stable display-name aliases instead of opaque ids.
|
|
208
|
+
# `app pull` writes both too (a deploy archive can never carry app_fields.ts);
|
|
209
|
+
# use this after a rename, or when a pull ran offline.
|
|
208
210
|
lotics app codegen # import { F, OPT } from "../.lotics/app_fields"
|
|
209
211
|
|
|
210
212
|
# Execute a bound app workflow end-to-end (inputs: inline / @file / stdin)
|
package/dist/src/cli.js
CHANGED
|
@@ -35953,7 +35953,7 @@ var require_stream_readable = __commonJS({
|
|
|
35953
35953
|
increasedAwaitDrain = false;
|
|
35954
35954
|
var ret = dest.write(chunk);
|
|
35955
35955
|
if (false === ret && !increasedAwaitDrain) {
|
|
35956
|
-
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 &&
|
|
35956
|
+
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf3(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
35957
35957
|
debug("false write response, pause", state.awaitDrain);
|
|
35958
35958
|
state.awaitDrain++;
|
|
35959
35959
|
increasedAwaitDrain = true;
|
|
@@ -36025,7 +36025,7 @@ var require_stream_readable = __commonJS({
|
|
|
36025
36025
|
}
|
|
36026
36026
|
return this;
|
|
36027
36027
|
}
|
|
36028
|
-
var index =
|
|
36028
|
+
var index = indexOf3(state.pipes, dest);
|
|
36029
36029
|
if (index === -1) return this;
|
|
36030
36030
|
state.pipes.splice(index, 1);
|
|
36031
36031
|
state.pipesCount -= 1;
|
|
@@ -36246,7 +36246,7 @@ var require_stream_readable = __commonJS({
|
|
|
36246
36246
|
stream.emit("end");
|
|
36247
36247
|
}
|
|
36248
36248
|
}
|
|
36249
|
-
function
|
|
36249
|
+
function indexOf3(xs, x2) {
|
|
36250
36250
|
for (var i2 = 0, l = xs.length; i2 < l; i2++) {
|
|
36251
36251
|
if (xs[i2] === x2) return i2;
|
|
36252
36252
|
}
|
|
@@ -47367,7 +47367,7 @@ function walk(node, visit) {
|
|
|
47367
47367
|
}
|
|
47368
47368
|
|
|
47369
47369
|
// src/generate_app_fields.ts
|
|
47370
|
-
var HEADER = `// Auto-generated by 'lotics app codegen'
|
|
47370
|
+
var HEADER = `// Auto-generated by 'lotics app codegen' and 'lotics app pull'.
|
|
47371
47371
|
// DO NOT EDIT \u2014 regenerated from the workspace schema.
|
|
47372
47372
|
//
|
|
47373
47373
|
// Runtime field + option ids addressed by stable display-name aliases:
|
|
@@ -47486,7 +47486,7 @@ export type AppOptions = typeof OPT;
|
|
|
47486
47486
|
}
|
|
47487
47487
|
|
|
47488
47488
|
// src/generate_package_fields.ts
|
|
47489
|
-
var HEADER2 = `// Auto-generated by 'lotics app codegen' (linked/published app
|
|
47489
|
+
var HEADER2 = `// Auto-generated by 'lotics app codegen' and 'lotics app pull' (linked/published app).
|
|
47490
47490
|
// DO NOT EDIT \u2014 regenerated from the installation's live binding.
|
|
47491
47491
|
//
|
|
47492
47492
|
// A package installation resolves F/OPT/ROLE at MODULE LOAD from its binding
|
|
@@ -70527,6 +70527,43 @@ function writeBindingAppFields(projectDir, binding) {
|
|
|
70527
70527
|
ensureAppVitestSetup(projectDir);
|
|
70528
70528
|
return file2;
|
|
70529
70529
|
}
|
|
70530
|
+
async function writeGeneratedAppFields(client, projectDir, app, queries) {
|
|
70531
|
+
if (client.viewAsMemberId) {
|
|
70532
|
+
console.error(
|
|
70533
|
+
`\u26A0 Skipped .lotics/app_fields.ts \u2014 running with --view-as ${client.viewAsMemberId}. The schema is read as that member, so any table they cannot see would be silently missing from F/OPT. Re-run without --view-as to regenerate it.`
|
|
70534
|
+
);
|
|
70535
|
+
return;
|
|
70536
|
+
}
|
|
70537
|
+
try {
|
|
70538
|
+
if (app.package_id) {
|
|
70539
|
+
const binding = await client.appBinding(app.app_id);
|
|
70540
|
+
const fieldsPath = writeBindingAppFields(projectDir, binding);
|
|
70541
|
+
const count = Object.keys(binding.fields).length;
|
|
70542
|
+
console.error(
|
|
70543
|
+
`Wrote ${fieldsPath} (binding form \u2014 linked to package ${app.package_id}; ${count} field alias${count === 1 ? "" : "es"} resolved per-install)`
|
|
70544
|
+
);
|
|
70545
|
+
} else {
|
|
70546
|
+
const tableIds = resolveCodegenTableIds(projectDir, queries);
|
|
70547
|
+
const tables = await client.getWorkspaceSchema(tableIds);
|
|
70548
|
+
const fieldsPath = writeAppFields(projectDir, tables);
|
|
70549
|
+
console.error(
|
|
70550
|
+
`Wrote ${fieldsPath} (baked form \u2014 bespoke; ${tables.length} table${tables.length === 1 ? "" : "s"})`
|
|
70551
|
+
);
|
|
70552
|
+
}
|
|
70553
|
+
} catch (err2) {
|
|
70554
|
+
warnAppFieldsUnwritten(projectDir, err2);
|
|
70555
|
+
}
|
|
70556
|
+
}
|
|
70557
|
+
function warnAppFieldsUnwritten(projectDir, err2) {
|
|
70558
|
+
const reason = err2 instanceof Error ? err2.message : String(err2);
|
|
70559
|
+
if (fs4.existsSync(path5.join(projectDir, ".lotics", "app_fields.ts"))) {
|
|
70560
|
+
console.error(`\u26A0 Could not regenerate .lotics/app_fields.ts (${reason}). Kept the existing file.`);
|
|
70561
|
+
return;
|
|
70562
|
+
}
|
|
70563
|
+
console.error(
|
|
70564
|
+
`\u26A0 Could not generate .lotics/app_fields.ts (${reason}), and this project has none. Any source importing F/OPT will fail to build with 'Could not resolve "../../.lotics/app_fields"'. Run 'lotics app codegen' once you can reach the workspace.`
|
|
70565
|
+
);
|
|
70566
|
+
}
|
|
70530
70567
|
function warnIfDeployingLinkedKit(projectDir) {
|
|
70531
70568
|
const uiSrc = process.env.LOTICS_UI_SRC;
|
|
70532
70569
|
if (!uiSrc) return;
|
|
@@ -70596,23 +70633,14 @@ async function appCodegen(args) {
|
|
|
70596
70633
|
}
|
|
70597
70634
|
try {
|
|
70598
70635
|
const app = await args.client.getApp(meta3.app_id);
|
|
70599
|
-
|
|
70600
|
-
|
|
70601
|
-
|
|
70602
|
-
|
|
70603
|
-
|
|
70604
|
-
`Regenerated ${fieldsPath} (binding form \u2014 ${count} field alias${count === 1 ? "" : "es"} resolved per-install)`
|
|
70605
|
-
);
|
|
70606
|
-
} else {
|
|
70607
|
-
const tableIds = resolveCodegenTableIds(projectDir, meta3.queries ?? {});
|
|
70608
|
-
const tables = await args.client.getWorkspaceSchema(tableIds);
|
|
70609
|
-
const fieldsPath = writeAppFields(projectDir, tables);
|
|
70610
|
-
console.error(`Regenerated ${fieldsPath} (${tables.length} table${tables.length === 1 ? "" : "s"})`);
|
|
70611
|
-
}
|
|
70612
|
-
} catch (err2) {
|
|
70613
|
-
console.error(
|
|
70614
|
-
`\u26A0 Could not regenerate .lotics/app_fields.ts (${err2 instanceof Error ? err2.message : String(err2)}). Kept the existing file.`
|
|
70636
|
+
await writeGeneratedAppFields(
|
|
70637
|
+
args.client,
|
|
70638
|
+
projectDir,
|
|
70639
|
+
{ app_id: meta3.app_id, package_id: app.package_id },
|
|
70640
|
+
meta3.queries ?? {}
|
|
70615
70641
|
);
|
|
70642
|
+
} catch (err2) {
|
|
70643
|
+
warnAppFieldsUnwritten(projectDir, err2);
|
|
70616
70644
|
}
|
|
70617
70645
|
await refreshWorkflowGlobals(args.client, projectDir, meta3.app_id, meta3.workflows ?? {});
|
|
70618
70646
|
}
|
|
@@ -70805,6 +70833,12 @@ async function appPull(client, args) {
|
|
|
70805
70833
|
queries: app.queries ?? {},
|
|
70806
70834
|
agents: app.agents ?? {}
|
|
70807
70835
|
});
|
|
70836
|
+
await writeGeneratedAppFields(
|
|
70837
|
+
client,
|
|
70838
|
+
targetPath,
|
|
70839
|
+
{ app_id: app.id, package_id: app.package_id },
|
|
70840
|
+
app.queries ?? {}
|
|
70841
|
+
);
|
|
70808
70842
|
const workflows = app.workflows ?? {};
|
|
70809
70843
|
if (Object.keys(workflows).length > 0) {
|
|
70810
70844
|
const written = await writeWorkflowFiles(client, targetPath, app.id, app.name, workflows);
|
|
@@ -89700,6 +89734,93 @@ function getAttr2(el, attr) {
|
|
|
89700
89734
|
return attrs?.[`@_${attr}`];
|
|
89701
89735
|
}
|
|
89702
89736
|
|
|
89737
|
+
// ../ooxml/src/schema_order.ts
|
|
89738
|
+
var PPR_ORDER = [
|
|
89739
|
+
"w:pStyle",
|
|
89740
|
+
"w:keepNext",
|
|
89741
|
+
"w:keepLines",
|
|
89742
|
+
"w:pageBreakBefore",
|
|
89743
|
+
"w:framePr",
|
|
89744
|
+
"w:widowControl",
|
|
89745
|
+
"w:numPr",
|
|
89746
|
+
"w:suppressLineNumbers",
|
|
89747
|
+
"w:pBdr",
|
|
89748
|
+
"w:shd",
|
|
89749
|
+
"w:tabs",
|
|
89750
|
+
"w:suppressAutoHyphens",
|
|
89751
|
+
"w:kinsoku",
|
|
89752
|
+
"w:wordWrap",
|
|
89753
|
+
"w:overflowPunct",
|
|
89754
|
+
"w:topLinePunct",
|
|
89755
|
+
"w:autoSpaceDE",
|
|
89756
|
+
"w:autoSpaceDN",
|
|
89757
|
+
"w:bidi",
|
|
89758
|
+
"w:adjustRightInd",
|
|
89759
|
+
"w:snapToGrid",
|
|
89760
|
+
"w:spacing",
|
|
89761
|
+
"w:ind",
|
|
89762
|
+
"w:contextualSpacing",
|
|
89763
|
+
"w:mirrorIndents",
|
|
89764
|
+
"w:suppressOverlap",
|
|
89765
|
+
"w:jc",
|
|
89766
|
+
"w:textDirection",
|
|
89767
|
+
"w:textAlignment",
|
|
89768
|
+
"w:textboxTightWrap",
|
|
89769
|
+
"w:outlineLvl",
|
|
89770
|
+
"w:divId",
|
|
89771
|
+
"w:cnfStyle",
|
|
89772
|
+
"w:rPr",
|
|
89773
|
+
"w:sectPr",
|
|
89774
|
+
"w:pPrChange"
|
|
89775
|
+
];
|
|
89776
|
+
var RPR_ORDER = [
|
|
89777
|
+
"w:rStyle",
|
|
89778
|
+
"w:rFonts",
|
|
89779
|
+
"w:b",
|
|
89780
|
+
"w:bCs",
|
|
89781
|
+
"w:i",
|
|
89782
|
+
"w:iCs",
|
|
89783
|
+
"w:caps",
|
|
89784
|
+
"w:smallCaps",
|
|
89785
|
+
"w:strike",
|
|
89786
|
+
"w:dstrike",
|
|
89787
|
+
"w:outline",
|
|
89788
|
+
"w:shadow",
|
|
89789
|
+
"w:emboss",
|
|
89790
|
+
"w:imprint",
|
|
89791
|
+
"w:noProof",
|
|
89792
|
+
"w:snapToGrid",
|
|
89793
|
+
"w:vanish",
|
|
89794
|
+
"w:webHidden",
|
|
89795
|
+
"w:color",
|
|
89796
|
+
"w:spacing",
|
|
89797
|
+
"w:w",
|
|
89798
|
+
"w:kern",
|
|
89799
|
+
"w:position",
|
|
89800
|
+
"w:sz",
|
|
89801
|
+
"w:szCs",
|
|
89802
|
+
"w:highlight",
|
|
89803
|
+
"w:u",
|
|
89804
|
+
"w:effect",
|
|
89805
|
+
"w:bdr",
|
|
89806
|
+
"w:shd",
|
|
89807
|
+
"w:fitText",
|
|
89808
|
+
"w:vertAlign",
|
|
89809
|
+
"w:rtl",
|
|
89810
|
+
"w:cs",
|
|
89811
|
+
"w:em",
|
|
89812
|
+
"w:lang",
|
|
89813
|
+
"w:eastAsianLayout",
|
|
89814
|
+
"w:specVanish",
|
|
89815
|
+
"w:oMath",
|
|
89816
|
+
"w:rPrChange"
|
|
89817
|
+
];
|
|
89818
|
+
function indexOf2(order) {
|
|
89819
|
+
return new Map(order.map((tag, i2) => [tag, i2]));
|
|
89820
|
+
}
|
|
89821
|
+
var PPR_INDEX = indexOf2(PPR_ORDER);
|
|
89822
|
+
var RPR_INDEX = indexOf2(RPR_ORDER);
|
|
89823
|
+
|
|
89703
89824
|
// ../ooxml/src/formatting.ts
|
|
89704
89825
|
var formattingSchema = external_exports.object({
|
|
89705
89826
|
bold: external_exports.boolean().optional(),
|
|
@@ -90564,23 +90685,25 @@ var DOCUMENT_RELS_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
|
90564
90685
|
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
90565
90686
|
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
|
|
90566
90687
|
</Relationships>`;
|
|
90567
|
-
|
|
90568
|
-
|
|
90569
|
-
|
|
90570
|
-
|
|
90571
|
-
|
|
90572
|
-
|
|
90573
|
-
"
|
|
90574
|
-
|
|
90575
|
-
|
|
90576
|
-
|
|
90577
|
-
|
|
90578
|
-
|
|
90579
|
-
|
|
90688
|
+
function buildDefaultSectPr() {
|
|
90689
|
+
return {
|
|
90690
|
+
"w:sectPr": [
|
|
90691
|
+
{ "w:pgSz": [], ":@": { "@_w:w": "12240", "@_w:h": "15840" } },
|
|
90692
|
+
{
|
|
90693
|
+
"w:pgMar": [],
|
|
90694
|
+
":@": {
|
|
90695
|
+
"@_w:top": "1440",
|
|
90696
|
+
"@_w:right": "1440",
|
|
90697
|
+
"@_w:bottom": "1440",
|
|
90698
|
+
"@_w:left": "1440",
|
|
90699
|
+
"@_w:header": "720",
|
|
90700
|
+
"@_w:footer": "720",
|
|
90701
|
+
"@_w:gutter": "0"
|
|
90702
|
+
}
|
|
90580
90703
|
}
|
|
90581
|
-
|
|
90582
|
-
|
|
90583
|
-
}
|
|
90704
|
+
]
|
|
90705
|
+
};
|
|
90706
|
+
}
|
|
90584
90707
|
var DEFAULT_HEADING_SIZES = [32, 26, 24, 22, 20, 18];
|
|
90585
90708
|
function escapeXmlAttr(value) {
|
|
90586
90709
|
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -90676,7 +90799,7 @@ function createBlankDocx(opts) {
|
|
|
90676
90799
|
default_font: opts?.default_font,
|
|
90677
90800
|
default_font_size: opts?.default_font_size
|
|
90678
90801
|
}));
|
|
90679
|
-
const bodyElements = [
|
|
90802
|
+
const bodyElements = [buildDefaultSectPr()];
|
|
90680
90803
|
const documentAttrs = { ...DOCUMENT_ATTRS };
|
|
90681
90804
|
if (opts?.page) setPageLayout(bodyElements, opts.page);
|
|
90682
90805
|
return { zip, bodyElements, documentAttrs };
|
package/docs/cli_reference.md
CHANGED
|
@@ -29,21 +29,21 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
29
29
|
| `lotics knowledge update <id> [--from <file.md> \| --content <str>] [--name <n>] [--description <d>]` | Call `update_knowledge` with **only** the provided fields (a body from --from/--content becomes `content`; the tool diffs + CASes the content change internally, so the CLI passes no `expected_content_file_id`). At least one field required; --from and --content are mutually exclusive. |
|
|
30
30
|
| `lotics knowledge rm <id>` | Archive the doc via `delete_knowledge` (`{ knowledge_doc_id }`). The REST execute path does not gate `needsApproval`, so this runs unattended. |
|
|
31
31
|
| `lotics app create <name> [path]` | Scaffold a Vite+React+TS custom-code app project; POST /v1/apps; npm install; vite build; upload as v1 |
|
|
32
|
-
| `lotics app pull <app_id> [path]` | Download source archive from R2 (presigned), extract, npm install, stamp package.json's `lotics` field. With no `[path]`: refresh the cwd IN PLACE when it's already this app's own project (its manifest `app_id` matches — the documented `cd <app> && lotics app pull` flow), else clone into an `<name>/` subdir; this avoids the stray nested `./<name>/` subdir a pull-from-inside-the-app used to drop. — `workflows` and `agents` are sourced from the live App row (NOT the archived manifest), so `set_app_workflow` / `set_app_agent` authoring survives the pull. Regenerates `.lotics/app_{workflows,queries,agents}.d.ts` so `useWorkflow` / `useQuery` / `useAgentRun` stay typed. Also writes one `src/workflows/<alias>.ts` per bound workflow (faithful body from `get_app_workflow`) and one `src/agents/<alias>.md` per bound agent (its instructions, straight off the live row) — so the prose an author actually edits lives in a file, and pull always overwrites it from live, leaving no second copy to drift. A legacy workflow alias with no rendered source, or an agent with no instructions, warns and is skipped. The stamped `lotics.agents` map carries the TYPED half only (`inputs`/`outputs`/`tool_names`/`model_id`/…) — an agent's prose lives solely in its `.md`, so there is never a second local copy to desync; a stale `instructions` left by an older CLI is inert and disappears on the next pull |
|
|
32
|
+
| `lotics app pull <app_id> [path]` | Download source archive from R2 (presigned), extract, npm install, stamp package.json's `lotics` field. With no `[path]`: refresh the cwd IN PLACE when it's already this app's own project (its manifest `app_id` matches — the documented `cd <app> && lotics app pull` flow), else clone into an `<name>/` subdir; this avoids the stray nested `./<name>/` subdir a pull-from-inside-the-app used to drop. — `workflows` and `agents` are sourced from the live App row (NOT the archived manifest), so `set_app_workflow` / `set_app_agent` authoring survives the pull. Regenerates `.lotics/app_{workflows,queries,agents}.d.ts` so `useWorkflow` / `useQuery` / `useAgentRun` stay typed, AND the runtime `.lotics/app_fields.ts` (the same linked-vs-bespoke branch `app codegen` runs, off the app row already fetched — see that row for the two forms). That one is not optional: `app deploy` tars source with `--exclude=.lotics`, so no archive can carry it, and a pulled project whose `src/` imports `F`/`OPT` would fail to build with `Could not resolve "../../.lotics/app_fields"` until `app codegen` was run by hand. The write NAMES the form and the reason, because an in-place pull can FLIP a project between them (`opctl app publish` links an origin, `package eject` unlinks it) and that changes what the module does at load. Skipped under `--view-as` (the schema is read as that member and silently drops tables they cannot see — a narrowed `F` map compiles and then throws at runtime, worse than the missing module). A binding/schema fetch failure is non-fatal and names the right recovery for what is on disk: an existing file is kept, an ABSENT one warns about the build error and points at `app codegen`. Pull GENERATES but never RECONCILES `.lotics/` — deleting a companion whose alias the manifest no longer declares is `app codegen`'s alone, since pull's authority is the server's alias set and a declared-but-not-yet-`set` alias is supported. Also writes one `src/workflows/<alias>.ts` per bound workflow (faithful body from `get_app_workflow`) and one `src/agents/<alias>.md` per bound agent (its instructions, straight off the live row) — so the prose an author actually edits lives in a file, and pull always overwrites it from live, leaving no second copy to drift. A legacy workflow alias with no rendered source, or an agent with no instructions, warns and is skipped. The stamped `lotics.agents` map carries the TYPED half only (`inputs`/`outputs`/`tool_names`/`model_id`/…) — an agent's prose lives solely in its `.md`, so there is never a second local copy to desync; a stale `instructions` left by an older CLI is inert and disappears on the next pull |
|
|
33
33
|
| `lotics app deploy -m <message>` | **`-m` is REQUIRED** (CLI errors without a non-empty message) — each deploy is a version row read back by `lotics app versions`, so a blank message loses the audit trail. npm run build; tar source + dist; POST /v1/apps/{id}/versions multipart. Carries code + capabilities only — **neither queries nor workflow/agent bindings are a deploy concern** (`set_app_workflow` / `remove_app_workflow` own `apps.workflows`; the manifest's `workflows` map is a pulled reflection, read by `useWorkflow` codegen and by `app workflow set`, never written by a deploy). Deploy DOES send the manifest's `lotics.workflows` alias KEYS (not the bindings) as `workflow_aliases`, recorded on the version row so `remove_app_workflow` can refuse to unbind an alias the served version still declares. It also reports any `lotics.queries` alias whose declaration DIFFERS from the app's, naming both recoveries (`app query set --all` to push yours, `app pull` to adopt the app's) — a deploy no longer writes them, so the two are allowed to drift. After a successful deploy it **warns loudly about any alias the source CALLS that is NOT bound on the server** (a `getApp` diff via `warnIfUnboundAliases`) — since deploy never binds them, that would otherwise throw only at the app's first `useWorkflow` / `useAgentRun` call; the warning points to `lotics app workflow set` / `set_app_agent`. Advisory only (never fails the deploy). |
|
|
34
34
|
| `lotics app versions [app_id]` | `GET /v1/apps/{id}/versions` — print deploy history newest-first (version number, timestamp, deployer name, build status, the `-m` message; `*` marks the currently-served version). app_id from the local manifest, or pass one to inspect any app without pulling it. Admin-only server-side (mirrors deploy + source download). Answers "what shipped, when, by whom" — e.g. whether a fix was live at an incident's time. The deploy pipeline already persisted all of this in `app_versions`; this is the read surface. Title → stderr, table → stdout (pipeable). |
|
|
35
35
|
| `lotics app codegen [path]` | Regenerate `.lotics/*` from the manifest + workspace schema **without a deploy**. The three `.d.ts` companions (`app_{workflows,queries,agents}.d.ts`) are always rewritten (synchronous, no network). When credentials resolve, also rewrites the **runtime** `.lotics/app_fields.ts` — **branched on whether the app is a package installation** (`getApp().package_id` set, from `generate_package_fields.ts`): a **linked/published** app emits the BINDING form (`F`/`OPT`/`ROLE` resolved from the installation's LIVE binding — via `appBinding` / the `binding` RPC — at module load through `getAppBinding()` + top-level await, so the source stays portable across every install); a **bespoke** app emits the BAKED form (`generate_app_fields.ts`) — a real `.ts` exporting `F` (table→field→`"fld_…"`) + `OPT` (table→select-field→option→`"opt_…"`) keyed by display-name aliases, for the tables the app's queries reference (+ optional `package.json#lotics.codegen.tables` allowlist). Both forms share the `F`/`OPT` shape (contract aliases derive from the same slugified display names), so a published origin's deployed source compiles unchanged. Writing the BINDING form also heals the project's vitest setup (`ensureAppVitestSetup`, folded into the same write boundary): the binding form awaits `getAppBinding()` (a network call) at module load, so without a stub `npm test` fails to collect any test that imports the app graph — the heal writes `vitest.setup.ts` (mocks only `getAppBinding`, returning an echo binding: any alias → a self-identifying `fld:test:…`/`opt:test:…`/`grp:test:…` id) if absent, and warns the one-liner to add to `vite.config.ts`'s `test.setupFiles` if the wiring is missing (TS source isn't safely munged, mirroring `ensureAppTsconfig`'s JSONC-tsconfig warn). New scaffolds ship both. Also refreshes each bound workflow's `.lotics/workflows/<alias>.globals.d.ts` + re-wraps its EXISTING `src/workflows/<alias>.ts` body in the current envelope (strips + re-wraps; never re-fetches the body, so local edits survive). **`.lotics/` is reconciled to the manifest, not merely added to** — a `<alias>.globals.d.ts` whose alias the manifest no longer declares is DELETED (that directory is read as the app's alias inventory, so a companion for a binding nobody can reach misreports what the app has). Only that exact filename shape is removed; anything else in the directory is left alone. The reconcile runs before the credential branch, so it happens offline too. The authored counterpart is never deleted — a `src/workflows/<alias>.ts` the manifest does not declare is NAMED instead (`check` and `set` both take their alias set from the manifest, so editing an undeclared body is a silent no-op). A getApp / binding / schema / dts-fetch failure is non-fatal (warns, keeps the last-generated files). |
|
|
36
|
-
| `lotics app workflow run <alias> '<json>'` | Execute a bound app workflow end-to-end via `appWorkflow`. `app_id` comes from the local manifest; the alias must be bound (`set_app_workflow`). Inputs ingest exactly like `lotics run` (inline JSON / `@file` / stdin — bulk inputs bypass `ARG_MAX`). Prints the full `{status,message,data,files,side_effects}` JSON to stdout + a one-line summary to stderr; exits non-zero on `status:"error"` (assertable). `--print-created` (alias `--report-effects`) renders the honest post-run harvest
|
|
36
|
+
| `lotics app workflow run <alias> '<json>'` | Execute a bound app workflow end-to-end via `appWorkflow`. `app_id` comes from the local manifest; the alias must be bound (`set_app_workflow`). Inputs ingest exactly like `lotics run` (inline JSON / `@file` / stdin — bulk inputs bypass `ARG_MAX`). Prints the full `{status,message,data,files,side_effects}` JSON to stdout + a one-line summary to stderr; exits non-zero on `status:"error"` (assertable). `--print-created` (alias `--report-effects`) renders the honest post-run harvest: created records grouped by table, a paste-ready `lotics run delete_records …` per table, then the **mandatory caveat** naming what cannot be auto-undone (external integrations + notifications) and that sub-workflows may have run. `--cleanup` (DEFAULT OFF, implies the report) additionally runs the deletes for harvested records ONLY — never files / external / notifications. Neither is a rollback — a rollback is structurally impossible here. |
|
|
37
37
|
| `lotics app workflow set <alias>` | Push the edited `src/workflows/<alias>.ts` body through `set_app_workflow` (the single author of `apps.workflows`). Reads the body from disk (header + `/// <reference>` + `export {};` marker + the `__workflow` wrapper all stripped) + the typed `inputs`/`outputs` **and the `description`** from `package.json#lotics.workflows.<alias>`; the **server** re-verifies the body and echoes the bound `outputs` (declared, else DERIVED from `return({ data })`). The `description` is the one line an agent reads when choosing between the app's aliases (the workflow counterpart to a query's) — authored in the manifest so it lives beside the body in version control and rides every push; omit it and the workflow keeps whatever description it already has, so a push can never blank one set elsewhere. When the manifest declared NO `outputs`, the DERIVED echo is written back into `package.json#lotics.workflows.<alias>.outputs` (a SURGICAL write — preserves `knowledge`/`config` and every other manifest field) and that alias's types are refreshed in place, so `useWorkflow("<alias>")`'s `result.data` is typed immediately with no hand-copy and no second `lotics app codegen`; an explicitly-declared `outputs` is authoritative and never overwritten. Deploy still never authors workflows — this is a CLI convenience over the existing tool. Clear error + non-zero exit on a missing file, an alias absent from the manifest, or a verify failure. |
|
|
38
38
|
| `lotics app agent set <alias>` | Push the edited `src/agents/<alias>.md` instructions back through `set_app_agent` — the agent mirror of `app workflow set`, and the deploy-free authoring path for `apps.agents`. Reads the prose from disk (the `<!-- lotics: … -->` header stripped) and the typed fields (`inputs`/`outputs`/`tool_names`/`model_id`/`effort_level`/`knowledge_doc_ids`/`query_aliases`/`workflow_aliases`) from `package.json#lotics.agents.<alias>`, then sends them as ONE declaration. That assembly is the point: **`set_app_agent` REPLACES the declaration rather than patching it**, so a hand-built payload that sets one field silently drops the instructions, the output schema and the model pin — a silent, unrecoverable edit against a live prompt. Clear error + non-zero exit on a missing file, an alias absent from the manifest, or a file that is empty once the header is stripped (refusing to push an empty prompt). `app pull` writes the file; edit, then `set`. |
|
|
39
39
|
| `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 ships code and binds nothing. 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. |
|
|
40
|
-
| `lotics app agent run <app_id> <alias> ['<json>'\|@file\|stdin]` | Run a bound app agent end-to-end
|
|
40
|
+
| `lotics app agent run <app_id> <alias> ['<json>'\|@file\|stdin]` | Run a bound app agent end-to-end. A run needs no deployed UI bundle — just the app row + the bound agent declaration + member auth — so the **`app_id` is explicit** (not read from a local manifest). Inputs ingest exactly like `lotics run` (inline JSON / `@file` / stdin; empty = `{}`). Opens the run's SSE (`appAgentRunStream`), streams `text-delta` prose to **stderr** as live progress, then reports from the **settled run RECORD** (`listAgentRuns`, polled to a terminal status — the client stream can close a beat before the run settles, or drop while it runs on server-side): default prints the run's structured `output` (JSON) or final text to **stdout** + a status line to stderr; `--json` prints the full run summary to stdout. Selects THIS run by the `x-app-agent-run-id` header (ordering-independent). Exits 0 **only** when the settled status is `completed`; otherwise non-zero with the run's error surfaced. A settled run that never appears fails loudly (never a silent success). A fresh `session_id` is minted per run (self-contained); `--session <id>` continues an existing thread (prior runs become the agent's context). |
|
|
41
41
|
| `lotics app workflow pull` | Rewrite every `src/workflows/<alias>.ts` from the server (faithful body per bound alias via `get_app_workflow`) **+ its `.lotics/workflows/<alias>.globals.d.ts`** (via `getAppWorkflowDts`, so the body is locally typecheckable via `lotics app workflow check`) without a full `app pull` (no source archive, no npm install). A legacy alias with no rendered source warns and is skipped; a dts-fetch failure is non-fatal (body still written with the fallback wrapper, typecheck degraded). Each alias's `description` is folded back into `package.json#lotics.workflows.<alias>` from the same read — the alias binding the manifest is otherwise stamped from carries `inputs`/`outputs` but not the description, which lives on the workflow ROW, so without this a pull would erase an authored one. The server's GENERATED default is skipped, so an app that never described its workflows gains no manifest noise. Also idempotently patches the main `tsconfig.json` `exclude` to cover `src/workflows` + `.lotics/workflows` so a pre-existing app's `npm run typecheck` never loads the bodies or the colliding per-alias globals. |
|
|
42
|
-
| `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 — that is what let the two diverge once) 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
|
|
42
|
+
| `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 — that is what let the two diverge once) 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 (compiling the raw text went red on it), 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 (run a pull). |
|
|
43
43
|
| `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. |
|
|
44
44
|
| `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. |
|
|
45
|
-
| `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
|
|
46
|
-
| `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: the app's own `vite.config.ts` reads the variable and adds a `{ find: /^@lotics\/ui\/(.+)$/, replacement: "<LOTICS_UI_SRC>/$1" }` entry to `resolve.alias`, so kit edits go live under `lotics app dev` (HMR) and bundle under `lotics app deploy`. Unset ⇒ the kit resolves from `node_modules` as normal. **Nothing is written to disk** — there is no link/unlink step, nothing to leave switched on, and no config for the CLI to corrupt (the `lotics ui link` command this replaces edited `vite.config.ts` by regex and twice deleted the load-bearing `react-native` → `react-native-web` alias with the array's closing bracket, breaking the app's build entirely
|
|
45
|
+
| `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. 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. |
|
|
46
|
+
| `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: the app's own `vite.config.ts` reads the variable and adds a `{ find: /^@lotics\/ui\/(.+)$/, replacement: "<LOTICS_UI_SRC>/$1" }` entry to `resolve.alias`, so kit edits go live under `lotics app dev` (HMR) and bundle under `lotics app deploy`. Unset ⇒ the kit resolves from `node_modules` as normal. **Nothing is written to disk** — there is no link/unlink step, nothing to leave switched on, and no config for the CLI to corrupt (the `lotics ui link` command this replaces edited `vite.config.ts` by regex and twice deleted the load-bearing `react-native` → `react-native-web` alias with the array's closing bracket, breaking the app's build entirely). Identical for a monorepo app and an EXTERNAL one (e.g. `~/lotics_apps`). `app dev` **warns** when the variable is set but the app's `vite.config.ts` predates it (scaffolded earlier) and prints the lines to add; `app deploy` **warns** that the bundle carries kit code from your working copy rather than the published package. **Vite-only, by design:** the app's `tsc` still resolves `@lotics/ui` from `node_modules` (the published `.d.ts`) — the kit `src` can't be typechecked inside an app because it's RN-Web, so typecheck the kit in `packages/ui` and let the finalize publish restore the app's own typecheck. |
|
|
47
47
|
| `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. Atomic in-place write (temp file + rename). |
|
|
48
48
|
| `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. |
|
|
49
49
|
| `lotics file preview <file\|fil_id> [-o out.png]` | (also `lotics preview`) Render a .docx/.xlsx to a PNG using the SAME engines the frontend FilePreview uses (`@lotics/docx` `loadDocxIntoElement` / `@lotics/xlsx` `drawSpreadsheet`) — so what you see matches an operator. Accepts a **local path** OR a stored **`fil_…` id** (`isStoredFileId` — a bare id, no extension): an id is first downloaded to a temp dir via `downloadFileById` (the `signed_url` presign path — same authority as `lotics file download`), rendered, then the transient source is removed; with no `-o` the PNG lands in cwd under the stored file's base name (`defaultPreviewOutputPath`). Drives a headless Chrome over **CDP with only Node built-ins** (`WebSocket`/`fetch`/`http`/`child_process`) — zero npm deps, the CLI stays a single bundled binary. The browser render logic is a separate esbuild **browser** bundle shipped at `dist/render_page.js` (built by `build_cli.mjs`, excluded from the node `tsgo`), served over a throwaway localhost http server and screenshotted full-page. **Requires a Chrome/Chromium on the machine** — detected from `CHROME_PATH`/`LOTICS_CHROME`, then Playwright's installed chromium, then system paths — inherent to rendering these browser formats; a clear "install a browser" error otherwise. PDFs need no render (open them directly). |
|