@lotics/cli 0.112.0 → 0.114.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 +7 -4
- package/dist/src/cli.js +147 -57
- package/dist/src/client.d.ts +1 -1
- package/docs/cli_reference.md +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,12 +156,15 @@ The CLI bundles Lotics's own xlsx and docx engines so you can read, write, and e
|
|
|
156
156
|
```bash
|
|
157
157
|
# .xlsx
|
|
158
158
|
lotics xlsx read ./report.xlsx # → JSON of sheets, cells, merges
|
|
159
|
+
lotics xlsx read ./report.xlsx --with-format # …plus each cell's resolved style
|
|
159
160
|
lotics xlsx write ./out.xlsx '{"sheets":[{"name":"S1","cells":{"A1":"Hi","B1":42}}]}'
|
|
160
161
|
# A cell is a bare value, or an object with numFmt / style / formula:
|
|
161
|
-
lotics xlsx write ./out.xlsx '{"sheets":[{"name":"S1",
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
|
|
162
|
+
lotics xlsx write ./out.xlsx '{"sheets":[{"name":"S1",
|
|
163
|
+
"colWidths":{"A":34,"B":14}, "rowHeights":{"1":28},
|
|
164
|
+
"cells":{
|
|
165
|
+
"A1":{"value":"Tổng","style":{"fontBold":true}},
|
|
166
|
+
"B1":{"value":1234567,"numFmt":"#,##0"},
|
|
167
|
+
"B2":{"formula":"B1*0.1","numFmt":"#,##0"}}}]}' # unknown keys are rejected, not ignored
|
|
165
168
|
lotics xlsx set-cell ./report.xlsx 'Sheet1!A1' '=SUM(B:B)'
|
|
166
169
|
lotics xlsx add-sheet ./report.xlsx 'Summary'
|
|
167
170
|
lotics xlsx merge ./report.xlsx 'Sheet1!A1:C1'
|
package/dist/src/cli.js
CHANGED
|
@@ -33334,8 +33334,8 @@ var require_utils2 = __commonJS({
|
|
|
33334
33334
|
var { Address } = require_helpers();
|
|
33335
33335
|
var { Prefix, Postfix, Infix, Operators } = require_operators();
|
|
33336
33336
|
var Collection = require_collection();
|
|
33337
|
-
var
|
|
33338
|
-
var
|
|
33337
|
+
var MAX_ROW2 = 1048576;
|
|
33338
|
+
var MAX_COLUMN2 = 16384;
|
|
33339
33339
|
var { NotAllInputParsedException } = require_api();
|
|
33340
33340
|
var Utils = class {
|
|
33341
33341
|
constructor(context) {
|
|
@@ -33564,7 +33564,7 @@ var require_utils2 = __commonJS({
|
|
|
33564
33564
|
// * @return {{ref: {from: {col: number, row: number}, to: {col: number, row: number}}}}
|
|
33565
33565
|
*/
|
|
33566
33566
|
applyRange(refs) {
|
|
33567
|
-
let res, maxRow = -1, maxCol = -1, minRow =
|
|
33567
|
+
let res, maxRow = -1, maxCol = -1, minRow = MAX_ROW2 + 1, minCol = MAX_COLUMN2 + 1;
|
|
33568
33568
|
refs.forEach((ref2) => {
|
|
33569
33569
|
if (this.isFormulaError(ref2))
|
|
33570
33570
|
return ref2;
|
|
@@ -33574,11 +33574,11 @@ var require_utils2 = __commonJS({
|
|
|
33574
33574
|
ref2 = ref2.ref;
|
|
33575
33575
|
if (ref2.row === void 0) {
|
|
33576
33576
|
minRow = 1;
|
|
33577
|
-
maxRow =
|
|
33577
|
+
maxRow = MAX_ROW2;
|
|
33578
33578
|
}
|
|
33579
33579
|
if (ref2.col === void 0) {
|
|
33580
33580
|
minCol = 1;
|
|
33581
|
-
maxCol =
|
|
33581
|
+
maxCol = MAX_COLUMN2;
|
|
33582
33582
|
}
|
|
33583
33583
|
if (ref2.row > maxRow)
|
|
33584
33584
|
maxRow = ref2.row;
|
|
@@ -34014,8 +34014,8 @@ var require_utils3 = __commonJS({
|
|
|
34014
34014
|
var { FormulaHelpers, Types, Address } = require_helpers();
|
|
34015
34015
|
var { Prefix, Postfix, Infix, Operators } = require_operators();
|
|
34016
34016
|
var Collection = require_collection();
|
|
34017
|
-
var
|
|
34018
|
-
var
|
|
34017
|
+
var MAX_ROW2 = 1048576;
|
|
34018
|
+
var MAX_COLUMN2 = 16384;
|
|
34019
34019
|
var Utils = class {
|
|
34020
34020
|
constructor(context) {
|
|
34021
34021
|
this.context = context;
|
|
@@ -34161,7 +34161,7 @@ var require_utils3 = __commonJS({
|
|
|
34161
34161
|
// * @return {{ref: {from: {col: number, row: number}, to: {col: number, row: number}}}}
|
|
34162
34162
|
*/
|
|
34163
34163
|
applyRange(refs) {
|
|
34164
|
-
let res, maxRow = -1, maxCol = -1, minRow =
|
|
34164
|
+
let res, maxRow = -1, maxCol = -1, minRow = MAX_ROW2 + 1, minCol = MAX_COLUMN2 + 1;
|
|
34165
34165
|
refs.forEach((ref2) => {
|
|
34166
34166
|
if (this.isFormulaError(ref2))
|
|
34167
34167
|
return ref2;
|
|
@@ -34171,11 +34171,11 @@ var require_utils3 = __commonJS({
|
|
|
34171
34171
|
ref2 = ref2.ref;
|
|
34172
34172
|
if (ref2.row === void 0) {
|
|
34173
34173
|
minRow = 1;
|
|
34174
|
-
maxRow =
|
|
34174
|
+
maxRow = MAX_ROW2;
|
|
34175
34175
|
}
|
|
34176
34176
|
if (ref2.col === void 0) {
|
|
34177
34177
|
minCol = 1;
|
|
34178
|
-
maxCol =
|
|
34178
|
+
maxCol = MAX_COLUMN2;
|
|
34179
34179
|
}
|
|
34180
34180
|
if (ref2.row > maxRow)
|
|
34181
34181
|
maxRow = ref2.row;
|
|
@@ -44124,9 +44124,9 @@ var require_load = __commonJS({
|
|
|
44124
44124
|
var require_lib4 = __commonJS({
|
|
44125
44125
|
"../../node_modules/jszip/lib/index.js"(exports2, module2) {
|
|
44126
44126
|
"use strict";
|
|
44127
|
-
function
|
|
44128
|
-
if (!(this instanceof
|
|
44129
|
-
return new
|
|
44127
|
+
function JSZip5() {
|
|
44128
|
+
if (!(this instanceof JSZip5)) {
|
|
44129
|
+
return new JSZip5();
|
|
44130
44130
|
}
|
|
44131
44131
|
if (arguments.length) {
|
|
44132
44132
|
throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
|
|
@@ -44135,7 +44135,7 @@ var require_lib4 = __commonJS({
|
|
|
44135
44135
|
this.comment = null;
|
|
44136
44136
|
this.root = "";
|
|
44137
44137
|
this.clone = function() {
|
|
44138
|
-
var newObj = new
|
|
44138
|
+
var newObj = new JSZip5();
|
|
44139
44139
|
for (var i2 in this) {
|
|
44140
44140
|
if (typeof this[i2] !== "function") {
|
|
44141
44141
|
newObj[i2] = this[i2];
|
|
@@ -44144,16 +44144,16 @@ var require_lib4 = __commonJS({
|
|
|
44144
44144
|
return newObj;
|
|
44145
44145
|
};
|
|
44146
44146
|
}
|
|
44147
|
-
|
|
44148
|
-
|
|
44149
|
-
|
|
44150
|
-
|
|
44151
|
-
|
|
44152
|
-
|
|
44153
|
-
return new
|
|
44147
|
+
JSZip5.prototype = require_object();
|
|
44148
|
+
JSZip5.prototype.loadAsync = require_load();
|
|
44149
|
+
JSZip5.support = require_support();
|
|
44150
|
+
JSZip5.defaults = require_defaults();
|
|
44151
|
+
JSZip5.version = "3.10.1";
|
|
44152
|
+
JSZip5.loadAsync = function(content, options) {
|
|
44153
|
+
return new JSZip5().loadAsync(content, options);
|
|
44154
44154
|
};
|
|
44155
|
-
|
|
44156
|
-
module2.exports =
|
|
44155
|
+
JSZip5.external = require_external();
|
|
44156
|
+
module2.exports = JSZip5;
|
|
44157
44157
|
}
|
|
44158
44158
|
});
|
|
44159
44159
|
|
|
@@ -64462,12 +64462,20 @@ var VALID_OPERATORS = {
|
|
|
64462
64462
|
var VALID_FILTER_TYPES = Object.keys(VALID_OPERATORS);
|
|
64463
64463
|
|
|
64464
64464
|
// ../shared/src/chat_models.ts
|
|
64465
|
-
var
|
|
64466
|
-
var
|
|
64467
|
-
|
|
64468
|
-
|
|
64469
|
-
|
|
64470
|
-
|
|
64465
|
+
var MODEL_TIERS = ["haiku", "sonnet", "opus"];
|
|
64466
|
+
var TIER_MODELS = {
|
|
64467
|
+
haiku: "claude-haiku-4-5",
|
|
64468
|
+
sonnet: "claude-sonnet-5",
|
|
64469
|
+
opus: "claude-opus-5"
|
|
64470
|
+
};
|
|
64471
|
+
var RESOLVED_MODEL_IDS = MODEL_TIERS.map(
|
|
64472
|
+
(tier) => TIER_MODELS[tier]
|
|
64473
|
+
);
|
|
64474
|
+
var DEFAULT_MODEL_TIER = "sonnet";
|
|
64475
|
+
var UTILITY_MODEL_TIER = "haiku";
|
|
64476
|
+
var DEFAULT_MODEL_ID = TIER_MODELS[DEFAULT_MODEL_TIER];
|
|
64477
|
+
var PICKER_MODEL_TIERS = MODEL_TIERS.filter(
|
|
64478
|
+
(tier) => tier !== UTILITY_MODEL_TIER
|
|
64471
64479
|
);
|
|
64472
64480
|
var EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
64473
64481
|
|
|
@@ -64927,11 +64935,11 @@ var appAgentDeclarationSchema = zod_default.object({
|
|
|
64927
64935
|
workflow_aliases: zod_default.array(zod_default.string().min(1)).optional().describe(
|
|
64928
64936
|
"Workflows from this app's manifest the agent may invoke via `run_app_workflow`, validated at declare time against the app's own workflows. This is the agent's ENTIRE write surface \u2014 the same declared mutation path the app's UI uses, so table hooks and side-effect harvesting apply. Omit for a read-only agent."
|
|
64929
64937
|
),
|
|
64930
|
-
|
|
64931
|
-
"
|
|
64938
|
+
model_tier: zod_default.enum(MODEL_TIERS).optional().describe(
|
|
64939
|
+
"Model tier the agent runs on \u2014 `haiku`, `sonnet`, or `opus`. Omit to follow the platform default tier, resolved at run time: the preferred choice. A tier names capability, not a version, so the generation behind it moves with the platform and this declaration never needs a rewrite. Pin only a deliberate, tested choice."
|
|
64932
64940
|
),
|
|
64933
64941
|
effort_level: zod_default.enum(EFFORT_LEVELS).optional().describe(
|
|
64934
|
-
"Reasoning depth for adaptive-thinking
|
|
64942
|
+
"Reasoning depth for adaptive-thinking tiers \u2014 one of the chosen tier's supported levels (validated against model_tier at declare time). Omit to use the model default; ignored on tiers without adaptive thinking."
|
|
64935
64943
|
),
|
|
64936
64944
|
inputs: zod_default.record(zod_default.string(), appWorkflowInputSchema).optional().describe(
|
|
64937
64945
|
"Typed input schema for one run. Keys are input names; values declare type + constraints. The server validates the run payload against this before invoking; CLI codegen emits a typed `useAgentRun<alias>` signature. Omit for an untyped payload."
|
|
@@ -65070,7 +65078,7 @@ var agentStepSchema = stepBaseSchema.extend({
|
|
|
65070
65078
|
instructions: zod_default.string().min(1),
|
|
65071
65079
|
input: zod_default.record(zod_default.string(), toolInputValueSchema),
|
|
65072
65080
|
tool_names: zod_default.array(zod_default.string().min(1)),
|
|
65073
|
-
|
|
65081
|
+
model_tier: zod_default.enum(MODEL_TIERS).optional(),
|
|
65074
65082
|
output: agentOutputSpecSchema
|
|
65075
65083
|
});
|
|
65076
65084
|
var breakStepSchema = stepBaseSchema.extend({
|
|
@@ -69683,8 +69691,6 @@ function walkAgentInvocation(call, scope, stepId, description) {
|
|
|
69683
69691
|
const toolsNode = kw.get("tools");
|
|
69684
69692
|
if (!toolsNode) fail(arg, "agent requires `tools` (use [] for none).");
|
|
69685
69693
|
const tool_names = readStaticStringArray(toolsNode, "agent `tools`");
|
|
69686
|
-
const modelNode = kw.get("model");
|
|
69687
|
-
const model_id = modelNode ? readStaticString(modelNode, "agent `model`") : void 0;
|
|
69688
69694
|
const outputNode = kw.get("output");
|
|
69689
69695
|
if (!outputNode) fail(arg, "agent requires `output`.");
|
|
69690
69696
|
const outputResult = agentOutputSpecSchema.safeParse(walkStaticJsonLiteral(outputNode));
|
|
@@ -69692,6 +69698,19 @@ function walkAgentInvocation(call, scope, stepId, description) {
|
|
|
69692
69698
|
const detail = outputResult.error.issues.map((i2) => `${i2.path.join(".") || "<root>"}: ${i2.message}`).join("; ");
|
|
69693
69699
|
fail(outputNode, `Invalid agent \`output\`: ${detail}`);
|
|
69694
69700
|
}
|
|
69701
|
+
const modelNode = kw.get("model");
|
|
69702
|
+
let model_tier;
|
|
69703
|
+
if (modelNode) {
|
|
69704
|
+
const literal2 = readStaticString(modelNode, "agent `model`");
|
|
69705
|
+
const tier = MODEL_TIERS.includes(literal2) ? literal2 : null;
|
|
69706
|
+
if (!tier) {
|
|
69707
|
+
fail(
|
|
69708
|
+
modelNode,
|
|
69709
|
+
`Unknown agent \`model\` "${literal2}" \u2014 expected one of: ${MODEL_TIERS.join(", ")}.`
|
|
69710
|
+
);
|
|
69711
|
+
}
|
|
69712
|
+
model_tier = tier;
|
|
69713
|
+
}
|
|
69695
69714
|
return {
|
|
69696
69715
|
id: stepId,
|
|
69697
69716
|
description: description ?? "agent",
|
|
@@ -69699,7 +69718,7 @@ function walkAgentInvocation(call, scope, stepId, description) {
|
|
|
69699
69718
|
instructions,
|
|
69700
69719
|
input,
|
|
69701
69720
|
tool_names,
|
|
69702
|
-
...
|
|
69721
|
+
...model_tier !== void 0 ? { model_tier } : {},
|
|
69703
69722
|
output: outputResult.data
|
|
69704
69723
|
};
|
|
69705
69724
|
}
|
|
@@ -70239,7 +70258,7 @@ function agentFilePath2(projectDir, alias) {
|
|
|
70239
70258
|
}
|
|
70240
70259
|
var CLI_AGENT_NOTES = [
|
|
70241
70260
|
"Pulled from the LIVE app row; edit here, then: lotics app agent set <alias>",
|
|
70242
|
-
"The typed fields (inputs/outputs/tool_names/
|
|
70261
|
+
"The typed fields (inputs/outputs/tool_names/model_tier) live in package.json#lotics.agents"
|
|
70243
70262
|
];
|
|
70244
70263
|
function writeAgentFile(projectDir, alias, instructions) {
|
|
70245
70264
|
fs4.mkdirSync(path5.join(projectDir, AGENTS_DIR), { recursive: true });
|
|
@@ -71410,7 +71429,7 @@ async function appAgentSet(client, args) {
|
|
|
71410
71429
|
process.exit(1);
|
|
71411
71430
|
}
|
|
71412
71431
|
console.error(
|
|
71413
|
-
`Set agent "${args.alias}" (${instructions.length} chars of instructions` + (live.
|
|
71432
|
+
`Set agent "${args.alias}" (${instructions.length} chars of instructions` + (live.model_tier ? `, ${live.model_tier}` : "") + `). Typed fields left as they are.`
|
|
71414
71433
|
);
|
|
71415
71434
|
}
|
|
71416
71435
|
async function appWorkflowSet(client, args) {
|
|
@@ -83163,6 +83182,8 @@ function buildSheetXml(sheet, styles, ssIndex, isActive, xfMap, numFmtMap, dxfMa
|
|
|
83163
83182
|
}
|
|
83164
83183
|
arr.push({ col: rc.col, cell });
|
|
83165
83184
|
}
|
|
83185
|
+
for (const rowNum of sheet.rowHeights.keys()) if (!rowMap.has(rowNum)) rowMap.set(rowNum, []);
|
|
83186
|
+
for (const rowNum of sheet.hiddenRows) if (!rowMap.has(rowNum)) rowMap.set(rowNum, []);
|
|
83166
83187
|
const sortedRows = Array.from(rowMap.keys()).sort((a, b) => a - b);
|
|
83167
83188
|
for (const rowNum of sortedRows) {
|
|
83168
83189
|
const cells = rowMap.get(rowNum);
|
|
@@ -83319,11 +83340,12 @@ function buildSheetXml(sheet, styles, ssIndex, isActive, xfMap, numFmtMap, dxfMa
|
|
|
83319
83340
|
}
|
|
83320
83341
|
}
|
|
83321
83342
|
let dimensionRef = "A1";
|
|
83322
|
-
|
|
83343
|
+
const cellRows = sortedRows.filter((rowNum) => rowMap.get(rowNum).length > 0);
|
|
83344
|
+
if (cellRows.length > 0) {
|
|
83323
83345
|
let minCol = Infinity, maxCol = 0;
|
|
83324
|
-
const minRow =
|
|
83325
|
-
const maxRow =
|
|
83326
|
-
for (const rowNum of
|
|
83346
|
+
const minRow = cellRows[0];
|
|
83347
|
+
const maxRow = cellRows[cellRows.length - 1];
|
|
83348
|
+
for (const rowNum of cellRows) {
|
|
83327
83349
|
const cells = rowMap.get(rowNum);
|
|
83328
83350
|
for (const { col } of cells) {
|
|
83329
83351
|
if (col < minCol) minCol = col;
|
|
@@ -92919,6 +92941,9 @@ function adjustMergedCellsForColDelete(sheet, atCol, count) {
|
|
|
92919
92941
|
|
|
92920
92942
|
// src/xlsx.ts
|
|
92921
92943
|
var SIMPLE_CELL_KEYS = /* @__PURE__ */ new Set(["value", "formula", "numFmt", "style"]);
|
|
92944
|
+
var SIMPLE_SHEET_KEYS = /* @__PURE__ */ new Set(["name", "cells", "merges", "freeze", "colWidths", "rowHeights"]);
|
|
92945
|
+
var MAX_COLUMN = 16384;
|
|
92946
|
+
var MAX_ROW = 1048576;
|
|
92922
92947
|
function loadFile(filePath) {
|
|
92923
92948
|
if (!fs6.existsSync(filePath)) fail2(`File not found: ${filePath}`);
|
|
92924
92949
|
const buffer = fs6.readFileSync(filePath);
|
|
@@ -92970,7 +92995,7 @@ function lazyEngine(workbook) {
|
|
|
92970
92995
|
}
|
|
92971
92996
|
};
|
|
92972
92997
|
}
|
|
92973
|
-
function readToJson(filePath, filter3) {
|
|
92998
|
+
function readToJson(filePath, filter3, opts) {
|
|
92974
92999
|
const buffer = fs6.readFileSync(filePath);
|
|
92975
93000
|
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
92976
93001
|
const parsed = parseExcelBuffer(arrayBuffer);
|
|
@@ -92989,13 +93014,13 @@ function readToJson(filePath, filter3) {
|
|
|
92989
93014
|
name: s.name,
|
|
92990
93015
|
totalRowCount: s.totalRowCount,
|
|
92991
93016
|
truncated: s.truncated,
|
|
92992
|
-
cells: cellsFromParsedRows(s.rows, filter3?.range),
|
|
93017
|
+
cells: cellsFromParsedRows(s.rows, filter3?.range, opts?.withFormat === true),
|
|
92993
93018
|
merges: s.mergedCells.map((m) => `${rowColToRef(m.startRow, m.startCol)}:${rowColToRef(m.endRow, m.endCol)}`),
|
|
92994
93019
|
freeze: s.freezePane ? { row: s.freezePane.frozenRows, col: s.freezePane.frozenCols } : void 0
|
|
92995
93020
|
}))
|
|
92996
93021
|
};
|
|
92997
93022
|
}
|
|
92998
|
-
function cellsFromParsedRows(rows, range2) {
|
|
93023
|
+
function cellsFromParsedRows(rows, range2, withFormat = false) {
|
|
92999
93024
|
const out = {};
|
|
93000
93025
|
for (const row of rows) {
|
|
93001
93026
|
if (range2 && (row.index < range2.startRow || row.index > range2.endRow)) continue;
|
|
@@ -93005,6 +93030,8 @@ function cellsFromParsedRows(rows, range2) {
|
|
|
93005
93030
|
const value2 = cell.typedValue ?? cell.value;
|
|
93006
93031
|
const entry = { value: value2 };
|
|
93007
93032
|
if (cell.formula) entry.formula = cell.formula;
|
|
93033
|
+
if (cell.numFmtCode && cell.numFmtCode !== "General") entry.numFmt = cell.numFmtCode;
|
|
93034
|
+
if (withFormat && cell.style && Object.keys(cell.style).length > 0) entry.style = cell.style;
|
|
93008
93035
|
out[ref2] = entry;
|
|
93009
93036
|
}
|
|
93010
93037
|
}
|
|
@@ -93025,6 +93052,10 @@ function buildWorkbookFromJson(input) {
|
|
|
93025
93052
|
}
|
|
93026
93053
|
function validateSimpleSheet(s, index) {
|
|
93027
93054
|
if (!s || typeof s !== "object") fail2(`sheets[${index}] must be an object`);
|
|
93055
|
+
const unknown2 = Object.keys(s).filter((k) => !SIMPLE_SHEET_KEYS.has(k));
|
|
93056
|
+
if (unknown2.length > 0) {
|
|
93057
|
+
fail2(`sheets[${index}] has unknown propert${unknown2.length > 1 ? "ies" : "y"}: ${unknown2.join(", ")}. Supported: ${[...SIMPLE_SHEET_KEYS].join(", ")}.`);
|
|
93058
|
+
}
|
|
93028
93059
|
if (typeof s.name !== "string" || s.name === "") fail2(`sheets[${index}].name must be a non-empty string`);
|
|
93029
93060
|
if (s.cells !== void 0 && (typeof s.cells !== "object" || s.cells === null || Array.isArray(s.cells))) {
|
|
93030
93061
|
fail2(`sheets[${index}].cells must be an object keyed by cell ref (e.g. {"A1": "value"})`);
|
|
@@ -93038,6 +93069,23 @@ function validateSimpleSheet(s, index) {
|
|
|
93038
93069
|
fail2(`sheets[${index}].freeze.row and .col must be numbers`);
|
|
93039
93070
|
}
|
|
93040
93071
|
}
|
|
93072
|
+
validateDimensionMap(s.colWidths, `sheets[${index}].colWidths`, "column letter within A..XFD", (k) => {
|
|
93073
|
+
const coord = /^[A-Za-z]+$/.test(k) ? refToRowCol(`${k.toUpperCase()}1`) : void 0;
|
|
93074
|
+
return coord !== void 0 && coord.col <= MAX_COLUMN;
|
|
93075
|
+
});
|
|
93076
|
+
validateDimensionMap(s.rowHeights, `sheets[${index}].rowHeights`, `row number within 1..${MAX_ROW}`, (k) => /^[0-9]+$/.test(k) && Number(k) >= 1 && Number(k) <= MAX_ROW);
|
|
93077
|
+
}
|
|
93078
|
+
function validateDimensionMap(map3, label, keyHint, keyOk) {
|
|
93079
|
+
if (map3 === void 0) return;
|
|
93080
|
+
if (typeof map3 !== "object" || map3 === null || Array.isArray(map3)) {
|
|
93081
|
+
fail2(`${label} must be an object keyed by ${keyHint}`);
|
|
93082
|
+
}
|
|
93083
|
+
for (const [key, value2] of Object.entries(map3)) {
|
|
93084
|
+
if (!keyOk(key)) fail2(`${label} key "${key}" must be a ${keyHint}`);
|
|
93085
|
+
if (typeof value2 !== "number" || !Number.isFinite(value2) || value2 <= 0) {
|
|
93086
|
+
fail2(`${label}["${key}"] must be a positive number`);
|
|
93087
|
+
}
|
|
93088
|
+
}
|
|
93041
93089
|
}
|
|
93042
93090
|
function applySheetCells(workbook, sheetIndex, def) {
|
|
93043
93091
|
const sheet = workbook.sheets[sheetIndex];
|
|
@@ -93070,6 +93118,20 @@ function applySheetCells(workbook, sheetIndex, def) {
|
|
|
93070
93118
|
if (def.freeze) {
|
|
93071
93119
|
sheet.freeze = { row: def.freeze.row, col: def.freeze.col };
|
|
93072
93120
|
}
|
|
93121
|
+
if (def.colWidths) {
|
|
93122
|
+
for (const [letter, width] of Object.entries(def.colWidths)) {
|
|
93123
|
+
const coord = refToRowCol(`${letter.toUpperCase()}1`);
|
|
93124
|
+
if (!coord) fail2(`Invalid column in sheet "${def.name}".colWidths: ${letter}`);
|
|
93125
|
+
sheet.colWidths.set(coord.col, width);
|
|
93126
|
+
}
|
|
93127
|
+
}
|
|
93128
|
+
if (def.rowHeights) {
|
|
93129
|
+
for (const [rowKey, height] of Object.entries(def.rowHeights)) {
|
|
93130
|
+
const row = Number(rowKey);
|
|
93131
|
+
if (!Number.isInteger(row) || row < 1) fail2(`Invalid row in sheet "${def.name}".rowHeights: ${rowKey}`);
|
|
93132
|
+
sheet.rowHeights.set(row, height);
|
|
93133
|
+
}
|
|
93134
|
+
}
|
|
93073
93135
|
}
|
|
93074
93136
|
function normalizeSimpleCell(raw, sheetName, ref2) {
|
|
93075
93137
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
@@ -93100,9 +93162,10 @@ function splitOptionalSheetRef(spec) {
|
|
|
93100
93162
|
return { sheet: spec.slice(0, idx), ref: spec.slice(idx + 1) };
|
|
93101
93163
|
}
|
|
93102
93164
|
function xlsxRead(filePath, rest2) {
|
|
93103
|
-
if (!filePath) fail2("Usage: lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>]");
|
|
93165
|
+
if (!filePath) fail2("Usage: lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>] [--with-format]");
|
|
93104
93166
|
const rangeArg = readOptionFlag(rest2, "--range");
|
|
93105
93167
|
const sheetArg = readOptionFlag(rest2, "--sheet");
|
|
93168
|
+
const withFormat = rest2.includes("--with-format");
|
|
93106
93169
|
let filter3;
|
|
93107
93170
|
if (rangeArg !== void 0) {
|
|
93108
93171
|
const { sheet, ref: ref2 } = splitOptionalSheetRef(rangeArg);
|
|
@@ -93114,7 +93177,7 @@ function xlsxRead(filePath, rest2) {
|
|
|
93114
93177
|
} else if (sheetArg !== void 0) {
|
|
93115
93178
|
filter3 = { sheet: sheetArg };
|
|
93116
93179
|
}
|
|
93117
|
-
const data2 = readToJson(filePath, filter3);
|
|
93180
|
+
const data2 = readToJson(filePath, filter3, { withFormat });
|
|
93118
93181
|
console.log(JSON.stringify(data2, null, 2));
|
|
93119
93182
|
}
|
|
93120
93183
|
function xlsxWrite(filePath, json2) {
|
|
@@ -93351,14 +93414,17 @@ function printXlsxHelp() {
|
|
|
93351
93414
|
console.error(`Lotics xlsx commands \u2014 manipulate .xlsx files in place.
|
|
93352
93415
|
Uses Lotics' own xlsx engine; round-trips faithfully with the Lotics editor and templates.
|
|
93353
93416
|
|
|
93354
|
-
lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>]
|
|
93417
|
+
lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>] [--with-format]
|
|
93355
93418
|
Dump file as JSON (sheets, cells, merges, freeze).
|
|
93356
93419
|
--sheet limits to one sheet; --range to a cell window
|
|
93357
93420
|
(its <sheet>! prefix is optional when --sheet is given)
|
|
93421
|
+
A cell carries numFmt when it has one; --with-format
|
|
93422
|
+
adds the resolved style (always present, hence a flag)
|
|
93358
93423
|
lotics xlsx write <file> '<json>' Create .xlsx from {"sheets":[{"name","cells":{"A1":...}}]}
|
|
93359
93424
|
A cell is a bare value, or {value|formula, numFmt, style}:
|
|
93360
93425
|
{"A1":{"value":1234,"numFmt":"#,##0 \\"\u20AB\\"","style":{"fontBold":true}}}
|
|
93361
|
-
|
|
93426
|
+
A sheet also takes merges, freeze, colWidths ({"A":34}),
|
|
93427
|
+
rowHeights ({"1":44}). Unknown properties are rejected.
|
|
93362
93428
|
lotics xlsx set-cell <file> <sheet>!<ref> '<v>' Set cell value (prefix '=' for formula)
|
|
93363
93429
|
lotics xlsx clear-range <file> <sheet>!<range> Clear all cells in a range
|
|
93364
93430
|
lotics xlsx merge <file> <sheet>!<range> Merge a range into one cell
|
|
@@ -95352,7 +95418,7 @@ function parseLegacyDoc(bytes) {
|
|
|
95352
95418
|
}
|
|
95353
95419
|
|
|
95354
95420
|
// ../ooxml/src/document.ts
|
|
95355
|
-
var
|
|
95421
|
+
var import_jszip2 = __toESM(require_lib4(), 1);
|
|
95356
95422
|
|
|
95357
95423
|
// ../ooxml/node_modules/fast-xml-parser/src/util.js
|
|
95358
95424
|
var nameStartChar2 = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
@@ -98031,6 +98097,14 @@ async function docModelToDocx(model) {
|
|
|
98031
98097
|
return doc;
|
|
98032
98098
|
}
|
|
98033
98099
|
|
|
98100
|
+
// ../ooxml/src/opc.ts
|
|
98101
|
+
var import_jszip = __toESM(require_lib4(), 1);
|
|
98102
|
+
function dropFolderEntries(zip) {
|
|
98103
|
+
for (const [path8, entry] of Object.entries(zip.files)) {
|
|
98104
|
+
if (entry.dir) delete zip.files[path8];
|
|
98105
|
+
}
|
|
98106
|
+
}
|
|
98107
|
+
|
|
98034
98108
|
// ../ooxml/src/document.ts
|
|
98035
98109
|
var DOCUMENT_ATTRS = {
|
|
98036
98110
|
"@_xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
@@ -98040,6 +98114,10 @@ var DOCUMENT_ATTRS = {
|
|
|
98040
98114
|
"@_xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
98041
98115
|
"@_xmlns:v": "urn:schemas-microsoft-com:vml",
|
|
98042
98116
|
"@_xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
98117
|
+
// Declared because mc:Ignorable below names it. Markup Compatibility (ECMA-376 Part 3) requires
|
|
98118
|
+
// every prefix listed there to be a declared namespace prefix; an undeclared one made Word
|
|
98119
|
+
// report unreadable content and offer to repair EVERY document this package wrote.
|
|
98120
|
+
"@_xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
|
98043
98121
|
"@_xmlns:w10": "urn:schemas-microsoft-com:office:word",
|
|
98044
98122
|
"@_xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
98045
98123
|
"@_xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
@@ -98135,7 +98213,7 @@ async function loadDocxFromBuffer(buffer) {
|
|
|
98135
98213
|
if (isLegacyDoc(buffer)) {
|
|
98136
98214
|
return docxFromLegacyDoc(buffer);
|
|
98137
98215
|
}
|
|
98138
|
-
const zip = await
|
|
98216
|
+
const zip = await import_jszip2.default.loadAsync(buffer);
|
|
98139
98217
|
const docFile = zip.file("word/document.xml");
|
|
98140
98218
|
if (!docFile) {
|
|
98141
98219
|
throw new Error("Invalid .docx: missing word/document.xml");
|
|
@@ -98168,19 +98246,30 @@ function withTrailingParagraph(body) {
|
|
|
98168
98246
|
out.splice(lastBlock + 1, 0, { "w:p": [] });
|
|
98169
98247
|
return out;
|
|
98170
98248
|
}
|
|
98249
|
+
function pruneIgnorable(attrs) {
|
|
98250
|
+
const listed = (attrs["@_mc:Ignorable"] ?? "").split(/\s+/).filter(Boolean);
|
|
98251
|
+
if (listed.length === 0) return attrs;
|
|
98252
|
+
const kept = listed.filter((prefix) => `@_xmlns:${prefix}` in attrs);
|
|
98253
|
+
if (kept.length === listed.length) return attrs;
|
|
98254
|
+
const next = { ...attrs };
|
|
98255
|
+
if (kept.length === 0) delete next["@_mc:Ignorable"];
|
|
98256
|
+
else next["@_mc:Ignorable"] = kept.join(" ");
|
|
98257
|
+
return next;
|
|
98258
|
+
}
|
|
98171
98259
|
async function saveDocxToBuffer(doc) {
|
|
98172
98260
|
const bodyChildren = withTrailingParagraph(doc.bodyElements);
|
|
98173
98261
|
const documentEl = {
|
|
98174
98262
|
"w:document": [{ "w:body": bodyChildren }],
|
|
98175
|
-
":@":
|
|
98263
|
+
":@": pruneIgnorable(doc.documentAttrs)
|
|
98176
98264
|
};
|
|
98177
98265
|
const xml = buildXml([documentEl]);
|
|
98178
98266
|
doc.zip.file("word/document.xml", xml);
|
|
98267
|
+
dropFolderEntries(doc.zip);
|
|
98179
98268
|
const buffer = await doc.zip.generateAsync({ type: "nodebuffer", compression: "DEFLATE" });
|
|
98180
98269
|
return buffer;
|
|
98181
98270
|
}
|
|
98182
98271
|
function createBlankDocx(opts) {
|
|
98183
|
-
const zip = new
|
|
98272
|
+
const zip = new import_jszip2.default();
|
|
98184
98273
|
zip.file("[Content_Types].xml", CONTENT_TYPES_XML);
|
|
98185
98274
|
zip.file("_rels/.rels", RELS_XML);
|
|
98186
98275
|
zip.file("word/_rels/document.xml.rels", DOCUMENT_RELS_XML);
|
|
@@ -98239,9 +98328,9 @@ async function ensureContentTypeOverride(doc, partName, contentType) {
|
|
|
98239
98328
|
}
|
|
98240
98329
|
|
|
98241
98330
|
// ../docx/src/parse/parser.ts
|
|
98242
|
-
var
|
|
98331
|
+
var import_jszip3 = __toESM(require_lib4(), 1);
|
|
98243
98332
|
async function parseDocx(buffer) {
|
|
98244
|
-
const zip = await
|
|
98333
|
+
const zip = await import_jszip3.default.loadAsync(buffer);
|
|
98245
98334
|
const parts = /* @__PURE__ */ new Map();
|
|
98246
98335
|
const filePromises = [];
|
|
98247
98336
|
zip.forEach((path8, file2) => {
|
|
@@ -98376,7 +98465,7 @@ function parseOpaqueRunChild(el) {
|
|
|
98376
98465
|
}
|
|
98377
98466
|
|
|
98378
98467
|
// ../docx/src/serialize/serializer.ts
|
|
98379
|
-
var
|
|
98468
|
+
var import_jszip4 = __toESM(require_lib4(), 1);
|
|
98380
98469
|
|
|
98381
98470
|
// ../docx/src/serialize/default_parts.ts
|
|
98382
98471
|
var encoder = new TextEncoder();
|
|
@@ -98490,7 +98579,7 @@ function fillDefaultParts(parts) {
|
|
|
98490
98579
|
|
|
98491
98580
|
// ../docx/src/serialize/serializer.ts
|
|
98492
98581
|
async function serializeDocx(doc) {
|
|
98493
|
-
const zip = new
|
|
98582
|
+
const zip = new import_jszip4.default();
|
|
98494
98583
|
const parts = fillDefaultParts(new Map(doc.parts));
|
|
98495
98584
|
for (const [path8, bytes] of parts) {
|
|
98496
98585
|
if (path8 === "word/document.xml") continue;
|
|
@@ -98498,6 +98587,7 @@ async function serializeDocx(doc) {
|
|
|
98498
98587
|
}
|
|
98499
98588
|
const documentXml = serializeDocumentXml(doc);
|
|
98500
98589
|
zip.file("word/document.xml", documentXml);
|
|
98590
|
+
dropFolderEntries(zip);
|
|
98501
98591
|
const out = await zip.generateAsync({
|
|
98502
98592
|
type: "uint8array",
|
|
98503
98593
|
compression: "DEFLATE"
|
package/dist/src/client.d.ts
CHANGED
|
@@ -233,7 +233,7 @@ export declare class LoticsClient {
|
|
|
233
233
|
agents?: Record<string, {
|
|
234
234
|
instructions?: string;
|
|
235
235
|
tool_names?: string[];
|
|
236
|
-
|
|
236
|
+
model_tier?: string;
|
|
237
237
|
inputs?: Record<string, unknown>;
|
|
238
238
|
outputs?: Record<string, unknown>;
|
|
239
239
|
}> | null;
|
package/docs/cli_reference.md
CHANGED
|
@@ -29,7 +29,7 @@ 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, 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`/`
|
|
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_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 |
|
|
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). **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. Refreshing here makes the divergence self-healing on a command already in the loop and keeps the remedy off `app pull` (which rewrites `src/workflows/*.ts` and would eat uncommitted body edits). The write is surgical and order-preserving (`orderedLike`), 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`. |
|
|
@@ -45,7 +45,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
45
45
|
| `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. |
|
|
46
46
|
| `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. |
|
|
47
47
|
| `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, which is what the deleted `lotics ui link` did when it twice destroyed the load-bearing `react-native` alias along with the array's closing bracket. 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. |
|
|
48
|
-
| `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
|
+
| `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. Atomic in-place write (temp file + rename). |
|
|
49
49
|
| `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. |
|
|
50
50
|
| `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). |
|
|
51
51
|
|