@massu/core 1.10.5 → 1.10.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/dist/cli.js +363 -334
- package/dist/hooks/post-edit-context.js +6 -1
- package/dist/hooks/pre-delete-check.js +12 -7
- package/package.json +1 -1
- package/src/db.ts +63 -62
- package/src/domains.ts +2 -1
- package/src/hooks/pre-delete-check.ts +7 -5
- package/src/import-resolver.ts +3 -2
- package/src/knowledge-tools.ts +3 -2
- package/src/lib/sql-table-names.ts +71 -0
- package/src/middleware-tree.ts +6 -5
- package/src/page-deps.ts +9 -8
- package/src/python/coupling-detector.ts +4 -3
- package/src/python/domain-enforcer.ts +3 -2
- package/src/python/impact-analyzer.ts +7 -6
- package/src/python/import-resolver.ts +3 -2
- package/src/python/migration-indexer.ts +5 -4
- package/src/python/model-indexer.ts +5 -4
- package/src/python/route-indexer.ts +4 -3
- package/src/python-tools.ts +30 -29
- package/src/security/license-pubkey.generated.ts +1 -1
- package/src/security/registry-pubkey.generated.ts +1 -1
- package/src/sentinel-db.ts +47 -46
- package/src/sentinel-scanner.ts +3 -2
- package/src/sentinel-tools.ts +2 -1
- package/src/tools.ts +14 -13
- package/src/trpc-index.ts +5 -4
- package/src/validate-features-runner.ts +5 -4
package/dist/cli.js
CHANGED
|
@@ -628,7 +628,7 @@ function sanitizeFts5Query(raw) {
|
|
|
628
628
|
const trimmed = raw.trim();
|
|
629
629
|
if (!trimmed) return '""';
|
|
630
630
|
const tokens = trimmed.replace(/"/g, "").split(/\s+/).filter(Boolean);
|
|
631
|
-
return tokens.map((
|
|
631
|
+
return tokens.map((t2) => `"${t2}"`).join(" ");
|
|
632
632
|
}
|
|
633
633
|
function getMemoryDb() {
|
|
634
634
|
const dbPath = getResolvedPaths().memoryDbPath;
|
|
@@ -6186,8 +6186,8 @@ var require_parse2 = __commonJS({
|
|
|
6186
6186
|
brace.value = brace.output = "\\{";
|
|
6187
6187
|
value = output = "\\}";
|
|
6188
6188
|
state.output = out;
|
|
6189
|
-
for (const
|
|
6190
|
-
state.output +=
|
|
6189
|
+
for (const t2 of toks) {
|
|
6190
|
+
state.output += t2.output || t2.value;
|
|
6191
6191
|
}
|
|
6192
6192
|
}
|
|
6193
6193
|
push({ type: "brace", value, output });
|
|
@@ -12113,23 +12113,23 @@ import { stdin as $, stdout as j } from "node:process";
|
|
|
12113
12113
|
import * as f from "node:readline";
|
|
12114
12114
|
import M from "node:readline";
|
|
12115
12115
|
import { WriteStream as U } from "node:tty";
|
|
12116
|
-
function J({ onlyFirst:
|
|
12116
|
+
function J({ onlyFirst: t2 = false } = {}) {
|
|
12117
12117
|
const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
12118
|
-
return new RegExp(F,
|
|
12118
|
+
return new RegExp(F, t2 ? void 0 : "g");
|
|
12119
12119
|
}
|
|
12120
|
-
function T(
|
|
12121
|
-
if (typeof
|
|
12122
|
-
return
|
|
12120
|
+
function T(t2) {
|
|
12121
|
+
if (typeof t2 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof t2}\``);
|
|
12122
|
+
return t2.replace(Q, "");
|
|
12123
12123
|
}
|
|
12124
|
-
function O(
|
|
12125
|
-
return
|
|
12124
|
+
function O(t2) {
|
|
12125
|
+
return t2 && t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
|
|
12126
12126
|
}
|
|
12127
|
-
function A(
|
|
12128
|
-
if (typeof
|
|
12129
|
-
|
|
12127
|
+
function A(t2, u2 = {}) {
|
|
12128
|
+
if (typeof t2 != "string" || t2.length === 0 || (u2 = { ambiguousIsNarrow: true, ...u2 }, t2 = T(t2), t2.length === 0)) return 0;
|
|
12129
|
+
t2 = t2.replace(FD(), " ");
|
|
12130
12130
|
const F = u2.ambiguousIsNarrow ? 1 : 2;
|
|
12131
12131
|
let e2 = 0;
|
|
12132
|
-
for (const s of
|
|
12132
|
+
for (const s of t2) {
|
|
12133
12133
|
const i = s.codePointAt(0);
|
|
12134
12134
|
if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
|
|
12135
12135
|
switch (DD.eastAsianWidth(s)) {
|
|
@@ -12147,12 +12147,12 @@ function A(t, u2 = {}) {
|
|
|
12147
12147
|
return e2;
|
|
12148
12148
|
}
|
|
12149
12149
|
function sD() {
|
|
12150
|
-
const
|
|
12150
|
+
const t2 = /* @__PURE__ */ new Map();
|
|
12151
12151
|
for (const [u2, F] of Object.entries(r)) {
|
|
12152
|
-
for (const [e2, s] of Object.entries(F)) r[e2] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[e2] = r[e2],
|
|
12152
|
+
for (const [e2, s] of Object.entries(F)) r[e2] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[e2] = r[e2], t2.set(s[0], s[1]);
|
|
12153
12153
|
Object.defineProperty(r, u2, { value: F, enumerable: false });
|
|
12154
12154
|
}
|
|
12155
|
-
return Object.defineProperty(r, "codes", { value:
|
|
12155
|
+
return Object.defineProperty(r, "codes", { value: t2, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = L(), r.color.ansi256 = N(), r.color.ansi16m = I(), r.bgColor.ansi = L(m), r.bgColor.ansi256 = N(m), r.bgColor.ansi16m = I(m), Object.defineProperties(r, { rgbToAnsi256: { value: (u2, F, e2) => u2 === F && F === e2 ? u2 < 8 ? 16 : u2 > 248 ? 231 : Math.round((u2 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u2 / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(e2 / 255 * 5), enumerable: false }, hexToRgb: { value: (u2) => {
|
|
12156
12156
|
const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u2.toString(16));
|
|
12157
12157
|
if (!F) return [0, 0, 0];
|
|
12158
12158
|
let [e2] = F;
|
|
@@ -12175,17 +12175,17 @@ function sD() {
|
|
|
12175
12175
|
return i === 2 && (D += 60), D;
|
|
12176
12176
|
}, enumerable: false }, rgbToAnsi: { value: (u2, F, e2) => r.ansi256ToAnsi(r.rgbToAnsi256(u2, F, e2)), enumerable: false }, hexToAnsi: { value: (u2) => r.ansi256ToAnsi(r.hexToAnsi256(u2)), enumerable: false } }), r;
|
|
12177
12177
|
}
|
|
12178
|
-
function G(
|
|
12179
|
-
return String(
|
|
12178
|
+
function G(t2, u2, F) {
|
|
12179
|
+
return String(t2).normalize().replace(/\r\n/g, `
|
|
12180
12180
|
`).split(`
|
|
12181
12181
|
`).map((e2) => oD(e2, u2, F)).join(`
|
|
12182
12182
|
`);
|
|
12183
12183
|
}
|
|
12184
|
-
function hD(
|
|
12185
|
-
for (const u2 in
|
|
12184
|
+
function hD(t2) {
|
|
12185
|
+
for (const u2 in t2) {
|
|
12186
12186
|
const F = u2;
|
|
12187
|
-
if (!Object.hasOwn(
|
|
12188
|
-
const e2 =
|
|
12187
|
+
if (!Object.hasOwn(t2, F)) continue;
|
|
12188
|
+
const e2 = t2[F];
|
|
12189
12189
|
switch (F) {
|
|
12190
12190
|
case "aliases": {
|
|
12191
12191
|
for (const s in e2) Object.hasOwn(e2, s) && (c.aliases.has(s) || c.aliases.set(s, e2[s]));
|
|
@@ -12194,29 +12194,29 @@ function hD(t) {
|
|
|
12194
12194
|
}
|
|
12195
12195
|
}
|
|
12196
12196
|
}
|
|
12197
|
-
function k(
|
|
12198
|
-
if (typeof
|
|
12199
|
-
for (const F of
|
|
12197
|
+
function k(t2, u2) {
|
|
12198
|
+
if (typeof t2 == "string") return c.aliases.get(t2) === u2;
|
|
12199
|
+
for (const F of t2) if (F !== void 0 && k(F, u2)) return true;
|
|
12200
12200
|
return false;
|
|
12201
12201
|
}
|
|
12202
|
-
function lD(
|
|
12203
|
-
if (
|
|
12204
|
-
const F =
|
|
12202
|
+
function lD(t2, u2) {
|
|
12203
|
+
if (t2 === u2) return;
|
|
12204
|
+
const F = t2.split(`
|
|
12205
12205
|
`), e2 = u2.split(`
|
|
12206
12206
|
`), s = [];
|
|
12207
12207
|
for (let i = 0; i < Math.max(F.length, e2.length); i++) F[i] !== e2[i] && s.push(i);
|
|
12208
12208
|
return s;
|
|
12209
12209
|
}
|
|
12210
|
-
function BD(
|
|
12211
|
-
return
|
|
12210
|
+
function BD(t2) {
|
|
12211
|
+
return t2 === S;
|
|
12212
12212
|
}
|
|
12213
|
-
function d(
|
|
12214
|
-
const F =
|
|
12213
|
+
function d(t2, u2) {
|
|
12214
|
+
const F = t2;
|
|
12215
12215
|
F.isTTY && F.setRawMode(u2);
|
|
12216
12216
|
}
|
|
12217
|
-
function cD({ input:
|
|
12218
|
-
const s = f.createInterface({ input:
|
|
12219
|
-
f.emitKeypressEvents(
|
|
12217
|
+
function cD({ input: t2 = $, output: u2 = j, overwrite: F = true, hideCursor: e2 = true } = {}) {
|
|
12218
|
+
const s = f.createInterface({ input: t2, output: u2, prompt: "", tabSize: 1 });
|
|
12219
|
+
f.emitKeypressEvents(t2, s), t2.isTTY && t2.setRawMode(true);
|
|
12220
12220
|
const i = (D, { name: C, sequence: o }) => {
|
|
12221
12221
|
const E2 = String(D);
|
|
12222
12222
|
if (k([E2, C, o], "cancel")) {
|
|
@@ -12227,12 +12227,12 @@ function cD({ input: t = $, output: u2 = j, overwrite: F = true, hideCursor: e2
|
|
|
12227
12227
|
const a2 = C === "return" ? 0 : -1, n = C === "return" ? -1 : 0;
|
|
12228
12228
|
f.moveCursor(u2, a2, n, () => {
|
|
12229
12229
|
f.clearLine(u2, 1, () => {
|
|
12230
|
-
|
|
12230
|
+
t2.once("keypress", i);
|
|
12231
12231
|
});
|
|
12232
12232
|
});
|
|
12233
12233
|
};
|
|
12234
|
-
return e2 && u2.write(import_sisteransi.cursor.hide),
|
|
12235
|
-
|
|
12234
|
+
return e2 && u2.write(import_sisteransi.cursor.hide), t2.once("keypress", i), () => {
|
|
12235
|
+
t2.off("keypress", i), e2 && u2.write(import_sisteransi.cursor.show), t2.isTTY && !xD && t2.setRawMode(false), s.terminal = false, s.close();
|
|
12236
12236
|
};
|
|
12237
12237
|
}
|
|
12238
12238
|
var import_sisteransi, import_picocolors, Q, P, X, DD, uD, FD, m, L, N, I, r, tD, eD, iD, v, CD, w, W, rD, R, y, V, z2, ED, _, nD, oD, aD, c, xD, S, AD, pD, h, x, fD, gD, vD, K, dD, bD, mD, Y, wD, yD, _D, Z, kD, SD, $D, q, jD, MD, TD, H, OD, PD;
|
|
@@ -12242,9 +12242,9 @@ var init_dist = __esm({
|
|
|
12242
12242
|
import_picocolors = __toESM(require_picocolors(), 1);
|
|
12243
12243
|
Q = J();
|
|
12244
12244
|
P = { exports: {} };
|
|
12245
|
-
(function(
|
|
12245
|
+
(function(t2) {
|
|
12246
12246
|
var u2 = {};
|
|
12247
|
-
|
|
12247
|
+
t2.exports = u2, u2.eastAsianWidth = function(e2) {
|
|
12248
12248
|
var s = e2.charCodeAt(0), i = e2.length == 2 ? e2.charCodeAt(1) : 0, D = s;
|
|
12249
12249
|
return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D = s << 10 | i, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
|
|
12250
12250
|
}, u2.characterLength = function(e2) {
|
|
@@ -12275,9 +12275,9 @@ var init_dist = __esm({
|
|
|
12275
12275
|
};
|
|
12276
12276
|
FD = O(uD);
|
|
12277
12277
|
m = 10;
|
|
12278
|
-
L = (
|
|
12279
|
-
N = (
|
|
12280
|
-
I = (
|
|
12278
|
+
L = (t2 = 0) => (u2) => `\x1B[${u2 + t2}m`;
|
|
12279
|
+
N = (t2 = 0) => (u2) => `\x1B[${38 + t2};5;${u2}m`;
|
|
12280
|
+
I = (t2 = 0) => (u2, F, e2) => `\x1B[${38 + t2};2;${u2};${F};${e2}m`;
|
|
12281
12281
|
r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
|
|
12282
12282
|
Object.keys(r.modifier);
|
|
12283
12283
|
tD = Object.keys(r.color);
|
|
@@ -12291,34 +12291,34 @@ var init_dist = __esm({
|
|
|
12291
12291
|
rD = "]";
|
|
12292
12292
|
R = "m";
|
|
12293
12293
|
y = `${rD}8;;`;
|
|
12294
|
-
V = (
|
|
12295
|
-
z2 = (
|
|
12296
|
-
ED = (
|
|
12297
|
-
_ = (
|
|
12294
|
+
V = (t2) => `${v.values().next().value}${W}${t2}${R}`;
|
|
12295
|
+
z2 = (t2) => `${v.values().next().value}${y}${t2}${w}`;
|
|
12296
|
+
ED = (t2) => t2.split(" ").map((u2) => A(u2));
|
|
12297
|
+
_ = (t2, u2, F) => {
|
|
12298
12298
|
const e2 = [...u2];
|
|
12299
|
-
let s = false, i = false, D = A(T(
|
|
12299
|
+
let s = false, i = false, D = A(T(t2[t2.length - 1]));
|
|
12300
12300
|
for (const [C, o] of e2.entries()) {
|
|
12301
12301
|
const E2 = A(o);
|
|
12302
|
-
if (D + E2 <= F ?
|
|
12302
|
+
if (D + E2 <= F ? t2[t2.length - 1] += o : (t2.push(o), D = 0), v.has(o) && (s = true, i = e2.slice(C + 1).join("").startsWith(y)), s) {
|
|
12303
12303
|
i ? o === w && (s = false, i = false) : o === R && (s = false);
|
|
12304
12304
|
continue;
|
|
12305
12305
|
}
|
|
12306
|
-
D += E2, D === F && C < e2.length - 1 && (
|
|
12306
|
+
D += E2, D === F && C < e2.length - 1 && (t2.push(""), D = 0);
|
|
12307
12307
|
}
|
|
12308
|
-
!D &&
|
|
12308
|
+
!D && t2[t2.length - 1].length > 0 && t2.length > 1 && (t2[t2.length - 2] += t2.pop());
|
|
12309
12309
|
};
|
|
12310
|
-
nD = (
|
|
12311
|
-
const u2 =
|
|
12310
|
+
nD = (t2) => {
|
|
12311
|
+
const u2 = t2.split(" ");
|
|
12312
12312
|
let F = u2.length;
|
|
12313
12313
|
for (; F > 0 && !(A(u2[F - 1]) > 0); ) F--;
|
|
12314
|
-
return F === u2.length ?
|
|
12314
|
+
return F === u2.length ? t2 : u2.slice(0, F).join(" ") + u2.slice(F).join("");
|
|
12315
12315
|
};
|
|
12316
|
-
oD = (
|
|
12317
|
-
if (F.trim !== false &&
|
|
12316
|
+
oD = (t2, u2, F = {}) => {
|
|
12317
|
+
if (F.trim !== false && t2.trim() === "") return "";
|
|
12318
12318
|
let e2 = "", s, i;
|
|
12319
|
-
const D = ED(
|
|
12319
|
+
const D = ED(t2);
|
|
12320
12320
|
let C = [""];
|
|
12321
|
-
for (const [E2, a2] of
|
|
12321
|
+
for (const [E2, a2] of t2.split(" ").entries()) {
|
|
12322
12322
|
F.trim !== false && (C[C.length - 1] = C[C.length - 1].trimStart());
|
|
12323
12323
|
let n = A(C[C.length - 1]);
|
|
12324
12324
|
if (E2 !== 0 && (n >= u2 && (F.wordWrap === false || F.trim === false) && (C.push(""), n = 0), (n > 0 || F.trim === false) && (C[C.length - 1] += " ", n++)), F.hard && D[E2] > u2) {
|
|
@@ -12362,8 +12362,8 @@ var init_dist = __esm({
|
|
|
12362
12362
|
xD = globalThis.process.platform.startsWith("win");
|
|
12363
12363
|
S = /* @__PURE__ */ Symbol("clack:cancel");
|
|
12364
12364
|
AD = Object.defineProperty;
|
|
12365
|
-
pD = (
|
|
12366
|
-
h = (
|
|
12365
|
+
pD = (t2, u2, F) => u2 in t2 ? AD(t2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t2[u2] = F;
|
|
12366
|
+
h = (t2, u2, F) => (pD(t2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
|
|
12367
12367
|
x = class {
|
|
12368
12368
|
constructor(u2, F = true) {
|
|
12369
12369
|
h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
|
|
@@ -12472,8 +12472,8 @@ var init_dist = __esm({
|
|
|
12472
12472
|
}
|
|
12473
12473
|
};
|
|
12474
12474
|
gD = Object.defineProperty;
|
|
12475
|
-
vD = (
|
|
12476
|
-
K = (
|
|
12475
|
+
vD = (t2, u2, F) => u2 in t2 ? gD(t2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t2[u2] = F;
|
|
12476
|
+
K = (t2, u2, F) => (vD(t2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
|
|
12477
12477
|
dD = class extends x {
|
|
12478
12478
|
constructor(u2) {
|
|
12479
12479
|
super(u2, false), K(this, "options"), K(this, "cursor", 0);
|
|
@@ -12512,8 +12512,8 @@ var init_dist = __esm({
|
|
|
12512
12512
|
}
|
|
12513
12513
|
};
|
|
12514
12514
|
bD = Object.defineProperty;
|
|
12515
|
-
mD = (
|
|
12516
|
-
Y = (
|
|
12515
|
+
mD = (t2, u2, F) => u2 in t2 ? bD(t2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t2[u2] = F;
|
|
12516
|
+
Y = (t2, u2, F) => (mD(t2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
|
|
12517
12517
|
wD = class extends x {
|
|
12518
12518
|
constructor(u2) {
|
|
12519
12519
|
super(u2, false), Y(this, "options"), Y(this, "cursor", 0), this.options = u2.options, this.value = [...u2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F }) => F === u2.cursorAt), 0), this.on("key", (F) => {
|
|
@@ -12547,8 +12547,8 @@ var init_dist = __esm({
|
|
|
12547
12547
|
}
|
|
12548
12548
|
};
|
|
12549
12549
|
yD = Object.defineProperty;
|
|
12550
|
-
_D = (
|
|
12551
|
-
Z = (
|
|
12550
|
+
_D = (t2, u2, F) => u2 in t2 ? yD(t2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t2[u2] = F;
|
|
12551
|
+
Z = (t2, u2, F) => (_D(t2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
|
|
12552
12552
|
kD = class extends x {
|
|
12553
12553
|
constructor({ mask: u2, ...F }) {
|
|
12554
12554
|
super(F), Z(this, "valueWithCursor", ""), Z(this, "_mask", "\u2022"), this._mask = u2 ?? "\u2022", this.on("finalize", () => {
|
|
@@ -12569,8 +12569,8 @@ var init_dist = __esm({
|
|
|
12569
12569
|
}
|
|
12570
12570
|
};
|
|
12571
12571
|
SD = Object.defineProperty;
|
|
12572
|
-
$D = (
|
|
12573
|
-
q = (
|
|
12572
|
+
$D = (t2, u2, F) => u2 in t2 ? SD(t2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t2[u2] = F;
|
|
12573
|
+
q = (t2, u2, F) => ($D(t2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
|
|
12574
12574
|
jD = class extends x {
|
|
12575
12575
|
constructor(u2) {
|
|
12576
12576
|
super(u2, false), q(this, "options"), q(this, "cursor", 0), this.options = u2.options, this.cursor = this.options.findIndex(({ value: F }) => F === u2.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F) => {
|
|
@@ -12595,8 +12595,8 @@ var init_dist = __esm({
|
|
|
12595
12595
|
}
|
|
12596
12596
|
};
|
|
12597
12597
|
MD = Object.defineProperty;
|
|
12598
|
-
TD = (
|
|
12599
|
-
H = (
|
|
12598
|
+
TD = (t2, u2, F) => u2 in t2 ? MD(t2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : t2[u2] = F;
|
|
12599
|
+
H = (t2, u2, F) => (TD(t2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
|
|
12600
12600
|
OD = class extends x {
|
|
12601
12601
|
constructor(u2) {
|
|
12602
12602
|
super(u2, false), H(this, "options"), H(this, "cursor", 0), this.options = u2.options;
|
|
@@ -12697,11 +12697,11 @@ var init_dist2 = __esm({
|
|
|
12697
12697
|
}
|
|
12698
12698
|
};
|
|
12699
12699
|
k2 = (s) => {
|
|
12700
|
-
const { cursor: n, options:
|
|
12700
|
+
const { cursor: n, options: t2, style: i } = s, r2 = s.maxItems ?? Number.POSITIVE_INFINITY, c2 = Math.max(process.stdout.rows - 4, 0), o = Math.min(c2, Math.max(r2, 5));
|
|
12701
12701
|
let l2 = 0;
|
|
12702
|
-
n >= l2 + o - 3 ? l2 = Math.max(Math.min(n - o + 3,
|
|
12703
|
-
const $2 = o <
|
|
12704
|
-
return
|
|
12702
|
+
n >= l2 + o - 3 ? l2 = Math.max(Math.min(n - o + 3, t2.length - o), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
|
|
12703
|
+
const $2 = o < t2.length && l2 > 0, d2 = o < t2.length && l2 + o < t2.length;
|
|
12704
|
+
return t2.slice(l2, l2 + o).map((w2, b2, C) => {
|
|
12705
12705
|
const I2 = b2 === 0 && $2, x2 = b2 === C.length - 1 && d2;
|
|
12706
12706
|
return I2 || x2 ? import_picocolors2.default.dim("...") : i(w2, b2 + l2 === n);
|
|
12707
12707
|
});
|
|
@@ -12709,7 +12709,7 @@ var init_dist2 = __esm({
|
|
|
12709
12709
|
ue = (s) => new PD({ validate: s.validate, placeholder: s.placeholder, defaultValue: s.defaultValue, initialValue: s.initialValue, render() {
|
|
12710
12710
|
const n = `${import_picocolors2.default.gray(a)}
|
|
12711
12711
|
${y2(this.state)} ${s.message}
|
|
12712
|
-
`,
|
|
12712
|
+
`, t2 = s.placeholder ? import_picocolors2.default.inverse(s.placeholder[0]) + import_picocolors2.default.dim(s.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : t2;
|
|
12713
12713
|
switch (this.state) {
|
|
12714
12714
|
case "error":
|
|
12715
12715
|
return `${n.trim()}
|
|
@@ -12730,7 +12730,7 @@ ${import_picocolors2.default.cyan(m2)}
|
|
|
12730
12730
|
$e = (s) => new kD({ validate: s.validate, mask: s.mask ?? se, render() {
|
|
12731
12731
|
const n = `${import_picocolors2.default.gray(a)}
|
|
12732
12732
|
${y2(this.state)} ${s.message}
|
|
12733
|
-
`,
|
|
12733
|
+
`, t2 = this.valueWithCursor, i = this.masked;
|
|
12734
12734
|
switch (this.state) {
|
|
12735
12735
|
case "error":
|
|
12736
12736
|
return `${n.trim()}
|
|
@@ -12743,17 +12743,17 @@ ${import_picocolors2.default.yellow(m2)} ${import_picocolors2.default.yellow(th
|
|
|
12743
12743
|
return `${n}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(i ?? ""))}${i ? `
|
|
12744
12744
|
${import_picocolors2.default.gray(a)}` : ""}`;
|
|
12745
12745
|
default:
|
|
12746
|
-
return `${n}${import_picocolors2.default.cyan(a)} ${
|
|
12746
|
+
return `${n}${import_picocolors2.default.cyan(a)} ${t2}
|
|
12747
12747
|
${import_picocolors2.default.cyan(m2)}
|
|
12748
12748
|
`;
|
|
12749
12749
|
}
|
|
12750
12750
|
} }).prompt();
|
|
12751
12751
|
me = (s) => {
|
|
12752
|
-
const n = s.active ?? "Yes",
|
|
12753
|
-
return new fD({ active: n, inactive:
|
|
12752
|
+
const n = s.active ?? "Yes", t2 = s.inactive ?? "No";
|
|
12753
|
+
return new fD({ active: n, inactive: t2, initialValue: s.initialValue ?? true, render() {
|
|
12754
12754
|
const i = `${import_picocolors2.default.gray(a)}
|
|
12755
12755
|
${y2(this.state)} ${s.message}
|
|
12756
|
-
`, r2 = this.value ? n :
|
|
12756
|
+
`, r2 = this.value ? n : t2;
|
|
12757
12757
|
switch (this.state) {
|
|
12758
12758
|
case "submit":
|
|
12759
12759
|
return `${i}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.dim(r2)}`;
|
|
@@ -12761,20 +12761,20 @@ ${y2(this.state)} ${s.message}
|
|
|
12761
12761
|
return `${i}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}
|
|
12762
12762
|
${import_picocolors2.default.gray(a)}`;
|
|
12763
12763
|
default:
|
|
12764
|
-
return `${i}${import_picocolors2.default.cyan(a)} ${this.value ? `${import_picocolors2.default.green(j2)} ${n}` : `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(
|
|
12764
|
+
return `${i}${import_picocolors2.default.cyan(a)} ${this.value ? `${import_picocolors2.default.green(j2)} ${n}` : `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(t2)}` : `${import_picocolors2.default.green(j2)} ${t2}`}
|
|
12765
12765
|
${import_picocolors2.default.cyan(m2)}
|
|
12766
12766
|
`;
|
|
12767
12767
|
}
|
|
12768
12768
|
} }).prompt();
|
|
12769
12769
|
};
|
|
12770
12770
|
de = (s) => {
|
|
12771
|
-
const n = (
|
|
12772
|
-
const r2 =
|
|
12771
|
+
const n = (t2, i) => {
|
|
12772
|
+
const r2 = t2.label ?? String(t2.value);
|
|
12773
12773
|
switch (i) {
|
|
12774
12774
|
case "selected":
|
|
12775
12775
|
return `${import_picocolors2.default.dim(r2)}`;
|
|
12776
12776
|
case "active":
|
|
12777
|
-
return `${import_picocolors2.default.green(j2)} ${r2} ${
|
|
12777
|
+
return `${import_picocolors2.default.green(j2)} ${r2} ${t2.hint ? import_picocolors2.default.dim(`(${t2.hint})`) : ""}`;
|
|
12778
12778
|
case "cancelled":
|
|
12779
12779
|
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}`;
|
|
12780
12780
|
default:
|
|
@@ -12782,17 +12782,17 @@ ${import_picocolors2.default.cyan(m2)}
|
|
|
12782
12782
|
}
|
|
12783
12783
|
};
|
|
12784
12784
|
return new jD({ options: s.options, initialValue: s.initialValue, render() {
|
|
12785
|
-
const
|
|
12785
|
+
const t2 = `${import_picocolors2.default.gray(a)}
|
|
12786
12786
|
${y2(this.state)} ${s.message}
|
|
12787
12787
|
`;
|
|
12788
12788
|
switch (this.state) {
|
|
12789
12789
|
case "submit":
|
|
12790
|
-
return `${
|
|
12790
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${n(this.options[this.cursor], "selected")}`;
|
|
12791
12791
|
case "cancel":
|
|
12792
|
-
return `${
|
|
12792
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${n(this.options[this.cursor], "cancelled")}
|
|
12793
12793
|
${import_picocolors2.default.gray(a)}`;
|
|
12794
12794
|
default:
|
|
12795
|
-
return `${
|
|
12795
|
+
return `${t2}${import_picocolors2.default.cyan(a)} ${k2({ cursor: this.cursor, options: this.options, maxItems: s.maxItems, style: (i, r2) => n(i, r2 ? "active" : "inactive") }).join(`
|
|
12796
12796
|
${import_picocolors2.default.cyan(a)} `)}
|
|
12797
12797
|
${import_picocolors2.default.cyan(m2)}
|
|
12798
12798
|
`;
|
|
@@ -12800,22 +12800,22 @@ ${import_picocolors2.default.cyan(m2)}
|
|
|
12800
12800
|
} }).prompt();
|
|
12801
12801
|
};
|
|
12802
12802
|
he = (s) => {
|
|
12803
|
-
const n = (
|
|
12804
|
-
const r2 =
|
|
12805
|
-
return i === "selected" ? `${import_picocolors2.default.dim(r2)}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}` : i === "active" ? `${import_picocolors2.default.bgCyan(import_picocolors2.default.gray(` ${
|
|
12803
|
+
const n = (t2, i = "inactive") => {
|
|
12804
|
+
const r2 = t2.label ?? String(t2.value);
|
|
12805
|
+
return i === "selected" ? `${import_picocolors2.default.dim(r2)}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}` : i === "active" ? `${import_picocolors2.default.bgCyan(import_picocolors2.default.gray(` ${t2.value} `))} ${r2} ${t2.hint ? import_picocolors2.default.dim(`(${t2.hint})`) : ""}` : `${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(` ${t2.value} `)))} ${r2} ${t2.hint ? import_picocolors2.default.dim(`(${t2.hint})`) : ""}`;
|
|
12806
12806
|
};
|
|
12807
12807
|
return new OD({ options: s.options, initialValue: s.initialValue, render() {
|
|
12808
|
-
const
|
|
12808
|
+
const t2 = `${import_picocolors2.default.gray(a)}
|
|
12809
12809
|
${y2(this.state)} ${s.message}
|
|
12810
12810
|
`;
|
|
12811
12811
|
switch (this.state) {
|
|
12812
12812
|
case "submit":
|
|
12813
|
-
return `${
|
|
12813
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${n(this.options.find((i) => i.value === this.value) ?? s.options[0], "selected")}`;
|
|
12814
12814
|
case "cancel":
|
|
12815
|
-
return `${
|
|
12815
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${n(this.options[0], "cancelled")}
|
|
12816
12816
|
${import_picocolors2.default.gray(a)}`;
|
|
12817
12817
|
default:
|
|
12818
|
-
return `${
|
|
12818
|
+
return `${t2}${import_picocolors2.default.cyan(a)} ${this.options.map((i, r2) => n(i, r2 === this.cursor ? "active" : "inactive")).join(`
|
|
12819
12819
|
${import_picocolors2.default.cyan(a)} `)}
|
|
12820
12820
|
${import_picocolors2.default.cyan(m2)}
|
|
12821
12821
|
`;
|
|
@@ -12823,15 +12823,15 @@ ${import_picocolors2.default.cyan(m2)}
|
|
|
12823
12823
|
} }).prompt();
|
|
12824
12824
|
};
|
|
12825
12825
|
pe = (s) => {
|
|
12826
|
-
const n = (
|
|
12827
|
-
const r2 =
|
|
12828
|
-
return i === "active" ? `${import_picocolors2.default.cyan(V2)} ${r2} ${
|
|
12826
|
+
const n = (t2, i) => {
|
|
12827
|
+
const r2 = t2.label ?? String(t2.value);
|
|
12828
|
+
return i === "active" ? `${import_picocolors2.default.cyan(V2)} ${r2} ${t2.hint ? import_picocolors2.default.dim(`(${t2.hint})`) : ""}` : i === "selected" ? `${import_picocolors2.default.green(M2)} ${import_picocolors2.default.dim(r2)}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}` : i === "active-selected" ? `${import_picocolors2.default.green(M2)} ${r2} ${t2.hint ? import_picocolors2.default.dim(`(${t2.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(r2)}` : `${import_picocolors2.default.dim(G2)} ${import_picocolors2.default.dim(r2)}`;
|
|
12829
12829
|
};
|
|
12830
|
-
return new wD({ options: s.options, initialValues: s.initialValues, required: s.required ?? true, cursorAt: s.cursorAt, validate(
|
|
12831
|
-
if (this.required &&
|
|
12830
|
+
return new wD({ options: s.options, initialValues: s.initialValues, required: s.required ?? true, cursorAt: s.cursorAt, validate(t2) {
|
|
12831
|
+
if (this.required && t2.length === 0) return `Please select at least one option.
|
|
12832
12832
|
${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`))}`;
|
|
12833
12833
|
}, render() {
|
|
12834
|
-
const
|
|
12834
|
+
const t2 = `${import_picocolors2.default.gray(a)}
|
|
12835
12835
|
${y2(this.state)} ${s.message}
|
|
12836
12836
|
`, i = (r2, c2) => {
|
|
12837
12837
|
const o = this.value.includes(r2.value);
|
|
@@ -12839,23 +12839,23 @@ ${y2(this.state)} ${s.message}
|
|
|
12839
12839
|
};
|
|
12840
12840
|
switch (this.state) {
|
|
12841
12841
|
case "submit":
|
|
12842
|
-
return `${
|
|
12842
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${this.options.filter(({ value: r2 }) => this.value.includes(r2)).map((r2) => n(r2, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
|
|
12843
12843
|
case "cancel": {
|
|
12844
12844
|
const r2 = this.options.filter(({ value: c2 }) => this.value.includes(c2)).map((c2) => n(c2, "cancelled")).join(import_picocolors2.default.dim(", "));
|
|
12845
|
-
return `${
|
|
12845
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${r2.trim() ? `${r2}
|
|
12846
12846
|
${import_picocolors2.default.gray(a)}` : ""}`;
|
|
12847
12847
|
}
|
|
12848
12848
|
case "error": {
|
|
12849
12849
|
const r2 = this.error.split(`
|
|
12850
12850
|
`).map((c2, o) => o === 0 ? `${import_picocolors2.default.yellow(m2)} ${import_picocolors2.default.yellow(c2)}` : ` ${c2}`).join(`
|
|
12851
12851
|
`);
|
|
12852
|
-
return `${
|
|
12852
|
+
return `${t2 + import_picocolors2.default.yellow(a)} ${k2({ options: this.options, cursor: this.cursor, maxItems: s.maxItems, style: i }).join(`
|
|
12853
12853
|
${import_picocolors2.default.yellow(a)} `)}
|
|
12854
12854
|
${r2}
|
|
12855
12855
|
`;
|
|
12856
12856
|
}
|
|
12857
12857
|
default:
|
|
12858
|
-
return `${
|
|
12858
|
+
return `${t2}${import_picocolors2.default.cyan(a)} ${k2({ options: this.options, cursor: this.cursor, maxItems: s.maxItems, style: i }).join(`
|
|
12859
12859
|
${import_picocolors2.default.cyan(a)} `)}
|
|
12860
12860
|
${import_picocolors2.default.cyan(m2)}
|
|
12861
12861
|
`;
|
|
@@ -12863,30 +12863,30 @@ ${import_picocolors2.default.cyan(m2)}
|
|
|
12863
12863
|
} }).prompt();
|
|
12864
12864
|
};
|
|
12865
12865
|
ge = (s) => {
|
|
12866
|
-
const n = (
|
|
12867
|
-
const c2 =
|
|
12868
|
-
return i === "active" ? `${import_picocolors2.default.dim(d2)}${import_picocolors2.default.cyan(V2)} ${c2} ${
|
|
12866
|
+
const n = (t2, i, r2 = []) => {
|
|
12867
|
+
const c2 = t2.label ?? String(t2.value), o = typeof t2.group == "string", l2 = o && (r2[r2.indexOf(t2) + 1] ?? { group: true }), $2 = o && l2.group === true, d2 = o ? `${$2 ? m2 : a} ` : "";
|
|
12868
|
+
return i === "active" ? `${import_picocolors2.default.dim(d2)}${import_picocolors2.default.cyan(V2)} ${c2} ${t2.hint ? import_picocolors2.default.dim(`(${t2.hint})`) : ""}` : i === "group-active" ? `${d2}${import_picocolors2.default.cyan(V2)} ${import_picocolors2.default.dim(c2)}` : i === "group-active-selected" ? `${d2}${import_picocolors2.default.green(M2)} ${import_picocolors2.default.dim(c2)}` : i === "selected" ? `${import_picocolors2.default.dim(d2)}${import_picocolors2.default.green(M2)} ${import_picocolors2.default.dim(c2)}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(c2))}` : i === "active-selected" ? `${import_picocolors2.default.dim(d2)}${import_picocolors2.default.green(M2)} ${c2} ${t2.hint ? import_picocolors2.default.dim(`(${t2.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(c2)}` : `${import_picocolors2.default.dim(d2)}${import_picocolors2.default.dim(G2)} ${import_picocolors2.default.dim(c2)}`;
|
|
12869
12869
|
};
|
|
12870
|
-
return new dD({ options: s.options, initialValues: s.initialValues, required: s.required ?? true, cursorAt: s.cursorAt, validate(
|
|
12871
|
-
if (this.required &&
|
|
12870
|
+
return new dD({ options: s.options, initialValues: s.initialValues, required: s.required ?? true, cursorAt: s.cursorAt, validate(t2) {
|
|
12871
|
+
if (this.required && t2.length === 0) return `Please select at least one option.
|
|
12872
12872
|
${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`))}`;
|
|
12873
12873
|
}, render() {
|
|
12874
|
-
const
|
|
12874
|
+
const t2 = `${import_picocolors2.default.gray(a)}
|
|
12875
12875
|
${y2(this.state)} ${s.message}
|
|
12876
12876
|
`;
|
|
12877
12877
|
switch (this.state) {
|
|
12878
12878
|
case "submit":
|
|
12879
|
-
return `${
|
|
12879
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${this.options.filter(({ value: i }) => this.value.includes(i)).map((i) => n(i, "submitted")).join(import_picocolors2.default.dim(", "))}`;
|
|
12880
12880
|
case "cancel": {
|
|
12881
12881
|
const i = this.options.filter(({ value: r2 }) => this.value.includes(r2)).map((r2) => n(r2, "cancelled")).join(import_picocolors2.default.dim(", "));
|
|
12882
|
-
return `${
|
|
12882
|
+
return `${t2}${import_picocolors2.default.gray(a)} ${i.trim() ? `${i}
|
|
12883
12883
|
${import_picocolors2.default.gray(a)}` : ""}`;
|
|
12884
12884
|
}
|
|
12885
12885
|
case "error": {
|
|
12886
12886
|
const i = this.error.split(`
|
|
12887
12887
|
`).map((r2, c2) => c2 === 0 ? `${import_picocolors2.default.yellow(m2)} ${import_picocolors2.default.yellow(r2)}` : ` ${r2}`).join(`
|
|
12888
12888
|
`);
|
|
12889
|
-
return `${
|
|
12889
|
+
return `${t2}${import_picocolors2.default.yellow(a)} ${this.options.map((r2, c2, o) => {
|
|
12890
12890
|
const l2 = this.value.includes(r2.value) || r2.group === true && this.isGroupSelected(`${r2.value}`), $2 = c2 === this.cursor;
|
|
12891
12891
|
return !$2 && typeof r2.group == "string" && this.options[this.cursor].value === r2.group ? n(r2, l2 ? "group-active-selected" : "group-active", o) : $2 && l2 ? n(r2, "active-selected", o) : l2 ? n(r2, "selected", o) : n(r2, $2 ? "active" : "inactive", o);
|
|
12892
12892
|
}).join(`
|
|
@@ -12895,7 +12895,7 @@ ${i}
|
|
|
12895
12895
|
`;
|
|
12896
12896
|
}
|
|
12897
12897
|
default:
|
|
12898
|
-
return `${
|
|
12898
|
+
return `${t2}${import_picocolors2.default.cyan(a)} ${this.options.map((i, r2, c2) => {
|
|
12899
12899
|
const o = this.value.includes(i.value) || i.group === true && this.isGroupSelected(`${i.value}`), l2 = r2 === this.cursor;
|
|
12900
12900
|
return !l2 && typeof i.group == "string" && this.options[this.cursor].value === i.group ? n(i, o ? "group-active-selected" : "group-active", c2) : l2 && o ? n(i, "active-selected", c2) : o ? n(i, "selected", c2) : n(i, l2 ? "active" : "inactive", c2);
|
|
12901
12901
|
}).join(`
|
|
@@ -12906,13 +12906,13 @@ ${import_picocolors2.default.cyan(m2)}
|
|
|
12906
12906
|
} }).prompt();
|
|
12907
12907
|
};
|
|
12908
12908
|
ye = (s = "", n = "") => {
|
|
12909
|
-
const
|
|
12909
|
+
const t2 = `
|
|
12910
12910
|
${s}
|
|
12911
12911
|
`.split(`
|
|
12912
|
-
`), i = T2(n).length, r2 = Math.max(
|
|
12912
|
+
`), i = T2(n).length, r2 = Math.max(t2.reduce((o, l2) => {
|
|
12913
12913
|
const $2 = T2(l2);
|
|
12914
12914
|
return $2.length > o ? $2.length : o;
|
|
12915
|
-
}, 0), i) + 2, c2 =
|
|
12915
|
+
}, 0), i) + 2, c2 = t2.map((o) => `${import_picocolors2.default.gray(a)} ${import_picocolors2.default.dim(o)}${" ".repeat(r2 - T2(o).length)}${import_picocolors2.default.gray(a)}`).join(`
|
|
12916
12916
|
`);
|
|
12917
12917
|
process.stdout.write(`${import_picocolors2.default.gray(a)}
|
|
12918
12918
|
${import_picocolors2.default.green(S2)} ${import_picocolors2.default.reset(n)} ${import_picocolors2.default.gray(N2.repeat(Math.max(r2 - i - 1, 1)) + re)}
|
|
@@ -12936,13 +12936,13 @@ ${import_picocolors2.default.gray(m2)} ${s}
|
|
|
12936
12936
|
`);
|
|
12937
12937
|
};
|
|
12938
12938
|
v2 = { message: (s = "", { symbol: n = import_picocolors2.default.gray(a) } = {}) => {
|
|
12939
|
-
const
|
|
12939
|
+
const t2 = [`${import_picocolors2.default.gray(a)}`];
|
|
12940
12940
|
if (s) {
|
|
12941
12941
|
const [i, ...r2] = s.split(`
|
|
12942
12942
|
`);
|
|
12943
|
-
|
|
12943
|
+
t2.push(`${n} ${i}`, ...r2.map((c2) => `${import_picocolors2.default.gray(a)} ${c2}`));
|
|
12944
12944
|
}
|
|
12945
|
-
process.stdout.write(`${
|
|
12945
|
+
process.stdout.write(`${t2.join(`
|
|
12946
12946
|
`)}
|
|
12947
12947
|
`);
|
|
12948
12948
|
}, info: (s) => {
|
|
@@ -12959,7 +12959,7 @@ ${import_picocolors2.default.gray(m2)} ${s}
|
|
|
12959
12959
|
v2.message(s, { symbol: import_picocolors2.default.red(le) });
|
|
12960
12960
|
} };
|
|
12961
12961
|
L2 = () => {
|
|
12962
|
-
const s = E ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], n = E ? 80 : 120,
|
|
12962
|
+
const s = E ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], n = E ? 80 : 120, t2 = process.env.CI === "true";
|
|
12963
12963
|
let i, r2, c2 = false, o = "", l2;
|
|
12964
12964
|
const $2 = (h2) => {
|
|
12965
12965
|
const g2 = h2 > 1 ? "Something went wrong" : "Canceled";
|
|
@@ -12970,7 +12970,7 @@ ${import_picocolors2.default.gray(m2)} ${s}
|
|
|
12970
12970
|
process.removeListener("uncaughtExceptionMonitor", d2), process.removeListener("unhandledRejection", d2), process.removeListener("SIGINT", w2), process.removeListener("SIGTERM", w2), process.removeListener("exit", $2);
|
|
12971
12971
|
}, I2 = () => {
|
|
12972
12972
|
if (l2 === void 0) return;
|
|
12973
|
-
|
|
12973
|
+
t2 && process.stdout.write(`
|
|
12974
12974
|
`);
|
|
12975
12975
|
const h2 = l2.split(`
|
|
12976
12976
|
`);
|
|
@@ -12980,9 +12980,9 @@ ${import_picocolors2.default.gray(m2)} ${s}
|
|
|
12980
12980
|
`);
|
|
12981
12981
|
let g2 = 0, f2 = 0;
|
|
12982
12982
|
b2(), r2 = setInterval(() => {
|
|
12983
|
-
if (
|
|
12983
|
+
if (t2 && o === l2) return;
|
|
12984
12984
|
I2(), l2 = o;
|
|
12985
|
-
const W2 = import_picocolors2.default.magenta(s[g2]), _2 =
|
|
12985
|
+
const W2 = import_picocolors2.default.magenta(s[g2]), _2 = t2 ? "..." : ".".repeat(Math.floor(f2)).slice(0, 3);
|
|
12986
12986
|
process.stdout.write(`${W2} ${o}${_2}`), g2 = g2 + 1 < s.length ? g2 + 1 : 0, f2 = f2 < s.length ? f2 + 0.125 : 0;
|
|
12987
12987
|
}, n);
|
|
12988
12988
|
}, P2 = (h2 = "", g2 = 0) => {
|
|
@@ -12996,26 +12996,26 @@ ${import_picocolors2.default.gray(m2)} ${s}
|
|
|
12996
12996
|
} };
|
|
12997
12997
|
};
|
|
12998
12998
|
be = async (s, n) => {
|
|
12999
|
-
const
|
|
12999
|
+
const t2 = {}, i = Object.keys(s);
|
|
13000
13000
|
for (const r2 of i) {
|
|
13001
|
-
const c2 = s[r2], o = await c2({ results:
|
|
13001
|
+
const c2 = s[r2], o = await c2({ results: t2 })?.catch((l2) => {
|
|
13002
13002
|
throw l2;
|
|
13003
13003
|
});
|
|
13004
13004
|
if (typeof n?.onCancel == "function" && BD(o)) {
|
|
13005
|
-
|
|
13005
|
+
t2[r2] = "canceled", n.onCancel({ results: t2 });
|
|
13006
13006
|
continue;
|
|
13007
13007
|
}
|
|
13008
|
-
|
|
13008
|
+
t2[r2] = o;
|
|
13009
13009
|
}
|
|
13010
|
-
return
|
|
13010
|
+
return t2;
|
|
13011
13011
|
};
|
|
13012
13012
|
xe = async (s) => {
|
|
13013
13013
|
for (const n of s) {
|
|
13014
13014
|
if (n.enabled === false) continue;
|
|
13015
|
-
const
|
|
13016
|
-
|
|
13017
|
-
const i = await n.task(
|
|
13018
|
-
|
|
13015
|
+
const t2 = L2();
|
|
13016
|
+
t2.start(n.title);
|
|
13017
|
+
const i = await n.task(t2.message);
|
|
13018
|
+
t2.stop(i || n.title);
|
|
13019
13019
|
}
|
|
13020
13020
|
};
|
|
13021
13021
|
}
|
|
@@ -15447,8 +15447,8 @@ async function handleChangelogSubcommand(args2) {
|
|
|
15447
15447
|
process.stdout.write("All plan-tokens referenced.\n");
|
|
15448
15448
|
return { exitCode: 0 };
|
|
15449
15449
|
}
|
|
15450
|
-
for (const
|
|
15451
|
-
process.stderr.write(`gap: ${
|
|
15450
|
+
for (const t2 of gaps) {
|
|
15451
|
+
process.stderr.write(`gap: ${t2}
|
|
15452
15452
|
`);
|
|
15453
15453
|
}
|
|
15454
15454
|
return { exitCode: 1 };
|
|
@@ -16413,14 +16413,14 @@ async function startDaemon(projectRoot, hooks) {
|
|
|
16413
16413
|
ctx.debounceTimer = null;
|
|
16414
16414
|
}
|
|
16415
16415
|
}
|
|
16416
|
-
function pruneRecent(
|
|
16417
|
-
const cutoff =
|
|
16416
|
+
function pruneRecent(t2) {
|
|
16417
|
+
const cutoff = t2 - DEEP_STORM_WINDOW_MS;
|
|
16418
16418
|
if (ctx.recent.length === 0 || ctx.recent[0] >= cutoff) return;
|
|
16419
16419
|
ctx.recent = ctx.recent.filter((x2) => x2 >= cutoff);
|
|
16420
16420
|
}
|
|
16421
|
-
function detectStorm(
|
|
16422
|
-
pruneRecent(
|
|
16423
|
-
const lastSecond = ctx.recent.filter((x2) =>
|
|
16421
|
+
function detectStorm(t2) {
|
|
16422
|
+
pruneRecent(t2);
|
|
16423
|
+
const lastSecond = ctx.recent.filter((x2) => t2 - x2 <= STORM_WINDOW_MS).length;
|
|
16424
16424
|
const lastTen = ctx.recent.length;
|
|
16425
16425
|
if (lastTen > cfg.deepStormThreshold) return "deep_storm";
|
|
16426
16426
|
if (lastSecond > cfg.stormThreshold) return "storm";
|
|
@@ -16470,22 +16470,22 @@ async function startDaemon(projectRoot, hooks) {
|
|
|
16470
16470
|
}
|
|
16471
16471
|
function pushEvent(_path) {
|
|
16472
16472
|
if (stopped) return;
|
|
16473
|
-
const
|
|
16474
|
-
ctx.recent.push(
|
|
16473
|
+
const t2 = now();
|
|
16474
|
+
ctx.recent.push(t2);
|
|
16475
16475
|
if (ctx.hardTimeoutAt === null) {
|
|
16476
|
-
ctx.hardTimeoutAt =
|
|
16476
|
+
ctx.hardTimeoutAt = t2 + cfg.hardTimeoutMs;
|
|
16477
16477
|
}
|
|
16478
|
-
if (
|
|
16479
|
-
const intensity = detectStorm(
|
|
16478
|
+
if (t2 < ctx.stormCooldownUntil) return;
|
|
16479
|
+
const intensity = detectStorm(t2);
|
|
16480
16480
|
let delay = cfg.debounceMs;
|
|
16481
16481
|
if (intensity === "storm") {
|
|
16482
16482
|
delay = STORM_WAIT_MS;
|
|
16483
|
-
ctx.stormCooldownUntil =
|
|
16483
|
+
ctx.stormCooldownUntil = t2 + STORM_WAIT_MS;
|
|
16484
16484
|
} else if (intensity === "deep_storm") {
|
|
16485
16485
|
delay = DEEP_STORM_WAIT_MS;
|
|
16486
|
-
ctx.stormCooldownUntil =
|
|
16486
|
+
ctx.stormCooldownUntil = t2 + DEEP_STORM_WAIT_MS;
|
|
16487
16487
|
}
|
|
16488
|
-
if (ctx.hardTimeoutAt !== null &&
|
|
16488
|
+
if (ctx.hardTimeoutAt !== null && t2 >= ctx.hardTimeoutAt) {
|
|
16489
16489
|
clearDebounce();
|
|
16490
16490
|
void fireRefresh();
|
|
16491
16491
|
return;
|
|
@@ -16516,11 +16516,11 @@ async function startDaemon(projectRoot, hooks) {
|
|
|
16516
16516
|
}
|
|
16517
16517
|
function tick() {
|
|
16518
16518
|
if (stopped) return;
|
|
16519
|
-
const
|
|
16520
|
-
const gap =
|
|
16521
|
-
ctx.lastTickAt =
|
|
16519
|
+
const t2 = now();
|
|
16520
|
+
const gap = t2 - ctx.lastTickAt;
|
|
16521
|
+
ctx.lastTickAt = t2;
|
|
16522
16522
|
try {
|
|
16523
|
-
updateState(cfg.projectRoot, { tickedAt: new Date(
|
|
16523
|
+
updateState(cfg.projectRoot, { tickedAt: new Date(t2).toISOString() });
|
|
16524
16524
|
} catch {
|
|
16525
16525
|
}
|
|
16526
16526
|
if (gap > TICK_GAP_THRESHOLD_MS && !ctx.reconciliationPending) {
|
|
@@ -18643,6 +18643,17 @@ var init_adapters2 = __esm({
|
|
|
18643
18643
|
}
|
|
18644
18644
|
});
|
|
18645
18645
|
|
|
18646
|
+
// src/lib/sql-table-names.ts
|
|
18647
|
+
function t(suffix) {
|
|
18648
|
+
return `${getConfig().toolPrefix}_${suffix}`;
|
|
18649
|
+
}
|
|
18650
|
+
var init_sql_table_names = __esm({
|
|
18651
|
+
"src/lib/sql-table-names.ts"() {
|
|
18652
|
+
"use strict";
|
|
18653
|
+
init_config();
|
|
18654
|
+
}
|
|
18655
|
+
});
|
|
18656
|
+
|
|
18646
18657
|
// src/db.ts
|
|
18647
18658
|
import Database2 from "better-sqlite3";
|
|
18648
18659
|
import { dirname as dirname13, join as join12 } from "path";
|
|
@@ -18670,7 +18681,7 @@ function getDataDb() {
|
|
|
18670
18681
|
}
|
|
18671
18682
|
function initDataSchema(db) {
|
|
18672
18683
|
db.exec(`
|
|
18673
|
-
CREATE TABLE IF NOT EXISTS
|
|
18684
|
+
CREATE TABLE IF NOT EXISTS ${t("imports")} (
|
|
18674
18685
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18675
18686
|
source_file TEXT NOT NULL,
|
|
18676
18687
|
target_file TEXT NOT NULL,
|
|
@@ -18679,10 +18690,10 @@ function initDataSchema(db) {
|
|
|
18679
18690
|
line INTEGER NOT NULL DEFAULT 0
|
|
18680
18691
|
);
|
|
18681
18692
|
|
|
18682
|
-
CREATE INDEX IF NOT EXISTS idx_massu_imports_source ON
|
|
18683
|
-
CREATE INDEX IF NOT EXISTS idx_massu_imports_target ON
|
|
18693
|
+
CREATE INDEX IF NOT EXISTS idx_massu_imports_source ON ${t("imports")}(source_file);
|
|
18694
|
+
CREATE INDEX IF NOT EXISTS idx_massu_imports_target ON ${t("imports")}(target_file);
|
|
18684
18695
|
|
|
18685
|
-
CREATE TABLE IF NOT EXISTS
|
|
18696
|
+
CREATE TABLE IF NOT EXISTS ${t("trpc_procedures")} (
|
|
18686
18697
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18687
18698
|
router_file TEXT NOT NULL,
|
|
18688
18699
|
router_name TEXT NOT NULL,
|
|
@@ -18691,20 +18702,20 @@ function initDataSchema(db) {
|
|
|
18691
18702
|
has_ui_caller INTEGER NOT NULL DEFAULT 0
|
|
18692
18703
|
);
|
|
18693
18704
|
|
|
18694
|
-
CREATE INDEX IF NOT EXISTS idx_massu_trpc_router ON
|
|
18705
|
+
CREATE INDEX IF NOT EXISTS idx_massu_trpc_router ON ${t("trpc_procedures")}(router_name);
|
|
18695
18706
|
|
|
18696
|
-
CREATE TABLE IF NOT EXISTS
|
|
18707
|
+
CREATE TABLE IF NOT EXISTS ${t("trpc_call_sites")} (
|
|
18697
18708
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18698
18709
|
procedure_id INTEGER NOT NULL,
|
|
18699
18710
|
file TEXT NOT NULL,
|
|
18700
18711
|
line INTEGER NOT NULL DEFAULT 0,
|
|
18701
18712
|
call_pattern TEXT NOT NULL,
|
|
18702
|
-
FOREIGN KEY (procedure_id) REFERENCES
|
|
18713
|
+
FOREIGN KEY (procedure_id) REFERENCES ${t("trpc_procedures")}(id)
|
|
18703
18714
|
);
|
|
18704
18715
|
|
|
18705
|
-
CREATE INDEX IF NOT EXISTS idx_massu_call_sites_proc ON
|
|
18716
|
+
CREATE INDEX IF NOT EXISTS idx_massu_call_sites_proc ON ${t("trpc_call_sites")}(procedure_id);
|
|
18706
18717
|
|
|
18707
|
-
CREATE TABLE IF NOT EXISTS
|
|
18718
|
+
CREATE TABLE IF NOT EXISTS ${t("page_deps")} (
|
|
18708
18719
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18709
18720
|
page_file TEXT NOT NULL,
|
|
18710
18721
|
route TEXT NOT NULL,
|
|
@@ -18715,14 +18726,14 @@ function initDataSchema(db) {
|
|
|
18715
18726
|
tables_touched TEXT NOT NULL DEFAULT '[]'
|
|
18716
18727
|
);
|
|
18717
18728
|
|
|
18718
|
-
CREATE INDEX IF NOT EXISTS idx_massu_page_deps_page ON
|
|
18729
|
+
CREATE INDEX IF NOT EXISTS idx_massu_page_deps_page ON ${t("page_deps")}(page_file);
|
|
18719
18730
|
|
|
18720
|
-
CREATE TABLE IF NOT EXISTS
|
|
18731
|
+
CREATE TABLE IF NOT EXISTS ${t("middleware_tree")} (
|
|
18721
18732
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18722
18733
|
file TEXT NOT NULL UNIQUE
|
|
18723
18734
|
);
|
|
18724
18735
|
|
|
18725
|
-
CREATE TABLE IF NOT EXISTS
|
|
18736
|
+
CREATE TABLE IF NOT EXISTS ${t("meta")} (
|
|
18726
18737
|
key TEXT PRIMARY KEY,
|
|
18727
18738
|
value TEXT NOT NULL
|
|
18728
18739
|
);
|
|
@@ -18731,7 +18742,7 @@ function initDataSchema(db) {
|
|
|
18731
18742
|
-- Python Code Intelligence Tables
|
|
18732
18743
|
-- ============================================================
|
|
18733
18744
|
|
|
18734
|
-
CREATE TABLE IF NOT EXISTS
|
|
18745
|
+
CREATE TABLE IF NOT EXISTS ${t("py_imports")} (
|
|
18735
18746
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18736
18747
|
source_file TEXT NOT NULL,
|
|
18737
18748
|
target_file TEXT NOT NULL,
|
|
@@ -18739,15 +18750,15 @@ function initDataSchema(db) {
|
|
|
18739
18750
|
imported_names TEXT NOT NULL DEFAULT '[]',
|
|
18740
18751
|
line INTEGER NOT NULL DEFAULT 0
|
|
18741
18752
|
);
|
|
18742
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_imports_source ON
|
|
18743
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_imports_target ON
|
|
18753
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_imports_source ON ${t("py_imports")}(source_file);
|
|
18754
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_imports_target ON ${t("py_imports")}(target_file);
|
|
18744
18755
|
|
|
18745
|
-
CREATE TABLE IF NOT EXISTS
|
|
18756
|
+
CREATE TABLE IF NOT EXISTS ${t("py_meta")} (
|
|
18746
18757
|
key TEXT PRIMARY KEY,
|
|
18747
18758
|
value TEXT NOT NULL
|
|
18748
18759
|
);
|
|
18749
18760
|
|
|
18750
|
-
CREATE TABLE IF NOT EXISTS
|
|
18761
|
+
CREATE TABLE IF NOT EXISTS ${t("py_routes")} (
|
|
18751
18762
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18752
18763
|
file TEXT NOT NULL,
|
|
18753
18764
|
method TEXT NOT NULL,
|
|
@@ -18759,19 +18770,19 @@ function initDataSchema(db) {
|
|
|
18759
18770
|
is_authenticated INTEGER NOT NULL DEFAULT 0,
|
|
18760
18771
|
line INTEGER NOT NULL DEFAULT 0
|
|
18761
18772
|
);
|
|
18762
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_routes_path ON
|
|
18763
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_routes_file ON
|
|
18773
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_routes_path ON ${t("py_routes")}(path);
|
|
18774
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_routes_file ON ${t("py_routes")}(file);
|
|
18764
18775
|
|
|
18765
|
-
CREATE TABLE IF NOT EXISTS
|
|
18776
|
+
CREATE TABLE IF NOT EXISTS ${t("py_route_callers")} (
|
|
18766
18777
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18767
|
-
route_id INTEGER NOT NULL REFERENCES
|
|
18778
|
+
route_id INTEGER NOT NULL REFERENCES ${t("py_routes")}(id) ON DELETE CASCADE,
|
|
18768
18779
|
frontend_file TEXT NOT NULL,
|
|
18769
18780
|
line INTEGER NOT NULL DEFAULT 0,
|
|
18770
18781
|
call_pattern TEXT NOT NULL
|
|
18771
18782
|
);
|
|
18772
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_route_callers_route ON
|
|
18783
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_route_callers_route ON ${t("py_route_callers")}(route_id);
|
|
18773
18784
|
|
|
18774
|
-
CREATE TABLE IF NOT EXISTS
|
|
18785
|
+
CREATE TABLE IF NOT EXISTS ${t("py_models")} (
|
|
18775
18786
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18776
18787
|
class_name TEXT NOT NULL,
|
|
18777
18788
|
table_name TEXT,
|
|
@@ -18781,20 +18792,20 @@ function initDataSchema(db) {
|
|
|
18781
18792
|
relationships TEXT NOT NULL DEFAULT '[]',
|
|
18782
18793
|
foreign_keys TEXT NOT NULL DEFAULT '[]'
|
|
18783
18794
|
);
|
|
18784
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_models_file ON
|
|
18785
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_models_table ON
|
|
18795
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_models_file ON ${t("py_models")}(file);
|
|
18796
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_models_table ON ${t("py_models")}(table_name);
|
|
18786
18797
|
|
|
18787
|
-
CREATE TABLE IF NOT EXISTS
|
|
18798
|
+
CREATE TABLE IF NOT EXISTS ${t("py_fk_edges")} (
|
|
18788
18799
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18789
18800
|
source_table TEXT NOT NULL,
|
|
18790
18801
|
source_column TEXT NOT NULL,
|
|
18791
18802
|
target_table TEXT NOT NULL,
|
|
18792
18803
|
target_column TEXT NOT NULL
|
|
18793
18804
|
);
|
|
18794
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_fk_source ON
|
|
18795
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_fk_target ON
|
|
18805
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_fk_source ON ${t("py_fk_edges")}(source_table);
|
|
18806
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_fk_target ON ${t("py_fk_edges")}(target_table);
|
|
18796
18807
|
|
|
18797
|
-
CREATE TABLE IF NOT EXISTS
|
|
18808
|
+
CREATE TABLE IF NOT EXISTS ${t("py_migrations")} (
|
|
18798
18809
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18799
18810
|
revision TEXT NOT NULL UNIQUE,
|
|
18800
18811
|
down_revision TEXT,
|
|
@@ -18803,14 +18814,14 @@ function initDataSchema(db) {
|
|
|
18803
18814
|
operations TEXT NOT NULL DEFAULT '[]',
|
|
18804
18815
|
is_head INTEGER NOT NULL DEFAULT 0
|
|
18805
18816
|
);
|
|
18806
|
-
CREATE INDEX IF NOT EXISTS idx_massu_py_migrations_rev ON
|
|
18817
|
+
CREATE INDEX IF NOT EXISTS idx_massu_py_migrations_rev ON ${t("py_migrations")}(revision);
|
|
18807
18818
|
|
|
18808
18819
|
-- ============================================================
|
|
18809
18820
|
-- Sentinel: Feature Registry Tables
|
|
18810
18821
|
-- ============================================================
|
|
18811
18822
|
|
|
18812
18823
|
-- Core feature definition
|
|
18813
|
-
CREATE TABLE IF NOT EXISTS
|
|
18824
|
+
CREATE TABLE IF NOT EXISTS ${t("sentinel")} (
|
|
18814
18825
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18815
18826
|
feature_key TEXT UNIQUE NOT NULL,
|
|
18816
18827
|
domain TEXT NOT NULL,
|
|
@@ -18828,14 +18839,14 @@ function initDataSchema(db) {
|
|
|
18828
18839
|
removed_reason TEXT
|
|
18829
18840
|
);
|
|
18830
18841
|
|
|
18831
|
-
CREATE INDEX IF NOT EXISTS idx_sentinel_domain ON
|
|
18832
|
-
CREATE INDEX IF NOT EXISTS idx_sentinel_status ON
|
|
18833
|
-
CREATE INDEX IF NOT EXISTS idx_sentinel_key ON
|
|
18842
|
+
CREATE INDEX IF NOT EXISTS idx_sentinel_domain ON ${t("sentinel")}(domain);
|
|
18843
|
+
CREATE INDEX IF NOT EXISTS idx_sentinel_status ON ${t("sentinel")}(status);
|
|
18844
|
+
CREATE INDEX IF NOT EXISTS idx_sentinel_key ON ${t("sentinel")}(feature_key);
|
|
18834
18845
|
|
|
18835
18846
|
-- Feature-to-component mapping (many-to-many)
|
|
18836
|
-
CREATE TABLE IF NOT EXISTS
|
|
18847
|
+
CREATE TABLE IF NOT EXISTS ${t("sentinel_components")} (
|
|
18837
18848
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18838
|
-
feature_id INTEGER NOT NULL REFERENCES
|
|
18849
|
+
feature_id INTEGER NOT NULL REFERENCES ${t("sentinel")}(id) ON DELETE CASCADE,
|
|
18839
18850
|
component_file TEXT NOT NULL,
|
|
18840
18851
|
component_name TEXT,
|
|
18841
18852
|
role TEXT DEFAULT 'implementation'
|
|
@@ -18845,9 +18856,9 @@ function initDataSchema(db) {
|
|
|
18845
18856
|
);
|
|
18846
18857
|
|
|
18847
18858
|
-- Feature-to-procedure mapping (many-to-many)
|
|
18848
|
-
CREATE TABLE IF NOT EXISTS
|
|
18859
|
+
CREATE TABLE IF NOT EXISTS ${t("sentinel_procedures")} (
|
|
18849
18860
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18850
|
-
feature_id INTEGER NOT NULL REFERENCES
|
|
18861
|
+
feature_id INTEGER NOT NULL REFERENCES ${t("sentinel")}(id) ON DELETE CASCADE,
|
|
18851
18862
|
router_name TEXT NOT NULL,
|
|
18852
18863
|
procedure_name TEXT NOT NULL,
|
|
18853
18864
|
procedure_type TEXT,
|
|
@@ -18855,28 +18866,28 @@ function initDataSchema(db) {
|
|
|
18855
18866
|
);
|
|
18856
18867
|
|
|
18857
18868
|
-- Feature-to-page mapping (where feature is accessible)
|
|
18858
|
-
CREATE TABLE IF NOT EXISTS
|
|
18869
|
+
CREATE TABLE IF NOT EXISTS ${t("sentinel_pages")} (
|
|
18859
18870
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18860
|
-
feature_id INTEGER NOT NULL REFERENCES
|
|
18871
|
+
feature_id INTEGER NOT NULL REFERENCES ${t("sentinel")}(id) ON DELETE CASCADE,
|
|
18861
18872
|
page_route TEXT NOT NULL,
|
|
18862
18873
|
portal TEXT,
|
|
18863
18874
|
UNIQUE(feature_id, page_route, portal)
|
|
18864
18875
|
);
|
|
18865
18876
|
|
|
18866
18877
|
-- Feature dependency graph
|
|
18867
|
-
CREATE TABLE IF NOT EXISTS
|
|
18878
|
+
CREATE TABLE IF NOT EXISTS ${t("sentinel_deps")} (
|
|
18868
18879
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18869
|
-
feature_id INTEGER NOT NULL REFERENCES
|
|
18870
|
-
depends_on_feature_id INTEGER NOT NULL REFERENCES
|
|
18880
|
+
feature_id INTEGER NOT NULL REFERENCES ${t("sentinel")}(id) ON DELETE CASCADE,
|
|
18881
|
+
depends_on_feature_id INTEGER NOT NULL REFERENCES ${t("sentinel")}(id) ON DELETE CASCADE,
|
|
18871
18882
|
dependency_type TEXT DEFAULT 'requires'
|
|
18872
18883
|
CHECK(dependency_type IN ('requires', 'enhances', 'replaces')),
|
|
18873
18884
|
UNIQUE(feature_id, depends_on_feature_id)
|
|
18874
18885
|
);
|
|
18875
18886
|
|
|
18876
18887
|
-- Feature change log (audit trail)
|
|
18877
|
-
CREATE TABLE IF NOT EXISTS
|
|
18888
|
+
CREATE TABLE IF NOT EXISTS ${t("sentinel_changelog")} (
|
|
18878
18889
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18879
|
-
feature_id INTEGER NOT NULL REFERENCES
|
|
18890
|
+
feature_id INTEGER NOT NULL REFERENCES ${t("sentinel")}(id) ON DELETE CASCADE,
|
|
18880
18891
|
change_type TEXT NOT NULL,
|
|
18881
18892
|
changed_by TEXT,
|
|
18882
18893
|
change_detail TEXT,
|
|
@@ -18884,48 +18895,48 @@ function initDataSchema(db) {
|
|
|
18884
18895
|
created_at TEXT DEFAULT (datetime('now'))
|
|
18885
18896
|
);
|
|
18886
18897
|
|
|
18887
|
-
CREATE INDEX IF NOT EXISTS idx_sentinel_components_file ON
|
|
18888
|
-
CREATE INDEX IF NOT EXISTS idx_sentinel_procedures_router ON
|
|
18889
|
-
CREATE INDEX IF NOT EXISTS idx_sentinel_pages_route ON
|
|
18890
|
-
CREATE INDEX IF NOT EXISTS idx_sentinel_changelog_feature ON
|
|
18898
|
+
CREATE INDEX IF NOT EXISTS idx_sentinel_components_file ON ${t("sentinel_components")}(component_file);
|
|
18899
|
+
CREATE INDEX IF NOT EXISTS idx_sentinel_procedures_router ON ${t("sentinel_procedures")}(router_name);
|
|
18900
|
+
CREATE INDEX IF NOT EXISTS idx_sentinel_pages_route ON ${t("sentinel_pages")}(page_route);
|
|
18901
|
+
CREATE INDEX IF NOT EXISTS idx_sentinel_changelog_feature ON ${t("sentinel_changelog")}(feature_id);
|
|
18891
18902
|
`);
|
|
18892
18903
|
db.exec(`
|
|
18893
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS
|
|
18904
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS ${t("sentinel_fts")} USING fts5(
|
|
18894
18905
|
feature_key, title, description, domain, subdomain,
|
|
18895
|
-
content
|
|
18906
|
+
content=${t("sentinel")}, content_rowid=id
|
|
18896
18907
|
);
|
|
18897
18908
|
`);
|
|
18898
18909
|
db.exec(`
|
|
18899
|
-
CREATE TRIGGER IF NOT EXISTS massu_sentinel_ai AFTER INSERT ON
|
|
18900
|
-
INSERT INTO
|
|
18910
|
+
CREATE TRIGGER IF NOT EXISTS massu_sentinel_ai AFTER INSERT ON ${t("sentinel")} BEGIN
|
|
18911
|
+
INSERT INTO ${t("sentinel_fts")}(rowid, feature_key, title, description, domain, subdomain)
|
|
18901
18912
|
VALUES (new.id, new.feature_key, new.title, new.description, new.domain, new.subdomain);
|
|
18902
18913
|
END;
|
|
18903
18914
|
|
|
18904
|
-
CREATE TRIGGER IF NOT EXISTS massu_sentinel_ad AFTER DELETE ON
|
|
18905
|
-
INSERT INTO
|
|
18915
|
+
CREATE TRIGGER IF NOT EXISTS massu_sentinel_ad AFTER DELETE ON ${t("sentinel")} BEGIN
|
|
18916
|
+
INSERT INTO ${t("sentinel_fts")}(${t("sentinel_fts")}, rowid, feature_key, title, description, domain, subdomain)
|
|
18906
18917
|
VALUES ('delete', old.id, old.feature_key, old.title, old.description, old.domain, old.subdomain);
|
|
18907
18918
|
END;
|
|
18908
18919
|
|
|
18909
|
-
CREATE TRIGGER IF NOT EXISTS massu_sentinel_au AFTER UPDATE ON
|
|
18910
|
-
INSERT INTO
|
|
18920
|
+
CREATE TRIGGER IF NOT EXISTS massu_sentinel_au AFTER UPDATE ON ${t("sentinel")} BEGIN
|
|
18921
|
+
INSERT INTO ${t("sentinel_fts")}(${t("sentinel_fts")}, rowid, feature_key, title, description, domain, subdomain)
|
|
18911
18922
|
VALUES ('delete', old.id, old.feature_key, old.title, old.description, old.domain, old.subdomain);
|
|
18912
|
-
INSERT INTO
|
|
18923
|
+
INSERT INTO ${t("sentinel_fts")}(rowid, feature_key, title, description, domain, subdomain)
|
|
18913
18924
|
VALUES (new.id, new.feature_key, new.title, new.description, new.domain, new.subdomain);
|
|
18914
18925
|
END;
|
|
18915
18926
|
`);
|
|
18916
18927
|
}
|
|
18917
18928
|
function isDataStale(dataDb, codegraphDb) {
|
|
18918
|
-
const lastBuild = dataDb.prepare(
|
|
18929
|
+
const lastBuild = dataDb.prepare(`SELECT value FROM ${t("meta")} WHERE key = 'last_build_time'`).get();
|
|
18919
18930
|
if (!lastBuild) return true;
|
|
18920
18931
|
const latestIndexed = codegraphDb.prepare("SELECT MAX(indexed_at) as latest FROM files").get();
|
|
18921
18932
|
if (!latestIndexed?.latest) return true;
|
|
18922
18933
|
return latestIndexed.latest * 1e3 > new Date(lastBuild.value).getTime();
|
|
18923
18934
|
}
|
|
18924
18935
|
function updateBuildTimestamp(dataDb) {
|
|
18925
|
-
dataDb.prepare(
|
|
18936
|
+
dataDb.prepare(`INSERT OR REPLACE INTO ${t("meta")} (key, value) VALUES ('last_build_time', ?)`).run((/* @__PURE__ */ new Date()).toISOString());
|
|
18926
18937
|
}
|
|
18927
18938
|
function isPythonDataStale(dataDb, pythonRoot) {
|
|
18928
|
-
const lastBuild = dataDb.prepare(
|
|
18939
|
+
const lastBuild = dataDb.prepare(`SELECT value FROM ${t("py_meta")} WHERE key = 'last_build_time'`).get();
|
|
18929
18940
|
if (!lastBuild) return true;
|
|
18930
18941
|
const lastBuildTime = new Date(lastBuild.value).getTime();
|
|
18931
18942
|
function checkDir(dir) {
|
|
@@ -18947,13 +18958,14 @@ function isPythonDataStale(dataDb, pythonRoot) {
|
|
|
18947
18958
|
return checkDir(pythonRoot);
|
|
18948
18959
|
}
|
|
18949
18960
|
function updatePythonBuildTimestamp(dataDb) {
|
|
18950
|
-
dataDb.prepare(
|
|
18961
|
+
dataDb.prepare(`INSERT OR REPLACE INTO ${t("py_meta")} (key, value) VALUES ('last_build_time', ?)`).run((/* @__PURE__ */ new Date()).toISOString());
|
|
18951
18962
|
}
|
|
18952
18963
|
var CodegraphDbNotInitializedError;
|
|
18953
18964
|
var init_db = __esm({
|
|
18954
18965
|
"src/db.ts"() {
|
|
18955
18966
|
"use strict";
|
|
18956
18967
|
init_config();
|
|
18968
|
+
init_sql_table_names();
|
|
18957
18969
|
CodegraphDbNotInitializedError = class extends Error {
|
|
18958
18970
|
dbPath;
|
|
18959
18971
|
constructor(dbPath) {
|
|
@@ -19137,9 +19149,9 @@ function toRelative(absPath) {
|
|
|
19137
19149
|
}
|
|
19138
19150
|
function buildImportIndex(dataDb, codegraphDb) {
|
|
19139
19151
|
const files = codegraphDb.prepare("SELECT path FROM files WHERE path LIKE 'src/%'").all();
|
|
19140
|
-
dataDb.exec(
|
|
19152
|
+
dataDb.exec(`DELETE FROM ${t("imports")}`);
|
|
19141
19153
|
const insertStmt = dataDb.prepare(
|
|
19142
|
-
|
|
19154
|
+
`INSERT INTO ${t("imports")} (source_file, target_file, import_type, imported_names, line) VALUES (?, ?, ?, ?, ?)`
|
|
19143
19155
|
);
|
|
19144
19156
|
let edgeCount = 0;
|
|
19145
19157
|
const projectRoot = getProjectRoot();
|
|
@@ -19187,6 +19199,7 @@ var init_import_resolver = __esm({
|
|
|
19187
19199
|
"use strict";
|
|
19188
19200
|
init_config();
|
|
19189
19201
|
init_security_utils();
|
|
19202
|
+
init_sql_table_names();
|
|
19190
19203
|
}
|
|
19191
19204
|
});
|
|
19192
19205
|
|
|
@@ -19303,14 +19316,14 @@ function escapeRegex2(str) {
|
|
|
19303
19316
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
19304
19317
|
}
|
|
19305
19318
|
function buildTrpcIndex(dataDb) {
|
|
19306
|
-
dataDb.exec(
|
|
19307
|
-
dataDb.exec(
|
|
19319
|
+
dataDb.exec(`DELETE FROM ${t("trpc_call_sites")}`);
|
|
19320
|
+
dataDb.exec(`DELETE FROM ${t("trpc_procedures")}`);
|
|
19308
19321
|
const routerMappings = parseRootRouter();
|
|
19309
19322
|
const insertProc = dataDb.prepare(
|
|
19310
|
-
|
|
19323
|
+
`INSERT INTO ${t("trpc_procedures")} (router_file, router_name, procedure_name, procedure_type, has_ui_caller) VALUES (?, ?, ?, ?, ?)`
|
|
19311
19324
|
);
|
|
19312
19325
|
const insertCallSite = dataDb.prepare(
|
|
19313
|
-
|
|
19326
|
+
`INSERT INTO ${t("trpc_call_sites")} (procedure_id, file, line, call_pattern) VALUES (?, ?, ?, ?)`
|
|
19314
19327
|
);
|
|
19315
19328
|
let totalProcedures = 0;
|
|
19316
19329
|
let withCallers = 0;
|
|
@@ -19339,6 +19352,7 @@ var init_trpc_index = __esm({
|
|
|
19339
19352
|
"src/trpc-index.ts"() {
|
|
19340
19353
|
"use strict";
|
|
19341
19354
|
init_config();
|
|
19355
|
+
init_sql_table_names();
|
|
19342
19356
|
}
|
|
19343
19357
|
});
|
|
19344
19358
|
|
|
@@ -19363,7 +19377,7 @@ function traceImports(startFile, dataDb, visited, components, hooks, maxDepth =
|
|
|
19363
19377
|
if (maxDepth <= 0 || visited.has(startFile)) return;
|
|
19364
19378
|
visited.add(startFile);
|
|
19365
19379
|
const imports = dataDb.prepare(
|
|
19366
|
-
|
|
19380
|
+
`SELECT target_file, imported_names FROM ${t("imports")} WHERE source_file = ?`
|
|
19367
19381
|
).all(startFile);
|
|
19368
19382
|
for (const imp of imports) {
|
|
19369
19383
|
const target = imp.target_file;
|
|
@@ -19400,7 +19414,7 @@ function findTablesFromRouters(routerNames, dataDb) {
|
|
|
19400
19414
|
const tables = /* @__PURE__ */ new Set();
|
|
19401
19415
|
for (const routerName of routerNames) {
|
|
19402
19416
|
const procs = dataDb.prepare(
|
|
19403
|
-
|
|
19417
|
+
`SELECT DISTINCT router_file FROM ${t("trpc_procedures")} WHERE router_name = ?`
|
|
19404
19418
|
).all(routerName);
|
|
19405
19419
|
for (const proc of procs) {
|
|
19406
19420
|
const absPath = ensureWithinRoot(resolve27(getProjectRoot(), proc.router_file), getProjectRoot());
|
|
@@ -19421,12 +19435,12 @@ function findTablesFromRouters(routerNames, dataDb) {
|
|
|
19421
19435
|
return [...tables];
|
|
19422
19436
|
}
|
|
19423
19437
|
function buildPageDeps(dataDb, codegraphDb) {
|
|
19424
|
-
dataDb.exec(
|
|
19438
|
+
dataDb.exec(`DELETE FROM ${t("page_deps")}`);
|
|
19425
19439
|
const pages = codegraphDb.prepare(
|
|
19426
19440
|
"SELECT path FROM files WHERE path LIKE 'src/app/%/page.tsx' OR path = 'src/app/page.tsx'"
|
|
19427
19441
|
).all();
|
|
19428
19442
|
const insertStmt = dataDb.prepare(
|
|
19429
|
-
|
|
19443
|
+
`INSERT INTO ${t("page_deps")} (page_file, route, portal, components, hooks, routers, tables_touched) VALUES (?, ?, ?, ?, ?, ?, ?)`
|
|
19430
19444
|
);
|
|
19431
19445
|
let count = 0;
|
|
19432
19446
|
const insertAll = dataDb.transaction(() => {
|
|
@@ -19456,7 +19470,7 @@ function buildPageDeps(dataDb, codegraphDb) {
|
|
|
19456
19470
|
return count;
|
|
19457
19471
|
}
|
|
19458
19472
|
function getPageChain(dataDb, pageFile) {
|
|
19459
|
-
const row = dataDb.prepare(
|
|
19473
|
+
const row = dataDb.prepare(`SELECT * FROM ${t("page_deps")} WHERE page_file = ?`).get(pageFile);
|
|
19460
19474
|
if (!row) return null;
|
|
19461
19475
|
return {
|
|
19462
19476
|
page: row.page_file,
|
|
@@ -19472,7 +19486,7 @@ function findAffectedPages(dataDb, file) {
|
|
|
19472
19486
|
const directPage = getPageChain(dataDb, file);
|
|
19473
19487
|
if (directPage) return [directPage];
|
|
19474
19488
|
const importers = dataDb.prepare(
|
|
19475
|
-
|
|
19489
|
+
`SELECT source_file FROM ${t("imports")} WHERE target_file = ?`
|
|
19476
19490
|
).all(file);
|
|
19477
19491
|
const affectedFiles = /* @__PURE__ */ new Set([file, ...importers.map((i) => i.source_file)]);
|
|
19478
19492
|
let frontier = [...importers.map((i) => i.source_file)];
|
|
@@ -19483,7 +19497,7 @@ function findAffectedPages(dataDb, file) {
|
|
|
19483
19497
|
const next = [];
|
|
19484
19498
|
for (const f2 of frontier) {
|
|
19485
19499
|
const upstreamImporters = dataDb.prepare(
|
|
19486
|
-
|
|
19500
|
+
`SELECT source_file FROM ${t("imports")} WHERE target_file = ?`
|
|
19487
19501
|
).all(f2);
|
|
19488
19502
|
for (const imp of upstreamImporters) {
|
|
19489
19503
|
if (!visited.has(imp.source_file)) {
|
|
@@ -19496,7 +19510,7 @@ function findAffectedPages(dataDb, file) {
|
|
|
19496
19510
|
frontier = next;
|
|
19497
19511
|
depth++;
|
|
19498
19512
|
}
|
|
19499
|
-
const allPages = dataDb.prepare(
|
|
19513
|
+
const allPages = dataDb.prepare(`SELECT * FROM ${t("page_deps")}`).all();
|
|
19500
19514
|
const results = [];
|
|
19501
19515
|
for (const row of allPages) {
|
|
19502
19516
|
if (affectedFiles.has(row.page_file)) {
|
|
@@ -19518,12 +19532,13 @@ var init_page_deps = __esm({
|
|
|
19518
19532
|
"use strict";
|
|
19519
19533
|
init_config();
|
|
19520
19534
|
init_security_utils();
|
|
19535
|
+
init_sql_table_names();
|
|
19521
19536
|
}
|
|
19522
19537
|
});
|
|
19523
19538
|
|
|
19524
19539
|
// src/middleware-tree.ts
|
|
19525
19540
|
function buildMiddlewareTree(dataDb) {
|
|
19526
|
-
dataDb.exec(
|
|
19541
|
+
dataDb.exec(`DELETE FROM ${t("middleware_tree")}`);
|
|
19527
19542
|
const config = getConfig();
|
|
19528
19543
|
const middlewareFile = config.paths.middleware ?? "src/middleware.ts";
|
|
19529
19544
|
if (!middlewareFile) return 0;
|
|
@@ -19533,7 +19548,7 @@ function buildMiddlewareTree(dataDb) {
|
|
|
19533
19548
|
while (queue.length > 0) {
|
|
19534
19549
|
const current = queue.shift();
|
|
19535
19550
|
const imports = dataDb.prepare(
|
|
19536
|
-
|
|
19551
|
+
`SELECT target_file FROM ${t("imports")} WHERE source_file = ?`
|
|
19537
19552
|
).all(current);
|
|
19538
19553
|
for (const imp of imports) {
|
|
19539
19554
|
if (!visited.has(imp.target_file) && imp.target_file.startsWith("src/")) {
|
|
@@ -19542,7 +19557,7 @@ function buildMiddlewareTree(dataDb) {
|
|
|
19542
19557
|
}
|
|
19543
19558
|
}
|
|
19544
19559
|
}
|
|
19545
|
-
const insertStmt = dataDb.prepare(
|
|
19560
|
+
const insertStmt = dataDb.prepare(`INSERT INTO ${t("middleware_tree")} (file) VALUES (?)`);
|
|
19546
19561
|
const insertAll = dataDb.transaction(() => {
|
|
19547
19562
|
for (const file of visited) {
|
|
19548
19563
|
insertStmt.run(file);
|
|
@@ -19552,13 +19567,14 @@ function buildMiddlewareTree(dataDb) {
|
|
|
19552
19567
|
return visited.size;
|
|
19553
19568
|
}
|
|
19554
19569
|
function isInMiddlewareTree(dataDb, file) {
|
|
19555
|
-
const result = dataDb.prepare(
|
|
19570
|
+
const result = dataDb.prepare(`SELECT 1 FROM ${t("middleware_tree")} WHERE file = ?`).get(file);
|
|
19556
19571
|
return result !== void 0;
|
|
19557
19572
|
}
|
|
19558
19573
|
var init_middleware_tree = __esm({
|
|
19559
19574
|
"src/middleware-tree.ts"() {
|
|
19560
19575
|
"use strict";
|
|
19561
19576
|
init_config();
|
|
19577
|
+
init_sql_table_names();
|
|
19562
19578
|
}
|
|
19563
19579
|
});
|
|
19564
19580
|
|
|
@@ -19620,7 +19636,7 @@ function findCrossDomainImports(dataDb) {
|
|
|
19620
19636
|
const srcPrefix = config.paths.source;
|
|
19621
19637
|
const srcPattern = srcPrefix + "/%";
|
|
19622
19638
|
const imports = dataDb.prepare(
|
|
19623
|
-
|
|
19639
|
+
`SELECT source_file, target_file FROM ${t("imports")} WHERE source_file LIKE ? AND target_file LIKE ?`
|
|
19624
19640
|
).all(srcPattern, srcPattern);
|
|
19625
19641
|
const crossings = [];
|
|
19626
19642
|
for (const imp of imports) {
|
|
@@ -19671,6 +19687,7 @@ var init_domains = __esm({
|
|
|
19671
19687
|
"use strict";
|
|
19672
19688
|
init_rules();
|
|
19673
19689
|
init_config();
|
|
19690
|
+
init_sql_table_names();
|
|
19674
19691
|
}
|
|
19675
19692
|
});
|
|
19676
19693
|
|
|
@@ -20006,9 +20023,9 @@ function walkPythonFiles(dir, excludeDirs) {
|
|
|
20006
20023
|
function buildPythonImportIndex(dataDb, pythonRoot, excludeDirs = ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache"]) {
|
|
20007
20024
|
const projectRoot = getProjectRoot();
|
|
20008
20025
|
const absRoot = resolve29(projectRoot, pythonRoot);
|
|
20009
|
-
dataDb.exec(
|
|
20026
|
+
dataDb.exec(`DELETE FROM ${t("py_imports")}`);
|
|
20010
20027
|
const insertStmt = dataDb.prepare(
|
|
20011
|
-
|
|
20028
|
+
`INSERT INTO ${t("py_imports")} (source_file, target_file, import_type, imported_names, line) VALUES (?, ?, ?, ?, ?)`
|
|
20012
20029
|
);
|
|
20013
20030
|
const files = walkPythonFiles(absRoot, excludeDirs);
|
|
20014
20031
|
let edgeCount = 0;
|
|
@@ -20053,6 +20070,7 @@ var init_import_resolver2 = __esm({
|
|
|
20053
20070
|
"use strict";
|
|
20054
20071
|
init_import_parser();
|
|
20055
20072
|
init_config();
|
|
20073
|
+
init_sql_table_names();
|
|
20056
20074
|
}
|
|
20057
20075
|
});
|
|
20058
20076
|
|
|
@@ -20309,10 +20327,10 @@ function walkPyFiles(dir, excludeDirs) {
|
|
|
20309
20327
|
function buildPythonRouteIndex(dataDb, pythonRoot, excludeDirs = ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache"]) {
|
|
20310
20328
|
const projectRoot = getProjectRoot();
|
|
20311
20329
|
const absRoot = join17(projectRoot, pythonRoot);
|
|
20312
|
-
dataDb.exec(
|
|
20313
|
-
dataDb.exec(
|
|
20330
|
+
dataDb.exec(`DELETE FROM ${t("py_routes")}`);
|
|
20331
|
+
dataDb.exec(`DELETE FROM ${t("py_route_callers")}`);
|
|
20314
20332
|
const insertStmt = dataDb.prepare(
|
|
20315
|
-
|
|
20333
|
+
`INSERT INTO ${t("py_routes")} (file, method, path, function_name, dependencies, request_model, response_model, is_authenticated, line) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
20316
20334
|
);
|
|
20317
20335
|
const files = walkPyFiles(absRoot, excludeDirs);
|
|
20318
20336
|
let count = 0;
|
|
@@ -20349,6 +20367,7 @@ var init_route_indexer = __esm({
|
|
|
20349
20367
|
"use strict";
|
|
20350
20368
|
init_route_parser();
|
|
20351
20369
|
init_config();
|
|
20370
|
+
init_sql_table_names();
|
|
20352
20371
|
}
|
|
20353
20372
|
});
|
|
20354
20373
|
|
|
@@ -20553,13 +20572,13 @@ function walkPyFiles2(dir, excludeDirs) {
|
|
|
20553
20572
|
function buildPythonModelIndex(dataDb, pythonRoot, excludeDirs = ["__pycache__", ".venv", "venv", ".mypy_cache", ".pytest_cache"]) {
|
|
20554
20573
|
const projectRoot = getProjectRoot();
|
|
20555
20574
|
const absRoot = join18(projectRoot, pythonRoot);
|
|
20556
|
-
dataDb.exec(
|
|
20557
|
-
dataDb.exec(
|
|
20575
|
+
dataDb.exec(`DELETE FROM ${t("py_models")}`);
|
|
20576
|
+
dataDb.exec(`DELETE FROM ${t("py_fk_edges")}`);
|
|
20558
20577
|
const insertModel = dataDb.prepare(
|
|
20559
|
-
|
|
20578
|
+
`INSERT INTO ${t("py_models")} (class_name, table_name, file, line, columns, relationships, foreign_keys) VALUES (?, ?, ?, ?, ?, ?, ?)`
|
|
20560
20579
|
);
|
|
20561
20580
|
const insertFk = dataDb.prepare(
|
|
20562
|
-
|
|
20581
|
+
`INSERT INTO ${t("py_fk_edges")} (source_table, source_column, target_table, target_column) VALUES (?, ?, ?, ?)`
|
|
20563
20582
|
);
|
|
20564
20583
|
const files = walkPyFiles2(absRoot, excludeDirs);
|
|
20565
20584
|
let count = 0;
|
|
@@ -20602,6 +20621,7 @@ var init_model_indexer = __esm({
|
|
|
20602
20621
|
"use strict";
|
|
20603
20622
|
init_model_parser();
|
|
20604
20623
|
init_config();
|
|
20624
|
+
init_sql_table_names();
|
|
20605
20625
|
}
|
|
20606
20626
|
});
|
|
20607
20627
|
|
|
@@ -20833,7 +20853,7 @@ import { join as join19, relative as relative9 } from "path";
|
|
|
20833
20853
|
function buildPythonMigrationIndex(dataDb, alembicDir) {
|
|
20834
20854
|
const projectRoot = getProjectRoot();
|
|
20835
20855
|
const absDir = join19(projectRoot, alembicDir);
|
|
20836
|
-
dataDb.exec(
|
|
20856
|
+
dataDb.exec(`DELETE FROM ${t("py_migrations")}`);
|
|
20837
20857
|
const versionsDir = join19(absDir, "versions");
|
|
20838
20858
|
let files = [];
|
|
20839
20859
|
try {
|
|
@@ -20845,7 +20865,7 @@ function buildPythonMigrationIndex(dataDb, alembicDir) {
|
|
|
20845
20865
|
}
|
|
20846
20866
|
}
|
|
20847
20867
|
const insertStmt = dataDb.prepare(
|
|
20848
|
-
|
|
20868
|
+
`INSERT INTO ${t("py_migrations")} (revision, down_revision, file, description, operations, is_head) VALUES (?, ?, ?, ?, ?, ?)`
|
|
20849
20869
|
);
|
|
20850
20870
|
let count = 0;
|
|
20851
20871
|
const allRevisions = /* @__PURE__ */ new Set();
|
|
@@ -20884,6 +20904,7 @@ var init_migration_indexer = __esm({
|
|
|
20884
20904
|
"use strict";
|
|
20885
20905
|
init_migration_parser();
|
|
20886
20906
|
init_config();
|
|
20907
|
+
init_sql_table_names();
|
|
20887
20908
|
}
|
|
20888
20909
|
});
|
|
20889
20910
|
|
|
@@ -20894,12 +20915,12 @@ function buildPythonCouplingIndex(dataDb) {
|
|
|
20894
20915
|
const projectRoot = getProjectRoot();
|
|
20895
20916
|
const config = getConfig();
|
|
20896
20917
|
const srcDir = join20(projectRoot, config.paths.source);
|
|
20897
|
-
const routes = dataDb.prepare(
|
|
20918
|
+
const routes = dataDb.prepare(`SELECT id, method, path FROM ${t("py_routes")}`).all();
|
|
20898
20919
|
if (routes.length === 0) return 0;
|
|
20899
|
-
dataDb.exec(
|
|
20920
|
+
dataDb.exec(`DELETE FROM ${t("py_route_callers")}`);
|
|
20900
20921
|
const frontendFiles = walkFrontendFiles(srcDir);
|
|
20901
20922
|
const insertStmt = dataDb.prepare(
|
|
20902
|
-
|
|
20923
|
+
`INSERT INTO ${t("py_route_callers")} (route_id, frontend_file, line, call_pattern) VALUES (?, ?, ?, ?)`
|
|
20903
20924
|
);
|
|
20904
20925
|
let count = 0;
|
|
20905
20926
|
const apiPatterns = [
|
|
@@ -20984,6 +21005,7 @@ var init_coupling_detector = __esm({
|
|
|
20984
21005
|
"src/python/coupling-detector.ts"() {
|
|
20985
21006
|
"use strict";
|
|
20986
21007
|
init_config();
|
|
21008
|
+
init_sql_table_names();
|
|
20987
21009
|
}
|
|
20988
21010
|
});
|
|
20989
21011
|
|
|
@@ -21813,8 +21835,8 @@ function handlePromptAnalysis(args2, db) {
|
|
|
21813
21835
|
const lines2 = ["## Recent Prompts", ""];
|
|
21814
21836
|
lines2.push("| Session | Turn | Prompt (truncated) | Tools | Response Tokens | Date |");
|
|
21815
21837
|
lines2.push("|---------|------|--------------------|-------|-----------------|------|");
|
|
21816
|
-
for (const
|
|
21817
|
-
lines2.push(`| ${
|
|
21838
|
+
for (const t2 of recentTurns) {
|
|
21839
|
+
lines2.push(`| ${t2.session_id.slice(0, 8)}... | ${t2.turn_number} | ${t2.user_prompt.slice(0, 60).replace(/\|/g, "\\|")} | ${t2.tool_call_count} | ${t2.response_tokens ?? "-"} | ${t2.created_at.split("T")[0]} |`);
|
|
21818
21840
|
}
|
|
21819
21841
|
return text3(lines2.join("\n"));
|
|
21820
21842
|
}
|
|
@@ -21969,10 +21991,10 @@ function toFeature(row) {
|
|
|
21969
21991
|
};
|
|
21970
21992
|
}
|
|
21971
21993
|
function upsertFeature(db, input) {
|
|
21972
|
-
const existing = db.prepare(
|
|
21994
|
+
const existing = db.prepare(`SELECT id FROM ${t("sentinel")} WHERE feature_key = ?`).get(input.feature_key);
|
|
21973
21995
|
if (existing) {
|
|
21974
21996
|
db.prepare(`
|
|
21975
|
-
UPDATE
|
|
21997
|
+
UPDATE ${t("sentinel")} SET
|
|
21976
21998
|
domain = ?, subdomain = ?, title = ?, description = ?,
|
|
21977
21999
|
status = COALESCE(?, status), priority = COALESCE(?, priority),
|
|
21978
22000
|
portal_scope = COALESCE(?, portal_scope),
|
|
@@ -21991,7 +22013,7 @@ function upsertFeature(db, input) {
|
|
|
21991
22013
|
return existing.id;
|
|
21992
22014
|
}
|
|
21993
22015
|
const result = db.prepare(`
|
|
21994
|
-
INSERT INTO
|
|
22016
|
+
INSERT INTO ${t("sentinel")} (feature_key, domain, subdomain, title, description, status, priority, portal_scope)
|
|
21995
22017
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
21996
22018
|
`).run(
|
|
21997
22019
|
input.feature_key,
|
|
@@ -22006,11 +22028,11 @@ function upsertFeature(db, input) {
|
|
|
22006
22028
|
return Number(result.lastInsertRowid);
|
|
22007
22029
|
}
|
|
22008
22030
|
function getFeature(db, featureKey) {
|
|
22009
|
-
const row = db.prepare(
|
|
22031
|
+
const row = db.prepare(`SELECT * FROM ${t("sentinel")} WHERE feature_key = ?`).get(featureKey);
|
|
22010
22032
|
return row ? toFeature(row) : null;
|
|
22011
22033
|
}
|
|
22012
22034
|
function getFeatureById(db, id) {
|
|
22013
|
-
const row = db.prepare(
|
|
22035
|
+
const row = db.prepare(`SELECT * FROM ${t("sentinel")} WHERE id = ?`).get(id);
|
|
22014
22036
|
return row ? toFeature(row) : null;
|
|
22015
22037
|
}
|
|
22016
22038
|
function searchFeatures(db, query, filters) {
|
|
@@ -22019,21 +22041,21 @@ function searchFeatures(db, query, filters) {
|
|
|
22019
22041
|
if (query && query.trim()) {
|
|
22020
22042
|
sql = `
|
|
22021
22043
|
SELECT s.*, fts.rank,
|
|
22022
|
-
(SELECT COUNT(*) FROM
|
|
22023
|
-
(SELECT COUNT(*) FROM
|
|
22024
|
-
(SELECT COUNT(*) FROM
|
|
22025
|
-
FROM
|
|
22026
|
-
JOIN
|
|
22027
|
-
WHERE
|
|
22044
|
+
(SELECT COUNT(*) FROM ${t("sentinel_components")} WHERE feature_id = s.id) as component_count,
|
|
22045
|
+
(SELECT COUNT(*) FROM ${t("sentinel_procedures")} WHERE feature_id = s.id) as procedure_count,
|
|
22046
|
+
(SELECT COUNT(*) FROM ${t("sentinel_pages")} WHERE feature_id = s.id) as page_count
|
|
22047
|
+
FROM ${t("sentinel")} s
|
|
22048
|
+
JOIN ${t("sentinel_fts")} fts ON s.id = fts.rowid
|
|
22049
|
+
WHERE ${t("sentinel_fts")} MATCH ?
|
|
22028
22050
|
`;
|
|
22029
22051
|
params.push(sanitizeFts5Query(query));
|
|
22030
22052
|
} else {
|
|
22031
22053
|
sql = `
|
|
22032
22054
|
SELECT s.*,
|
|
22033
|
-
(SELECT COUNT(*) FROM
|
|
22034
|
-
(SELECT COUNT(*) FROM
|
|
22035
|
-
(SELECT COUNT(*) FROM
|
|
22036
|
-
FROM
|
|
22055
|
+
(SELECT COUNT(*) FROM ${t("sentinel_components")} WHERE feature_id = s.id) as component_count,
|
|
22056
|
+
(SELECT COUNT(*) FROM ${t("sentinel_procedures")} WHERE feature_id = s.id) as procedure_count,
|
|
22057
|
+
(SELECT COUNT(*) FROM ${t("sentinel_pages")} WHERE feature_id = s.id) as page_count
|
|
22058
|
+
FROM ${t("sentinel")} s
|
|
22037
22059
|
WHERE 1=1
|
|
22038
22060
|
`;
|
|
22039
22061
|
}
|
|
@@ -22055,7 +22077,7 @@ function searchFeatures(db, query, filters) {
|
|
|
22055
22077
|
params.push(`%"${escapedPortal}"%`);
|
|
22056
22078
|
}
|
|
22057
22079
|
if (filters?.page_route) {
|
|
22058
|
-
sql +=
|
|
22080
|
+
sql += ` AND s.id IN (SELECT feature_id FROM ${t("sentinel_pages")} WHERE page_route = ?)`;
|
|
22059
22081
|
params.push(filters.page_route);
|
|
22060
22082
|
}
|
|
22061
22083
|
sql += query && query.trim() ? " ORDER BY fts.rank LIMIT 100" : " ORDER BY s.domain, s.subdomain, s.feature_key LIMIT 100";
|
|
@@ -22075,11 +22097,11 @@ function getFeatureDetail(db, featureKeyOrId) {
|
|
|
22075
22097
|
feature = getFeature(db, featureKeyOrId);
|
|
22076
22098
|
}
|
|
22077
22099
|
if (!feature) return null;
|
|
22078
|
-
const components = db.prepare(
|
|
22079
|
-
const procedures = db.prepare(
|
|
22080
|
-
const pages = db.prepare(
|
|
22081
|
-
const dependencies = db.prepare(
|
|
22082
|
-
const changelog = db.prepare(
|
|
22100
|
+
const components = db.prepare(`SELECT * FROM ${t("sentinel_components")} WHERE feature_id = ?`).all(feature.id);
|
|
22101
|
+
const procedures = db.prepare(`SELECT * FROM ${t("sentinel_procedures")} WHERE feature_id = ?`).all(feature.id);
|
|
22102
|
+
const pages = db.prepare(`SELECT * FROM ${t("sentinel_pages")} WHERE feature_id = ?`).all(feature.id);
|
|
22103
|
+
const dependencies = db.prepare(`SELECT * FROM ${t("sentinel_deps")} WHERE feature_id = ?`).all(feature.id);
|
|
22104
|
+
const changelog = db.prepare(`SELECT * FROM ${t("sentinel_changelog")} WHERE feature_id = ? ORDER BY created_at DESC LIMIT 50`).all(feature.id);
|
|
22083
22105
|
return { ...feature, components, procedures, pages, dependencies, changelog };
|
|
22084
22106
|
}
|
|
22085
22107
|
function getFeatureImpact(db, filePaths) {
|
|
@@ -22087,7 +22109,7 @@ function getFeatureImpact(db, filePaths) {
|
|
|
22087
22109
|
const affectedFeatureIds = /* @__PURE__ */ new Set();
|
|
22088
22110
|
for (const filePath of filePaths) {
|
|
22089
22111
|
const links = db.prepare(
|
|
22090
|
-
|
|
22112
|
+
`SELECT feature_id FROM ${t("sentinel_components")} WHERE component_file = ?`
|
|
22091
22113
|
).all(filePath);
|
|
22092
22114
|
for (const link of links) {
|
|
22093
22115
|
affectedFeatureIds.add(link.feature_id);
|
|
@@ -22100,7 +22122,7 @@ function getFeatureImpact(db, filePaths) {
|
|
|
22100
22122
|
const feature = getFeatureById(db, featureId);
|
|
22101
22123
|
if (!feature || feature.status !== "active") continue;
|
|
22102
22124
|
const allComponents = db.prepare(
|
|
22103
|
-
|
|
22125
|
+
`SELECT component_file, is_primary FROM ${t("sentinel_components")} WHERE feature_id = ?`
|
|
22104
22126
|
).all(featureId);
|
|
22105
22127
|
const affected = allComponents.filter((c2) => fileSet.has(c2.component_file));
|
|
22106
22128
|
const remaining = allComponents.filter((c2) => !fileSet.has(c2.component_file));
|
|
@@ -22134,30 +22156,30 @@ function getFeatureImpact(db, filePaths) {
|
|
|
22134
22156
|
}
|
|
22135
22157
|
function linkComponent(db, featureId, filePath, componentName, role = "implementation", isPrimary = false) {
|
|
22136
22158
|
db.prepare(`
|
|
22137
|
-
INSERT OR REPLACE INTO
|
|
22159
|
+
INSERT OR REPLACE INTO ${t("sentinel_components")} (feature_id, component_file, component_name, role, is_primary)
|
|
22138
22160
|
VALUES (?, ?, ?, ?, ?)
|
|
22139
22161
|
`).run(featureId, filePath, componentName, role, isPrimary ? 1 : 0);
|
|
22140
22162
|
}
|
|
22141
22163
|
function linkProcedure(db, featureId, routerName, procedureName, procedureType) {
|
|
22142
22164
|
db.prepare(`
|
|
22143
|
-
INSERT OR REPLACE INTO
|
|
22165
|
+
INSERT OR REPLACE INTO ${t("sentinel_procedures")} (feature_id, router_name, procedure_name, procedure_type)
|
|
22144
22166
|
VALUES (?, ?, ?, ?)
|
|
22145
22167
|
`).run(featureId, routerName, procedureName, procedureType || null);
|
|
22146
22168
|
}
|
|
22147
22169
|
function linkPage(db, featureId, route, portal) {
|
|
22148
22170
|
db.prepare(`
|
|
22149
|
-
INSERT OR REPLACE INTO
|
|
22171
|
+
INSERT OR REPLACE INTO ${t("sentinel_pages")} (feature_id, page_route, portal)
|
|
22150
22172
|
VALUES (?, ?, ?)
|
|
22151
22173
|
`).run(featureId, route, portal || null);
|
|
22152
22174
|
}
|
|
22153
22175
|
function logChange(db, featureId, changeType, detail, commitHash, changedBy = "claude-code") {
|
|
22154
22176
|
db.prepare(`
|
|
22155
|
-
INSERT INTO
|
|
22177
|
+
INSERT INTO ${t("sentinel_changelog")} (feature_id, change_type, changed_by, change_detail, commit_hash)
|
|
22156
22178
|
VALUES (?, ?, ?, ?, ?)
|
|
22157
22179
|
`).run(featureId, changeType, changedBy, detail, commitHash || null);
|
|
22158
22180
|
}
|
|
22159
22181
|
function validateFeatures(db, domainFilter) {
|
|
22160
|
-
let sql = `SELECT * FROM
|
|
22182
|
+
let sql = `SELECT * FROM ${t("sentinel")} WHERE status = 'active'`;
|
|
22161
22183
|
const params = [];
|
|
22162
22184
|
if (domainFilter) {
|
|
22163
22185
|
sql += " AND domain = ?";
|
|
@@ -22171,9 +22193,9 @@ function validateFeatures(db, domainFilter) {
|
|
|
22171
22193
|
let degradedCount = 0;
|
|
22172
22194
|
for (const row of features) {
|
|
22173
22195
|
const feature = toFeature(row);
|
|
22174
|
-
const components = db.prepare(
|
|
22175
|
-
const procedures = db.prepare(
|
|
22176
|
-
const pages = db.prepare(
|
|
22196
|
+
const components = db.prepare(`SELECT * FROM ${t("sentinel_components")} WHERE feature_id = ?`).all(feature.id);
|
|
22197
|
+
const procedures = db.prepare(`SELECT * FROM ${t("sentinel_procedures")} WHERE feature_id = ?`).all(feature.id);
|
|
22198
|
+
const pages = db.prepare(`SELECT * FROM ${t("sentinel_pages")} WHERE feature_id = ?`).all(feature.id);
|
|
22177
22199
|
const missingComponents = [];
|
|
22178
22200
|
const missingProcedures = [];
|
|
22179
22201
|
const missingPages = [];
|
|
@@ -22228,14 +22250,14 @@ function checkParity(db, oldFiles, newFiles) {
|
|
|
22228
22250
|
const newFileSet = new Set(newFiles);
|
|
22229
22251
|
const oldFeatureIds = /* @__PURE__ */ new Set();
|
|
22230
22252
|
for (const file of oldFiles) {
|
|
22231
|
-
const links = db.prepare(
|
|
22253
|
+
const links = db.prepare(`SELECT feature_id FROM ${t("sentinel_components")} WHERE component_file = ?`).all(file);
|
|
22232
22254
|
for (const link of links) {
|
|
22233
22255
|
oldFeatureIds.add(link.feature_id);
|
|
22234
22256
|
}
|
|
22235
22257
|
}
|
|
22236
22258
|
const newFeatureIds = /* @__PURE__ */ new Set();
|
|
22237
22259
|
for (const file of newFiles) {
|
|
22238
|
-
const links = db.prepare(
|
|
22260
|
+
const links = db.prepare(`SELECT feature_id FROM ${t("sentinel_components")} WHERE component_file = ?`).all(file);
|
|
22239
22261
|
for (const link of links) {
|
|
22240
22262
|
newFeatureIds.add(link.feature_id);
|
|
22241
22263
|
}
|
|
@@ -22246,8 +22268,8 @@ function checkParity(db, oldFiles, newFiles) {
|
|
|
22246
22268
|
for (const fId of oldFeatureIds) {
|
|
22247
22269
|
const feature = getFeatureById(db, fId);
|
|
22248
22270
|
if (!feature) continue;
|
|
22249
|
-
const oldComps = db.prepare(
|
|
22250
|
-
const newComps = db.prepare(
|
|
22271
|
+
const oldComps = db.prepare(`SELECT component_file FROM ${t("sentinel_components")} WHERE feature_id = ? AND component_file IN (` + oldFiles.map(() => "?").join(",") + ")").all(fId, ...oldFiles);
|
|
22272
|
+
const newComps = db.prepare(`SELECT component_file FROM ${t("sentinel_components")} WHERE feature_id = ? AND component_file IN (` + newFiles.map(() => "?").join(",") + ")").all(fId, ...newFiles);
|
|
22251
22273
|
const item = {
|
|
22252
22274
|
feature_key: feature.feature_key,
|
|
22253
22275
|
title: feature.title,
|
|
@@ -22265,7 +22287,7 @@ function checkParity(db, oldFiles, newFiles) {
|
|
|
22265
22287
|
if (oldFeatureIds.has(fId)) continue;
|
|
22266
22288
|
const feature = getFeatureById(db, fId);
|
|
22267
22289
|
if (!feature) continue;
|
|
22268
|
-
const newComps = db.prepare(
|
|
22290
|
+
const newComps = db.prepare(`SELECT component_file FROM ${t("sentinel_components")} WHERE feature_id = ? AND component_file IN (` + newFiles.map(() => "?").join(",") + ")").all(fId, ...newFiles);
|
|
22269
22291
|
newFeatures.push({
|
|
22270
22292
|
feature_key: feature.feature_key,
|
|
22271
22293
|
title: feature.title,
|
|
@@ -22284,6 +22306,7 @@ var init_sentinel_db = __esm({
|
|
|
22284
22306
|
"use strict";
|
|
22285
22307
|
init_config();
|
|
22286
22308
|
init_memory_db();
|
|
22309
|
+
init_sql_table_names();
|
|
22287
22310
|
PROJECT_ROOT = getProjectRoot();
|
|
22288
22311
|
}
|
|
22289
22312
|
});
|
|
@@ -22620,7 +22643,7 @@ function handleValidate(args2, db) {
|
|
|
22620
22643
|
if (fix) {
|
|
22621
22644
|
lines.push("### Auto-Fix Applied");
|
|
22622
22645
|
for (const item of issues.filter((i) => i.status === "orphaned")) {
|
|
22623
|
-
db.prepare(
|
|
22646
|
+
db.prepare(`UPDATE ${t("sentinel")} SET status = 'deprecated', updated_at = datetime('now') WHERE id = ?`).run(item.feature.id);
|
|
22624
22647
|
logChange(db, item.feature.id, "deprecated", "Auto-deprecated: all primary components missing");
|
|
22625
22648
|
lines.push(`- Deprecated: ${item.feature.feature_key}`);
|
|
22626
22649
|
}
|
|
@@ -22714,6 +22737,7 @@ var init_sentinel_tools = __esm({
|
|
|
22714
22737
|
"use strict";
|
|
22715
22738
|
init_sentinel_db();
|
|
22716
22739
|
init_config();
|
|
22740
|
+
init_sql_table_names();
|
|
22717
22741
|
}
|
|
22718
22742
|
});
|
|
22719
22743
|
|
|
@@ -22770,7 +22794,7 @@ function scanTrpcProcedures(dataDb) {
|
|
|
22770
22794
|
const featureMap = /* @__PURE__ */ new Map();
|
|
22771
22795
|
const procedures = dataDb.prepare(`
|
|
22772
22796
|
SELECT router_name, procedure_name, procedure_type, router_file
|
|
22773
|
-
FROM
|
|
22797
|
+
FROM ${t("trpc_procedures")}
|
|
22774
22798
|
ORDER BY router_name, procedure_name
|
|
22775
22799
|
`).all();
|
|
22776
22800
|
for (const proc of procedures) {
|
|
@@ -22812,7 +22836,7 @@ function scanPageRoutes(dataDb) {
|
|
|
22812
22836
|
const features = [];
|
|
22813
22837
|
const pages = dataDb.prepare(`
|
|
22814
22838
|
SELECT page_file, route, portal, components, hooks, routers
|
|
22815
|
-
FROM
|
|
22839
|
+
FROM ${t("page_deps")}
|
|
22816
22840
|
ORDER BY route
|
|
22817
22841
|
`).all();
|
|
22818
22842
|
for (const page of pages) {
|
|
@@ -22983,6 +23007,7 @@ var init_sentinel_scanner = __esm({
|
|
|
22983
23007
|
"use strict";
|
|
22984
23008
|
init_sentinel_db();
|
|
22985
23009
|
init_config();
|
|
23010
|
+
init_sql_table_names();
|
|
22986
23011
|
}
|
|
22987
23012
|
});
|
|
22988
23013
|
|
|
@@ -26747,7 +26772,7 @@ function handleGaps(db, args2) {
|
|
|
26747
26772
|
let dataDb = null;
|
|
26748
26773
|
try {
|
|
26749
26774
|
dataDb = getDataDb();
|
|
26750
|
-
let sql =
|
|
26775
|
+
let sql = `SELECT feature_key, title, domain, status FROM ${t("sentinel")} WHERE status = 'active'`;
|
|
26751
26776
|
const params = [];
|
|
26752
26777
|
if (domain) {
|
|
26753
26778
|
sql += " AND domain LIKE ?";
|
|
@@ -26814,7 +26839,7 @@ function handleGaps(db, args2) {
|
|
|
26814
26839
|
try {
|
|
26815
26840
|
dataDb = getDataDb();
|
|
26816
26841
|
const domains = dataDb.prepare(
|
|
26817
|
-
|
|
26842
|
+
`SELECT DISTINCT domain FROM ${t("sentinel")} WHERE status = 'active' ORDER BY domain`
|
|
26818
26843
|
).all();
|
|
26819
26844
|
for (const d2 of domains) {
|
|
26820
26845
|
const hasPattern = documentedDomains.has(d2.domain.toLowerCase());
|
|
@@ -26925,6 +26950,7 @@ var init_knowledge_tools = __esm({
|
|
|
26925
26950
|
init_config();
|
|
26926
26951
|
init_db();
|
|
26927
26952
|
init_memory_db();
|
|
26953
|
+
init_sql_table_names();
|
|
26928
26954
|
KNOWLEDGE_BASE_NAMES = /* @__PURE__ */ new Set([
|
|
26929
26955
|
"knowledge_search",
|
|
26930
26956
|
"knowledge_rule",
|
|
@@ -27135,6 +27161,7 @@ var init_domain_enforcer = __esm({
|
|
|
27135
27161
|
"src/python/domain-enforcer.ts"() {
|
|
27136
27162
|
"use strict";
|
|
27137
27163
|
init_config();
|
|
27164
|
+
init_sql_table_names();
|
|
27138
27165
|
}
|
|
27139
27166
|
});
|
|
27140
27167
|
|
|
@@ -27307,7 +27334,7 @@ function handlePyImports(args2, dataDb) {
|
|
|
27307
27334
|
if (depth > maxDepth || visited.has(f2)) return;
|
|
27308
27335
|
visited.add(f2);
|
|
27309
27336
|
const imports = dataDb.prepare(
|
|
27310
|
-
|
|
27337
|
+
`SELECT target_file, imported_names FROM ${t("py_imports")} WHERE source_file = ?`
|
|
27311
27338
|
).all(f2);
|
|
27312
27339
|
for (const imp of imports) {
|
|
27313
27340
|
const indent = " ".repeat(depth);
|
|
@@ -27322,7 +27349,7 @@ function handlePyImports(args2, dataDb) {
|
|
|
27322
27349
|
traverse2(file, 0);
|
|
27323
27350
|
} else {
|
|
27324
27351
|
const imports = dataDb.prepare(
|
|
27325
|
-
|
|
27352
|
+
`SELECT target_file, import_type, imported_names, line FROM ${t("py_imports")} WHERE source_file = ? ORDER BY line`
|
|
27326
27353
|
).all(file);
|
|
27327
27354
|
lines.push(`## Imports from ${file} (${imports.length} edges)`);
|
|
27328
27355
|
for (const imp of imports) {
|
|
@@ -27332,7 +27359,7 @@ function handlePyImports(args2, dataDb) {
|
|
|
27332
27359
|
}
|
|
27333
27360
|
} else if (importedBy) {
|
|
27334
27361
|
const importers = dataDb.prepare(
|
|
27335
|
-
|
|
27362
|
+
`SELECT source_file, imported_names, line FROM ${t("py_imports")} WHERE target_file = ? ORDER BY source_file`
|
|
27336
27363
|
).all(importedBy);
|
|
27337
27364
|
lines.push(`## Files importing ${importedBy} (${importers.length} edges)`);
|
|
27338
27365
|
for (const imp of importers) {
|
|
@@ -27340,8 +27367,8 @@ function handlePyImports(args2, dataDb) {
|
|
|
27340
27367
|
lines.push(`- ${imp.source_file}:${imp.line}${names.length > 0 ? " (" + names.join(", ") + ")" : ""}`);
|
|
27341
27368
|
}
|
|
27342
27369
|
} else {
|
|
27343
|
-
const total = dataDb.prepare(
|
|
27344
|
-
const files = dataDb.prepare(
|
|
27370
|
+
const total = dataDb.prepare(`SELECT COUNT(*) as cnt FROM ${t("py_imports")}`).get().cnt;
|
|
27371
|
+
const files = dataDb.prepare(`SELECT COUNT(DISTINCT source_file) as cnt FROM ${t("py_imports")}`).get().cnt;
|
|
27345
27372
|
lines.push("## Python Import Index Summary");
|
|
27346
27373
|
lines.push(`- Total import edges: ${total}`);
|
|
27347
27374
|
lines.push(`- Files with imports: ${files}`);
|
|
@@ -27354,7 +27381,7 @@ function handlePyImports(args2, dataDb) {
|
|
|
27354
27381
|
function handlePyRoutes(args2, dataDb) {
|
|
27355
27382
|
const lines = [];
|
|
27356
27383
|
const limit = Math.min(Math.max(args2.limit || 500, 1), 5e3);
|
|
27357
|
-
let query =
|
|
27384
|
+
let query = `SELECT * FROM ${t("py_routes")} WHERE 1=1`;
|
|
27358
27385
|
const params = [];
|
|
27359
27386
|
if (args2.method) {
|
|
27360
27387
|
query += " AND method = ?";
|
|
@@ -27374,7 +27401,7 @@ function handlePyRoutes(args2, dataDb) {
|
|
|
27374
27401
|
query += ` ORDER BY file, line LIMIT ${limit}`;
|
|
27375
27402
|
const routes = dataDb.prepare(query).all(...params);
|
|
27376
27403
|
if (args2.uncoupled) {
|
|
27377
|
-
const callerCountStmt = dataDb.prepare(
|
|
27404
|
+
const callerCountStmt = dataDb.prepare(`SELECT COUNT(*) as cnt FROM ${t("py_route_callers")} WHERE route_id = ?`);
|
|
27378
27405
|
const uncoupledRoutes = routes.filter((r2) => {
|
|
27379
27406
|
const callers = callerCountStmt.get(r2.id).cnt;
|
|
27380
27407
|
return callers === 0;
|
|
@@ -27400,8 +27427,8 @@ function handlePyCoupling(args2, dataDb) {
|
|
|
27400
27427
|
let query = `
|
|
27401
27428
|
SELECT rc.frontend_file, rc.call_pattern, rc.line as caller_line,
|
|
27402
27429
|
r.method, r.path, r.function_name, r.file as backend_file
|
|
27403
|
-
FROM
|
|
27404
|
-
JOIN
|
|
27430
|
+
FROM ${t("py_route_callers")} rc
|
|
27431
|
+
JOIN ${t("py_routes")} r ON rc.route_id = r.id
|
|
27405
27432
|
WHERE 1=1
|
|
27406
27433
|
`;
|
|
27407
27434
|
const params = [];
|
|
@@ -27430,7 +27457,7 @@ function handlePyCoupling(args2, dataDb) {
|
|
|
27430
27457
|
function handlePyModels(args2, dataDb) {
|
|
27431
27458
|
const lines = [];
|
|
27432
27459
|
if (args2.fk_graph) {
|
|
27433
|
-
const edges = dataDb.prepare(
|
|
27460
|
+
const edges = dataDb.prepare(`SELECT * FROM ${t("py_fk_edges")} ORDER BY source_table`).all();
|
|
27434
27461
|
lines.push(`## Foreign Key Graph (${edges.length} edges)`);
|
|
27435
27462
|
for (const e2 of edges) {
|
|
27436
27463
|
lines.push(`- ${e2.source_table}.${e2.source_column} \u2192 ${e2.target_table}.${e2.target_column}`);
|
|
@@ -27438,7 +27465,7 @@ function handlePyModels(args2, dataDb) {
|
|
|
27438
27465
|
} else if (args2.model || args2.table) {
|
|
27439
27466
|
const search = args2.model || args2.table;
|
|
27440
27467
|
const model = dataDb.prepare(
|
|
27441
|
-
|
|
27468
|
+
`SELECT * FROM ${t("py_models")} WHERE class_name = ? OR table_name = ?`
|
|
27442
27469
|
).get(search, search);
|
|
27443
27470
|
if (!model) return text16(`Model "${search}" not found.`);
|
|
27444
27471
|
lines.push(`## ${model.class_name} (table: ${model.table_name || "N/A"})`);
|
|
@@ -27466,7 +27493,7 @@ function handlePyModels(args2, dataDb) {
|
|
|
27466
27493
|
}
|
|
27467
27494
|
} else {
|
|
27468
27495
|
const limit = Math.min(Math.max(args2.limit || 500, 1), 5e3);
|
|
27469
|
-
const models = dataDb.prepare(`SELECT class_name, table_name, file, line FROM
|
|
27496
|
+
const models = dataDb.prepare(`SELECT class_name, table_name, file, line FROM ${t("py_models")} ORDER BY class_name LIMIT ${limit}`).all();
|
|
27470
27497
|
lines.push(`## Python Models (${models.length})`);
|
|
27471
27498
|
for (const m3 of models) {
|
|
27472
27499
|
lines.push(`- ${m3.class_name} (${m3.table_name || "no table"}) \u2014 ${m3.file}:${m3.line}`);
|
|
@@ -27477,8 +27504,8 @@ function handlePyModels(args2, dataDb) {
|
|
|
27477
27504
|
function handlePyMigrations(args2, dataDb) {
|
|
27478
27505
|
const lines = [];
|
|
27479
27506
|
if (args2.drift) {
|
|
27480
|
-
const models = dataDb.prepare(
|
|
27481
|
-
const migrations = dataDb.prepare(
|
|
27507
|
+
const models = dataDb.prepare(`SELECT class_name, table_name, columns FROM ${t("py_models")}`).all();
|
|
27508
|
+
const migrations = dataDb.prepare(`SELECT revision, operations FROM ${t("py_migrations")}`).all();
|
|
27482
27509
|
const migratedTables = /* @__PURE__ */ new Set();
|
|
27483
27510
|
for (const m3 of migrations) {
|
|
27484
27511
|
const ops = safeParseArray(m3.operations);
|
|
@@ -27499,14 +27526,14 @@ function handlePyMigrations(args2, dataDb) {
|
|
|
27499
27526
|
}
|
|
27500
27527
|
} else if (args2.chain) {
|
|
27501
27528
|
const limit = Math.min(Math.max(args2.limit || 500, 1), 5e3);
|
|
27502
|
-
const migrations = dataDb.prepare(`SELECT * FROM
|
|
27529
|
+
const migrations = dataDb.prepare(`SELECT * FROM ${t("py_migrations")} ORDER BY id LIMIT ${limit}`).all();
|
|
27503
27530
|
lines.push(`## Migration Chain (${migrations.length} revisions)`);
|
|
27504
27531
|
for (const m3 of migrations) {
|
|
27505
27532
|
const head = m3.is_head ? " [HEAD]" : "";
|
|
27506
27533
|
lines.push(`- ${m3.revision}${head} \u2190 ${m3.down_revision || "BASE"}: ${m3.description || "(no description)"} (${m3.file})`);
|
|
27507
27534
|
}
|
|
27508
27535
|
} else if (args2.revision) {
|
|
27509
|
-
const m3 = dataDb.prepare(
|
|
27536
|
+
const m3 = dataDb.prepare(`SELECT * FROM ${t("py_migrations")} WHERE revision = ?`).get(args2.revision);
|
|
27510
27537
|
if (!m3) return text16(`Revision "${args2.revision}" not found.`);
|
|
27511
27538
|
lines.push(`## Revision: ${m3.revision}`);
|
|
27512
27539
|
lines.push(`Down: ${m3.down_revision || "BASE"}`);
|
|
@@ -27520,8 +27547,8 @@ function handlePyMigrations(args2, dataDb) {
|
|
|
27520
27547
|
}
|
|
27521
27548
|
}
|
|
27522
27549
|
} else {
|
|
27523
|
-
const total = dataDb.prepare(
|
|
27524
|
-
const head = dataDb.prepare(
|
|
27550
|
+
const total = dataDb.prepare(`SELECT COUNT(*) as cnt FROM ${t("py_migrations")}`).get().cnt;
|
|
27551
|
+
const head = dataDb.prepare(`SELECT revision FROM ${t("py_migrations")} WHERE is_head = 1`).get();
|
|
27525
27552
|
lines.push("## Migration Summary");
|
|
27526
27553
|
lines.push(`- Total revisions: ${total}`);
|
|
27527
27554
|
lines.push(`- Current head: ${head?.revision || "N/A"}`);
|
|
@@ -27542,7 +27569,7 @@ function handlePyDomains(args2, dataDb) {
|
|
|
27542
27569
|
lines.push(`Allowed imports from: ${domainConfig.allowed_imports_from.join(", ") || "any"}`);
|
|
27543
27570
|
}
|
|
27544
27571
|
} else if (args2.crossings) {
|
|
27545
|
-
const imports = dataDb.prepare(
|
|
27572
|
+
const imports = dataDb.prepare(`SELECT source_file, target_file FROM ${t("py_imports")}`).all();
|
|
27546
27573
|
const violations = [];
|
|
27547
27574
|
for (const imp of imports) {
|
|
27548
27575
|
const srcDomain = classifyPythonFileDomain(imp.source_file);
|
|
@@ -27561,7 +27588,7 @@ function handlePyDomains(args2, dataDb) {
|
|
|
27561
27588
|
if (violations.length > 50) lines.push(`... and ${violations.length - 50} more`);
|
|
27562
27589
|
} else if (args2.domain) {
|
|
27563
27590
|
const domainName = args2.domain;
|
|
27564
|
-
const allFiles = dataDb.prepare(
|
|
27591
|
+
const allFiles = dataDb.prepare(`SELECT DISTINCT source_file FROM ${t("py_imports")} UNION SELECT DISTINCT target_file FROM ${t("py_imports")}`).all();
|
|
27565
27592
|
const filesInDomain = allFiles.filter((f2) => classifyPythonFileDomain(f2.source_file) === domainName);
|
|
27566
27593
|
lines.push(`## Domain: ${domainName} (${filesInDomain.length} files)`);
|
|
27567
27594
|
for (const f2 of filesInDomain) {
|
|
@@ -27579,14 +27606,14 @@ function handlePyImpact(args2, dataDb) {
|
|
|
27579
27606
|
const file = args2.file;
|
|
27580
27607
|
const lines = [`## Impact Analysis: ${file}`, ""];
|
|
27581
27608
|
const importedBy = dataDb.prepare(
|
|
27582
|
-
|
|
27609
|
+
`SELECT source_file FROM ${t("py_imports")} WHERE target_file = ?`
|
|
27583
27610
|
).all(file);
|
|
27584
27611
|
lines.push(`### Imported By (${importedBy.length} files)`);
|
|
27585
27612
|
for (const imp of importedBy.slice(0, 20)) {
|
|
27586
27613
|
lines.push(`- ${imp.source_file}`);
|
|
27587
27614
|
}
|
|
27588
27615
|
const routes = dataDb.prepare(
|
|
27589
|
-
|
|
27616
|
+
`SELECT method, path, function_name FROM ${t("py_routes")} WHERE file = ?`
|
|
27590
27617
|
).all(file);
|
|
27591
27618
|
if (routes.length > 0) {
|
|
27592
27619
|
lines.push(`
|
|
@@ -27596,7 +27623,7 @@ function handlePyImpact(args2, dataDb) {
|
|
|
27596
27623
|
}
|
|
27597
27624
|
}
|
|
27598
27625
|
const models = dataDb.prepare(
|
|
27599
|
-
|
|
27626
|
+
`SELECT class_name, table_name FROM ${t("py_models")} WHERE file = ?`
|
|
27600
27627
|
).all(file);
|
|
27601
27628
|
if (models.length > 0) {
|
|
27602
27629
|
lines.push(`
|
|
@@ -27605,11 +27632,11 @@ function handlePyImpact(args2, dataDb) {
|
|
|
27605
27632
|
lines.push(`- ${m3.class_name} (${m3.table_name || "no table"})`);
|
|
27606
27633
|
}
|
|
27607
27634
|
}
|
|
27608
|
-
const routeIds = dataDb.prepare(
|
|
27635
|
+
const routeIds = dataDb.prepare(`SELECT id FROM ${t("py_routes")} WHERE file = ?`).all(file);
|
|
27609
27636
|
if (routeIds.length > 0) {
|
|
27610
27637
|
const placeholders = routeIds.map(() => "?").join(",");
|
|
27611
27638
|
const callers = dataDb.prepare(
|
|
27612
|
-
`SELECT DISTINCT frontend_file FROM
|
|
27639
|
+
`SELECT DISTINCT frontend_file FROM ${t("py_route_callers")} WHERE route_id IN (${placeholders})`
|
|
27613
27640
|
).all(...routeIds.map((r2) => r2.id));
|
|
27614
27641
|
if (callers.length > 0) {
|
|
27615
27642
|
lines.push(`
|
|
@@ -27632,7 +27659,7 @@ function handlePyContext(args2, dataDb) {
|
|
|
27632
27659
|
const domain = classifyPythonFileDomain(file);
|
|
27633
27660
|
lines.push(`**Domain**: ${domain}`);
|
|
27634
27661
|
const imports = dataDb.prepare(
|
|
27635
|
-
|
|
27662
|
+
`SELECT target_file, imported_names FROM ${t("py_imports")} WHERE source_file = ? LIMIT 20`
|
|
27636
27663
|
).all(file);
|
|
27637
27664
|
if (imports.length > 0) {
|
|
27638
27665
|
lines.push("\n### Imports");
|
|
@@ -27642,7 +27669,7 @@ function handlePyContext(args2, dataDb) {
|
|
|
27642
27669
|
}
|
|
27643
27670
|
}
|
|
27644
27671
|
const importedBy = dataDb.prepare(
|
|
27645
|
-
|
|
27672
|
+
`SELECT source_file FROM ${t("py_imports")} WHERE target_file = ? LIMIT 10`
|
|
27646
27673
|
).all(file);
|
|
27647
27674
|
if (importedBy.length > 0) {
|
|
27648
27675
|
lines.push("\n### Imported By");
|
|
@@ -27650,14 +27677,14 @@ function handlePyContext(args2, dataDb) {
|
|
|
27650
27677
|
lines.push(`- ${imp.source_file}`);
|
|
27651
27678
|
}
|
|
27652
27679
|
}
|
|
27653
|
-
const routes = dataDb.prepare(
|
|
27680
|
+
const routes = dataDb.prepare(`SELECT method, path, function_name, line FROM ${t("py_routes")} WHERE file = ?`).all(file);
|
|
27654
27681
|
if (routes.length > 0) {
|
|
27655
27682
|
lines.push("\n### Routes");
|
|
27656
27683
|
for (const r2 of routes) {
|
|
27657
27684
|
lines.push(`- ${r2.method} ${r2.path} \u2192 ${r2.function_name} (L${r2.line})`);
|
|
27658
27685
|
}
|
|
27659
27686
|
}
|
|
27660
|
-
const models = dataDb.prepare(
|
|
27687
|
+
const models = dataDb.prepare(`SELECT class_name, table_name, line FROM ${t("py_models")} WHERE file = ?`).all(file);
|
|
27661
27688
|
if (models.length > 0) {
|
|
27662
27689
|
lines.push("\n### Models");
|
|
27663
27690
|
for (const m3 of models) {
|
|
@@ -27686,6 +27713,7 @@ var init_python_tools = __esm({
|
|
|
27686
27713
|
"use strict";
|
|
27687
27714
|
init_config();
|
|
27688
27715
|
init_domain_enforcer();
|
|
27716
|
+
init_sql_table_names();
|
|
27689
27717
|
}
|
|
27690
27718
|
});
|
|
27691
27719
|
|
|
@@ -28113,7 +28141,7 @@ function handleContext(file, dataDb, codegraphDb) {
|
|
|
28113
28141
|
lines.push(`## Domain: ${domain}`);
|
|
28114
28142
|
lines.push("");
|
|
28115
28143
|
const imports = dataDb.prepare(
|
|
28116
|
-
|
|
28144
|
+
`SELECT target_file, imported_names FROM ${t("imports")} WHERE source_file = ? LIMIT 20`
|
|
28117
28145
|
).all(file);
|
|
28118
28146
|
if (imports.length > 0) {
|
|
28119
28147
|
lines.push("## Imports (from this file)");
|
|
@@ -28124,7 +28152,7 @@ function handleContext(file, dataDb, codegraphDb) {
|
|
|
28124
28152
|
lines.push("");
|
|
28125
28153
|
}
|
|
28126
28154
|
const importedBy = dataDb.prepare(
|
|
28127
|
-
|
|
28155
|
+
`SELECT source_file FROM ${t("imports")} WHERE target_file = ? LIMIT 20`
|
|
28128
28156
|
).all(file);
|
|
28129
28157
|
if (importedBy.length > 0) {
|
|
28130
28158
|
lines.push("## Imported By");
|
|
@@ -28291,7 +28319,7 @@ function handleTrpcMap(args2, dataDb) {
|
|
|
28291
28319
|
const lines = [];
|
|
28292
28320
|
if (args2.uncoupled) {
|
|
28293
28321
|
const uncoupled = dataDb.prepare(
|
|
28294
|
-
|
|
28322
|
+
`SELECT router_name, procedure_name, procedure_type, router_file FROM ${t("trpc_procedures")} WHERE has_ui_caller = 0 ORDER BY router_name, procedure_name`
|
|
28295
28323
|
).all();
|
|
28296
28324
|
lines.push(`## Uncoupled Procedures (${uncoupled.length} total)`);
|
|
28297
28325
|
lines.push("These procedures have ZERO UI callers.");
|
|
@@ -28306,7 +28334,7 @@ function handleTrpcMap(args2, dataDb) {
|
|
|
28306
28334
|
}
|
|
28307
28335
|
} else if (args2.router) {
|
|
28308
28336
|
const procs = dataDb.prepare(
|
|
28309
|
-
|
|
28337
|
+
`SELECT id, procedure_name, procedure_type, has_ui_caller FROM ${t("trpc_procedures")} WHERE router_name = ? ORDER BY procedure_name`
|
|
28310
28338
|
).all(args2.router);
|
|
28311
28339
|
lines.push(`## Router: ${args2.router} (${procs.length} procedures)`);
|
|
28312
28340
|
lines.push("");
|
|
@@ -28314,7 +28342,7 @@ function handleTrpcMap(args2, dataDb) {
|
|
|
28314
28342
|
const status = proc.has_ui_caller ? "" : " [NO UI CALLERS]";
|
|
28315
28343
|
lines.push(`### ${args2.router}.${proc.procedure_name} (${proc.procedure_type})${status}`);
|
|
28316
28344
|
const callSites = dataDb.prepare(
|
|
28317
|
-
|
|
28345
|
+
`SELECT file, line, call_pattern FROM ${t("trpc_call_sites")} WHERE procedure_id = ?`
|
|
28318
28346
|
).all(proc.id);
|
|
28319
28347
|
if (callSites.length > 0) {
|
|
28320
28348
|
lines.push("UI Call Sites:");
|
|
@@ -28328,7 +28356,7 @@ function handleTrpcMap(args2, dataDb) {
|
|
|
28328
28356
|
}
|
|
28329
28357
|
} else if (args2.procedure) {
|
|
28330
28358
|
const procs = dataDb.prepare(
|
|
28331
|
-
|
|
28359
|
+
`SELECT id, router_name, router_file, procedure_type, has_ui_caller FROM ${t("trpc_procedures")} WHERE procedure_name = ? ORDER BY router_name`
|
|
28332
28360
|
).all(args2.procedure);
|
|
28333
28361
|
lines.push(`## Procedure "${args2.procedure}" found in ${procs.length} routers`);
|
|
28334
28362
|
lines.push("");
|
|
@@ -28336,7 +28364,7 @@ function handleTrpcMap(args2, dataDb) {
|
|
|
28336
28364
|
lines.push(`### ${proc.router_name}.${args2.procedure} (${proc.procedure_type})`);
|
|
28337
28365
|
lines.push(`File: ${proc.router_file}`);
|
|
28338
28366
|
const callSites = dataDb.prepare(
|
|
28339
|
-
|
|
28367
|
+
`SELECT file, line, call_pattern FROM ${t("trpc_call_sites")} WHERE procedure_id = ?`
|
|
28340
28368
|
).all(proc.id);
|
|
28341
28369
|
if (callSites.length > 0) {
|
|
28342
28370
|
lines.push("UI Call Sites:");
|
|
@@ -28349,8 +28377,8 @@ function handleTrpcMap(args2, dataDb) {
|
|
|
28349
28377
|
lines.push("");
|
|
28350
28378
|
}
|
|
28351
28379
|
} else {
|
|
28352
|
-
const total = dataDb.prepare(
|
|
28353
|
-
const coupled = dataDb.prepare(
|
|
28380
|
+
const total = dataDb.prepare(`SELECT COUNT(*) as count FROM ${t("trpc_procedures")}`).get();
|
|
28381
|
+
const coupled = dataDb.prepare(`SELECT COUNT(*) as count FROM ${t("trpc_procedures")} WHERE has_ui_caller = 1`).get();
|
|
28354
28382
|
const uncoupled = total.count - coupled.count;
|
|
28355
28383
|
if (total.count === 0) {
|
|
28356
28384
|
lines.push("## tRPC Index Empty");
|
|
@@ -28381,11 +28409,11 @@ function handleCouplingCheck(args2, dataDb, codegraphDb) {
|
|
|
28381
28409
|
let uncoupledProcs;
|
|
28382
28410
|
if (stagedFiles) {
|
|
28383
28411
|
uncoupledProcs = dataDb.prepare(
|
|
28384
|
-
`SELECT router_name, procedure_name, procedure_type, router_file FROM
|
|
28412
|
+
`SELECT router_name, procedure_name, procedure_type, router_file FROM ${t("trpc_procedures")} WHERE has_ui_caller = 0 AND router_file IN (${stagedFiles.map(() => "?").join(",")})`
|
|
28385
28413
|
).all(...stagedFiles);
|
|
28386
28414
|
} else {
|
|
28387
28415
|
uncoupledProcs = dataDb.prepare(
|
|
28388
|
-
|
|
28416
|
+
`SELECT router_name, procedure_name, procedure_type, router_file FROM ${t("trpc_procedures")} WHERE has_ui_caller = 0`
|
|
28389
28417
|
).all();
|
|
28390
28418
|
}
|
|
28391
28419
|
lines.push("## Coupling Check Results");
|
|
@@ -28406,7 +28434,7 @@ function handleCouplingCheck(args2, dataDb, codegraphDb) {
|
|
|
28406
28434
|
const pageImports = /* @__PURE__ */ new Set();
|
|
28407
28435
|
for (const page of allPages) {
|
|
28408
28436
|
const imports = dataDb.prepare(
|
|
28409
|
-
|
|
28437
|
+
`SELECT target_file FROM ${t("imports")} WHERE source_file = ?`
|
|
28410
28438
|
).all(page.path);
|
|
28411
28439
|
for (const imp of imports) {
|
|
28412
28440
|
pageImports.add(imp.target_file);
|
|
@@ -28478,7 +28506,7 @@ function handleImpact2(file, dataDb, codegraphDb) {
|
|
|
28478
28506
|
const fileDomain = classifyFile(file);
|
|
28479
28507
|
lines.push(`### Domain: ${fileDomain}`);
|
|
28480
28508
|
const imports = dataDb.prepare(
|
|
28481
|
-
|
|
28509
|
+
`SELECT target_file FROM ${t("imports")} WHERE source_file = ?`
|
|
28482
28510
|
).all(file);
|
|
28483
28511
|
const crossings = [];
|
|
28484
28512
|
for (const imp of imports) {
|
|
@@ -28677,6 +28705,7 @@ var init_tools = __esm({
|
|
|
28677
28705
|
init_python_tools();
|
|
28678
28706
|
init_config();
|
|
28679
28707
|
init_license();
|
|
28708
|
+
init_sql_table_names();
|
|
28680
28709
|
}
|
|
28681
28710
|
});
|
|
28682
28711
|
|