@marktiderman/genesis-cli 1.26.1 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/dist/cli.js +1129 -450
- package/dist/cli.js.map +1 -1
- package/dist/{config-ARs2YQ60.d.ts → config-BmMsEWU-.d.ts} +7 -0
- package/dist/doctor.d.ts +3 -3
- package/dist/doctor.js +492 -33
- package/dist/doctor.js.map +1 -1
- package/dist/expo.d.ts +2 -2
- package/dist/expo.js +11 -0
- package/dist/expo.js.map +1 -1
- package/dist/genesis-catalog.json +36 -12
- package/dist/index.d.ts +11 -5
- package/dist/index.js +493 -34
- package/dist/index.js.map +1 -1
- package/dist/starter/package.json +5 -5
- package/dist/starter/supabase/migrations/20261025000095_genesis_support_ticket_fixes.sql +115 -0
- package/dist/starter/supabase/tests/database/genesis_support_ticket_fixes.test.sql +121 -0
- package/dist/vite.js +490 -31
- package/dist/vite.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -25,6 +25,15 @@ var __export = (target, all) => {
|
|
|
25
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
// src/regexp.ts
|
|
29
|
+
function escapeRegExp(s) {
|
|
30
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31
|
+
}
|
|
32
|
+
var init_regexp = __esm({
|
|
33
|
+
"src/regexp.ts"() {
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
28
37
|
// src/introspect/catalog-text.ts
|
|
29
38
|
function tokenize(tree) {
|
|
30
39
|
const tokens = [];
|
|
@@ -154,9 +163,6 @@ function splitTopLevel(expr, separator) {
|
|
|
154
163
|
parts.push(expr.slice(from));
|
|
155
164
|
return parts;
|
|
156
165
|
}
|
|
157
|
-
function escapeRegExp(s) {
|
|
158
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
159
|
-
}
|
|
160
166
|
function checkEnumValues(definition, column) {
|
|
161
167
|
const outer = /^CHECK \((.*)\)(?: NOT VALID)?$/s.exec(definition.trim());
|
|
162
168
|
if (!outer) return void 0;
|
|
@@ -191,6 +197,7 @@ function checkEnumValues(definition, column) {
|
|
|
191
197
|
var CAST, LITERAL;
|
|
192
198
|
var init_catalog_text = __esm({
|
|
193
199
|
"src/introspect/catalog-text.ts"() {
|
|
200
|
+
init_regexp();
|
|
194
201
|
CAST = String.raw`::[a-z][a-z ]*(?:\(\d+(?:,\d+)?\))?`;
|
|
195
202
|
LITERAL = String.raw`'((?:[^']|'')*)'${CAST}`;
|
|
196
203
|
}
|
|
@@ -285,8 +292,11 @@ var init_model = __esm({
|
|
|
285
292
|
});
|
|
286
293
|
|
|
287
294
|
// src/introspect/postgres.ts
|
|
288
|
-
function where(
|
|
289
|
-
return "schemas" in scope ?
|
|
295
|
+
function where(scope) {
|
|
296
|
+
return "schemas" in scope ? { condition: "n.nspname = any(array(select jsonb_array_elements_text($1::text::jsonb)))", param: JSON.stringify(scope.schemas) } : { condition: "c.oid = any(array(select jsonb_array_elements_text($1::text::jsonb)::oid))", param: JSON.stringify(scope.oids) };
|
|
297
|
+
}
|
|
298
|
+
async function read(sql, text, param) {
|
|
299
|
+
return [...await sql.unsafe(text, [param])];
|
|
290
300
|
}
|
|
291
301
|
function linkOf(columns, refColumns, refUnique = []) {
|
|
292
302
|
if (columns.length === 1) return 0;
|
|
@@ -295,7 +305,8 @@ function linkOf(columns, refColumns, refUnique = []) {
|
|
|
295
305
|
return own.length === 1 && refUnique[own[0]] === true ? own[0] : -1;
|
|
296
306
|
}
|
|
297
307
|
async function readRelations(sql, scope, into) {
|
|
298
|
-
const
|
|
308
|
+
const { condition, param } = where(scope);
|
|
309
|
+
const columns = await read(sql, `
|
|
299
310
|
select c.oid::text as oid, c.relkind::text as relkind, n.nspname as schema, c.relname as table,
|
|
300
311
|
obj_description(c.oid, 'pg_class') as table_comment,
|
|
301
312
|
a.attnum::int as attnum,
|
|
@@ -314,17 +325,17 @@ async function readRelations(sql, scope, into) {
|
|
|
314
325
|
join pg_attribute a on a.attrelid = c.oid and a.attnum > 0 and not a.attisdropped
|
|
315
326
|
join pg_type t on t.oid = a.atttypid
|
|
316
327
|
where c.relkind in ('r', 'p', 'v', 'm', 'f')
|
|
317
|
-
and ${
|
|
318
|
-
order by n.nspname, c.relname, a.attnum
|
|
319
|
-
const keys = await sql`
|
|
328
|
+
and ${condition}
|
|
329
|
+
order by n.nspname, c.relname, a.attnum`, param);
|
|
330
|
+
const keys = await read(sql, `
|
|
320
331
|
select c.oid::text as oid, array_agg(k.attnum::int order by k.ord) as columns
|
|
321
332
|
from pg_constraint con
|
|
322
333
|
join pg_class c on c.oid = con.conrelid
|
|
323
334
|
join pg_namespace n on n.oid = c.relnamespace
|
|
324
335
|
cross join lateral unnest(con.conkey) with ordinality as k(attnum, ord)
|
|
325
|
-
where con.contype = 'p' and ${
|
|
326
|
-
group by c.oid
|
|
327
|
-
const links = await sql`
|
|
336
|
+
where con.contype = 'p' and ${condition}
|
|
337
|
+
group by c.oid`, param);
|
|
338
|
+
const links = await read(sql, `
|
|
328
339
|
select c.oid::text as oid, con.conkey::int[] as attnums,
|
|
329
340
|
array(select a.attname::text from unnest(con.conkey) with ordinality k(attnum, ord)
|
|
330
341
|
join pg_attribute a on a.attrelid = c.oid and a.attnum = k.attnum order by k.ord) as columns,
|
|
@@ -341,9 +352,9 @@ async function readRelations(sql, scope, into) {
|
|
|
341
352
|
join pg_class rc on rc.oid = con.confrelid
|
|
342
353
|
join pg_namespace rn on rn.oid = rc.relnamespace
|
|
343
354
|
where con.contype = 'f'
|
|
344
|
-
and ${
|
|
345
|
-
order by con.conname
|
|
346
|
-
const checks = await sql`
|
|
355
|
+
and ${condition}
|
|
356
|
+
order by con.conname`, param);
|
|
357
|
+
const checks = await read(sql, `
|
|
347
358
|
select c.oid::text as oid, con.conkey[1]::int as attnum, a.attname as column,
|
|
348
359
|
pg_get_constraintdef(con.oid) as definition
|
|
349
360
|
from pg_constraint con
|
|
@@ -351,9 +362,9 @@ async function readRelations(sql, scope, into) {
|
|
|
351
362
|
join pg_namespace n on n.oid = c.relnamespace
|
|
352
363
|
join pg_attribute a on a.attrelid = c.oid and a.attnum = con.conkey[1]
|
|
353
364
|
where con.contype = 'c' and array_length(con.conkey, 1) = 1
|
|
354
|
-
and ${
|
|
355
|
-
order by con.conname
|
|
356
|
-
const views = await sql`
|
|
365
|
+
and ${condition}
|
|
366
|
+
order by con.conname`, param);
|
|
367
|
+
const views = await read(sql, `
|
|
357
368
|
select c.oid::text as oid, r.ev_action::text as ev_action
|
|
358
369
|
from pg_class c
|
|
359
370
|
join pg_namespace n on n.oid = c.relnamespace
|
|
@@ -361,7 +372,7 @@ async function readRelations(sql, scope, into) {
|
|
|
361
372
|
where c.relkind = 'v'
|
|
362
373
|
and (pg_relation_is_updatable(c.oid, false) & 20) = 20
|
|
363
374
|
and not exists (select 1 from pg_rewrite o where o.ev_class = c.oid and o.rulename <> '_RETURN')
|
|
364
|
-
and ${
|
|
375
|
+
and ${condition}`, param);
|
|
365
376
|
const added = [];
|
|
366
377
|
for (const row of columns) {
|
|
367
378
|
let relation = into.get(row.oid);
|
|
@@ -822,9 +833,9 @@ async function runScaffold(opts, fs) {
|
|
|
822
833
|
function joinPath(...parts) {
|
|
823
834
|
return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
|
|
824
835
|
}
|
|
825
|
-
function dirname(
|
|
826
|
-
const idx =
|
|
827
|
-
return idx === -1 ? "." :
|
|
836
|
+
function dirname(path50) {
|
|
837
|
+
const idx = path50.lastIndexOf("/");
|
|
838
|
+
return idx === -1 ? "." : path50.slice(0, idx);
|
|
828
839
|
}
|
|
829
840
|
function brandPackageJson(consumer, genesisVersion) {
|
|
830
841
|
return JSON.stringify(
|
|
@@ -1622,6 +1633,7 @@ function readGenesisConfig(root) {
|
|
|
1622
1633
|
}
|
|
1623
1634
|
if (raw.appFolder !== void 0) out.appFolder = validateAppFolder(raw.appFolder, file);
|
|
1624
1635
|
if (raw.environments !== void 0) out.environments = validateEnvironments(raw.environments, file);
|
|
1636
|
+
if (raw.client !== void 0) out.client = validateClient(raw.client, file);
|
|
1625
1637
|
return out;
|
|
1626
1638
|
}
|
|
1627
1639
|
var PLAIN_FOLDER = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,59}(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]{0,59}){0,7}$/;
|
|
@@ -1633,6 +1645,16 @@ function validateAppFolder(raw, source = "config") {
|
|
|
1633
1645
|
if (!isPlainFolder(norm)) throw new GenesisConfigError(`${source}: "appFolder" must be the app's folder from the repository root, such as "mobile" or "apps/phone" (got ${JSON.stringify(raw)})`);
|
|
1634
1646
|
return norm;
|
|
1635
1647
|
}
|
|
1648
|
+
function validateClient(raw, source = "config") {
|
|
1649
|
+
const fail = (msg) => {
|
|
1650
|
+
throw new GenesisConfigError(`${source}: ${msg}`);
|
|
1651
|
+
};
|
|
1652
|
+
if (!isObject(raw)) return fail(`"client" must be { "dir": "<the client layer's folder, e.g. src/client>" }`);
|
|
1653
|
+
for (const key2 of Object.keys(raw)) if (key2 !== "dir" && key2 !== "$comment") fail(`client: unknown setting "${key2}" (known: dir)`);
|
|
1654
|
+
const dir = typeof raw.dir === "string" ? raw.dir.replace(/^\.\//, "").replace(/\/+$/, "") : "";
|
|
1655
|
+
if (!isPlainFolder(dir)) return fail(`client.dir must be a folder inside the app, such as "src/client" (got ${JSON.stringify(raw.dir)})`);
|
|
1656
|
+
return { dir };
|
|
1657
|
+
}
|
|
1636
1658
|
function validateSupabase(raw, source = "config") {
|
|
1637
1659
|
const fail = (msg) => {
|
|
1638
1660
|
throw new GenesisConfigError(`${source}: ${msg}`);
|
|
@@ -1896,7 +1918,7 @@ function globToRegExp(glob) {
|
|
|
1896
1918
|
}
|
|
1897
1919
|
function globMatcher(globs) {
|
|
1898
1920
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
1899
|
-
return (
|
|
1921
|
+
return (path50) => res.some((re) => re.test(path50));
|
|
1900
1922
|
}
|
|
1901
1923
|
var GENESIS_PACKAGE = /^@marktiderman\/genesis(-[a-z0-9-]+)?$/;
|
|
1902
1924
|
var BLOCK_ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
|
|
@@ -3458,6 +3480,319 @@ function resolvePlugin(id, configDir) {
|
|
|
3458
3480
|
function resolveFrom(id, from) {
|
|
3459
3481
|
return createRequire(path21.join(from, "noop.js")).resolve(id);
|
|
3460
3482
|
}
|
|
3483
|
+
|
|
3484
|
+
// src/doctor/js-scan.ts
|
|
3485
|
+
var IDENT_START = /[A-Za-z_$]/;
|
|
3486
|
+
var IDENT = /[\w$]/;
|
|
3487
|
+
var PUNCT3 = ["...", "===", "!==", "**=", "<<=", ">>=", "??=", "&&=", "||="];
|
|
3488
|
+
var PUNCT2 = ["=>", "==", "!=", "<=", ">=", "&&", "||", "??", "?.", "++", "--", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "**", "<<", ">>"];
|
|
3489
|
+
var EXPRESSION_KEYWORDS = /* @__PURE__ */ new Set(["return", "typeof", "case", "do", "else", "in", "new", "delete", "void", "throw", "yield", "await", "instanceof"]);
|
|
3490
|
+
var TYPE_PARAMETERS = /^<\s*[A-Za-z_$][\w$]*\s*(?:,|extends\b)/;
|
|
3491
|
+
function scanCode(code, options = {}) {
|
|
3492
|
+
const jsx = options.jsx ?? true;
|
|
3493
|
+
const tokens = [];
|
|
3494
|
+
const push = (kind, value) => tokens.push({ kind, value, index: tokens.length });
|
|
3495
|
+
const expressionNext = (start) => {
|
|
3496
|
+
if (tokens.length <= start) return true;
|
|
3497
|
+
const t = tokens[tokens.length - 1];
|
|
3498
|
+
if (!t) return true;
|
|
3499
|
+
if (t.kind === "ident") return EXPRESSION_KEYWORDS.has(t.value);
|
|
3500
|
+
if (t.kind === "jsxTag" || t.kind === "literal") return false;
|
|
3501
|
+
return !(t.value === ")" || t.value === "]" || t.value === "}" || t.value === "<>");
|
|
3502
|
+
};
|
|
3503
|
+
const skipString2 = (i2, quote2) => {
|
|
3504
|
+
let j = i2 + 1;
|
|
3505
|
+
while (j < code.length && code[j] !== quote2) {
|
|
3506
|
+
if (code[j] === "\\") j++;
|
|
3507
|
+
else if (code[j] === "\n") return j;
|
|
3508
|
+
j++;
|
|
3509
|
+
}
|
|
3510
|
+
return j + 1;
|
|
3511
|
+
};
|
|
3512
|
+
const skipAttribute = (i2, quote2) => {
|
|
3513
|
+
const end = code.indexOf(quote2, i2 + 1);
|
|
3514
|
+
return end < 0 ? code.length : end + 1;
|
|
3515
|
+
};
|
|
3516
|
+
const skipRegex = (i2) => {
|
|
3517
|
+
let j = i2 + 1;
|
|
3518
|
+
let inClass = false;
|
|
3519
|
+
while (j < code.length && code[j] !== "\n") {
|
|
3520
|
+
const c = code[j];
|
|
3521
|
+
if (c === "\\") j++;
|
|
3522
|
+
else if (c === "[") inClass = true;
|
|
3523
|
+
else if (c === "]") inClass = false;
|
|
3524
|
+
else if (c === "/" && !inClass) {
|
|
3525
|
+
j++;
|
|
3526
|
+
while (j < code.length && IDENT.test(code[j])) j++;
|
|
3527
|
+
return j;
|
|
3528
|
+
}
|
|
3529
|
+
j++;
|
|
3530
|
+
}
|
|
3531
|
+
return j;
|
|
3532
|
+
};
|
|
3533
|
+
const skipTrivia = (i2) => {
|
|
3534
|
+
let j = i2;
|
|
3535
|
+
for (; ; ) {
|
|
3536
|
+
while (j < code.length && /\s/.test(code[j])) j++;
|
|
3537
|
+
if (code.startsWith("//", j)) {
|
|
3538
|
+
const end = code.indexOf("\n", j);
|
|
3539
|
+
j = end < 0 ? code.length : end;
|
|
3540
|
+
} else if (code.startsWith("/*", j)) {
|
|
3541
|
+
const end = code.indexOf("*/", j + 2);
|
|
3542
|
+
j = end < 0 ? code.length : end + 2;
|
|
3543
|
+
} else return j;
|
|
3544
|
+
}
|
|
3545
|
+
};
|
|
3546
|
+
const stack = [{ k: "code", depth: 0, stop: false, start: 0 }];
|
|
3547
|
+
const openCode = () => stack.push({ k: "code", depth: 0, stop: true, start: tokens.length });
|
|
3548
|
+
const openElement = (i2) => {
|
|
3549
|
+
if (code[i2 + 1] === ">") {
|
|
3550
|
+
stack.push({ k: "children" });
|
|
3551
|
+
return i2 + 2;
|
|
3552
|
+
}
|
|
3553
|
+
let j = i2 + 1;
|
|
3554
|
+
while (j < code.length && /[\w$.:-]/.test(code[j])) j++;
|
|
3555
|
+
const name = code.slice(i2 + 1, j);
|
|
3556
|
+
if (name) push("jsxTag", name.split(/[.:]/)[0]);
|
|
3557
|
+
stack.push({ k: "tag" });
|
|
3558
|
+
return j;
|
|
3559
|
+
};
|
|
3560
|
+
const closeElement = () => {
|
|
3561
|
+
stack.pop();
|
|
3562
|
+
push("punct", "<>");
|
|
3563
|
+
};
|
|
3564
|
+
let i = 0;
|
|
3565
|
+
while (i < code.length) {
|
|
3566
|
+
const top = stack[stack.length - 1];
|
|
3567
|
+
if (top.k === "code") {
|
|
3568
|
+
i = skipTrivia(i);
|
|
3569
|
+
if (i >= code.length) break;
|
|
3570
|
+
const c = code[i];
|
|
3571
|
+
if (c === '"' || c === "'") {
|
|
3572
|
+
i = skipString2(i, c);
|
|
3573
|
+
push("literal", "''");
|
|
3574
|
+
} else if (c === "`") {
|
|
3575
|
+
stack.push({ k: "template" });
|
|
3576
|
+
i++;
|
|
3577
|
+
} else if (IDENT_START.test(c)) {
|
|
3578
|
+
let j = i + 1;
|
|
3579
|
+
while (j < code.length && IDENT.test(code[j])) j++;
|
|
3580
|
+
push("ident", code.slice(i, j));
|
|
3581
|
+
i = j;
|
|
3582
|
+
} else if (/\d/.test(c) || c === "." && /\d/.test(code[i + 1] ?? "")) {
|
|
3583
|
+
let j = i + 1;
|
|
3584
|
+
while (j < code.length && /[\w.]/.test(code[j])) j++;
|
|
3585
|
+
push("literal", "0");
|
|
3586
|
+
i = j;
|
|
3587
|
+
} else if (c === "/" && expressionNext(top.start)) {
|
|
3588
|
+
i = skipRegex(i);
|
|
3589
|
+
push("literal", "//");
|
|
3590
|
+
} else if (c === "<" && jsx && expressionNext(top.start) && /[A-Za-z_$>]/.test(code[i + 1] ?? "") && !TYPE_PARAMETERS.test(code.slice(i, i + 200))) {
|
|
3591
|
+
i = openElement(i);
|
|
3592
|
+
} else if (c === "{") {
|
|
3593
|
+
top.depth++;
|
|
3594
|
+
push("punct", "{");
|
|
3595
|
+
i++;
|
|
3596
|
+
} else if (c === "}") {
|
|
3597
|
+
i++;
|
|
3598
|
+
if (top.depth === 0 && top.stop) stack.pop();
|
|
3599
|
+
else {
|
|
3600
|
+
top.depth = Math.max(0, top.depth - 1);
|
|
3601
|
+
push("punct", "}");
|
|
3602
|
+
}
|
|
3603
|
+
} else {
|
|
3604
|
+
const three = code.slice(i, i + 3);
|
|
3605
|
+
const two = code.slice(i, i + 2);
|
|
3606
|
+
const p = PUNCT3.includes(three) ? three : PUNCT2.includes(two) ? two : c;
|
|
3607
|
+
push("punct", p);
|
|
3608
|
+
i += p.length;
|
|
3609
|
+
}
|
|
3610
|
+
} else if (top.k === "template") {
|
|
3611
|
+
const c = code[i];
|
|
3612
|
+
if (c === "\\") i += 2;
|
|
3613
|
+
else if (c === "`") {
|
|
3614
|
+
stack.pop();
|
|
3615
|
+
push("literal", "``");
|
|
3616
|
+
i++;
|
|
3617
|
+
} else if (c === "$" && code[i + 1] === "{") {
|
|
3618
|
+
openCode();
|
|
3619
|
+
i += 2;
|
|
3620
|
+
} else i++;
|
|
3621
|
+
} else if (top.k === "tag") {
|
|
3622
|
+
i = skipTrivia(i);
|
|
3623
|
+
const c = code[i];
|
|
3624
|
+
if (c === void 0) break;
|
|
3625
|
+
if (c === "/" && code[i + 1] === ">") {
|
|
3626
|
+
closeElement();
|
|
3627
|
+
i += 2;
|
|
3628
|
+
} else if (c === ">") {
|
|
3629
|
+
stack[stack.length - 1] = { k: "children" };
|
|
3630
|
+
i++;
|
|
3631
|
+
} else if (c === "{") {
|
|
3632
|
+
openCode();
|
|
3633
|
+
i++;
|
|
3634
|
+
} else if (c === '"' || c === "'") i = skipAttribute(i, c);
|
|
3635
|
+
else if (c === "<") i = openElement(i);
|
|
3636
|
+
else i++;
|
|
3637
|
+
} else {
|
|
3638
|
+
const c = code[i];
|
|
3639
|
+
if (c === "<" && code[i + 1] === "/") {
|
|
3640
|
+
const end = code.indexOf(">", i);
|
|
3641
|
+
i = end < 0 ? code.length : end + 1;
|
|
3642
|
+
closeElement();
|
|
3643
|
+
} else if (c === "<" && /[A-Za-z_$>]/.test(code[i + 1] ?? "")) i = openElement(i);
|
|
3644
|
+
else if (c === "{") {
|
|
3645
|
+
openCode();
|
|
3646
|
+
i++;
|
|
3647
|
+
} else i++;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
return tokens;
|
|
3651
|
+
}
|
|
3652
|
+
function usesAsCode(code, name, options = {}) {
|
|
3653
|
+
const tokens = scanCode(code, options);
|
|
3654
|
+
return tokens.some((t, i) => {
|
|
3655
|
+
if (t.value !== name) return false;
|
|
3656
|
+
if (t.kind === "jsxTag") return true;
|
|
3657
|
+
if (t.kind !== "ident") return false;
|
|
3658
|
+
const before = tokens[i - 1];
|
|
3659
|
+
const after = tokens[i + 1];
|
|
3660
|
+
if (before?.value === "." || before?.value === "?." || before?.value === "as" || before?.value === "import") return false;
|
|
3661
|
+
if (after?.value === ":" && (before?.value === "{" || before?.value === ",")) return false;
|
|
3662
|
+
return true;
|
|
3663
|
+
});
|
|
3664
|
+
}
|
|
3665
|
+
var NOT_METHODS = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "with", "function", "return", "typeof", "await", "new"]);
|
|
3666
|
+
var BEFORE_METHOD = /* @__PURE__ */ new Set(["{", "}", ";", ",", "*", "async", "get", "set", "static", "public", "private", "protected", "readonly", "override", "abstract", "declare", "accessor"]);
|
|
3667
|
+
var TYPE_PARAMETERS_REACH = 200;
|
|
3668
|
+
var OPENS = /* @__PURE__ */ new Set(["(", "[", "{"]);
|
|
3669
|
+
var CLOSES = /* @__PURE__ */ new Set([")", "]", "}"]);
|
|
3670
|
+
function boundNames(list) {
|
|
3671
|
+
const out = [];
|
|
3672
|
+
const params = [[]];
|
|
3673
|
+
let depth = 0;
|
|
3674
|
+
let angles = 0;
|
|
3675
|
+
let inType = false;
|
|
3676
|
+
for (const t of list) {
|
|
3677
|
+
if (OPENS.has(t.value)) depth++;
|
|
3678
|
+
else if (CLOSES.has(t.value)) depth--;
|
|
3679
|
+
else if (depth === 0 && t.value === ":") inType = true;
|
|
3680
|
+
else if (depth === 0 && t.value === "=") inType = false;
|
|
3681
|
+
else if (inType && t.value === "<") angles++;
|
|
3682
|
+
else if (inType && (t.value === ">" || t.value === ">>")) angles = Math.max(0, angles - t.value.length);
|
|
3683
|
+
if (depth === 0 && angles === 0 && t.value === ",") {
|
|
3684
|
+
params.push([]);
|
|
3685
|
+
inType = false;
|
|
3686
|
+
} else params[params.length - 1].push(t);
|
|
3687
|
+
}
|
|
3688
|
+
for (const param of params) {
|
|
3689
|
+
let d = 0;
|
|
3690
|
+
let end = param.length;
|
|
3691
|
+
for (let k = 0; k < param.length; k++) {
|
|
3692
|
+
const v = param[k].value;
|
|
3693
|
+
if (OPENS.has(v)) d++;
|
|
3694
|
+
else if (CLOSES.has(v)) d--;
|
|
3695
|
+
else if (d === 0 && (v === "=" || v === ":" || v === "?")) {
|
|
3696
|
+
end = k;
|
|
3697
|
+
break;
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
const pattern = param.slice(0, end);
|
|
3701
|
+
let skipping = -1;
|
|
3702
|
+
d = 0;
|
|
3703
|
+
for (let k = 0; k < pattern.length; k++) {
|
|
3704
|
+
const t = pattern[k];
|
|
3705
|
+
if (t.value === "[" && skipping < 0) {
|
|
3706
|
+
let depth2 = 0;
|
|
3707
|
+
let close = k;
|
|
3708
|
+
for (; close < pattern.length; close++) {
|
|
3709
|
+
const v = pattern[close].value;
|
|
3710
|
+
if (OPENS.has(v)) depth2++;
|
|
3711
|
+
else if (CLOSES.has(v) && --depth2 === 0) break;
|
|
3712
|
+
}
|
|
3713
|
+
if (pattern[close + 1]?.value === ":") {
|
|
3714
|
+
k = close;
|
|
3715
|
+
continue;
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
if (OPENS.has(t.value)) d++;
|
|
3719
|
+
else if (CLOSES.has(t.value)) {
|
|
3720
|
+
d--;
|
|
3721
|
+
if (skipping > d) skipping = -1;
|
|
3722
|
+
}
|
|
3723
|
+
if (skipping >= 0) {
|
|
3724
|
+
if (t.value === "," && d === skipping) skipping = -1;
|
|
3725
|
+
continue;
|
|
3726
|
+
}
|
|
3727
|
+
if (t.value === "=") {
|
|
3728
|
+
skipping = d;
|
|
3729
|
+
continue;
|
|
3730
|
+
}
|
|
3731
|
+
if (t.kind === "ident" && pattern[k + 1]?.value !== ":") out.push(t.value);
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
return out;
|
|
3735
|
+
}
|
|
3736
|
+
function boundAsParameter(code, name, options = {}) {
|
|
3737
|
+
const tokens = scanCode(code, options);
|
|
3738
|
+
const match = new Int32Array(tokens.length).fill(-1);
|
|
3739
|
+
const open = [];
|
|
3740
|
+
tokens.forEach((t, k) => {
|
|
3741
|
+
if (t.value === "(") open.push(k);
|
|
3742
|
+
else if (t.value === ")" && open.length) match[open.pop()] = k;
|
|
3743
|
+
});
|
|
3744
|
+
const arrowAfter = (end) => {
|
|
3745
|
+
const next = tokens[end + 1];
|
|
3746
|
+
if (next?.value === "=>") return true;
|
|
3747
|
+
if (next?.value !== ":") return false;
|
|
3748
|
+
let depth = 0;
|
|
3749
|
+
for (let k = end + 2; k < Math.min(tokens.length, end + 200); k++) {
|
|
3750
|
+
const v = tokens[k].value;
|
|
3751
|
+
if (v === "(" || v === "{" || v === "[" || v === "<") depth++;
|
|
3752
|
+
else if (v === ")" || v === "}" || v === "]" || v === ">") depth--;
|
|
3753
|
+
if (depth < 0) return false;
|
|
3754
|
+
if (depth === 0 && v === "=>") return true;
|
|
3755
|
+
if (depth === 0 && (v === ";" || v === "," || v === "=")) return false;
|
|
3756
|
+
}
|
|
3757
|
+
return false;
|
|
3758
|
+
};
|
|
3759
|
+
const beforeTypeParameters = (paren) => {
|
|
3760
|
+
let k = paren - 1;
|
|
3761
|
+
if (tokens[k]?.value !== ">" && tokens[k]?.value !== ">>") return k;
|
|
3762
|
+
let depth = 0;
|
|
3763
|
+
for (const stop = Math.max(0, k - TYPE_PARAMETERS_REACH); k >= stop; k--) {
|
|
3764
|
+
const v = tokens[k].value;
|
|
3765
|
+
if (v === ">") depth++;
|
|
3766
|
+
else if (v === ">>") depth += 2;
|
|
3767
|
+
else if (v === "<" && --depth === 0) return k - 1;
|
|
3768
|
+
}
|
|
3769
|
+
return -1;
|
|
3770
|
+
};
|
|
3771
|
+
const isFunction = (paren) => {
|
|
3772
|
+
let k = beforeTypeParameters(paren);
|
|
3773
|
+
if (k < 0) return false;
|
|
3774
|
+
if (tokens[k]?.kind === "ident" && tokens[k].value !== "function") k--;
|
|
3775
|
+
if (tokens[k]?.value === "*") k--;
|
|
3776
|
+
return tokens[k]?.value === "function";
|
|
3777
|
+
};
|
|
3778
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
3779
|
+
const t = tokens[i];
|
|
3780
|
+
if (t.value === "=>" && tokens[i - 1]?.kind === "ident" && tokens[i - 1].value === name && tokens[i - 2]?.value !== ".") return true;
|
|
3781
|
+
if (t.value !== "(") continue;
|
|
3782
|
+
const end = match[i];
|
|
3783
|
+
if (end < 0) continue;
|
|
3784
|
+
const before = tokens[i - 1];
|
|
3785
|
+
const catchClause = before?.value === "catch";
|
|
3786
|
+
const nameAt = beforeTypeParameters(i);
|
|
3787
|
+
const methodName = nameAt >= 0 ? tokens[nameAt] : void 0;
|
|
3788
|
+
const typed = tokens[end + 1]?.value === ":" && !arrowAfter(end);
|
|
3789
|
+
const method = !catchClause && methodName?.kind === "ident" && !NOT_METHODS.has(methodName.value) && (tokens[end + 1]?.value === "{" || typed && (nameAt === 0 || BEFORE_METHOD.has(tokens[nameAt - 1].value)));
|
|
3790
|
+
if ((catchClause || isFunction(i) || method || arrowAfter(end)) && boundNames(tokens.slice(i + 1, end)).includes(name)) return true;
|
|
3791
|
+
}
|
|
3792
|
+
return false;
|
|
3793
|
+
}
|
|
3794
|
+
|
|
3795
|
+
// src/doctor/rules.ts
|
|
3461
3796
|
var BUILTIN_RULES = [
|
|
3462
3797
|
"local-primitives",
|
|
3463
3798
|
// figma (figma/routes.ts; runs when genesis.config.json has a figma block)
|
|
@@ -3545,7 +3880,10 @@ var BUILTIN_RULES = [
|
|
|
3545
3880
|
// custom views and app parts (custom-views.ts)
|
|
3546
3881
|
"app-part-colors",
|
|
3547
3882
|
"app-part-name",
|
|
3548
|
-
"custom-view-states"
|
|
3883
|
+
"custom-view-states",
|
|
3884
|
+
// the app's client layer (client-layer.ts)
|
|
3885
|
+
"client/layer",
|
|
3886
|
+
"client/one-view-per-resource"
|
|
3549
3887
|
];
|
|
3550
3888
|
var DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
|
|
3551
3889
|
var STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
|
|
@@ -3684,14 +4022,32 @@ function checkShadowedExports(ctx) {
|
|
|
3684
4022
|
const re = /\bexport\s+(?:default\s+)?(?:declare\s+)?(?:async\s+)?(?:function\*?|const|let|var|class)\s+([A-Z][\w$]*)/g;
|
|
3685
4023
|
for (const file of ctx.files) {
|
|
3686
4024
|
if (!SCRIPT_EXTS.has(file.ext) || insideOverlayOf(overlays, file, ctx.genesis.uiPackage)) continue;
|
|
4025
|
+
const wrapped = wrappedGenesisNames(file.code, ctx.genesis.uiPackage, { jsx: file.ext !== ".ts" && file.ext !== ".mts" });
|
|
3687
4026
|
file.code.split("\n").forEach((text, i) => {
|
|
3688
4027
|
for (const m of text.matchAll(re)) {
|
|
3689
4028
|
if (!ctx.genesis.values.has(m[1])) continue;
|
|
4029
|
+
if (wrapped.has(m[1])) continue;
|
|
3690
4030
|
ctx.report({ rule: "shadowed-export", file: file.path, line: i + 1, subject: m[1], message: `shadows the Genesis export '${m[1]}'; reuse or extend ${m[1]} from ${ctx.genesis.uiPackage} (or rename yours if it's a different thing)` });
|
|
3691
4031
|
}
|
|
3692
4032
|
});
|
|
3693
4033
|
}
|
|
3694
4034
|
}
|
|
4035
|
+
function wrappedGenesisNames(code, uiPackage, options = {}) {
|
|
4036
|
+
const out = /* @__PURE__ */ new Set();
|
|
4037
|
+
const pkg = uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
4038
|
+
const re = new RegExp(`\\bimport\\s+(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*["']${pkg}(?:/[^"']*)?["']`, "g");
|
|
4039
|
+
for (const m of code.matchAll(re)) {
|
|
4040
|
+
if (/^import\s+type\b/.test(m[0])) continue;
|
|
4041
|
+
for (const part of m[1].split(",")) {
|
|
4042
|
+
const spec = part.trim();
|
|
4043
|
+
if (!spec || spec.startsWith("type ")) continue;
|
|
4044
|
+
const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
|
|
4045
|
+
if (!imported || !local || local === imported) continue;
|
|
4046
|
+
if (usesAsCode(code, local, options)) out.add(imported);
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
return out;
|
|
4050
|
+
}
|
|
3695
4051
|
function unusedComponents(ctx) {
|
|
3696
4052
|
const used = /* @__PURE__ */ new Set();
|
|
3697
4053
|
const pkg = ctx.genesis.uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
@@ -4506,7 +4862,7 @@ function createTrail(ctx) {
|
|
|
4506
4862
|
declared = null;
|
|
4507
4863
|
}
|
|
4508
4864
|
const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));
|
|
4509
|
-
const
|
|
4865
|
+
const read3 = (abs) => byPath.get(abs) ?? readSource(abs);
|
|
4510
4866
|
const importsCache = /* @__PURE__ */ new Map();
|
|
4511
4867
|
const importsOf = (file) => {
|
|
4512
4868
|
const hit = importsCache.get(file.absolutePath);
|
|
@@ -4583,7 +4939,7 @@ function createTrail(ctx) {
|
|
|
4583
4939
|
cut.add(abs);
|
|
4584
4940
|
continue;
|
|
4585
4941
|
}
|
|
4586
|
-
const target =
|
|
4942
|
+
const target = read3(abs);
|
|
4587
4943
|
if (!target) {
|
|
4588
4944
|
unknown = true;
|
|
4589
4945
|
continue;
|
|
@@ -6821,7 +7177,109 @@ function checkAppParts(ctx) {
|
|
|
6821
7177
|
}
|
|
6822
7178
|
}
|
|
6823
7179
|
}
|
|
6824
|
-
|
|
7180
|
+
init_regexp();
|
|
7181
|
+
var JSX_EXTS5 = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
|
|
7182
|
+
var SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts"]);
|
|
7183
|
+
var DEFAULT_CLIENT_DIR = "src/client";
|
|
7184
|
+
function clientLayer(root, files) {
|
|
7185
|
+
let dir = DEFAULT_CLIENT_DIR;
|
|
7186
|
+
try {
|
|
7187
|
+
dir = readGenesisConfig(root)?.client?.dir ?? DEFAULT_CLIENT_DIR;
|
|
7188
|
+
} catch {
|
|
7189
|
+
}
|
|
7190
|
+
const inside2 = `${dir}/`;
|
|
7191
|
+
const present = files.some((f) => f.path.startsWith(inside2) && /(^|\/)resource-view\.(t|j)sx?$/.test(f.path)) || existsSync(path21.join(root, dir, "resource-view.tsx"));
|
|
7192
|
+
const recordWrapper = files.some((f) => f.path.startsWith(inside2) && /(^|\/)record-view\.(t|j)sx?$/.test(f.path)) || existsSync(path21.join(root, dir, "record-view.tsx"));
|
|
7193
|
+
return { dir, present, recordWrapper };
|
|
7194
|
+
}
|
|
7195
|
+
function genesisImports(code, uiPackage) {
|
|
7196
|
+
const out = /* @__PURE__ */ new Map();
|
|
7197
|
+
const escaped = uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
7198
|
+
const re = new RegExp(`import\\s*(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*["']${escaped}(?:/data)?["']`, "g");
|
|
7199
|
+
for (const m of code.matchAll(re)) {
|
|
7200
|
+
if (/^\s*type\s/.test(m[0].slice(6))) continue;
|
|
7201
|
+
for (const part of m[1].split(",")) {
|
|
7202
|
+
const spec = part.trim().replace(/^type\s+/, "");
|
|
7203
|
+
if (!spec || part.trim().startsWith("type ")) continue;
|
|
7204
|
+
const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
|
|
7205
|
+
if (imported === "ResourceView" || imported === "RecordView") out.set(local ?? imported, imported);
|
|
7206
|
+
}
|
|
7207
|
+
}
|
|
7208
|
+
return out;
|
|
7209
|
+
}
|
|
7210
|
+
function checkClientLayer(ctx) {
|
|
7211
|
+
const layer = clientLayer(ctx.root, ctx.files);
|
|
7212
|
+
const inside2 = `${layer.dir}/`;
|
|
7213
|
+
if (layer.present) {
|
|
7214
|
+
for (const file of ctx.files) {
|
|
7215
|
+
if (!JSX_EXTS5.has(file.ext) || file.path.startsWith(inside2)) continue;
|
|
7216
|
+
const imported = genesisImports(file.code, ctx.genesis.uiPackage);
|
|
7217
|
+
for (const [local, name] of imported) {
|
|
7218
|
+
if (name === "RecordView" && !layer.recordWrapper) continue;
|
|
7219
|
+
const at = file.code.search(new RegExp(`<${local}\\b`));
|
|
7220
|
+
if (at < 0) continue;
|
|
7221
|
+
ctx.report({
|
|
7222
|
+
rule: "client/layer",
|
|
7223
|
+
level: "warn",
|
|
7224
|
+
file: file.path,
|
|
7225
|
+
line: lineAt(file.code, at),
|
|
7226
|
+
subject: name,
|
|
7227
|
+
message: `renders Genesis's <${name}> directly; the app has a client layer (${layer.dir}), so render its ${name === "ResourceView" ? "ResourceView from resource-view.tsx" : "RecordView from record-view.tsx"}, and its defaults reach this screen too (docs/adr/0020-client-layer.md)`
|
|
7228
|
+
});
|
|
7229
|
+
}
|
|
7230
|
+
}
|
|
7231
|
+
}
|
|
7232
|
+
if (!layer.present) return;
|
|
7233
|
+
const seen = /* @__PURE__ */ new Map();
|
|
7234
|
+
for (const file of ctx.files) {
|
|
7235
|
+
if (!SCRIPT_EXTS6.has(file.ext) || SHOWN_OR_TRIED.test(file.path)) continue;
|
|
7236
|
+
const imports = importedNames(file.path, file.code);
|
|
7237
|
+
for (const m of file.code.matchAll(/\bdefineView\s*(?:<[^>]*>)?\s*\(\s*([A-Za-z_$][\w$]*)((?:\s*(?:\.\s*[A-Za-z_$][\w$]*|\[\s*["'`][^"'`]+["'`]\s*\]))*)\s*[,)]/g)) {
|
|
7238
|
+
const base = m[1];
|
|
7239
|
+
const access = m[2].replace(/\s+/g, "").replace(/'|`/g, '"');
|
|
7240
|
+
const imported = imports.get(base);
|
|
7241
|
+
if (!imported && !declaredAtTop(file.code, base)) continue;
|
|
7242
|
+
if (boundAsParameter(file.code, base, { jsx: file.ext !== ".ts" && file.ext !== ".mts" })) continue;
|
|
7243
|
+
const identity = `${imported ?? `${file.path}#${base}`}${access}`;
|
|
7244
|
+
const shown = `${base}${access}`;
|
|
7245
|
+
const line = lineAt(file.code, m.index ?? 0);
|
|
7246
|
+
const first = seen.get(identity);
|
|
7247
|
+
if (!first) {
|
|
7248
|
+
seen.set(identity, { file: file.path, line });
|
|
7249
|
+
continue;
|
|
7250
|
+
}
|
|
7251
|
+
ctx.report({
|
|
7252
|
+
rule: "client/one-view-per-resource",
|
|
7253
|
+
level: "warn",
|
|
7254
|
+
file: file.path,
|
|
7255
|
+
line,
|
|
7256
|
+
subject: shown,
|
|
7257
|
+
message: `defines a second view over ${shown} (the first is in ${first.file}:${first.line}); keep one view per resource and narrow it on the screen (preset, filter, columns), so its rules can't drift (docs/adr/0020-client-layer.md)`
|
|
7258
|
+
});
|
|
7259
|
+
}
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
7262
|
+
function declaredAtTop(code, name) {
|
|
7263
|
+
const escaped = escapeRegExp(name);
|
|
7264
|
+
return new RegExp(`^(?:export\\s+)?(?:const|let|var)\\s+${escaped}\\b`, "m").test(code);
|
|
7265
|
+
}
|
|
7266
|
+
var SHOWN_OR_TRIED = /(\.stories\.|\.test\.|\.spec\.|(^|\/)__tests__\/)/;
|
|
7267
|
+
function importedNames(filePath, code) {
|
|
7268
|
+
const out = /* @__PURE__ */ new Map();
|
|
7269
|
+
const dir = path21.posix.dirname(filePath);
|
|
7270
|
+
const where2 = (spec) => spec.startsWith(".") ? path21.posix.normalize(path21.posix.join(dir, spec)).replace(/\.(t|j)sx?$/, "").replace(/\/index$/, "") : spec;
|
|
7271
|
+
for (const m of code.matchAll(/import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g)) {
|
|
7272
|
+
for (const part of m[1].split(",")) {
|
|
7273
|
+
const spec = part.trim().replace(/^type\s+/, "");
|
|
7274
|
+
if (!spec) continue;
|
|
7275
|
+
const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
|
|
7276
|
+
out.set(local ?? imported, `${where2(m[2])}#${imported}`);
|
|
7277
|
+
}
|
|
7278
|
+
}
|
|
7279
|
+
for (const m of code.matchAll(/import\s+(?:\*\s+as\s+)?([A-Za-z_$][\w$]*)\s+from\s*["']([^"']+)["']/g)) out.set(m[1], `${where2(m[2])}#*`);
|
|
7280
|
+
return out;
|
|
7281
|
+
}
|
|
7282
|
+
var SCRIPT_EXTS7 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
|
|
6825
7283
|
var DECLARATION = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\n(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/g;
|
|
6826
7284
|
var REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
|
|
6827
7285
|
function specifierParts(spec) {
|
|
@@ -6911,7 +7369,7 @@ function checkStabilityImports(ctx) {
|
|
|
6911
7369
|
return cache2.get(pkg);
|
|
6912
7370
|
};
|
|
6913
7371
|
for (const file of ctx.files) {
|
|
6914
|
-
if (!
|
|
7372
|
+
if (!SCRIPT_EXTS7.has(file.ext)) continue;
|
|
6915
7373
|
for (const { pkg, specifier, names, line } of genesisNamedImports(file.code)) {
|
|
6916
7374
|
const tags = tagsOf(pkg);
|
|
6917
7375
|
if (!tags) continue;
|
|
@@ -7244,7 +7702,7 @@ function sourceSchemas(source) {
|
|
|
7244
7702
|
return schemas?.length ? schemas : null;
|
|
7245
7703
|
}
|
|
7246
7704
|
var lf = (text) => text.replace(/\r\n/g, "\n");
|
|
7247
|
-
async function checkContracts(ctx,
|
|
7705
|
+
async function checkContracts(ctx, read3 = postgresContract) {
|
|
7248
7706
|
const settings = ctx.config.contracts;
|
|
7249
7707
|
if (!settings) return;
|
|
7250
7708
|
const out = settings.out ?? DEFAULT_CONTRACT_OUT;
|
|
@@ -7268,7 +7726,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
|
|
|
7268
7726
|
}
|
|
7269
7727
|
let expected;
|
|
7270
7728
|
try {
|
|
7271
|
-
expected = lf((await
|
|
7729
|
+
expected = lf((await read3(url, schemas)).content);
|
|
7272
7730
|
} catch (err) {
|
|
7273
7731
|
const generation = err.name === "EmitError";
|
|
7274
7732
|
const message = err.message.split("\n")[0];
|
|
@@ -7286,7 +7744,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
|
|
|
7286
7744
|
}
|
|
7287
7745
|
}
|
|
7288
7746
|
var GENESIS_DOCS = "https://github.com/marktiderman/genesis/blob/main/docs";
|
|
7289
|
-
var
|
|
7747
|
+
var read2 = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
7290
7748
|
var CORE = [
|
|
7291
7749
|
{
|
|
7292
7750
|
need: "anything, before building it",
|
|
@@ -7416,7 +7874,7 @@ function packageGuides(root, packages) {
|
|
|
7416
7874
|
const guides = [];
|
|
7417
7875
|
for (const p of packages) {
|
|
7418
7876
|
const stable = p.local ? path21.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
|
|
7419
|
-
const text = stable === null ? null :
|
|
7877
|
+
const text = stable === null ? null : read2(stable);
|
|
7420
7878
|
if (stable === null || text === null) continue;
|
|
7421
7879
|
const description = skillDescription(text);
|
|
7422
7880
|
const at = description.indexOf("Load before");
|
|
@@ -7515,8 +7973,8 @@ function claudeState(root) {
|
|
|
7515
7973
|
function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
|
|
7516
7974
|
const rows = primitivesCatalog(packages);
|
|
7517
7975
|
const guides = packageGuides(root, packages);
|
|
7518
|
-
const skill =
|
|
7519
|
-
const block = currentAgentsBlock(
|
|
7976
|
+
const skill = read2(path21.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
|
|
7977
|
+
const block = currentAgentsBlock(read2(path21.join(root, agentsFile)));
|
|
7520
7978
|
return {
|
|
7521
7979
|
skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
|
|
7522
7980
|
agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",
|
|
@@ -8536,6 +8994,7 @@ function builtinChecks(config, options = {}) {
|
|
|
8536
8994
|
{ name: "studio-server-imports", check: checkStudioServerImports },
|
|
8537
8995
|
{ name: "removed-scope-names", check: checkRemovedScopeNames },
|
|
8538
8996
|
{ name: "app-parts", check: checkAppParts },
|
|
8997
|
+
{ name: "client-layer", check: checkClientLayer },
|
|
8539
8998
|
{ name: "stability-imports", check: checkStabilityImports },
|
|
8540
8999
|
{ name: "agent-guide", check: (ctx) => {
|
|
8541
9000
|
checkAgentGuide(ctx);
|