@marktiderman/genesis-features 0.9.0 → 0.10.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.
Files changed (43) hide show
  1. package/README.md +14 -279
  2. package/dist/blocks.d.ts +4 -470
  3. package/dist/blocks.js +7 -5
  4. package/dist/gate-react.d.ts +4 -45
  5. package/dist/gate-react.js +7 -36
  6. package/dist/gate.d.ts +4 -15
  7. package/dist/gate.js +7 -5
  8. package/dist/index.d.ts +4 -124
  9. package/dist/index.js +7 -8
  10. package/dist/node.d.ts +4 -156
  11. package/dist/node.js +7 -486
  12. package/dist/react.d.ts +4 -57
  13. package/dist/react.js +7 -235
  14. package/dist/settings-protocol.d.ts +7 -0
  15. package/dist/settings-protocol.js +7 -0
  16. package/dist/settings-react.d.ts +7 -0
  17. package/dist/settings-react.js +8 -0
  18. package/dist/settings.d.ts +7 -0
  19. package/dist/settings.js +7 -0
  20. package/package.json +35 -51
  21. package/dist/blocks.js.map +0 -1
  22. package/dist/chunk-B6WRD3WF.js +0 -6
  23. package/dist/chunk-B6WRD3WF.js.map +0 -1
  24. package/dist/chunk-OW46SL2G.js +0 -10
  25. package/dist/chunk-OW46SL2G.js.map +0 -1
  26. package/dist/chunk-SEFG2QV6.js +0 -413
  27. package/dist/chunk-SEFG2QV6.js.map +0 -1
  28. package/dist/chunk-VYUX7VAX.js +0 -52
  29. package/dist/chunk-VYUX7VAX.js.map +0 -1
  30. package/dist/chunk-YTPGUU5F.js +0 -121
  31. package/dist/chunk-YTPGUU5F.js.map +0 -1
  32. package/dist/chunk-Z3TTDIVM.js +0 -494
  33. package/dist/chunk-Z3TTDIVM.js.map +0 -1
  34. package/dist/gate-oYFzQKyb.d.ts +0 -199
  35. package/dist/gate-react.js.map +0 -1
  36. package/dist/gate.js.map +0 -1
  37. package/dist/index.js.map +0 -1
  38. package/dist/model-sTRmrxz3.d.ts +0 -437
  39. package/dist/node.js.map +0 -1
  40. package/dist/packages-CWhdXtzS.d.ts +0 -203
  41. package/dist/platforms-NR0liM8L.d.ts +0 -10
  42. package/dist/react.js.map +0 -1
  43. package/dist/types-Bd766VxF.d.ts +0 -39
