@lotics/cli 0.156.2 → 0.156.4
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 +252 -236
- package/docs/cli_reference.md +1 -0
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -26822,12 +26822,12 @@ var require_tokens = __commonJS({
|
|
|
26822
26822
|
});
|
|
26823
26823
|
}
|
|
26824
26824
|
exports2.assignCategoriesMapProp = assignCategoriesMapProp;
|
|
26825
|
-
function singleAssignCategoriesToksMap(
|
|
26826
|
-
utils_1.forEach(
|
|
26825
|
+
function singleAssignCategoriesToksMap(path13, nextNode) {
|
|
26826
|
+
utils_1.forEach(path13, function(pathNode) {
|
|
26827
26827
|
nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;
|
|
26828
26828
|
});
|
|
26829
26829
|
utils_1.forEach(nextNode.CATEGORIES, function(nextCategory) {
|
|
26830
|
-
var newPath =
|
|
26830
|
+
var newPath = path13.concat(nextNode);
|
|
26831
26831
|
if (!utils_1.contains(newPath, nextCategory)) {
|
|
26832
26832
|
singleAssignCategoriesToksMap(newPath, nextCategory);
|
|
26833
26833
|
}
|
|
@@ -28590,10 +28590,10 @@ var require_interpreter = __commonJS({
|
|
|
28590
28590
|
/** @class */
|
|
28591
28591
|
(function(_super) {
|
|
28592
28592
|
__extends(AbstractNextPossibleTokensWalker2, _super);
|
|
28593
|
-
function AbstractNextPossibleTokensWalker2(topProd,
|
|
28593
|
+
function AbstractNextPossibleTokensWalker2(topProd, path13) {
|
|
28594
28594
|
var _this = _super.call(this) || this;
|
|
28595
28595
|
_this.topProd = topProd;
|
|
28596
|
-
_this.path =
|
|
28596
|
+
_this.path = path13;
|
|
28597
28597
|
_this.possibleTokTypes = [];
|
|
28598
28598
|
_this.nextProductionName = "";
|
|
28599
28599
|
_this.nextProductionOccurrence = 0;
|
|
@@ -28647,9 +28647,9 @@ var require_interpreter = __commonJS({
|
|
|
28647
28647
|
/** @class */
|
|
28648
28648
|
(function(_super) {
|
|
28649
28649
|
__extends(NextAfterTokenWalker2, _super);
|
|
28650
|
-
function NextAfterTokenWalker2(topProd,
|
|
28651
|
-
var _this = _super.call(this, topProd,
|
|
28652
|
-
_this.path =
|
|
28650
|
+
function NextAfterTokenWalker2(topProd, path13) {
|
|
28651
|
+
var _this = _super.call(this, topProd, path13) || this;
|
|
28652
|
+
_this.path = path13;
|
|
28653
28653
|
_this.nextTerminalName = "";
|
|
28654
28654
|
_this.nextTerminalOccurrence = 0;
|
|
28655
28655
|
_this.nextTerminalName = _this.path.lastTok.name;
|
|
@@ -29346,10 +29346,10 @@ var require_lookahead = __commonJS({
|
|
|
29346
29346
|
}
|
|
29347
29347
|
return result;
|
|
29348
29348
|
}
|
|
29349
|
-
function pathToHashKeys(
|
|
29349
|
+
function pathToHashKeys(path13) {
|
|
29350
29350
|
var keys3 = [""];
|
|
29351
|
-
for (var i2 = 0; i2 <
|
|
29352
|
-
var tokType =
|
|
29351
|
+
for (var i2 = 0; i2 < path13.length; i2++) {
|
|
29352
|
+
var tokType = path13[i2];
|
|
29353
29353
|
var longerKeys = [];
|
|
29354
29354
|
for (var j = 0; j < keys3.length; j++) {
|
|
29355
29355
|
var currShorterKey = keys3[j];
|
|
@@ -29661,9 +29661,9 @@ var require_checks = __commonJS({
|
|
|
29661
29661
|
return errors2;
|
|
29662
29662
|
}
|
|
29663
29663
|
exports2.validateRuleIsOverridden = validateRuleIsOverridden;
|
|
29664
|
-
function validateNoLeftRecursion(topRule, currRule, errMsgProvider,
|
|
29665
|
-
if (
|
|
29666
|
-
|
|
29664
|
+
function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path13) {
|
|
29665
|
+
if (path13 === void 0) {
|
|
29666
|
+
path13 = [];
|
|
29667
29667
|
}
|
|
29668
29668
|
var errors2 = [];
|
|
29669
29669
|
var nextNonTerminals = getFirstNoneTerminal(currRule.definition);
|
|
@@ -29676,15 +29676,15 @@ var require_checks = __commonJS({
|
|
|
29676
29676
|
errors2.push({
|
|
29677
29677
|
message: errMsgProvider.buildLeftRecursionError({
|
|
29678
29678
|
topLevelRule: topRule,
|
|
29679
|
-
leftRecursionPath:
|
|
29679
|
+
leftRecursionPath: path13
|
|
29680
29680
|
}),
|
|
29681
29681
|
type: parser_1.ParserDefinitionErrorType.LEFT_RECURSION,
|
|
29682
29682
|
ruleName
|
|
29683
29683
|
});
|
|
29684
29684
|
}
|
|
29685
|
-
var validNextSteps = utils2.difference(nextNonTerminals,
|
|
29685
|
+
var validNextSteps = utils2.difference(nextNonTerminals, path13.concat([topRule]));
|
|
29686
29686
|
var errorsFromNextSteps = utils2.map(validNextSteps, function(currRefRule) {
|
|
29687
|
-
var newPath = utils2.cloneArr(
|
|
29687
|
+
var newPath = utils2.cloneArr(path13);
|
|
29688
29688
|
newPath.push(currRefRule);
|
|
29689
29689
|
return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);
|
|
29690
29690
|
});
|
|
@@ -37293,8 +37293,8 @@ var require_utils4 = __commonJS({
|
|
|
37293
37293
|
var result = transform2[inputType][outputType](input);
|
|
37294
37294
|
return result;
|
|
37295
37295
|
};
|
|
37296
|
-
exports2.resolve = function(
|
|
37297
|
-
var parts =
|
|
37296
|
+
exports2.resolve = function(path13) {
|
|
37297
|
+
var parts = path13.split("/");
|
|
37298
37298
|
var result = [];
|
|
37299
37299
|
for (var index = 0; index < parts.length; index++) {
|
|
37300
37300
|
var part = parts[index];
|
|
@@ -43147,18 +43147,18 @@ var require_object = __commonJS({
|
|
|
43147
43147
|
var object2 = new ZipObject(name2, zipObjectContent, o);
|
|
43148
43148
|
this.files[name2] = object2;
|
|
43149
43149
|
};
|
|
43150
|
-
var parentFolder = function(
|
|
43151
|
-
if (
|
|
43152
|
-
|
|
43150
|
+
var parentFolder = function(path13) {
|
|
43151
|
+
if (path13.slice(-1) === "/") {
|
|
43152
|
+
path13 = path13.substring(0, path13.length - 1);
|
|
43153
43153
|
}
|
|
43154
|
-
var lastSlash =
|
|
43155
|
-
return lastSlash > 0 ?
|
|
43154
|
+
var lastSlash = path13.lastIndexOf("/");
|
|
43155
|
+
return lastSlash > 0 ? path13.substring(0, lastSlash) : "";
|
|
43156
43156
|
};
|
|
43157
|
-
var forceTrailingSlash = function(
|
|
43158
|
-
if (
|
|
43159
|
-
|
|
43157
|
+
var forceTrailingSlash = function(path13) {
|
|
43158
|
+
if (path13.slice(-1) !== "/") {
|
|
43159
|
+
path13 += "/";
|
|
43160
43160
|
}
|
|
43161
|
-
return
|
|
43161
|
+
return path13;
|
|
43162
43162
|
};
|
|
43163
43163
|
var folderAdd = function(name2, createFolders) {
|
|
43164
43164
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults2.createFolders;
|
|
@@ -44162,7 +44162,7 @@ import dns from "node:dns";
|
|
|
44162
44162
|
import net2 from "node:net";
|
|
44163
44163
|
import fs13 from "node:fs";
|
|
44164
44164
|
import os4 from "node:os";
|
|
44165
|
-
import
|
|
44165
|
+
import path12 from "node:path";
|
|
44166
44166
|
import readline from "node:readline";
|
|
44167
44167
|
|
|
44168
44168
|
// ../shared/src/transport_error.ts
|
|
@@ -44356,8 +44356,8 @@ var LoticsClient = class {
|
|
|
44356
44356
|
}
|
|
44357
44357
|
return headers;
|
|
44358
44358
|
}
|
|
44359
|
-
async request(method,
|
|
44360
|
-
const url2 = `${this.baseUrl}${
|
|
44359
|
+
async request(method, path13, body) {
|
|
44360
|
+
const url2 = `${this.baseUrl}${path13}`;
|
|
44361
44361
|
const headers = this.buildHeaders();
|
|
44362
44362
|
const init = { method, headers };
|
|
44363
44363
|
if (body !== void 0) {
|
|
@@ -46206,7 +46206,7 @@ async function reportCommand(client, options) {
|
|
|
46206
46206
|
|
|
46207
46207
|
// src/app_commands.ts
|
|
46208
46208
|
import fs8 from "node:fs";
|
|
46209
|
-
import
|
|
46209
|
+
import path10 from "node:path";
|
|
46210
46210
|
import { spawn as spawn2 } from "node:child_process";
|
|
46211
46211
|
import { createHash as createHash3 } from "node:crypto";
|
|
46212
46212
|
import { tmpdir } from "node:os";
|
|
@@ -46964,6 +46964,8 @@ function escapeHtml(s) {
|
|
|
46964
46964
|
// src/dev/server.ts
|
|
46965
46965
|
import http from "node:http";
|
|
46966
46966
|
import net from "node:net";
|
|
46967
|
+
import { existsSync } from "node:fs";
|
|
46968
|
+
import path8 from "node:path";
|
|
46967
46969
|
import { spawn } from "node:child_process";
|
|
46968
46970
|
|
|
46969
46971
|
// src/child_env.ts
|
|
@@ -47535,6 +47537,7 @@ function createFileRelay(wrapperOrigin, now = Date.now) {
|
|
|
47535
47537
|
// src/dev/server.ts
|
|
47536
47538
|
var DEFAULT_PORT = 5174;
|
|
47537
47539
|
var DEFAULT_VITE_PORT = 5173;
|
|
47540
|
+
var STOP_DEADLINE_MS = 2e3;
|
|
47538
47541
|
function serializeRpcResult(result) {
|
|
47539
47542
|
return JSON.stringify(result ?? null);
|
|
47540
47543
|
}
|
|
@@ -47549,9 +47552,15 @@ async function startDevServer(args) {
|
|
|
47549
47552
|
vite_url: viteUrl,
|
|
47550
47553
|
api_url: args.api_url
|
|
47551
47554
|
});
|
|
47555
|
+
const viteEntry = path8.join(args.projectDir, "node_modules", "vite", "bin", "vite.js");
|
|
47556
|
+
if (!existsSync(viteEntry)) {
|
|
47557
|
+
throw new Error(
|
|
47558
|
+
`Vite is not installed in ${args.projectDir} \u2014 run \`npm install\` there first.`
|
|
47559
|
+
);
|
|
47560
|
+
}
|
|
47552
47561
|
const viteChild = spawn(
|
|
47553
|
-
|
|
47554
|
-
[
|
|
47562
|
+
process.execPath,
|
|
47563
|
+
[viteEntry, "--port", String(vitePort), "--strictPort"],
|
|
47555
47564
|
{
|
|
47556
47565
|
cwd: args.projectDir,
|
|
47557
47566
|
stdio: [process.stdin.isTTY ? "inherit" : "ignore", "inherit", "inherit"],
|
|
@@ -47819,7 +47828,14 @@ async function startDevServer(args) {
|
|
|
47819
47828
|
if (!viteChild.killed) {
|
|
47820
47829
|
viteChild.kill("SIGINT");
|
|
47821
47830
|
}
|
|
47822
|
-
await new Promise((resolve2) =>
|
|
47831
|
+
await new Promise((resolve2) => {
|
|
47832
|
+
const done = setTimeout(resolve2, STOP_DEADLINE_MS);
|
|
47833
|
+
server.close(() => {
|
|
47834
|
+
clearTimeout(done);
|
|
47835
|
+
resolve2();
|
|
47836
|
+
});
|
|
47837
|
+
server.closeAllConnections();
|
|
47838
|
+
});
|
|
47823
47839
|
stoppingResolve?.();
|
|
47824
47840
|
}
|
|
47825
47841
|
const ready = new Promise((resolve2) => {
|
|
@@ -48519,7 +48535,7 @@ export type AppRoles = typeof ROLE;
|
|
|
48519
48535
|
|
|
48520
48536
|
// src/app_workflow_check.ts
|
|
48521
48537
|
import fs7 from "node:fs";
|
|
48522
|
-
import
|
|
48538
|
+
import path9 from "node:path";
|
|
48523
48539
|
import { createRequire } from "node:module";
|
|
48524
48540
|
|
|
48525
48541
|
// ../shared/src/parse_workflow_js.ts
|
|
@@ -49291,10 +49307,10 @@ function mergeDefs(...defs) {
|
|
|
49291
49307
|
function cloneDef(schema) {
|
|
49292
49308
|
return mergeDefs(schema._zod.def);
|
|
49293
49309
|
}
|
|
49294
|
-
function getElementAtPath(obj,
|
|
49295
|
-
if (!
|
|
49310
|
+
function getElementAtPath(obj, path13) {
|
|
49311
|
+
if (!path13)
|
|
49296
49312
|
return obj;
|
|
49297
|
-
return
|
|
49313
|
+
return path13.reduce((acc, key) => acc?.[key], obj);
|
|
49298
49314
|
}
|
|
49299
49315
|
function promiseAllObject(promisesObj) {
|
|
49300
49316
|
const keys3 = Object.keys(promisesObj);
|
|
@@ -49703,11 +49719,11 @@ function explicitlyAborted(x2, startIndex = 0) {
|
|
|
49703
49719
|
}
|
|
49704
49720
|
return false;
|
|
49705
49721
|
}
|
|
49706
|
-
function prefixIssues(
|
|
49722
|
+
function prefixIssues(path13, issues) {
|
|
49707
49723
|
return issues.map((iss) => {
|
|
49708
49724
|
var _a4;
|
|
49709
49725
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
49710
|
-
iss.path.unshift(
|
|
49726
|
+
iss.path.unshift(path13);
|
|
49711
49727
|
return iss;
|
|
49712
49728
|
});
|
|
49713
49729
|
}
|
|
@@ -49854,16 +49870,16 @@ function flattenError(error52, mapper = (issue2) => issue2.message) {
|
|
|
49854
49870
|
}
|
|
49855
49871
|
function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
49856
49872
|
const fieldErrors = { _errors: [] };
|
|
49857
|
-
const processError = (error53,
|
|
49873
|
+
const processError = (error53, path13 = []) => {
|
|
49858
49874
|
for (const issue2 of error53.issues) {
|
|
49859
49875
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
49860
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
49876
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
49861
49877
|
} else if (issue2.code === "invalid_key") {
|
|
49862
|
-
processError({ issues: issue2.issues }, [...
|
|
49878
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
49863
49879
|
} else if (issue2.code === "invalid_element") {
|
|
49864
|
-
processError({ issues: issue2.issues }, [...
|
|
49880
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
49865
49881
|
} else {
|
|
49866
|
-
const fullpath = [...
|
|
49882
|
+
const fullpath = [...path13, ...issue2.path];
|
|
49867
49883
|
if (fullpath.length === 0) {
|
|
49868
49884
|
fieldErrors._errors.push(mapper(issue2));
|
|
49869
49885
|
} else {
|
|
@@ -49890,17 +49906,17 @@ function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
|
49890
49906
|
}
|
|
49891
49907
|
function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
49892
49908
|
const result = { errors: [] };
|
|
49893
|
-
const processError = (error53,
|
|
49909
|
+
const processError = (error53, path13 = []) => {
|
|
49894
49910
|
var _a4, _b2;
|
|
49895
49911
|
for (const issue2 of error53.issues) {
|
|
49896
49912
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
49897
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
49913
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
49898
49914
|
} else if (issue2.code === "invalid_key") {
|
|
49899
|
-
processError({ issues: issue2.issues }, [...
|
|
49915
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
49900
49916
|
} else if (issue2.code === "invalid_element") {
|
|
49901
|
-
processError({ issues: issue2.issues }, [...
|
|
49917
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
49902
49918
|
} else {
|
|
49903
|
-
const fullpath = [...
|
|
49919
|
+
const fullpath = [...path13, ...issue2.path];
|
|
49904
49920
|
if (fullpath.length === 0) {
|
|
49905
49921
|
result.errors.push(mapper(issue2));
|
|
49906
49922
|
continue;
|
|
@@ -49932,8 +49948,8 @@ function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
|
49932
49948
|
}
|
|
49933
49949
|
function toDotPath(_path) {
|
|
49934
49950
|
const segs = [];
|
|
49935
|
-
const
|
|
49936
|
-
for (const seg of
|
|
49951
|
+
const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
49952
|
+
for (const seg of path13) {
|
|
49937
49953
|
if (typeof seg === "number")
|
|
49938
49954
|
segs.push(`[${seg}]`);
|
|
49939
49955
|
else if (typeof seg === "symbol")
|
|
@@ -62625,13 +62641,13 @@ function resolveRef(ref2, ctx) {
|
|
|
62625
62641
|
if (!ref2.startsWith("#")) {
|
|
62626
62642
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
62627
62643
|
}
|
|
62628
|
-
const
|
|
62629
|
-
if (
|
|
62644
|
+
const path13 = ref2.slice(1).split("/").filter(Boolean);
|
|
62645
|
+
if (path13.length === 0) {
|
|
62630
62646
|
return ctx.rootSchema;
|
|
62631
62647
|
}
|
|
62632
62648
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
62633
|
-
if (
|
|
62634
|
-
const key =
|
|
62649
|
+
if (path13[0] === defsKey) {
|
|
62650
|
+
const key = path13[1];
|
|
62635
62651
|
if (!key || !ctx.defs[key]) {
|
|
62636
62652
|
throw new Error(`Reference not found: ${ref2}`);
|
|
62637
62653
|
}
|
|
@@ -67341,9 +67357,9 @@ __export(expression_object_exports, {
|
|
|
67341
67357
|
pick: () => pick3,
|
|
67342
67358
|
values: () => values2
|
|
67343
67359
|
});
|
|
67344
|
-
function getNestedValue(obj,
|
|
67360
|
+
function getNestedValue(obj, path13) {
|
|
67345
67361
|
if (obj == null) return void 0;
|
|
67346
|
-
const parts =
|
|
67362
|
+
const parts = path13.split(".");
|
|
67347
67363
|
let value2 = obj;
|
|
67348
67364
|
for (const part of parts) {
|
|
67349
67365
|
if (value2 == null) return void 0;
|
|
@@ -67382,11 +67398,11 @@ function entries(obj) {
|
|
|
67382
67398
|
}
|
|
67383
67399
|
return Object.entries(obj);
|
|
67384
67400
|
}
|
|
67385
|
-
function get(obj,
|
|
67386
|
-
if (typeof
|
|
67401
|
+
function get(obj, path13, defaultValue) {
|
|
67402
|
+
if (typeof path13 !== "string") {
|
|
67387
67403
|
throw new Error("get: path must be a string");
|
|
67388
67404
|
}
|
|
67389
|
-
const value2 = getNestedValue(obj,
|
|
67405
|
+
const value2 = getNestedValue(obj, path13);
|
|
67390
67406
|
return value2 !== void 0 ? value2 : defaultValue;
|
|
67391
67407
|
}
|
|
67392
67408
|
function pick3(obj, fields) {
|
|
@@ -69269,17 +69285,17 @@ function readFromChanges(chain2) {
|
|
|
69269
69285
|
if (first3.kind === "bracket-number" || first3.kind === "bracket-expr") {
|
|
69270
69286
|
fail(first3.node, "changes is keyed by field name, not numeric index.");
|
|
69271
69287
|
}
|
|
69272
|
-
const
|
|
69288
|
+
const path13 = [{ at: "key", key: first3.key }];
|
|
69273
69289
|
for (const seg of segments.slice(1)) {
|
|
69274
69290
|
if (seg.kind === "bracket-number") {
|
|
69275
|
-
|
|
69291
|
+
path13.push({ at: "index", index: seg.index });
|
|
69276
69292
|
} else if (seg.kind === "bracket-expr") {
|
|
69277
|
-
|
|
69293
|
+
path13.push({ at: "index", index: seg.expr });
|
|
69278
69294
|
} else {
|
|
69279
|
-
|
|
69295
|
+
path13.push({ at: "key", key: seg.key });
|
|
69280
69296
|
}
|
|
69281
69297
|
}
|
|
69282
|
-
return { kind: "read", source: { from: "trigger_changes" }, path:
|
|
69298
|
+
return { kind: "read", source: { from: "trigger_changes" }, path: path13 };
|
|
69283
69299
|
});
|
|
69284
69300
|
}
|
|
69285
69301
|
var TRIGGER_RECORD_VIEWS = /* @__PURE__ */ new Map([
|
|
@@ -69297,17 +69313,17 @@ function readFromTrigger(chain2) {
|
|
|
69297
69313
|
return view === "trigger_changes" ? readFromChanges(lowered) : readFromRecord(view, lowered);
|
|
69298
69314
|
}
|
|
69299
69315
|
return wrapOptionalGuards(chain2, (segments) => {
|
|
69300
|
-
const
|
|
69316
|
+
const path13 = [];
|
|
69301
69317
|
for (const seg of segments) {
|
|
69302
69318
|
if (seg.kind === "bracket-number") {
|
|
69303
|
-
|
|
69319
|
+
path13.push({ at: "index", index: seg.index });
|
|
69304
69320
|
} else if (seg.kind === "bracket-expr") {
|
|
69305
|
-
|
|
69321
|
+
path13.push({ at: "index", index: seg.expr });
|
|
69306
69322
|
} else {
|
|
69307
|
-
|
|
69323
|
+
path13.push({ at: "key", key: seg.key });
|
|
69308
69324
|
}
|
|
69309
69325
|
}
|
|
69310
|
-
return { kind: "read", source: { from: "trigger" }, path:
|
|
69326
|
+
return { kind: "read", source: { from: "trigger" }, path: path13 };
|
|
69311
69327
|
});
|
|
69312
69328
|
}
|
|
69313
69329
|
function readFromRuntime(chain2) {
|
|
@@ -69329,17 +69345,17 @@ function readFromRuntime(chain2) {
|
|
|
69329
69345
|
const parked = PARKED_RUNTIME_KEYS.get(key);
|
|
69330
69346
|
if (parked) fail(first3.node, parked, parkedRuntimeKeyConstruct(key));
|
|
69331
69347
|
const source = { from: "runtime", key };
|
|
69332
|
-
const
|
|
69348
|
+
const path13 = [];
|
|
69333
69349
|
for (const seg of segments.slice(1)) {
|
|
69334
69350
|
if (seg.kind === "bracket-number") {
|
|
69335
|
-
|
|
69351
|
+
path13.push({ at: "index", index: seg.index });
|
|
69336
69352
|
} else if (seg.kind === "bracket-expr") {
|
|
69337
|
-
|
|
69353
|
+
path13.push({ at: "index", index: seg.expr });
|
|
69338
69354
|
} else {
|
|
69339
|
-
|
|
69355
|
+
path13.push({ at: "key", key: seg.key });
|
|
69340
69356
|
}
|
|
69341
69357
|
}
|
|
69342
|
-
return { kind: "read", source, path:
|
|
69358
|
+
return { kind: "read", source, path: path13 };
|
|
69343
69359
|
});
|
|
69344
69360
|
}
|
|
69345
69361
|
function readFromForeachItem(chain2) {
|
|
@@ -69375,17 +69391,17 @@ function readFromLexical(name2, chain2) {
|
|
|
69375
69391
|
}
|
|
69376
69392
|
function readFromStepOutput(stepId, chain2) {
|
|
69377
69393
|
return wrapOptionalGuards(chain2, (segments) => {
|
|
69378
|
-
const
|
|
69394
|
+
const path13 = [];
|
|
69379
69395
|
for (const seg of segments) {
|
|
69380
69396
|
if (seg.kind === "bracket-number") {
|
|
69381
|
-
|
|
69397
|
+
path13.push({ at: "index", index: seg.index });
|
|
69382
69398
|
} else if (seg.kind === "bracket-expr") {
|
|
69383
|
-
|
|
69399
|
+
path13.push({ at: "index", index: seg.expr });
|
|
69384
69400
|
} else {
|
|
69385
|
-
|
|
69401
|
+
path13.push({ at: "key", key: seg.key });
|
|
69386
69402
|
}
|
|
69387
69403
|
}
|
|
69388
|
-
return { kind: "read", source: { from: "step_output", step_id: stepId }, path:
|
|
69404
|
+
return { kind: "read", source: { from: "step_output", step_id: stepId }, path: path13 };
|
|
69389
69405
|
});
|
|
69390
69406
|
}
|
|
69391
69407
|
function classifyRecordPath(segs) {
|
|
@@ -71054,7 +71070,7 @@ function subsetIssues(bodySource, offset) {
|
|
|
71054
71070
|
];
|
|
71055
71071
|
}
|
|
71056
71072
|
async function loadProjectTypescript(projectDir) {
|
|
71057
|
-
const requireFromProject = createRequire(
|
|
71073
|
+
const requireFromProject = createRequire(path9.join(projectDir, "package.json"));
|
|
71058
71074
|
let resolved;
|
|
71059
71075
|
try {
|
|
71060
71076
|
resolved = requireFromProject.resolve("typescript");
|
|
@@ -71067,9 +71083,9 @@ async function loadProjectTypescript(projectDir) {
|
|
|
71067
71083
|
return mod2.default ?? mod2;
|
|
71068
71084
|
}
|
|
71069
71085
|
function pathToImportUrl(p) {
|
|
71070
|
-
const resolved =
|
|
71086
|
+
const resolved = path9.resolve(p);
|
|
71071
71087
|
const prefixed = resolved.startsWith("/") ? resolved : `/${resolved}`;
|
|
71072
|
-
return `file://${prefixed.split(
|
|
71088
|
+
return `file://${prefixed.split(path9.sep).join("/")}`;
|
|
71073
71089
|
}
|
|
71074
71090
|
function checkOneWorkflowBody(tsApi, input) {
|
|
71075
71091
|
const wrapped = fs7.readFileSync(input.bodyPath, "utf-8");
|
|
@@ -71119,7 +71135,7 @@ function checkOneWorkflowBody(tsApi, input) {
|
|
|
71119
71135
|
}
|
|
71120
71136
|
function createCheckedSourceHost(tsApi, options, bodyPath, bodyText) {
|
|
71121
71137
|
const base = tsApi.createCompilerHost(options, false);
|
|
71122
|
-
const key = (fileName) => base.getCanonicalFileName(
|
|
71138
|
+
const key = (fileName) => base.getCanonicalFileName(path9.resolve(fileName).replace(/\\/g, "/"));
|
|
71123
71139
|
const bodyKey = key(bodyPath);
|
|
71124
71140
|
return {
|
|
71125
71141
|
...base,
|
|
@@ -72318,7 +72334,7 @@ function syncedEntry(entry) {
|
|
|
72318
72334
|
function readSynced(projectDir) {
|
|
72319
72335
|
try {
|
|
72320
72336
|
const pkg2 = JSON.parse(
|
|
72321
|
-
fs8.readFileSync(
|
|
72337
|
+
fs8.readFileSync(path10.join(projectDir, "package.json"), "utf-8")
|
|
72322
72338
|
);
|
|
72323
72339
|
const raw = pkg2.lotics?.synced ?? {};
|
|
72324
72340
|
return {
|
|
@@ -72339,16 +72355,16 @@ function normalizeSyncedMap(map3) {
|
|
|
72339
72355
|
);
|
|
72340
72356
|
}
|
|
72341
72357
|
function writeSynced(projectDir, kind, alias, entry) {
|
|
72342
|
-
const pkgPath2 =
|
|
72358
|
+
const pkgPath2 = path10.join(projectDir, "package.json");
|
|
72343
72359
|
const pkg2 = JSON.parse(fs8.readFileSync(pkgPath2, "utf-8"));
|
|
72344
72360
|
if (!pkg2.lotics) return;
|
|
72345
72361
|
pkg2.lotics.synced ??= {};
|
|
72346
72362
|
pkg2.lotics.synced[kind] = { ...pkg2.lotics.synced[kind], [alias]: entry };
|
|
72347
72363
|
fs8.writeFileSync(pkgPath2, JSON.stringify(pkg2, null, 2) + "\n");
|
|
72348
72364
|
}
|
|
72349
|
-
var WORKFLOWS_DIR =
|
|
72350
|
-
var WORKFLOW_GLOBALS_DIR =
|
|
72351
|
-
var AGENTS_DIR =
|
|
72365
|
+
var WORKFLOWS_DIR = path10.join("src", "workflows");
|
|
72366
|
+
var WORKFLOW_GLOBALS_DIR = path10.join(".lotics", "workflows");
|
|
72367
|
+
var AGENTS_DIR = path10.join("src", "agents");
|
|
72352
72368
|
var WORKFLOW_TSCONFIG_EXCLUDES = ["src/workflows", ".lotics/workflows"];
|
|
72353
72369
|
var LOTICS_INCLUDE_GLOB = ".lotics/**/*";
|
|
72354
72370
|
var STALE_LOTICS_INCLUDES = /* @__PURE__ */ new Set([".lotics", "./.lotics", ".lotics/"]);
|
|
@@ -72359,7 +72375,7 @@ function isMissingWorkflowBodyError(error52) {
|
|
|
72359
72375
|
return /has no step source|cannot be rendered|unsupported step/i.test(error52);
|
|
72360
72376
|
}
|
|
72361
72377
|
function workflowFileHeader(alias) {
|
|
72362
|
-
const refPath =
|
|
72378
|
+
const refPath = path10.join("..", "..", WORKFLOW_GLOBALS_DIR, `${alias}.globals.d.ts`).split(path10.sep).join("/");
|
|
72363
72379
|
return (
|
|
72364
72380
|
// The scaffold ships oxlint, whose `triple-slash-reference` rule flags the
|
|
72365
72381
|
// line below — so every pulled body arrived with a warning its author could
|
|
@@ -72382,27 +72398,27 @@ export {};
|
|
|
72382
72398
|
);
|
|
72383
72399
|
}
|
|
72384
72400
|
function workflowFilePath(projectDir, alias) {
|
|
72385
|
-
return
|
|
72401
|
+
return path10.join(projectDir, WORKFLOWS_DIR, `${alias}.ts`);
|
|
72386
72402
|
}
|
|
72387
72403
|
var GLOBALS_SUFFIX = ".globals.d.ts";
|
|
72388
72404
|
function workflowGlobalsPath(projectDir, alias) {
|
|
72389
|
-
return
|
|
72405
|
+
return path10.join(projectDir, WORKFLOW_GLOBALS_DIR, `${alias}${GLOBALS_SUFFIX}`);
|
|
72390
72406
|
}
|
|
72391
72407
|
function pruneOrphanWorkflowGlobals(projectDir, declared) {
|
|
72392
|
-
const dir =
|
|
72408
|
+
const dir = path10.join(projectDir, WORKFLOW_GLOBALS_DIR);
|
|
72393
72409
|
if (!fs8.existsSync(dir)) return [];
|
|
72394
72410
|
const removed = [];
|
|
72395
72411
|
for (const entry of fs8.readdirSync(dir)) {
|
|
72396
72412
|
if (!entry.endsWith(GLOBALS_SUFFIX)) continue;
|
|
72397
72413
|
const alias = entry.slice(0, -GLOBALS_SUFFIX.length);
|
|
72398
72414
|
if (declared.has(alias)) continue;
|
|
72399
|
-
fs8.unlinkSync(
|
|
72415
|
+
fs8.unlinkSync(path10.join(dir, entry));
|
|
72400
72416
|
removed.push(alias);
|
|
72401
72417
|
}
|
|
72402
72418
|
return removed.sort();
|
|
72403
72419
|
}
|
|
72404
72420
|
function orphanWorkflowBodies(projectDir, declared) {
|
|
72405
|
-
const dir =
|
|
72421
|
+
const dir = path10.join(projectDir, WORKFLOWS_DIR);
|
|
72406
72422
|
if (!fs8.existsSync(dir)) return [];
|
|
72407
72423
|
return fs8.readdirSync(dir).filter((e) => e.endsWith(".ts") && !e.endsWith(".d.ts") && !e.endsWith(".test.ts")).map((e) => e.slice(0, -".ts".length)).filter((alias) => !declared.has(alias)).sort();
|
|
72408
72424
|
}
|
|
@@ -72440,7 +72456,7 @@ function staleWorkflowGlobals(projectDir, workflows) {
|
|
|
72440
72456
|
return out;
|
|
72441
72457
|
}
|
|
72442
72458
|
function writeWorkflowGlobals(projectDir, alias, dts, declaration) {
|
|
72443
|
-
const dir =
|
|
72459
|
+
const dir = path10.join(projectDir, WORKFLOW_GLOBALS_DIR);
|
|
72444
72460
|
fs8.mkdirSync(dir, { recursive: true });
|
|
72445
72461
|
const file2 = workflowGlobalsPath(projectDir, alias);
|
|
72446
72462
|
const stamp = `${GLOBALS_STAMP_PREFIX}${workflowDeclarationStamp(declaration)}`;
|
|
@@ -72453,7 +72469,7 @@ function normalizeWorkflowBody(source) {
|
|
|
72453
72469
|
return source.replace(/\s+$/, "");
|
|
72454
72470
|
}
|
|
72455
72471
|
function writeWorkflowFile(projectDir, alias, source, envelope2 = { prefix: WORKFLOW_ENVELOPE_PREFIX, suffix: WORKFLOW_ENVELOPE_SUFFIX }) {
|
|
72456
|
-
const dir =
|
|
72472
|
+
const dir = path10.join(projectDir, WORKFLOWS_DIR);
|
|
72457
72473
|
fs8.mkdirSync(dir, { recursive: true });
|
|
72458
72474
|
const file2 = workflowFilePath(projectDir, alias);
|
|
72459
72475
|
const body = normalizeWorkflowBody(source);
|
|
@@ -72463,14 +72479,14 @@ ${envelope2.prefix}${body}${envelope2.suffix}
|
|
|
72463
72479
|
return file2;
|
|
72464
72480
|
}
|
|
72465
72481
|
function agentFilePath2(projectDir, alias) {
|
|
72466
|
-
return
|
|
72482
|
+
return path10.join(projectDir, ...agentFilePath(alias).split("/"));
|
|
72467
72483
|
}
|
|
72468
72484
|
var CLI_AGENT_NOTES = [
|
|
72469
72485
|
"Pulled from the LIVE app row; edit here, then: lotics app agent set <alias>",
|
|
72470
72486
|
"The typed fields (inputs/outputs/tool_names/model_tier) live in package.json#lotics.agents"
|
|
72471
72487
|
];
|
|
72472
72488
|
function writeAgentFile(projectDir, alias, instructions) {
|
|
72473
|
-
fs8.mkdirSync(
|
|
72489
|
+
fs8.mkdirSync(path10.join(projectDir, AGENTS_DIR), { recursive: true });
|
|
72474
72490
|
const file2 = agentFilePath2(projectDir, alias);
|
|
72475
72491
|
fs8.writeFileSync(
|
|
72476
72492
|
file2,
|
|
@@ -72569,7 +72585,7 @@ async function writeWorkflowFiles(client, projectDir, app_id, appName, workflows
|
|
|
72569
72585
|
return written;
|
|
72570
72586
|
}
|
|
72571
72587
|
function writeWorkflowDescription(projectDir, alias, description) {
|
|
72572
|
-
const pkgPath2 =
|
|
72588
|
+
const pkgPath2 = path10.join(projectDir, "package.json");
|
|
72573
72589
|
const pkg2 = JSON.parse(fs8.readFileSync(pkgPath2, "utf-8"));
|
|
72574
72590
|
const declaration = pkg2.lotics?.workflows?.[alias];
|
|
72575
72591
|
if (!declaration) return;
|
|
@@ -72624,7 +72640,7 @@ function runNpm(args, cwd) {
|
|
|
72624
72640
|
}
|
|
72625
72641
|
function readAppWorkspaceId(projectDir) {
|
|
72626
72642
|
try {
|
|
72627
|
-
const pkgPath2 =
|
|
72643
|
+
const pkgPath2 = path10.join(projectDir, "package.json");
|
|
72628
72644
|
if (!fs8.existsSync(pkgPath2)) return null;
|
|
72629
72645
|
const pkg2 = JSON.parse(fs8.readFileSync(pkgPath2, "utf-8"));
|
|
72630
72646
|
return pkg2.lotics?.workspace_id ?? null;
|
|
@@ -72633,7 +72649,7 @@ function readAppWorkspaceId(projectDir) {
|
|
|
72633
72649
|
}
|
|
72634
72650
|
}
|
|
72635
72651
|
function readAppMeta(projectDir) {
|
|
72636
|
-
const pkgPath2 =
|
|
72652
|
+
const pkgPath2 = path10.join(projectDir, "package.json");
|
|
72637
72653
|
if (!fs8.existsSync(pkgPath2)) {
|
|
72638
72654
|
throw new Error(`No package.json found at ${projectDir}. Run 'lotics app create' first.`);
|
|
72639
72655
|
}
|
|
@@ -72656,7 +72672,7 @@ function readAppMeta(projectDir) {
|
|
|
72656
72672
|
};
|
|
72657
72673
|
}
|
|
72658
72674
|
function writeAppMeta(projectDir, meta3) {
|
|
72659
|
-
const pkgPath2 =
|
|
72675
|
+
const pkgPath2 = path10.join(projectDir, "package.json");
|
|
72660
72676
|
const pkg2 = JSON.parse(fs8.readFileSync(pkgPath2, "utf-8"));
|
|
72661
72677
|
const existing = pkg2.lotics && typeof pkg2.lotics === "object" ? pkg2.lotics : {};
|
|
72662
72678
|
const supplied = new Set(
|
|
@@ -72670,7 +72686,7 @@ function writeAppMeta(projectDir, meta3) {
|
|
|
72670
72686
|
fs8.writeFileSync(pkgPath2, JSON.stringify(pkg2, null, 2) + "\n");
|
|
72671
72687
|
}
|
|
72672
72688
|
function writeWorkflowOutputs(projectDir, alias, outputs) {
|
|
72673
|
-
const pkgPath2 =
|
|
72689
|
+
const pkgPath2 = path10.join(projectDir, "package.json");
|
|
72674
72690
|
const pkg2 = JSON.parse(fs8.readFileSync(pkgPath2, "utf-8"));
|
|
72675
72691
|
const declaration = pkg2.lotics?.workflows?.[alias];
|
|
72676
72692
|
if (!declaration) {
|
|
@@ -72695,7 +72711,7 @@ function workflowBodyDrift(projectDir, workflows, synced = {}) {
|
|
|
72695
72711
|
return drifted;
|
|
72696
72712
|
}
|
|
72697
72713
|
function ensureAppTsconfig(projectDir) {
|
|
72698
|
-
const tsconfigPath =
|
|
72714
|
+
const tsconfigPath = path10.join(projectDir, "tsconfig.json");
|
|
72699
72715
|
if (!fs8.existsSync(tsconfigPath)) {
|
|
72700
72716
|
console.error(
|
|
72701
72717
|
`\u26A0 No tsconfig.json at ${projectDir} \u2014 could not ensure "include" has "${LOTICS_INCLUDE_GLOB}" (a bare .lotics loads none of the generated types) or "exclude" has ${WORKFLOW_TSCONFIG_EXCLUDES.join(", ")}.`
|
|
@@ -72747,15 +72763,15 @@ function writeDevLinkTsconfig(projectDir) {
|
|
|
72747
72763
|
if (uiSrc) {
|
|
72748
72764
|
paths["@lotics/ui/*"] = [`${uiSrc}/*`];
|
|
72749
72765
|
for (const peer of readKitPeerNames(projectDir)) {
|
|
72750
|
-
const typesDir =
|
|
72751
|
-
const runtimeDir =
|
|
72766
|
+
const typesDir = path10.join(projectDir, "node_modules", typesPackageFor(peer));
|
|
72767
|
+
const runtimeDir = path10.join(projectDir, "node_modules", peer);
|
|
72752
72768
|
const target = fs8.existsSync(typesDir) ? `../node_modules/${typesPackageFor(peer)}` : fs8.existsSync(runtimeDir) ? `../node_modules/${peer}` : null;
|
|
72753
72769
|
if (!target) continue;
|
|
72754
72770
|
paths[peer] = [target];
|
|
72755
72771
|
paths[`${peer}/*`] = [`${target}/*`];
|
|
72756
72772
|
}
|
|
72757
72773
|
}
|
|
72758
|
-
const file2 =
|
|
72774
|
+
const file2 = path10.join(projectDir, ".lotics", "tsconfig.link.json");
|
|
72759
72775
|
const header = uiSrc ? `// GENERATED by \`lotics app codegen\` \u2014 do not edit.
|
|
72760
72776
|
// LOTICS_UI_SRC is set, so @lotics/ui resolves to your working copy for tsc,
|
|
72761
72777
|
// vitest, eslint and your editor \u2014 the same copy Vite is bundling. The peer
|
|
@@ -72772,8 +72788,8 @@ function writeDevLinkTsconfig(projectDir) {
|
|
|
72772
72788
|
}
|
|
72773
72789
|
function writeKitTypeAugmentation(projectDir) {
|
|
72774
72790
|
const uiSrc = process.env.LOTICS_UI_SRC;
|
|
72775
|
-
const source = uiSrc ?
|
|
72776
|
-
const target =
|
|
72791
|
+
const source = uiSrc ? path10.join(uiSrc, "react_native.d.ts") : path10.join(projectDir, "node_modules", "@lotics", "ui", "src", "react_native.d.ts");
|
|
72792
|
+
const target = path10.join(projectDir, ".lotics", "react_native.d.ts");
|
|
72777
72793
|
if (!fs8.existsSync(source)) {
|
|
72778
72794
|
if (fs8.existsSync(target)) fs8.rmSync(target);
|
|
72779
72795
|
return;
|
|
@@ -72790,7 +72806,7 @@ function typesPackageFor(peer) {
|
|
|
72790
72806
|
return peer.startsWith("@") ? `@types/${peer.slice(1).replace("/", "__")}` : `@types/${peer}`;
|
|
72791
72807
|
}
|
|
72792
72808
|
function readKitPeerNames(projectDir) {
|
|
72793
|
-
const kitPkg =
|
|
72809
|
+
const kitPkg = path10.join(projectDir, "node_modules", "@lotics", "ui", "package.json");
|
|
72794
72810
|
if (!fs8.existsSync(kitPkg)) return [];
|
|
72795
72811
|
const parsed = JSON.parse(fs8.readFileSync(kitPkg, "utf-8"));
|
|
72796
72812
|
const peers = parsed.peerDependencies;
|
|
@@ -72801,12 +72817,12 @@ function writeAppDtsKitLinks(projectDir) {
|
|
|
72801
72817
|
writeKitTypeAugmentation(projectDir);
|
|
72802
72818
|
}
|
|
72803
72819
|
function writeAppDts(projectDir, manifest) {
|
|
72804
|
-
const dotLotics =
|
|
72820
|
+
const dotLotics = path10.join(projectDir, ".lotics");
|
|
72805
72821
|
fs8.mkdirSync(dotLotics, { recursive: true });
|
|
72806
72822
|
const written = [
|
|
72807
|
-
[
|
|
72808
|
-
[
|
|
72809
|
-
[
|
|
72823
|
+
[path10.join(dotLotics, "app_workflows.d.ts"), generateAppWorkflowsDts(manifest.workflows)],
|
|
72824
|
+
[path10.join(dotLotics, "app_queries.d.ts"), generateAppQueriesDts(manifest.queries)],
|
|
72825
|
+
[path10.join(dotLotics, "app_agents.d.ts"), generateAppAgentsDts(manifest.agents)]
|
|
72810
72826
|
];
|
|
72811
72827
|
for (const [file2, content] of written) fs8.writeFileSync(file2, content);
|
|
72812
72828
|
writeAppDtsKitLinks(projectDir);
|
|
@@ -72815,7 +72831,7 @@ function writeAppDts(projectDir, manifest) {
|
|
|
72815
72831
|
return written.map(([file2]) => file2);
|
|
72816
72832
|
}
|
|
72817
72833
|
function readCodegenTablesAllowlist(projectDir) {
|
|
72818
|
-
const pkg2 = JSON.parse(fs8.readFileSync(
|
|
72834
|
+
const pkg2 = JSON.parse(fs8.readFileSync(path10.join(projectDir, "package.json"), "utf-8"));
|
|
72819
72835
|
const tables = pkg2.lotics?.codegen?.tables;
|
|
72820
72836
|
return Array.isArray(tables) ? tables.filter((t) => typeof t === "string") : [];
|
|
72821
72837
|
}
|
|
@@ -72828,16 +72844,16 @@ function resolveCodegenTableIds(projectDir, queries) {
|
|
|
72828
72844
|
return [...ids];
|
|
72829
72845
|
}
|
|
72830
72846
|
function writeAppFields(projectDir, tables) {
|
|
72831
|
-
const dotLotics =
|
|
72847
|
+
const dotLotics = path10.join(projectDir, ".lotics");
|
|
72832
72848
|
fs8.mkdirSync(dotLotics, { recursive: true });
|
|
72833
|
-
const file2 =
|
|
72849
|
+
const file2 = path10.join(dotLotics, "app_fields.ts");
|
|
72834
72850
|
fs8.writeFileSync(file2, generateAppFields(tables));
|
|
72835
72851
|
return file2;
|
|
72836
72852
|
}
|
|
72837
72853
|
function writeBindingAppFields(projectDir, binding) {
|
|
72838
|
-
const dotLotics =
|
|
72854
|
+
const dotLotics = path10.join(projectDir, ".lotics");
|
|
72839
72855
|
fs8.mkdirSync(dotLotics, { recursive: true });
|
|
72840
|
-
const file2 =
|
|
72856
|
+
const file2 = path10.join(dotLotics, "app_fields.ts");
|
|
72841
72857
|
fs8.writeFileSync(file2, generatePackageAppFields(binding));
|
|
72842
72858
|
return file2;
|
|
72843
72859
|
}
|
|
@@ -72879,7 +72895,7 @@ async function writeGeneratedAppFields(client, projectDir, app, queries) {
|
|
|
72879
72895
|
}
|
|
72880
72896
|
function warnAppFieldsUnwritten(projectDir, err2) {
|
|
72881
72897
|
const reason = err2 instanceof Error ? err2.message : String(err2);
|
|
72882
|
-
if (fs8.existsSync(
|
|
72898
|
+
if (fs8.existsSync(path10.join(projectDir, ".lotics", "app_fields.ts"))) {
|
|
72883
72899
|
console.error(`\u26A0 Could not regenerate .lotics/app_fields.ts (${reason}). Kept the existing file.`);
|
|
72884
72900
|
return;
|
|
72885
72901
|
}
|
|
@@ -72890,7 +72906,7 @@ function warnAppFieldsUnwritten(projectDir, err2) {
|
|
|
72890
72906
|
function warnAboutDevLink(projectDir, command) {
|
|
72891
72907
|
const uiSrc = process.env.LOTICS_UI_SRC;
|
|
72892
72908
|
if (!uiSrc) return;
|
|
72893
|
-
const viteConfigPath =
|
|
72909
|
+
const viteConfigPath = path10.join(projectDir, "vite.config.ts");
|
|
72894
72910
|
const config2 = fs8.existsSync(viteConfigPath) ? fs8.readFileSync(viteConfigPath, "utf-8") : "";
|
|
72895
72911
|
const linked = config2.includes("loticsResolve") || config2.includes("LOTICS_UI_SRC");
|
|
72896
72912
|
if (!linked) {
|
|
@@ -72909,7 +72925,7 @@ function warnAboutDevLink(projectDir, command) {
|
|
|
72909
72925
|
}
|
|
72910
72926
|
}
|
|
72911
72927
|
function ensureAppVitestSetup(projectDir) {
|
|
72912
|
-
const setupPath =
|
|
72928
|
+
const setupPath = path10.join(projectDir, VITEST_SETUP_FILENAME);
|
|
72913
72929
|
if (!fs8.existsSync(setupPath)) {
|
|
72914
72930
|
fs8.writeFileSync(setupPath, VITEST_SETUP_CONTENT);
|
|
72915
72931
|
console.error(`Wrote ${VITEST_SETUP_FILENAME} (stubs getAppBinding so \`npm test\` collects).`);
|
|
@@ -72919,7 +72935,7 @@ function ensureAppVitestSetup(projectDir) {
|
|
|
72919
72935
|
${VITEST_SETUP_CONTENT}`
|
|
72920
72936
|
);
|
|
72921
72937
|
}
|
|
72922
|
-
const viteConfigPath =
|
|
72938
|
+
const viteConfigPath = path10.join(projectDir, "vite.config.ts");
|
|
72923
72939
|
if (!fs8.existsSync(viteConfigPath)) return;
|
|
72924
72940
|
const viteConfig = fs8.readFileSync(viteConfigPath, "utf-8");
|
|
72925
72941
|
if (/setupFiles\s*:/.test(viteConfig) && viteConfig.includes(VITEST_SETUP_FILENAME)) return;
|
|
@@ -72929,7 +72945,7 @@ ${VITEST_SETUP_CONTENT}`
|
|
|
72929
72945
|
);
|
|
72930
72946
|
}
|
|
72931
72947
|
async function appCodegen(args) {
|
|
72932
|
-
const projectDir =
|
|
72948
|
+
const projectDir = path10.resolve(args.projectDir ?? process.cwd());
|
|
72933
72949
|
const meta3 = readAppMeta(projectDir);
|
|
72934
72950
|
const dtsPaths = writeAppDts(projectDir, {
|
|
72935
72951
|
workflows: meta3.workflows,
|
|
@@ -72943,7 +72959,7 @@ async function appCodegen(args) {
|
|
|
72943
72959
|
}
|
|
72944
72960
|
for (const alias of orphanWorkflowBodies(projectDir, declared)) {
|
|
72945
72961
|
console.error(
|
|
72946
|
-
`\u26A0 ${
|
|
72962
|
+
`\u26A0 ${path10.join(WORKFLOWS_DIR, `${alias}.ts`)} is not declared in package.json#lotics.workflows \u2014 'workflow check' and 'workflow set' both skip it. Declare the alias or delete the file.`
|
|
72947
72963
|
);
|
|
72948
72964
|
}
|
|
72949
72965
|
if (!args.client) {
|
|
@@ -73002,7 +73018,7 @@ async function refreshWorkflowTypes(client, projectDir, app_id, alias, declarati
|
|
|
73002
73018
|
return true;
|
|
73003
73019
|
}
|
|
73004
73020
|
function readPriorStamp(projectDir) {
|
|
73005
|
-
const pkgPath2 =
|
|
73021
|
+
const pkgPath2 = path10.join(projectDir, "package.json");
|
|
73006
73022
|
if (!fs8.existsSync(pkgPath2)) return null;
|
|
73007
73023
|
let pkg2;
|
|
73008
73024
|
try {
|
|
@@ -73071,8 +73087,8 @@ function appDirName(name2) {
|
|
|
73071
73087
|
}
|
|
73072
73088
|
async function materializeScaffold(targetPath, files) {
|
|
73073
73089
|
for (const file2 of files) {
|
|
73074
|
-
const fullPath =
|
|
73075
|
-
fs8.mkdirSync(
|
|
73090
|
+
const fullPath = path10.join(targetPath, file2.path);
|
|
73091
|
+
fs8.mkdirSync(path10.dirname(fullPath), { recursive: true });
|
|
73076
73092
|
fs8.writeFileSync(fullPath, file2.content);
|
|
73077
73093
|
}
|
|
73078
73094
|
console.error(`Scaffolded ${files.length} files into ${targetPath}`);
|
|
@@ -73082,7 +73098,7 @@ async function materializeScaffold(targetPath, files) {
|
|
|
73082
73098
|
writeAppDtsKitLinks(targetPath);
|
|
73083
73099
|
}
|
|
73084
73100
|
async function appCreate(client, args) {
|
|
73085
|
-
const targetPath =
|
|
73101
|
+
const targetPath = path10.resolve(args.targetPath ?? appDirName(args.name));
|
|
73086
73102
|
if (fs8.existsSync(targetPath)) {
|
|
73087
73103
|
const entries2 = fs8.readdirSync(targetPath);
|
|
73088
73104
|
if (entries2.length > 0) {
|
|
@@ -73111,7 +73127,7 @@ async function appCreate(client, args) {
|
|
|
73111
73127
|
});
|
|
73112
73128
|
console.error(`
|
|
73113
73129
|
Ready. Next steps:`);
|
|
73114
|
-
console.error(` cd ${
|
|
73130
|
+
console.error(` cd ${path10.relative(process.cwd(), targetPath) || "."}`);
|
|
73115
73131
|
console.error(` lotics docs # the contracts, at the versions installed here`);
|
|
73116
73132
|
console.error(` # edit src/App.tsx, then:`);
|
|
73117
73133
|
console.error(` lotics app check # every pre-flight a deploy runs`);
|
|
@@ -73170,7 +73186,7 @@ async function appVersions(client, args) {
|
|
|
73170
73186
|
}
|
|
73171
73187
|
}
|
|
73172
73188
|
function defaultPullTarget(appId, appName) {
|
|
73173
|
-
const cwdPkgPath =
|
|
73189
|
+
const cwdPkgPath = path10.join(process.cwd(), "package.json");
|
|
73174
73190
|
if (fs8.existsSync(cwdPkgPath)) {
|
|
73175
73191
|
let pkg2 = null;
|
|
73176
73192
|
try {
|
|
@@ -73195,21 +73211,21 @@ async function appPull(client, args) {
|
|
|
73195
73211
|
if (!versionId) throw new Error(`App ${app.id} has no version to pull.`);
|
|
73196
73212
|
const version2 = await client.getAppVersion(app.id, versionId);
|
|
73197
73213
|
const sourceUrl = await client.getAppVersionSourceUrl(app.id, version2.id);
|
|
73198
|
-
const targetPath =
|
|
73214
|
+
const targetPath = path10.resolve(args.targetPath ?? defaultPullTarget(app.id, app.name));
|
|
73199
73215
|
fs8.mkdirSync(targetPath, { recursive: true });
|
|
73200
73216
|
const prior = readPriorStamp(targetPath);
|
|
73201
|
-
const tmpFile =
|
|
73217
|
+
const tmpFile = path10.join(tmpdir(), `lotics-app-${app.id}-${Date.now()}.tar.gz`);
|
|
73202
73218
|
console.error(`Downloading source archive...`);
|
|
73203
73219
|
await downloadToFile(sourceUrl, tmpFile);
|
|
73204
73220
|
const keptLocal = [];
|
|
73205
|
-
const stagingDir = fs8.mkdtempSync(
|
|
73221
|
+
const stagingDir = fs8.mkdtempSync(path10.join(tmpdir(), `lotics-pull-${app.id}-`));
|
|
73206
73222
|
try {
|
|
73207
73223
|
await runTar(["-xzf", tmpFile, "-C", stagingDir], stagingDir);
|
|
73208
73224
|
console.error(`Extracting to ${targetPath}...`);
|
|
73209
73225
|
keptLocal.push(
|
|
73210
73226
|
...copyTree(stagingDir, targetPath, {
|
|
73211
73227
|
overwrite: args.force === true,
|
|
73212
|
-
skip: [WORKFLOWS_DIR, AGENTS_DIR].map((d) => d.split(
|
|
73228
|
+
skip: [WORKFLOWS_DIR, AGENTS_DIR].map((d) => d.split(path10.sep).join("/"))
|
|
73213
73229
|
})
|
|
73214
73230
|
);
|
|
73215
73231
|
} finally {
|
|
@@ -73287,20 +73303,20 @@ async function appPull(client, args) {
|
|
|
73287
73303
|
});
|
|
73288
73304
|
console.error(`
|
|
73289
73305
|
Ready. Next steps:`);
|
|
73290
|
-
console.error(` cd ${
|
|
73306
|
+
console.error(` cd ${path10.relative(process.cwd(), targetPath) || "."}`);
|
|
73291
73307
|
console.error(` lotics docs # the contracts, at the versions installed here`);
|
|
73292
73308
|
console.error(` # edit src/App.tsx, then:`);
|
|
73293
73309
|
console.error(` lotics app deploy`);
|
|
73294
73310
|
}
|
|
73295
73311
|
function readAppSourceText(projectDir) {
|
|
73296
|
-
const srcDir =
|
|
73312
|
+
const srcDir = path10.join(projectDir, "src");
|
|
73297
73313
|
if (!fs8.existsSync(srcDir)) return "";
|
|
73298
73314
|
const parts = [];
|
|
73299
73315
|
const walk2 = (dir) => {
|
|
73300
73316
|
for (const entry of fs8.readdirSync(dir, { withFileTypes: true })) {
|
|
73301
|
-
const full =
|
|
73317
|
+
const full = path10.join(dir, entry.name);
|
|
73302
73318
|
if (entry.isDirectory()) walk2(full);
|
|
73303
|
-
else if (isAppSourcePath(
|
|
73319
|
+
else if (isAppSourcePath(path10.relative(projectDir, full))) {
|
|
73304
73320
|
parts.push(fs8.readFileSync(full, "utf8"));
|
|
73305
73321
|
}
|
|
73306
73322
|
}
|
|
@@ -73309,7 +73325,7 @@ function readAppSourceText(projectDir) {
|
|
|
73309
73325
|
return parts.join("\n");
|
|
73310
73326
|
}
|
|
73311
73327
|
async function appDeploy(client, args) {
|
|
73312
|
-
const projectDir =
|
|
73328
|
+
const projectDir = path10.resolve(args.projectDir ?? process.cwd());
|
|
73313
73329
|
const meta3 = readAppMeta(projectDir);
|
|
73314
73330
|
warnAboutDevLink(projectDir, "deploy");
|
|
73315
73331
|
const liveApp = await client.getApp(meta3.app_id);
|
|
@@ -73344,14 +73360,14 @@ async function appDeploy(client, args) {
|
|
|
73344
73360
|
}
|
|
73345
73361
|
console.error("Building...");
|
|
73346
73362
|
await runNpm(["run", "build"], projectDir);
|
|
73347
|
-
const distDir =
|
|
73363
|
+
const distDir = path10.join(projectDir, "dist");
|
|
73348
73364
|
if (!fs8.existsSync(distDir)) {
|
|
73349
73365
|
throw new Error(
|
|
73350
73366
|
`Build did not produce a dist/ directory in ${projectDir}. Check that 'npm run build' is configured correctly (Vite/etc. defaults to dist/).`
|
|
73351
73367
|
);
|
|
73352
73368
|
}
|
|
73353
|
-
const tmpSource =
|
|
73354
|
-
const tmpDist =
|
|
73369
|
+
const tmpSource = path10.join(tmpdir(), `lotics-source-${Date.now()}.tar.gz`);
|
|
73370
|
+
const tmpDist = path10.join(tmpdir(), `lotics-dist-${Date.now()}.tar.gz`);
|
|
73355
73371
|
try {
|
|
73356
73372
|
console.error("Packaging source...");
|
|
73357
73373
|
await runTar(
|
|
@@ -73524,7 +73540,7 @@ function reportKnowledgeWarnings(warnings) {
|
|
|
73524
73540
|
);
|
|
73525
73541
|
}
|
|
73526
73542
|
async function upgradeCommand(client, args) {
|
|
73527
|
-
const projectDir =
|
|
73543
|
+
const projectDir = path10.resolve(args.projectDir ?? process.cwd());
|
|
73528
73544
|
const meta3 = readAppMeta(projectDir);
|
|
73529
73545
|
const plan = await client.previewPackageUpgrade(meta3.app_id, {});
|
|
73530
73546
|
if (plan.from_version === plan.to_version) {
|
|
@@ -73568,7 +73584,7 @@ async function upgradeCommand(client, args) {
|
|
|
73568
73584
|
);
|
|
73569
73585
|
}
|
|
73570
73586
|
async function appCheck(client, args = {}) {
|
|
73571
|
-
const projectDir =
|
|
73587
|
+
const projectDir = path10.resolve(args.projectDir ?? process.cwd());
|
|
73572
73588
|
const meta3 = readAppMeta(projectDir);
|
|
73573
73589
|
const app = await client.getApp(meta3.app_id);
|
|
73574
73590
|
assertProjectIsCurrent(meta3, app);
|
|
@@ -73794,10 +73810,10 @@ function derivedDeployMessage(pending) {
|
|
|
73794
73810
|
function copyTree(from, to, opts, relative = "") {
|
|
73795
73811
|
const kept = [];
|
|
73796
73812
|
for (const entry of fs8.readdirSync(from, { withFileTypes: true })) {
|
|
73797
|
-
const src =
|
|
73798
|
-
const dest =
|
|
73799
|
-
const rel =
|
|
73800
|
-
if (opts.skip?.includes(rel.split(
|
|
73813
|
+
const src = path10.join(from, entry.name);
|
|
73814
|
+
const dest = path10.join(to, entry.name);
|
|
73815
|
+
const rel = path10.join(relative, entry.name);
|
|
73816
|
+
if (opts.skip?.includes(rel.split(path10.sep).join("/"))) continue;
|
|
73801
73817
|
if (entry.isDirectory()) {
|
|
73802
73818
|
fs8.mkdirSync(dest, { recursive: true });
|
|
73803
73819
|
kept.push(...copyTree(src, dest, opts, rel));
|
|
@@ -73934,7 +73950,7 @@ function defineBlockKeys(config2) {
|
|
|
73934
73950
|
}
|
|
73935
73951
|
var REALTIME_SDK_FLOOR = "0.80.0";
|
|
73936
73952
|
function installedAppSdkVersion(projectDir) {
|
|
73937
|
-
const manifest =
|
|
73953
|
+
const manifest = path10.join(projectDir, "node_modules", "@lotics", "app-sdk", "package.json");
|
|
73938
73954
|
if (!fs8.existsSync(manifest)) return null;
|
|
73939
73955
|
const version2 = JSON.parse(fs8.readFileSync(manifest, "utf-8")).version;
|
|
73940
73956
|
return typeof version2 === "string" ? version2 : null;
|
|
@@ -73961,9 +73977,9 @@ function warnIfProjectFootguns(projectDir, sourceText) {
|
|
|
73961
73977
|
].join("\n")
|
|
73962
73978
|
);
|
|
73963
73979
|
}
|
|
73964
|
-
const configName = VITE_CONFIG_NAMES.find((name2) => fs8.existsSync(
|
|
73980
|
+
const configName = VITE_CONFIG_NAMES.find((name2) => fs8.existsSync(path10.join(projectDir, name2)));
|
|
73965
73981
|
if (configName !== void 0) {
|
|
73966
|
-
const config2 = fs8.readFileSync(
|
|
73982
|
+
const config2 = fs8.readFileSync(path10.join(projectDir, configName), "utf-8");
|
|
73967
73983
|
const defined = defineBlockKeys(config2);
|
|
73968
73984
|
const missing = ["global", "__DEV__"].filter((name2) => !defined.has(name2));
|
|
73969
73985
|
if (missing.length > 0) {
|
|
@@ -74059,7 +74075,7 @@ function warnIfUnboundAliases(app, called) {
|
|
|
74059
74075
|
console.error(lines.join("\n"));
|
|
74060
74076
|
}
|
|
74061
74077
|
async function appDev(client, args) {
|
|
74062
|
-
const projectDir =
|
|
74078
|
+
const projectDir = path10.resolve(args.projectDir ?? process.cwd());
|
|
74063
74079
|
const meta3 = readAppMeta(projectDir);
|
|
74064
74080
|
warnAboutDevLink(projectDir, "dev");
|
|
74065
74081
|
writeAppDts(projectDir, { workflows: meta3.workflows, queries: meta3.queries, agents: meta3.agents });
|
|
@@ -74193,7 +74209,7 @@ async function appAgentSet(client, args) {
|
|
|
74193
74209
|
}
|
|
74194
74210
|
if (!hasDeclaration) {
|
|
74195
74211
|
console.error(
|
|
74196
|
-
`No instructions at ${
|
|
74212
|
+
`No instructions at ${path10.relative(projectDir, file2)}, and nothing declared in package.json#lotics.agents.${args.alias} to push instead.
|
|
74197
74213
|
Run 'lotics app pull ${meta3.app_id}' to write ${AGENTS_DIR}/${args.alias}.md, then edit it.`
|
|
74198
74214
|
);
|
|
74199
74215
|
process.exit(1);
|
|
@@ -74202,7 +74218,7 @@ async function appAgentSet(client, args) {
|
|
|
74202
74218
|
const instructions = hasProse ? stripAgentHeader(fs8.readFileSync(file2, "utf-8")) : void 0;
|
|
74203
74219
|
if (instructions === "") {
|
|
74204
74220
|
console.error(
|
|
74205
|
-
`${
|
|
74221
|
+
`${path10.relative(projectDir, file2)} is empty after stripping the header \u2014 refusing to push an empty prompt.`
|
|
74206
74222
|
);
|
|
74207
74223
|
process.exit(1);
|
|
74208
74224
|
}
|
|
@@ -74269,7 +74285,7 @@ async function appWorkflowSet(client, args) {
|
|
|
74269
74285
|
const file2 = workflowFilePath(projectDir, args.alias);
|
|
74270
74286
|
if (!fs8.existsSync(file2)) {
|
|
74271
74287
|
console.error(
|
|
74272
|
-
`No workflow body at ${
|
|
74288
|
+
`No workflow body at ${path10.relative(projectDir, file2)}.
|
|
74273
74289
|
If "${args.alias}" is already bound: lotics app pull ${meta3.app_id} (writes the body)
|
|
74274
74290
|
If it is a NEW alias you declared: create that file yourself, then re-run this.`
|
|
74275
74291
|
);
|
|
@@ -74278,7 +74294,7 @@ async function appWorkflowSet(client, args) {
|
|
|
74278
74294
|
noteScope({ alias: args.alias });
|
|
74279
74295
|
const source = stripWorkflowHeader(fs8.readFileSync(file2, "utf-8"));
|
|
74280
74296
|
if (source.trim() === "") {
|
|
74281
|
-
console.error(`Workflow body ${
|
|
74297
|
+
console.error(`Workflow body ${path10.relative(projectDir, file2)} is empty after stripping the header.`);
|
|
74282
74298
|
process.exit(1);
|
|
74283
74299
|
}
|
|
74284
74300
|
const res = await client.setAppWorkflow(meta3.app_id, args.alias, {
|
|
@@ -74413,13 +74429,13 @@ async function appWorkflowCheck(args) {
|
|
|
74413
74429
|
const globalsPath = workflowGlobalsPath(projectDir, alias);
|
|
74414
74430
|
if (!fs8.existsSync(bodyPath)) {
|
|
74415
74431
|
console.error(
|
|
74416
|
-
`\u26A0 Skipped "${alias}" \u2014 no body at ${
|
|
74432
|
+
`\u26A0 Skipped "${alias}" \u2014 no body at ${path10.relative(projectDir, bodyPath)}. Run 'lotics app workflow pull' to write it.`
|
|
74417
74433
|
);
|
|
74418
74434
|
continue;
|
|
74419
74435
|
}
|
|
74420
74436
|
if (!fs8.existsSync(globalsPath)) {
|
|
74421
74437
|
console.error(
|
|
74422
|
-
`Cannot check "${alias}" \u2014 missing types at ${
|
|
74438
|
+
`Cannot check "${alias}" \u2014 missing types at ${path10.relative(projectDir, globalsPath)}. Run 'lotics app codegen' to fetch them (it refreshes types WITHOUT touching your body; a pull would overwrite it).`
|
|
74423
74439
|
);
|
|
74424
74440
|
process.exit(1);
|
|
74425
74441
|
}
|
|
@@ -74455,7 +74471,7 @@ async function appWorkflowCheck(args) {
|
|
|
74455
74471
|
function printWorkflowCheckResults(projectDir, results) {
|
|
74456
74472
|
let totalErrors = 0;
|
|
74457
74473
|
for (const r of results) {
|
|
74458
|
-
const rel =
|
|
74474
|
+
const rel = path10.relative(projectDir, r.bodyPath);
|
|
74459
74475
|
if (r.issues.length === 0) {
|
|
74460
74476
|
console.error(`\u2713 ${r.alias} (${rel}) \u2014 clean`);
|
|
74461
74477
|
continue;
|
|
@@ -74727,7 +74743,7 @@ import fs10 from "node:fs";
|
|
|
74727
74743
|
|
|
74728
74744
|
// src/file_command_io.ts
|
|
74729
74745
|
import fs9 from "node:fs";
|
|
74730
|
-
import
|
|
74746
|
+
import path11 from "node:path";
|
|
74731
74747
|
var CliError = class extends Error {
|
|
74732
74748
|
constructor(message2) {
|
|
74733
74749
|
super(message2);
|
|
@@ -74748,8 +74764,8 @@ function rejectExtraArgs(rest2, arity, usage) {
|
|
|
74748
74764
|
fail2(`${usage} takes ${arity} argument${arity === 1 ? "" : "s"} after <file>, got ${rest2.length}. Unused: ${rest2.slice(arity).join(" ")}`);
|
|
74749
74765
|
}
|
|
74750
74766
|
function writeFileAtomic(filePath, bytes) {
|
|
74751
|
-
const dir =
|
|
74752
|
-
const tmp =
|
|
74767
|
+
const dir = path11.dirname(path11.resolve(filePath));
|
|
74768
|
+
const tmp = path11.join(dir, `.${path11.basename(filePath)}.${process.pid}.${Date.now()}.tmp`);
|
|
74753
74769
|
fs9.writeFileSync(tmp, bytes);
|
|
74754
74770
|
try {
|
|
74755
74771
|
fs9.renameSync(tmp, filePath);
|
|
@@ -77552,16 +77568,16 @@ var MatcherView = class {
|
|
|
77552
77568
|
* @returns {string|undefined}
|
|
77553
77569
|
*/
|
|
77554
77570
|
getCurrentTag() {
|
|
77555
|
-
const
|
|
77556
|
-
return
|
|
77571
|
+
const path13 = this._matcher.path;
|
|
77572
|
+
return path13.length > 0 ? path13[path13.length - 1].tag : void 0;
|
|
77557
77573
|
}
|
|
77558
77574
|
/**
|
|
77559
77575
|
* Get current namespace.
|
|
77560
77576
|
* @returns {string|undefined}
|
|
77561
77577
|
*/
|
|
77562
77578
|
getCurrentNamespace() {
|
|
77563
|
-
const
|
|
77564
|
-
return
|
|
77579
|
+
const path13 = this._matcher.path;
|
|
77580
|
+
return path13.length > 0 ? path13[path13.length - 1].namespace : void 0;
|
|
77565
77581
|
}
|
|
77566
77582
|
/**
|
|
77567
77583
|
* Get current node's attribute value.
|
|
@@ -77569,9 +77585,9 @@ var MatcherView = class {
|
|
|
77569
77585
|
* @returns {*}
|
|
77570
77586
|
*/
|
|
77571
77587
|
getAttrValue(attrName) {
|
|
77572
|
-
const
|
|
77573
|
-
if (
|
|
77574
|
-
return
|
|
77588
|
+
const path13 = this._matcher.path;
|
|
77589
|
+
if (path13.length === 0) return void 0;
|
|
77590
|
+
return path13[path13.length - 1].values?.[attrName];
|
|
77575
77591
|
}
|
|
77576
77592
|
/**
|
|
77577
77593
|
* Check if current node has an attribute.
|
|
@@ -77579,9 +77595,9 @@ var MatcherView = class {
|
|
|
77579
77595
|
* @returns {boolean}
|
|
77580
77596
|
*/
|
|
77581
77597
|
hasAttr(attrName) {
|
|
77582
|
-
const
|
|
77583
|
-
if (
|
|
77584
|
-
const current =
|
|
77598
|
+
const path13 = this._matcher.path;
|
|
77599
|
+
if (path13.length === 0) return false;
|
|
77600
|
+
const current = path13[path13.length - 1];
|
|
77585
77601
|
return current.values !== void 0 && attrName in current.values;
|
|
77586
77602
|
}
|
|
77587
77603
|
/**
|
|
@@ -77607,18 +77623,18 @@ var MatcherView = class {
|
|
|
77607
77623
|
* @returns {number}
|
|
77608
77624
|
*/
|
|
77609
77625
|
getPosition() {
|
|
77610
|
-
const
|
|
77611
|
-
if (
|
|
77612
|
-
return
|
|
77626
|
+
const path13 = this._matcher.path;
|
|
77627
|
+
if (path13.length === 0) return -1;
|
|
77628
|
+
return path13[path13.length - 1].position ?? 0;
|
|
77613
77629
|
}
|
|
77614
77630
|
/**
|
|
77615
77631
|
* Get current node's repeat counter (occurrence count of this tag name).
|
|
77616
77632
|
* @returns {number}
|
|
77617
77633
|
*/
|
|
77618
77634
|
getCounter() {
|
|
77619
|
-
const
|
|
77620
|
-
if (
|
|
77621
|
-
return
|
|
77635
|
+
const path13 = this._matcher.path;
|
|
77636
|
+
if (path13.length === 0) return -1;
|
|
77637
|
+
return path13[path13.length - 1].counter ?? 0;
|
|
77622
77638
|
}
|
|
77623
77639
|
/**
|
|
77624
77640
|
* Get current node's sibling index (alias for getPosition).
|
|
@@ -83276,10 +83292,10 @@ function resolveRelativePath(basePath, relativePath) {
|
|
|
83276
83292
|
}
|
|
83277
83293
|
return resolved.join("/");
|
|
83278
83294
|
}
|
|
83279
|
-
function findZipEntry(zipEntries,
|
|
83280
|
-
if (zipEntries[
|
|
83281
|
-
if (zipEntries[`xl/${
|
|
83282
|
-
const noSlash =
|
|
83295
|
+
function findZipEntry(zipEntries, path13) {
|
|
83296
|
+
if (zipEntries[path13]) return zipEntries[path13];
|
|
83297
|
+
if (zipEntries[`xl/${path13}`]) return zipEntries[`xl/${path13}`];
|
|
83298
|
+
const noSlash = path13.replace(/^\//, "");
|
|
83283
83299
|
if (zipEntries[noSlash]) return zipEntries[noSlash];
|
|
83284
83300
|
return void 0;
|
|
83285
83301
|
}
|
|
@@ -84911,9 +84927,9 @@ function parseExcelFromZip(zip, options) {
|
|
|
84911
84927
|
}
|
|
84912
84928
|
return result;
|
|
84913
84929
|
}
|
|
84914
|
-
function findEntry(zip,
|
|
84915
|
-
if (zip[
|
|
84916
|
-
const lower2 =
|
|
84930
|
+
function findEntry(zip, path13) {
|
|
84931
|
+
if (zip[path13]) return zip[path13];
|
|
84932
|
+
const lower2 = path13.toLowerCase();
|
|
84917
84933
|
for (const key of Object.keys(zip)) {
|
|
84918
84934
|
if (key.toLowerCase() === lower2) return zip[key];
|
|
84919
84935
|
}
|
|
@@ -85550,12 +85566,12 @@ function extractPivotRoundTripInfo(originalZip) {
|
|
|
85550
85566
|
if (paths.length > 0) pivotTablesBySheetIndex.set(i2, paths);
|
|
85551
85567
|
}
|
|
85552
85568
|
const pivotXmlPaths = [];
|
|
85553
|
-
for (const
|
|
85554
|
-
if (
|
|
85555
|
-
pivotXmlPaths.push(
|
|
85569
|
+
for (const path13 of Object.keys(originalZip)) {
|
|
85570
|
+
if (path13.startsWith("xl/pivotTables/") && path13.endsWith(".xml")) {
|
|
85571
|
+
pivotXmlPaths.push(path13);
|
|
85556
85572
|
}
|
|
85557
|
-
if (
|
|
85558
|
-
pivotXmlPaths.push(
|
|
85573
|
+
if (path13.startsWith("xl/pivotCache/") && path13.endsWith(".xml")) {
|
|
85574
|
+
pivotXmlPaths.push(path13);
|
|
85559
85575
|
}
|
|
85560
85576
|
}
|
|
85561
85577
|
return { cachesByWorkbook, pivotTablesBySheetIndex, pivotXmlPaths };
|
|
@@ -85563,15 +85579,15 @@ function extractPivotRoundTripInfo(originalZip) {
|
|
|
85563
85579
|
function decode3(bytes) {
|
|
85564
85580
|
return new TextDecoder().decode(bytes);
|
|
85565
85581
|
}
|
|
85566
|
-
function pivotContentTypeFor(
|
|
85567
|
-
if (
|
|
85568
|
-
return `<Override PartName="/${
|
|
85582
|
+
function pivotContentTypeFor(path13) {
|
|
85583
|
+
if (path13.startsWith("xl/pivotTables/") && path13.endsWith(".xml")) {
|
|
85584
|
+
return `<Override PartName="/${path13}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"/>`;
|
|
85569
85585
|
}
|
|
85570
|
-
if (
|
|
85571
|
-
return `<Override PartName="/${
|
|
85586
|
+
if (path13.includes("/pivotCacheDefinition") && path13.endsWith(".xml")) {
|
|
85587
|
+
return `<Override PartName="/${path13}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"/>`;
|
|
85572
85588
|
}
|
|
85573
|
-
if (
|
|
85574
|
-
return `<Override PartName="/${
|
|
85589
|
+
if (path13.includes("/pivotCacheRecords") && path13.endsWith(".xml")) {
|
|
85590
|
+
return `<Override PartName="/${path13}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"/>`;
|
|
85575
85591
|
}
|
|
85576
85592
|
return void 0;
|
|
85577
85593
|
}
|
|
@@ -85644,16 +85660,16 @@ function exportWorkbook(workbook, originalZip) {
|
|
|
85644
85660
|
regeneratedPaths.add(`xl/worksheets/sheet${i2 + 1}.xml`);
|
|
85645
85661
|
regeneratedPaths.add(`xl/worksheets/_rels/sheet${i2 + 1}.xml.rels`);
|
|
85646
85662
|
}
|
|
85647
|
-
for (const
|
|
85648
|
-
if (
|
|
85649
|
-
regeneratedPaths.add(
|
|
85663
|
+
for (const path13 of Object.keys(originalZip)) {
|
|
85664
|
+
if (path13.startsWith("xl/drawings/") || path13.startsWith("xl/charts/") || path13.startsWith("xl/tables/") || path13.startsWith("xl/media/")) {
|
|
85665
|
+
regeneratedPaths.add(path13);
|
|
85650
85666
|
}
|
|
85651
85667
|
}
|
|
85652
|
-
for (const [
|
|
85653
|
-
if (regeneratedPaths.has(
|
|
85654
|
-
const ext =
|
|
85668
|
+
for (const [path13, data2] of Object.entries(originalZip)) {
|
|
85669
|
+
if (regeneratedPaths.has(path13)) continue;
|
|
85670
|
+
const ext = path13.slice(path13.lastIndexOf(".") + 1).toLowerCase();
|
|
85655
85671
|
if (!DECLARED_EXTENSIONS.includes(ext)) continue;
|
|
85656
|
-
entries2[
|
|
85672
|
+
entries2[path13] = data2;
|
|
85657
85673
|
}
|
|
85658
85674
|
}
|
|
85659
85675
|
const sharedStrings = buildSharedStrings(workbook);
|
|
@@ -85669,8 +85685,8 @@ function exportWorkbook(workbook, originalZip) {
|
|
|
85669
85685
|
buildWorkbookRels(workbook, pivotInfo)
|
|
85670
85686
|
);
|
|
85671
85687
|
const extraContentTypes = [];
|
|
85672
|
-
for (const
|
|
85673
|
-
const ct = pivotContentTypeFor(
|
|
85688
|
+
for (const path13 of pivotInfo.pivotXmlPaths) {
|
|
85689
|
+
const ct = pivotContentTypeFor(path13);
|
|
85674
85690
|
if (ct) extraContentTypes.push(ct);
|
|
85675
85691
|
}
|
|
85676
85692
|
let globalChartIndex = 1;
|
|
@@ -94856,14 +94872,14 @@ var DependencyGraph = class {
|
|
|
94856
94872
|
stack.push({ cell: p, path: [cell, p] });
|
|
94857
94873
|
}
|
|
94858
94874
|
while (stack.length > 0) {
|
|
94859
|
-
const { cell: current, path:
|
|
94860
|
-
if (current === cell || originCoarse.has(current)) return
|
|
94875
|
+
const { cell: current, path: path13 } = stack.pop();
|
|
94876
|
+
if (current === cell || originCoarse.has(current)) return path13;
|
|
94861
94877
|
if (visited.has(current)) continue;
|
|
94862
94878
|
visited.add(current);
|
|
94863
94879
|
const nextPrec = this.precedents.get(current);
|
|
94864
94880
|
if (!nextPrec) continue;
|
|
94865
94881
|
for (const p of nextPrec) {
|
|
94866
|
-
stack.push({ cell: p, path: [...
|
|
94882
|
+
stack.push({ cell: p, path: [...path13, p] });
|
|
94867
94883
|
}
|
|
94868
94884
|
}
|
|
94869
94885
|
return null;
|
|
@@ -101702,8 +101718,8 @@ async function docModelToDocx(model) {
|
|
|
101702
101718
|
// ../ooxml/src/opc.ts
|
|
101703
101719
|
var import_jszip = __toESM(require_lib4(), 1);
|
|
101704
101720
|
function dropFolderEntries(zip) {
|
|
101705
|
-
for (const [
|
|
101706
|
-
if (entry.dir) delete zip.files[
|
|
101721
|
+
for (const [path13, entry] of Object.entries(zip.files)) {
|
|
101722
|
+
if (entry.dir) delete zip.files[path13];
|
|
101707
101723
|
}
|
|
101708
101724
|
}
|
|
101709
101725
|
|
|
@@ -101958,11 +101974,11 @@ async function parseDocx(buffer) {
|
|
|
101958
101974
|
const zip = await import_jszip3.default.loadAsync(buffer);
|
|
101959
101975
|
const parts = /* @__PURE__ */ new Map();
|
|
101960
101976
|
const filePromises = [];
|
|
101961
|
-
zip.forEach((
|
|
101977
|
+
zip.forEach((path13, file2) => {
|
|
101962
101978
|
if (file2.dir) return;
|
|
101963
101979
|
filePromises.push(
|
|
101964
101980
|
file2.async("uint8array").then((bytes) => {
|
|
101965
|
-
parts.set(
|
|
101981
|
+
parts.set(path13, bytes);
|
|
101966
101982
|
})
|
|
101967
101983
|
);
|
|
101968
101984
|
});
|
|
@@ -102194,9 +102210,9 @@ var DEFAULT_PARTS = [
|
|
|
102194
102210
|
["word/theme/theme1.xml", () => encoder.encode(THEME_XML)]
|
|
102195
102211
|
];
|
|
102196
102212
|
function fillDefaultParts(parts) {
|
|
102197
|
-
for (const [
|
|
102198
|
-
if (!parts.has(
|
|
102199
|
-
parts.set(
|
|
102213
|
+
for (const [path13, makeBytes] of DEFAULT_PARTS) {
|
|
102214
|
+
if (!parts.has(path13)) {
|
|
102215
|
+
parts.set(path13, makeBytes());
|
|
102200
102216
|
}
|
|
102201
102217
|
}
|
|
102202
102218
|
return parts;
|
|
@@ -102206,9 +102222,9 @@ function fillDefaultParts(parts) {
|
|
|
102206
102222
|
async function serializeDocx(doc) {
|
|
102207
102223
|
const zip = new import_jszip4.default();
|
|
102208
102224
|
const parts = fillDefaultParts(new Map(doc.parts));
|
|
102209
|
-
for (const [
|
|
102210
|
-
if (
|
|
102211
|
-
zip.file(
|
|
102225
|
+
for (const [path13, bytes] of parts) {
|
|
102226
|
+
if (path13 === "word/document.xml") continue;
|
|
102227
|
+
zip.file(path13, bytes);
|
|
102212
102228
|
}
|
|
102213
102229
|
const documentXml = serializeDocumentXml(doc);
|
|
102214
102230
|
zip.file("word/document.xml", documentXml);
|
|
@@ -102999,7 +103015,7 @@ async function runKnowledgeCommand(client, subcommand, toolArgs, flags, restArgs
|
|
|
102999
103015
|
// src/preview.ts
|
|
103000
103016
|
import { spawn as spawn3 } from "node:child_process";
|
|
103001
103017
|
import { createServer } from "node:http";
|
|
103002
|
-
import { readFileSync as readFileSync2, writeFileSync, existsSync, mkdtempSync, rmSync, readdirSync } from "node:fs";
|
|
103018
|
+
import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync2, mkdtempSync, rmSync, readdirSync } from "node:fs";
|
|
103003
103019
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
103004
103020
|
import { join as join2, dirname, resolve, extname, basename } from "node:path";
|
|
103005
103021
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -103011,16 +103027,16 @@ function fail3(msg) {
|
|
|
103011
103027
|
}
|
|
103012
103028
|
function findChrome() {
|
|
103013
103029
|
const env = process.env.LOTICS_CHROME || process.env.CHROME_PATH;
|
|
103014
|
-
if (env &&
|
|
103030
|
+
if (env && existsSync2(env)) return env;
|
|
103015
103031
|
const home = process.env.HOME || "";
|
|
103016
103032
|
const pwDir = process.platform === "darwin" ? `${home}/Library/Caches/ms-playwright` : `${home}/.cache/ms-playwright`;
|
|
103017
|
-
if (
|
|
103033
|
+
if (existsSync2(pwDir)) {
|
|
103018
103034
|
const rel = process.platform === "darwin" ? ["chrome-mac/Chromium.app/Contents/MacOS/Chromium"] : ["chrome-linux/chrome", "chrome-linux/headless_shell"];
|
|
103019
103035
|
const revs = readdirSync(pwDir).filter((n) => n.startsWith("chromium-") || n.startsWith("chromium_headless_shell-")).sort().reverse();
|
|
103020
103036
|
for (const rev2 of revs) {
|
|
103021
103037
|
for (const r of rel) {
|
|
103022
103038
|
const bin = join2(pwDir, rev2, r);
|
|
103023
|
-
if (
|
|
103039
|
+
if (existsSync2(bin)) return bin;
|
|
103024
103040
|
}
|
|
103025
103041
|
}
|
|
103026
103042
|
}
|
|
@@ -103032,7 +103048,7 @@ function findChrome() {
|
|
|
103032
103048
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
103033
103049
|
"/Applications/Chromium.app/Contents/MacOS/Chromium"
|
|
103034
103050
|
];
|
|
103035
|
-
return systemPaths.find((p) =>
|
|
103051
|
+
return systemPaths.find((p) => existsSync2(p)) ?? null;
|
|
103036
103052
|
}
|
|
103037
103053
|
async function cdpConnect(wsUrl) {
|
|
103038
103054
|
const ws = new WebSocket(wsUrl);
|
|
@@ -103070,7 +103086,7 @@ function defaultPreviewOutputPath(filename, cwd) {
|
|
|
103070
103086
|
async function runPreviewCommand(filePath, flags) {
|
|
103071
103087
|
if (!filePath) fail3("Usage: lotics preview <file.docx|.xlsx | fil_id> [-o <file.png>]");
|
|
103072
103088
|
const abs2 = resolve(filePath);
|
|
103073
|
-
if (!
|
|
103089
|
+
if (!existsSync2(abs2)) fail3(`File not found: ${abs2}`);
|
|
103074
103090
|
const ext = extname(abs2).toLowerCase();
|
|
103075
103091
|
const type = ext === ".docx" ? "docx" : ext === ".xlsx" || ext === ".xls" || ext === ".csv" ? "xlsx" : null;
|
|
103076
103092
|
if (!type) fail3(`Unsupported file type "${ext}" \u2014 preview supports .docx and .xlsx/.csv. (PDFs open directly \u2014 no preview needed.)`);
|
|
@@ -103078,7 +103094,7 @@ async function runPreviewCommand(filePath, flags) {
|
|
|
103078
103094
|
fail3("lotics preview needs Node 22+ (it drives Chrome over CDP via the built-in WebSocket). Upgrade Node and retry.");
|
|
103079
103095
|
}
|
|
103080
103096
|
const bundlePath = join2(HERE, "..", "render_page.js");
|
|
103081
|
-
if (!
|
|
103097
|
+
if (!existsSync2(bundlePath)) fail3(`Render bundle missing at ${bundlePath} \u2014 reinstall @lotics/cli (build step failed).`);
|
|
103082
103098
|
const chrome = findChrome();
|
|
103083
103099
|
if (!chrome) {
|
|
103084
103100
|
fail3(
|
|
@@ -103131,7 +103147,7 @@ async function runPreviewCommand(filePath, flags) {
|
|
|
103131
103147
|
let cdpPort = 0;
|
|
103132
103148
|
const portFile = join2(udd, "DevToolsActivePort");
|
|
103133
103149
|
for (let i2 = 0; i2 < 100 && !cdpPort; i2++) {
|
|
103134
|
-
if (
|
|
103150
|
+
if (existsSync2(portFile)) {
|
|
103135
103151
|
const p = parseInt(readFileSync2(portFile, "utf8").split("\n")[0], 10);
|
|
103136
103152
|
if (p) cdpPort = p;
|
|
103137
103153
|
}
|
|
@@ -103339,8 +103355,8 @@ function prompt(question) {
|
|
|
103339
103355
|
});
|
|
103340
103356
|
});
|
|
103341
103357
|
}
|
|
103342
|
-
async function publicPost(
|
|
103343
|
-
const response = await fetch(`${API_BASE_URL}${
|
|
103358
|
+
async function publicPost(path13, body) {
|
|
103359
|
+
const response = await fetch(`${API_BASE_URL}${path13}`, {
|
|
103344
103360
|
method: "POST",
|
|
103345
103361
|
headers: { "Content-Type": "application/json" },
|
|
103346
103362
|
body: JSON.stringify(body)
|
|
@@ -103508,13 +103524,13 @@ async function resolveWorkspace(client, ctx) {
|
|
|
103508
103524
|
function resolveUploadPaths(rawPaths) {
|
|
103509
103525
|
const result = [];
|
|
103510
103526
|
for (const p of rawPaths) {
|
|
103511
|
-
const resolved =
|
|
103527
|
+
const resolved = path12.resolve(p);
|
|
103512
103528
|
const stat = fs13.statSync(resolved);
|
|
103513
103529
|
if (stat.isDirectory()) {
|
|
103514
103530
|
const entries2 = fs13.readdirSync(resolved, { withFileTypes: true });
|
|
103515
103531
|
for (const entry of entries2) {
|
|
103516
103532
|
if (entry.isFile()) {
|
|
103517
|
-
result.push(
|
|
103533
|
+
result.push(path12.join(resolved, entry.name));
|
|
103518
103534
|
}
|
|
103519
103535
|
}
|
|
103520
103536
|
} else {
|
|
@@ -103720,7 +103736,7 @@ async function main() {
|
|
|
103720
103736
|
if (command === "preview") {
|
|
103721
103737
|
if (subcommand && isStoredFileId(subcommand)) {
|
|
103722
103738
|
const { client: client2 } = requireClient(flags);
|
|
103723
|
-
const tmpDir = fs13.mkdtempSync(
|
|
103739
|
+
const tmpDir = fs13.mkdtempSync(path12.join(os4.tmpdir(), "lotics-preview-"));
|
|
103724
103740
|
try {
|
|
103725
103741
|
const { path: localPath, filename } = await client2.downloadFileById(subcommand, tmpDir);
|
|
103726
103742
|
const output = flags.output ?? defaultPreviewOutputPath(filename, process.cwd());
|