@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/doctor.js
CHANGED
|
@@ -24,6 +24,15 @@ var __export = (target, all) => {
|
|
|
24
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
// src/regexp.ts
|
|
28
|
+
function escapeRegExp(s) {
|
|
29
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
30
|
+
}
|
|
31
|
+
var init_regexp = __esm({
|
|
32
|
+
"src/regexp.ts"() {
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
27
36
|
// src/introspect/catalog-text.ts
|
|
28
37
|
function tokenize(tree) {
|
|
29
38
|
const tokens = [];
|
|
@@ -153,9 +162,6 @@ function splitTopLevel(expr, separator) {
|
|
|
153
162
|
parts.push(expr.slice(from));
|
|
154
163
|
return parts;
|
|
155
164
|
}
|
|
156
|
-
function escapeRegExp(s) {
|
|
157
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
158
|
-
}
|
|
159
165
|
function checkEnumValues(definition, column) {
|
|
160
166
|
const outer = /^CHECK \((.*)\)(?: NOT VALID)?$/s.exec(definition.trim());
|
|
161
167
|
if (!outer) return void 0;
|
|
@@ -190,6 +196,7 @@ function checkEnumValues(definition, column) {
|
|
|
190
196
|
var CAST, LITERAL;
|
|
191
197
|
var init_catalog_text = __esm({
|
|
192
198
|
"src/introspect/catalog-text.ts"() {
|
|
199
|
+
init_regexp();
|
|
193
200
|
CAST = String.raw`::[a-z][a-z ]*(?:\(\d+(?:,\d+)?\))?`;
|
|
194
201
|
LITERAL = String.raw`'((?:[^']|'')*)'${CAST}`;
|
|
195
202
|
}
|
|
@@ -284,8 +291,11 @@ var init_model = __esm({
|
|
|
284
291
|
});
|
|
285
292
|
|
|
286
293
|
// src/introspect/postgres.ts
|
|
287
|
-
function where(
|
|
288
|
-
return "schemas" in scope ?
|
|
294
|
+
function where(scope) {
|
|
295
|
+
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) };
|
|
296
|
+
}
|
|
297
|
+
async function read(sql, text, param) {
|
|
298
|
+
return [...await sql.unsafe(text, [param])];
|
|
289
299
|
}
|
|
290
300
|
function linkOf(columns, refColumns, refUnique = []) {
|
|
291
301
|
if (columns.length === 1) return 0;
|
|
@@ -294,7 +304,8 @@ function linkOf(columns, refColumns, refUnique = []) {
|
|
|
294
304
|
return own.length === 1 && refUnique[own[0]] === true ? own[0] : -1;
|
|
295
305
|
}
|
|
296
306
|
async function readRelations(sql, scope, into) {
|
|
297
|
-
const
|
|
307
|
+
const { condition, param } = where(scope);
|
|
308
|
+
const columns = await read(sql, `
|
|
298
309
|
select c.oid::text as oid, c.relkind::text as relkind, n.nspname as schema, c.relname as table,
|
|
299
310
|
obj_description(c.oid, 'pg_class') as table_comment,
|
|
300
311
|
a.attnum::int as attnum,
|
|
@@ -313,17 +324,17 @@ async function readRelations(sql, scope, into) {
|
|
|
313
324
|
join pg_attribute a on a.attrelid = c.oid and a.attnum > 0 and not a.attisdropped
|
|
314
325
|
join pg_type t on t.oid = a.atttypid
|
|
315
326
|
where c.relkind in ('r', 'p', 'v', 'm', 'f')
|
|
316
|
-
and ${
|
|
317
|
-
order by n.nspname, c.relname, a.attnum
|
|
318
|
-
const keys = await sql`
|
|
327
|
+
and ${condition}
|
|
328
|
+
order by n.nspname, c.relname, a.attnum`, param);
|
|
329
|
+
const keys = await read(sql, `
|
|
319
330
|
select c.oid::text as oid, array_agg(k.attnum::int order by k.ord) as columns
|
|
320
331
|
from pg_constraint con
|
|
321
332
|
join pg_class c on c.oid = con.conrelid
|
|
322
333
|
join pg_namespace n on n.oid = c.relnamespace
|
|
323
334
|
cross join lateral unnest(con.conkey) with ordinality as k(attnum, ord)
|
|
324
|
-
where con.contype = 'p' and ${
|
|
325
|
-
group by c.oid
|
|
326
|
-
const links = await sql`
|
|
335
|
+
where con.contype = 'p' and ${condition}
|
|
336
|
+
group by c.oid`, param);
|
|
337
|
+
const links = await read(sql, `
|
|
327
338
|
select c.oid::text as oid, con.conkey::int[] as attnums,
|
|
328
339
|
array(select a.attname::text from unnest(con.conkey) with ordinality k(attnum, ord)
|
|
329
340
|
join pg_attribute a on a.attrelid = c.oid and a.attnum = k.attnum order by k.ord) as columns,
|
|
@@ -340,9 +351,9 @@ async function readRelations(sql, scope, into) {
|
|
|
340
351
|
join pg_class rc on rc.oid = con.confrelid
|
|
341
352
|
join pg_namespace rn on rn.oid = rc.relnamespace
|
|
342
353
|
where con.contype = 'f'
|
|
343
|
-
and ${
|
|
344
|
-
order by con.conname
|
|
345
|
-
const checks = await sql`
|
|
354
|
+
and ${condition}
|
|
355
|
+
order by con.conname`, param);
|
|
356
|
+
const checks = await read(sql, `
|
|
346
357
|
select c.oid::text as oid, con.conkey[1]::int as attnum, a.attname as column,
|
|
347
358
|
pg_get_constraintdef(con.oid) as definition
|
|
348
359
|
from pg_constraint con
|
|
@@ -350,9 +361,9 @@ async function readRelations(sql, scope, into) {
|
|
|
350
361
|
join pg_namespace n on n.oid = c.relnamespace
|
|
351
362
|
join pg_attribute a on a.attrelid = c.oid and a.attnum = con.conkey[1]
|
|
352
363
|
where con.contype = 'c' and array_length(con.conkey, 1) = 1
|
|
353
|
-
and ${
|
|
354
|
-
order by con.conname
|
|
355
|
-
const views = await sql`
|
|
364
|
+
and ${condition}
|
|
365
|
+
order by con.conname`, param);
|
|
366
|
+
const views = await read(sql, `
|
|
356
367
|
select c.oid::text as oid, r.ev_action::text as ev_action
|
|
357
368
|
from pg_class c
|
|
358
369
|
join pg_namespace n on n.oid = c.relnamespace
|
|
@@ -360,7 +371,7 @@ async function readRelations(sql, scope, into) {
|
|
|
360
371
|
where c.relkind = 'v'
|
|
361
372
|
and (pg_relation_is_updatable(c.oid, false) & 20) = 20
|
|
362
373
|
and not exists (select 1 from pg_rewrite o where o.ev_class = c.oid and o.rulename <> '_RETURN')
|
|
363
|
-
and ${
|
|
374
|
+
and ${condition}`, param);
|
|
364
375
|
const added = [];
|
|
365
376
|
for (const row of columns) {
|
|
366
377
|
let relation = into.get(row.oid);
|
|
@@ -934,6 +945,7 @@ function readGenesisConfig(root) {
|
|
|
934
945
|
}
|
|
935
946
|
if (raw.appFolder !== void 0) out.appFolder = validateAppFolder(raw.appFolder, file);
|
|
936
947
|
if (raw.environments !== void 0) out.environments = validateEnvironments(raw.environments, file);
|
|
948
|
+
if (raw.client !== void 0) out.client = validateClient(raw.client, file);
|
|
937
949
|
return out;
|
|
938
950
|
}
|
|
939
951
|
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}$/;
|
|
@@ -945,6 +957,16 @@ function validateAppFolder(raw, source = "config") {
|
|
|
945
957
|
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)})`);
|
|
946
958
|
return norm;
|
|
947
959
|
}
|
|
960
|
+
function validateClient(raw, source = "config") {
|
|
961
|
+
const fail = (msg) => {
|
|
962
|
+
throw new GenesisConfigError(`${source}: ${msg}`);
|
|
963
|
+
};
|
|
964
|
+
if (!isObject(raw)) return fail(`"client" must be { "dir": "<the client layer's folder, e.g. src/client>" }`);
|
|
965
|
+
for (const key2 of Object.keys(raw)) if (key2 !== "dir" && key2 !== "$comment") fail(`client: unknown setting "${key2}" (known: dir)`);
|
|
966
|
+
const dir = typeof raw.dir === "string" ? raw.dir.replace(/^\.\//, "").replace(/\/+$/, "") : "";
|
|
967
|
+
if (!isPlainFolder(dir)) return fail(`client.dir must be a folder inside the app, such as "src/client" (got ${JSON.stringify(raw.dir)})`);
|
|
968
|
+
return { dir };
|
|
969
|
+
}
|
|
948
970
|
function validateSupabase(raw, source = "config") {
|
|
949
971
|
const fail = (msg) => {
|
|
950
972
|
throw new GenesisConfigError(`${source}: ${msg}`);
|
|
@@ -1208,7 +1230,7 @@ function globToRegExp(glob) {
|
|
|
1208
1230
|
}
|
|
1209
1231
|
function globMatcher(globs) {
|
|
1210
1232
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
1211
|
-
return (
|
|
1233
|
+
return (path50) => res.some((re) => re.test(path50));
|
|
1212
1234
|
}
|
|
1213
1235
|
var GENESIS_PACKAGE = /^@marktiderman\/genesis(-[a-z0-9-]+)?$/;
|
|
1214
1236
|
var BLOCK_ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
|
|
@@ -2770,6 +2792,319 @@ function resolvePlugin(id, configDir) {
|
|
|
2770
2792
|
function resolveFrom(id, from) {
|
|
2771
2793
|
return createRequire(path21.join(from, "noop.js")).resolve(id);
|
|
2772
2794
|
}
|
|
2795
|
+
|
|
2796
|
+
// src/doctor/js-scan.ts
|
|
2797
|
+
var IDENT_START = /[A-Za-z_$]/;
|
|
2798
|
+
var IDENT = /[\w$]/;
|
|
2799
|
+
var PUNCT3 = ["...", "===", "!==", "**=", "<<=", ">>=", "??=", "&&=", "||="];
|
|
2800
|
+
var PUNCT2 = ["=>", "==", "!=", "<=", ">=", "&&", "||", "??", "?.", "++", "--", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "**", "<<", ">>"];
|
|
2801
|
+
var EXPRESSION_KEYWORDS = /* @__PURE__ */ new Set(["return", "typeof", "case", "do", "else", "in", "new", "delete", "void", "throw", "yield", "await", "instanceof"]);
|
|
2802
|
+
var TYPE_PARAMETERS = /^<\s*[A-Za-z_$][\w$]*\s*(?:,|extends\b)/;
|
|
2803
|
+
function scanCode(code, options = {}) {
|
|
2804
|
+
const jsx = options.jsx ?? true;
|
|
2805
|
+
const tokens = [];
|
|
2806
|
+
const push = (kind, value) => tokens.push({ kind, value, index: tokens.length });
|
|
2807
|
+
const expressionNext = (start) => {
|
|
2808
|
+
if (tokens.length <= start) return true;
|
|
2809
|
+
const t = tokens[tokens.length - 1];
|
|
2810
|
+
if (!t) return true;
|
|
2811
|
+
if (t.kind === "ident") return EXPRESSION_KEYWORDS.has(t.value);
|
|
2812
|
+
if (t.kind === "jsxTag" || t.kind === "literal") return false;
|
|
2813
|
+
return !(t.value === ")" || t.value === "]" || t.value === "}" || t.value === "<>");
|
|
2814
|
+
};
|
|
2815
|
+
const skipString2 = (i2, quote2) => {
|
|
2816
|
+
let j = i2 + 1;
|
|
2817
|
+
while (j < code.length && code[j] !== quote2) {
|
|
2818
|
+
if (code[j] === "\\") j++;
|
|
2819
|
+
else if (code[j] === "\n") return j;
|
|
2820
|
+
j++;
|
|
2821
|
+
}
|
|
2822
|
+
return j + 1;
|
|
2823
|
+
};
|
|
2824
|
+
const skipAttribute = (i2, quote2) => {
|
|
2825
|
+
const end = code.indexOf(quote2, i2 + 1);
|
|
2826
|
+
return end < 0 ? code.length : end + 1;
|
|
2827
|
+
};
|
|
2828
|
+
const skipRegex = (i2) => {
|
|
2829
|
+
let j = i2 + 1;
|
|
2830
|
+
let inClass = false;
|
|
2831
|
+
while (j < code.length && code[j] !== "\n") {
|
|
2832
|
+
const c = code[j];
|
|
2833
|
+
if (c === "\\") j++;
|
|
2834
|
+
else if (c === "[") inClass = true;
|
|
2835
|
+
else if (c === "]") inClass = false;
|
|
2836
|
+
else if (c === "/" && !inClass) {
|
|
2837
|
+
j++;
|
|
2838
|
+
while (j < code.length && IDENT.test(code[j])) j++;
|
|
2839
|
+
return j;
|
|
2840
|
+
}
|
|
2841
|
+
j++;
|
|
2842
|
+
}
|
|
2843
|
+
return j;
|
|
2844
|
+
};
|
|
2845
|
+
const skipTrivia = (i2) => {
|
|
2846
|
+
let j = i2;
|
|
2847
|
+
for (; ; ) {
|
|
2848
|
+
while (j < code.length && /\s/.test(code[j])) j++;
|
|
2849
|
+
if (code.startsWith("//", j)) {
|
|
2850
|
+
const end = code.indexOf("\n", j);
|
|
2851
|
+
j = end < 0 ? code.length : end;
|
|
2852
|
+
} else if (code.startsWith("/*", j)) {
|
|
2853
|
+
const end = code.indexOf("*/", j + 2);
|
|
2854
|
+
j = end < 0 ? code.length : end + 2;
|
|
2855
|
+
} else return j;
|
|
2856
|
+
}
|
|
2857
|
+
};
|
|
2858
|
+
const stack = [{ k: "code", depth: 0, stop: false, start: 0 }];
|
|
2859
|
+
const openCode = () => stack.push({ k: "code", depth: 0, stop: true, start: tokens.length });
|
|
2860
|
+
const openElement = (i2) => {
|
|
2861
|
+
if (code[i2 + 1] === ">") {
|
|
2862
|
+
stack.push({ k: "children" });
|
|
2863
|
+
return i2 + 2;
|
|
2864
|
+
}
|
|
2865
|
+
let j = i2 + 1;
|
|
2866
|
+
while (j < code.length && /[\w$.:-]/.test(code[j])) j++;
|
|
2867
|
+
const name = code.slice(i2 + 1, j);
|
|
2868
|
+
if (name) push("jsxTag", name.split(/[.:]/)[0]);
|
|
2869
|
+
stack.push({ k: "tag" });
|
|
2870
|
+
return j;
|
|
2871
|
+
};
|
|
2872
|
+
const closeElement = () => {
|
|
2873
|
+
stack.pop();
|
|
2874
|
+
push("punct", "<>");
|
|
2875
|
+
};
|
|
2876
|
+
let i = 0;
|
|
2877
|
+
while (i < code.length) {
|
|
2878
|
+
const top = stack[stack.length - 1];
|
|
2879
|
+
if (top.k === "code") {
|
|
2880
|
+
i = skipTrivia(i);
|
|
2881
|
+
if (i >= code.length) break;
|
|
2882
|
+
const c = code[i];
|
|
2883
|
+
if (c === '"' || c === "'") {
|
|
2884
|
+
i = skipString2(i, c);
|
|
2885
|
+
push("literal", "''");
|
|
2886
|
+
} else if (c === "`") {
|
|
2887
|
+
stack.push({ k: "template" });
|
|
2888
|
+
i++;
|
|
2889
|
+
} else if (IDENT_START.test(c)) {
|
|
2890
|
+
let j = i + 1;
|
|
2891
|
+
while (j < code.length && IDENT.test(code[j])) j++;
|
|
2892
|
+
push("ident", code.slice(i, j));
|
|
2893
|
+
i = j;
|
|
2894
|
+
} else if (/\d/.test(c) || c === "." && /\d/.test(code[i + 1] ?? "")) {
|
|
2895
|
+
let j = i + 1;
|
|
2896
|
+
while (j < code.length && /[\w.]/.test(code[j])) j++;
|
|
2897
|
+
push("literal", "0");
|
|
2898
|
+
i = j;
|
|
2899
|
+
} else if (c === "/" && expressionNext(top.start)) {
|
|
2900
|
+
i = skipRegex(i);
|
|
2901
|
+
push("literal", "//");
|
|
2902
|
+
} else if (c === "<" && jsx && expressionNext(top.start) && /[A-Za-z_$>]/.test(code[i + 1] ?? "") && !TYPE_PARAMETERS.test(code.slice(i, i + 200))) {
|
|
2903
|
+
i = openElement(i);
|
|
2904
|
+
} else if (c === "{") {
|
|
2905
|
+
top.depth++;
|
|
2906
|
+
push("punct", "{");
|
|
2907
|
+
i++;
|
|
2908
|
+
} else if (c === "}") {
|
|
2909
|
+
i++;
|
|
2910
|
+
if (top.depth === 0 && top.stop) stack.pop();
|
|
2911
|
+
else {
|
|
2912
|
+
top.depth = Math.max(0, top.depth - 1);
|
|
2913
|
+
push("punct", "}");
|
|
2914
|
+
}
|
|
2915
|
+
} else {
|
|
2916
|
+
const three = code.slice(i, i + 3);
|
|
2917
|
+
const two = code.slice(i, i + 2);
|
|
2918
|
+
const p = PUNCT3.includes(three) ? three : PUNCT2.includes(two) ? two : c;
|
|
2919
|
+
push("punct", p);
|
|
2920
|
+
i += p.length;
|
|
2921
|
+
}
|
|
2922
|
+
} else if (top.k === "template") {
|
|
2923
|
+
const c = code[i];
|
|
2924
|
+
if (c === "\\") i += 2;
|
|
2925
|
+
else if (c === "`") {
|
|
2926
|
+
stack.pop();
|
|
2927
|
+
push("literal", "``");
|
|
2928
|
+
i++;
|
|
2929
|
+
} else if (c === "$" && code[i + 1] === "{") {
|
|
2930
|
+
openCode();
|
|
2931
|
+
i += 2;
|
|
2932
|
+
} else i++;
|
|
2933
|
+
} else if (top.k === "tag") {
|
|
2934
|
+
i = skipTrivia(i);
|
|
2935
|
+
const c = code[i];
|
|
2936
|
+
if (c === void 0) break;
|
|
2937
|
+
if (c === "/" && code[i + 1] === ">") {
|
|
2938
|
+
closeElement();
|
|
2939
|
+
i += 2;
|
|
2940
|
+
} else if (c === ">") {
|
|
2941
|
+
stack[stack.length - 1] = { k: "children" };
|
|
2942
|
+
i++;
|
|
2943
|
+
} else if (c === "{") {
|
|
2944
|
+
openCode();
|
|
2945
|
+
i++;
|
|
2946
|
+
} else if (c === '"' || c === "'") i = skipAttribute(i, c);
|
|
2947
|
+
else if (c === "<") i = openElement(i);
|
|
2948
|
+
else i++;
|
|
2949
|
+
} else {
|
|
2950
|
+
const c = code[i];
|
|
2951
|
+
if (c === "<" && code[i + 1] === "/") {
|
|
2952
|
+
const end = code.indexOf(">", i);
|
|
2953
|
+
i = end < 0 ? code.length : end + 1;
|
|
2954
|
+
closeElement();
|
|
2955
|
+
} else if (c === "<" && /[A-Za-z_$>]/.test(code[i + 1] ?? "")) i = openElement(i);
|
|
2956
|
+
else if (c === "{") {
|
|
2957
|
+
openCode();
|
|
2958
|
+
i++;
|
|
2959
|
+
} else i++;
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
return tokens;
|
|
2963
|
+
}
|
|
2964
|
+
function usesAsCode(code, name, options = {}) {
|
|
2965
|
+
const tokens = scanCode(code, options);
|
|
2966
|
+
return tokens.some((t, i) => {
|
|
2967
|
+
if (t.value !== name) return false;
|
|
2968
|
+
if (t.kind === "jsxTag") return true;
|
|
2969
|
+
if (t.kind !== "ident") return false;
|
|
2970
|
+
const before = tokens[i - 1];
|
|
2971
|
+
const after = tokens[i + 1];
|
|
2972
|
+
if (before?.value === "." || before?.value === "?." || before?.value === "as" || before?.value === "import") return false;
|
|
2973
|
+
if (after?.value === ":" && (before?.value === "{" || before?.value === ",")) return false;
|
|
2974
|
+
return true;
|
|
2975
|
+
});
|
|
2976
|
+
}
|
|
2977
|
+
var NOT_METHODS = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "with", "function", "return", "typeof", "await", "new"]);
|
|
2978
|
+
var BEFORE_METHOD = /* @__PURE__ */ new Set(["{", "}", ";", ",", "*", "async", "get", "set", "static", "public", "private", "protected", "readonly", "override", "abstract", "declare", "accessor"]);
|
|
2979
|
+
var TYPE_PARAMETERS_REACH = 200;
|
|
2980
|
+
var OPENS = /* @__PURE__ */ new Set(["(", "[", "{"]);
|
|
2981
|
+
var CLOSES = /* @__PURE__ */ new Set([")", "]", "}"]);
|
|
2982
|
+
function boundNames(list) {
|
|
2983
|
+
const out = [];
|
|
2984
|
+
const params = [[]];
|
|
2985
|
+
let depth = 0;
|
|
2986
|
+
let angles = 0;
|
|
2987
|
+
let inType = false;
|
|
2988
|
+
for (const t of list) {
|
|
2989
|
+
if (OPENS.has(t.value)) depth++;
|
|
2990
|
+
else if (CLOSES.has(t.value)) depth--;
|
|
2991
|
+
else if (depth === 0 && t.value === ":") inType = true;
|
|
2992
|
+
else if (depth === 0 && t.value === "=") inType = false;
|
|
2993
|
+
else if (inType && t.value === "<") angles++;
|
|
2994
|
+
else if (inType && (t.value === ">" || t.value === ">>")) angles = Math.max(0, angles - t.value.length);
|
|
2995
|
+
if (depth === 0 && angles === 0 && t.value === ",") {
|
|
2996
|
+
params.push([]);
|
|
2997
|
+
inType = false;
|
|
2998
|
+
} else params[params.length - 1].push(t);
|
|
2999
|
+
}
|
|
3000
|
+
for (const param of params) {
|
|
3001
|
+
let d = 0;
|
|
3002
|
+
let end = param.length;
|
|
3003
|
+
for (let k = 0; k < param.length; k++) {
|
|
3004
|
+
const v = param[k].value;
|
|
3005
|
+
if (OPENS.has(v)) d++;
|
|
3006
|
+
else if (CLOSES.has(v)) d--;
|
|
3007
|
+
else if (d === 0 && (v === "=" || v === ":" || v === "?")) {
|
|
3008
|
+
end = k;
|
|
3009
|
+
break;
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
const pattern = param.slice(0, end);
|
|
3013
|
+
let skipping = -1;
|
|
3014
|
+
d = 0;
|
|
3015
|
+
for (let k = 0; k < pattern.length; k++) {
|
|
3016
|
+
const t = pattern[k];
|
|
3017
|
+
if (t.value === "[" && skipping < 0) {
|
|
3018
|
+
let depth2 = 0;
|
|
3019
|
+
let close = k;
|
|
3020
|
+
for (; close < pattern.length; close++) {
|
|
3021
|
+
const v = pattern[close].value;
|
|
3022
|
+
if (OPENS.has(v)) depth2++;
|
|
3023
|
+
else if (CLOSES.has(v) && --depth2 === 0) break;
|
|
3024
|
+
}
|
|
3025
|
+
if (pattern[close + 1]?.value === ":") {
|
|
3026
|
+
k = close;
|
|
3027
|
+
continue;
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
if (OPENS.has(t.value)) d++;
|
|
3031
|
+
else if (CLOSES.has(t.value)) {
|
|
3032
|
+
d--;
|
|
3033
|
+
if (skipping > d) skipping = -1;
|
|
3034
|
+
}
|
|
3035
|
+
if (skipping >= 0) {
|
|
3036
|
+
if (t.value === "," && d === skipping) skipping = -1;
|
|
3037
|
+
continue;
|
|
3038
|
+
}
|
|
3039
|
+
if (t.value === "=") {
|
|
3040
|
+
skipping = d;
|
|
3041
|
+
continue;
|
|
3042
|
+
}
|
|
3043
|
+
if (t.kind === "ident" && pattern[k + 1]?.value !== ":") out.push(t.value);
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
return out;
|
|
3047
|
+
}
|
|
3048
|
+
function boundAsParameter(code, name, options = {}) {
|
|
3049
|
+
const tokens = scanCode(code, options);
|
|
3050
|
+
const match = new Int32Array(tokens.length).fill(-1);
|
|
3051
|
+
const open = [];
|
|
3052
|
+
tokens.forEach((t, k) => {
|
|
3053
|
+
if (t.value === "(") open.push(k);
|
|
3054
|
+
else if (t.value === ")" && open.length) match[open.pop()] = k;
|
|
3055
|
+
});
|
|
3056
|
+
const arrowAfter = (end) => {
|
|
3057
|
+
const next = tokens[end + 1];
|
|
3058
|
+
if (next?.value === "=>") return true;
|
|
3059
|
+
if (next?.value !== ":") return false;
|
|
3060
|
+
let depth = 0;
|
|
3061
|
+
for (let k = end + 2; k < Math.min(tokens.length, end + 200); k++) {
|
|
3062
|
+
const v = tokens[k].value;
|
|
3063
|
+
if (v === "(" || v === "{" || v === "[" || v === "<") depth++;
|
|
3064
|
+
else if (v === ")" || v === "}" || v === "]" || v === ">") depth--;
|
|
3065
|
+
if (depth < 0) return false;
|
|
3066
|
+
if (depth === 0 && v === "=>") return true;
|
|
3067
|
+
if (depth === 0 && (v === ";" || v === "," || v === "=")) return false;
|
|
3068
|
+
}
|
|
3069
|
+
return false;
|
|
3070
|
+
};
|
|
3071
|
+
const beforeTypeParameters = (paren) => {
|
|
3072
|
+
let k = paren - 1;
|
|
3073
|
+
if (tokens[k]?.value !== ">" && tokens[k]?.value !== ">>") return k;
|
|
3074
|
+
let depth = 0;
|
|
3075
|
+
for (const stop = Math.max(0, k - TYPE_PARAMETERS_REACH); k >= stop; k--) {
|
|
3076
|
+
const v = tokens[k].value;
|
|
3077
|
+
if (v === ">") depth++;
|
|
3078
|
+
else if (v === ">>") depth += 2;
|
|
3079
|
+
else if (v === "<" && --depth === 0) return k - 1;
|
|
3080
|
+
}
|
|
3081
|
+
return -1;
|
|
3082
|
+
};
|
|
3083
|
+
const isFunction = (paren) => {
|
|
3084
|
+
let k = beforeTypeParameters(paren);
|
|
3085
|
+
if (k < 0) return false;
|
|
3086
|
+
if (tokens[k]?.kind === "ident" && tokens[k].value !== "function") k--;
|
|
3087
|
+
if (tokens[k]?.value === "*") k--;
|
|
3088
|
+
return tokens[k]?.value === "function";
|
|
3089
|
+
};
|
|
3090
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
3091
|
+
const t = tokens[i];
|
|
3092
|
+
if (t.value === "=>" && tokens[i - 1]?.kind === "ident" && tokens[i - 1].value === name && tokens[i - 2]?.value !== ".") return true;
|
|
3093
|
+
if (t.value !== "(") continue;
|
|
3094
|
+
const end = match[i];
|
|
3095
|
+
if (end < 0) continue;
|
|
3096
|
+
const before = tokens[i - 1];
|
|
3097
|
+
const catchClause = before?.value === "catch";
|
|
3098
|
+
const nameAt = beforeTypeParameters(i);
|
|
3099
|
+
const methodName = nameAt >= 0 ? tokens[nameAt] : void 0;
|
|
3100
|
+
const typed = tokens[end + 1]?.value === ":" && !arrowAfter(end);
|
|
3101
|
+
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)));
|
|
3102
|
+
if ((catchClause || isFunction(i) || method || arrowAfter(end)) && boundNames(tokens.slice(i + 1, end)).includes(name)) return true;
|
|
3103
|
+
}
|
|
3104
|
+
return false;
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
// src/doctor/rules.ts
|
|
2773
3108
|
var BUILTIN_RULES = [
|
|
2774
3109
|
"local-primitives",
|
|
2775
3110
|
// figma (figma/routes.ts; runs when genesis.config.json has a figma block)
|
|
@@ -2857,7 +3192,10 @@ var BUILTIN_RULES = [
|
|
|
2857
3192
|
// custom views and app parts (custom-views.ts)
|
|
2858
3193
|
"app-part-colors",
|
|
2859
3194
|
"app-part-name",
|
|
2860
|
-
"custom-view-states"
|
|
3195
|
+
"custom-view-states",
|
|
3196
|
+
// the app's client layer (client-layer.ts)
|
|
3197
|
+
"client/layer",
|
|
3198
|
+
"client/one-view-per-resource"
|
|
2861
3199
|
];
|
|
2862
3200
|
var DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
|
|
2863
3201
|
var STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
|
|
@@ -2996,14 +3334,32 @@ function checkShadowedExports(ctx) {
|
|
|
2996
3334
|
const re = /\bexport\s+(?:default\s+)?(?:declare\s+)?(?:async\s+)?(?:function\*?|const|let|var|class)\s+([A-Z][\w$]*)/g;
|
|
2997
3335
|
for (const file of ctx.files) {
|
|
2998
3336
|
if (!SCRIPT_EXTS.has(file.ext) || insideOverlayOf(overlays, file, ctx.genesis.uiPackage)) continue;
|
|
3337
|
+
const wrapped = wrappedGenesisNames(file.code, ctx.genesis.uiPackage, { jsx: file.ext !== ".ts" && file.ext !== ".mts" });
|
|
2999
3338
|
file.code.split("\n").forEach((text, i) => {
|
|
3000
3339
|
for (const m of text.matchAll(re)) {
|
|
3001
3340
|
if (!ctx.genesis.values.has(m[1])) continue;
|
|
3341
|
+
if (wrapped.has(m[1])) continue;
|
|
3002
3342
|
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)` });
|
|
3003
3343
|
}
|
|
3004
3344
|
});
|
|
3005
3345
|
}
|
|
3006
3346
|
}
|
|
3347
|
+
function wrappedGenesisNames(code, uiPackage, options = {}) {
|
|
3348
|
+
const out = /* @__PURE__ */ new Set();
|
|
3349
|
+
const pkg = uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
3350
|
+
const re = new RegExp(`\\bimport\\s+(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*["']${pkg}(?:/[^"']*)?["']`, "g");
|
|
3351
|
+
for (const m of code.matchAll(re)) {
|
|
3352
|
+
if (/^import\s+type\b/.test(m[0])) continue;
|
|
3353
|
+
for (const part of m[1].split(",")) {
|
|
3354
|
+
const spec = part.trim();
|
|
3355
|
+
if (!spec || spec.startsWith("type ")) continue;
|
|
3356
|
+
const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
|
|
3357
|
+
if (!imported || !local || local === imported) continue;
|
|
3358
|
+
if (usesAsCode(code, local, options)) out.add(imported);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
return out;
|
|
3362
|
+
}
|
|
3007
3363
|
function unusedComponents(ctx) {
|
|
3008
3364
|
const used = /* @__PURE__ */ new Set();
|
|
3009
3365
|
const pkg = ctx.genesis.uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
@@ -3818,7 +4174,7 @@ function createTrail(ctx) {
|
|
|
3818
4174
|
declared = null;
|
|
3819
4175
|
}
|
|
3820
4176
|
const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));
|
|
3821
|
-
const
|
|
4177
|
+
const read3 = (abs) => byPath.get(abs) ?? readSource(abs);
|
|
3822
4178
|
const importsCache = /* @__PURE__ */ new Map();
|
|
3823
4179
|
const importsOf = (file) => {
|
|
3824
4180
|
const hit = importsCache.get(file.absolutePath);
|
|
@@ -3895,7 +4251,7 @@ function createTrail(ctx) {
|
|
|
3895
4251
|
cut.add(abs);
|
|
3896
4252
|
continue;
|
|
3897
4253
|
}
|
|
3898
|
-
const target =
|
|
4254
|
+
const target = read3(abs);
|
|
3899
4255
|
if (!target) {
|
|
3900
4256
|
unknown = true;
|
|
3901
4257
|
continue;
|
|
@@ -6136,7 +6492,109 @@ function checkAppParts(ctx) {
|
|
|
6136
6492
|
}
|
|
6137
6493
|
}
|
|
6138
6494
|
}
|
|
6139
|
-
|
|
6495
|
+
init_regexp();
|
|
6496
|
+
var JSX_EXTS5 = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
|
|
6497
|
+
var SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts"]);
|
|
6498
|
+
var DEFAULT_CLIENT_DIR = "src/client";
|
|
6499
|
+
function clientLayer(root, files) {
|
|
6500
|
+
let dir = DEFAULT_CLIENT_DIR;
|
|
6501
|
+
try {
|
|
6502
|
+
dir = readGenesisConfig(root)?.client?.dir ?? DEFAULT_CLIENT_DIR;
|
|
6503
|
+
} catch {
|
|
6504
|
+
}
|
|
6505
|
+
const inside2 = `${dir}/`;
|
|
6506
|
+
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"));
|
|
6507
|
+
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"));
|
|
6508
|
+
return { dir, present, recordWrapper };
|
|
6509
|
+
}
|
|
6510
|
+
function genesisImports(code, uiPackage) {
|
|
6511
|
+
const out = /* @__PURE__ */ new Map();
|
|
6512
|
+
const escaped = uiPackage.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
6513
|
+
const re = new RegExp(`import\\s*(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*["']${escaped}(?:/data)?["']`, "g");
|
|
6514
|
+
for (const m of code.matchAll(re)) {
|
|
6515
|
+
if (/^\s*type\s/.test(m[0].slice(6))) continue;
|
|
6516
|
+
for (const part of m[1].split(",")) {
|
|
6517
|
+
const spec = part.trim().replace(/^type\s+/, "");
|
|
6518
|
+
if (!spec || part.trim().startsWith("type ")) continue;
|
|
6519
|
+
const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
|
|
6520
|
+
if (imported === "ResourceView" || imported === "RecordView") out.set(local ?? imported, imported);
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
return out;
|
|
6524
|
+
}
|
|
6525
|
+
function checkClientLayer(ctx) {
|
|
6526
|
+
const layer = clientLayer(ctx.root, ctx.files);
|
|
6527
|
+
const inside2 = `${layer.dir}/`;
|
|
6528
|
+
if (layer.present) {
|
|
6529
|
+
for (const file of ctx.files) {
|
|
6530
|
+
if (!JSX_EXTS5.has(file.ext) || file.path.startsWith(inside2)) continue;
|
|
6531
|
+
const imported = genesisImports(file.code, ctx.genesis.uiPackage);
|
|
6532
|
+
for (const [local, name] of imported) {
|
|
6533
|
+
if (name === "RecordView" && !layer.recordWrapper) continue;
|
|
6534
|
+
const at = file.code.search(new RegExp(`<${local}\\b`));
|
|
6535
|
+
if (at < 0) continue;
|
|
6536
|
+
ctx.report({
|
|
6537
|
+
rule: "client/layer",
|
|
6538
|
+
level: "warn",
|
|
6539
|
+
file: file.path,
|
|
6540
|
+
line: lineAt(file.code, at),
|
|
6541
|
+
subject: name,
|
|
6542
|
+
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)`
|
|
6543
|
+
});
|
|
6544
|
+
}
|
|
6545
|
+
}
|
|
6546
|
+
}
|
|
6547
|
+
if (!layer.present) return;
|
|
6548
|
+
const seen = /* @__PURE__ */ new Map();
|
|
6549
|
+
for (const file of ctx.files) {
|
|
6550
|
+
if (!SCRIPT_EXTS6.has(file.ext) || SHOWN_OR_TRIED.test(file.path)) continue;
|
|
6551
|
+
const imports = importedNames(file.path, file.code);
|
|
6552
|
+
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)) {
|
|
6553
|
+
const base = m[1];
|
|
6554
|
+
const access = m[2].replace(/\s+/g, "").replace(/'|`/g, '"');
|
|
6555
|
+
const imported = imports.get(base);
|
|
6556
|
+
if (!imported && !declaredAtTop(file.code, base)) continue;
|
|
6557
|
+
if (boundAsParameter(file.code, base, { jsx: file.ext !== ".ts" && file.ext !== ".mts" })) continue;
|
|
6558
|
+
const identity = `${imported ?? `${file.path}#${base}`}${access}`;
|
|
6559
|
+
const shown = `${base}${access}`;
|
|
6560
|
+
const line = lineAt(file.code, m.index ?? 0);
|
|
6561
|
+
const first = seen.get(identity);
|
|
6562
|
+
if (!first) {
|
|
6563
|
+
seen.set(identity, { file: file.path, line });
|
|
6564
|
+
continue;
|
|
6565
|
+
}
|
|
6566
|
+
ctx.report({
|
|
6567
|
+
rule: "client/one-view-per-resource",
|
|
6568
|
+
level: "warn",
|
|
6569
|
+
file: file.path,
|
|
6570
|
+
line,
|
|
6571
|
+
subject: shown,
|
|
6572
|
+
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)`
|
|
6573
|
+
});
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
}
|
|
6577
|
+
function declaredAtTop(code, name) {
|
|
6578
|
+
const escaped = escapeRegExp(name);
|
|
6579
|
+
return new RegExp(`^(?:export\\s+)?(?:const|let|var)\\s+${escaped}\\b`, "m").test(code);
|
|
6580
|
+
}
|
|
6581
|
+
var SHOWN_OR_TRIED = /(\.stories\.|\.test\.|\.spec\.|(^|\/)__tests__\/)/;
|
|
6582
|
+
function importedNames(filePath, code) {
|
|
6583
|
+
const out = /* @__PURE__ */ new Map();
|
|
6584
|
+
const dir = path21.posix.dirname(filePath);
|
|
6585
|
+
const where2 = (spec) => spec.startsWith(".") ? path21.posix.normalize(path21.posix.join(dir, spec)).replace(/\.(t|j)sx?$/, "").replace(/\/index$/, "") : spec;
|
|
6586
|
+
for (const m of code.matchAll(/import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g)) {
|
|
6587
|
+
for (const part of m[1].split(",")) {
|
|
6588
|
+
const spec = part.trim().replace(/^type\s+/, "");
|
|
6589
|
+
if (!spec) continue;
|
|
6590
|
+
const [imported, local] = spec.split(/\s+as\s+/).map((x) => x.trim());
|
|
6591
|
+
out.set(local ?? imported, `${where2(m[2])}#${imported}`);
|
|
6592
|
+
}
|
|
6593
|
+
}
|
|
6594
|
+
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])}#*`);
|
|
6595
|
+
return out;
|
|
6596
|
+
}
|
|
6597
|
+
var SCRIPT_EXTS7 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
|
|
6140
6598
|
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;
|
|
6141
6599
|
var REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
|
|
6142
6600
|
function specifierParts(spec) {
|
|
@@ -6226,7 +6684,7 @@ function checkStabilityImports(ctx) {
|
|
|
6226
6684
|
return cache2.get(pkg);
|
|
6227
6685
|
};
|
|
6228
6686
|
for (const file of ctx.files) {
|
|
6229
|
-
if (!
|
|
6687
|
+
if (!SCRIPT_EXTS7.has(file.ext)) continue;
|
|
6230
6688
|
for (const { pkg, specifier, names, line } of genesisNamedImports(file.code)) {
|
|
6231
6689
|
const tags = tagsOf(pkg);
|
|
6232
6690
|
if (!tags) continue;
|
|
@@ -6559,7 +7017,7 @@ function sourceSchemas(source) {
|
|
|
6559
7017
|
return schemas?.length ? schemas : null;
|
|
6560
7018
|
}
|
|
6561
7019
|
var lf = (text) => text.replace(/\r\n/g, "\n");
|
|
6562
|
-
async function checkContracts(ctx,
|
|
7020
|
+
async function checkContracts(ctx, read3 = postgresContract) {
|
|
6563
7021
|
const settings = ctx.config.contracts;
|
|
6564
7022
|
if (!settings) return;
|
|
6565
7023
|
const out = settings.out ?? DEFAULT_CONTRACT_OUT;
|
|
@@ -6583,7 +7041,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
|
|
|
6583
7041
|
}
|
|
6584
7042
|
let expected;
|
|
6585
7043
|
try {
|
|
6586
|
-
expected = lf((await
|
|
7044
|
+
expected = lf((await read3(url, schemas)).content);
|
|
6587
7045
|
} catch (err) {
|
|
6588
7046
|
const generation = err.name === "EmitError";
|
|
6589
7047
|
const message = err.message.split("\n")[0];
|
|
@@ -6601,7 +7059,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
|
|
|
6601
7059
|
}
|
|
6602
7060
|
}
|
|
6603
7061
|
var GENESIS_DOCS = "https://github.com/marktiderman/genesis/blob/main/docs";
|
|
6604
|
-
var
|
|
7062
|
+
var read2 = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
6605
7063
|
var CLAUDE_IMPORT = "@AGENTS.md\n";
|
|
6606
7064
|
function pathTaken(file) {
|
|
6607
7065
|
try {
|
|
@@ -6754,7 +7212,7 @@ function packageGuides(root, packages) {
|
|
|
6754
7212
|
const guides = [];
|
|
6755
7213
|
for (const p of packages) {
|
|
6756
7214
|
const stable = p.local ? path21.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
|
|
6757
|
-
const text = stable === null ? null :
|
|
7215
|
+
const text = stable === null ? null : read2(stable);
|
|
6758
7216
|
if (stable === null || text === null) continue;
|
|
6759
7217
|
const description = skillDescription(text);
|
|
6760
7218
|
const at = description.indexOf("Load before");
|
|
@@ -6846,11 +7304,11 @@ function writeAgentGuide(root, packages, agentsFile = "AGENTS.md") {
|
|
|
6846
7304
|
const guides = packageGuides(root, packages);
|
|
6847
7305
|
const changed = [];
|
|
6848
7306
|
const agents = path21.join(root, agentsFile);
|
|
6849
|
-
const before =
|
|
7307
|
+
const before = read2(agents);
|
|
6850
7308
|
const after = mergeAgentsBlock(before, renderAgentsBlock(rows, guides));
|
|
6851
7309
|
const skill = path21.join(root, SKILL_PATH);
|
|
6852
7310
|
const skillText = renderSkill(rows, guides);
|
|
6853
|
-
if (
|
|
7311
|
+
if (read2(skill)?.replace(/\r\n/g, "\n") !== skillText) {
|
|
6854
7312
|
mkdirSync(path21.dirname(skill), { recursive: true });
|
|
6855
7313
|
writeFileSync(skill, skillText);
|
|
6856
7314
|
changed.push(SKILL_PATH);
|
|
@@ -6890,8 +7348,8 @@ function claudeState(root) {
|
|
|
6890
7348
|
function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
|
|
6891
7349
|
const rows = primitivesCatalog(packages);
|
|
6892
7350
|
const guides = packageGuides(root, packages);
|
|
6893
|
-
const skill =
|
|
6894
|
-
const block = currentAgentsBlock(
|
|
7351
|
+
const skill = read2(path21.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
|
|
7352
|
+
const block = currentAgentsBlock(read2(path21.join(root, agentsFile)));
|
|
6895
7353
|
return {
|
|
6896
7354
|
skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
|
|
6897
7355
|
agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",
|
|
@@ -7955,6 +8413,7 @@ function builtinChecks(config, options = {}) {
|
|
|
7955
8413
|
{ name: "studio-server-imports", check: checkStudioServerImports },
|
|
7956
8414
|
{ name: "removed-scope-names", check: checkRemovedScopeNames },
|
|
7957
8415
|
{ name: "app-parts", check: checkAppParts },
|
|
8416
|
+
{ name: "client-layer", check: checkClientLayer },
|
|
7958
8417
|
{ name: "stability-imports", check: checkStabilityImports },
|
|
7959
8418
|
{ name: "agent-guide", check: (ctx) => {
|
|
7960
8419
|
checkAgentGuide(ctx);
|