@marktiderman/genesis-cli 1.22.1 → 1.24.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 +45 -2
- package/dist/cli.js +382 -45
- package/dist/cli.js.map +1 -1
- package/dist/{config-HOmiOLQc.d.ts → config-DRHg7V3Z.d.ts} +17 -0
- package/dist/doctor.d.ts +73 -6
- package/dist/doctor.js +309 -12
- package/dist/doctor.js.map +1 -1
- package/dist/expo.d.ts +2 -2
- package/dist/expo.js +20 -0
- package/dist/expo.js.map +1 -1
- package/dist/genesis-catalog.json +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +229 -17
- package/dist/index.js.map +1 -1
- package/dist/starter/.eas/workflows/deploy-production.yml +41 -38
- package/dist/starter/.eas/workflows/rollout.yml +3 -2
- package/dist/starter/README.md +2 -2
- package/dist/templates/ci/claude-review.yml +26 -0
- package/dist/templates/eas/workflows/deploy-production.yml +41 -38
- package/dist/templates/eas/workflows/rollout.yml +3 -2
- package/dist/templates/vercel/ignore-build.sh +131 -0
- package/dist/templates/vercel/vercel.json +4 -0
- package/dist/vite.js +221 -9
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/vite.js
CHANGED
|
@@ -817,6 +817,25 @@ var PRIVACY_PURPOSES = {
|
|
|
817
817
|
"third-party advertising": "NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising",
|
|
818
818
|
other: "NSPrivacyCollectedDataTypePurposeOther"
|
|
819
819
|
};
|
|
820
|
+
var ENVIRONMENT_KEYS = /* @__PURE__ */ new Set(["previews", "label", "branchPrefix", "$comment"]);
|
|
821
|
+
function validateEnvironments(raw, source = "config") {
|
|
822
|
+
const fail = (msg) => {
|
|
823
|
+
throw new GenesisConfigError(`${source}: ${msg}`);
|
|
824
|
+
};
|
|
825
|
+
if (!isObject(raw)) return fail(`"environments" must be an object`);
|
|
826
|
+
for (const key2 of Object.keys(raw)) if (!ENVIRONMENT_KEYS.has(key2)) fail(`environments: unknown setting "${key2}" (known: previews, label, branchPrefix)`);
|
|
827
|
+
const out = {};
|
|
828
|
+
if (raw.previews !== void 0) {
|
|
829
|
+
if (raw.previews !== "on-demand" && raw.previews !== "every-pr" && raw.previews !== "off") fail(`environments.previews must be "on-demand", "every-pr" or "off" (got ${JSON.stringify(raw.previews)})`);
|
|
830
|
+
out.previews = raw.previews;
|
|
831
|
+
}
|
|
832
|
+
for (const key2 of ["label", "branchPrefix"]) {
|
|
833
|
+
if (raw[key2] === void 0) continue;
|
|
834
|
+
if (typeof raw[key2] !== "string") fail(`environments.${key2} must be a string ("" turns that check off)`);
|
|
835
|
+
out[key2] = raw[key2];
|
|
836
|
+
}
|
|
837
|
+
return out;
|
|
838
|
+
}
|
|
820
839
|
var STRING_LISTS = ["src", "extensions", "ignore", "tokenFiles", "ignoreTokenPrefixes", "localPrimitiveDirs", "build", "componentPackages"];
|
|
821
840
|
var STRINGS = ["uiPackage", "rulesDoc"];
|
|
822
841
|
var KNOWN = /* @__PURE__ */ new Set([
|
|
@@ -848,7 +867,7 @@ var CONTRACT_KEYS = /* @__PURE__ */ new Set(["out", "schemas", "databaseEnv"]);
|
|
|
848
867
|
var PACKS = /* @__PURE__ */ new Set(["native", "supabase", "packages"]);
|
|
849
868
|
var PACK_KEYS = {
|
|
850
869
|
native: { routerRoot: "path" },
|
|
851
|
-
supabase: { migrations: "path", base: "string", exposedSchemas: "list", since: "string" },
|
|
870
|
+
supabase: { migrations: "path", base: "string", exposedSchemas: "list", since: "string", automaticBranching: "boolean" },
|
|
852
871
|
packages: { base: "string" }
|
|
853
872
|
};
|
|
854
873
|
function appPath(v, where2, fail) {
|
|
@@ -909,6 +928,7 @@ function readGenesisConfig(root) {
|
|
|
909
928
|
if (supabase !== true) out.supabase = supabase;
|
|
910
929
|
}
|
|
911
930
|
if (raw.appFolder !== void 0) out.appFolder = validateAppFolder(raw.appFolder, file);
|
|
931
|
+
if (raw.environments !== void 0) out.environments = validateEnvironments(raw.environments, file);
|
|
912
932
|
return out;
|
|
913
933
|
}
|
|
914
934
|
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}$/;
|
|
@@ -1107,6 +1127,7 @@ function validateConfig(raw, source = "config") {
|
|
|
1107
1127
|
if (!want) fail(`${pack}: unknown setting "${k}"`);
|
|
1108
1128
|
if (want === "string" && typeof v !== "string") fail(`${pack}.${k} must be a string`);
|
|
1109
1129
|
if (want === "list" && !isStringList(v)) fail(`${pack}.${k} must be a list of strings`);
|
|
1130
|
+
if (want === "boolean" && typeof v !== "boolean") fail(`${pack}.${k} must be true or false`);
|
|
1110
1131
|
if (want === "string" && !v.trim()) fail(`${pack}.${k} must not be empty`);
|
|
1111
1132
|
if (want === "path") block[k] = appPath(v, `${pack}.${k}`, fail);
|
|
1112
1133
|
}
|
|
@@ -1158,7 +1179,7 @@ function globToRegExp(glob) {
|
|
|
1158
1179
|
}
|
|
1159
1180
|
function globMatcher(globs) {
|
|
1160
1181
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
1161
|
-
return (
|
|
1182
|
+
return (path50) => res.some((re) => re.test(path50));
|
|
1162
1183
|
}
|
|
1163
1184
|
var GENESIS_PACKAGE = /^@marktiderman\/genesis(-[a-z0-9-]+)?$/;
|
|
1164
1185
|
var BLOCK_ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
|
|
@@ -2711,6 +2732,7 @@ var BUILTIN_RULES = [
|
|
|
2711
2732
|
"migration-edited",
|
|
2712
2733
|
"migration-testing-kit",
|
|
2713
2734
|
"migration-view-rls",
|
|
2735
|
+
"exposed-schema-created-later",
|
|
2714
2736
|
// packages pack
|
|
2715
2737
|
"package-app-import",
|
|
2716
2738
|
"package-undeclared-dependency",
|
|
@@ -4854,6 +4876,67 @@ function checkSupabasePack(ctx) {
|
|
|
4854
4876
|
checkViewInvoker(ctx, migrations, exposed);
|
|
4855
4877
|
checkDefinerSearchPath(ctx, migrations);
|
|
4856
4878
|
checkTestingKit(ctx, migrations);
|
|
4879
|
+
checkExposedSchemasCreatedLater(ctx, dir, migrations, settings.exposedSchemas, settings.automaticBranching !== false);
|
|
4880
|
+
}
|
|
4881
|
+
var PLATFORM_SCHEMAS = /* @__PURE__ */ new Set(["public", "graphql_public", "graphql", "extensions", "storage", "auth", "realtime", "vault"]);
|
|
4882
|
+
function apiSchemas(toml) {
|
|
4883
|
+
const lines = toml.split("\n");
|
|
4884
|
+
const start = lines.findIndex((l) => /^\s*\[api\]\s*(?:#.*)?$/.test(l));
|
|
4885
|
+
if (start < 0) return null;
|
|
4886
|
+
let end = lines.findIndex((l, i) => i > start && /^\s*\[/.test(l));
|
|
4887
|
+
if (end < 0) end = lines.length;
|
|
4888
|
+
const bare = (l) => {
|
|
4889
|
+
let quoted = false;
|
|
4890
|
+
for (let i = 0; i < l.length; i++) {
|
|
4891
|
+
if (l[i] === '"' && l[i - 1] !== "\\") quoted = !quoted;
|
|
4892
|
+
else if (l[i] === "#" && !quoted) return l.slice(0, i);
|
|
4893
|
+
}
|
|
4894
|
+
return l;
|
|
4895
|
+
};
|
|
4896
|
+
const body = lines.slice(start + 1, end).map(bare);
|
|
4897
|
+
const enabled = !body.some((l) => /^\s*enabled\s*=\s*false\b/.test(l));
|
|
4898
|
+
const at = body.findIndex((l) => /^\s*schemas\s*=/.test(l));
|
|
4899
|
+
if (at < 0) return { enabled, schemas: [], line: start + 1 };
|
|
4900
|
+
let list = "";
|
|
4901
|
+
for (let i = at; i < body.length; i++) {
|
|
4902
|
+
list += `${body[i]}
|
|
4903
|
+
`;
|
|
4904
|
+
if (body[i].includes("]")) break;
|
|
4905
|
+
}
|
|
4906
|
+
const inner = /\[([\s\S]*?)\]/.exec(list)?.[1] ?? "";
|
|
4907
|
+
const schemas = [...inner.matchAll(/"((?:[^"\\]|\\.)*)"|'([^']*)'/g)].map((m) => (m[1] ?? m[2]).trim().toLowerCase()).filter(Boolean);
|
|
4908
|
+
return { enabled, schemas, line: start + at + 2 };
|
|
4909
|
+
}
|
|
4910
|
+
function checkExposedSchemasCreatedLater(ctx, dir, migrations, configured, branching) {
|
|
4911
|
+
const created = /* @__PURE__ */ new Map();
|
|
4912
|
+
for (const { file, statements } of migrations) {
|
|
4913
|
+
for (const { sql, line } of statements) {
|
|
4914
|
+
const m = /^create schema (?:if not exists )?"?([\w$]+)"?/.exec(sql);
|
|
4915
|
+
if (m && m[1] !== "authorization" && !created.has(m[1])) created.set(m[1], { file, line });
|
|
4916
|
+
}
|
|
4917
|
+
}
|
|
4918
|
+
const tomlFile = path21.posix.join(path21.posix.dirname(dir), "config.toml");
|
|
4919
|
+
const tomlText = existsSync(path21.join(ctx.root, tomlFile)) ? readFileSync(path21.join(ctx.root, tomlFile), "utf8") : null;
|
|
4920
|
+
const api2 = tomlText === null ? null : apiSchemas(tomlText);
|
|
4921
|
+
const sources = [];
|
|
4922
|
+
if (api2?.enabled) for (const schema of api2.schemas) sources.push({ schema, file: tomlFile, line: api2.line, where: `${tomlFile} [api] schemas` });
|
|
4923
|
+
for (const schema of api2?.enabled === false ? [] : configured ?? []) {
|
|
4924
|
+
const s = schema.toLowerCase();
|
|
4925
|
+
if (!sources.some((x) => x.schema === s)) sources.push({ schema: s, file: "genesis.config.json", where: "doctor.supabase.exposedSchemas" });
|
|
4926
|
+
}
|
|
4927
|
+
for (const { schema, file, line, where: where2 } of sources) {
|
|
4928
|
+
if (PLATFORM_SCHEMAS.has(schema)) continue;
|
|
4929
|
+
const by = created.get(schema);
|
|
4930
|
+
if (by && !branching) continue;
|
|
4931
|
+
ctx.report({
|
|
4932
|
+
rule: "exposed-schema-created-later",
|
|
4933
|
+
level: "warn",
|
|
4934
|
+
file,
|
|
4935
|
+
...line ? { line } : {},
|
|
4936
|
+
subject: schema,
|
|
4937
|
+
message: by ? `${where2} exposes ${schema}, which only a migration creates (${by.file}:${by.line}); a Supabase branch points its Data API at ${schema} before it runs migrations, so a fresh preview branch fails its health check. Turn off Supabase's automatic branching (Genesis docs/APP-CI.md, "Previews"), then set doctor.supabase.automaticBranching to false` : `${where2} exposes ${schema}, which no migration creates, so a database built from the migrations can't serve it (a Supabase branch fails its health check); create it in a migration or stop exposing it`
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4857
4940
|
}
|
|
4858
4941
|
function checkTestingKit(ctx, migrations) {
|
|
4859
4942
|
for (const { file, statements } of migrations) {
|
|
@@ -6104,6 +6187,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
|
|
|
6104
6187
|
}
|
|
6105
6188
|
}
|
|
6106
6189
|
var GENESIS_DOCS = "https://github.com/marktiderman/genesis/blob/main/docs";
|
|
6190
|
+
var read = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
6107
6191
|
var CORE = [
|
|
6108
6192
|
{
|
|
6109
6193
|
need: "anything, before building it",
|
|
@@ -6176,14 +6260,79 @@ var SKILL_PATH = ".claude/skills/genesis/SKILL.md";
|
|
|
6176
6260
|
var AGENTS_START = "<!-- genesis-primitives:start -->";
|
|
6177
6261
|
var AGENTS_END = "<!-- genesis-primitives:end -->";
|
|
6178
6262
|
var RULES = [
|
|
6179
|
-
|
|
6263
|
+
`Use the Genesis primitive for the need first: reuse, then extend, then invent (G1 to G6 in ${GENESIS_DOCS}/FRAMEWORK.md).`,
|
|
6180
6264
|
"Never copy an older screen as a template. Old screens predate the primitives; the doctor flags what they did.",
|
|
6181
6265
|
"A list screen is a view (`defineView`) rendered by `ResourceView`; a record view is `RecordView`; on the phone, `NativeResourceView`.",
|
|
6182
6266
|
"Screens never call the database client (`supabase.from`, `.rpc`) directly: reads go through a view or a named data function, writes through the resource's provider rules.",
|
|
6183
6267
|
"When no primitive fits, write the gap up for Genesis before inventing, then invent in the app on Genesis primitives.",
|
|
6184
6268
|
"Run `genesis doctor` before you finish; it enforces these rules."
|
|
6185
6269
|
];
|
|
6186
|
-
function
|
|
6270
|
+
function skillDescription(text) {
|
|
6271
|
+
const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1];
|
|
6272
|
+
if (!fm) return "";
|
|
6273
|
+
const lines = fm.split(/\r?\n/);
|
|
6274
|
+
const i = lines.findIndex((l) => /^description:/.test(l));
|
|
6275
|
+
if (i < 0) return "";
|
|
6276
|
+
const first = lines[i].replace(/^description:\s*/, "").trim();
|
|
6277
|
+
if (first && !/^[>|][+-]?$/.test(first)) return first.replace(/^["']|["']$/g, "");
|
|
6278
|
+
const more = [];
|
|
6279
|
+
for (const l of lines.slice(i + 1)) {
|
|
6280
|
+
if (!/^\s+\S/.test(l)) break;
|
|
6281
|
+
more.push(l.trim());
|
|
6282
|
+
}
|
|
6283
|
+
return more.join(" ");
|
|
6284
|
+
}
|
|
6285
|
+
var GUIDE_SEARCH_LEVELS = 4;
|
|
6286
|
+
function stableGuidePath(root, p) {
|
|
6287
|
+
const real2 = (f) => {
|
|
6288
|
+
try {
|
|
6289
|
+
return realpathSync(f);
|
|
6290
|
+
} catch {
|
|
6291
|
+
return null;
|
|
6292
|
+
}
|
|
6293
|
+
};
|
|
6294
|
+
const want = real2(p.dir);
|
|
6295
|
+
for (let dir = root, level = 0; level <= GUIDE_SEARCH_LEVELS; level++) {
|
|
6296
|
+
const found = path21.join(dir, "node_modules", p.name);
|
|
6297
|
+
if (existsSync(found)) {
|
|
6298
|
+
const file = path21.join(found, "SKILL.md");
|
|
6299
|
+
return want !== null && real2(found) === want && existsSync(file) ? file : null;
|
|
6300
|
+
}
|
|
6301
|
+
if (existsSync(path21.join(dir, ".git")) || existsSync(path21.join(dir, "pnpm-workspace.yaml"))) return null;
|
|
6302
|
+
const up = path21.dirname(dir);
|
|
6303
|
+
if (up === dir) return null;
|
|
6304
|
+
dir = up;
|
|
6305
|
+
}
|
|
6306
|
+
return null;
|
|
6307
|
+
}
|
|
6308
|
+
function packageGuides(root, packages) {
|
|
6309
|
+
const guides = [];
|
|
6310
|
+
for (const p of packages) {
|
|
6311
|
+
const stable = p.local ? path21.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
|
|
6312
|
+
const text = stable === null ? null : read(stable);
|
|
6313
|
+
if (stable === null || text === null) continue;
|
|
6314
|
+
const description = skillDescription(text);
|
|
6315
|
+
const at = description.indexOf("Load before");
|
|
6316
|
+
guides.push({ package: p.name, path: path21.relative(root, stable).split(path21.sep).join("/"), when: at >= 0 ? description.slice(at) : description });
|
|
6317
|
+
}
|
|
6318
|
+
return guides.sort((a, b) => a.package.localeCompare(b.package));
|
|
6319
|
+
}
|
|
6320
|
+
function unlistedGuides(root, packages) {
|
|
6321
|
+
const listed = new Set(packageGuides(root, packages).map((g) => g.package));
|
|
6322
|
+
return packages.filter((p) => !p.local && !listed.has(p.name) && existsSync(path21.join(p.dir, "SKILL.md"))).map((p) => p.name).sort();
|
|
6323
|
+
}
|
|
6324
|
+
function guidesSection(guides) {
|
|
6325
|
+
if (!guides.length) return [];
|
|
6326
|
+
return [
|
|
6327
|
+
"### Package guides (they match the installed versions)",
|
|
6328
|
+
"",
|
|
6329
|
+
"Before using a package's primitives, read its guide:",
|
|
6330
|
+
"",
|
|
6331
|
+
...guides.map((g) => `- \`${g.path}\` (${g.package}): ${g.when}`),
|
|
6332
|
+
""
|
|
6333
|
+
];
|
|
6334
|
+
}
|
|
6335
|
+
function renderSkill(rows, guides = []) {
|
|
6187
6336
|
return [
|
|
6188
6337
|
"---",
|
|
6189
6338
|
"name: genesis",
|
|
@@ -6196,6 +6345,7 @@ function renderSkill(rows) {
|
|
|
6196
6345
|
"",
|
|
6197
6346
|
...RULES.map((r) => `- ${r}`),
|
|
6198
6347
|
"",
|
|
6348
|
+
...guidesSection(guides),
|
|
6199
6349
|
"## What to use for each need",
|
|
6200
6350
|
"",
|
|
6201
6351
|
catalogTable(rows, { docs: true }),
|
|
@@ -6204,7 +6354,7 @@ function renderSkill(rows) {
|
|
|
6204
6354
|
""
|
|
6205
6355
|
].join("\n");
|
|
6206
6356
|
}
|
|
6207
|
-
function renderAgentsBlock(rows) {
|
|
6357
|
+
function renderAgentsBlock(rows, guides = []) {
|
|
6208
6358
|
return [
|
|
6209
6359
|
AGENTS_START,
|
|
6210
6360
|
"## Building with Genesis",
|
|
@@ -6215,6 +6365,7 @@ function renderAgentsBlock(rows) {
|
|
|
6215
6365
|
"",
|
|
6216
6366
|
...RULES.map((r) => `- ${r}`),
|
|
6217
6367
|
"",
|
|
6368
|
+
...guidesSection(guides),
|
|
6218
6369
|
catalogTable(rows),
|
|
6219
6370
|
AGENTS_END
|
|
6220
6371
|
].join("\n");
|
|
@@ -6233,14 +6384,37 @@ function currentAgentsBlock(agents) {
|
|
|
6233
6384
|
if (span === "broken") return "broken";
|
|
6234
6385
|
return agents.slice(span.start, span.end).replace(/\r\n/g, "\n");
|
|
6235
6386
|
}
|
|
6236
|
-
|
|
6387
|
+
function claudeState(root) {
|
|
6388
|
+
const file = path21.join(root, "CLAUDE.md");
|
|
6389
|
+
let names = [];
|
|
6390
|
+
try {
|
|
6391
|
+
names = readdirSync(root);
|
|
6392
|
+
} catch {
|
|
6393
|
+
}
|
|
6394
|
+
if (!names.includes("CLAUDE.md")) return names.some((n) => n.toLowerCase() === "claude.md") ? "blocked" : "missing";
|
|
6395
|
+
let text;
|
|
6396
|
+
try {
|
|
6397
|
+
text = readFileSync(file, "utf8");
|
|
6398
|
+
} catch {
|
|
6399
|
+
return "blocked";
|
|
6400
|
+
}
|
|
6401
|
+
if (/^@AGENTS\.md\b/m.test(text)) return "ok";
|
|
6402
|
+
try {
|
|
6403
|
+
if (realpathSync(file) === realpathSync(path21.join(root, "AGENTS.md"))) return "ok";
|
|
6404
|
+
} catch {
|
|
6405
|
+
}
|
|
6406
|
+
return "no-import";
|
|
6407
|
+
}
|
|
6237
6408
|
function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
|
|
6238
6409
|
const rows = primitivesCatalog(packages);
|
|
6410
|
+
const guides = packageGuides(root, packages);
|
|
6239
6411
|
const skill = read(path21.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
|
|
6240
6412
|
const block = currentAgentsBlock(read(path21.join(root, agentsFile)));
|
|
6241
6413
|
return {
|
|
6242
|
-
skill: skill === null ? "missing" : skill === renderSkill(rows) ? "ok" : "stale",
|
|
6243
|
-
agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows) ? "ok" : "stale"
|
|
6414
|
+
skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
|
|
6415
|
+
agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",
|
|
6416
|
+
// Only the default AGENTS.md gets a CLAUDE.md written for it, so only then is a missing one reported.
|
|
6417
|
+
claude: agentsFile !== "AGENTS.md" ? "ok" : claudeState(root)
|
|
6244
6418
|
};
|
|
6245
6419
|
}
|
|
6246
6420
|
function checkAgentGuide(ctx) {
|
|
@@ -6258,6 +6432,41 @@ function checkAgentGuide(ctx) {
|
|
|
6258
6432
|
}[state.agents];
|
|
6259
6433
|
ctx.report({ rule: "agent-guide-stale", level: "warn", file: "AGENTS.md", message });
|
|
6260
6434
|
}
|
|
6435
|
+
if (state.claude === "no-import") {
|
|
6436
|
+
ctx.report({ rule: "agent-guide-stale", level: "info", file: "CLAUDE.md", message: "doesn't import AGENTS.md (`@AGENTS.md`), so reviewers and cloud project threads that read only CLAUDE.md don't see the Genesis guide" });
|
|
6437
|
+
}
|
|
6438
|
+
if (state.claude === "missing") {
|
|
6439
|
+
ctx.report({ rule: "agent-guide-stale", level: "warn", file: "CLAUDE.md", message: `is missing, so reviewers and cloud project threads that read only CLAUDE.md never see AGENTS.md; ${fix} (it writes \`@AGENTS.md\`)` });
|
|
6440
|
+
}
|
|
6441
|
+
if (state.claude === "blocked") {
|
|
6442
|
+
ctx.report({ rule: "agent-guide-stale", level: "warn", file: "CLAUDE.md", message: `can't be read: something else is in its place (another case of the name such as claude.md, a dangling link, a folder or an unreadable file), and genesis agents won't write over it; ${BLOCKED_FIX}` });
|
|
6443
|
+
}
|
|
6444
|
+
const unlisted = unlistedGuides(ctx.root, ctx.packages);
|
|
6445
|
+
if (unlisted.length) {
|
|
6446
|
+
ctx.report({ rule: "agent-guide-stale", level: "info", file: "AGENTS.md", message: `leaves out the guide of ${unlisted.join(", ")}: it's only inside pnpm's store, under a path that changes with unrelated bumps. Add the package as a direct dependency to list its guide.` });
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
var BLOCKED_FIX = "rename or replace it with a CLAUDE.md file (or remove the dangling link), then run genesis agents";
|
|
6450
|
+
var SETTINGS_PATH = ".claude/settings.json";
|
|
6451
|
+
var SUBAGENT_HOOK_COMMAND = '"$CLAUDE_PROJECT_DIR"/node_modules/.bin/genesis agents --hook subagent-start --dir "$CLAUDE_PROJECT_DIR" 2>/dev/null || true';
|
|
6452
|
+
var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
6453
|
+
var isGenesisHook = (h) => typeof h.command === "string" && h.command.includes("genesis agents --hook");
|
|
6454
|
+
function agentHooksState(root) {
|
|
6455
|
+
let settings;
|
|
6456
|
+
try {
|
|
6457
|
+
settings = JSON.parse(readFileSync(path21.join(root, SETTINGS_PATH), "utf8"));
|
|
6458
|
+
} catch {
|
|
6459
|
+
return "none";
|
|
6460
|
+
}
|
|
6461
|
+
const start = isObject4(settings) && isObject4(settings.hooks) ? settings.hooks["SubagentStart"] : void 0;
|
|
6462
|
+
const commands = (Array.isArray(start) ? start : []).flatMap((e) => isObject4(e) && Array.isArray(e.hooks) ? e.hooks : []).filter((h) => isObject4(h) && isGenesisHook(h)).map((h) => h.command);
|
|
6463
|
+
if (!commands.length) return "none";
|
|
6464
|
+
return commands.every((c) => c === SUBAGENT_HOOK_COMMAND) ? "ok" : "stale";
|
|
6465
|
+
}
|
|
6466
|
+
function checkAgentHooks(ctx) {
|
|
6467
|
+
if (agentHooksState(ctx.root) === "stale") {
|
|
6468
|
+
ctx.report({ rule: "agent-guide-stale", level: "warn", file: SETTINGS_PATH, message: "has an older Genesis SubagentStart hook command; run genesis agents --hooks and commit the result" });
|
|
6469
|
+
}
|
|
6261
6470
|
}
|
|
6262
6471
|
|
|
6263
6472
|
// src/blocks/templates.ts
|
|
@@ -7165,7 +7374,10 @@ function builtinChecks(config, options = {}) {
|
|
|
7165
7374
|
{ name: "studio-server-imports", check: checkStudioServerImports },
|
|
7166
7375
|
{ name: "removed-scope-names", check: checkRemovedScopeNames },
|
|
7167
7376
|
{ name: "stability-imports", check: checkStabilityImports },
|
|
7168
|
-
{ name: "agent-guide", check:
|
|
7377
|
+
{ name: "agent-guide", check: (ctx) => {
|
|
7378
|
+
checkAgentGuide(ctx);
|
|
7379
|
+
checkAgentHooks(ctx);
|
|
7380
|
+
} },
|
|
7169
7381
|
{ name: "overlays", check: (ctx) => checkOverlays(ctx) },
|
|
7170
7382
|
{ name: "lock-files", check: checkLockFiles },
|
|
7171
7383
|
{ name: "database-elsewhere", check: checkDatabaseHome },
|