@marktiderman/genesis-features 0.0.0-stage → 0.1.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/dist/node.js ADDED
@@ -0,0 +1,337 @@
1
+ import { BrokenBlockError, expiredFlags, toAgentsMarkdown, readAgentsBlock, replaceAgentsBlock, toJson, toOpenFeatureManifest, toSkillMarkdown, toMarketingMarkdown, readBlock, MARKETING_BLOCK_START, MARKETING_BLOCK_END, replaceBlock } from './chunk-YKNISEPJ.js';
2
+ import { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync } from 'fs';
3
+ import { join, dirname } from 'path';
4
+
5
+ var CODE = "{ts,tsx,js,jsx,mjs,cjs}";
6
+ var DEFAULT_SCAN = [`src/**/*.${CODE}`, `app/**/*.${CODE}`, `packages/*/src/**/*.${CODE}`];
7
+ var DEFAULT_TESTS = [`**/*.{test,spec}.${CODE}`, "**/__tests__/**/*", "supabase/tests/**/*.sql"];
8
+ var DEFAULT_COVERAGE = [`src/routes/**/*.${CODE}`, `app/routes/**/*.${CODE}`, "**/*.functions.ts"];
9
+ var DEFAULT_COVERAGE_IGNORE = ["**/routeTree.gen.ts", "**/__root.tsx", "**/*.d.ts"];
10
+ var DEFAULT_ACCESSORS = ["useFlag", "getFlag", "<Flag name>"];
11
+ var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage", "out", "storybook-static"]);
12
+ function read(file) {
13
+ return existsSync(file) ? readFileSync(file, "utf8").replace(/\r\n/g, "\n") : null;
14
+ }
15
+ function globToRegExp(glob) {
16
+ let out = "";
17
+ for (let i = 0; i < glob.length; i++) {
18
+ const c = glob[i];
19
+ if (c === "*" && glob[i + 1] === "*") {
20
+ const slash = glob[i + 2] === "/";
21
+ out += slash ? "(?:.*/)?" : ".*";
22
+ i += slash ? 2 : 1;
23
+ } else if (c === "*") out += "[^/]*";
24
+ else if (c === "?") out += "[^/]";
25
+ else if (c === "{") {
26
+ const close = glob.indexOf("}", i);
27
+ out += `(?:${glob.slice(i + 1, close).split(",").map((s) => s.replace(/[.+^$()|[\]\\]/g, "\\$&")).join("|")})`;
28
+ i = close;
29
+ } else out += c.replace(/[.+^$()|[\]\\]/g, "\\$&");
30
+ }
31
+ return new RegExp(`^${out}$`);
32
+ }
33
+ function listFiles(root) {
34
+ const out = [];
35
+ const walk = (rel) => {
36
+ let entries;
37
+ try {
38
+ entries = readdirSync(join(root, rel), { withFileTypes: true });
39
+ } catch {
40
+ return;
41
+ }
42
+ for (const entry of entries) {
43
+ const path = rel ? `${rel}/${entry.name}` : entry.name;
44
+ if (entry.isDirectory()) {
45
+ if (!entry.name.startsWith(".") && !SKIP_DIRS.has(entry.name)) walk(path);
46
+ } else if (entry.isFile()) out.push(path);
47
+ }
48
+ };
49
+ walk("");
50
+ return out;
51
+ }
52
+ function matcher(globs) {
53
+ const res = globs.map(globToRegExp);
54
+ return (path) => res.some((re) => re.test(path));
55
+ }
56
+ var at = (path, text, index) => `${path}:${text.slice(0, index).split("\n").length}`;
57
+ function literalAt(text, i) {
58
+ const quote = text[i];
59
+ if (quote !== '"' && quote !== "'" && quote !== "`") return null;
60
+ const end = text.indexOf(quote, i + 1);
61
+ if (end === -1) return null;
62
+ const value = text.slice(i + 1, end);
63
+ if (quote === "`" && value.includes("${")) return null;
64
+ return value;
65
+ }
66
+ function scanFlagReads(path, text, accessors = DEFAULT_ACCESSORS) {
67
+ const keys = [];
68
+ const dynamic = [];
69
+ for (const accessor of accessors) {
70
+ const jsx = /^<(\w[\w.]*)\s+(\w+)>$/.exec(accessor);
71
+ if (jsx) {
72
+ const re2 = new RegExp(`<${jsx[1].replace(/\./g, "\\.")}\\b[^>]*?\\b${jsx[2]}\\s*=\\s*`, "g");
73
+ for (const m of text.matchAll(re2)) {
74
+ let i = m.index + m[0].length;
75
+ if (text[i] === "{") i = text.slice(i + 1).search(/\S/) + i + 1;
76
+ const key = literalAt(text, i);
77
+ if (key === null) dynamic.push(at(path, text, m.index));
78
+ else keys.push({ key, where: at(path, text, m.index) });
79
+ }
80
+ continue;
81
+ }
82
+ const re = new RegExp(`(?<![\\w$.])(function\\s+)?${accessor.replace(/\$/g, "\\$")}\\s*(?:<[^>()]*>)?\\s*\\(\\s*`, "g");
83
+ for (const m of text.matchAll(re)) {
84
+ if (m[1]) continue;
85
+ const i = m.index + m[0].length;
86
+ if (text[i] === ")") continue;
87
+ const key = literalAt(text, i);
88
+ if (key !== null) keys.push({ key, where: at(path, text, m.index) });
89
+ else if (!/^[\w$]+\??\s*:/.test(text.slice(i))) dynamic.push(at(path, text, m.index));
90
+ }
91
+ }
92
+ return { keys, dynamic };
93
+ }
94
+ var ids = (features) => new Set(Object.entries(features).flatMap(([id, f]) => [id, ...f.aliases ?? []]));
95
+ function removedIds(options) {
96
+ const json = options.json === void 0 ? "features.json" : options.json;
97
+ if (!json) return [];
98
+ const doc = read(join(options.root, json));
99
+ if (!doc) return [];
100
+ let previous;
101
+ try {
102
+ previous = JSON.parse(doc).features?.flatMap((f) => [f.id, ...f.aliases ?? []]) ?? [];
103
+ } catch {
104
+ return [];
105
+ }
106
+ const now = ids(options.features);
107
+ return previous.filter((id) => !now.has(id));
108
+ }
109
+ var canonical = (features) => new Map(Object.entries(features).flatMap(([id, f]) => [id, ...f.aliases ?? []].map((name) => [name, id])));
110
+ var and = (items) => items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
111
+ var removedMessage = (id) => `the feature id "${id}" was removed. Ids are permanent: keep the entry with status "retired", or list "${id}" in the new entry's aliases`;
112
+ function outputs(options) {
113
+ const { features, flags, source, command } = options;
114
+ const agents = options.agents === void 0 ? "AGENTS.md" : options.agents;
115
+ const json = options.json === void 0 ? "features.json" : options.json;
116
+ const openfeature = options.openfeature === void 0 ? "flags.json" : options.openfeature;
117
+ const skill = options.skill === void 0 ? ".claude/skills/features/SKILL.md" : options.skill;
118
+ const whole = (content) => ({ next: () => content, same: (current, next) => current === next });
119
+ const list = [];
120
+ if (agents) {
121
+ const block = toAgentsMarkdown(features, flags, { source, command, skill });
122
+ list.push({
123
+ path: agents,
124
+ next: (current) => replaceAgentsBlock(current ?? "", block),
125
+ same: (current) => current !== null && readAgentsBlock(current) === block
126
+ });
127
+ }
128
+ if (json) list.push({ path: json, ...whole(toJson(features, flags, { source })) });
129
+ if (openfeature && flags && Object.keys(flags).length) list.push({ path: openfeature, ...whole(toOpenFeatureManifest(flags, features)) });
130
+ if (skill) list.push({ path: skill, ...whole(toSkillMarkdown({ source, command })) });
131
+ if (options.marketing) {
132
+ const block = toMarketingMarkdown(features, { heading: options.marketingHeading, source });
133
+ list.push({
134
+ path: options.marketing,
135
+ next: (current) => replaceBlock(current ?? "", block, MARKETING_BLOCK_START, MARKETING_BLOCK_END),
136
+ same: (current) => current !== null && readBlock(current, MARKETING_BLOCK_START, MARKETING_BLOCK_END) === block
137
+ });
138
+ }
139
+ return list;
140
+ }
141
+ function claudeImport(options) {
142
+ const agents = options.agents === void 0 ? "AGENTS.md" : options.agents;
143
+ const claude = options.claude === void 0 ? "CLAUDE.md" : options.claude;
144
+ return agents && claude ? { path: claude, line: `@${agents}` } : null;
145
+ }
146
+ var hasImport = (doc, line) => doc !== null && new RegExp(`^${line.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`, "m").test(doc);
147
+ function buildFeatureOutputs(options) {
148
+ const removed = removedIds(options);
149
+ if (removed.length) throw new Error(removed.map(removedMessage).join("\n"));
150
+ const changed = [];
151
+ const write = (rel, next) => {
152
+ const file = join(options.root, rel);
153
+ mkdirSync(dirname(file), { recursive: true });
154
+ writeFileSync(file, next);
155
+ changed.push(rel);
156
+ };
157
+ for (const output of outputs(options)) {
158
+ const current = read(join(options.root, output.path));
159
+ let next;
160
+ try {
161
+ next = output.next(current);
162
+ } catch (error) {
163
+ if (error instanceof BrokenBlockError) throw new Error(`${output.path}: ${error.message}`);
164
+ throw error;
165
+ }
166
+ if (!output.same(current, next)) write(output.path, next);
167
+ }
168
+ const claude = claudeImport(options);
169
+ if (claude) {
170
+ const current = read(join(options.root, claude.path));
171
+ if (!hasImport(current, claude.line)) {
172
+ const base = current === null || current === "" ? "" : current.endsWith("\n") ? `${current}
173
+ ` : `${current}
174
+
175
+ `;
176
+ write(claude.path, `${base}${claude.line}
177
+ `);
178
+ }
179
+ }
180
+ return changed;
181
+ }
182
+ function checkFeatureOutputs(options) {
183
+ const { root, features, flags } = options;
184
+ const today = options.today ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
185
+ const errors = [];
186
+ const warnings = [];
187
+ const stale = [];
188
+ const known = ids(features);
189
+ for (const output of outputs(options)) {
190
+ const current = read(join(root, output.path));
191
+ let same;
192
+ try {
193
+ same = output.same(current, output.next(current));
194
+ } catch (error) {
195
+ if (!(error instanceof BrokenBlockError)) throw error;
196
+ errors.push(`${output.path}: ${error.message}`);
197
+ continue;
198
+ }
199
+ if (!same) {
200
+ stale.push(output.path);
201
+ errors.push(`${output.path} is stale. Run \`${options.command ?? "genesis features"} build\` and commit the result.`);
202
+ }
203
+ }
204
+ const claude = claudeImport(options);
205
+ if (claude && !hasImport(read(join(root, claude.path)), claude.line)) {
206
+ errors.push(`${claude.path} must import the agent notes with a line \`${claude.line}\` (\`build\` adds it).`);
207
+ }
208
+ for (const id of removedIds(options)) errors.push(removedMessage(id));
209
+ const reviewCutoff = new Date(Date.parse(today) - (options.reviewDays ?? 90) * 864e5).toISOString().slice(0, 10);
210
+ const claims = [];
211
+ for (const [id, def] of Object.entries(features)) {
212
+ for (const path of def.links?.code ?? []) {
213
+ if (!existsSync(join(root, path))) errors.push(`${id}.links.code: ${path} doesn't exist`);
214
+ }
215
+ for (const path of def.links?.docs ?? []) {
216
+ if (!/^https?:\/\//.test(path) && !existsSync(join(root, path))) warnings.push(`${id}.links.docs: ${path} doesn't exist`);
217
+ }
218
+ if (def.claimedBy) claims.push([id, def.claimedBy]);
219
+ if (def.status !== "planned" && def.status !== "retired") {
220
+ if (!def.reviewedAt) warnings.push(`${id}: never reviewed (set reviewedAt)`);
221
+ else if (def.reviewedAt < reviewCutoff) warnings.push(`${id}: last reviewed ${def.reviewedAt}, over ${options.reviewDays ?? 90} days ago`);
222
+ }
223
+ }
224
+ const files = listFiles(root);
225
+ const expired = expiredFlags(flags, today);
226
+ if (flags) {
227
+ for (const [name, flag] of Object.entries(flags)) {
228
+ if (flag.kind === "permission") errors.push(`${name}: a permission flag. Paid or role access belongs in the feature's \`access\` (entitlements), not a flag`);
229
+ if (flag.runbook && !/^https?:\/\//.test(flag.runbook) && !existsSync(join(root, flag.runbook))) {
230
+ errors.push(`${name}.runbook: ${flag.runbook} doesn't exist`);
231
+ }
232
+ }
233
+ for (const name of expired) errors.push(`${name} expired on ${flags[name].expires}: remove its code path, then the flag`);
234
+ if (options.scan !== false) {
235
+ const inScan = matcher(options.scan ?? DEFAULT_SCAN);
236
+ const used = /* @__PURE__ */ new Map();
237
+ for (const path of files.filter((p) => inScan(p) && !p.endsWith(".d.ts"))) {
238
+ const { keys, dynamic } = scanFlagReads(path, readFileSync(join(root, path), "utf8"), options.flagAccessors ?? DEFAULT_ACCESSORS);
239
+ for (const where of dynamic) errors.push(`${where}: a flag read with a computed key. Use a literal key, so the read can be checked`);
240
+ for (const { key, where } of keys) {
241
+ if (!Object.hasOwn(flags, key)) errors.push(`${where}: the flag "${key}" is read but not defined`);
242
+ if (!used.has(key)) used.set(key, where);
243
+ }
244
+ }
245
+ for (const name of Object.keys(flags)) {
246
+ if (!used.has(name)) errors.push(`${name}: defined but never read. Remove it, or read it through the flag accessor`);
247
+ }
248
+ }
249
+ }
250
+ const tagged = /* @__PURE__ */ new Set();
251
+ if (options.tests !== false) {
252
+ const inTests = matcher(options.tests ?? DEFAULT_TESTS);
253
+ for (const path of files.filter(inTests)) {
254
+ const text = readFileSync(join(root, path), "utf8");
255
+ for (const m of text.matchAll(/@feat:([a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*)/g)) {
256
+ if (!known.has(m[1])) errors.push(`${at(path, text, m.index)}: @feat:${m[1]} is not a feature`);
257
+ else tagged.add(m[1]);
258
+ }
259
+ }
260
+ for (const [id, def] of Object.entries(features)) {
261
+ const names = [id, ...def.aliases ?? []];
262
+ if (def.status === "live" && !names.some((n) => tagged.has(n))) warnings.push(`${id}: live, but no test is tagged @feat:${id}`);
263
+ }
264
+ }
265
+ const idOf = canonical(features);
266
+ const shippedIn = /* @__PURE__ */ new Map();
267
+ const shipped = (name) => {
268
+ const id = idOf.get(name);
269
+ if (!shippedIn.has(id)) shippedIn.set(id, { changesets: [], prs: [] });
270
+ return shippedIn.get(id);
271
+ };
272
+ const changesets = options.changesets === void 0 ? ".changeset" : options.changesets;
273
+ if (changesets) {
274
+ for (const path of listChangesets(root, changesets)) {
275
+ const text = read(join(root, path)).replace(/^---\n[\s\S]*?\n---\n/, "");
276
+ for (const m of text.matchAll(/^features:[ \t]*\[?([^\]\n]*)\]?[ \t]*$/gim)) {
277
+ for (const id of m[1].split(/[\s,]+/).filter(Boolean)) {
278
+ if (!known.has(id)) errors.push(`${path}: Features: ${id} is not a feature`);
279
+ else if (!shipped(id).changesets.includes(path)) shipped(id).changesets.push(path);
280
+ }
281
+ }
282
+ }
283
+ }
284
+ for (const [name, prs] of Object.entries(options.evidence?.prs ?? {})) {
285
+ if (!known.has(name)) continue;
286
+ const list = shipped(name).prs;
287
+ for (const pr of prs) if (!list.some((p) => p.number === pr.number)) list.push(pr);
288
+ }
289
+ const plannedButShipped = [];
290
+ for (const [id, def] of Object.entries(features)) {
291
+ const found = shippedIn.get(id);
292
+ if (def.status !== "planned" || !found || !found.changesets.length && !found.prs.length) continue;
293
+ const prs = [...found.prs].sort((a, b) => a.number - b.number);
294
+ plannedButShipped.push({ id, changesets: found.changesets, prs });
295
+ warnings.push(`${id} is still planned, but ${and([...found.changesets, ...prs.map((p) => `PR #${p.number}`)])} shipped work for it`);
296
+ }
297
+ for (const label of options.labels ?? []) {
298
+ const id = /^feature:(.+)$/.exec(label.trim())?.[1];
299
+ if (id && !known.has(id)) errors.push(`PR label ${label}: ${id} is not a feature`);
300
+ }
301
+ if (options.coverage !== false) {
302
+ const inCoverage = matcher(options.coverage ?? DEFAULT_COVERAGE);
303
+ const ignored = matcher(options.coverageIgnore ?? DEFAULT_COVERAGE_IGNORE);
304
+ const covered = Object.values(features).flatMap((f) => f.links?.code ?? []).map((p) => p.replace(/\/+$/, ""));
305
+ for (const path of files.filter((p) => inCoverage(p) && !ignored(p))) {
306
+ if (!covered.some((c) => path === c || path.startsWith(`${c}/`))) warnings.push(`${path}: no feature's links.code covers it`);
307
+ }
308
+ }
309
+ return { ok: errors.length === 0, errors, warnings, stale, expiredFlags: expired, claims, plannedButShipped };
310
+ }
311
+ function listChangesets(root, dir) {
312
+ try {
313
+ return readdirSync(join(root, dir)).filter((f) => f.endsWith(".md") && f.toLowerCase() !== "readme.md").map((f) => `${dir}/${f}`);
314
+ } catch {
315
+ return [];
316
+ }
317
+ }
318
+ function summarizeCheck(result, features) {
319
+ const total = Object.keys(features).length;
320
+ const lines = [
321
+ `Features: ${total} in the registry; ${result.errors.length} error${result.errors.length === 1 ? "" : "s"}, ${result.warnings.length} warning${result.warnings.length === 1 ? "" : "s"}.`
322
+ ];
323
+ if (result.stale.length) lines.push(`- Stale generated files: ${result.stale.join(", ")}. Run the features build.`);
324
+ if (result.expiredFlags.length) lines.push(`- Expired flags: ${result.expiredFlags.join(", ")}. Remove the code path, then the flag.`);
325
+ if (result.plannedButShipped.length) {
326
+ const n = result.plannedButShipped.length;
327
+ lines.push(`- ${n} planned feature${n === 1 ? " has" : "s have"} shipped work: ${result.plannedButShipped.map((s) => s.id).join(", ")}. Move ${n === 1 ? "its" : "their"} status on.`);
328
+ }
329
+ if (result.claims.length) lines.push(`- Being built: ${result.claims.map(([id, by]) => `${id} (${by})`).join(", ")}.`);
330
+ const other = result.errors.length - result.stale.length - result.expiredFlags.length;
331
+ if (other > 0) lines.push(`- ${other} other error${other === 1 ? "" : "s"}: run the features check for details.`);
332
+ return lines.join("\n");
333
+ }
334
+
335
+ export { buildFeatureOutputs, checkFeatureOutputs, globToRegExp, scanFlagReads, summarizeCheck };
336
+ //# sourceMappingURL=node.js.map
337
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node.ts"],"names":["re"],"mappings":";;;;AAiHA,IAAM,IAAA,GAAO,yBAAA;AACb,IAAM,YAAA,GAAe,CAAC,CAAA,SAAA,EAAY,IAAI,CAAA,CAAA,EAAI,YAAY,IAAI,CAAA,CAAA,EAAI,CAAA,oBAAA,EAAuB,IAAI,CAAA,CAAE,CAAA;AAC3F,IAAM,gBAAgB,CAAC,CAAA,iBAAA,EAAoB,IAAI,CAAA,CAAA,EAAI,qBAAqB,yBAAyB,CAAA;AACjG,IAAM,gBAAA,GAAmB,CAAC,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,gBAAA,EAAmB,IAAI,IAAI,mBAAmB,CAAA;AACnG,IAAM,uBAAA,GAA0B,CAAC,qBAAA,EAAuB,eAAA,EAAiB,WAAW,CAAA;AACpF,IAAM,iBAAA,GAAoB,CAAC,SAAA,EAAW,SAAA,EAAW,aAAa,CAAA;AAC9D,IAAM,SAAA,mBAAY,IAAI,GAAA,CAAI,CAAC,cAAA,EAAgB,QAAQ,OAAA,EAAS,UAAA,EAAY,KAAA,EAAO,kBAAkB,CAAC,CAAA;AAGlG,SAAS,KAAK,IAAA,EAA6B;AACzC,EAAA,OAAO,UAAA,CAAW,IAAI,CAAA,GAAI,YAAA,CAAa,IAAA,EAAM,MAAM,CAAA,CAAE,OAAA,CAAQ,OAAA,EAAS,IAAI,CAAA,GAAI,IAAA;AAChF;AAGO,SAAS,aAAa,IAAA,EAAsB;AACjD,EAAA,IAAI,GAAA,GAAM,EAAA;AACV,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAA,CAAK,QAAQ,CAAA,EAAA,EAAK;AACpC,IAAA,MAAM,CAAA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{ existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n BrokenBlockError,\n MARKETING_BLOCK_END,\n MARKETING_BLOCK_START,\n readAgentsBlock,\n readBlock,\n replaceAgentsBlock,\n replaceBlock,\n toAgentsMarkdown,\n toJson,\n toMarketingMarkdown,\n toOpenFeatureManifest,\n toSkillMarkdown,\n} from \"./generate\";\nimport { expiredFlags, type Features, type Flags } from \"./model\";\n\n/**\n * Where a repo keeps its registry's outputs and what `check` scans. Every\n * path is relative to `root`; `false` turns an output or a scan off. The CLI\n * reads these from `package.json` → `\"genesisFeatures\"`, and its options win.\n *\n * @stability Beta\n */\nexport interface FeatureProjectOptions {\n /** The repository root. */\n root: string;\n features: Features;\n flags?: Flags;\n /** The registry file, named in generated output. Default `src/features.ts`. */\n source?: string;\n /** How people run the CLI here, named in generated output. Default `genesis features`. */\n command?: string;\n /** The AGENTS.md that holds the pointer block. Default `AGENTS.md`. */\n agents?: string | false;\n /** The CLAUDE.md that must import AGENTS.md (`@AGENTS.md`). Default `CLAUDE.md`. */\n claude?: string | false;\n /** The JSON copy, which is also the record of every id ever used. Default `features.json`. */\n json?: string | false;\n /** The OpenFeature flag manifest, written when there are flags. Default `flags.json`. */\n openfeature?: string | false;\n /** The agent skill. Default `.claude/skills/features/SKILL.md`. */\n skill?: string | false;\n /** A file to keep the marketing block in (e.g. README.md). Default none. */\n marketing?: string | false;\n /** The marketing block's heading. Default `Features`. */\n marketingHeading?: string;\n /**\n * How code reads a flag: a function name (`useFlag`, read as its first\n * argument) or a JSX attribute (`<Flag name>`). Default `useFlag`, `getFlag`\n * and `<Flag name>`.\n */\n flagAccessors?: readonly string[];\n /** Code scanned for flag reads. Default `src`, `app` and `packages/*\\/src`. */\n scan?: readonly string[] | false;\n /** Test files scanned for `@feat:<id>` tags. */\n tests?: readonly string[] | false;\n /** The changesets folder, scanned for `Features: <id>` lines. Default `.changeset`. */\n changesets?: string | false;\n /** The PR's labels, checked for `feature:<id>`. */\n labels?: readonly string[];\n /** Route and server-function files every one of which some `links.code` should cover. */\n coverage?: readonly string[] | false;\n coverageIgnore?: readonly string[];\n /** Warn when `reviewedAt` is older than this many days. Default 90. */\n reviewDays?: number;\n /** `YYYY-MM-DD`. Default today (UTC). */\n today?: string;\n /**\n * Shipped work gathered elsewhere (the CLI's `--prs` reads it with `gh`).\n * A planned feature with any of it gets a warning, as do changesets that\n * name it.\n */\n evidence?: FeatureEvidence;\n}\n\n/** A merged PR labelled `feature:<id>`. @stability Beta */\nexport interface FeaturePrEvidence {\n number: number;\n title: string;\n}\n\n/** @stability Beta */\nexport interface FeatureEvidence {\n /** Merged PRs by the feature id (or alias) on their `feature:<id>` label. */\n prs?: Record<string, readonly FeaturePrEvidence[]>;\n}\n\n/** A feature still marked planned that already has shipped work tagged with it. @stability Beta */\nexport interface PlannedButShipped {\n id: string;\n /** Changeset files with a `Features: <id>` line. */\n changesets: string[];\n prs: FeaturePrEvidence[];\n}\n\n/** @stability Beta */\nexport interface FeatureCheckResult {\n ok: boolean;\n /** Hard failures: stale generated output, missing code paths, flag rules, removed ids, bad tags, no `@AGENTS.md`. */\n errors: string[];\n /** Everything else: reviews due, untested live features, uncovered routes, missing docs. */\n warnings: string[];\n /** Generated files that differ from what the generator makes now. */\n stale: string[];\n expiredFlags: string[];\n /** Building features with someone on them: `[id, claimedBy]`. */\n claims: [string, string][];\n /** Planned features with shipped work; each is also a warning. */\n plannedButShipped: PlannedButShipped[];\n}\n\nconst CODE = \"{ts,tsx,js,jsx,mjs,cjs}\";\nconst DEFAULT_SCAN = [`src/**/*.${CODE}`, `app/**/*.${CODE}`, `packages/*/src/**/*.${CODE}`];\nconst DEFAULT_TESTS = [`**/*.{test,spec}.${CODE}`, \"**/__tests__/**/*\", \"supabase/tests/**/*.sql\"];\nconst DEFAULT_COVERAGE = [`src/routes/**/*.${CODE}`, `app/routes/**/*.${CODE}`, \"**/*.functions.ts\"];\nconst DEFAULT_COVERAGE_IGNORE = [\"**/routeTree.gen.ts\", \"**/__root.tsx\", \"**/*.d.ts\"];\nconst DEFAULT_ACCESSORS = [\"useFlag\", \"getFlag\", \"<Flag name>\"];\nconst SKIP_DIRS = new Set([\"node_modules\", \"dist\", \"build\", \"coverage\", \"out\", \"storybook-static\"]);\n\n/** A file's text with CRLF line endings read as LF, so a Windows checkout isn't \"stale\" forever. */\nfunction read(file: string): string | null {\n return existsSync(file) ? readFileSync(file, \"utf8\").replace(/\\r\\n/g, \"\\n\") : null;\n}\n\n/** A glob (`*`, `**`, `?`, `{a,b}`) as a RegExp over `/`-separated relative paths. */\nexport function globToRegExp(glob: string): RegExp {\n let out = \"\";\n for (let i = 0; i < glob.length; i++) {\n const c = glob[i]!;\n if (c === \"*\" && glob[i + 1] === \"*\") {\n const slash = glob[i + 2] === \"/\";\n out += slash ? \"(?:.*/)?\" : \".*\";\n i += slash ? 2 : 1;\n } else if (c === \"*\") out += \"[^/]*\";\n else if (c === \"?\") out += \"[^/]\";\n else if (c === \"{\") {\n const close = glob.indexOf(\"}\", i);\n out += `(?:${glob.slice(i + 1, close).split(\",\").map((s) => s.replace(/[.+^$()|[\\]\\\\]/g, \"\\\\$&\")).join(\"|\")})`;\n i = close;\n } else out += c.replace(/[.+^$()|[\\]\\\\]/g, \"\\\\$&\");\n }\n return new RegExp(`^${out}$`);\n}\n\n/** Every file under `root`, skipping dot-folders, node_modules and build output. */\nfunction listFiles(root: string): string[] {\n const out: string[] = [];\n const walk = (rel: string) => {\n let entries;\n try {\n entries = readdirSync(join(root, rel), { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n const path = rel ? `${rel}/${entry.name}` : entry.name;\n if (entry.isDirectory()) {\n if (!entry.name.startsWith(\".\") && !SKIP_DIRS.has(entry.name)) walk(path);\n } else if (entry.isFile()) out.push(path);\n }\n };\n walk(\"\");\n return out;\n}\n\nfunction matcher(globs: readonly string[]) {\n const res = globs.map(globToRegExp);\n return (path: string) => res.some((re) => re.test(path));\n}\n\n/** A position in a file, as `path:line`. */\nconst at = (path: string, text: string, index: number) => `${path}:${text.slice(0, index).split(\"\\n\").length}`;\n\n/** The string literal starting at `text[i]`, or null when the expression there isn't one. */\nfunction literalAt(text: string, i: number): string | null {\n const quote = text[i];\n if (quote !== '\"' && quote !== \"'\" && quote !== \"`\") return null;\n const end = text.indexOf(quote, i + 1);\n if (end === -1) return null;\n const value = text.slice(i + 1, end);\n if (quote === \"`\" && value.includes(\"${\")) return null;\n return value;\n}\n\n/**\n * Flag reads in `text`: each key read through an accessor with a literal, and\n * each read whose key isn't a literal (`dynamic`), as `path:line`.\n */\nexport function scanFlagReads(path: string, text: string, accessors: readonly string[] = DEFAULT_ACCESSORS) {\n const keys: { key: string; where: string }[] = [];\n const dynamic: string[] = [];\n for (const accessor of accessors) {\n const jsx = /^<(\\w[\\w.]*)\\s+(\\w+)>$/.exec(accessor);\n if (jsx) {\n const re = new RegExp(`<${jsx[1]!.replace(/\\./g, \"\\\\.\")}\\\\b[^>]*?\\\\b${jsx[2]}\\\\s*=\\\\s*`, \"g\");\n for (const m of text.matchAll(re)) {\n let i = m.index! + m[0].length;\n if (text[i] === \"{\") i = text.slice(i + 1).search(/\\S/) + i + 1;\n const key = literalAt(text, i);\n if (key === null) dynamic.push(at(path, text, m.index!));\n else keys.push({ key, where: at(path, text, m.index!) });\n }\n continue;\n }\n const re = new RegExp(`(?<![\\\\w$.])(function\\\\s+)?${accessor.replace(/\\$/g, \"\\\\$\")}\\\\s*(?:<[^>()]*>)?\\\\s*\\\\(\\\\s*`, \"g\");\n for (const m of text.matchAll(re)) {\n if (m[1]) continue; // its own definition\n const i = m.index! + m[0].length;\n if (text[i] === \")\") continue;\n const key = literalAt(text, i);\n if (key !== null) keys.push({ key, where: at(path, text, m.index!) });\n // `useFlag(key: K)` in a type or a signature declares the accessor; it doesn't read a flag.\n else if (!/^[\\w$]+\\??\\s*:/.test(text.slice(i))) dynamic.push(at(path, text, m.index!));\n }\n }\n return { keys, dynamic };\n}\n\nconst ids = (features: Features) => new Set(Object.entries(features).flatMap(([id, f]) => [id, ...(f.aliases ?? [])]));\n\n/** Ids recorded in the committed JSON that the registry no longer has, as an id or an alias. */\nfunction removedIds(options: FeatureProjectOptions): string[] {\n const json = options.json === undefined ? \"features.json\" : options.json;\n if (!json) return [];\n const doc = read(join(options.root, json));\n if (!doc) return [];\n let previous: string[];\n try {\n previous = (JSON.parse(doc) as { features?: { id: string; aliases?: string[] }[] }).features?.flatMap((f) => [f.id, ...(f.aliases ?? [])]) ?? [];\n } catch {\n return [];\n }\n const now = ids(options.features);\n return previous.filter((id) => !now.has(id));\n}\n\n/** Each id and alias, mapped to its feature's id. */\nconst canonical = (features: Features) =>\n new Map(Object.entries(features).flatMap(([id, f]) => [id, ...(f.aliases ?? [])].map((name) => [name, id] as const)));\n\n/** \"a\", \"a and b\", \"a, b and c\". */\nconst and = (items: string[]) => (items.length < 2 ? items.join(\"\") : `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}`);\n\nconst removedMessage = (id: string) =>\n `the feature id \"${id}\" was removed. Ids are permanent: keep the entry with status \"retired\", or list \"${id}\" in the new entry's aliases`;\n\n/** Every generated file: its path, and its content given what's on disk now. */\nfunction outputs(options: FeatureProjectOptions): { path: string; next: (current: string | null) => string; same: (current: string | null, next: string) => boolean }[] {\n const { features, flags, source, command } = options;\n const agents = options.agents === undefined ? \"AGENTS.md\" : options.agents;\n const json = options.json === undefined ? \"features.json\" : options.json;\n const openfeature = options.openfeature === undefined ? \"flags.json\" : options.openfeature;\n const skill = options.skill === undefined ? \".claude/skills/features/SKILL.md\" : options.skill;\n const whole = (content: string) => ({ next: () => content, same: (current: string | null, next: string) => current === next });\n const list = [];\n if (agents) {\n const block = toAgentsMarkdown(features, flags, { source, command, skill });\n list.push({\n path: agents,\n next: (current: string | null) => replaceAgentsBlock(current ?? \"\", block),\n same: (current: string | null) => current !== null && readAgentsBlock(current) === block,\n });\n }\n if (json) list.push({ path: json, ...whole(toJson(features, flags, { source })) });\n if (openfeature && flags && Object.keys(flags).length) list.push({ path: openfeature, ...whole(toOpenFeatureManifest(flags, features)) });\n if (skill) list.push({ path: skill, ...whole(toSkillMarkdown({ source, command })) });\n if (options.marketing) {\n const block = toMarketingMarkdown(features, { heading: options.marketingHeading, source });\n list.push({\n path: options.marketing,\n next: (current: string | null) => replaceBlock(current ?? \"\", block, MARKETING_BLOCK_START, MARKETING_BLOCK_END),\n same: (current: string | null) => current !== null && readBlock(current, MARKETING_BLOCK_START, MARKETING_BLOCK_END) === block,\n });\n }\n return list;\n}\n\nfunction claudeImport(options: FeatureProjectOptions): { path: string; line: string } | null {\n const agents = options.agents === undefined ? \"AGENTS.md\" : options.agents;\n const claude = options.claude === undefined ? \"CLAUDE.md\" : options.claude;\n return agents && claude ? { path: claude, line: `@${agents}` } : null;\n}\n\nconst hasImport = (doc: string | null, line: string) =>\n doc !== null && new RegExp(`^${line.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\s*$`, \"m\").test(doc);\n\n/**\n * Writes every generated output (the AGENTS.md block, the JSON, the flag\n * manifest, the skill, the marketing block) and adds `@AGENTS.md` to\n * CLAUDE.md when it's missing. Refuses, writing nothing, when an id recorded\n * in the JSON has disappeared. Returns the paths it changed.\n *\n * @stability Beta\n */\nexport function buildFeatureOutputs(options: FeatureProjectOptions): string[] {\n const removed = removedIds(options);\n if (removed.length) throw new Error(removed.map(removedMessage).join(\"\\n\"));\n const changed: string[] = [];\n const write = (rel: string, next: string) => {\n const file = join(options.root, rel);\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, next);\n changed.push(rel);\n };\n for (const output of outputs(options)) {\n const current = read(join(options.root, output.path));\n let next: string;\n try {\n next = output.next(current);\n } catch (error) {\n if (error instanceof BrokenBlockError) throw new Error(`${output.path}: ${error.message}`);\n throw error;\n }\n if (!output.same(current, next)) write(output.path, next);\n }\n const claude = claudeImport(options);\n if (claude) {\n const current = read(join(options.root, claude.path));\n if (!hasImport(current, claude.line)) {\n const base = current === null || current === \"\" ? \"\" : current.endsWith(\"\\n\") ? `${current}\\n` : `${current}\\n\\n`;\n write(claude.path, `${base}${claude.line}\\n`);\n }\n }\n return changed;\n}\n\n/**\n * Checks the registry against the repo. Errors (exit 1): generated output that\n * is stale, `links.code` paths that don't exist, the flag rules (a permission\n * flag, an expired flag, a dynamic key, a key read but not defined or defined\n * but never read, a missing runbook), an id that disappeared, an unknown id in\n * a test, changeset or PR tag, and a CLAUDE.md without `@AGENTS.md`.\n * Warnings: reviews due, live features without tagged tests, planned features\n * with shipped work (changesets, and `evidence.prs`), route and\n * server-function files no feature covers, missing docs.\n *\n * It only ever compares generated output with the generator, never two\n * hand-written files.\n *\n * @stability Beta\n */\nexport function checkFeatureOutputs(options: FeatureProjectOptions): FeatureCheckResult {\n const { root, features, flags } = options;\n const today = options.today ?? new Date().toISOString().slice(0, 10);\n const errors: string[] = [];\n const warnings: string[] = [];\n const stale: string[] = [];\n const known = ids(features);\n\n for (const output of outputs(options)) {\n const current = read(join(root, output.path));\n let same: boolean;\n try {\n same = output.same(current, output.next(current));\n } catch (error) {\n if (!(error instanceof BrokenBlockError)) throw error;\n errors.push(`${output.path}: ${error.message}`);\n continue;\n }\n if (!same) {\n stale.push(output.path);\n errors.push(`${output.path} is stale. Run \\`${options.command ?? \"genesis features\"} build\\` and commit the result.`);\n }\n }\n const claude = claudeImport(options);\n if (claude && !hasImport(read(join(root, claude.path)), claude.line)) {\n errors.push(`${claude.path} must import the agent notes with a line \\`${claude.line}\\` (\\`build\\` adds it).`);\n }\n for (const id of removedIds(options)) errors.push(removedMessage(id));\n\n const reviewCutoff = new Date(Date.parse(today) - (options.reviewDays ?? 90) * 86_400_000).toISOString().slice(0, 10);\n const claims: [string, string][] = [];\n for (const [id, def] of Object.entries(features)) {\n for (const path of def.links?.code ?? []) {\n if (!existsSync(join(root, path))) errors.push(`${id}.links.code: ${path} doesn't exist`);\n }\n for (const path of def.links?.docs ?? []) {\n if (!/^https?:\\/\\//.test(path) && !existsSync(join(root, path))) warnings.push(`${id}.links.docs: ${path} doesn't exist`);\n }\n if (def.claimedBy) claims.push([id, def.claimedBy]);\n if (def.status !== \"planned\" && def.status !== \"retired\") {\n if (!def.reviewedAt) warnings.push(`${id}: never reviewed (set reviewedAt)`);\n else if (def.reviewedAt < reviewCutoff) warnings.push(`${id}: last reviewed ${def.reviewedAt}, over ${options.reviewDays ?? 90} days ago`);\n }\n }\n\n const files = listFiles(root);\n const expired = expiredFlags(flags, today);\n if (flags) {\n for (const [name, flag] of Object.entries(flags)) {\n if (flag.kind === \"permission\") errors.push(`${name}: a permission flag. Paid or role access belongs in the feature's \\`access\\` (entitlements), not a flag`);\n if (flag.runbook && !/^https?:\\/\\//.test(flag.runbook) && !existsSync(join(root, flag.runbook))) {\n errors.push(`${name}.runbook: ${flag.runbook} doesn't exist`);\n }\n }\n for (const name of expired) errors.push(`${name} expired on ${flags[name]!.expires}: remove its code path, then the flag`);\n if (options.scan !== false) {\n const inScan = matcher(options.scan ?? DEFAULT_SCAN);\n const used = new Map<string, string>();\n for (const path of files.filter((p) => inScan(p) && !p.endsWith(\".d.ts\"))) {\n const { keys, dynamic } = scanFlagReads(path, readFileSync(join(root, path), \"utf8\"), options.flagAccessors ?? DEFAULT_ACCESSORS);\n for (const where of dynamic) errors.push(`${where}: a flag read with a computed key. Use a literal key, so the read can be checked`);\n for (const { key, where } of keys) {\n if (!Object.hasOwn(flags, key)) errors.push(`${where}: the flag \"${key}\" is read but not defined`);\n if (!used.has(key)) used.set(key, where);\n }\n }\n for (const name of Object.keys(flags)) {\n if (!used.has(name)) errors.push(`${name}: defined but never read. Remove it, or read it through the flag accessor`);\n }\n }\n }\n\n const tagged = new Set<string>();\n if (options.tests !== false) {\n const inTests = matcher(options.tests ?? DEFAULT_TESTS);\n for (const path of files.filter(inTests)) {\n const text = readFileSync(join(root, path), \"utf8\");\n for (const m of text.matchAll(/@feat:([a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*)/g)) {\n if (!known.has(m[1]!)) errors.push(`${at(path, text, m.index!)}: @feat:${m[1]} is not a feature`);\n else tagged.add(m[1]!);\n }\n }\n for (const [id, def] of Object.entries(features)) {\n const names = [id, ...(def.aliases ?? [])];\n if (def.status === \"live\" && !names.some((n) => tagged.has(n))) warnings.push(`${id}: live, but no test is tagged @feat:${id}`);\n }\n }\n\n const idOf = canonical(features);\n const shippedIn = new Map<string, { changesets: string[]; prs: FeaturePrEvidence[] }>();\n const shipped = (name: string) => {\n const id = idOf.get(name)!;\n if (!shippedIn.has(id)) shippedIn.set(id, { changesets: [], prs: [] });\n return shippedIn.get(id)!;\n };\n const changesets = options.changesets === undefined ? \".changeset\" : options.changesets;\n if (changesets) {\n for (const path of listChangesets(root, changesets)) {\n // The body only, so frontmatter never counts; CRLF read as LF.\n const text = read(join(root, path))!.replace(/^---\\n[\\s\\S]*?\\n---\\n/, \"\");\n for (const m of text.matchAll(/^features:[ \\t]*\\[?([^\\]\\n]*)\\]?[ \\t]*$/gim)) {\n for (const id of m[1]!.split(/[\\s,]+/).filter(Boolean)) {\n if (!known.has(id)) errors.push(`${path}: Features: ${id} is not a feature`);\n else if (!shipped(id).changesets.includes(path)) shipped(id).changesets.push(path);\n }\n }\n }\n }\n for (const [name, prs] of Object.entries(options.evidence?.prs ?? {})) {\n if (!known.has(name)) continue;\n const list = shipped(name).prs;\n for (const pr of prs) if (!list.some((p) => p.number === pr.number)) list.push(pr);\n }\n const plannedButShipped: PlannedButShipped[] = [];\n for (const [id, def] of Object.entries(features)) {\n const found = shippedIn.get(id);\n if (def.status !== \"planned\" || !found || (!found.changesets.length && !found.prs.length)) continue;\n const prs = [...found.prs].sort((a, b) => a.number - b.number);\n plannedButShipped.push({ id, changesets: found.changesets, prs });\n warnings.push(`${id} is still planned, but ${and([...found.changesets, ...prs.map((p) => `PR #${p.number}`)])} shipped work for it`);\n }\n for (const label of options.labels ?? []) {\n const id = /^feature:(.+)$/.exec(label.trim())?.[1];\n if (id && !known.has(id)) errors.push(`PR label ${label}: ${id} is not a feature`);\n }\n\n if (options.coverage !== false) {\n const inCoverage = matcher(options.coverage ?? DEFAULT_COVERAGE);\n const ignored = matcher(options.coverageIgnore ?? DEFAULT_COVERAGE_IGNORE);\n const covered = Object.values(features).flatMap((f) => f.links?.code ?? []).map((p) => p.replace(/\\/+$/, \"\"));\n for (const path of files.filter((p) => inCoverage(p) && !ignored(p))) {\n if (!covered.some((c) => path === c || path.startsWith(`${c}/`))) warnings.push(`${path}: no feature's links.code covers it`);\n }\n }\n\n return { ok: errors.length === 0, errors, warnings, stale, expiredFlags: expired, claims, plannedButShipped };\n}\n\nfunction listChangesets(root: string, dir: string): string[] {\n try {\n return readdirSync(join(root, dir))\n .filter((f) => f.endsWith(\".md\") && f.toLowerCase() !== \"readme.md\")\n .map((f) => `${dir}/${f}`);\n } catch {\n return [];\n }\n}\n\n/**\n * A few lines for a session's start: counts, stale output, expired flags,\n * planned features with shipped work and open claims. Meant for a SessionStart hook (`genesis features check --summary`).\n *\n * @stability Beta\n */\nexport function summarizeCheck(result: FeatureCheckResult, features: Features): string {\n const total = Object.keys(features).length;\n const lines = [\n `Features: ${total} in the registry; ${result.errors.length} error${result.errors.length === 1 ? \"\" : \"s\"}, ${result.warnings.length} warning${result.warnings.length === 1 ? \"\" : \"s\"}.`,\n ];\n if (result.stale.length) lines.push(`- Stale generated files: ${result.stale.join(\", \")}. Run the features build.`);\n if (result.expiredFlags.length) lines.push(`- Expired flags: ${result.expiredFlags.join(\", \")}. Remove the code path, then the flag.`);\n if (result.plannedButShipped.length) {\n const n = result.plannedButShipped.length;\n lines.push(`- ${n} planned feature${n === 1 ? \" has\" : \"s have\"} shipped work: ${result.plannedButShipped.map((s) => s.id).join(\", \")}. Move ${n === 1 ? \"its\" : \"their\"} status on.`);\n }\n if (result.claims.length) lines.push(`- Being built: ${result.claims.map(([id, by]) => `${id} (${by})`).join(\", \")}.`);\n const other = result.errors.length - result.stale.length - result.expiredFlags.length;\n if (other > 0) lines.push(`- ${other} other error${other === 1 ? \"\" : \"s\"}: run the features check for details.`);\n return lines.join(\"\\n\");\n}\n"]}
@@ -0,0 +1,57 @@
1
+ import * as react from 'react';
2
+ import { ResourcePageProps } from '@marktiderman/genesis-ui/data';
3
+ import { F as Features, b as Flags, a as FeatureRecord, m as FeatureStatus } from './model-CW5ocPFw.js';
4
+ import 'zod';
5
+
6
+ /**
7
+ * A feature's status as a badge. `StatusBadge` covers the active states and
8
+ * deprecated; planned and retired have no status there, so they use the
9
+ * secondary and outline `Badge`.
10
+ *
11
+ * @stability Beta
12
+ */
13
+ declare function FeatureStatusBadge({ status }: {
14
+ status: FeatureStatus;
15
+ }): react.JSX.Element;
16
+ /** @stability Beta */
17
+ interface FeatureListProps {
18
+ features: Features;
19
+ /** The repo's flags, so each feature shows its own. */
20
+ flags?: Flags;
21
+ /** Default "Features". */
22
+ title?: string;
23
+ subtitle?: string;
24
+ /**
25
+ * The view before the user picks one: `"table"` (default) or `"board"`. The
26
+ * page's grid view is the board, grouped by status.
27
+ */
28
+ defaultView?: "table" | "board";
29
+ /** Persist the user's view, page size and density under this key. */
30
+ viewSettingsKey?: string;
31
+ /** A link for a repo path in `links.code` / `links.docs`, e.g. to GitHub. Default: shown as text. */
32
+ pathHref?: (path: string) => string | undefined;
33
+ /**
34
+ * `"admin"` (default): the full list, a status board and the roadmap.
35
+ * `"marketing"`: public, shipped features with a tagline as benefit cards,
36
+ * highlights first, grouped by category.
37
+ */
38
+ variant?: "admin" | "marketing";
39
+ /** Show the roadmap (features with a `horizon`) under the list. Default true. */
40
+ roadmap?: boolean;
41
+ /** Anything else for the underlying `ResourcePage` (e.g. `urlState`). */
42
+ resourcePageProps?: Partial<ResourcePageProps<FeatureRecord>>;
43
+ className?: string;
44
+ }
45
+ /**
46
+ * A repo's features as a page. The default (`variant="admin"`) is a
47
+ * ResourcePage over static data: a table, and in its grid view a board grouped
48
+ * by status, with status chips, filters by app, audience and visibility,
49
+ * search, and a detail panel with the feature's links, acceptance and flags.
50
+ * Planned work is kept off the list and shown on the roadmap below it.
51
+ * `variant="marketing"` shows only public, shipped features with a tagline.
52
+ *
53
+ * @stability Beta
54
+ */
55
+ declare function FeatureList({ features, flags, title, subtitle, defaultView, viewSettingsKey, pathHref, variant, roadmap, resourcePageProps, className, }: FeatureListProps): react.JSX.Element;
56
+
57
+ export { FeatureList, type FeatureListProps, FeatureStatusBadge };