lopebase 0.6.6 → 0.6.7
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 +14 -1
- package/dist/lopebase.js +358 -329
- package/package.json +1 -2
package/dist/lopebase.js
CHANGED
|
@@ -14,7 +14,7 @@ var __toESMCache_node, __toESMCache_esm, __toESM = (mod, isNodeMode, target) =>
|
|
|
14
14
|
return cached;
|
|
15
15
|
}
|
|
16
16
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
17
|
-
let to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target;
|
|
17
|
+
let to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target;
|
|
18
18
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
19
19
|
for (let key of __getOwnPropNames(mod))
|
|
20
20
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -157,8 +157,8 @@ var require_windows = __commonJS(function(exports, module) {
|
|
|
157
157
|
if (pathext = pathext.split(";"), pathext.indexOf("") !== -1)
|
|
158
158
|
return !0;
|
|
159
159
|
for (var i = 0;i < pathext.length; i++) {
|
|
160
|
-
var
|
|
161
|
-
if (
|
|
160
|
+
var p = pathext[i].toLowerCase();
|
|
161
|
+
if (p && path.substr(-p.length).toLowerCase() === p)
|
|
162
162
|
return !0;
|
|
163
163
|
}
|
|
164
164
|
return !1;
|
|
@@ -195,7 +195,7 @@ var require_mode = __commonJS(function(exports, module) {
|
|
|
195
195
|
return stat.isFile() && checkMode(stat, options);
|
|
196
196
|
}
|
|
197
197
|
function checkMode(stat, options) {
|
|
198
|
-
var { mode: mod, uid, gid } = stat, myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid(), myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid(),
|
|
198
|
+
var { mode: mod, uid, gid } = stat, myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid(), myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid(), u = parseInt("100", 8), g = parseInt("010", 8), o = parseInt("001", 8), ug = u | g, ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
199
199
|
return ret;
|
|
200
200
|
}
|
|
201
201
|
});
|
|
@@ -268,19 +268,19 @@ var require_which = __commonJS(function(exports, module) {
|
|
|
268
268
|
let { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt), found = [], step = (i) => new Promise((resolve, reject) => {
|
|
269
269
|
if (i === pathEnv.length)
|
|
270
270
|
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
271
|
-
let ppRaw = pathEnv[i], pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw, pCmd = path.join(pathPart, cmd),
|
|
272
|
-
resolve(subStep(
|
|
273
|
-
}), subStep = (
|
|
271
|
+
let ppRaw = pathEnv[i], pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw, pCmd = path.join(pathPart, cmd), p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
272
|
+
resolve(subStep(p, i, 0));
|
|
273
|
+
}), subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
274
274
|
if (ii === pathExt.length)
|
|
275
275
|
return resolve(step(i + 1));
|
|
276
276
|
let ext = pathExt[ii];
|
|
277
|
-
isexe(
|
|
277
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
278
278
|
if (!er && is)
|
|
279
279
|
if (opt.all)
|
|
280
|
-
found.push(
|
|
280
|
+
found.push(p + ext);
|
|
281
281
|
else
|
|
282
|
-
return resolve(
|
|
283
|
-
return resolve(subStep(
|
|
282
|
+
return resolve(p + ext);
|
|
283
|
+
return resolve(subStep(p, i, ii + 1));
|
|
284
284
|
});
|
|
285
285
|
});
|
|
286
286
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -288,9 +288,9 @@ var require_which = __commonJS(function(exports, module) {
|
|
|
288
288
|
opt = opt || {};
|
|
289
289
|
let { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt), found = [];
|
|
290
290
|
for (let i = 0;i < pathEnv.length; i++) {
|
|
291
|
-
let ppRaw = pathEnv[i], pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw, pCmd = path.join(pathPart, cmd),
|
|
292
|
-
for (let
|
|
293
|
-
let cur =
|
|
291
|
+
let ppRaw = pathEnv[i], pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw, pCmd = path.join(pathPart, cmd), p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
292
|
+
for (let j = 0;j < pathExt.length; j++) {
|
|
293
|
+
let cur = p + pathExt[j];
|
|
294
294
|
try {
|
|
295
295
|
if (isexe.sync(cur, { pathExt: pathExtExe }))
|
|
296
296
|
if (opt.all)
|
|
@@ -337,7 +337,7 @@ var require_resolveCommand = __commonJS(function(exports, module) {
|
|
|
337
337
|
path: env[getPathKey({ env })],
|
|
338
338
|
pathExt: withoutPathExt ? path.delimiter : void 0
|
|
339
339
|
});
|
|
340
|
-
} catch (
|
|
340
|
+
} catch (e) {} finally {
|
|
341
341
|
if (shouldSwitchCwd)
|
|
342
342
|
process.chdir(cwd);
|
|
343
343
|
}
|
|
@@ -392,7 +392,7 @@ var require_readShebang = __commonJS(function(exports, module) {
|
|
|
392
392
|
let buffer = Buffer.alloc(150), fd;
|
|
393
393
|
try {
|
|
394
394
|
fd = fs.openSync(command, "r"), fs.readSync(fd, buffer, 0, 150, 0), fs.closeSync(fd);
|
|
395
|
-
} catch (
|
|
395
|
+
} catch (e) {}
|
|
396
396
|
return shebangCommand(buffer.toString());
|
|
397
397
|
}
|
|
398
398
|
module.exports = readShebang;
|
|
@@ -968,17 +968,17 @@ var V2 = ce(), u = (t, n) => V2 ? t : n, le = u("◆", "*"), L2 = u("■", "x"),
|
|
|
968
968
|
return import_picocolors2.default.green(C);
|
|
969
969
|
}
|
|
970
970
|
}, G2 = (t) => {
|
|
971
|
-
let { cursor: n, options:
|
|
972
|
-
n >=
|
|
973
|
-
let $
|
|
974
|
-
return
|
|
975
|
-
let
|
|
976
|
-
return
|
|
971
|
+
let { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5)), l = 0;
|
|
972
|
+
n >= l + a - 3 ? l = Math.max(Math.min(n - a + 3, r.length - a), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
|
|
973
|
+
let $ = a < r.length && l > 0, g = a < r.length && l + a < r.length;
|
|
974
|
+
return r.slice(l, l + a).map((p, v, f) => {
|
|
975
|
+
let j = v === 0 && $, E = v === f.length - 1 && g;
|
|
976
|
+
return j || E ? import_picocolors2.default.dim("...") : i(p, v + l === n);
|
|
977
977
|
});
|
|
978
978
|
}, he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
|
|
979
979
|
let n = `${import_picocolors2.default.gray(o)}
|
|
980
980
|
${b2(this.state)} ${t.message}
|
|
981
|
-
`,
|
|
981
|
+
`, r = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : r;
|
|
982
982
|
switch (this.state) {
|
|
983
983
|
case "error":
|
|
984
984
|
return `${n.trim()}
|
|
@@ -998,7 +998,7 @@ ${import_picocolors2.default.cyan(d2)}
|
|
|
998
998
|
} }).prompt(), ge = (t) => new MD({ validate: t.validate, mask: t.mask ?? $e, render() {
|
|
999
999
|
let n = `${import_picocolors2.default.gray(o)}
|
|
1000
1000
|
${b2(this.state)} ${t.message}
|
|
1001
|
-
`,
|
|
1001
|
+
`, r = this.valueWithCursor, i = this.masked;
|
|
1002
1002
|
switch (this.state) {
|
|
1003
1003
|
case "error":
|
|
1004
1004
|
return `${n.trim()}
|
|
@@ -1011,16 +1011,16 @@ ${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(th
|
|
|
1011
1011
|
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(i ?? ""))}${i ? `
|
|
1012
1012
|
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
1013
1013
|
default:
|
|
1014
|
-
return `${n}${import_picocolors2.default.cyan(o)} ${
|
|
1014
|
+
return `${n}${import_picocolors2.default.cyan(o)} ${r}
|
|
1015
1015
|
${import_picocolors2.default.cyan(d2)}
|
|
1016
1016
|
`;
|
|
1017
1017
|
}
|
|
1018
1018
|
} }).prompt(), ye = (t) => {
|
|
1019
|
-
let n = t.active ?? "Yes",
|
|
1020
|
-
return new dD({ active: n, inactive:
|
|
1019
|
+
let n = t.active ?? "Yes", r = t.inactive ?? "No";
|
|
1020
|
+
return new dD({ active: n, inactive: r, initialValue: t.initialValue ?? !0, render() {
|
|
1021
1021
|
let i = `${import_picocolors2.default.gray(o)}
|
|
1022
1022
|
${b2(this.state)} ${t.message}
|
|
1023
|
-
`, s = this.value ? n :
|
|
1023
|
+
`, s = this.value ? n : r;
|
|
1024
1024
|
switch (this.state) {
|
|
1025
1025
|
case "submit":
|
|
1026
1026
|
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(s)}`;
|
|
@@ -1028,19 +1028,19 @@ ${b2(this.state)} ${t.message}
|
|
|
1028
1028
|
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
|
|
1029
1029
|
${import_picocolors2.default.gray(o)}`;
|
|
1030
1030
|
default:
|
|
1031
|
-
return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(
|
|
1031
|
+
return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(r)}` : `${import_picocolors2.default.green(k2)} ${r}`}
|
|
1032
1032
|
${import_picocolors2.default.cyan(d2)}
|
|
1033
1033
|
`;
|
|
1034
1034
|
}
|
|
1035
1035
|
} }).prompt();
|
|
1036
1036
|
}, ve = (t) => {
|
|
1037
|
-
let n = (
|
|
1038
|
-
let s =
|
|
1037
|
+
let n = (r, i) => {
|
|
1038
|
+
let s = r.label ?? String(r.value);
|
|
1039
1039
|
switch (i) {
|
|
1040
1040
|
case "selected":
|
|
1041
1041
|
return `${import_picocolors2.default.dim(s)}`;
|
|
1042
1042
|
case "active":
|
|
1043
|
-
return `${import_picocolors2.default.green(k2)} ${s} ${
|
|
1043
|
+
return `${import_picocolors2.default.green(k2)} ${s} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}`;
|
|
1044
1044
|
case "cancelled":
|
|
1045
1045
|
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
|
|
1046
1046
|
default:
|
|
@@ -1048,17 +1048,17 @@ ${import_picocolors2.default.cyan(d2)}
|
|
|
1048
1048
|
}
|
|
1049
1049
|
};
|
|
1050
1050
|
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
1051
|
-
let
|
|
1051
|
+
let r = `${import_picocolors2.default.gray(o)}
|
|
1052
1052
|
${b2(this.state)} ${t.message}
|
|
1053
1053
|
`;
|
|
1054
1054
|
switch (this.state) {
|
|
1055
1055
|
case "submit":
|
|
1056
|
-
return `${
|
|
1056
|
+
return `${r}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
1057
1057
|
case "cancel":
|
|
1058
|
-
return `${
|
|
1058
|
+
return `${r}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
1059
1059
|
${import_picocolors2.default.gray(o)}`;
|
|
1060
1060
|
default:
|
|
1061
|
-
return `${
|
|
1061
|
+
return `${r}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
|
|
1062
1062
|
${import_picocolors2.default.cyan(o)} `)}
|
|
1063
1063
|
${import_picocolors2.default.cyan(d2)}
|
|
1064
1064
|
`;
|
|
@@ -1066,16 +1066,16 @@ ${import_picocolors2.default.cyan(d2)}
|
|
|
1066
1066
|
} }).prompt();
|
|
1067
1067
|
};
|
|
1068
1068
|
var fe = (t) => {
|
|
1069
|
-
let n = (
|
|
1070
|
-
let s =
|
|
1071
|
-
return i === "active" ? `${import_picocolors2.default.cyan(A2)} ${s} ${
|
|
1069
|
+
let n = (r, i) => {
|
|
1070
|
+
let s = r.label ?? String(r.value);
|
|
1071
|
+
return i === "active" ? `${import_picocolors2.default.cyan(A2)} ${s} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}` : i === "selected" ? `${import_picocolors2.default.green(T)} ${import_picocolors2.default.dim(s)} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : i === "active-selected" ? `${import_picocolors2.default.green(T)} ${s} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(F)} ${import_picocolors2.default.dim(s)}`;
|
|
1072
1072
|
};
|
|
1073
|
-
return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? !0, cursorAt: t.cursorAt, validate(
|
|
1074
|
-
if (this.required &&
|
|
1073
|
+
return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? !0, cursorAt: t.cursorAt, validate(r) {
|
|
1074
|
+
if (this.required && r.length === 0)
|
|
1075
1075
|
return `Please select at least one option.
|
|
1076
1076
|
${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
|
|
1077
1077
|
}, render() {
|
|
1078
|
-
let
|
|
1078
|
+
let r = `${import_picocolors2.default.gray(o)}
|
|
1079
1079
|
${b2(this.state)} ${t.message}
|
|
1080
1080
|
`, i = (s, c) => {
|
|
1081
1081
|
let a = this.value.includes(s.value);
|
|
@@ -1083,23 +1083,23 @@ ${b2(this.state)} ${t.message}
|
|
|
1083
1083
|
};
|
|
1084
1084
|
switch (this.state) {
|
|
1085
1085
|
case "submit":
|
|
1086
|
-
return `${
|
|
1086
|
+
return `${r}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
|
|
1087
1087
|
case "cancel": {
|
|
1088
1088
|
let s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors2.default.dim(", "));
|
|
1089
|
-
return `${
|
|
1089
|
+
return `${r}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
|
|
1090
1090
|
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
1091
1091
|
}
|
|
1092
1092
|
case "error": {
|
|
1093
1093
|
let s = this.error.split(`
|
|
1094
1094
|
`).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
|
|
1095
1095
|
`);
|
|
1096
|
-
return `${
|
|
1096
|
+
return `${r + import_picocolors2.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
1097
1097
|
${import_picocolors2.default.yellow(o)} `)}
|
|
1098
1098
|
${s}
|
|
1099
1099
|
`;
|
|
1100
1100
|
}
|
|
1101
1101
|
default:
|
|
1102
|
-
return `${
|
|
1102
|
+
return `${r}${import_picocolors2.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
1103
1103
|
${import_picocolors2.default.cyan(o)} `)}
|
|
1104
1104
|
${import_picocolors2.default.cyan(d2)}
|
|
1105
1105
|
`;
|
|
@@ -1107,13 +1107,13 @@ ${import_picocolors2.default.cyan(d2)}
|
|
|
1107
1107
|
} }).prompt();
|
|
1108
1108
|
};
|
|
1109
1109
|
var Me = (t = "", n = "") => {
|
|
1110
|
-
let
|
|
1110
|
+
let r = `
|
|
1111
1111
|
${t}
|
|
1112
1112
|
`.split(`
|
|
1113
|
-
`), i = S2(n).length, s = Math.max(
|
|
1114
|
-
let $
|
|
1115
|
-
return
|
|
1116
|
-
}, 0), i) + 2, c =
|
|
1113
|
+
`), i = S2(n).length, s = Math.max(r.reduce((a, l) => {
|
|
1114
|
+
let $ = S2(l);
|
|
1115
|
+
return $.length > a ? $.length : a;
|
|
1116
|
+
}, 0), i) + 2, c = r.map((a) => `${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(a)}${" ".repeat(s - S2(a).length)}${import_picocolors2.default.gray(o)}`).join(`
|
|
1117
1117
|
`);
|
|
1118
1118
|
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
1119
1119
|
${import_picocolors2.default.green(C)} ${import_picocolors2.default.reset(n)} ${import_picocolors2.default.gray(_2.repeat(Math.max(s - i - 1, 1)) + me)}
|
|
@@ -1133,13 +1133,13 @@ ${import_picocolors2.default.gray(d2)} ${t}
|
|
|
1133
1133
|
|
|
1134
1134
|
`);
|
|
1135
1135
|
}, M2 = { message: (t = "", { symbol: n = import_picocolors2.default.gray(o) } = {}) => {
|
|
1136
|
-
let
|
|
1136
|
+
let r = [`${import_picocolors2.default.gray(o)}`];
|
|
1137
1137
|
if (t) {
|
|
1138
1138
|
let [i, ...s] = t.split(`
|
|
1139
1139
|
`);
|
|
1140
|
-
|
|
1140
|
+
r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors2.default.gray(o)} ${c}`));
|
|
1141
1141
|
}
|
|
1142
|
-
process.stdout.write(`${
|
|
1142
|
+
process.stdout.write(`${r.join(`
|
|
1143
1143
|
`)}
|
|
1144
1144
|
`);
|
|
1145
1145
|
}, info: (t) => {
|
|
@@ -1156,52 +1156,52 @@ ${import_picocolors2.default.gray(d2)} ${t}
|
|
|
1156
1156
|
M2.message(t, { symbol: import_picocolors2.default.red(K2) });
|
|
1157
1157
|
} }, J2 = `${import_picocolors2.default.gray(o)} `;
|
|
1158
1158
|
var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
1159
|
-
let n = V2 ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"],
|
|
1160
|
-
let
|
|
1161
|
-
a &&
|
|
1162
|
-
},
|
|
1163
|
-
process.on("uncaughtExceptionMonitor",
|
|
1159
|
+
let n = V2 ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], r = V2 ? 80 : 120, i = process.env.CI === "true", s, c, a = !1, l = "", $, g = performance.now(), p = (m) => {
|
|
1160
|
+
let h = m > 1 ? "Something went wrong" : "Canceled";
|
|
1161
|
+
a && N(h, m);
|
|
1162
|
+
}, v = () => p(2), f = () => p(1), j = () => {
|
|
1163
|
+
process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p);
|
|
1164
1164
|
}, E = () => {
|
|
1165
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1166
|
-
},
|
|
1167
|
-
if ($
|
|
1165
|
+
process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p);
|
|
1166
|
+
}, B = () => {
|
|
1167
|
+
if ($ === void 0)
|
|
1168
1168
|
return;
|
|
1169
1169
|
i && process.stdout.write(`
|
|
1170
1170
|
`);
|
|
1171
|
-
let
|
|
1171
|
+
let m = $.split(`
|
|
1172
1172
|
`);
|
|
1173
|
-
process.stdout.write(import_sisteransi2.cursor.move(-999,
|
|
1174
|
-
},
|
|
1175
|
-
let
|
|
1176
|
-
return
|
|
1177
|
-
},
|
|
1178
|
-
a = !0, s = fD(),
|
|
1173
|
+
process.stdout.write(import_sisteransi2.cursor.move(-999, m.length - 1)), process.stdout.write(import_sisteransi2.erase.down(m.length));
|
|
1174
|
+
}, R = (m) => m.replace(/\.+$/, ""), O = (m) => {
|
|
1175
|
+
let h = (performance.now() - m) / 1000, w = Math.floor(h / 60), I = Math.floor(h % 60);
|
|
1176
|
+
return w > 0 ? `[${w}m ${I}s]` : `[${I}s]`;
|
|
1177
|
+
}, H = (m = "") => {
|
|
1178
|
+
a = !0, s = fD(), l = R(m), g = performance.now(), process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
1179
1179
|
`);
|
|
1180
|
-
let
|
|
1181
|
-
|
|
1182
|
-
if (i &&
|
|
1180
|
+
let h = 0, w = 0;
|
|
1181
|
+
j(), c = setInterval(() => {
|
|
1182
|
+
if (i && l === $)
|
|
1183
1183
|
return;
|
|
1184
|
-
|
|
1185
|
-
let
|
|
1184
|
+
B(), $ = l;
|
|
1185
|
+
let I = import_picocolors2.default.magenta(n[h]);
|
|
1186
1186
|
if (i)
|
|
1187
|
-
process.stdout.write(`${
|
|
1187
|
+
process.stdout.write(`${I} ${l}...`);
|
|
1188
1188
|
else if (t === "timer")
|
|
1189
|
-
process.stdout.write(`${
|
|
1189
|
+
process.stdout.write(`${I} ${l} ${O(g)}`);
|
|
1190
1190
|
else {
|
|
1191
|
-
let
|
|
1192
|
-
process.stdout.write(`${
|
|
1191
|
+
let z = ".".repeat(Math.floor(w)).slice(0, 3);
|
|
1192
|
+
process.stdout.write(`${I} ${l}${z}`);
|
|
1193
1193
|
}
|
|
1194
|
-
|
|
1195
|
-
},
|
|
1196
|
-
},
|
|
1197
|
-
a = !1, clearInterval(c),
|
|
1198
|
-
let
|
|
1199
|
-
|
|
1200
|
-
`) : process.stdout.write(`${
|
|
1194
|
+
h = h + 1 < n.length ? h + 1 : 0, w = w < n.length ? w + 0.125 : 0;
|
|
1195
|
+
}, r);
|
|
1196
|
+
}, N = (m = "", h = 0) => {
|
|
1197
|
+
a = !1, clearInterval(c), B();
|
|
1198
|
+
let w = h === 0 ? import_picocolors2.default.green(C) : h === 1 ? import_picocolors2.default.red(L2) : import_picocolors2.default.red(W2);
|
|
1199
|
+
l = R(m ?? l), t === "timer" ? process.stdout.write(`${w} ${l} ${O(g)}
|
|
1200
|
+
`) : process.stdout.write(`${w} ${l}
|
|
1201
1201
|
`), E(), s();
|
|
1202
1202
|
};
|
|
1203
|
-
return { start:
|
|
1204
|
-
|
|
1203
|
+
return { start: H, stop: N, message: (m = "") => {
|
|
1204
|
+
l = R(m ?? l);
|
|
1205
1205
|
} };
|
|
1206
1206
|
};
|
|
1207
1207
|
|
|
@@ -1284,29 +1284,29 @@ var ADAPTER_VERSION = "0.4.2", ADAPTER_RELEASES = [
|
|
|
1284
1284
|
steps: []
|
|
1285
1285
|
}
|
|
1286
1286
|
];
|
|
1287
|
-
function compareVersions(a,
|
|
1288
|
-
let parts = (
|
|
1289
|
-
if (
|
|
1290
|
-
return
|
|
1291
|
-
if (
|
|
1287
|
+
function compareVersions(a, b) {
|
|
1288
|
+
let parts = (v) => (v.match(/^\D*(\d+)\.(\d+)\.(\d+)/) ?? []).slice(1).map(Number), [x, y] = [parts(a), parts(b)];
|
|
1289
|
+
if (x.length !== 3)
|
|
1290
|
+
return y.length === 3 ? -1 : 0;
|
|
1291
|
+
if (y.length !== 3)
|
|
1292
1292
|
return 1;
|
|
1293
1293
|
for (let i = 0;i < 3; i++)
|
|
1294
|
-
if (
|
|
1295
|
-
return
|
|
1294
|
+
if (x[i] !== y[i])
|
|
1295
|
+
return x[i] < y[i] ? -1 : 1;
|
|
1296
1296
|
return 0;
|
|
1297
1297
|
}
|
|
1298
1298
|
function releasesSince(version) {
|
|
1299
|
-
return ADAPTER_RELEASES.filter((
|
|
1299
|
+
return ADAPTER_RELEASES.filter((r) => !version || compareVersions(r.version, version) > 0).reverse();
|
|
1300
1300
|
}
|
|
1301
1301
|
function upgradePrompt(fromVersion) {
|
|
1302
|
-
let todo = releasesSince(fromVersion), breaking = todo.flatMap((
|
|
1302
|
+
let todo = releasesSince(fromVersion), breaking = todo.flatMap((r) => r.breaking ?? []), steps = todo.flatMap((r) => r.steps);
|
|
1303
1303
|
return [
|
|
1304
1304
|
`Update this app's LopeBase adapter (@lopebase/adapter) from ${fromVersion ?? "its current version"} to 0.4.2.`,
|
|
1305
1305
|
"",
|
|
1306
1306
|
"1. Install it with this repo's package manager, for example `npm install @lopebase/adapter@latest`. A 0.x range like ^0.1.2 does not pick up 0.2 or later on its own.",
|
|
1307
1307
|
...breaking.length ? [
|
|
1308
1308
|
"2. These changes would stop the adapter from starting; handle each one:",
|
|
1309
|
-
...breaking.map((
|
|
1309
|
+
...breaking.map((b) => ` - ${b}`)
|
|
1310
1310
|
] : ["2. Nothing in this update stops an existing adapter from starting."],
|
|
1311
1311
|
...steps.length ? [
|
|
1312
1312
|
"3. Adopt what is new, asking the human before each change:",
|
|
@@ -1322,7 +1322,7 @@ function upgradePrompt(fromVersion) {
|
|
|
1322
1322
|
var SIGNATURE_HEADER = "lopebase-signature";
|
|
1323
1323
|
var enc = /* @__PURE__ */ new TextEncoder;
|
|
1324
1324
|
function hex(bytes) {
|
|
1325
|
-
return [...new Uint8Array(bytes)].map((
|
|
1325
|
+
return [...new Uint8Array(bytes)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1326
1326
|
}
|
|
1327
1327
|
async function sha256Hex(data) {
|
|
1328
1328
|
return hex(await crypto.subtle.digest("SHA-256", data));
|
|
@@ -1333,8 +1333,8 @@ async function hmacHex(secret, message) {
|
|
|
1333
1333
|
}
|
|
1334
1334
|
function newSigningSecret() {
|
|
1335
1335
|
let bytes = crypto.getRandomValues(new Uint8Array(32)), bin = "";
|
|
1336
|
-
for (let
|
|
1337
|
-
bin += String.fromCharCode(
|
|
1336
|
+
for (let b of bytes)
|
|
1337
|
+
bin += String.fromCharCode(b);
|
|
1338
1338
|
return "lbs_" + btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1339
1339
|
}
|
|
1340
1340
|
function payload(t, method, pathAndQuery, bodyHash) {
|
|
@@ -1371,7 +1371,7 @@ var SENSITIVE_PARTS = /* @__PURE__ */ new Set([
|
|
|
1371
1371
|
]), SENSITIVE_JOINED = /apikey|privatekey|secretkey|accesskey|accountnumber|routingnumber|stripecustomer|paymentmethod|recoverycode/;
|
|
1372
1372
|
function isSensitiveFieldName(name) {
|
|
1373
1373
|
let parts = name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
1374
|
-
if (parts.some((
|
|
1374
|
+
if (parts.some((p) => SENSITIVE_PARTS.has(p)))
|
|
1375
1375
|
return !0;
|
|
1376
1376
|
return SENSITIVE_JOINED.test(parts.join(""));
|
|
1377
1377
|
}
|
|
@@ -1390,12 +1390,12 @@ function conformanceChecks(opts) {
|
|
|
1390
1390
|
let remote = !opts.adapter, base = opts.baseUrl ? opts.baseUrl.replace(/\/$/, "") : `${opts.origin ?? "https://property.test"}${(opts.basePath ?? opts.adapter?.config.basePath ?? DEFAULT_BASE_PATH).replace(/\/$/, "")}`, send = (req) => opts.adapter ? opts.adapter.handle(req) : fetch(req);
|
|
1391
1391
|
async function signedHeaders(url, method, bodyText, timestamp) {
|
|
1392
1392
|
if (opts.secret) {
|
|
1393
|
-
let
|
|
1393
|
+
let u = new URL(url);
|
|
1394
1394
|
return {
|
|
1395
1395
|
[SIGNATURE_HEADER]: await signRequest({
|
|
1396
1396
|
secret: opts.secret,
|
|
1397
1397
|
method,
|
|
1398
|
-
pathAndQuery:
|
|
1398
|
+
pathAndQuery: u.pathname + u.search,
|
|
1399
1399
|
body: bodyText,
|
|
1400
1400
|
timestamp
|
|
1401
1401
|
})
|
|
@@ -1413,14 +1413,14 @@ function conformanceChecks(opts) {
|
|
|
1413
1413
|
...init?.headers
|
|
1414
1414
|
}
|
|
1415
1415
|
}));
|
|
1416
|
-
}, resources = () => authed("/resources").then((
|
|
1416
|
+
}, resources = () => authed("/resources").then((r) => body(r)), checks = [
|
|
1417
1417
|
{
|
|
1418
1418
|
name: "GET /health returns { ok } without auth",
|
|
1419
1419
|
async run() {
|
|
1420
1420
|
let res = await send(new Request(`${base}/health`));
|
|
1421
1421
|
assert.equal(res.status, 200);
|
|
1422
|
-
let
|
|
1423
|
-
assert.equal(typeof
|
|
1422
|
+
let b = await body(res);
|
|
1423
|
+
assert.equal(typeof b.ok, "boolean");
|
|
1424
1424
|
}
|
|
1425
1425
|
},
|
|
1426
1426
|
{
|
|
@@ -1435,10 +1435,10 @@ function conformanceChecks(opts) {
|
|
|
1435
1435
|
async run() {
|
|
1436
1436
|
let res = await authed("/resources");
|
|
1437
1437
|
assert.equal(res.status, 200);
|
|
1438
|
-
let
|
|
1439
|
-
assert.ok(Array.isArray(
|
|
1440
|
-
for (let
|
|
1441
|
-
assert.ok(
|
|
1438
|
+
let b = await body(res);
|
|
1439
|
+
assert.ok(Array.isArray(b.resources));
|
|
1440
|
+
for (let r of b.resources)
|
|
1441
|
+
assert.ok(r.name && r.label && r.readCapability), assert.ok(Array.isArray(r.fields));
|
|
1442
1442
|
}
|
|
1443
1443
|
},
|
|
1444
1444
|
{
|
|
@@ -1446,9 +1446,9 @@ function conformanceChecks(opts) {
|
|
|
1446
1446
|
async run() {
|
|
1447
1447
|
let res = await authed("/actions");
|
|
1448
1448
|
assert.equal(res.status, 200);
|
|
1449
|
-
let
|
|
1450
|
-
assert.ok(Array.isArray(
|
|
1451
|
-
for (let a of
|
|
1449
|
+
let b = await body(res);
|
|
1450
|
+
assert.ok(Array.isArray(b.actions));
|
|
1451
|
+
for (let a of b.actions)
|
|
1452
1452
|
assert.ok(a.name && a.label && a.capability), assert.ok(Array.isArray(a.params));
|
|
1453
1453
|
}
|
|
1454
1454
|
},
|
|
@@ -1467,7 +1467,7 @@ function conformanceChecks(opts) {
|
|
|
1467
1467
|
{
|
|
1468
1468
|
name: "GET /resources/:name/:id returns a row or 404-null",
|
|
1469
1469
|
async run() {
|
|
1470
|
-
let cat = await resources(), meta = opts.sampleResource ? cat.resources.find((
|
|
1470
|
+
let cat = await resources(), meta = opts.sampleResource ? cat.resources.find((r) => r.name === opts.sampleResource) : cat.resources[0];
|
|
1471
1471
|
if (!meta)
|
|
1472
1472
|
return;
|
|
1473
1473
|
let first = (await body(await authed(`/resources/${meta.name}?limit=1`))).rows[0];
|
|
@@ -1482,8 +1482,8 @@ function conformanceChecks(opts) {
|
|
|
1482
1482
|
async run() {
|
|
1483
1483
|
let res = await authed("/audit");
|
|
1484
1484
|
assert.equal(res.status, 200);
|
|
1485
|
-
let
|
|
1486
|
-
assert.ok(Array.isArray(
|
|
1485
|
+
let b = await body(res);
|
|
1486
|
+
assert.ok(Array.isArray(b.rows));
|
|
1487
1487
|
}
|
|
1488
1488
|
},
|
|
1489
1489
|
{
|
|
@@ -1497,24 +1497,24 @@ function conformanceChecks(opts) {
|
|
|
1497
1497
|
name: "no field in the catalog looks like a secret unless marked safe",
|
|
1498
1498
|
async run() {
|
|
1499
1499
|
let cat = await resources();
|
|
1500
|
-
for (let
|
|
1501
|
-
for (let f of
|
|
1502
|
-
assert.ok(!isSensitiveFieldName(f.name) || f.sensitive === "allow", `${
|
|
1500
|
+
for (let r of cat.resources)
|
|
1501
|
+
for (let f of r.fields)
|
|
1502
|
+
assert.ok(!isSensitiveFieldName(f.name) || f.sensitive === "allow", `${r.name}.${f.name} looks sensitive`);
|
|
1503
1503
|
}
|
|
1504
1504
|
},
|
|
1505
1505
|
{
|
|
1506
1506
|
name: "rows contain only declared fields, and a page is at most 100",
|
|
1507
1507
|
async run() {
|
|
1508
1508
|
let cat = await resources();
|
|
1509
|
-
for (let
|
|
1510
|
-
let res = await authed(`/resources/${
|
|
1509
|
+
for (let r of cat.resources) {
|
|
1510
|
+
let res = await authed(`/resources/${r.name}?limit=1000`);
|
|
1511
1511
|
assert.equal(res.status, 200);
|
|
1512
1512
|
let page = await body(res);
|
|
1513
|
-
assert.ok(page.rows.length <= 100, `${
|
|
1514
|
-
let declared = /* @__PURE__ */ new Set(["id", ...
|
|
1513
|
+
assert.ok(page.rows.length <= 100, `${r.name} returned ${page.rows.length} rows`);
|
|
1514
|
+
let declared = /* @__PURE__ */ new Set(["id", ...r.fields.map((f) => f.name)]);
|
|
1515
1515
|
for (let row of page.rows)
|
|
1516
|
-
for (let
|
|
1517
|
-
assert.ok(declared.has(
|
|
1516
|
+
for (let k of Object.keys(row))
|
|
1517
|
+
assert.ok(declared.has(k), `${r.name} returned undeclared field ${k}`);
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
1520
1520
|
},
|
|
@@ -1532,7 +1532,7 @@ function conformanceChecks(opts) {
|
|
|
1532
1532
|
{
|
|
1533
1533
|
name: "a mutation writes an audit row (PATCH round-trips into /audit)",
|
|
1534
1534
|
async run() {
|
|
1535
|
-
let writable = (await resources()).resources.find((
|
|
1535
|
+
let writable = (await resources()).resources.find((r) => r.writeCapability && r.fields.some((f) => f.editable));
|
|
1536
1536
|
if (!writable || remote)
|
|
1537
1537
|
return;
|
|
1538
1538
|
let row = (await body(await authed(`/resources/${writable.name}?limit=1`))).rows[0];
|
|
@@ -1568,8 +1568,8 @@ async function checkAdapter(input) {
|
|
|
1568
1568
|
})
|
|
1569
1569
|
} : { authorization: `Bearer ${input.token ?? ""}` };
|
|
1570
1570
|
status = (await fetch(url, { headers })).status;
|
|
1571
|
-
} catch (
|
|
1572
|
-
let error = `Could not reach ${base} (${
|
|
1571
|
+
} catch (e) {
|
|
1572
|
+
let error = `Could not reach ${base} (${e instanceof Error ? e.message : String(e)}).`;
|
|
1573
1573
|
return log(`FAIL ${error}`), { passed, failed: [{ name: "reachable", error }] };
|
|
1574
1574
|
}
|
|
1575
1575
|
if (status === 401) {
|
|
@@ -1587,9 +1587,9 @@ async function checkAdapter(input) {
|
|
|
1587
1587
|
}))
|
|
1588
1588
|
try {
|
|
1589
1589
|
await c.run(), passed++, log(`pass ${c.name}`);
|
|
1590
|
-
} catch (
|
|
1591
|
-
let error =
|
|
1592
|
-
`)[0] : String(
|
|
1590
|
+
} catch (e) {
|
|
1591
|
+
let error = e instanceof Error ? e.message.split(`
|
|
1592
|
+
`)[0] : String(e);
|
|
1593
1593
|
failed.push({ name: c.name, error }), log(`FAIL ${c.name}: ${error}`);
|
|
1594
1594
|
}
|
|
1595
1595
|
return { passed, failed };
|
|
@@ -1603,7 +1603,7 @@ var AGENTS = [
|
|
|
1603
1603
|
id: "claude",
|
|
1604
1604
|
label: "Claude Code",
|
|
1605
1605
|
bin: "claude",
|
|
1606
|
-
args: (
|
|
1606
|
+
args: (p) => [p],
|
|
1607
1607
|
mcpAdd: (argv) => [
|
|
1608
1608
|
"mcp",
|
|
1609
1609
|
"add",
|
|
@@ -1618,27 +1618,27 @@ var AGENTS = [
|
|
|
1618
1618
|
id: "codex",
|
|
1619
1619
|
label: "Codex",
|
|
1620
1620
|
bin: "codex",
|
|
1621
|
-
args: (
|
|
1621
|
+
args: (p) => [p],
|
|
1622
1622
|
mcpAdd: (argv) => ["mcp", "add", "lopebase", "--", ...argv]
|
|
1623
1623
|
},
|
|
1624
1624
|
{
|
|
1625
1625
|
id: "gemini",
|
|
1626
1626
|
label: "Gemini CLI",
|
|
1627
1627
|
bin: "gemini",
|
|
1628
|
-
args: (
|
|
1628
|
+
args: (p) => ["-i", p],
|
|
1629
1629
|
mcpAdd: (argv) => ["mcp", "add", "lopebase", ...argv]
|
|
1630
1630
|
},
|
|
1631
1631
|
{
|
|
1632
1632
|
id: "opencode",
|
|
1633
1633
|
label: "opencode",
|
|
1634
1634
|
bin: "opencode",
|
|
1635
|
-
args: (
|
|
1635
|
+
args: (p) => ["--prompt", p]
|
|
1636
1636
|
},
|
|
1637
1637
|
{
|
|
1638
1638
|
id: "cursor-agent",
|
|
1639
1639
|
label: "Cursor Agent",
|
|
1640
1640
|
bin: "cursor-agent",
|
|
1641
|
-
args: (
|
|
1641
|
+
args: (p) => [p]
|
|
1642
1642
|
}
|
|
1643
1643
|
];
|
|
1644
1644
|
function isInstalled(bin) {
|
|
@@ -1681,6 +1681,7 @@ var shared = {
|
|
|
1681
1681
|
updated: { kind: "date", role: "updated" },
|
|
1682
1682
|
image: { kind: "url", role: "image" },
|
|
1683
1683
|
image_alt: { kind: "string", role: "imageAlt" },
|
|
1684
|
+
image_kind: { kind: "imageKind", role: "imageKind" },
|
|
1684
1685
|
faq: { kind: "faq", role: "faq" }
|
|
1685
1686
|
}, BLOG_PRESETS = {
|
|
1686
1687
|
markdown: {
|
|
@@ -1729,22 +1730,22 @@ var shared = {
|
|
|
1729
1730
|
},
|
|
1730
1731
|
datedFileKey: "date"
|
|
1731
1732
|
}
|
|
1732
|
-
}, isBlogFormat = (
|
|
1733
|
-
function realDate(
|
|
1734
|
-
let date = new Date(Date.UTC(+
|
|
1735
|
-
return date.getUTCFullYear() === +
|
|
1733
|
+
}, isBlogFormat = (v) => Object.hasOwn(BLOG_PRESETS, v), IMAGE_KINDS = ["title_card", "artwork"], SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/, DATE = /^(\d{4})-(\d{2})-(\d{2})$/, DATETIME = /^(\d{4})-(\d{2})-(\d{2})T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/, JEKYLL_FILE = /^(\d{4}-\d{2}-\d{2})-(.+)$/, HTML_TAG = /<\/?[A-Za-z][A-Za-z0-9-]*(?:\s[^<>]*)?\/?>|<!--/;
|
|
1734
|
+
function realDate(y, m, d) {
|
|
1735
|
+
let date = new Date(Date.UTC(+y, +m - 1, +d));
|
|
1736
|
+
return date.getUTCFullYear() === +y && date.getUTCMonth() === +m - 1 && date.getUTCDate() === +d;
|
|
1736
1737
|
}
|
|
1737
|
-
function isUrl(
|
|
1738
|
-
if (typeof
|
|
1738
|
+
function isUrl(v) {
|
|
1739
|
+
if (typeof v !== "string")
|
|
1739
1740
|
return !1;
|
|
1740
1741
|
try {
|
|
1741
|
-
let
|
|
1742
|
-
return
|
|
1742
|
+
let u = new URL(v);
|
|
1743
|
+
return u.protocol === "https:" || u.protocol === "http:";
|
|
1743
1744
|
} catch {
|
|
1744
1745
|
return !1;
|
|
1745
1746
|
}
|
|
1746
1747
|
}
|
|
1747
|
-
var filled = (
|
|
1748
|
+
var filled = (v) => typeof v === "string" && v.trim() !== "";
|
|
1748
1749
|
function json(raw) {
|
|
1749
1750
|
try {
|
|
1750
1751
|
return { ok: !0, value: JSON.parse(raw) };
|
|
@@ -1756,41 +1757,45 @@ function checkValue(key, kind, raw) {
|
|
|
1756
1757
|
switch (kind) {
|
|
1757
1758
|
case "layout":
|
|
1758
1759
|
return raw === "post" ? void 0 : `${key} must be post`;
|
|
1760
|
+
case "imageKind": {
|
|
1761
|
+
let v = json(raw);
|
|
1762
|
+
return v.ok && IMAGE_KINDS.includes(v.value) ? void 0 : `${key} must be "title_card" or "artwork"`;
|
|
1763
|
+
}
|
|
1759
1764
|
case "date": {
|
|
1760
|
-
let
|
|
1761
|
-
return
|
|
1765
|
+
let m = DATE.exec(raw);
|
|
1766
|
+
return m && realDate(m[1], m[2], m[3]) ? void 0 : `${key} must be a date like 2026-11-05`;
|
|
1762
1767
|
}
|
|
1763
1768
|
case "datetime": {
|
|
1764
|
-
let
|
|
1765
|
-
return
|
|
1769
|
+
let m = DATETIME.exec(raw);
|
|
1770
|
+
return m && realDate(m[1], m[2], m[3]) ? void 0 : `${key} must be a date and time like 2026-11-05T15:00:00Z`;
|
|
1766
1771
|
}
|
|
1767
1772
|
case "string": {
|
|
1768
|
-
let
|
|
1769
|
-
if (!
|
|
1773
|
+
let v = json(raw);
|
|
1774
|
+
if (!v.ok || typeof v.value !== "string")
|
|
1770
1775
|
return `${key} must be a quoted string`;
|
|
1771
|
-
return
|
|
1776
|
+
return v.value.trim() ? void 0 : `${key} is empty`;
|
|
1772
1777
|
}
|
|
1773
1778
|
case "url": {
|
|
1774
|
-
let
|
|
1775
|
-
return
|
|
1779
|
+
let v = json(raw);
|
|
1780
|
+
return v.ok && isUrl(v.value) ? void 0 : `${key} must be a quoted http or https address`;
|
|
1776
1781
|
}
|
|
1777
1782
|
case "tags": {
|
|
1778
|
-
let
|
|
1779
|
-
return
|
|
1783
|
+
let v = json(raw);
|
|
1784
|
+
return v.ok && Array.isArray(v.value) && v.value.every((t) => typeof t === "string") ? void 0 : `${key} must be a list of quoted strings, like ["seo"]`;
|
|
1780
1785
|
}
|
|
1781
1786
|
case "urls": {
|
|
1782
|
-
let
|
|
1783
|
-
return
|
|
1787
|
+
let v = json(raw);
|
|
1788
|
+
return v.ok && Array.isArray(v.value) && v.value.every(isUrl) ? void 0 : `${key} must be a list of quoted http or https addresses`;
|
|
1784
1789
|
}
|
|
1785
1790
|
case "faq": {
|
|
1786
|
-
let
|
|
1787
|
-
return
|
|
1791
|
+
let v = json(raw);
|
|
1792
|
+
return v.ok && Array.isArray(v.value) && v.value.every((f) => f !== null && typeof f === "object" && filled(f.q) && filled(f.a)) ? void 0 : `${key} must be one line of JSON like [{"q": "A question?", "a": "An answer."}]`;
|
|
1788
1793
|
}
|
|
1789
1794
|
}
|
|
1790
1795
|
}
|
|
1791
|
-
function proseOnly(
|
|
1796
|
+
function proseOnly(body) {
|
|
1792
1797
|
let out = [], fence;
|
|
1793
|
-
for (let line of
|
|
1798
|
+
for (let line of body.split(`
|
|
1794
1799
|
`)) {
|
|
1795
1800
|
let open = /^\s{0,3}(`{3,}|~{3,})/.exec(line);
|
|
1796
1801
|
if (fence) {
|
|
@@ -1809,9 +1814,9 @@ function proseOnly(body2) {
|
|
|
1809
1814
|
function inspectPost(fileName, text, format) {
|
|
1810
1815
|
let preset = BLOG_PRESETS[format], problems = [], base = fileName.endsWith(preset.ext) ? fileName.slice(0, fileName.length - preset.ext.length) : fileName.replace(/\.[^.]*$/, ""), fileSlug = base, fileDate;
|
|
1811
1816
|
if (preset.datedFileKey) {
|
|
1812
|
-
let
|
|
1813
|
-
if (
|
|
1814
|
-
fileDate =
|
|
1817
|
+
let m = JEKYLL_FILE.exec(base);
|
|
1818
|
+
if (m)
|
|
1819
|
+
fileDate = m[1], fileSlug = m[2];
|
|
1815
1820
|
else
|
|
1816
1821
|
problems.push("file name must look like YYYY-MM-DD-<slug>.md");
|
|
1817
1822
|
}
|
|
@@ -1824,14 +1829,14 @@ function inspectPost(fileName, text, format) {
|
|
|
1824
1829
|
for (let line of lines.slice(1, end)) {
|
|
1825
1830
|
if (!line.trim())
|
|
1826
1831
|
continue;
|
|
1827
|
-
let
|
|
1828
|
-
if (!
|
|
1832
|
+
let m = /^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(line);
|
|
1833
|
+
if (!m) {
|
|
1829
1834
|
problems.push(`front matter line is not "key: value": ${line.trim()}`);
|
|
1830
1835
|
continue;
|
|
1831
1836
|
}
|
|
1832
|
-
if (raws.has(
|
|
1833
|
-
problems.push(`${
|
|
1834
|
-
raws.set(
|
|
1837
|
+
if (raws.has(m[1]))
|
|
1838
|
+
problems.push(`${m[1]} appears more than once`);
|
|
1839
|
+
raws.set(m[1], m[2].trim());
|
|
1835
1840
|
}
|
|
1836
1841
|
let values = {};
|
|
1837
1842
|
for (let [key, spec] of Object.entries(preset.keys)) {
|
|
@@ -1849,13 +1854,13 @@ function inspectPost(fileName, text, format) {
|
|
|
1849
1854
|
}
|
|
1850
1855
|
let slug = fileSlug;
|
|
1851
1856
|
if (preset.slugKey) {
|
|
1852
|
-
let
|
|
1853
|
-
if (
|
|
1854
|
-
if (!SLUG.test(
|
|
1855
|
-
problems.push(`${preset.slugKey} "${
|
|
1856
|
-
else if (
|
|
1857
|
-
problems.push(`${preset.slugKey} "${
|
|
1858
|
-
slug =
|
|
1857
|
+
let v = json(raws.get(preset.slugKey) ?? "");
|
|
1858
|
+
if (v.ok && typeof v.value === "string" && v.value) {
|
|
1859
|
+
if (!SLUG.test(v.value))
|
|
1860
|
+
problems.push(`${preset.slugKey} "${v.value}" must be lowercase words joined by hyphens`);
|
|
1861
|
+
else if (v.value !== fileSlug)
|
|
1862
|
+
problems.push(`${preset.slugKey} "${v.value}" does not match the file name "${fileSlug}"`);
|
|
1863
|
+
slug = v.value;
|
|
1859
1864
|
}
|
|
1860
1865
|
}
|
|
1861
1866
|
if (preset.datedFileKey && fileDate) {
|
|
@@ -1863,17 +1868,17 @@ function inspectPost(fileName, text, format) {
|
|
|
1863
1868
|
if (date && DATE.test(date) && date !== fileDate)
|
|
1864
1869
|
problems.push(`${preset.datedFileKey} ${date} does not match the file name date ${fileDate}`);
|
|
1865
1870
|
}
|
|
1866
|
-
let
|
|
1867
|
-
`), fields = { slug, values, body
|
|
1868
|
-
if (!
|
|
1871
|
+
let body = lines.slice(end + 1).join(`
|
|
1872
|
+
`), fields = { slug, values, body };
|
|
1873
|
+
if (!body.trim())
|
|
1869
1874
|
return problems.push("the post has no body"), { slug, problems, fields };
|
|
1870
|
-
let prose = proseOnly(
|
|
1871
|
-
`).find((
|
|
1875
|
+
let prose = proseOnly(body), first = body.split(`
|
|
1876
|
+
`).find((l) => l.trim());
|
|
1872
1877
|
if (first && /^\s{0,3}#(?:\s|$)/.test(first))
|
|
1873
1878
|
problems.push("the body starts with a # heading; the title comes from front matter");
|
|
1874
|
-
if (!prose.some((
|
|
1879
|
+
if (!prose.some((l) => /^\s{0,3}## /.test(l)))
|
|
1875
1880
|
problems.push("the body needs at least one ## heading");
|
|
1876
|
-
if (prose.some((
|
|
1881
|
+
if (prose.some((l) => HTML_TAG.test(l)))
|
|
1877
1882
|
problems.push("the body has raw HTML outside code; use Markdown instead");
|
|
1878
1883
|
return { slug, problems, fields };
|
|
1879
1884
|
}
|
|
@@ -1891,7 +1896,7 @@ function checkBlog(opts) {
|
|
|
1891
1896
|
posts: 0,
|
|
1892
1897
|
problems: [{ file: dir, problem: "is not a folder" }]
|
|
1893
1898
|
};
|
|
1894
|
-
names = readdirSync(abs, { withFileTypes: !0 }).filter((
|
|
1899
|
+
names = readdirSync(abs, { withFileTypes: !0 }).filter((e) => e.isFile() && e.name.endsWith(preset.ext)).map((e) => e.name).sort();
|
|
1895
1900
|
} catch {
|
|
1896
1901
|
return {
|
|
1897
1902
|
dir,
|
|
@@ -1935,17 +1940,17 @@ import os from "node:os";
|
|
|
1935
1940
|
import path from "node:path";
|
|
1936
1941
|
var DEFAULT_URL = "https://app.lopebase.com";
|
|
1937
1942
|
function workspaceUrl(input) {
|
|
1938
|
-
let
|
|
1939
|
-
if (!
|
|
1943
|
+
let v = input.trim().replace(/\/+$/, "");
|
|
1944
|
+
if (!v)
|
|
1940
1945
|
return null;
|
|
1941
|
-
if (/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(
|
|
1942
|
-
return `https://${
|
|
1943
|
-
let withScheme = /^https?:\/\//i.test(
|
|
1946
|
+
if (/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(v))
|
|
1947
|
+
return `https://${v.toLowerCase()}.lopebase.com`;
|
|
1948
|
+
let withScheme = /^https?:\/\//i.test(v) ? v : `https://${v}`;
|
|
1944
1949
|
try {
|
|
1945
|
-
let
|
|
1946
|
-
if (!
|
|
1950
|
+
let u = new URL(withScheme);
|
|
1951
|
+
if (!u.hostname.includes(".") && u.hostname !== "localhost")
|
|
1947
1952
|
return null;
|
|
1948
|
-
return `${
|
|
1953
|
+
return `${u.origin}${u.pathname.replace(/\/+$/, "")}`;
|
|
1949
1954
|
} catch {
|
|
1950
1955
|
return null;
|
|
1951
1956
|
}
|
|
@@ -1995,7 +2000,7 @@ var APP_SIDE_ENV = /^(NEXT_PUBLIC_|PUBLIC_|VITE_|NUXT_PUBLIC_|EXPO_PUBLIC_|REACT
|
|
|
1995
2000
|
function evidenceFor(facts, rule) {
|
|
1996
2001
|
let out = [], weak = [];
|
|
1997
2002
|
for (let re of rule.deps ?? []) {
|
|
1998
|
-
let hit = facts.dependencies.find((
|
|
2003
|
+
let hit = facts.dependencies.find((d) => re.test(d));
|
|
1999
2004
|
if (hit)
|
|
2000
2005
|
out.push(`uses ${hit.replace(/^(py|gem|composer|go|cargo):/, "")}`);
|
|
2001
2006
|
}
|
|
@@ -2005,7 +2010,7 @@ function evidenceFor(facts, rule) {
|
|
|
2005
2010
|
out.push(`has ${hit.replace(/#.*$/, "")}`);
|
|
2006
2011
|
}
|
|
2007
2012
|
for (let re of rule.env ?? []) {
|
|
2008
|
-
let hit = facts.envKeys.find((
|
|
2013
|
+
let hit = facts.envKeys.find((k) => re.test(k));
|
|
2009
2014
|
if (hit)
|
|
2010
2015
|
(APP_SIDE_ENV.test(hit) ? out : weak).push(`env ${hit}`);
|
|
2011
2016
|
}
|
|
@@ -2587,11 +2592,11 @@ var QUEUES = [
|
|
|
2587
2592
|
[/^py:celery$/, "Job queue (Celery)"],
|
|
2588
2593
|
[/^gem:sidekiq$/, "Job queue (Sidekiq)"]
|
|
2589
2594
|
], NOT_A_SERVICE = /* @__PURE__ */ new Set(["Prisma", "Drizzle"]);
|
|
2590
|
-
function watchList(
|
|
2595
|
+
function watchList(d, facts) {
|
|
2591
2596
|
let slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""), out = [];
|
|
2592
|
-
if (
|
|
2597
|
+
if (d.sources.some((s) => s.source === "uptime") || facts.siteUrl)
|
|
2593
2598
|
out.push({ id: "site", label: facts.siteUrl ?? "Website", how: "address" });
|
|
2594
|
-
for (let s of
|
|
2599
|
+
for (let s of d.stack)
|
|
2595
2600
|
if (s.kind === "database" && !NOT_A_SERVICE.has(s.name))
|
|
2596
2601
|
out.push({ id: slug(s.name), label: s.name, how: "service" });
|
|
2597
2602
|
for (let [re, label] of QUEUES)
|
|
@@ -2601,7 +2606,7 @@ function watchList(d3, facts) {
|
|
|
2601
2606
|
label,
|
|
2602
2607
|
how: "service"
|
|
2603
2608
|
});
|
|
2604
|
-
let email =
|
|
2609
|
+
let email = d.stack.find((s) => s.kind === "email" && s.name !== "Nodemailer");
|
|
2605
2610
|
if (email)
|
|
2606
2611
|
out.push({
|
|
2607
2612
|
id: "email",
|
|
@@ -2609,7 +2614,7 @@ function watchList(d3, facts) {
|
|
|
2609
2614
|
how: "service"
|
|
2610
2615
|
});
|
|
2611
2616
|
let seen = /* @__PURE__ */ new Set;
|
|
2612
|
-
return out.filter((
|
|
2617
|
+
return out.filter((w) => !seen.has(w.id) && seen.add(w.id));
|
|
2613
2618
|
}
|
|
2614
2619
|
|
|
2615
2620
|
// src/device-login.ts
|
|
@@ -2626,27 +2631,27 @@ async function startDeviceLogin(url, opts = {}) {
|
|
|
2626
2631
|
});
|
|
2627
2632
|
if (!res.ok)
|
|
2628
2633
|
return null;
|
|
2629
|
-
let
|
|
2630
|
-
if (typeof
|
|
2634
|
+
let b = await res.json();
|
|
2635
|
+
if (typeof b.device_code !== "string" || typeof b.user_code !== "string")
|
|
2631
2636
|
return null;
|
|
2632
2637
|
return {
|
|
2633
|
-
deviceCode:
|
|
2634
|
-
userCode:
|
|
2635
|
-
verifyUrl: String(
|
|
2636
|
-
interval: Number(
|
|
2637
|
-
expiresIn: Number(
|
|
2638
|
+
deviceCode: b.device_code,
|
|
2639
|
+
userCode: b.user_code,
|
|
2640
|
+
verifyUrl: String(b.verification_uri_complete ?? b.verification_uri),
|
|
2641
|
+
interval: Number(b.interval) || 5,
|
|
2642
|
+
expiresIn: Number(b.expires_in) || 600
|
|
2638
2643
|
};
|
|
2639
2644
|
} catch {
|
|
2640
2645
|
return null;
|
|
2641
2646
|
}
|
|
2642
2647
|
}
|
|
2643
2648
|
async function pollDeviceLogin(url, start, opts = {}) {
|
|
2644
|
-
let f = opts.fetchImpl ?? fetch, sleep = opts.sleep ?? ((ms) => new Promise((
|
|
2649
|
+
let f = opts.fetchImpl ?? fetch, sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))), interval = start.interval, deadline = Date.now() + start.expiresIn * 1000;
|
|
2645
2650
|
while (Date.now() < deadline) {
|
|
2646
2651
|
await sleep(interval * 1000);
|
|
2647
|
-
let
|
|
2652
|
+
let body;
|
|
2648
2653
|
try {
|
|
2649
|
-
|
|
2654
|
+
body = await (await f(`${url}/api/oauth/token`, {
|
|
2650
2655
|
method: "POST",
|
|
2651
2656
|
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
2652
2657
|
body: new URLSearchParams({
|
|
@@ -2657,14 +2662,14 @@ async function pollDeviceLogin(url, start, opts = {}) {
|
|
|
2657
2662
|
} catch {
|
|
2658
2663
|
continue;
|
|
2659
2664
|
}
|
|
2660
|
-
if (typeof
|
|
2665
|
+
if (typeof body.access_token === "string")
|
|
2661
2666
|
return {
|
|
2662
2667
|
ok: !0,
|
|
2663
|
-
token:
|
|
2664
|
-
url: typeof
|
|
2665
|
-
scope: String(
|
|
2668
|
+
token: body.access_token,
|
|
2669
|
+
url: typeof body.workspace_url === "string" ? body.workspace_url : url,
|
|
2670
|
+
scope: String(body.scope ?? "")
|
|
2666
2671
|
};
|
|
2667
|
-
switch (
|
|
2672
|
+
switch (body.error) {
|
|
2668
2673
|
case "authorization_pending":
|
|
2669
2674
|
continue;
|
|
2670
2675
|
case "slow_down":
|
|
@@ -2686,7 +2691,7 @@ async function pollDeviceLogin(url, start, opts = {}) {
|
|
|
2686
2691
|
return {
|
|
2687
2692
|
ok: !1,
|
|
2688
2693
|
reason: "error",
|
|
2689
|
-
message: String(
|
|
2694
|
+
message: String(body.error_description ?? body.error ?? "Sign-in failed.")
|
|
2690
2695
|
};
|
|
2691
2696
|
}
|
|
2692
2697
|
}
|
|
@@ -2697,6 +2702,25 @@ async function pollDeviceLogin(url, start, opts = {}) {
|
|
|
2697
2702
|
};
|
|
2698
2703
|
}
|
|
2699
2704
|
|
|
2705
|
+
// src/headless.ts
|
|
2706
|
+
function canPrompt(stdin = process.stdin, stdout = process.stdout) {
|
|
2707
|
+
return Boolean(stdin.isTTY && stdout.isTTY);
|
|
2708
|
+
}
|
|
2709
|
+
function headlessHelp() {
|
|
2710
|
+
return `npx lopebase needs an interactive terminal to sign in, and this one is not (no TTY).
|
|
2711
|
+
|
|
2712
|
+
For a coding agent or a script:
|
|
2713
|
+
npx lopebase prompt print the setup prompt, with this project's scan
|
|
2714
|
+
npx lopebase scan --json print the scan as JSON
|
|
2715
|
+
Add the MCP server https://app.lopebase.com/api/mcp to your agent. It opens
|
|
2716
|
+
a browser page for the person to approve.
|
|
2717
|
+
Or set LOPEBASE_TOKEN to an agent token (Agents, Access in LopeBase) and
|
|
2718
|
+
register "npx -y lopebase mcp" as a stdio MCP server.
|
|
2719
|
+
|
|
2720
|
+
To connect this computer, a person runs "npx lopebase login" in their own terminal.
|
|
2721
|
+
More: https://lopebase.com/docs/npx-lopebase#headless`;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2700
2724
|
// src/mcp-proxy.ts
|
|
2701
2725
|
import { createInterface as createInterface2 } from "node:readline";
|
|
2702
2726
|
async function runMcpProxy(auth, fetchImpl = fetch) {
|
|
@@ -2755,7 +2779,7 @@ async function runMcpProxy(auth, fetchImpl = fetch) {
|
|
|
2755
2779
|
}
|
|
2756
2780
|
process.stdout.write(`${text}
|
|
2757
2781
|
`);
|
|
2758
|
-
} catch (
|
|
2782
|
+
} catch (e) {
|
|
2759
2783
|
if (id === null)
|
|
2760
2784
|
return;
|
|
2761
2785
|
write({
|
|
@@ -2763,7 +2787,7 @@ async function runMcpProxy(auth, fetchImpl = fetch) {
|
|
|
2763
2787
|
id,
|
|
2764
2788
|
error: {
|
|
2765
2789
|
code: -32000,
|
|
2766
|
-
message: `Could not reach LopeBase at ${endpoint}: ${String(
|
|
2790
|
+
message: `Could not reach LopeBase at ${endpoint}: ${String(e)}`
|
|
2767
2791
|
}
|
|
2768
2792
|
});
|
|
2769
2793
|
}
|
|
@@ -2781,7 +2805,7 @@ function onboardingPrompt(input) {
|
|
|
2781
2805
|
`- Stack: ${stack}`,
|
|
2782
2806
|
`- Already in use: ${found.map((s) => s.label).join(", ") || "none of the sources LopeBase reads"}`,
|
|
2783
2807
|
`- The human wants connected: ${chosen.join(", ") || "whatever get_onboarding_status recommends"}`,
|
|
2784
|
-
`- Worth watching for uptime: ${(input.watch ?? []).map((
|
|
2808
|
+
`- Worth watching for uptime: ${(input.watch ?? []).map((w) => `${w.label} (${w.how === "address" ? "uptime check on its address" : "adapter health service"})`).join(", ") || "the site, if it has one"}`,
|
|
2785
2809
|
`- LopeBase pageviews: ${input.pageviews ? "yes, the human wants them" : "not chosen; offer once, do not push"}`,
|
|
2786
2810
|
"",
|
|
2787
2811
|
"How to work:",
|
|
@@ -2855,15 +2879,15 @@ var MONOREPO_DIRS = ["apps", "packages", "services", "sites", "web", "site"], SK
|
|
|
2855
2879
|
".github/workflows",
|
|
2856
2880
|
"content/config.ts"
|
|
2857
2881
|
], EXAMPLE_ENV = /^(\.env\.(example|sample|template|dist|local\.example|development\.example|production\.example)|example\.env|\.dev\.vars\.example)$/;
|
|
2858
|
-
function readText(
|
|
2882
|
+
function readText(file) {
|
|
2859
2883
|
try {
|
|
2860
|
-
return readFileSync3(
|
|
2884
|
+
return readFileSync3(file, "utf8");
|
|
2861
2885
|
} catch {
|
|
2862
2886
|
return null;
|
|
2863
2887
|
}
|
|
2864
2888
|
}
|
|
2865
|
-
function readJson(
|
|
2866
|
-
let text = readText(
|
|
2889
|
+
function readJson(file) {
|
|
2890
|
+
let text = readText(file);
|
|
2867
2891
|
if (text === null)
|
|
2868
2892
|
return null;
|
|
2869
2893
|
try {
|
|
@@ -2872,9 +2896,9 @@ function readJson(file2) {
|
|
|
2872
2896
|
return null;
|
|
2873
2897
|
}
|
|
2874
2898
|
}
|
|
2875
|
-
function isDir(
|
|
2899
|
+
function isDir(p) {
|
|
2876
2900
|
try {
|
|
2877
|
-
return statSync2(
|
|
2901
|
+
return statSync2(p).isDirectory();
|
|
2878
2902
|
} catch {
|
|
2879
2903
|
return !1;
|
|
2880
2904
|
}
|
|
@@ -2899,14 +2923,14 @@ function isPackage(dir) {
|
|
|
2899
2923
|
}
|
|
2900
2924
|
function workspaceGlobs(root) {
|
|
2901
2925
|
let globs = [], ws = readJson(path2.join(root, "package.json"))?.workspaces, list = Array.isArray(ws) ? ws : ws && typeof ws === "object" && Array.isArray(ws.packages) ? ws.packages : [];
|
|
2902
|
-
for (let
|
|
2903
|
-
if (typeof
|
|
2904
|
-
globs.push(
|
|
2926
|
+
for (let g of list)
|
|
2927
|
+
if (typeof g === "string")
|
|
2928
|
+
globs.push(g);
|
|
2905
2929
|
let pnpm = readText(path2.join(root, "pnpm-workspace.yaml"));
|
|
2906
2930
|
if (pnpm)
|
|
2907
|
-
for (let
|
|
2908
|
-
globs.push(
|
|
2909
|
-
return globs.filter((
|
|
2931
|
+
for (let m of pnpm.matchAll(/^\s*-\s*["']?([^"'\s#]+)["']?/gm))
|
|
2932
|
+
globs.push(m[1]);
|
|
2933
|
+
return globs.filter((g) => !g.startsWith("!"));
|
|
2910
2934
|
}
|
|
2911
2935
|
function expandGlob(root, glob) {
|
|
2912
2936
|
let clean = glob.replace(/\/\*\*$/, "/*").replace(/\/$/, "");
|
|
@@ -2915,24 +2939,24 @@ function expandGlob(root, glob) {
|
|
|
2915
2939
|
return isDir(dir) ? [dir] : [];
|
|
2916
2940
|
}
|
|
2917
2941
|
let [base] = clean.split("*"), parent = path2.join(root, base);
|
|
2918
|
-
return listDir(parent).filter((
|
|
2942
|
+
return listDir(parent).filter((e) => !SKIP_DIRS.has(e) && !e.startsWith(".")).map((e) => path2.join(parent, e)).filter(isDir);
|
|
2919
2943
|
}
|
|
2920
2944
|
function packageDirs(root) {
|
|
2921
2945
|
let dirs = /* @__PURE__ */ new Set([root]);
|
|
2922
|
-
for (let
|
|
2923
|
-
for (let
|
|
2924
|
-
if (isPackage(
|
|
2925
|
-
dirs.add(
|
|
2946
|
+
for (let g of workspaceGlobs(root))
|
|
2947
|
+
for (let d of expandGlob(root, g))
|
|
2948
|
+
if (isPackage(d))
|
|
2949
|
+
dirs.add(d);
|
|
2926
2950
|
for (let group of MONOREPO_DIRS) {
|
|
2927
|
-
let
|
|
2928
|
-
if (!isDir(
|
|
2951
|
+
let g = path2.join(root, group);
|
|
2952
|
+
if (!isDir(g))
|
|
2929
2953
|
continue;
|
|
2930
|
-
if (isPackage(
|
|
2931
|
-
dirs.add(
|
|
2932
|
-
for (let entry of listDir(
|
|
2933
|
-
let
|
|
2934
|
-
if (!SKIP_DIRS.has(entry) && isDir(
|
|
2935
|
-
dirs.add(
|
|
2954
|
+
if (isPackage(g))
|
|
2955
|
+
dirs.add(g);
|
|
2956
|
+
for (let entry of listDir(g)) {
|
|
2957
|
+
let d = path2.join(g, entry);
|
|
2958
|
+
if (!SKIP_DIRS.has(entry) && isDir(d) && isPackage(d))
|
|
2959
|
+
dirs.add(d);
|
|
2936
2960
|
}
|
|
2937
2961
|
}
|
|
2938
2962
|
return [...dirs].slice(0, MAX_PACKAGES);
|
|
@@ -2940,36 +2964,36 @@ function packageDirs(root) {
|
|
|
2940
2964
|
function pythonRequirements(text) {
|
|
2941
2965
|
let out = [];
|
|
2942
2966
|
for (let line of text.split(/\r?\n/)) {
|
|
2943
|
-
let
|
|
2944
|
-
if (
|
|
2945
|
-
out.push(
|
|
2967
|
+
let m = /^\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(line.replace(/#.*/, ""));
|
|
2968
|
+
if (m && !line.trim().startsWith("-"))
|
|
2969
|
+
out.push(m[1].toLowerCase());
|
|
2946
2970
|
}
|
|
2947
2971
|
return out;
|
|
2948
2972
|
}
|
|
2949
2973
|
function pythonProjectDeps(text) {
|
|
2950
2974
|
let out = /* @__PURE__ */ new Set;
|
|
2951
2975
|
for (let block of text.matchAll(/(?:^|\n)\s*dependencies\s*=\s*\[([\s\S]*?)\]/g))
|
|
2952
|
-
for (let
|
|
2953
|
-
out.add(
|
|
2976
|
+
for (let m of block[1].matchAll(/["']([A-Za-z0-9][A-Za-z0-9._-]*)/g))
|
|
2977
|
+
out.add(m[1].toLowerCase());
|
|
2954
2978
|
for (let table of text.matchAll(/\[(?:tool\.poetry\.(?:group\.[a-z]+\.)?dependencies|(?:dev-)?packages)\]([\s\S]*?)(?=\n\[|$)/g))
|
|
2955
|
-
for (let
|
|
2956
|
-
out.add(
|
|
2979
|
+
for (let m of table[1].matchAll(/^\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*=/gm))
|
|
2980
|
+
out.add(m[1].toLowerCase());
|
|
2957
2981
|
return out.delete("python"), [...out];
|
|
2958
2982
|
}
|
|
2959
2983
|
function gemfileDeps(text) {
|
|
2960
|
-
return [...text.matchAll(/^\s*gem\s+["']([^"']+)["']/gm)].map((
|
|
2984
|
+
return [...text.matchAll(/^\s*gem\s+["']([^"']+)["']/gm)].map((m) => m[1]);
|
|
2961
2985
|
}
|
|
2962
2986
|
function goModDeps(text) {
|
|
2963
2987
|
let out = [];
|
|
2964
|
-
for (let
|
|
2965
|
-
out.push(
|
|
2988
|
+
for (let m of text.matchAll(/^\s*(?:require\s+)?([a-z0-9.-]+\.[a-z]+\/[^\s]+)\s+v[0-9]/gm))
|
|
2989
|
+
out.push(m[1]);
|
|
2966
2990
|
return out;
|
|
2967
2991
|
}
|
|
2968
2992
|
function cargoDeps(text) {
|
|
2969
2993
|
let out = [];
|
|
2970
2994
|
for (let table of text.matchAll(/\[(?:dev-|build-)?dependencies\]([\s\S]*?)(?=\n\[|$)/g))
|
|
2971
|
-
for (let
|
|
2972
|
-
out.push(
|
|
2995
|
+
for (let m of table[1].matchAll(/^\s*([A-Za-z0-9_-]+)\s*=/gm))
|
|
2996
|
+
out.push(m[1]);
|
|
2973
2997
|
return out;
|
|
2974
2998
|
}
|
|
2975
2999
|
function manifestDeps(dir) {
|
|
@@ -2988,10 +3012,10 @@ function manifestDeps(dir) {
|
|
|
2988
3012
|
if (gem)
|
|
2989
3013
|
add("gem", gemfileDeps(gem));
|
|
2990
3014
|
let composer = readJson(path2.join(dir, "composer.json"));
|
|
2991
|
-
for (let
|
|
2992
|
-
let
|
|
2993
|
-
if (
|
|
2994
|
-
add("composer", Object.keys(
|
|
3015
|
+
for (let k of ["require", "require-dev"]) {
|
|
3016
|
+
let d = composer?.[k];
|
|
3017
|
+
if (d && typeof d === "object")
|
|
3018
|
+
add("composer", Object.keys(d));
|
|
2995
3019
|
}
|
|
2996
3020
|
let gomod = readText(path2.join(dir, "go.mod"));
|
|
2997
3021
|
if (gomod)
|
|
@@ -3005,7 +3029,7 @@ function siteFromWrangler(text) {
|
|
|
3005
3029
|
let first = [
|
|
3006
3030
|
...text.matchAll(/(?:pattern|route)["']?\s*[:=]\s*["']([^"'*/\s]+)/g),
|
|
3007
3031
|
...text.matchAll(/custom_domain["']?\s*[:=]\s*["']([^"'*/\s]+)/g)
|
|
3008
|
-
].map((
|
|
3032
|
+
].map((m) => m[1].toLowerCase()).filter((h) => h.includes(".") && !h.endsWith("workers.dev"))[0];
|
|
3009
3033
|
if (!first)
|
|
3010
3034
|
return;
|
|
3011
3035
|
return `https://${first.replace(/^(app|www|api|console)\./, "")}`;
|
|
@@ -3013,26 +3037,26 @@ function siteFromWrangler(text) {
|
|
|
3013
3037
|
var NOT_A_SITE = /(^|\.)(localhost|example\.(com|org)|your-?(site|domain)\.[a-z]+|vercel\.app|netlify\.app|pages\.dev|workers\.dev|github\.com|gitlab\.com|npmjs\.com)$/;
|
|
3014
3038
|
function publicSite(url) {
|
|
3015
3039
|
try {
|
|
3016
|
-
let
|
|
3017
|
-
if (!
|
|
3040
|
+
let u = new URL(url.startsWith("http") ? url : `https://${url}`);
|
|
3041
|
+
if (!u.hostname.includes(".") || NOT_A_SITE.test(u.hostname))
|
|
3018
3042
|
return;
|
|
3019
|
-
return `https://${
|
|
3043
|
+
return `https://${u.hostname.replace(/^www\./, "")}`;
|
|
3020
3044
|
} catch {
|
|
3021
3045
|
return;
|
|
3022
3046
|
}
|
|
3023
3047
|
}
|
|
3024
3048
|
function siteFromConfig(text) {
|
|
3025
|
-
let
|
|
3026
|
-
return
|
|
3049
|
+
let m = /\b(?:site|siteUrl|baseURL|baseUrl|url)\s*[:=]\s*["'`](https?:\/\/[^"'`\s]+)["'`]/.exec(text);
|
|
3050
|
+
return m ? publicSite(m[1]) : void 0;
|
|
3027
3051
|
}
|
|
3028
3052
|
function githubRepo(gitConfig) {
|
|
3029
3053
|
let remotes = [
|
|
3030
3054
|
...gitConfig.matchAll(/\[remote "([^"]+)"\][^[]*?url\s*=\s*(\S+)/g)
|
|
3031
|
-
].sort((a,
|
|
3055
|
+
].sort((a, b) => Number(b[1] === "origin") - Number(a[1] === "origin"));
|
|
3032
3056
|
for (let [, , url] of remotes) {
|
|
3033
|
-
let
|
|
3034
|
-
if (
|
|
3035
|
-
return `${
|
|
3057
|
+
let m = /github\.com[:/]([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/.exec(url);
|
|
3058
|
+
if (m)
|
|
3059
|
+
return `${m[1]}/${m[2]}`;
|
|
3036
3060
|
}
|
|
3037
3061
|
return;
|
|
3038
3062
|
}
|
|
@@ -3047,21 +3071,21 @@ function readGitConfig(root) {
|
|
|
3047
3071
|
return readText(path2.join(gitDir, "config")) ?? readText(path2.join(gitDir, "..", "..", "config"));
|
|
3048
3072
|
}
|
|
3049
3073
|
function siteFromHtml(html) {
|
|
3050
|
-
let
|
|
3051
|
-
return
|
|
3074
|
+
let m = /<link[^>]+rel=["']canonical["'][^>]+href=["'](https?:\/\/[^"']+)/i.exec(html) ?? /<link[^>]+href=["'](https?:\/\/[^"']+)["'][^>]+rel=["']canonical["']/i.exec(html) ?? /<meta[^>]+property=["']og:url["'][^>]+content=["'](https?:\/\/[^"']+)/i.exec(html);
|
|
3075
|
+
return m ? publicSite(m[1]) : void 0;
|
|
3052
3076
|
}
|
|
3053
3077
|
function envKeyNames(text) {
|
|
3054
3078
|
let out = [];
|
|
3055
3079
|
for (let line of text.split(/\r?\n/)) {
|
|
3056
|
-
let
|
|
3057
|
-
if (
|
|
3058
|
-
out.push(
|
|
3080
|
+
let m = /^\s*(?:#\s*)?(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=/.exec(line);
|
|
3081
|
+
if (m)
|
|
3082
|
+
out.push(m[1]);
|
|
3059
3083
|
}
|
|
3060
3084
|
return out;
|
|
3061
3085
|
}
|
|
3062
3086
|
var SITE_CONFIGS = /^(astro\.config\.\w+|next-sitemap\.config\.\w+|gatsby-config\.\w+|docusaurus\.config\.\w+|hugo\.toml|config\.toml|_config\.ya?ml|nuxt\.config\.\w+)$/;
|
|
3063
3087
|
function scanProject(root, onProgress) {
|
|
3064
|
-
let deps = /* @__PURE__ */ new Set, files = /* @__PURE__ */ new Set, envKeys = /* @__PURE__ */ new Set, name, siteUrl, dirs = packageDirs(root), relDir = (
|
|
3088
|
+
let deps = /* @__PURE__ */ new Set, files = /* @__PURE__ */ new Set, envKeys = /* @__PURE__ */ new Set, name, siteUrl, dirs = packageDirs(root), relDir = (d) => path2.relative(root, d).split(path2.sep).join("/") || ".";
|
|
3065
3089
|
onProgress?.({
|
|
3066
3090
|
label: `Found ${dirs.length} ${dirs.length === 1 ? "package" : "packages"}`,
|
|
3067
3091
|
detail: dirs.length > 1 ? dirs.map(relDir).join(", ") : void 0
|
|
@@ -3074,22 +3098,22 @@ function scanProject(root, onProgress) {
|
|
|
3074
3098
|
name = pkg.name;
|
|
3075
3099
|
if (!siteUrl && typeof pkg.homepage === "string")
|
|
3076
3100
|
siteUrl = publicSite(pkg.homepage);
|
|
3077
|
-
for (let
|
|
3078
|
-
let
|
|
3079
|
-
if (
|
|
3080
|
-
for (let n of Object.keys(
|
|
3101
|
+
for (let k of ["dependencies", "devDependencies"]) {
|
|
3102
|
+
let d = pkg[k];
|
|
3103
|
+
if (d && typeof d === "object")
|
|
3104
|
+
for (let n of Object.keys(d))
|
|
3081
3105
|
deps.add(n);
|
|
3082
3106
|
}
|
|
3083
3107
|
}
|
|
3084
|
-
for (let
|
|
3085
|
-
deps.add(
|
|
3108
|
+
for (let d of manifestDeps(dir))
|
|
3109
|
+
deps.add(d);
|
|
3086
3110
|
for (let entry of listDir(dir)) {
|
|
3087
3111
|
if (EXAMPLE_ENV.test(entry)) {
|
|
3088
3112
|
let text = readText(path2.join(dir, entry));
|
|
3089
3113
|
if (text) {
|
|
3090
3114
|
envFiles++;
|
|
3091
|
-
for (let
|
|
3092
|
-
envKeys.add(
|
|
3115
|
+
for (let k of envKeyNames(text))
|
|
3116
|
+
envKeys.add(k);
|
|
3093
3117
|
}
|
|
3094
3118
|
}
|
|
3095
3119
|
if (!MARKERS.some((re) => re.test(entry)))
|
|
@@ -3160,8 +3184,8 @@ function paint(rgb, text, bg = !1) {
|
|
|
3160
3184
|
return text;
|
|
3161
3185
|
if (!trueColor())
|
|
3162
3186
|
return bg ? import_picocolors3.default.bgMagenta(import_picocolors3.default.black(text)) : import_picocolors3.default.magenta(text);
|
|
3163
|
-
let [
|
|
3164
|
-
return `\x1B[${bg ? 48 : 38};2;${
|
|
3187
|
+
let [r, g, b] = rgb;
|
|
3188
|
+
return `\x1B[${bg ? 48 : 38};2;${r};${g};${b}m${text}\x1B[${bg ? 49 : 39}m`;
|
|
3165
3189
|
}
|
|
3166
3190
|
var brand = (text) => paint(BRAND, text), badge = (text) => paint(BRAND, import_picocolors3.default.black(import_picocolors3.default.bold(` ${text} `)), !0), ramp = (i, text) => paint(RAMP[Math.min(i, RAMP.length - 1)], text), MARK = [
|
|
3167
3191
|
" ▗▖ ▗▖ ",
|
|
@@ -3176,7 +3200,7 @@ var brand = (text) => paint(BRAND, text), badge = (text) => paint(BRAND, import_
|
|
|
3176
3200
|
function motionAllowed(argv = process.argv, env = process.env, isTTY = Boolean(process.stdout.isTTY)) {
|
|
3177
3201
|
return isTTY && !env.CI && !env.LOPEBASE_NO_MOTION && env.TERM !== "dumb" && !argv.includes("--no-motion");
|
|
3178
3202
|
}
|
|
3179
|
-
var sleep = (ms) => new Promise((
|
|
3203
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
3180
3204
|
function logoLines(opts) {
|
|
3181
3205
|
let right = {
|
|
3182
3206
|
3: `${import_picocolors3.default.bold("Lope")}${brand("Base")}${opts.version ? import_picocolors3.default.dim(` v${opts.version}`) : ""}`,
|
|
@@ -3197,7 +3221,7 @@ ${lines.join(`
|
|
|
3197
3221
|
`);
|
|
3198
3222
|
return;
|
|
3199
3223
|
}
|
|
3200
|
-
let blank = MARK.map((
|
|
3224
|
+
let blank = MARK.map((r) => " ".repeat(r.length)), frame = (shown) => MARK.map((row, i) => shown.has(i) ? HORIZON.has(i) ? import_picocolors3.default.dim(ramp(i, row)) : ramp(i, row) : blank[i]), up = `\x1B[${MARK.length}A`, onInterrupt = () => {
|
|
3201
3225
|
write(`\x1B[?25h
|
|
3202
3226
|
`), process.exit(130);
|
|
3203
3227
|
};
|
|
@@ -3251,8 +3275,8 @@ function stackRows(detection, facts) {
|
|
|
3251
3275
|
rows.push(["Repo", facts.repo]);
|
|
3252
3276
|
if (!rows.length)
|
|
3253
3277
|
return [import_picocolors3.default.dim("Nothing recognized yet. Your agent will look closer.")];
|
|
3254
|
-
let width = Math.max(...rows.map(([
|
|
3255
|
-
return rows.map(([
|
|
3278
|
+
let width = Math.max(...rows.map(([k]) => k.length));
|
|
3279
|
+
return rows.map(([k, v]) => `${import_picocolors3.default.dim(k.padEnd(width))} ${v}`);
|
|
3256
3280
|
}
|
|
3257
3281
|
var PLAN = [
|
|
3258
3282
|
{
|
|
@@ -3277,13 +3301,13 @@ function planLines() {
|
|
|
3277
3301
|
${import_picocolors3.default.dim(s.detail)}`);
|
|
3278
3302
|
}
|
|
3279
3303
|
function stepRail(n, total = PLAN.length) {
|
|
3280
|
-
return Array.from({ length: total }, (
|
|
3304
|
+
return Array.from({ length: total }, (_, i) => i < n ? brand("◆") : import_picocolors3.default.dim("◇")).join(import_picocolors3.default.dim(" ── "));
|
|
3281
3305
|
}
|
|
3282
3306
|
function stepTitle(n) {
|
|
3283
3307
|
return `${stepRail(n)} ${import_picocolors3.default.dim(`Step ${n} of ${PLAN.length}`)} ${import_picocolors3.default.bold(PLAN[n - 1].title)}`;
|
|
3284
3308
|
}
|
|
3285
3309
|
async function horizon(opts) {
|
|
3286
|
-
let write = opts.write ?? ((s) => process.stdout.write(s)), width = opts.width ?? 28, line = (n) => Array.from({ length: n }, (
|
|
3310
|
+
let write = opts.write ?? ((s) => process.stdout.write(s)), width = opts.width ?? 28, line = (n) => Array.from({ length: n }, (_, i) => ramp(Math.floor(i / width * RAMP.length), "━")).join("");
|
|
3287
3311
|
if (!opts.motion) {
|
|
3288
3312
|
write(` ${line(width)}
|
|
3289
3313
|
`);
|
|
@@ -3295,15 +3319,15 @@ async function horizon(opts) {
|
|
|
3295
3319
|
`);
|
|
3296
3320
|
}
|
|
3297
3321
|
function watchRows(items) {
|
|
3298
|
-
return items.map((
|
|
3322
|
+
return items.map((w) => w.how === "address" ? `${brand("◉")} ${import_picocolors3.default.bold(w.label)} ${import_picocolors3.default.dim("uptime check, every 15 minutes")}` : `${brand("○")} ${import_picocolors3.default.bold(w.label)} ${import_picocolors3.default.dim("a service in the adapter's health list")}`);
|
|
3299
3323
|
}
|
|
3300
3324
|
|
|
3301
3325
|
// src/update.ts
|
|
3302
3326
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
3303
3327
|
import path3 from "node:path";
|
|
3304
|
-
var readJson2 = (
|
|
3328
|
+
var readJson2 = (file) => {
|
|
3305
3329
|
try {
|
|
3306
|
-
return JSON.parse(readFileSync4(
|
|
3330
|
+
return JSON.parse(readFileSync4(file, "utf8"));
|
|
3307
3331
|
} catch {
|
|
3308
3332
|
return null;
|
|
3309
3333
|
}
|
|
@@ -3320,7 +3344,7 @@ function findAdapterInstalls(root) {
|
|
|
3320
3344
|
}["@lopebase/adapter"];
|
|
3321
3345
|
if (!range || range.startsWith("workspace:"))
|
|
3322
3346
|
continue;
|
|
3323
|
-
let installed = [dir, root].map((
|
|
3347
|
+
let installed = [dir, root].map((d) => readJson2(path3.join(d, "node_modules/@lopebase/adapter/package.json"))).find((p) => typeof p?.version === "string")?.version;
|
|
3324
3348
|
out.push({ dir: path3.relative(root, dir) || ".", range, installed });
|
|
3325
3349
|
}
|
|
3326
3350
|
return out;
|
|
@@ -3337,8 +3361,8 @@ async function latestOnNpm(name, timeoutMs = 1500, fetchImpl = fetch) {
|
|
|
3337
3361
|
});
|
|
3338
3362
|
if (!res.ok)
|
|
3339
3363
|
return;
|
|
3340
|
-
let
|
|
3341
|
-
return typeof
|
|
3364
|
+
let body = await res.json();
|
|
3365
|
+
return typeof body.version === "string" ? body.version : void 0;
|
|
3342
3366
|
} catch {
|
|
3343
3367
|
return;
|
|
3344
3368
|
}
|
|
@@ -3382,6 +3406,11 @@ function version() {
|
|
|
3382
3406
|
function bail(message) {
|
|
3383
3407
|
xe(message), process.exit(1);
|
|
3384
3408
|
}
|
|
3409
|
+
function requireTerminal() {
|
|
3410
|
+
if (canPrompt())
|
|
3411
|
+
return;
|
|
3412
|
+
console.error(headlessHelp()), process.exit(1);
|
|
3413
|
+
}
|
|
3385
3414
|
function guard(value) {
|
|
3386
3415
|
if (pD(value))
|
|
3387
3416
|
bail("Stopped. Run lopebase again any time.");
|
|
@@ -3411,12 +3440,12 @@ async function checkToken(auth) {
|
|
|
3411
3440
|
});
|
|
3412
3441
|
if (res.status === 401)
|
|
3413
3442
|
return { ok: !1, message: "That token is not valid or has expired." };
|
|
3414
|
-
let
|
|
3415
|
-
return { ok: !0, products: JSON.parse(
|
|
3416
|
-
} catch (
|
|
3443
|
+
let body = await res.json();
|
|
3444
|
+
return { ok: !0, products: JSON.parse(body.result?.content?.[0]?.text ?? "[]").length };
|
|
3445
|
+
} catch (e) {
|
|
3417
3446
|
return {
|
|
3418
3447
|
ok: !1,
|
|
3419
|
-
message: `Could not reach ${auth.url} (${String(
|
|
3448
|
+
message: `Could not reach ${auth.url} (${String(e)}).`
|
|
3420
3449
|
};
|
|
3421
3450
|
}
|
|
3422
3451
|
}
|
|
@@ -3444,8 +3473,8 @@ async function login() {
|
|
|
3444
3473
|
s.start("Waiting for you to approve in the browser");
|
|
3445
3474
|
let res = await pollDeviceLogin(url, device);
|
|
3446
3475
|
if (res.ok) {
|
|
3447
|
-
let
|
|
3448
|
-
return s.stop(`Connected to ${import_picocolors4.default.bold(res.url)}. Saved to ${import_picocolors4.default.dim(
|
|
3476
|
+
let file = saveAuth({ url: res.url, token: res.token });
|
|
3477
|
+
return s.stop(`Connected to ${import_picocolors4.default.bold(res.url)}. Saved to ${import_picocolors4.default.dim(file)}`), { url: res.url, token: res.token };
|
|
3449
3478
|
}
|
|
3450
3479
|
if (s.stop(import_picocolors4.default.red(res.message)), res.reason === "denied")
|
|
3451
3480
|
bail("Nothing was connected.");
|
|
@@ -3458,47 +3487,47 @@ async function askWorkspace() {
|
|
|
3458
3487
|
return workspaceUrl(guard(await he({
|
|
3459
3488
|
message: "Your LopeBase workspace (name or address)",
|
|
3460
3489
|
placeholder: "yourteam or https://yourteam.lopebase.com",
|
|
3461
|
-
validate: (
|
|
3490
|
+
validate: (v) => workspaceUrl(v ?? "") ? void 0 : "Type your workspace name, like yourteam, or its full address"
|
|
3462
3491
|
})));
|
|
3463
3492
|
}
|
|
3464
3493
|
async function pasteLogin(url) {
|
|
3465
|
-
let settings = `${url}/
|
|
3494
|
+
let settings = `${url}/agents?tab=access`;
|
|
3466
3495
|
Me([
|
|
3467
3496
|
"1. Sign in (or sign up) in the browser tab we open.",
|
|
3468
|
-
`2. Under
|
|
3497
|
+
`2. Under Agents, Access, press ${import_picocolors4.default.bold("Create agent access")}.`,
|
|
3469
3498
|
"3. Copy the token and paste it here. It is saved on this computer only."
|
|
3470
3499
|
].join(`
|
|
3471
3500
|
`), "Get an agent token"), openBrowser(settings), M2.info(import_picocolors4.default.dim(settings));
|
|
3472
3501
|
for (;; ) {
|
|
3473
3502
|
let token = guard(await ge({
|
|
3474
3503
|
message: "Paste the agent token",
|
|
3475
|
-
validate: (
|
|
3504
|
+
validate: (v) => v?.startsWith("lb_agent_") ? void 0 : "Tokens start with lb_agent_"
|
|
3476
3505
|
})).trim(), s = Y2();
|
|
3477
3506
|
s.start("Checking the token");
|
|
3478
3507
|
let check = await checkToken({ url, token });
|
|
3479
3508
|
if (check.ok) {
|
|
3480
|
-
let
|
|
3481
|
-
return s.stop(`Signed in. ${check.products} ${check.products === 1 ? "property" : "properties"} in this workspace. Saved to ${import_picocolors4.default.dim(
|
|
3509
|
+
let file = saveAuth({ url, token });
|
|
3510
|
+
return s.stop(`Signed in. ${check.products} ${check.products === 1 ? "property" : "properties"} in this workspace. Saved to ${import_picocolors4.default.dim(file)}`), { url, token };
|
|
3482
3511
|
}
|
|
3483
3512
|
s.stop(import_picocolors4.default.red(check.message ?? "That did not work."));
|
|
3484
3513
|
}
|
|
3485
3514
|
}
|
|
3486
|
-
async function printDetection(
|
|
3487
|
-
Me(stackRows(
|
|
3515
|
+
async function printDetection(d, facts) {
|
|
3516
|
+
Me(stackRows(d, facts).join(`
|
|
3488
3517
|
`), "Your stack"), await pace(motion, 150);
|
|
3489
|
-
let found =
|
|
3518
|
+
let found = d.sources.filter((s) => s.status === "found");
|
|
3490
3519
|
if (found.length)
|
|
3491
3520
|
Me(found.map((s) => `${import_picocolors4.default.green("●")} ${import_picocolors4.default.bold(s.label)} ${import_picocolors4.default.dim(s.evidence.join(", "))}`).join(`
|
|
3492
3521
|
`), "Already in your code, ready to connect"), await pace(motion, 150);
|
|
3493
|
-
let possible =
|
|
3522
|
+
let possible = d.sources.filter((s) => s.status === "possible");
|
|
3494
3523
|
if (possible.length)
|
|
3495
3524
|
Me(possible.map((s) => `${import_picocolors4.default.yellow("?")} ${import_picocolors4.default.bold(s.label)} ${import_picocolors4.default.dim(`only ${s.evidence.join(", ")}`)}`).join(`
|
|
3496
3525
|
`), "Maybe in use, your agent will check"), await pace(motion, 150);
|
|
3497
|
-
let watch = watchList(
|
|
3526
|
+
let watch = watchList(d, facts);
|
|
3498
3527
|
if (watch.length)
|
|
3499
3528
|
Me(watchRows(watch).join(`
|
|
3500
3529
|
`), "Worth watching for uptime"), await pace(motion, 150);
|
|
3501
|
-
for (let gap of
|
|
3530
|
+
for (let gap of d.gaps)
|
|
3502
3531
|
M2.info(import_picocolors4.default.dim(gap));
|
|
3503
3532
|
}
|
|
3504
3533
|
async function scanWithProgress() {
|
|
@@ -3529,7 +3558,7 @@ function registerMcp(agent) {
|
|
|
3529
3558
|
return res.status === 0 || /already exists/i.test(`${res.stderr}${res.stdout}`);
|
|
3530
3559
|
}
|
|
3531
3560
|
async function init() {
|
|
3532
|
-
if (console.clear(), await showLogo({ tagline: TAGLINE, version: version(), motion }), await horizon({ motion }), Ie(`${badge("LopeBase")} set up this project`), await noticeNewerCli(), Me(planLines().join(`
|
|
3561
|
+
if (requireTerminal(), console.clear(), await showLogo({ tagline: TAGLINE, version: version(), motion }), await horizon({ motion }), Ie(`${badge("LopeBase")} set up this project`), await noticeNewerCli(), Me(planLines().join(`
|
|
3533
3562
|
`), "Here is what happens"), !guard(await ye({
|
|
3534
3563
|
message: `Scan ${import_picocolors4.default.bold(cwd)}?`,
|
|
3535
3564
|
initialValue: !0
|
|
@@ -3560,7 +3589,7 @@ async function init() {
|
|
|
3560
3589
|
label: src.status === "found" ? src.label : src.status === "possible" ? `${src.label} ${import_picocolors4.default.dim("(maybe in use, we'll check)")}` : `${src.label} ${import_picocolors4.default.dim("(not set up yet, we'll help)")}`,
|
|
3561
3590
|
hint: src.why
|
|
3562
3591
|
})),
|
|
3563
|
-
...watchList(detection, facts).some((
|
|
3592
|
+
...watchList(detection, facts).some((w) => w.how === "address") ? [
|
|
3564
3593
|
{
|
|
3565
3594
|
value: PAGEVIEWS,
|
|
3566
3595
|
label: `${PAGEVIEWS} ${import_picocolors4.default.dim("(one tag, no cookies)")}`,
|
|
@@ -3584,7 +3613,7 @@ async function init() {
|
|
|
3584
3613
|
`${import_picocolors4.default.bold(agent)} will now:`,
|
|
3585
3614
|
` ${brand("1.")} add ${import_picocolors4.default.bold(productName || "this product")} to your workspace`,
|
|
3586
3615
|
` ${brand("2.")} connect ${chosen.length ? chosen.join(", ") : "what it recommends"}`,
|
|
3587
|
-
` ${brand("3.")} pick what to watch for uptime: ${watchList(detection, facts).map((
|
|
3616
|
+
` ${brand("3.")} pick what to watch for uptime: ${watchList(detection, facts).map((w) => w.label).join(", ") || "the site"}`,
|
|
3588
3617
|
` ${brand("4.")} stop and ask you for any sign-in, key, or yes`,
|
|
3589
3618
|
"",
|
|
3590
3619
|
import_picocolors4.default.dim("You can follow along in your workspace as each one turns green.")
|
|
@@ -3622,7 +3651,7 @@ async function handOff(prompt, plan) {
|
|
|
3622
3651
|
stdio: "inherit",
|
|
3623
3652
|
cwd
|
|
3624
3653
|
});
|
|
3625
|
-
child.on("error", (
|
|
3654
|
+
child.on("error", (e) => bail(`Could not start ${agent.label}: ${e.message}`)), child.on("exit", (code) => process.exit(code ?? 0));
|
|
3626
3655
|
}
|
|
3627
3656
|
async function noticeNewerCli() {
|
|
3628
3657
|
let mine = version(), latest = await latestOnNpm("lopebase");
|
|
@@ -3648,11 +3677,11 @@ async function update() {
|
|
|
3648
3677
|
let latest = npmLatest && isBehind(ADAPTER_VERSION, npmLatest) ? npmLatest : ADAPTER_VERSION, behind = installs.filter((i) => isBehind(runningVersion(i), latest));
|
|
3649
3678
|
if (s.stop(installs.map((i) => `${i.dir === "." ? "This folder" : i.dir} runs ${import_picocolors4.default.bold(runningVersion(i))}`).join(", ")), !behind.length)
|
|
3650
3679
|
return Se(`Up to date with ${import_picocolors4.default.bold(latest)}.`);
|
|
3651
|
-
let from = behind.map(runningVersion).sort((a,
|
|
3652
|
-
if (Me(
|
|
3653
|
-
`${brand("◆")} ${import_picocolors4.default.bold(
|
|
3654
|
-
...
|
|
3655
|
-
...(
|
|
3680
|
+
let from = behind.map(runningVersion).sort((a, b) => isBehind(a, b) ? -1 : 1)[0], releases = releasesSince(from);
|
|
3681
|
+
if (Me(releases.flatMap((r) => [
|
|
3682
|
+
`${brand("◆")} ${import_picocolors4.default.bold(r.version)} ${import_picocolors4.default.dim(r.date)}`,
|
|
3683
|
+
...r.features.map((f) => ` ${f}`),
|
|
3684
|
+
...(r.breaking ?? []).map((b) => ` ${import_picocolors4.default.yellow("!")} ${b}`)
|
|
3656
3685
|
]).join(`
|
|
3657
3686
|
`), `New since ${from}`), npmLatest && isBehind(ADAPTER_VERSION, npmLatest))
|
|
3658
3687
|
M2.warn(`npm has ${npmLatest}, newer than these notes. Run ${brand("npx lopebase@latest update")} for its steps.`);
|
|
@@ -3689,8 +3718,8 @@ ${BLOG_USAGE}`), process.exit(1);
|
|
|
3689
3718
|
dir,
|
|
3690
3719
|
allowEmpty: flag("allow-empty")
|
|
3691
3720
|
});
|
|
3692
|
-
for (let { file
|
|
3693
|
-
console.log(`${
|
|
3721
|
+
for (let { file, problem } of res.problems)
|
|
3722
|
+
console.log(`${file}: ${problem}`);
|
|
3694
3723
|
let posts = `${res.posts} ${res.posts === 1 ? "post" : "posts"}`;
|
|
3695
3724
|
console.log(res.problems.length ? import_picocolors4.default.red(`${res.problems.length} ${res.problems.length === 1 ? "problem" : "problems"} in ${posts} in ${res.dir}.`) : import_picocolors4.default.green(`Checked ${posts} in ${res.dir}. All good.`)), process.exit(res.problems.length ? 1 : 0);
|
|
3696
3725
|
}
|
|
@@ -3702,7 +3731,7 @@ async function main() {
|
|
|
3702
3731
|
case "upgrade":
|
|
3703
3732
|
return update();
|
|
3704
3733
|
case "login":
|
|
3705
|
-
return await showLogo({ tagline: TAGLINE, version: version(), motion }), Ie(`${badge("LopeBase")} sign in`), await login(), Se("Ready. Run lopebase in any project.");
|
|
3734
|
+
return requireTerminal(), await showLogo({ tagline: TAGLINE, version: version(), motion }), Ie(`${badge("LopeBase")} sign in`), await login(), Se("Ready. Run lopebase in any project.");
|
|
3706
3735
|
case "scan": {
|
|
3707
3736
|
let facts = scanProject(cwd), detection = detectStack(facts);
|
|
3708
3737
|
if (flag("json"))
|
|
@@ -3727,7 +3756,7 @@ async function main() {
|
|
|
3727
3756
|
baseUrl: rest[1],
|
|
3728
3757
|
secret,
|
|
3729
3758
|
token: secret ? void 0 : token,
|
|
3730
|
-
log: (
|
|
3759
|
+
log: (l) => console.log(l.startsWith("FAIL") ? import_picocolors4.default.red(l) : import_picocolors4.default.green(l))
|
|
3731
3760
|
});
|
|
3732
3761
|
console.log(res.failed.length ? import_picocolors4.default.red(`${res.failed.length} failed, ${res.passed} passed`) : import_picocolors4.default.green(`All ${res.passed} checks passed. Ready to connect.`)), process.exit(res.failed.length ? 1 : 0);
|
|
3733
3762
|
}
|