@@ -1,413 +0,0 @@
1
- import { requirementProblem, cycleProblems } from './chunk-VYUX7VAX.js';
2
- import { FEATURE_PLATFORMS } from './chunk-B6WRD3WF.js';
3
- import { statusOn } from './chunk-OW46SL2G.js';
4
- import { z } from 'zod';
5
-
6
- // src/types.ts
7
- var FEATURE_STATUSES = ["idea", "planned", "building", "beta", "live", "deprecated", "retired"];
8
- var FLAG_KINDS = ["release", "experiment", "ops", "permission"];
9
- var FEATURE_HORIZONS = ["now", "next", "later"];
10
- var FEATURE_KINDS = ["token", "element", "pattern", "layout", "hook", "provider", "block", "service", "tool"];
11
- var FEATURE_LAYERS = FEATURE_KINDS;
12
- function featureLayer(layer) {
13
- return layer === "primitive" ? "element" : layer;
14
- }
15
- function featureKind(def) {
16
- return def.kind ?? featureLayer(def.layer);
17
- }
18
- var ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
19
- var DAY = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
20
- var MONTH_OR_DAY = /^\d{4}-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01]))?$/;
21
- var URL_RE = /^https?:\/\/\S+$/;
22
- var ISSUE = /^(https?:\/\/\S+|([\w.-]+\/[\w.-]+)?#\d+)$/;
23
- var text = z.string().trim().min(1);
24
- var day = z.string().regex(DAY, "must be YYYY-MM-DD");
25
- var repoPath = text.refine(
26
- (p) => !p.startsWith("/") && !/^[a-z]:/i.test(p) && !p.split(/[\\/]/).includes(".."),
27
- { message: "must be a path relative to the repo root, without .." }
28
- );
29
- var pathOrUrl = z.union([z.string().regex(URL_RE), repoPath]);
30
- var linksSchema = z.object({
31
- code: z.array(repoPath).optional(),
32
- docs: z.array(pathOrUrl).optional(),
33
- issue: z.string().regex(ISSUE, "must be a URL, #123 or owner/repo#123").optional()
34
- }).strict();
35
- var visibilitySchema = z.union([
36
- z.enum(["internal", "customer", "public"]),
37
- z.string().regex(/^client:\S+$/, "must be internal, customer, public or client:<name>")
38
- ]);
39
- var perPlatform = (value) => z.object(Object.fromEntries(FEATURE_PLATFORMS.map((p) => [p, value.optional()]))).strict();
40
- var featureSchema = z.object({
41
- name: text,
42
- summary: text,
43
- status: z.enum(FEATURE_STATUSES),
44
- owner: text,
45
- apps: z.array(text).min(1),
46
- audience: z.array(text).min(1),
47
- horizon: z.enum(FEATURE_HORIZONS).optional(),
48
- visibility: visibilitySchema.optional(),
49
- access: z.union([z.literal("all"), z.object({ plan: text }).strict()]).optional(),
50
- acceptance: z.array(text).optional(),
51
- aliases: z.array(z.string().regex(ID, "must be a feature id")).optional(),
52
- reviewedAt: day.optional(),
53
- claimedBy: text.optional(),
54
- since: z.string().regex(MONTH_OR_DAY, "must be YYYY-MM-DD or YYYY-MM").optional(),
55
- links: linksSchema.optional(),
56
- tagline: text.optional(),
57
- category: text.optional(),
58
- media: z.object({ image: pathOrUrl.optional(), video: pathOrUrl.optional(), alt: text }).strict().optional(),
59
- highlight: z.boolean().optional(),
60
- kind: z.enum(FEATURE_KINDS).optional(),
61
- layer: z.enum([...FEATURE_KINDS, "primitive"]).optional(),
62
- platforms: perPlatform(z.enum(FEATURE_STATUSES)).optional(),
63
- entry: perPlatform(text).optional(),
64
- keywords: z.array(text).optional(),
65
- extends: z.string().regex(ID, "must be a feature id").optional(),
66
- requires: z.array(z.string().regex(ID, "must be a feature id")).optional(),
67
- contributes: z.array(text).optional(),
68
- slots: z.array(text).optional()
69
- }).strict();
70
- var flagValue = z.union([z.boolean(), z.string(), z.number(), z.record(z.string(), z.unknown())]);
71
- var flagSchema = z.object({
72
- feature: text,
73
- kind: z.enum(FLAG_KINDS),
74
- owner: text,
75
- default: flagValue,
76
- scopes: z.array(text).min(1),
77
- description: text.optional(),
78
- expires: day.optional(),
79
- runbook: pathOrUrl.optional(),
80
- splitReason: text.optional()
81
- }).strict();
82
- var FeatureRegistryError = class extends Error {
83
- constructor(problems) {
84
- super(`Invalid feature registry:
85
- ${problems.map((p) => ` - ${p}`).join("\n")}`);
86
- this.problems = problems;
87
- this.name = "FeatureRegistryError";
88
- }
89
- problems;
90
- };
91
- function issues(prefix, error) {
92
- return error.issues.map((i) => `${[prefix, ...i.path].join(".")}: ${i.message}`);
93
- }
94
- function featureProblems(id, def) {
95
- const problems = [];
96
- const early = def.status === "planned" || def.status === "building";
97
- if (def.horizon && !early) problems.push(`${id}.horizon: only planned and building features are on the roadmap`);
98
- if (def.status === "planned" && !def.horizon) problems.push(`${id}.horizon: a planned feature needs now, next or later`);
99
- if ((def.status === "beta" || def.status === "live") && !def.acceptance?.length) {
100
- problems.push(`${id}.acceptance: a ${def.status} feature needs at least one testable sentence`);
101
- }
102
- if (def.claimedBy && def.status !== "building") problems.push(`${id}.claimedBy: only a building feature can be claimed`);
103
- if (def.media && !def.media.image && !def.media.video) problems.push(`${id}.media: needs an image or a video`);
104
- if (def.kind && def.layer && featureLayer(def.layer) !== def.kind) {
105
- problems.push(`${id}.layer: says ${def.layer} but kind says ${def.kind}; drop layer (deprecated), kind replaces it`);
106
- }
107
- return problems;
108
- }
109
- function defineFeatures(features) {
110
- const problems = [];
111
- const invalid = /* @__PURE__ */ new Set();
112
- const owners = /* @__PURE__ */ new Map();
113
- for (const [id, def] of Object.entries(features)) {
114
- if (!ID.test(id)) problems.push(`${id}: the id must be lowercase letters and digits, joined by -, _ or .`);
115
- const parsed = featureSchema.safeParse(def);
116
- if (!parsed.success) {
117
- problems.push(...issues(id, parsed.error));
118
- invalid.add(id);
119
- continue;
120
- }
121
- problems.push(...featureProblems(id, def));
122
- for (const name of [id, ...def.aliases ?? []]) {
123
- const other = owners.get(name);
124
- if (other !== void 0) problems.push(`${id}: "${name}" is already ${other === name ? "a feature id" : `an alias of ${other}`}`);
125
- else owners.set(name, id);
126
- }
127
- }
128
- problems.push(...relationProblems(features, invalid));
129
- if (problems.length) throw new FeatureRegistryError(problems);
130
- return Object.freeze(features);
131
- }
132
- var UNSHIPPED = ["idea", "planned", "retired"];
133
- function relationProblems(features, skip) {
134
- const problems = [];
135
- const has = (id) => Object.hasOwn(features, id);
136
- for (const [id, def] of Object.entries(features)) {
137
- if (skip.has(id)) continue;
138
- if (def.extends !== void 0) {
139
- if (def.extends === id) problems.push(`${id}.extends: a feature can't extend itself`);
140
- else if (!has(def.extends)) problems.push(`${id}.extends: "${def.extends}" is not a feature`);
141
- }
142
- for (const req of def.requires ?? []) {
143
- const problem = requirementProblem(features, id, req, { noun: "feature" });
144
- if (problem) problems.push(problem);
145
- else if (!skip.has(req) && (def.status === "beta" || def.status === "live") && UNSHIPPED.includes(features[req].status)) {
146
- problems.push(`${id}.requires: a ${def.status} feature can't require "${req}", which is ${features[req].status}`);
147
- }
148
- }
149
- }
150
- problems.push(...cycleProblems(features, skip));
151
- return problems;
152
- }
153
- function defineFlags(features, flags) {
154
- const problems = [];
155
- const seen = /* @__PURE__ */ new Map();
156
- for (const [name, def] of Object.entries(flags)) {
157
- const parsed = flagSchema.safeParse(def);
158
- if (!parsed.success) {
159
- problems.push(...issues(name, parsed.error));
160
- continue;
161
- }
162
- const flag = parsed.data;
163
- if (!Object.hasOwn(features, flag.feature)) problems.push(`${name}.feature: "${flag.feature}" is not a feature`);
164
- if ((flag.kind === "release" || flag.kind === "experiment") && !flag.expires) {
165
- problems.push(`${name}.expires: a ${flag.kind} flag needs an expiry date`);
166
- }
167
- if (flag.kind === "ops" && !flag.runbook) problems.push(`${name}.runbook: an ops flag needs a runbook`);
168
- const first = seen.get(flag.feature);
169
- if (first === void 0) seen.set(flag.feature, name);
170
- else if (!flag.splitReason)
171
- problems.push(`${name}.splitReason: "${flag.feature}" already has the flag ${first}; say why this one is separate`);
172
- }
173
- if (problems.length) throw new FeatureRegistryError(problems);
174
- return Object.freeze(flags);
175
- }
176
- function flagsForFeature(flags, id) {
177
- if (!flags) return [];
178
- return Object.entries(flags).filter(([, flag]) => flag.feature === id).map(([name]) => name);
179
- }
180
- function expiredFlags(flags, today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)) {
181
- if (!flags) return [];
182
- return Object.entries(flags).filter(([, flag]) => flag.expires !== void 0 && flag.expires < today).map(([name]) => name);
183
- }
184
- function toRecords(features, flags) {
185
- return Object.entries(features).map(([id, { layer: _layer, ...def }]) => ({
186
- id,
187
- ...def,
188
- ...featureKind({ ...def, layer: _layer }) ? { kind: featureKind({ ...def, layer: _layer }) } : {},
189
- visibility: def.visibility ?? "customer",
190
- access: def.access ?? "all",
191
- flags: flagsForFeature(flags, id)
192
- }));
193
- }
194
- function specifierPackage(specifier) {
195
- const parts = specifier.split("/");
196
- return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
197
- }
198
- function featurePackageLayer(def, packages) {
199
- for (const specifier of Object.values(def.entry ?? {})) {
200
- const name = specifier && specifierPackage(specifier);
201
- const hit = packages.find((p) => p.name === name);
202
- if (hit) return hit.layer;
203
- }
204
- for (const raw of def.links?.code ?? []) {
205
- const path = raw.replace(/\\/g, "/").replace(/^\.\//, "");
206
- const hit = packages.find((p) => p.dir && (path === p.dir || path.startsWith(`${p.dir}/`)));
207
- if (hit) return hit.layer;
208
- }
209
- return void 0;
210
- }
211
- function findFeatures(features, term, flags, options = {}) {
212
- const needle = term.trim().toLowerCase();
213
- const kind = options.kind ?? featureLayer(options.layer);
214
- if (options.packageLayer && !options.packages) throw new Error("findFeatures: packageLayer needs packages");
215
- const filtered = Boolean(options.platform || kind || options.packageLayer || options.status);
216
- if (!needle && !filtered) return [];
217
- const keep = (r) => (!options.platform || statusOn(r, options.platform) !== void 0) && (!kind || featureKind(r) === kind) && (!options.packageLayer || featurePackageLayer(r, options.packages ?? []) === options.packageLayer) && (!options.status || r.status === options.status);
218
- const score = (r) => {
219
- if (!needle) return 0;
220
- if (r.id === needle || r.aliases?.includes(needle)) return 0;
221
- if (r.id.includes(needle) || r.name.toLowerCase().includes(needle)) return 1;
222
- if (r.keywords?.some((k) => k.toLowerCase().includes(needle))) return 1;
223
- if (r.flags.some((f) => f.toLowerCase().includes(needle))) return 2;
224
- const rest = [
225
- r.summary,
226
- r.tagline,
227
- r.category,
228
- ...r.links?.code ?? [],
229
- ...r.aliases ?? [],
230
- ...Object.values(r.entry ?? {}),
231
- ...r.slots ?? [],
232
- ...r.contributes ?? []
233
- ];
234
- return rest.some((v) => v?.toLowerCase().includes(needle)) ? 3 : -1;
235
- };
236
- return toRecords(features, flags).filter(keep).map((r) => [score(r), r]).filter(([s]) => s >= 0).sort((a, b) => a[0] - b[0]).map(([, r]) => r);
237
- }
238
-
239
- // src/generate.ts
240
- var AGENTS_BLOCK_START = "<!-- genesis-features:start -->";
241
- var AGENTS_BLOCK_END = "<!-- genesis-features:end -->";
242
- var MARKETING_BLOCK_START = "<!-- genesis-features:marketing:start -->";
243
- var MARKETING_BLOCK_END = "<!-- genesis-features:marketing:end -->";
244
- function toJson(features, flags, options = {}) {
245
- const doc = {
246
- generatedFrom: options.source ?? "src/features.ts",
247
- features: toRecords(features, flags),
248
- flags: flags ?? {}
249
- };
250
- return `${JSON.stringify(doc, null, 2)}
251
- `;
252
- }
253
- function flagType(value) {
254
- if (typeof value === "boolean") return "boolean";
255
- if (typeof value === "string") return "string";
256
- if (typeof value === "number") return Number.isInteger(value) ? "integer" : "float";
257
- return "object";
258
- }
259
- var OPENFEATURE_MANIFEST_SCHEMA = "https://raw.githubusercontent.com/open-feature/cli/refs/heads/main/schema/v0/flag-manifest.json";
260
- function toOpenFeatureManifest(flags, features) {
261
- const manifest = {
262
- $schema: OPENFEATURE_MANIFEST_SCHEMA,
263
- flags: Object.fromEntries(
264
- Object.entries(flags).map(([key, flag]) => [
265
- key,
266
- {
267
- flagType: flagType(flag.default),
268
- defaultValue: flag.default,
269
- description: flag.description ?? `${flag.kind} flag for ${features?.[flag.feature]?.name ?? flag.feature}`
270
- }
271
- ])
272
- )
273
- };
274
- return `${JSON.stringify(manifest, null, 2)}
275
- `;
276
- }
277
- var cell = (value) => value.replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
278
- function toAgentsMarkdown(features, flags, options = {}) {
279
- const source = options.source ?? "src/features.ts";
280
- const command = options.command ?? "genesis features";
281
- const skill = options.skill === void 0 ? ".claude/skills/features/SKILL.md" : options.skill;
282
- const records = toRecords(features, flags);
283
- const counts = FEATURE_STATUSES.map((s) => [s, records.filter((r) => r.status === s).length]).filter(([, n]) => n > 0).map(([s, n]) => `${n} ${s}`).join(", ");
284
- const flagCount = flags ? Object.keys(flags).length : 0;
285
- const lines = [
286
- AGENTS_BLOCK_START,
287
- "## Features",
288
- "",
289
- `Every feature is in \`${source}\`: ${records.length} features (${counts})${flagCount ? `, ${flagCount} flag${flagCount === 1 ? "" : "s"}` : ""}.`,
290
- "",
291
- `- Before adding UI, routes or flags, run \`${command} find <term>\` to see whether a feature already covers it.`,
292
- `- New work starts as an entry in \`${source}\`; then run \`${command} build\`. \`${command} check\` runs in CI.`,
293
- ...skill ? [`- Finding, adding and retiring features: \`${skill}\`.`] : [],
294
- "",
295
- `Generated by \`${command} build\`. Don't edit this block.`,
296
- AGENTS_BLOCK_END
297
- ];
298
- return lines.join("\n");
299
- }
300
- function marketingRecords(features) {
301
- return toRecords(features).filter((r) => r.visibility === "public" && r.tagline && (r.status === "live" || r.status === "beta")).sort((a, b) => Number(Boolean(b.highlight)) - Number(Boolean(a.highlight)));
302
- }
303
- function toMarketingMarkdown(features, options = {}) {
304
- const records = marketingRecords(features);
305
- const lines = [MARKETING_BLOCK_START, `## ${options.heading ?? "Features"}`, ""];
306
- const highlights = records.filter((r) => r.highlight);
307
- for (const r of highlights) lines.push(`- **${cell(r.name)}** \u2014 ${cell(r.tagline)}`);
308
- if (highlights.length) lines.push("");
309
- const categories = [...new Set(records.filter((r) => !r.highlight).map((r) => r.category ?? "More"))];
310
- for (const category of categories) {
311
- lines.push(`### ${category}`, "");
312
- for (const r of records.filter((x) => !x.highlight && (x.category ?? "More") === category)) {
313
- lines.push(`- **${cell(r.name)}**${r.status === "beta" ? " (beta)" : ""} \u2014 ${cell(r.tagline)}`);
314
- }
315
- lines.push("");
316
- }
317
- lines.push(`<sub>Generated from \`${options.source ?? "src/features.ts"}\`.</sub>`, MARKETING_BLOCK_END);
318
- return lines.join("\n");
319
- }
320
- var BrokenBlockError = class extends Error {
321
- constructor(start) {
322
- super(`The generated block's markers are broken (${start} and its end marker must each appear once, in order). Fix them by hand, or delete both and the block between them.`);
323
- this.name = "BrokenBlockError";
324
- }
325
- };
326
- var count = (doc, marker) => doc.split(marker).length - 1;
327
- function readBlock(doc, start, end) {
328
- const starts = count(doc, start);
329
- const ends = count(doc, end);
330
- if (starts === 0 && ends === 0) return null;
331
- const from = doc.indexOf(start);
332
- const to = doc.indexOf(end);
333
- if (starts !== 1 || ends !== 1 || to < from) throw new BrokenBlockError(start);
334
- return doc.slice(from, to + end.length);
335
- }
336
- function replaceBlock(doc, block, start, end) {
337
- const current = readBlock(doc, start, end);
338
- if (current !== null) return doc.replace(current, () => block);
339
- const base = doc.length === 0 || doc.endsWith("\n") ? doc : `${doc}
340
- `;
341
- return `${base}${base.length ? "\n" : ""}${block}
342
- `;
343
- }
344
- var readAgentsBlock = (doc) => readBlock(doc, AGENTS_BLOCK_START, AGENTS_BLOCK_END);
345
- var replaceAgentsBlock = (doc, block) => replaceBlock(doc, block, AGENTS_BLOCK_START, AGENTS_BLOCK_END);
346
- function toSkillMarkdown(options = {}) {
347
- const source = options.source ?? "src/features.ts";
348
- const command = options.command ?? "genesis features";
349
- const outputs = options.outputs ?? ["the AGENTS.md block", "features.json", "this skill"];
350
- return `---
351
- name: features
352
- description: Find, add, change and retire this repo's features in ${source}, and their flags. Use before adding UI, a route, a server function or a flag, when someone asks what the product does, or when shipping, deprecating or removing something.
353
- ---
354
-
355
- <!-- Generated by \`${command} build\`. Don't edit; it is rewritten. -->
356
-
357
- # Features
358
-
359
- \`${source}\` is the one list of what this product does. Running code imports it, and
360
- \`${command} build\` generates the rest from it: ${outputs.join(", ")}.
361
-
362
- ## Find: reuse, then extend, then invent
363
- - \`${command} find <term>\` searches ids, aliases, names, keywords, summaries, import paths, slots
364
- and code paths; \`--platform\`, \`--kind\`, \`--layer\` (the owning package's layer) and
365
- \`--status\` narrow it (an empty term lists all that pass). Run it before building anything
366
- new, in this order:
367
- 1. **Reuse**: a feature already does it. Use it as is, configured through its \`slots\`.
368
- 2. **Extend**: one is close. Fill a slot, or add a variant with \`extends: <id>\`.
369
- 3. **Invent**: nothing is close. Add an entry first (an \`idea\` is enough), then build.
370
-
371
- ## Add
372
- 1. Add an entry to \`${source}\`. The key is the id: lowercase, permanent, never reused.
373
- Required: \`name\`, \`summary\` (internal, one sentence), \`status\`, \`owner\`, \`apps\`, \`audience\`.
374
- - \`idea\`: captured, not agreed. Nothing else is required; add \`keywords\` so \`find\` matches it.
375
- - \`planned\` needs a \`horizon\` (now, next, later). No dates on the roadmap.
376
- - \`building\`: set \`claimedBy\` to your name or session while you work on it.
377
- - \`beta\` and \`live\` need \`acceptance\`: one testable sentence each. Tag the tests that prove
378
- them with \`@feat:<id>\` in a comment or the test name.
379
- - \`links.code\`: the files or folders that implement it. \`check\` fails when one is missing.
380
- - \`visibility\` (internal, customer, public, client:<name>) and \`access\` ("all" or { plan }).
381
- Paid access is \`access\`, never a flag. The id is the billing entitlement's lookup key.
382
- - For a public page: \`tagline\` (the customer benefit), \`category\`, \`media\`, \`highlight\`.
383
- - For reuse: \`kind\` (token, element, pattern, layout, hook, provider, block, service, tool;
384
- \`layer\` is its deprecated name, read until the next major),
385
- \`platforms\` (status per platform when it differs), \`entry\` (what to import, per platform),
386
- \`keywords\`, \`slots\`, \`extends\` (the feature this is a variant of), \`requires\` (a beta or
387
- live feature can't require an idea, a planned or a retired one) and \`contributes\`.
388
- 2. Flags go in the flags registry with \`feature: <id>\`. One flag per feature; a second needs a
389
- \`splitReason\`. \`release\` and \`experiment\` flags need \`expires\`, \`ops\` flags a \`runbook\`.
390
- Read flags only through the typed accessor with a literal key, never a computed one.
391
- 3. Run \`${command} build\` and commit what it writes. Tag the changeset (a \`Features: <id>\` line in
392
- its body) or the PR (a \`feature:<id>\` label).
393
-
394
- ## Change
395
- - Move \`status\` as it ships: idea, planned, building, beta, live, deprecated, retired. \`check\` warns
396
- when an idea or a planned feature already has shipped work tagged with it (a changeset, or with \`--prs\` a merged PR).
397
- - Set \`reviewedAt\` (today) whenever you check an entry against the product; \`check\` warns after 90 days.
398
- - Rename by giving the feature a new id and putting the old one in \`aliases\`. Never delete an id once a
399
- feature is being built; an \`idea\` or \`planned\` entry (never shipped) may be removed outright, for
400
- example when a backlog moves to a planning repo. Aliases are never removed.
401
-
402
- ## Retire
403
- 1. Remove the code first: the UI, routes, server functions and tests.
404
- 2. Then remove its flags from the flags registry (the code that read them is gone, so \`check\`
405
- would flag them as unused).
406
- 3. Set \`status: "retired"\`, keep the entry, and drop \`links.code\` paths that no longer exist.
407
- 4. Run \`${command} build\` and \`${command} check\`.
408
- `;
409
- }
410
-
411
- export { AGENTS_BLOCK_END, AGENTS_BLOCK_START, BrokenBlockError, FEATURE_HORIZONS, FEATURE_KINDS, FEATURE_LAYERS, FEATURE_STATUSES, FLAG_KINDS, FeatureRegistryError, MARKETING_BLOCK_END, MARKETING_BLOCK_START, OPENFEATURE_MANIFEST_SCHEMA, defineFeatures, defineFlags, expiredFlags, featureKind, featureLayer, featurePackageLayer, featureSchema, findFeatures, flagSchema, flagsForFeature, marketingRecords, readAgentsBlock, readBlock, replaceAgentsBlock, replaceBlock, toAgentsMarkdown, toJson, toMarketingMarkdown, toOpenFeatureManifest, toRecords, toSkillMarkdown };
412
- //# sourceMappingURL=chunk-SEFG2QV6.js.map
413
- //# sourceMappingURL=chunk-SEFG2QV6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts","../src/model.ts","../src/generate.ts"],"names":[],"mappings":";;;;;;AAYO,IAAM,gBAAA,GAAmB,CAAC,MAAA,E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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAA,EAmBlB,OAAO,CAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAA,EAgBP,OAAO,kBAAkB,OAAO,CAAA;AAAA,CAAA;AAE3C","file":"chunk-SEFG2QV6.js","sourcesContent":["/**\n * The registry's plain types, with no zod: shared by the model and the zod-free\n * gate so `/gate` never pulls zod in, even in its type declarations.\n */\n\n/**\n * Where a feature is in its life. The order is the board's column order.\n * `idea` is captured but not agreed: it is in the list so `find` turns it up\n * before someone builds the same thing twice.\n *\n * @stability Beta\n */\nexport const FEATURE_STATUSES = [\"idea\", \"planned\", \"building\", \"beta\", \"live\", \"deprecated\", \"retired\"] as const;\n\n/** @stability Beta */\nexport type FeatureStatus = (typeof FEATURE_STATUSES)[number];\n\n/**\n * Who gets a feature: everyone, or one paid plan. The feature id doubles as\n * the billing entitlement's lookup key (a Stripe `lookup_key`).\n *\n * @stability Beta\n */\nexport type FeatureAccess = \"all\" | { plan: string };\n\n/**\n * Why a flag exists. `release` and `experiment` flags need `expires`, `ops`\n * flags need a `runbook`, and `permission` flags fail `check`: paid access\n * belongs in entitlements (`access`), not flags.\n *\n * @stability Beta\n */\nexport const FLAG_KINDS = [\"release\", \"experiment\", \"ops\", \"permission\"] as const;\n\n/** @stability Beta */\nexport type FlagKind = (typeof FLAG_KINDS)[number];\n\n/** A flag's default: anything an OpenFeature flag can hold. */\nexport type FlagValue = boolean | string | number | { readonly [key: string]: unknown };\n\n","import { z } from \"zod\";\nimport { cycleProblems, requirementProblem } from \"./graph\";\nimport { FEATURE_PLATFORMS, type FeaturePlatform } from \"./platforms\";\nimport { statusOn } from \"./status\";\nimport type { PackageLayer } from \"./packages\";\nimport { FEATURE_STATUSES, FLAG_KINDS, type FeatureAccess, type FeatureStatus, type FlagKind, type FlagValue } from \"./types\";\n\n// The plain types live in their own zod-free file, shared with the gate.\nexport { FEATURE_STATUSES, FLAG_KINDS, type FeatureAccess, type FeatureStatus, type FlagKind, type FlagValue };\n\n\n\n/**\n * When a planned or building feature is due, without dates: the roadmap's\n * three columns.\n *\n * @stability Beta\n */\nexport const FEATURE_HORIZONS = [\"now\", \"next\", \"later\"] as const;\n\n/** @stability Beta */\nexport type FeatureHorizon = (typeof FEATURE_HORIZONS)[number];\n\n/**\n * Who may see a feature listed. `public` features with a `tagline` go on\n * marketing output; `client:<name>` is one customer's own feature.\n *\n * @stability Beta\n */\nexport type FeatureVisibility = \"internal\" | \"customer\" | \"public\" | `client:${string}`;\n\n\n/**\n * Pointers from a feature to where it lives. `code` paths are relative to the\n * repository root and `genesis features check` fails when one doesn't exist.\n *\n * @stability Beta\n */\nexport interface FeatureLinks {\n /** Files or folders that implement the feature, relative to the repo root. */\n code?: readonly string[];\n /** Docs: a repo-relative path or a URL. */\n docs?: readonly string[];\n /** The tracking issue: a URL, `#123` or `owner/repo#123`. */\n issue?: string;\n}\n\n// Where a feature runs: in its own file so the zod-free blocks entry shares it.\nexport { FEATURE_PLATFORMS, type FeaturePlatform };\n\n/**\n * What kind of thing a feature is, from smallest to largest, so an agent\n * looking for a building block can tell an element from a whole block:\n * `token`, `element` (one component), `pattern` (a composed component with\n * slots), `layout` (a page or screen shell), `hook`, `provider` (data or\n * context), `block` (a feature an app adds whole: UI, data and server),\n * `service` (server code) and `tool` (CLI, CI, devtools).\n *\n * A feature's layer is not declared: it is its package's layer (see\n * {@link featurePackageLayer} and `PACKAGE_LAYERS`).\n *\n * @stability Beta\n */\nexport const FEATURE_KINDS = [\"token\", \"element\", \"pattern\", \"layout\", \"hook\", \"provider\", \"block\", \"service\", \"tool\"] as const;\n\n/** @stability Beta */\nexport type FeatureKind = (typeof FEATURE_KINDS)[number];\n\n/** @deprecated Use `FEATURE_KINDS`. Removed at the next major. */\nexport const FEATURE_LAYERS = FEATURE_KINDS;\n\n/** @deprecated Use `FeatureKind`. Removed at the next major. */\nexport type FeatureLayer = FeatureKind;\n\n/** @deprecated Use `\"element\"`. Accepted until the next major. */\nexport type DeprecatedFeatureLayer = \"primitive\";\n\n/**\n * A kind written in the deprecated `layer` field, with its old name\n * `\"primitive\"` mapped to `\"element\"`.\n *\n * @stability Beta\n */\nexport function featureLayer(layer: FeatureKind | DeprecatedFeatureLayer | undefined): FeatureKind | undefined {\n return layer === \"primitive\" ? \"element\" : layer;\n}\n\n/**\n * A feature's kind: `kind`, or else the deprecated `layer` field (read until\n * the next major).\n *\n * @stability Beta\n */\nexport function featureKind(def: Pick<FeatureDef, \"kind\" | \"layer\">): FeatureKind | undefined {\n return def.kind ?? featureLayer(def.layer);\n}\n\n/** A picture or video for a marketing page. @stability Beta */\nexport interface FeatureMedia {\n image?: string;\n video?: string;\n alt: string;\n}\n\n/**\n * One feature. The object key in {@link defineFeatures} is its id: permanent,\n * never reused, and renamed only through `aliases`.\n *\n * @stability Beta\n */\nexport interface FeatureDef {\n name: string;\n /** One sentence for the team: what it does for whom. */\n summary: string;\n status: FeatureStatus;\n /** Who answers for it: a person, a team or an agent session's name. */\n owner: string;\n /** Which of the repo's apps or surfaces carry it, e.g. `[\"web\"]`. */\n apps: readonly string[];\n /** Who it is for, e.g. `[\"client\", \"coach\"]`. */\n audience: readonly string[];\n /** Roadmap column. Only on planned (required) or building features. */\n horizon?: FeatureHorizon;\n /** Default `customer`. */\n visibility?: FeatureVisibility;\n /** Default `all`. */\n access?: FeatureAccess;\n /** One testable sentence each. Required on beta and live features. */\n acceptance?: readonly string[];\n /** Ids this feature had before. An old id can't be reused. */\n aliases?: readonly string[];\n /** When someone last checked this entry against the product: `YYYY-MM-DD`. */\n reviewedAt?: string;\n /** Who is building it right now. Only on building features. */\n claimedBy?: string;\n /** When it first shipped or started: `YYYY-MM-DD` or `YYYY-MM`. */\n since?: string;\n links?: FeatureLinks;\n /** One line of benefit, for customers. Needed for marketing output. */\n tagline?: string;\n /** A group on a marketing page. */\n category?: string;\n media?: FeatureMedia;\n /** A hero item on a marketing page. */\n highlight?: boolean;\n /** What kind of thing it is. */\n kind?: FeatureKind;\n /**\n * @deprecated Use `kind` (same values; `\"primitive\"` means `\"element\"`). Read until the\n * next major, when `layer` is the owning package's layer, derived and never written.\n */\n layer?: FeatureKind | DeprecatedFeatureLayer;\n /**\n * Status per platform, when it differs from `status`: `{ web: \"live\", native: \"planned\" }`.\n * A platform left out doesn't have it.\n */\n platforms?: Partial<Record<FeaturePlatform, FeatureStatus>>;\n /** What to import, per platform, e.g. `{ web: \"@marktiderman/genesis-ui/settings-row\" }`. */\n entry?: Partial<Record<FeaturePlatform, string>>;\n /** Other words people use for it, so `find` matches them: `[\"chat\", \"dm\"]`. */\n keywords?: readonly string[];\n /** The feature this one is a variant of. */\n extends?: string;\n /** Features it needs. A beta or live feature can't require an idea, a planned or a retired one. */\n requires?: readonly string[];\n /** What it adds to an app, e.g. `[\"nav item\", \"settings row\", \"table: threads\"]`. */\n contributes?: readonly string[];\n /** The parts an app can replace or drop through `slots`. */\n slots?: readonly string[];\n}\n\n\n\n\n/**\n * One flag. `feature` names the {@link FeatureDef} it belongs to; a feature's\n * flags are found by reverse lookup ({@link flagsForFeature}) and never\n * written on the feature itself.\n *\n * @stability Beta\n */\nexport interface FlagDef<F extends string = string> {\n feature: F;\n kind: FlagKind;\n owner: string;\n default: FlagValue;\n /** Where it can be set, e.g. `[\"platform\", \"practice\", \"user\"]`. */\n scopes: readonly string[];\n description?: string;\n /** `YYYY-MM-DD`. Required on release and experiment flags; `check` fails after it. */\n expires?: string;\n /** What to do when you flip it: a repo path or a URL. Required on ops flags. */\n runbook?: string;\n /**\n * Flags are grouped by feature: one flag per feature by default. Every flag\n * after a feature's first must say why it is a separate flag.\n */\n splitReason?: string;\n}\n\n/** The id type of a features object: `type FeatureId = FeatureIdOf<typeof features>`. */\nexport type FeatureIdOf<T> = Extract<keyof T, string>;\n\n/** A features object as {@link defineFeatures} returns it. */\nexport type Features<Id extends string = string> = { readonly [K in Id]: FeatureDef };\n\n/** A flags object as {@link defineFlags} returns it. */\nexport type Flags<F extends string = string> = { readonly [name: string]: FlagDef<F> };\n\nconst ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;\nconst DAY = /^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$/;\nconst MONTH_OR_DAY = /^\\d{4}-(0[1-9]|1[0-2])(-(0[1-9]|[12]\\d|3[01]))?$/;\nconst URL_RE = /^https?:\\/\\/\\S+$/;\nconst ISSUE = /^(https?:\\/\\/\\S+|([\\w.-]+\\/[\\w.-]+)?#\\d+)$/;\n\nconst text = z.string().trim().min(1);\nconst day = z.string().regex(DAY, \"must be YYYY-MM-DD\");\n\n/** A repo-relative path that stays inside the repo. */\nconst repoPath = text.refine(\n (p) => !p.startsWith(\"/\") && !/^[a-z]:/i.test(p) && !p.split(/[\\\\/]/).includes(\"..\"),\n { message: \"must be a path relative to the repo root, without ..\" },\n);\nconst pathOrUrl = z.union([z.string().regex(URL_RE), repoPath]);\n\nconst linksSchema = z\n .object({\n code: z.array(repoPath).optional(),\n docs: z.array(pathOrUrl).optional(),\n issue: z.string().regex(ISSUE, \"must be a URL, #123 or owner/repo#123\").optional(),\n })\n .strict();\n\nconst visibilitySchema = z.union([\n z.enum([\"internal\", \"customer\", \"public\"]),\n z.string().regex(/^client:\\S+$/, \"must be internal, customer, public or client:<name>\"),\n]);\n\n/** `{ web?, native?, server?, cli? }`, each holding `value`. (Not `z.partialRecord`, which zod 3 lacks.) */\nconst perPlatform = <T extends z.ZodTypeAny>(value: T) =>\n z.object(Object.fromEntries(FEATURE_PLATFORMS.map((p) => [p, value.optional()])) as Record<FeaturePlatform, z.ZodOptional<T>>).strict();\n\n/** The Zod schema for one {@link FeatureDef}, field by field. Cross-field rules live in {@link featureProblems}. */\nexport const featureSchema = z\n .object({\n name: text,\n summary: text,\n status: z.enum(FEATURE_STATUSES),\n owner: text,\n apps: z.array(text).min(1),\n audience: z.array(text).min(1),\n horizon: z.enum(FEATURE_HORIZONS).optional(),\n visibility: visibilitySchema.optional(),\n access: z.union([z.literal(\"all\"), z.object({ plan: text }).strict()]).optional(),\n acceptance: z.array(text).optional(),\n aliases: z.array(z.string().regex(ID, \"must be a feature id\")).optional(),\n reviewedAt: day.optional(),\n claimedBy: text.optional(),\n since: z.string().regex(MONTH_OR_DAY, \"must be YYYY-MM-DD or YYYY-MM\").optional(),\n links: linksSchema.optional(),\n tagline: text.optional(),\n category: text.optional(),\n media: z\n .object({ image: pathOrUrl.optional(), video: pathOrUrl.optional(), alt: text })\n .strict()\n .optional(),\n highlight: z.boolean().optional(),\n kind: z.enum(FEATURE_KINDS).optional(),\n layer: z.enum([...FEATURE_KINDS, \"primitive\"]).optional(),\n platforms: perPlatform(z.enum(FEATURE_STATUSES)).optional(),\n entry: perPlatform(text).optional(),\n keywords: z.array(text).optional(),\n extends: z.string().regex(ID, \"must be a feature id\").optional(),\n requires: z.array(z.string().regex(ID, \"must be a feature id\")).optional(),\n contributes: z.array(text).optional(),\n slots: z.array(text).optional(),\n })\n .strict();\n\nconst flagValue: z.ZodType<FlagValue> = z.union([z.boolean(), z.string(), z.number(), z.record(z.string(), z.unknown())]);\n\n/** The Zod schema for one {@link FlagDef}. Cross-flag rules live in {@link defineFlags}. */\nexport const flagSchema = z\n .object({\n feature: text,\n kind: z.enum(FLAG_KINDS),\n owner: text,\n default: flagValue,\n scopes: z.array(text).min(1),\n description: text.optional(),\n expires: day.optional(),\n runbook: pathOrUrl.optional(),\n splitReason: text.optional(),\n })\n .strict();\n\n/** Thrown by {@link defineFeatures} and {@link defineFlags}; lists every problem at once. */\nexport class FeatureRegistryError extends Error {\n constructor(readonly problems: string[]) {\n super(`Invalid feature registry:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n this.name = \"FeatureRegistryError\";\n }\n}\n\nfunction issues(prefix: string, error: z.ZodError): string[] {\n return error.issues.map((i) => `${[prefix, ...i.path].join(\".\")}: ${i.message}`);\n}\n\n/** The rules between one feature's fields, as problem strings. */\nfunction featureProblems(id: string, def: FeatureDef): string[] {\n const problems: string[] = [];\n const early = def.status === \"planned\" || def.status === \"building\";\n if (def.horizon && !early) problems.push(`${id}.horizon: only planned and building features are on the roadmap`);\n if (def.status === \"planned\" && !def.horizon) problems.push(`${id}.horizon: a planned feature needs now, next or later`);\n if ((def.status === \"beta\" || def.status === \"live\") && !def.acceptance?.length) {\n problems.push(`${id}.acceptance: a ${def.status} feature needs at least one testable sentence`);\n }\n if (def.claimedBy && def.status !== \"building\") problems.push(`${id}.claimedBy: only a building feature can be claimed`);\n if (def.media && !def.media.image && !def.media.video) problems.push(`${id}.media: needs an image or a video`);\n if (def.kind && def.layer && featureLayer(def.layer) !== def.kind) {\n problems.push(`${id}.layer: says ${def.layer} but kind says ${def.kind}; drop layer (deprecated), kind replaces it`);\n }\n return problems;\n}\n\n/**\n * The one source of truth for a repo's features. Validates every entry and\n * returns the same object, so running code reads it directly and the key type\n * becomes the repo's `FeatureId`:\n *\n * ```ts\n * export const features = defineFeatures({\n * tasks: { name: \"Tasks\", summary: \"…\", status: \"live\", owner: \"mark\", apps: [\"web\"], audience: [\"client\"],\n * acceptance: [\"A client can tick off a task their coach added.\"] },\n * });\n * export type FeatureId = FeatureIdOf<typeof features>;\n * ```\n *\n * @stability Beta\n */\nexport function defineFeatures<const T extends Record<string, FeatureDef>>(features: T): T {\n const problems: string[] = [];\n const invalid = new Set<string>();\n const owners = new Map<string, string>();\n for (const [id, def] of Object.entries(features)) {\n if (!ID.test(id)) problems.push(`${id}: the id must be lowercase letters and digits, joined by -, _ or .`);\n const parsed = featureSchema.safeParse(def);\n if (!parsed.success) {\n problems.push(...issues(id, parsed.error));\n invalid.add(id);\n continue;\n }\n problems.push(...featureProblems(id, def));\n for (const name of [id, ...(def.aliases ?? [])]) {\n const other = owners.get(name);\n if (other !== undefined) problems.push(`${id}: \"${name}\" is already ${other === name ? \"a feature id\" : `an alias of ${other}`}`);\n else owners.set(name, id);\n }\n }\n problems.push(...relationProblems(features, invalid));\n if (problems.length) throw new FeatureRegistryError(problems);\n return Object.freeze(features);\n}\n\nconst UNSHIPPED: readonly FeatureStatus[] = [\"idea\", \"planned\", \"retired\"];\n\n/** `extends` and `requires` name real, distinct features; `requires` has no cycles; shipped features need shipped ones. */\nfunction relationProblems(features: Record<string, FeatureDef>, skip: ReadonlySet<string>): string[] {\n const problems: string[] = [];\n const has = (id: string) => Object.hasOwn(features, id);\n for (const [id, def] of Object.entries(features)) {\n // A schema-invalid entry is already reported; its fields can't be trusted here.\n if (skip.has(id)) continue;\n if (def.extends !== undefined) {\n if (def.extends === id) problems.push(`${id}.extends: a feature can't extend itself`);\n else if (!has(def.extends)) problems.push(`${id}.extends: \"${def.extends}\" is not a feature`);\n }\n // Itself and unknown ids: the same checks `resolveBlocks` runs on blocks.\n for (const req of def.requires ?? []) {\n const problem = requirementProblem(features, id, req, { noun: \"feature\" });\n if (problem) problems.push(problem);\n else if (!skip.has(req) && (def.status === \"beta\" || def.status === \"live\") && UNSHIPPED.includes(features[req]!.status)) {\n problems.push(`${id}.requires: a ${def.status} feature can't require \"${req}\", which is ${features[req]!.status}`);\n }\n }\n }\n problems.push(...cycleProblems(features, skip));\n return problems;\n}\n\n/**\n * Flags, each tied to a feature of `features`. An unknown `feature` is a type\n * error, and at runtime:\n * - every flag needs an `owner`, a `kind`, a `default` and its `scopes`;\n * - `release` and `experiment` flags need an `expires` date, `ops` flags a `runbook`;\n * - a feature's second (third, …) flag needs a `splitReason`, because flags\n * are grouped by feature unless there's a stated reason to split.\n *\n * `permission` flags are accepted here so the app still runs, and refused by\n * `genesis features check`.\n *\n * @stability Beta\n */\nexport function defineFlags<F extends string, const T extends Record<string, FlagDef<NoInfer<F>>>>(\n features: { readonly [K in F]: FeatureDef },\n flags: T,\n): T {\n const problems: string[] = [];\n const seen = new Map<string, string>();\n for (const [name, def] of Object.entries(flags)) {\n const parsed = flagSchema.safeParse(def);\n if (!parsed.success) {\n problems.push(...issues(name, parsed.error));\n continue;\n }\n const flag = parsed.data;\n if (!Object.hasOwn(features, flag.feature)) problems.push(`${name}.feature: \"${flag.feature}\" is not a feature`);\n if ((flag.kind === \"release\" || flag.kind === \"experiment\") && !flag.expires) {\n problems.push(`${name}.expires: a ${flag.kind} flag needs an expiry date`);\n }\n if (flag.kind === \"ops\" && !flag.runbook) problems.push(`${name}.runbook: an ops flag needs a runbook`);\n const first = seen.get(flag.feature);\n if (first === undefined) seen.set(flag.feature, name);\n else if (!flag.splitReason)\n problems.push(`${name}.splitReason: \"${flag.feature}\" already has the flag ${first}; say why this one is separate`);\n }\n if (problems.length) throw new FeatureRegistryError(problems);\n return Object.freeze(flags);\n}\n\n/**\n * The names of the flags that belong to a feature, in declaration order.\n *\n * @stability Beta\n */\nexport function flagsForFeature(flags: Flags | undefined, id: string): string[] {\n if (!flags) return [];\n return Object.entries(flags)\n .filter(([, flag]) => flag.feature === id)\n .map(([name]) => name);\n}\n\n/**\n * Flags whose `expires` date is before `today` (`YYYY-MM-DD`, default today in\n * UTC): remove the code path, then the flag.\n *\n * @stability Beta\n */\nexport function expiredFlags(flags: Flags | undefined, today = new Date().toISOString().slice(0, 10)): string[] {\n if (!flags) return [];\n return Object.entries(flags)\n .filter(([, flag]) => flag.expires !== undefined && flag.expires < today)\n .map(([name]) => name);\n}\n\n/**\n * A feature flattened for a list, a board or JSON: its id, its fields with\n * defaults filled in, and the names of its flags.\n *\n * @stability Beta\n */\nexport interface FeatureRecord extends FeatureDef {\n [key: string]: unknown;\n id: string;\n visibility: FeatureVisibility;\n access: FeatureAccess;\n flags: string[];\n}\n\n/**\n * Features as records, in declaration order, each with its flags attached.\n *\n * @stability Beta\n */\nexport function toRecords(features: Features, flags?: Flags): FeatureRecord[] {\n // The deprecated `layer` comes out as `kind`, so a record's `layer` can later mean the package's.\n return Object.entries(features).map(([id, { layer: _layer, ...def }]) => ({\n id,\n ...def,\n ...(featureKind({ ...def, layer: _layer }) ? { kind: featureKind({ ...def, layer: _layer }) } : {}),\n visibility: def.visibility ?? \"customer\",\n access: def.access ?? \"all\",\n flags: flagsForFeature(flags, id),\n }));\n}\n\n/**\n * Narrows {@link findFeatures}: only features on a platform (from `platforms`,\n * or `apps` when a feature has no `platforms`), of a layer, or in a status.\n *\n * @stability Beta\n */\nexport interface FindOptions {\n platform?: FeaturePlatform;\n kind?: FeatureKind;\n /** @deprecated Use `kind` (`\"primitive\"` is read as `\"element\"`). */\n layer?: FeatureKind | DeprecatedFeatureLayer;\n /**\n * Only features whose package is in this layer (see {@link featurePackageLayer}).\n * Needs `packages`: without them it throws, rather than matching nothing.\n */\n packageLayer?: PackageLayer;\n /** The packages a feature can belong to, for `packageLayer`. */\n packages?: readonly FeaturePackage[];\n status?: FeatureStatus;\n}\n\n/**\n * A package a feature can belong to: its npm name, its folder (repo-relative,\n * e.g. `packages/ui`) when it is in this repo, and its layer.\n *\n * @stability Beta\n */\nexport interface FeaturePackage {\n name: string;\n dir?: string;\n layer: PackageLayer;\n}\n\n/** The package an import specifier names: `@scope/name` or `name`, without a subpath. */\nfunction specifierPackage(specifier: string): string {\n const parts = specifier.split(\"/\");\n return specifier.startsWith(\"@\") ? parts.slice(0, 2).join(\"/\") : (parts[0] ?? specifier);\n}\n\n/**\n * A feature's layer, derived from the package that owns it: the first `entry`\n * import whose package is known, else the first `links.code` path inside a\n * known package folder. Undefined when no package owns it (an app's own\n * feature, a tool in scripts/).\n *\n * @stability Beta\n */\nexport function featurePackageLayer(\n def: FeatureDef,\n packages: readonly FeaturePackage[],\n): PackageLayer | undefined {\n for (const specifier of Object.values(def.entry ?? {})) {\n const name = specifier && specifierPackage(specifier);\n const hit = packages.find((p) => p.name === name);\n if (hit) return hit.layer;\n }\n for (const raw of def.links?.code ?? []) {\n const path = raw.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n const hit = packages.find((p) => p.dir && (path === p.dir || path.startsWith(`${p.dir}/`)));\n if (hit) return hit.layer;\n }\n return undefined;\n}\n\n// A feature's status on one platform: in its own zod-free file so the gate shares it.\nexport { statusOn };\n\n/**\n * Features matching `term` in their id, aliases, name, keywords, summary,\n * tagline, category, import paths, slots, contributions or code paths, best\n * matches (id, name and keywords) first. With `options` and an empty `term`,\n * every feature that passes the filters.\n *\n * @stability Beta\n */\nexport function findFeatures(features: Features, term: string, flags?: Flags, options: FindOptions = {}): FeatureRecord[] {\n const needle = term.trim().toLowerCase();\n const kind = options.kind ?? featureLayer(options.layer);\n if (options.packageLayer && !options.packages) throw new Error(\"findFeatures: packageLayer needs packages\");\n const filtered = Boolean(options.platform || kind || options.packageLayer || options.status);\n if (!needle && !filtered) return [];\n const keep = (r: FeatureRecord) =>\n (!options.platform || statusOn(r, options.platform) !== undefined) &&\n (!kind || featureKind(r) === kind) &&\n (!options.packageLayer || featurePackageLayer(r, options.packages ?? []) === options.packageLayer) &&\n (!options.status || r.status === options.status);\n const score = (r: FeatureRecord) => {\n if (!needle) return 0;\n if (r.id === needle || r.aliases?.includes(needle)) return 0;\n if (r.id.includes(needle) || r.name.toLowerCase().includes(needle)) return 1;\n if (r.keywords?.some((k) => k.toLowerCase().includes(needle))) return 1;\n if (r.flags.some((f) => f.toLowerCase().includes(needle))) return 2;\n const rest = [\n r.summary,\n r.tagline,\n r.category,\n ...(r.links?.code ?? []),\n ...(r.aliases ?? []),\n ...Object.values(r.entry ?? {}),\n ...(r.slots ?? []),\n ...(r.contributes ?? []),\n ];\n return rest.some((v) => v?.toLowerCase().includes(needle)) ? 3 : -1;\n };\n return toRecords(features, flags)\n .filter(keep)\n .map((r) => [score(r), r] as const)\n .filter(([s]) => s >= 0)\n .sort((a, b) => a[0] - b[0])\n .map(([, r]) => r);\n}\n","import { FEATURE_STATUSES, toRecords, type FeatureRecord, type Features, type Flags, type FlagValue } from \"./model\";\n\n/** Marks the start of the generated block in AGENTS.md. */\nexport const AGENTS_BLOCK_START = \"<!-- genesis-features:start -->\";\n/** Marks the end of the generated block in AGENTS.md. */\nexport const AGENTS_BLOCK_END = \"<!-- genesis-features:end -->\";\n/** Marks the start of the generated marketing block (e.g. in README.md). */\nexport const MARKETING_BLOCK_START = \"<!-- genesis-features:marketing:start -->\";\n/** Marks the end of the generated marketing block. */\nexport const MARKETING_BLOCK_END = \"<!-- genesis-features:marketing:end -->\";\n\nexport interface GenerateOptions {\n /** The file the registry lives in, named in the \"generated from\" notes. Default `src/features.ts`. */\n source?: string;\n /** How agents run the CLI here, e.g. `genesis features` or `bun run features`. Default `genesis features`. */\n command?: string;\n /** Where the skill lives, named in the AGENTS.md pointer. Default `.claude/skills/features/SKILL.md`. */\n skill?: string | false;\n}\n\n/**\n * The registry as JSON, for tools that can't import TypeScript. Stable: no\n * timestamps, features in declaration order, so `check` can compare it. It is\n * also the record of every id ever used, which keeps ids permanent.\n *\n * @stability Beta\n */\nexport function toJson(features: Features, flags?: Flags, options: GenerateOptions = {}): string {\n const doc = {\n generatedFrom: options.source ?? \"src/features.ts\",\n features: toRecords(features, flags),\n flags: flags ?? {},\n };\n return `${JSON.stringify(doc, null, 2)}\\n`;\n}\n\nfunction flagType(value: FlagValue): string {\n if (typeof value === \"boolean\") return \"boolean\";\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"number\") return Number.isInteger(value) ? \"integer\" : \"float\";\n return \"object\";\n}\n\n/** The schema an OpenFeature CLI flag manifest points at. */\nexport const OPENFEATURE_MANIFEST_SCHEMA =\n \"https://raw.githubusercontent.com/open-feature/cli/refs/heads/main/schema/v0/flag-manifest.json\";\n\n/**\n * The flags as an OpenFeature CLI flag manifest (`flags.json`), so\n * `openfeature generate` can make typed accessors from the same registry.\n *\n * @stability Beta\n */\nexport function toOpenFeatureManifest(flags: Flags, features?: Features): string {\n const manifest = {\n $schema: OPENFEATURE_MANIFEST_SCHEMA,\n flags: Object.fromEntries(\n Object.entries(flags).map(([key, flag]) => [\n key,\n {\n flagType: flagType(flag.default),\n defaultValue: flag.default,\n description: flag.description ?? `${flag.kind} flag for ${features?.[flag.feature]?.name ?? flag.feature}`,\n },\n ]),\n ),\n };\n return `${JSON.stringify(manifest, null, 2)}\\n`;\n}\n\nconst cell = (value: string) => value.replace(/\\|/g, \"\\\\|\").replace(/\\r?\\n/g, \" \");\n\n/**\n * The marker-delimited block for AGENTS.md: deliberately short. It points\n * agents at `find` and the skill and gives counts, never the whole list, so\n * AGENTS.md stays small however many features there are.\n *\n * @stability Beta\n */\nexport function toAgentsMarkdown(features: Features, flags?: Flags, options: GenerateOptions = {}): string {\n const source = options.source ?? \"src/features.ts\";\n const command = options.command ?? \"genesis features\";\n const skill = options.skill === undefined ? \".claude/skills/features/SKILL.md\" : options.skill;\n const records = toRecords(features, flags);\n const counts = FEATURE_STATUSES.map((s) => [s, records.filter((r) => r.status === s).length] as const)\n .filter(([, n]) => n > 0)\n .map(([s, n]) => `${n} ${s}`)\n .join(\", \");\n const flagCount = flags ? Object.keys(flags).length : 0;\n const lines = [\n AGENTS_BLOCK_START,\n \"## Features\",\n \"\",\n `Every feature is in \\`${source}\\`: ${records.length} features (${counts})${flagCount ? `, ${flagCount} flag${flagCount === 1 ? \"\" : \"s\"}` : \"\"}.`,\n \"\",\n `- Before adding UI, routes or flags, run \\`${command} find <term>\\` to see whether a feature already covers it.`,\n `- New work starts as an entry in \\`${source}\\`; then run \\`${command} build\\`. \\`${command} check\\` runs in CI.`,\n ...(skill ? [`- Finding, adding and retiring features: \\`${skill}\\`.`] : []),\n \"\",\n `Generated by \\`${command} build\\`. Don't edit this block.`,\n AGENTS_BLOCK_END,\n ];\n return lines.join(\"\\n\");\n}\n\n/** The public, shipped features a marketing page shows: visibility public, a tagline, live or beta. */\nexport function marketingRecords(features: Features): FeatureRecord[] {\n return toRecords(features)\n .filter((r) => r.visibility === \"public\" && r.tagline && (r.status === \"live\" || r.status === \"beta\"))\n .sort((a, b) => Number(Boolean(b.highlight)) - Number(Boolean(a.highlight)));\n}\n\n/**\n * A benefit-led feature list for a README or a marketing page: public, shipped\n * features with a tagline, highlights first, grouped by category.\n *\n * @stability Beta\n */\nexport function toMarketingMarkdown(features: Features, options: { heading?: string; source?: string } = {}): string {\n const records = marketingRecords(features);\n const lines = [MARKETING_BLOCK_START, `## ${options.heading ?? \"Features\"}`, \"\"];\n const highlights = records.filter((r) => r.highlight);\n for (const r of highlights) lines.push(`- **${cell(r.name)}** — ${cell(r.tagline!)}`);\n if (highlights.length) lines.push(\"\");\n const categories = [...new Set(records.filter((r) => !r.highlight).map((r) => r.category ?? \"More\"))];\n for (const category of categories) {\n lines.push(`### ${category}`, \"\");\n for (const r of records.filter((x) => !x.highlight && (x.category ?? \"More\") === category)) {\n lines.push(`- **${cell(r.name)}**${r.status === \"beta\" ? \" (beta)\" : \"\"} — ${cell(r.tagline!)}`);\n }\n lines.push(\"\");\n }\n lines.push(`<sub>Generated from \\`${options.source ?? \"src/features.ts\"}\\`.</sub>`, MARKETING_BLOCK_END);\n return lines.join(\"\\n\");\n}\n\n/** Thrown when a generated block's markers are broken: one is missing, repeated or out of order. */\nexport class BrokenBlockError extends Error {\n constructor(start: string) {\n super(`The generated block's markers are broken (${start} and its end marker must each appear once, in order). Fix them by hand, or delete both and the block between them.`);\n this.name = \"BrokenBlockError\";\n }\n}\n\nconst count = (doc: string, marker: string) => doc.split(marker).length - 1;\n\n/**\n * The block between `start` and `end` inside `doc`, markers included, or null\n * when there is none. Throws {@link BrokenBlockError} when only one marker is\n * there, or either is repeated or out of order, rather than guess where the\n * block ends and wipe the text after it.\n */\nexport function readBlock(doc: string, start: string, end: string): string | null {\n const starts = count(doc, start);\n const ends = count(doc, end);\n if (starts === 0 && ends === 0) return null;\n const from = doc.indexOf(start);\n const to = doc.indexOf(end);\n if (starts !== 1 || ends !== 1 || to < from) throw new BrokenBlockError(start);\n return doc.slice(from, to + end.length);\n}\n\n/**\n * `doc` with the block between `start` and `end` replaced by `block`, or with\n * `block` appended when it has none yet. Everything outside the markers is\n * left as it was.\n */\nexport function replaceBlock(doc: string, block: string, start: string, end: string): string {\n const current = readBlock(doc, start, end);\n if (current !== null) return doc.replace(current, () => block);\n const base = doc.length === 0 || doc.endsWith(\"\\n\") ? doc : `${doc}\\n`;\n return `${base}${base.length ? \"\\n\" : \"\"}${block}\\n`;\n}\n\n/** The generated AGENTS.md block inside `doc`, or null. */\nexport const readAgentsBlock = (doc: string) => readBlock(doc, AGENTS_BLOCK_START, AGENTS_BLOCK_END);\n\n/**\n * `doc` with its generated AGENTS.md block replaced by `block`, or with\n * `block` appended when it has none yet.\n *\n * @stability Beta\n */\nexport const replaceAgentsBlock = (doc: string, block: string) => replaceBlock(doc, block, AGENTS_BLOCK_START, AGENTS_BLOCK_END);\n\n/**\n * The agent skill for working with the registry, written to\n * `.claude/skills/features/SKILL.md` by `genesis features build`. `outputs`\n * names what the build writes in this repo, so the skill never claims a file\n * the repo turned off.\n *\n * @stability Beta\n */\nexport function toSkillMarkdown(options: GenerateOptions & { outputs?: readonly string[] } = {}): string {\n const source = options.source ?? \"src/features.ts\";\n const command = options.command ?? \"genesis features\";\n const outputs = options.outputs ?? [\"the AGENTS.md block\", \"features.json\", \"this skill\"];\n return `---\nname: features\ndescription: Find, add, change and retire this repo's features in ${source}, and their flags. Use before adding UI, a route, a server function or a flag, when someone asks what the product does, or when shipping, deprecating or removing something.\n---\n\n<!-- Generated by \\`${command} build\\`. Don't edit; it is rewritten. -->\n\n# Features\n\n\\`${source}\\` is the one list of what this product does. Running code imports it, and\n\\`${command} build\\` generates the rest from it: ${outputs.join(\", \")}.\n\n## Find: reuse, then extend, then invent\n- \\`${command} find <term>\\` searches ids, aliases, names, keywords, summaries, import paths, slots\n and code paths; \\`--platform\\`, \\`--kind\\`, \\`--layer\\` (the owning package's layer) and\n \\`--status\\` narrow it (an empty term lists all that pass). Run it before building anything\n new, in this order:\n 1. **Reuse**: a feature already does it. Use it as is, configured through its \\`slots\\`.\n 2. **Extend**: one is close. Fill a slot, or add a variant with \\`extends: <id>\\`.\n 3. **Invent**: nothing is close. Add an entry first (an \\`idea\\` is enough), then build.\n\n## Add\n1. Add an entry to \\`${source}\\`. The key is the id: lowercase, permanent, never reused.\n Required: \\`name\\`, \\`summary\\` (internal, one sentence), \\`status\\`, \\`owner\\`, \\`apps\\`, \\`audience\\`.\n - \\`idea\\`: captured, not agreed. Nothing else is required; add \\`keywords\\` so \\`find\\` matches it.\n - \\`planned\\` needs a \\`horizon\\` (now, next, later). No dates on the roadmap.\n - \\`building\\`: set \\`claimedBy\\` to your name or session while you work on it.\n - \\`beta\\` and \\`live\\` need \\`acceptance\\`: one testable sentence each. Tag the tests that prove\n them with \\`@feat:<id>\\` in a comment or the test name.\n - \\`links.code\\`: the files or folders that implement it. \\`check\\` fails when one is missing.\n - \\`visibility\\` (internal, customer, public, client:<name>) and \\`access\\` (\"all\" or { plan }).\n Paid access is \\`access\\`, never a flag. The id is the billing entitlement's lookup key.\n - For a public page: \\`tagline\\` (the customer benefit), \\`category\\`, \\`media\\`, \\`highlight\\`.\n - For reuse: \\`kind\\` (token, element, pattern, layout, hook, provider, block, service, tool;\n \\`layer\\` is its deprecated name, read until the next major),\n \\`platforms\\` (status per platform when it differs), \\`entry\\` (what to import, per platform),\n \\`keywords\\`, \\`slots\\`, \\`extends\\` (the feature this is a variant of), \\`requires\\` (a beta or\n live feature can't require an idea, a planned or a retired one) and \\`contributes\\`.\n2. Flags go in the flags registry with \\`feature: <id>\\`. One flag per feature; a second needs a\n \\`splitReason\\`. \\`release\\` and \\`experiment\\` flags need \\`expires\\`, \\`ops\\` flags a \\`runbook\\`.\n Read flags only through the typed accessor with a literal key, never a computed one.\n3. Run \\`${command} build\\` and commit what it writes. Tag the changeset (a \\`Features: <id>\\` line in\n its body) or the PR (a \\`feature:<id>\\` label).\n\n## Change\n- Move \\`status\\` as it ships: idea, planned, building, beta, live, deprecated, retired. \\`check\\` warns\n when an idea or a planned feature already has shipped work tagged with it (a changeset, or with \\`--prs\\` a merged PR).\n- Set \\`reviewedAt\\` (today) whenever you check an entry against the product; \\`check\\` warns after 90 days.\n- Rename by giving the feature a new id and putting the old one in \\`aliases\\`. Never delete an id once a\n feature is being built; an \\`idea\\` or \\`planned\\` entry (never shipped) may be removed outright, for\n example when a backlog moves to a planning repo. Aliases are never removed.\n\n## Retire\n1. Remove the code first: the UI, routes, server functions and tests.\n2. Then remove its flags from the flags registry (the code that read them is gone, so \\`check\\`\n would flag them as unused).\n3. Set \\`status: \"retired\"\\`, keep the entry, and drop \\`links.code\\` paths that no longer exist.\n4. Run \\`${command} build\\` and \\`${command} check\\`.\n`;\n}\n"]}
@@ -1,52 +0,0 @@
1
- // src/graph.ts
2
- function requiresProblems(nodes, options) {
3
- const { skip = /* @__PURE__ */ new Set() } = options;
4
- const problems = [];
5
- for (const [id, node] of Object.entries(nodes)) {
6
- if (skip.has(id)) continue;
7
- for (const req of node.requires ?? []) {
8
- const problem = requirementProblem(nodes, id, req, options);
9
- if (problem) problems.push(problem);
10
- }
11
- }
12
- return [...problems, ...cycleProblems(nodes, skip)];
13
- }
14
- function requirementProblem(nodes, id, req, options) {
15
- const known = options.isKnown ?? ((r) => Object.hasOwn(nodes, r));
16
- if (req === id) return `${id}.requires: a ${options.noun} can't require itself`;
17
- if (!known(req)) return `${id}.requires: ${options.unknown ? options.unknown(req, id) : `"${req}" is not a ${options.noun}`}`;
18
- return void 0;
19
- }
20
- function cycleProblems(nodes, skip = /* @__PURE__ */ new Set()) {
21
- const has = (id) => Object.hasOwn(nodes, id);
22
- const problems = [];
23
- const state = /* @__PURE__ */ new Map();
24
- const visit = (id, path) => {
25
- state.set(id, "open");
26
- if (skip.has(id)) return;
27
- for (const req of nodes[id]?.requires ?? []) {
28
- if (!has(req) || req === id) continue;
29
- if (state.get(req) === "open") problems.push(`${id}.requires: a cycle: ${[...path.slice(path.indexOf(req)), id, req].join(" \u2192 ")}`);
30
- else if (!state.has(req)) visit(req, [...path, id]);
31
- }
32
- state.set(id, "done");
33
- };
34
- for (const id of Object.keys(nodes)) if (!state.has(id)) visit(id, []);
35
- return problems;
36
- }
37
- function dependencyOrder(nodes) {
38
- const order = [];
39
- const seen = /* @__PURE__ */ new Set();
40
- const visit = (id) => {
41
- if (seen.has(id)) return;
42
- seen.add(id);
43
- for (const req of nodes[id]?.requires ?? []) if (Object.hasOwn(nodes, req)) visit(req);
44
- order.push(id);
45
- };
46
- for (const id of Object.keys(nodes)) visit(id);
47
- return order;
48
- }
49
-
50
- export { cycleProblems, dependencyOrder, requirementProblem, requiresProblems };
51
- //# sourceMappingURL=chunk-VYUX7VAX.js.map
52
- //# sourceMappingURL=chunk-VYUX7VAX.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graph.ts"],"names":[],"mappings":";AA6BO,SAAS,gBAAA,CAAiB,OAA+C,OAAA,EAA4C;AAC1H,EAAA,MAAM,EAAE,IAAA,mBAAO,IAAI,GAAA,IAAc,GAAI,OAAA;AACrC,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,KAAA,MAAW,CAAC,EAAA,EAAI,IAAI,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC9C,IAAA,IAAI,IAAA,CAAK,GAAA,CAAI,EAAE,CAAA,EAAG;AAClB,IAAA,KAAA,MAAW,GAAA,IAAO,IAAA,CAAK,QAAA,IAAY,EAAC,EAAG;AACrC,MAAA,MAAM,OAAA,GAAU,kBAAA,CAAmB,KAAA,EAAO,EAAA,EAAI,KAAK,OAAO,CAAA;AAC1D,MAAA,IAAI,OAAA,EAAS,QAAA,CAAS,IAAA,CAAK,OAAO,CAAA;AAAA,IACpC;AAAA,EACF;AACA,EAAA,OAAO,CAAC,GAAG,QAAA,EAAU,GAAG,aAAA,CAAc,KAAA,EAAO,IAAI,CAAC,CAAA;AACpD;AAGO,SAAS,kBAAA,CACd,KAAA,EACA,EAAA,EACA,GAAA,EACA,OAAA,EACoB;AACpB,EAAA,MAAM,KAAA,GAAQ,QAAQ,OAAA,KAAY,CAAC,MAAc,MAAA,CAAO,MAAA,CAAO,OAAO,CAAC,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A,WAAA,IACzH,CAAC,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA,EAAG,KAAA,CAAM,GAAA,EAAK,CAAC,GAAG,IAAA,EAAM,EAAE,CAAC,CAAA;AAAA,IACpD;AACA,IAAA,KAAA,CAAM,GAAA,CAAI,IAAI,MAAM,CAAA;AAAA,EACtB,CAAA;AACA,EAAA,KAAA,MAAW,EAAA,IAAM,MAAA,CAAO,IAAA,CAAK,KAAK,GAAG,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,EAAE,CAAA,EAAG,KAAA,CAAM,EAAA,EAAI,EAAE,CAAA;AACrE,EAAA,OAAO,QAAA;AACT;AAOO,SAAS,gBAAgB,KAAA,EAAyD;AACvF,EAAA,MAAM,QAAkB,EAAC;AACzB,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,MAAM,KAAA,GAAQ,CAAC,EAAA,KAAe;AAC5B,IAAA,IAAI,IAAA,CAAK,GAAA,CAAI,EAAE,CAAA,EAAG;AAClB,IAAA,IAAA,CAAK,IAAI,EAAE,CAAA;AACX,IAAA,KAAA,MAAW,GAAA,IAAO,KAAA,CAAM,EAAE,CAAA,EAAG,YAAY,EAAC,EAAG,IAAI,MAAA,CAAO,MAAA,CAAO,KAAA,EAAO,GAAG,CAAA,QAAS,GAAG,CAAA;AACrF,IAAA,KAAA,CAAM,KAAK,EAAE,CAAA;AAAA,EACf,CAAA;AACA,EAAA,KAAA,MAAW,MAAM,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,QAAS,EAAE,CAAA;AAC7C,EAAA,OAAO,KAAA;AACT","file":"chunk-VYUX7VAX.js","sourcesContent":["/**\n * The `requires` graph checks shared by the feature registry\n * (`defineFeatures`) and blocks (`resolveBlocks`). No zod here: blocks import\n * this from a platform-neutral entry that ships to phones.\n */\n\n/** A node with the ids it needs. */\nexport interface RequiresNode {\n readonly requires?: readonly string[];\n}\n\nexport interface RequiresProblemsOptions {\n /** What a node is called in messages: `feature` or `block`. */\n noun: string;\n /** Whether an id may be required. Default: it is a node of the graph. */\n isKnown?: (id: string) => boolean;\n /** The message for a requirement `isKnown` refuses. Default `\"x\" is not a <noun>`. */\n unknown?: (req: string, id: string) => string;\n /** Nodes already reported invalid: their edges can't be trusted, so they are skipped. */\n skip?: ReadonlySet<string>;\n}\n\n/**\n * Self-requirements, unknown requirements and cycles through `requires`, as\n * problem strings (`a.requires: …`). Each cycle is reported once, from where\n * the depth-first search found it: `a.requires: a cycle: a → b → a`.\n *\n * @stability Beta\n */\nexport function requiresProblems(nodes: Readonly<Record<string, RequiresNode>>, options: RequiresProblemsOptions): string[] {\n const { skip = new Set<string>() } = options;\n const problems: string[] = [];\n for (const [id, node] of Object.entries(nodes)) {\n if (skip.has(id)) continue;\n for (const req of node.requires ?? []) {\n const problem = requirementProblem(nodes, id, req, options);\n if (problem) problems.push(problem);\n }\n }\n return [...problems, ...cycleProblems(nodes, skip)];\n}\n\n/** One requirement's problem (itself, or an unknown id), or undefined when it is fine. @stability Beta */\nexport function requirementProblem(\n nodes: Readonly<Record<string, RequiresNode>>,\n id: string,\n req: string,\n options: RequiresProblemsOptions,\n): string | undefined {\n const known = options.isKnown ?? ((r: string) => Object.hasOwn(nodes, r));\n if (req === id) return `${id}.requires: a ${options.noun} can't require itself`;\n if (!known(req)) return `${id}.requires: ${options.unknown ? options.unknown(req, id) : `\"${req}\" is not a ${options.noun}`}`;\n return undefined;\n}\n\n/** Cycles through `requires`, each reported once, from where the depth-first search found it. @stability Beta */\nexport function cycleProblems(nodes: Readonly<Record<string, RequiresNode>>, skip: ReadonlySet<string> = new Set()): string[] {\n const has = (id: string) => Object.hasOwn(nodes, id);\n const problems: string[] = [];\n const state = new Map<string, \"open\" | \"done\">();\n const visit = (id: string, path: string[]): void => {\n state.set(id, \"open\");\n if (skip.has(id)) return;\n for (const req of nodes[id]?.requires ?? []) {\n if (!has(req) || req === id) continue;\n if (state.get(req) === \"open\") problems.push(`${id}.requires: a cycle: ${[...path.slice(path.indexOf(req)), id, req].join(\" → \")}`);\n else if (!state.has(req)) visit(req, [...path, id]);\n }\n state.set(id, \"done\");\n };\n for (const id of Object.keys(nodes)) if (!state.has(id)) visit(id, []);\n return problems;\n}\n\n/**\n * The ids in dependency order (what a node requires comes first), ties kept\n * in the given order. Requirements outside `nodes` are ignored. Assumes no\n * cycles ({@link requiresProblems} reports them).\n */\nexport function dependencyOrder(nodes: Readonly<Record<string, RequiresNode>>): string[] {\n const order: string[] = [];\n const seen = new Set<string>();\n const visit = (id: string) => {\n if (seen.has(id)) return;\n seen.add(id);\n for (const req of nodes[id]?.requires ?? []) if (Object.hasOwn(nodes, req)) visit(req);\n order.push(id);\n };\n for (const id of Object.keys(nodes)) visit(id);\n return order;\n}\n"]}