@lotics/cli 0.179.0 → 0.181.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 +145 -79
- package/docs/cli_reference.md +5 -5
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -45711,7 +45711,7 @@ function resultSideEffects(result) {
|
|
|
45711
45711
|
}
|
|
45712
45712
|
|
|
45713
45713
|
// src/version.ts
|
|
45714
|
-
var VERSION = "0.
|
|
45714
|
+
var VERSION = "0.181.0";
|
|
45715
45715
|
|
|
45716
45716
|
// src/timezone.ts
|
|
45717
45717
|
function machineTimezone() {
|
|
@@ -46112,6 +46112,53 @@ function matchesKnownFlag(known, arg) {
|
|
|
46112
46112
|
return known.some((k) => k.endsWith("=") ? arg.startsWith(k) : arg === k);
|
|
46113
46113
|
}
|
|
46114
46114
|
|
|
46115
|
+
// src/inputs.ts
|
|
46116
|
+
function shellQuotingHint(raw, source) {
|
|
46117
|
+
if (source !== "inline") return null;
|
|
46118
|
+
if (!/^\s*[[{]/.test(raw) || raw.includes('"')) return null;
|
|
46119
|
+
return "No double quotes reached the CLI \u2014 the shell consumed them, which PowerShell does to an inline argument. Write the JSON to a file and pass it as @args.json, or pipe it on stdin; neither goes through the shell's quoting.";
|
|
46120
|
+
}
|
|
46121
|
+
function readStdin() {
|
|
46122
|
+
return new Promise((resolve2, reject2) => {
|
|
46123
|
+
const chunks = [];
|
|
46124
|
+
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
46125
|
+
process.stdin.on("end", () => resolve2(Buffer.concat(chunks).toString("utf-8").trim()));
|
|
46126
|
+
process.stdin.on("error", reject2);
|
|
46127
|
+
});
|
|
46128
|
+
}
|
|
46129
|
+
async function ingestJsonArgs(opts) {
|
|
46130
|
+
let raw = opts.rawArg;
|
|
46131
|
+
let source = "inline";
|
|
46132
|
+
if (raw && raw.startsWith("@")) {
|
|
46133
|
+
source = "file";
|
|
46134
|
+
const argsPath = raw.slice(1);
|
|
46135
|
+
try {
|
|
46136
|
+
raw = opts.readFile(argsPath);
|
|
46137
|
+
} catch (err2) {
|
|
46138
|
+
return {
|
|
46139
|
+
kind: "error",
|
|
46140
|
+
message: `Cannot read args file "${argsPath}": ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
46141
|
+
};
|
|
46142
|
+
}
|
|
46143
|
+
} else if (!raw && !opts.stdinIsTTY) {
|
|
46144
|
+
source = "stdin";
|
|
46145
|
+
raw = await opts.readStdin();
|
|
46146
|
+
}
|
|
46147
|
+
if (!raw) return { kind: "ok", args: {} };
|
|
46148
|
+
try {
|
|
46149
|
+
const parsed = JSON.parse(raw);
|
|
46150
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
46151
|
+
return { kind: "error", message: `JSON args must be an object, got: ${raw}` };
|
|
46152
|
+
}
|
|
46153
|
+
return { kind: "ok", args: parsed };
|
|
46154
|
+
} catch {
|
|
46155
|
+
const hint = shellQuotingHint(raw, source);
|
|
46156
|
+
return { kind: "error", message: `Invalid JSON: ${raw}${hint ? `
|
|
46157
|
+
|
|
46158
|
+
${hint}` : ""}` };
|
|
46159
|
+
}
|
|
46160
|
+
}
|
|
46161
|
+
|
|
46115
46162
|
// src/report_command.ts
|
|
46116
46163
|
import fs6 from "node:fs";
|
|
46117
46164
|
import path6 from "node:path";
|
|
@@ -46141,15 +46188,18 @@ There is no severity or category to pick. How bad and how common are read off
|
|
|
46141
46188
|
the corpus; what you were trying to do is not recoverable from anywhere else.
|
|
46142
46189
|
|
|
46143
46190
|
Do not paste customer records, file contents, or credentials.`;
|
|
46144
|
-
function parseReport(raw) {
|
|
46191
|
+
function parseReport(raw, source) {
|
|
46145
46192
|
const text = raw.trim();
|
|
46146
46193
|
if (text === "") return { error: "Nothing to report." };
|
|
46147
46194
|
let parsed;
|
|
46148
46195
|
try {
|
|
46149
46196
|
parsed = JSON.parse(text);
|
|
46150
46197
|
} catch {
|
|
46198
|
+
const hint = shellQuotingHint(text, source);
|
|
46151
46199
|
return {
|
|
46152
|
-
error: text.startsWith("{") ? "That is not valid JSON." : "A report is a JSON object, not a sentence \u2014 the frame below is what makes it debuggable."
|
|
46200
|
+
error: (text.startsWith("{") ? "That is not valid JSON." : "A report is a JSON object, not a sentence \u2014 the frame below is what makes it debuggable.") + (hint ? `
|
|
46201
|
+
|
|
46202
|
+
${hint}` : "")
|
|
46153
46203
|
};
|
|
46154
46204
|
}
|
|
46155
46205
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
@@ -71859,7 +71909,12 @@ function readAppMeta(projectDir) {
|
|
|
71859
71909
|
workflows: pkg.lotics.workflows ?? {},
|
|
71860
71910
|
queries: pkg.lotics.queries ?? {},
|
|
71861
71911
|
agents: pkg.lotics.agents ?? {},
|
|
71862
|
-
capabilities: pkg.lotics.capabilities
|
|
71912
|
+
capabilities: pkg.lotics.capabilities,
|
|
71913
|
+
// Deliberately NOT defaulted: absent must stay absent, because absent is
|
|
71914
|
+
// what tells the orphan report it has no baseline to compare against and
|
|
71915
|
+
// must say nothing. An `?? {queries:[],…}` here would read as "the last
|
|
71916
|
+
// bundle called nothing" and make every live binding look deleted.
|
|
71917
|
+
bundle_calls: pkg.lotics.bundle_calls
|
|
71863
71918
|
};
|
|
71864
71919
|
}
|
|
71865
71920
|
function writeAppMeta(projectDir, meta3) {
|
|
@@ -72676,6 +72731,9 @@ async function appDeploy(client, args) {
|
|
|
72676
72731
|
...meta3,
|
|
72677
72732
|
current_version_id: result.version_id,
|
|
72678
72733
|
version_number: result.version_number
|
|
72734
|
+
// `bundle_calls` is deliberately NOT stamped here — see the advance
|
|
72735
|
+
// below. Omitting it preserves the previous set, which is what keeps an
|
|
72736
|
+
// unresolved orphan reportable on the next run.
|
|
72679
72737
|
});
|
|
72680
72738
|
note(`Deployed v${result.version_number} (${result.version_id})`);
|
|
72681
72739
|
note(`Bundle size: ${(result.bundle_size_bytes / 1024).toFixed(1)} KB`);
|
|
@@ -72702,16 +72760,34 @@ async function appDeploy(client, args) {
|
|
|
72702
72760
|
warnIfInertAgentTools(liveAfter);
|
|
72703
72761
|
}
|
|
72704
72762
|
if (liveAfter) {
|
|
72763
|
+
const orphans = orphanedBindings(called, liveAfter, meta3.bundle_calls);
|
|
72764
|
+
let outstanding = orphans;
|
|
72705
72765
|
if (args.prune) {
|
|
72706
|
-
|
|
72766
|
+
if (!meta3.bundle_calls) {
|
|
72767
|
+
note(
|
|
72768
|
+
"Nothing to prune yet: this project has no record of what the previous bundle called, so there is no way to tell a retired binding from an agent-facing one. This deploy records it; the next can compare."
|
|
72769
|
+
);
|
|
72770
|
+
}
|
|
72771
|
+
outstanding = await pruneOrphanedBindings(
|
|
72707
72772
|
client,
|
|
72708
72773
|
projectDir,
|
|
72709
72774
|
{ app_id: meta3.app_id },
|
|
72710
|
-
|
|
72775
|
+
orphans,
|
|
72711
72776
|
called.dynamic
|
|
72712
72777
|
);
|
|
72713
72778
|
} else {
|
|
72714
|
-
warnAboutOrphanedBindings(called, liveAfter);
|
|
72779
|
+
warnAboutOrphanedBindings(called, liveAfter, meta3.bundle_calls);
|
|
72780
|
+
}
|
|
72781
|
+
const settled = outstanding.queries.length === 0 && outstanding.workflows.length === 0 && outstanding.agents.length === 0;
|
|
72782
|
+
if (settled) {
|
|
72783
|
+
writeAppMeta(projectDir, {
|
|
72784
|
+
...readAppMeta(projectDir),
|
|
72785
|
+
bundle_calls: {
|
|
72786
|
+
queries: called.queries,
|
|
72787
|
+
workflows: called.workflows,
|
|
72788
|
+
agents: called.agents
|
|
72789
|
+
}
|
|
72790
|
+
});
|
|
72715
72791
|
}
|
|
72716
72792
|
}
|
|
72717
72793
|
} catch (err2) {
|
|
@@ -72770,7 +72846,7 @@ async function appCheck(client, args = {}) {
|
|
|
72770
72846
|
const sourceText = readAppSourceText(projectDir);
|
|
72771
72847
|
const called = calledAppAliases(sourceText);
|
|
72772
72848
|
warnAboutDevLink(projectDir, "deploy");
|
|
72773
|
-
warnAboutOrphanedBindings(called, app);
|
|
72849
|
+
warnAboutOrphanedBindings(called, app, meta3.bundle_calls);
|
|
72774
72850
|
const pending = pendingBindings({
|
|
72775
72851
|
projectDir,
|
|
72776
72852
|
meta: meta3,
|
|
@@ -72896,7 +72972,8 @@ function divergedWorkflowAliases(manifestWorkflows, liveWorkflows) {
|
|
|
72896
72972
|
...new Set(workflowTypeDivergences(manifestWorkflows, liveWorkflows).map((d) => d.alias))
|
|
72897
72973
|
].sort();
|
|
72898
72974
|
}
|
|
72899
|
-
function orphanedBindings(called, live) {
|
|
72975
|
+
function orphanedBindings(called, live, previouslyCalled) {
|
|
72976
|
+
if (!previouslyCalled) return { queries: [], workflows: [], agents: [] };
|
|
72900
72977
|
const agentDeclarations = Object.values(live.agents ?? {});
|
|
72901
72978
|
const referenced = {
|
|
72902
72979
|
queries: [...called.queries, ...agentDeclarations.flatMap((a) => a.query_aliases ?? [])],
|
|
@@ -72904,17 +72981,22 @@ function orphanedBindings(called, live) {
|
|
|
72904
72981
|
// Nothing declares an agent but the client bundle — an agent cannot run another.
|
|
72905
72982
|
agents: called.agents
|
|
72906
72983
|
};
|
|
72984
|
+
const stillBound = {
|
|
72985
|
+
queries: new Set(Object.keys(live.queries ?? {})),
|
|
72986
|
+
workflows: new Set(Object.keys(live.workflows ?? {})),
|
|
72987
|
+
agents: new Set(Object.keys(live.agents ?? {}))
|
|
72988
|
+
};
|
|
72907
72989
|
return orphanedAliases(
|
|
72908
72990
|
{
|
|
72909
|
-
queries:
|
|
72910
|
-
workflows:
|
|
72911
|
-
agents:
|
|
72991
|
+
queries: previouslyCalled.queries.filter((a) => stillBound.queries.has(a)),
|
|
72992
|
+
workflows: previouslyCalled.workflows.filter((a) => stillBound.workflows.has(a)),
|
|
72993
|
+
agents: previouslyCalled.agents.filter((a) => stillBound.agents.has(a))
|
|
72912
72994
|
},
|
|
72913
72995
|
referenced
|
|
72914
72996
|
);
|
|
72915
72997
|
}
|
|
72916
|
-
function warnAboutOrphanedBindings(called, live) {
|
|
72917
|
-
const orphans = orphanedBindings(called, live);
|
|
72998
|
+
function warnAboutOrphanedBindings(called, live, previouslyCalled) {
|
|
72999
|
+
const orphans = orphanedBindings(called, live, previouslyCalled);
|
|
72918
73000
|
const lines = [
|
|
72919
73001
|
...orphans.queries.map((a) => ` \u2022 query ${a}`),
|
|
72920
73002
|
...orphans.workflows.map((a) => ` \u2022 workflow ${a}`),
|
|
@@ -72923,20 +73005,26 @@ function warnAboutOrphanedBindings(called, live) {
|
|
|
72923
73005
|
if (lines.length === 0) return 0;
|
|
72924
73006
|
console.error(
|
|
72925
73007
|
`
|
|
72926
|
-
\u26A0 ${lines.length} binding(s)
|
|
73008
|
+
\u26A0 ${lines.length} binding(s) still live that this bundle STOPPED calling:
|
|
72927
73009
|
` + lines.join("\n") + (called.dynamic.length > 0 ? `
|
|
72928
73010
|
|
|
72929
73011
|
This app computes an alias at runtime, so one of these may be called after
|
|
72930
73012
|
all \u2014 and \`--prune\` therefore leaves them ALL in place. Make those call
|
|
72931
73013
|
sites literal to prune them.` : `
|
|
72932
73014
|
|
|
72933
|
-
|
|
72934
|
-
|
|
72935
|
-
site
|
|
73015
|
+
Removing the call site does not unbind it, so it keeps serving. It also
|
|
73016
|
+
stays published to chat and to MCP, which reach an alias with no call
|
|
73017
|
+
site \u2014 so an agent can still invoke what you meant to retire.
|
|
73018
|
+
To unbind: lotics app deploy --prune`)
|
|
72936
73019
|
);
|
|
72937
73020
|
return lines.length;
|
|
72938
73021
|
}
|
|
72939
73022
|
async function pruneOrphanedBindings(client, projectDir, app, orphans, dynamic) {
|
|
73023
|
+
const stillBound = {
|
|
73024
|
+
queries: [],
|
|
73025
|
+
workflows: [],
|
|
73026
|
+
agents: []
|
|
73027
|
+
};
|
|
72940
73028
|
const targets = [
|
|
72941
73029
|
...orphans.queries.map((alias) => ({
|
|
72942
73030
|
tool: "remove_app_query",
|
|
@@ -72960,7 +73048,7 @@ async function pruneOrphanedBindings(client, projectDir, app, orphans, dynamic)
|
|
|
72960
73048
|
setCommand: `lotics app agent set ${alias}`
|
|
72961
73049
|
}))
|
|
72962
73050
|
];
|
|
72963
|
-
if (targets.length === 0) return;
|
|
73051
|
+
if (targets.length === 0) return stillBound;
|
|
72964
73052
|
if (dynamic.length > 0) {
|
|
72965
73053
|
console.error(
|
|
72966
73054
|
`
|
|
@@ -72968,7 +73056,8 @@ async function pruneOrphanedBindings(client, projectDir, app, orphans, dynamic)
|
|
|
72968
73056
|
` + targets.map((t) => ` \u2022 ${t.label}`).join("\n") + `
|
|
72969
73057
|
Make those call sites literal and the next deploy will clean them up, or remove the ones you know are dead by hand.`
|
|
72970
73058
|
);
|
|
72971
|
-
|
|
73059
|
+
for (const t of targets) stillBound[t.kind].push(t.alias);
|
|
73060
|
+
return stillBound;
|
|
72972
73061
|
}
|
|
72973
73062
|
const tablesBefore = new Set(resolveCodegenTableIds(projectDir, readAppMeta(projectDir).queries ?? {}));
|
|
72974
73063
|
let removedLocally = false;
|
|
@@ -72976,6 +73065,7 @@ async function pruneOrphanedBindings(client, projectDir, app, orphans, dynamic)
|
|
|
72976
73065
|
const res = await client.execute(target.tool, { app_id: app.app_id, alias: target.alias });
|
|
72977
73066
|
if (res.error) {
|
|
72978
73067
|
console.error(` \u2717 could not unbind ${target.label} \u2014 ${res.error}`);
|
|
73068
|
+
stillBound[target.kind].push(target.alias);
|
|
72979
73069
|
continue;
|
|
72980
73070
|
}
|
|
72981
73071
|
let line;
|
|
@@ -73025,6 +73115,7 @@ async function pruneOrphanedBindings(client, projectDir, app, orphans, dynamic)
|
|
|
73025
73115
|
);
|
|
73026
73116
|
}
|
|
73027
73117
|
}
|
|
73118
|
+
return stillBound;
|
|
73028
73119
|
}
|
|
73029
73120
|
function derivedDeployMessage(pending) {
|
|
73030
73121
|
const parts = [
|
|
@@ -74069,6 +74160,10 @@ function instantiateBody(args) {
|
|
|
74069
74160
|
}
|
|
74070
74161
|
async function starterInit(client, args) {
|
|
74071
74162
|
const starter = await client.getPackage(args.starter_id);
|
|
74163
|
+
const targetPath = path10.resolve(args.targetPath ?? appDirName(starter.name));
|
|
74164
|
+
if (fs9.existsSync(targetPath) && fs9.readdirSync(targetPath).length > 0) {
|
|
74165
|
+
throw new Error(`Target directory ${targetPath} is not empty. Pass an empty path and re-run.`);
|
|
74166
|
+
}
|
|
74072
74167
|
note(
|
|
74073
74168
|
`Copying ${starter.name}${starter.is_official ? " (official)" : ""} into this workspace\u2026`
|
|
74074
74169
|
);
|
|
@@ -74101,12 +74196,6 @@ Done \u2014 these are yours now, with no link back to the starter.`);
|
|
|
74101
74196
|
signin_url: null
|
|
74102
74197
|
};
|
|
74103
74198
|
}
|
|
74104
|
-
const targetPath = path10.resolve(args.targetPath ?? appDirName(starter.name));
|
|
74105
|
-
if (fs9.existsSync(targetPath) && fs9.readdirSync(targetPath).length > 0) {
|
|
74106
|
-
throw new Error(
|
|
74107
|
-
`Target directory ${targetPath} is not empty. The app (${result.app_id}) was created \u2014 pass an empty path and re-run, or finish it with "lotics app pull ${result.app_id}".`
|
|
74108
|
-
);
|
|
74109
|
-
}
|
|
74110
74199
|
fs9.mkdirSync(targetPath, { recursive: true });
|
|
74111
74200
|
note(`Downloading source\u2026`);
|
|
74112
74201
|
const bundleFile = path10.join(tmpdir2(), `lotics-starter-${args.starter_id}-${process.pid}.tar.gz`);
|
|
@@ -74273,34 +74362,6 @@ Captured ${totalRows} row${totalRows === 1 ? "" : "s"} across ${result.captured.
|
|
|
74273
74362
|
);
|
|
74274
74363
|
}
|
|
74275
74364
|
|
|
74276
|
-
// src/inputs.ts
|
|
74277
|
-
async function ingestJsonArgs(opts) {
|
|
74278
|
-
let raw = opts.rawArg;
|
|
74279
|
-
if (raw && raw.startsWith("@")) {
|
|
74280
|
-
const argsPath = raw.slice(1);
|
|
74281
|
-
try {
|
|
74282
|
-
raw = opts.readFile(argsPath);
|
|
74283
|
-
} catch (err2) {
|
|
74284
|
-
return {
|
|
74285
|
-
kind: "error",
|
|
74286
|
-
message: `Cannot read args file "${argsPath}": ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
74287
|
-
};
|
|
74288
|
-
}
|
|
74289
|
-
} else if (!raw && !opts.stdinIsTTY) {
|
|
74290
|
-
raw = await opts.readStdin();
|
|
74291
|
-
}
|
|
74292
|
-
if (!raw) return { kind: "ok", args: {} };
|
|
74293
|
-
try {
|
|
74294
|
-
const parsed = JSON.parse(raw);
|
|
74295
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
74296
|
-
return { kind: "error", message: `JSON args must be an object, got: ${raw}` };
|
|
74297
|
-
}
|
|
74298
|
-
return { kind: "ok", args: parsed };
|
|
74299
|
-
} catch {
|
|
74300
|
-
return { kind: "error", message: `Invalid JSON: ${raw}` };
|
|
74301
|
-
}
|
|
74302
|
-
}
|
|
74303
|
-
|
|
74304
74365
|
// src/org_commands.ts
|
|
74305
74366
|
function printWorkspaceList(workspaces, currentId) {
|
|
74306
74367
|
for (const ws of workspaces) {
|
|
@@ -96516,14 +96577,19 @@ function xlsxRead(filePath, rest2) {
|
|
|
96516
96577
|
const data2 = readToJson(filePath, filter3, { withFormat });
|
|
96517
96578
|
console.log(JSON.stringify(data2, null, 2));
|
|
96518
96579
|
}
|
|
96519
|
-
function xlsxWrite(filePath, json2) {
|
|
96520
|
-
|
|
96521
|
-
|
|
96522
|
-
|
|
96523
|
-
parsed = JSON.parse(json2);
|
|
96524
|
-
} catch (e) {
|
|
96525
|
-
fail2(`Invalid JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
96580
|
+
async function xlsxWrite(filePath, json2) {
|
|
96581
|
+
const stdinIsTTY = process.stdin.isTTY ?? false;
|
|
96582
|
+
if (!filePath || !json2 && stdinIsTTY) {
|
|
96583
|
+
fail2("Usage: lotics xlsx write <file> '<json>' | @workbook.json | < workbook.json");
|
|
96526
96584
|
}
|
|
96585
|
+
const ingested = await ingestJsonArgs({
|
|
96586
|
+
rawArg: json2,
|
|
96587
|
+
stdinIsTTY,
|
|
96588
|
+
readFile: (p) => fs11.readFileSync(p, "utf-8"),
|
|
96589
|
+
readStdin
|
|
96590
|
+
});
|
|
96591
|
+
if (ingested.kind === "error") fail2(ingested.message);
|
|
96592
|
+
const parsed = ingested.args;
|
|
96527
96593
|
const workbook = buildWorkbookFromJson(parsed);
|
|
96528
96594
|
const report = recomputeAll(workbook);
|
|
96529
96595
|
if (report.unevaluated.length > 0) {
|
|
@@ -96784,7 +96850,7 @@ Uses Lotics' own xlsx engine; round-trips faithfully with the Lotics editor and
|
|
|
96784
96850
|
(its <sheet>! prefix is optional when --sheet is given)
|
|
96785
96851
|
A cell carries numFmt when it has one; --with-format
|
|
96786
96852
|
adds the resolved style (always present, hence a flag)
|
|
96787
|
-
lotics xlsx write <file> '<json>' Create .xlsx from {"sheets":[{"name","cells":{"A1":...}}]}
|
|
96853
|
+
lotics xlsx write <file> '<json>' | @workbook.json | < workbook.json Create .xlsx from {"sheets":[{"name","cells":{"A1":...}}]}
|
|
96788
96854
|
A cell is a bare value, or {value|formula, numFmt, style}:
|
|
96789
96855
|
{"A1":{"value":1234,"numFmt":"#,##0 \\"\u20AB\\"","style":{"fontBold":true}}}
|
|
96790
96856
|
A bare "=A1+B1" is a formula; an object's "value" is
|
|
@@ -102408,13 +102474,18 @@ async function docxRead(filePath, rest2) {
|
|
|
102408
102474
|
console.log(JSON.stringify(readToJson2(doc, includeOpaque), null, 2));
|
|
102409
102475
|
}
|
|
102410
102476
|
async function docxWrite(filePath, json2) {
|
|
102411
|
-
|
|
102412
|
-
|
|
102413
|
-
|
|
102414
|
-
|
|
102415
|
-
|
|
102416
|
-
|
|
102417
|
-
|
|
102477
|
+
const stdinIsTTY = process.stdin.isTTY ?? false;
|
|
102478
|
+
if (!filePath || !json2 && stdinIsTTY) {
|
|
102479
|
+
fail2("Usage: lotics docx write <file> '<json>' | @doc.json | < doc.json");
|
|
102480
|
+
}
|
|
102481
|
+
const ingested = await ingestJsonArgs({
|
|
102482
|
+
rawArg: json2,
|
|
102483
|
+
stdinIsTTY,
|
|
102484
|
+
readFile: (p) => fs12.readFileSync(p, "utf-8"),
|
|
102485
|
+
readStdin
|
|
102486
|
+
});
|
|
102487
|
+
if (ingested.kind === "error") fail2(ingested.message);
|
|
102488
|
+
const parsed = ingested.args;
|
|
102418
102489
|
const doc = buildDoc(parsed);
|
|
102419
102490
|
await writeDoc(filePath, doc);
|
|
102420
102491
|
}
|
|
@@ -102722,7 +102793,7 @@ function printDocxHelp() {
|
|
|
102722
102793
|
Uses Lotics' own OOXML engine; round-trips faithfully with the Lotics editor and templates.
|
|
102723
102794
|
|
|
102724
102795
|
lotics docx read <file> [--include-opaque] Dump file as JSON (blocks with text/style)
|
|
102725
|
-
lotics docx write <file> '<json>' Create .docx from {"blocks":[{"kind":"paragraph","text":...}]}
|
|
102796
|
+
lotics docx write <file> '<json>' | @doc.json | < doc.json Create .docx from {"blocks":[{"kind":"paragraph","text":...}]}
|
|
102726
102797
|
lotics docx append-paragraph <file> '<text>' [--style=NAME]
|
|
102727
102798
|
Append a paragraph (styles: Title, Heading1..3, Quote, Code)
|
|
102728
102799
|
lotics docx insert-paragraph <file> '<text>' --at=<i> [--style=NAME]
|
|
@@ -103312,14 +103383,6 @@ Resolution precedence (highest first):
|
|
|
103312
103383
|
--api-key flag > LOTICS_API_KEY env > LOTICS_ORG env > local .lotics/config.json
|
|
103313
103384
|
> global active profile. LOTICS_WORKSPACE / --workspace override the workspace.`);
|
|
103314
103385
|
}
|
|
103315
|
-
function readStdin() {
|
|
103316
|
-
return new Promise((resolve2, reject2) => {
|
|
103317
|
-
const chunks = [];
|
|
103318
|
-
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
103319
|
-
process.stdin.on("end", () => resolve2(Buffer.concat(chunks).toString("utf-8").trim()));
|
|
103320
|
-
process.stdin.on("error", reject2);
|
|
103321
|
-
});
|
|
103322
|
-
}
|
|
103323
103386
|
function prompt(question) {
|
|
103324
103387
|
const rl = readline.createInterface({
|
|
103325
103388
|
input: process.stdin,
|
|
@@ -103755,7 +103818,9 @@ async function main() {
|
|
|
103755
103818
|
}
|
|
103756
103819
|
if (command === "report") {
|
|
103757
103820
|
let input = subcommand ?? "";
|
|
103821
|
+
let source = "inline";
|
|
103758
103822
|
if (input.startsWith("@")) {
|
|
103823
|
+
source = "file";
|
|
103759
103824
|
const file2 = input.slice(1);
|
|
103760
103825
|
if (!fs14.existsSync(file2)) {
|
|
103761
103826
|
console.error(`No such file: ${file2}`);
|
|
@@ -103763,13 +103828,14 @@ async function main() {
|
|
|
103763
103828
|
}
|
|
103764
103829
|
input = fs14.readFileSync(file2, "utf-8");
|
|
103765
103830
|
} else if (input === "-") {
|
|
103831
|
+
source = "stdin";
|
|
103766
103832
|
input = await readStdin();
|
|
103767
103833
|
}
|
|
103768
103834
|
if (input.trim() === "") {
|
|
103769
103835
|
console.error(REPORT_USAGE);
|
|
103770
103836
|
process.exit(1);
|
|
103771
103837
|
}
|
|
103772
|
-
const parsed2 = parseReport(input);
|
|
103838
|
+
const parsed2 = parseReport(input, source);
|
|
103773
103839
|
if ("error" in parsed2) {
|
|
103774
103840
|
console.error(`${parsed2.error}
|
|
103775
103841
|
`);
|
package/docs/cli_reference.md
CHANGED
|
@@ -20,7 +20,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
20
20
|
| `lotics workspace doctor` | Report workspace-wide dangling schema references via `GET /v1/workspaces/dangling-references` — every active app/workflow artifact whose prefixed schema id no longer resolves, printed as `<referent.kind> "<name>" (<id>) → <namespace> <id> (missing)`; healthy prints a one-line all-clear. **Exits non-zero (exit 1) on findings** so scripts can gate on it. Resolves the first workspace like every data command (runs before the global workspace resolution). Admin-only. |
|
|
21
21
|
| `lotics tools` | List tools by category with descriptions |
|
|
22
22
|
| `lotics tools <name>` | Full description + JSON Schema for one tool |
|
|
23
|
-
| `lotics run <tool> '<json>'` | Execute a tool (text output via toModelOutput). Args may also come from a file (`lotics run <tool> @args.json`) or piped stdin (`cat args.json \| lotics run <tool>`) — both bypass the OS `ARG_MAX` limit for large payloads (a knowledge-doc `content`, a bulk update). A leading `@` on the args is unambiguously a file path (JSON args start with `{`). |
|
|
23
|
+
| `lotics run <tool> '<json>'` | Execute a tool (text output via toModelOutput). Args may also come from a file (`lotics run <tool> @args.json`) or piped stdin (`cat args.json \| lotics run <tool>`) — both bypass the OS `ARG_MAX` limit for large payloads (a knowledge-doc `content`, a bulk update). A leading `@` on the args is unambiguously a file path (JSON args start with `{`). In PowerShell use `@file`: quotes inside an inline argument are consumed by the shell, and the CLI reports the JSON it received with its quotes gone — the error names both escapes. |
|
|
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. |
|
|
@@ -38,7 +38,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
38
38
|
| `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. |
|
|
39
39
|
| `lotics app create <name> [path]` | Scaffold a Vite+React+TS custom-code app project; POST /v1/apps; npm install; vite build; upload as v1. The generated `package.json#name` is the app name FOLDED to ASCII (`Đơn hàng` → `don-hang`), never stripped of it — dropping the marks would treat each accented vowel as a separator and can slug a name away to nothing. The app's display name is unaffected; this is the npm field only |
|
|
40
40
|
| `lotics app pull <app_id> [path]` | Download source archive from R2 (presigned), extract, install dependencies (`npm ci --ignore-scripts` when a lockfile is present, else `npm install --ignore-scripts`), 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. **A pull never overwrites a file that differs from what it is about to write** — it writes only what is ABSENT or already identical, keeps the rest, and reports which files it kept plus the commands that close the gap. The same rule covers `src/workflows/<alias>.ts` and `src/agents/<alias>.md`, so an unpushed body or prompt survives too. Those two are written from the LIVE App row (`apps.workflows` / `apps.agents`), which owns them, and the archive's own copy of them is deliberately SKIPPED on extract: a deploy tars the whole source directory, so the tarball holds a deploy-time snapshot that is stale for anything authored since. The comparison is against the app's own content, not git, so it holds for a project that was never a repo. `--force` takes the app's copy and DISCARDS local edits; there is no other way to lose them. **For a KEPT workflow body or agent prompt the pull records the server's fingerprint only when the server has not moved** — that token is `set_app_workflow`/`set_app_agent`'s lost-update precondition, so recording one for text the author has not seen would clear the next push's refusal by disarming the guard, and silently overwrite whoever edited it. When the live text HAS moved, the pull writes it beside the checkout (`.lotics/agents/<alias>.live.md`, `.lotics/workflows/<alias>.live.ts`), names it, and leaves the token stale: the next deploy is refused, which is correct, and the text to merge is now on disk. A file whose prose/body already reads back AS the live text is never "kept" at all — the baselines are healed from it, so a checkout whose prose was pushed out of band (chat, `lotics run set_app_agent`) converges instead of latching. **A pull also REPORTS the files it restored** when refreshing a tree that already claimed a version: a pull mirrors the last DEPLOYED source, so a file deleted locally comes back until the deletion itself ships, and saying so is the only honest fix — nothing can read a deletion off the disk. **When a pull ACROSS versions keeps files, the manifest is left on the OLDER of the two versions** — the tree is then part one and part the other, and claiming the newer would make `deploy`'s `prev_version_id` check pass and ship a half-and-half bundle. Older, not "the one it had": `--from-version` pulls a deliberately old revision, so the version it had is the NEWER side, and holding that would match what the server serves and let the old source ship. Either way a deploy from that tree is refused until you reconcile the listed files by hand and pull again, or take the app's copy with `--force`. The report says which version each side is on, because a kept file is your unshipped work when the project was already current and merely the OLD version when it was behind — and nothing in a byte comparison can tell those apart. **`--from-version <apv_…>`** pulls an OLDER revision instead of the current one (`lotics app versions` lists the ids) — point it at a NEW path to read a previous revision without disturbing the project you are in. The manifest records the version actually written, never the live pointer, so a deploy from that checkout is refused by the version guard rather than shipping old source over newer. — `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 — AFTER `npm install`, so `node_modules/@lotics/ui` actually exists to read — `.lotics/react_native.d.ts` (the kit's web-only ViewStyle/TextStyle augmentation) and `.lotics/tsconfig.link.json`'s peer pins; a pulled project's own `tsc` used to fail the moment it used a component relying on the augmentation (Dialog, Picker, TimePicker, …) until `app codegen` was run by hand, because nothing had regenerated either one after install populated node_modules. AND the runtime `.lotics/app_fields.ts` (the same generation `app codegen` runs, off the app row already fetched). 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. 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 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. A pull writes it from live UNLESS the local file holds unpushed work, in which case it is kept and the live text is parked beside the checkout — the same rule the rest of this row describes. 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_tier`/…) — 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 |
|
|
41
|
-
| `lotics app deploy [--prune] -m <message>` | `-m` is OPTIONAL — omitted, the deploy derives the version message from what it actually pushed; pass `-m` when you have a reason worth recording. npm run build; tar source + dist; POST /v1/apps/{id}/versions multipart. **One command ships everything**: before the bundle moves, a deploy pushes every binding the project has ahead of the app — an edited workflow body or declaration, edited agent prose, a changed query — through `set_app_query`, then `set_app_workflow`, then `set_app_agent`, and fails the release if any push is refused. That order is required: an agent declares the query and workflow aliases it may call, so pushing it before its own new query is refused. A workflow's `description` is part of that push and is compared against the recorded baseline, not the live app — it lives on the workflow ROW, which `getApp` does not carry. It never AUTHORS a binding itself — those verbs stay the single writers — and each push carries the fingerprint the project last saw live (`lotics.synced`), so a stale checkout is refused rather than overwriting another author's edit. `package.json` means the same thing for both artifacts: editing `lotics.agents.<alias>.inputs`/`outputs` is pushed exactly like the workflow equivalent (only those two fields — `set_app_agent` merges, so everything the manifest does not model is left untouched). It also regenerates `.lotics/app_fields.ts` before building, since the build INLINES it and a stale copy would ship ids that no longer name what the source thinks they do. `lotics app check` reports the same set without pushing; neither has a `--strict`. What the version RECORDS as the aliases it calls — the set `remove_app_workflow` / `remove_app_query` / `remove_app_agent` consult to refuse unbinding one the served version still reaches — is read by the SERVER out of the source archive this deploy uploads, not reported by the deploy. That matters because the deploy is also what unbinds: a client supplying the evidence used to refuse its own removal cannot be checked by it. After a successful deploy it warns about any alias the source CALLS that is NOT bound, and **names the inverse** —
|
|
41
|
+
| `lotics app deploy [--prune] -m <message>` | `-m` is OPTIONAL — omitted, the deploy derives the version message from what it actually pushed; pass `-m` when you have a reason worth recording. npm run build; tar source + dist; POST /v1/apps/{id}/versions multipart. **One command ships everything**: before the bundle moves, a deploy pushes every binding the project has ahead of the app — an edited workflow body or declaration, edited agent prose, a changed query — through `set_app_query`, then `set_app_workflow`, then `set_app_agent`, and fails the release if any push is refused. That order is required: an agent declares the query and workflow aliases it may call, so pushing it before its own new query is refused. A workflow's `description` is part of that push and is compared against the recorded baseline, not the live app — it lives on the workflow ROW, which `getApp` does not carry. It never AUTHORS a binding itself — those verbs stay the single writers — and each push carries the fingerprint the project last saw live (`lotics.synced`), so a stale checkout is refused rather than overwriting another author's edit. `package.json` means the same thing for both artifacts: editing `lotics.agents.<alias>.inputs`/`outputs` is pushed exactly like the workflow equivalent (only those two fields — `set_app_agent` merges, so everything the manifest does not model is left untouched). It also regenerates `.lotics/app_fields.ts` before building, since the build INLINES it and a stale copy would ship ids that no longer name what the source thinks they do. `lotics app check` reports the same set without pushing; neither has a `--strict`. What the version RECORDS as the aliases it calls — the set `remove_app_workflow` / `remove_app_query` / `remove_app_agent` consult to refuse unbinding one the served version still reaches — is read by the SERVER out of the source archive this deploy uploads, not reported by the deploy. That matters because the deploy is also what unbinds: a client supplying the evidence used to refuse its own removal cannot be checked by it. After a successful deploy it warns about any alias the source CALLS that is NOT bound, and **names the inverse** — but as a TRANSITION, not a state: bindings this bundle *stopped* calling, compared against what the previous deploy's bundle called (`package.json#lotics.bundle_calls`, which a deploy records). It does NOT remove them: **`--prune` does, and only when passed.** The distinction is what makes the report readable. A static scan sees the bundle's call sites and an agent's `query_aliases`/`workflow_aliases`; it cannot see `lotics run run_app_query`/`run_app_workflow`, whose whole contract is that the alias is bound server-side, or chat's call under `app:use` — and the capability catalog publishes EVERY declared alias to both. So an alias the bundle never called is the normal shape of an agent-facing binding, not a dead one, and reporting it fired on every app built to be driven by an agent while pointing at the flag that deletes it. An alias that WAS called and is not any more is different: that is a call site the author removed, which is compile-, check- and deploy-clean while the binding keeps serving. **No baseline ⇒ nothing reported** — a manifest from before this field, or one a `pull` rebuilt from the server row, costs one quiet deploy and then self-heals, because silence is the only honest answer with nothing to compare. The baseline is STICKY: it advances only once nothing is outstanding, so the `--prune` this warning names still finds the transition on a later run instead of reporting ✓ over a binding that still serves. Pruning runs AFTER the version is live, because the removal tools refuse an alias the SERVED version still declares — so doing it first is refused by the guard that makes it safe. `--prune` is skipped ENTIRELY (with a warning, never a failure) when the source computes an alias at run time, since the scan cannot tell which binding that reaches and pruning "the rest" would be guessing with a deletion. **A removal DELETES the local declaration too** — `package.json#lotics.<kind>.<alias>` and its `synced` baseline — because leaving it would undo the prune: the manifest is what the next plain deploy pushes FROM, so the binding came straight back. That makes the act destructive rather than merely reversible, so what it deleted is written to `.lotics/pruned/<kind>/<alias>.json` and the ✓ names that file plus the `set` verb that re-binds it, on the same line. (These trees are never committed, so git is not the fallback; `lotics app pull --from-version <apv_…>` is the only other route back.) After a successful prune the generated companions are regenerated from the narrowed manifest — the `.d.ts` set and, when a query was pruned, `.lotics/app_fields.ts`, whose table set is derived from the surviving query ASTs. A table named ONLY by the pruned query leaves `F`/`OPT`, which is reported: if your source still addresses it, add the table id to `package.json#lotics.codegen.tables`. A local write that fails at any of this reports what could not be written and which aliases were already unbound server-side; it never fails the release, which is already live. A binding that will not unbind is reported and does NOT fail the release: the version is live and correct — and the server refuses to unbind a WORKFLOW this workspace has actually run (a recorded execution means a caller the source cannot name), which surfaces here as `✗ could not unbind …` with the date it last ran. After a successful deploy it also REFRESHES the `.lotics/workflows/<alias>.globals.d.ts` of any alias whose `// lotics:declaration` stamp says this deploy moved its declaration (only those — refreshing every bound alias would cost one round trip each on every deploy to fix something only ever wrong right after a manifest edit), from the manifest declaration, re-wrapping the SAME on-disk body (never re-fetching it, so local edits survive). A deploy is the moment the manifest becomes real, so it is also the moment the local types stop matching it — and the author's next act is usually `workflow set`, whose body would otherwise be typechecked against the declaration as it stood before this deploy. Non-fatal: the release already shipped, and stale types never fail it. |
|
|
42
42
|
| `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. Title → stderr, table → stdout (pipeable). |
|
|
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> [path] [--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`. **`--json` prints one object on stdout and nothing else** — `organization_id`, `workspace_id`, `app_id`, `project_dir`, `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, and the notice naming whose build is about to run on this machine. 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. npm's and vite's own output is captured under `--json` and surfaced only if the build FAILS, where it rides out in the error. Reachable with no install: `npx -y @lotics/cli start …`. |
|
|
@@ -49,7 +49,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
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 the
|
|
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. |
|
|
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. |
|
|
@@ -59,7 +59,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
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
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. |
|
|
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
|
-
| `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 `--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
|
-
| `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. |
|
|
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
|
+
| `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. |
|
|
64
64
|
| `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). |
|
|
65
65
|
|