specdx 0.1.0-alpha.1 → 0.1.0-alpha.3

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 (59) hide show
  1. package/dist/chunk-ADUPKQBA.js +260 -0
  2. package/dist/chunk-ADUPKQBA.js.map +1 -0
  3. package/dist/chunk-KQKWPO7Y.js +203 -0
  4. package/dist/chunk-KQKWPO7Y.js.map +1 -0
  5. package/dist/graph-XJSNQ7B7.js +44 -0
  6. package/dist/graph-XJSNQ7B7.js.map +1 -0
  7. package/dist/index.js +873 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/lint-BOQDKP7A.js +326 -0
  10. package/dist/lint-BOQDKP7A.js.map +1 -0
  11. package/dist/main.js +132 -9
  12. package/dist/main.js.map +1 -1
  13. package/dist/validate-FFNJWR6V.js +32 -0
  14. package/dist/validate-FFNJWR6V.js.map +1 -0
  15. package/package.json +16 -6
  16. package/dist/commands/graph.d.ts +0 -19
  17. package/dist/commands/graph.d.ts.map +0 -1
  18. package/dist/commands/graph.js +0 -36
  19. package/dist/commands/graph.js.map +0 -1
  20. package/dist/commands/init.d.ts +0 -26
  21. package/dist/commands/init.d.ts.map +0 -1
  22. package/dist/commands/init.js +0 -116
  23. package/dist/commands/init.js.map +0 -1
  24. package/dist/commands/init.test.d.ts +0 -2
  25. package/dist/commands/init.test.d.ts.map +0 -1
  26. package/dist/commands/init.test.js +0 -42
  27. package/dist/commands/init.test.js.map +0 -1
  28. package/dist/commands/lint.d.ts +0 -39
  29. package/dist/commands/lint.d.ts.map +0 -1
  30. package/dist/commands/lint.js +0 -66
  31. package/dist/commands/lint.js.map +0 -1
  32. package/dist/commands/lint.test.d.ts +0 -2
  33. package/dist/commands/lint.test.d.ts.map +0 -1
  34. package/dist/commands/lint.test.js +0 -61
  35. package/dist/commands/lint.test.js.map +0 -1
  36. package/dist/commands/validate.d.ts +0 -19
  37. package/dist/commands/validate.d.ts.map +0 -1
  38. package/dist/commands/validate.js +0 -25
  39. package/dist/commands/validate.js.map +0 -1
  40. package/dist/formatters/github.d.ts +0 -3
  41. package/dist/formatters/github.d.ts.map +0 -1
  42. package/dist/formatters/github.js +0 -10
  43. package/dist/formatters/github.js.map +0 -1
  44. package/dist/formatters/json.d.ts +0 -3
  45. package/dist/formatters/json.d.ts.map +0 -1
  46. package/dist/formatters/json.js +0 -4
  47. package/dist/formatters/json.js.map +0 -1
  48. package/dist/formatters/pretty.d.ts +0 -3
  49. package/dist/formatters/pretty.d.ts.map +0 -1
  50. package/dist/formatters/pretty.js +0 -11
  51. package/dist/formatters/pretty.js.map +0 -1
  52. package/dist/index.d.ts +0 -3
  53. package/dist/index.d.ts.map +0 -1
  54. package/dist/main.d.ts +0 -3
  55. package/dist/main.d.ts.map +0 -1
  56. package/dist/shared-args.d.ts +0 -18
  57. package/dist/shared-args.d.ts.map +0 -1
  58. package/dist/shared-args.js +0 -10
  59. package/dist/shared-args.js.map +0 -1
@@ -0,0 +1,260 @@
1
+ import {
2
+ validateConfig,
3
+ validateSpec
4
+ } from "./chunk-KQKWPO7Y.js";
5
+
6
+ // ../core/dist/config.js
7
+ import { readFile } from "fs/promises";
8
+ import { join, dirname } from "path";
9
+ import { parse as parseYaml } from "yaml";
10
+ var ConfigError = class extends Error {
11
+ errors;
12
+ constructor(message, errors) {
13
+ super(message);
14
+ this.errors = errors;
15
+ this.name = "ConfigError";
16
+ }
17
+ };
18
+ var CONFIG_FILENAME = "spec.config.yaml";
19
+ async function loadConfig(filePath, searchFrom) {
20
+ const resolvedPath = filePath ?? await findConfig(searchFrom ?? process.cwd());
21
+ if (!resolvedPath) {
22
+ throw new ConfigError(`No ${CONFIG_FILENAME} found. Run 'sdx init' to create one.`);
23
+ }
24
+ let raw;
25
+ try {
26
+ raw = await readFile(resolvedPath, "utf-8");
27
+ } catch {
28
+ throw new ConfigError(`Cannot read config file: ${resolvedPath}`);
29
+ }
30
+ let data;
31
+ try {
32
+ data = parseYaml(raw);
33
+ } catch (err) {
34
+ throw new ConfigError(`Invalid YAML in ${resolvedPath}: ${err.message}`);
35
+ }
36
+ const result = validateConfig(data);
37
+ if (!result.valid) {
38
+ throw new ConfigError(`Invalid config in ${resolvedPath}`, result.errors ?? void 0);
39
+ }
40
+ return data;
41
+ }
42
+ async function findConfig(from) {
43
+ let dir = from;
44
+ while (true) {
45
+ const candidate = join(dir, CONFIG_FILENAME);
46
+ try {
47
+ await readFile(candidate, "utf-8");
48
+ return candidate;
49
+ } catch {
50
+ const parent = dirname(dir);
51
+ if (parent === dir)
52
+ return void 0;
53
+ dir = parent;
54
+ }
55
+ }
56
+ }
57
+
58
+ // ../core/dist/parser.js
59
+ import { readFile as readFile2 } from "fs/promises";
60
+ import { extname } from "path";
61
+ import * as grayMatterNs from "gray-matter";
62
+ import { parse as parseYaml2 } from "yaml";
63
+ import { unified } from "unified";
64
+ import remarkParse from "remark-parse";
65
+ import { visit } from "unist-util-visit";
66
+ var matter = grayMatterNs.default ?? grayMatterNs;
67
+ var ParseError = class extends Error {
68
+ constructor(message) {
69
+ super(message);
70
+ this.name = "ParseError";
71
+ }
72
+ };
73
+ async function parseSpec(filePath) {
74
+ let raw;
75
+ try {
76
+ raw = await readFile2(filePath, "utf-8");
77
+ } catch {
78
+ throw new ParseError(`Cannot read spec file: ${filePath}`);
79
+ }
80
+ const ext = extname(filePath).toLowerCase();
81
+ if (ext === ".yaml" || ext === ".yml") {
82
+ return parseYamlSpec(filePath, raw);
83
+ }
84
+ return parseMarkdownSpec(filePath, raw);
85
+ }
86
+ function parseMarkdownSpec(filePath, raw) {
87
+ const { data, content } = matter(raw);
88
+ const sections = extractSections(content);
89
+ const frontmatter = data;
90
+ const specType = frontmatter.type;
91
+ let valid = false;
92
+ let validationErrors = null;
93
+ if (specType) {
94
+ const result = validateSpec(specType, data);
95
+ valid = result.valid;
96
+ validationErrors = result.errors;
97
+ }
98
+ return { filePath, frontmatter, content, sections, valid, validationErrors };
99
+ }
100
+ function parseYamlSpec(filePath, raw) {
101
+ let data;
102
+ try {
103
+ data = parseYaml2(raw);
104
+ } catch (err) {
105
+ throw new ParseError(`Invalid YAML in ${filePath}: ${err.message}`);
106
+ }
107
+ const frontmatter = data;
108
+ const specType = frontmatter.type;
109
+ let valid = false;
110
+ let validationErrors = null;
111
+ if (specType) {
112
+ const result = validateSpec(specType, data);
113
+ valid = result.valid;
114
+ validationErrors = result.errors;
115
+ }
116
+ return { filePath, frontmatter, content: "", sections: [], valid, validationErrors };
117
+ }
118
+ function extractSections(markdown) {
119
+ const tree = unified().use(remarkParse).parse(markdown);
120
+ const sections = [];
121
+ visit(tree, "heading", (node) => {
122
+ if (node.depth === 2) {
123
+ const text = node.children.filter((c) => c.type === "text").map((c) => c.value).join("");
124
+ if (text)
125
+ sections.push(text);
126
+ }
127
+ });
128
+ return sections;
129
+ }
130
+
131
+ // ../core/dist/graph.js
132
+ var GraphError = class extends Error {
133
+ constructor(message) {
134
+ super(message);
135
+ this.name = "GraphError";
136
+ }
137
+ };
138
+ function buildGraph(config) {
139
+ const specNames = Object.keys(config.specs);
140
+ const adjacency = /* @__PURE__ */ new Map();
141
+ const reverseAdj = /* @__PURE__ */ new Map();
142
+ const edges = [];
143
+ for (const name of specNames) {
144
+ adjacency.set(name, []);
145
+ reverseAdj.set(name, []);
146
+ }
147
+ for (const [name, entry] of Object.entries(config.specs)) {
148
+ if (!entry.requires)
149
+ continue;
150
+ for (const dep of entry.requires) {
151
+ if (!adjacency.has(dep)) {
152
+ throw new GraphError(`Spec "${name}" requires "${dep}", which does not exist in the config.`);
153
+ }
154
+ adjacency.get(dep).push(name);
155
+ reverseAdj.get(name).push(dep);
156
+ edges.push({ from: dep, to: name });
157
+ }
158
+ }
159
+ const inDegree = /* @__PURE__ */ new Map();
160
+ for (const name of specNames)
161
+ inDegree.set(name, reverseAdj.get(name).length);
162
+ const queue = [];
163
+ for (const [name, degree] of inDegree) {
164
+ if (degree === 0)
165
+ queue.push(name);
166
+ }
167
+ const sorted = [];
168
+ while (queue.length > 0) {
169
+ const node = queue.shift();
170
+ sorted.push(node);
171
+ for (const neighbor of adjacency.get(node)) {
172
+ const newDegree = inDegree.get(neighbor) - 1;
173
+ inDegree.set(neighbor, newDegree);
174
+ if (newDegree === 0)
175
+ queue.push(neighbor);
176
+ }
177
+ }
178
+ if (sorted.length !== specNames.length) {
179
+ const remaining = specNames.filter((n) => !sorted.includes(n));
180
+ throw new GraphError(`Circular dependency detected involving: ${remaining.join(", ")}`);
181
+ }
182
+ return {
183
+ nodes: specNames,
184
+ edges,
185
+ topologicalSort: () => [...sorted],
186
+ getDownstream(nodeId) {
187
+ const visited = /* @__PURE__ */ new Set();
188
+ const stack = [nodeId];
189
+ while (stack.length > 0) {
190
+ const current = stack.pop();
191
+ for (const neighbor of adjacency.get(current) ?? []) {
192
+ if (!visited.has(neighbor)) {
193
+ visited.add(neighbor);
194
+ stack.push(neighbor);
195
+ }
196
+ }
197
+ }
198
+ return [...visited];
199
+ },
200
+ getUpstream(nodeId) {
201
+ const visited = /* @__PURE__ */ new Set();
202
+ const stack = [nodeId];
203
+ while (stack.length > 0) {
204
+ const current = stack.pop();
205
+ for (const dep of reverseAdj.get(current) ?? []) {
206
+ if (!visited.has(dep)) {
207
+ visited.add(dep);
208
+ stack.push(dep);
209
+ }
210
+ }
211
+ }
212
+ return [...visited];
213
+ }
214
+ };
215
+ }
216
+
217
+ // ../core/dist/glob.js
218
+ import { glob } from "tinyglobby";
219
+ import { join as join2, isAbsolute } from "path";
220
+ async function resolveGlob(pattern, baseDir) {
221
+ const absolutePattern = isAbsolute(pattern) ? pattern : join2(baseDir, pattern);
222
+ return glob([absolutePattern], { absolute: true });
223
+ }
224
+
225
+ // ../core/dist/logger.js
226
+ import { createConsola } from "consola";
227
+ function createLogger(options) {
228
+ let level = 3;
229
+ if (options?.quiet)
230
+ level = 1;
231
+ if (options?.verbose)
232
+ level = 4;
233
+ return createConsola({ level });
234
+ }
235
+
236
+ // ../core/dist/tokens.js
237
+ import { encodingForModel } from "js-tiktoken";
238
+
239
+ // src/shared-args.ts
240
+ var sharedArgs = {
241
+ quiet: { type: "boolean", description: "Suppress info output", alias: ["q"] },
242
+ verbose: { type: "boolean", description: "Enable debug output", alias: ["V"] },
243
+ format: {
244
+ type: "string",
245
+ description: "Output format (pretty, json, github)",
246
+ default: "pretty"
247
+ }
248
+ };
249
+
250
+ export {
251
+ ConfigError,
252
+ loadConfig,
253
+ parseSpec,
254
+ GraphError,
255
+ buildGraph,
256
+ resolveGlob,
257
+ createLogger,
258
+ sharedArgs
259
+ };
260
+ //# sourceMappingURL=chunk-ADUPKQBA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../core/src/config.ts","../../core/src/parser.ts","../../core/src/graph.ts","../../core/src/glob.ts","../../core/src/logger.ts","../../core/src/tokens.ts","../src/shared-args.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join, dirname } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport { validateConfig, type SdxConfig } from \"@sdx/schema\";\n\nexport class ConfigError extends Error {\n constructor(\n message: string,\n public readonly errors?: unknown[],\n ) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n\nconst CONFIG_FILENAME = \"spec.config.yaml\";\n\nexport async function loadConfig(filePath?: string, searchFrom?: string): Promise<SdxConfig> {\n const resolvedPath = filePath ?? (await findConfig(searchFrom ?? process.cwd()));\n if (!resolvedPath) {\n throw new ConfigError(`No ${CONFIG_FILENAME} found. Run 'sdx init' to create one.`);\n }\n\n let raw: string;\n try {\n raw = await readFile(resolvedPath, \"utf-8\");\n } catch {\n throw new ConfigError(`Cannot read config file: ${resolvedPath}`);\n }\n\n let data: Record<string, unknown>;\n try {\n data = parseYaml(raw) as Record<string, unknown>;\n } catch (err) {\n throw new ConfigError(`Invalid YAML in ${resolvedPath}: ${(err as Error).message}`);\n }\n\n const result = validateConfig(data);\n if (!result.valid) {\n throw new ConfigError(`Invalid config in ${resolvedPath}`, result.errors ?? undefined);\n }\n\n return data as unknown as SdxConfig;\n}\n\nasync function findConfig(from: string): Promise<string | undefined> {\n let dir = from;\n while (true) {\n const candidate = join(dir, CONFIG_FILENAME);\n try {\n await readFile(candidate, \"utf-8\");\n return candidate;\n } catch {\n const parent = dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport { extname } from \"node:path\";\nimport * as grayMatterNs from \"gray-matter\";\nimport { parse as parseYaml } from \"yaml\";\nimport { unified } from \"unified\";\nimport remarkParse from \"remark-parse\";\nimport { visit } from \"unist-util-visit\";\nimport { validateSpec, type ValidationResult } from \"@sdx/schema\";\nimport type { BaseSpec, SpecType } from \"@sdx/schema\";\n\n// gray-matter is CJS — its callable default is exposed via .default in an ESM context\ntype GrayMatterFn = (input: string) => { data: Record<string, unknown>; content: string };\nconst matter = ((grayMatterNs as unknown as { default?: GrayMatterFn }).default ??\n (grayMatterNs as unknown as GrayMatterFn)) as GrayMatterFn;\n\nexport class ParseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ParseError\";\n }\n}\n\nexport interface ParsedSpec {\n filePath: string;\n frontmatter: BaseSpec & Record<string, unknown>;\n content: string;\n sections: string[];\n valid: boolean;\n validationErrors: ValidationResult[\"errors\"];\n}\n\nexport async function parseSpec(filePath: string): Promise<ParsedSpec> {\n let raw: string;\n try {\n raw = await readFile(filePath, \"utf-8\");\n } catch {\n throw new ParseError(`Cannot read spec file: ${filePath}`);\n }\n\n const ext = extname(filePath).toLowerCase();\n if (ext === \".yaml\" || ext === \".yml\") {\n return parseYamlSpec(filePath, raw);\n }\n return parseMarkdownSpec(filePath, raw);\n}\n\nfunction parseMarkdownSpec(filePath: string, raw: string): ParsedSpec {\n const { data, content } = matter(raw);\n const sections = extractSections(content);\n const frontmatter = data as BaseSpec & Record<string, unknown>;\n const specType = frontmatter.type as SpecType | undefined;\n\n let valid = false;\n let validationErrors: ValidationResult[\"errors\"] = null;\n if (specType) {\n const result = validateSpec(specType, data);\n valid = result.valid;\n validationErrors = result.errors;\n }\n\n return { filePath, frontmatter, content, sections, valid, validationErrors };\n}\n\nfunction parseYamlSpec(filePath: string, raw: string): ParsedSpec {\n let data: Record<string, unknown>;\n try {\n data = parseYaml(raw) as Record<string, unknown>;\n } catch (err) {\n throw new ParseError(`Invalid YAML in ${filePath}: ${(err as Error).message}`);\n }\n\n const frontmatter = data as BaseSpec & Record<string, unknown>;\n const specType = frontmatter.type as SpecType | undefined;\n\n let valid = false;\n let validationErrors: ValidationResult[\"errors\"] = null;\n if (specType) {\n const result = validateSpec(specType, data);\n valid = result.valid;\n validationErrors = result.errors;\n }\n\n return { filePath, frontmatter, content: \"\", sections: [], valid, validationErrors };\n}\n\nfunction extractSections(markdown: string): string[] {\n const tree = unified().use(remarkParse).parse(markdown);\n const sections: string[] = [];\n\n visit(tree, \"heading\", (node: any) => {\n if (node.depth === 2) {\n const text = node.children\n .filter((c: any) => c.type === \"text\")\n .map((c: any) => c.value)\n .join(\"\");\n if (text) sections.push(text);\n }\n });\n\n return sections;\n}\n","import type { SdxConfig } from \"@sdx/schema\";\n\nexport class GraphError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"GraphError\";\n }\n}\n\nexport interface Edge {\n from: string;\n to: string;\n}\n\nexport interface DependencyGraph {\n nodes: string[];\n edges: Edge[];\n topologicalSort(): string[];\n getDownstream(nodeId: string): string[];\n getUpstream(nodeId: string): string[];\n}\n\nexport function buildGraph(config: SdxConfig): DependencyGraph {\n const specNames = Object.keys(config.specs);\n const adjacency = new Map<string, string[]>();\n const reverseAdj = new Map<string, string[]>();\n const edges: Edge[] = [];\n\n for (const name of specNames) {\n adjacency.set(name, []);\n reverseAdj.set(name, []);\n }\n\n for (const [name, entry] of Object.entries(config.specs)) {\n if (!entry.requires) continue;\n for (const dep of entry.requires) {\n if (!adjacency.has(dep)) {\n throw new GraphError(\n `Spec \"${name}\" requires \"${dep}\", which does not exist in the config.`,\n );\n }\n adjacency.get(dep)!.push(name);\n reverseAdj.get(name)!.push(dep);\n edges.push({ from: dep, to: name });\n }\n }\n\n // Kahn's algorithm for cycle detection + topological sort\n const inDegree = new Map<string, number>();\n for (const name of specNames) inDegree.set(name, reverseAdj.get(name)!.length);\n\n const queue: string[] = [];\n for (const [name, degree] of inDegree) {\n if (degree === 0) queue.push(name);\n }\n\n const sorted: string[] = [];\n while (queue.length > 0) {\n const node = queue.shift()!;\n sorted.push(node);\n for (const neighbor of adjacency.get(node)!) {\n const newDegree = inDegree.get(neighbor)! - 1;\n inDegree.set(neighbor, newDegree);\n if (newDegree === 0) queue.push(neighbor);\n }\n }\n\n if (sorted.length !== specNames.length) {\n const remaining = specNames.filter((n) => !sorted.includes(n));\n throw new GraphError(`Circular dependency detected involving: ${remaining.join(\", \")}`);\n }\n\n return {\n nodes: specNames,\n edges,\n topologicalSort: () => [...sorted],\n getDownstream(nodeId: string): string[] {\n const visited = new Set<string>();\n const stack = [nodeId];\n while (stack.length > 0) {\n const current = stack.pop()!;\n for (const neighbor of adjacency.get(current) ?? []) {\n if (!visited.has(neighbor)) {\n visited.add(neighbor);\n stack.push(neighbor);\n }\n }\n }\n return [...visited];\n },\n getUpstream(nodeId: string): string[] {\n const visited = new Set<string>();\n const stack = [nodeId];\n while (stack.length > 0) {\n const current = stack.pop()!;\n for (const dep of reverseAdj.get(current) ?? []) {\n if (!visited.has(dep)) {\n visited.add(dep);\n stack.push(dep);\n }\n }\n }\n return [...visited];\n },\n };\n}\n","import { glob } from \"tinyglobby\";\nimport { join, isAbsolute } from \"node:path\";\n\nexport async function resolveGlob(pattern: string, baseDir: string): Promise<string[]> {\n const absolutePattern = isAbsolute(pattern) ? pattern : join(baseDir, pattern);\n return glob([absolutePattern], { absolute: true });\n}\n","import { createConsola, type ConsolaInstance } from \"consola\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport interface LoggerOptions {\n quiet?: boolean;\n verbose?: boolean;\n}\n\nexport interface Logger extends ConsolaInstance {\n level: number;\n}\n\nexport function createLogger(options?: LoggerOptions): Logger {\n let level = 3; // info\n if (options?.quiet) level = 1; // only errors\n if (options?.verbose) level = 4; // debug\n return createConsola({ level }) as Logger;\n}\n","import { encodingForModel } from \"js-tiktoken\";\n\nlet encoder: ReturnType<typeof encodingForModel> | undefined;\n\nfunction getEncoder() {\n if (!encoder) encoder = encodingForModel(\"gpt-4o\");\n return encoder;\n}\n\nexport function countTokens(text: string): number {\n if (!text) return 0;\n return getEncoder().encode(text).length;\n}\n","export const sharedArgs = {\n quiet: { type: \"boolean\" as const, description: \"Suppress info output\", alias: [\"q\"] },\n verbose: { type: \"boolean\" as const, description: \"Enable debug output\", alias: [\"V\"] },\n format: {\n type: \"string\" as const,\n description: \"Output format (pretty, json, github)\",\n default: \"pretty\",\n },\n};\n"],"mappings":";;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,MAAM,eAAe;AAC9B,SAAS,SAAS,iBAAiB;AAG7B,IAAO,cAAP,cAA2B,MAAK;EAGlB;EAFlB,YACE,SACgB,QAAkB;AAElC,UAAM,OAAO;AAFG,SAAA,SAAA;AAGhB,SAAK,OAAO;EACd;;AAGF,IAAM,kBAAkB;AAExB,eAAsB,WAAW,UAAmB,YAAmB;AACrE,QAAM,eAAe,YAAa,MAAM,WAAW,cAAc,QAAQ,IAAG,CAAE;AAC9E,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,YAAY,MAAM,eAAe,uCAAuC;EACpF;AAEA,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,SAAS,cAAc,OAAO;EAC5C,QAAQ;AACN,UAAM,IAAI,YAAY,4BAA4B,YAAY,EAAE;EAClE;AAEA,MAAI;AACJ,MAAI;AACF,WAAO,UAAU,GAAG;EACtB,SAAS,KAAK;AACZ,UAAM,IAAI,YAAY,mBAAmB,YAAY,KAAM,IAAc,OAAO,EAAE;EACpF;AAEA,QAAM,SAAS,eAAe,IAAI;AAClC,MAAI,CAAC,OAAO,OAAO;AACjB,UAAM,IAAI,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F;","names":["readFile","parseYaml","readFile","parseYaml","join"]}
@@ -0,0 +1,203 @@
1
+ // ../schema/dist/sections.js
2
+ var REQUIRED_SECTIONS = {
3
+ prd: ["Problem Statement", "Goals", "Non-Goals", "Features", "Success Criteria"],
4
+ "technical-design": [
5
+ "Overview",
6
+ "Architecture",
7
+ "Data Model",
8
+ "API Design",
9
+ "Dependencies",
10
+ "Risks",
11
+ "Open Questions"
12
+ ],
13
+ "user-story": ["Description", "Acceptance Criteria", "Dependencies", "Notes"],
14
+ "test-plan": ["Scope", "Test Cases", "Coverage Matrix", "Edge Cases"],
15
+ adr: ["Context", "Decision", "Status", "Consequences"],
16
+ "api-contract": ["Endpoints", "Request/Response Schemas", "Auth", "Error Codes"]
17
+ };
18
+
19
+ // ../schema/dist/validator.js
20
+ import { Ajv as AjvClass } from "ajv";
21
+
22
+ // ../schema/dist/schemas/base-spec.json
23
+ var base_spec_default = {
24
+ $id: "base-spec",
25
+ $schema: "http://json-schema.org/draft-07/schema#",
26
+ type: "object",
27
+ properties: {
28
+ id: { type: "string", minLength: 1 },
29
+ type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract"] },
30
+ title: { type: "string", minLength: 1 },
31
+ status: { type: "string", enum: ["draft", "review", "approved", "superseded"] },
32
+ version: { type: "string" },
33
+ created: { type: "string", format: "date" },
34
+ updated: { type: "string", format: "date" },
35
+ authors: { type: "array", items: { type: "string" }, minItems: 1 },
36
+ tags: { type: "array", items: { type: "string" }, default: [] },
37
+ references: {
38
+ type: "array",
39
+ items: {
40
+ type: "object",
41
+ properties: {
42
+ id: { type: "string" },
43
+ relationship: { type: "string", enum: ["implemented-by", "decomposed-into", "depends-on", "supersedes", "related-to"] }
44
+ },
45
+ required: ["id", "relationship"],
46
+ additionalProperties: false
47
+ },
48
+ default: []
49
+ }
50
+ },
51
+ required: ["id", "type", "title", "status", "version", "created", "authors"],
52
+ additionalProperties: true
53
+ };
54
+
55
+ // ../schema/dist/schemas/config.json
56
+ var config_default = {
57
+ $id: "sdx-config",
58
+ $schema: "http://json-schema.org/draft-07/schema#",
59
+ type: "object",
60
+ properties: {
61
+ version: { type: "string" },
62
+ project: {
63
+ type: "object",
64
+ properties: {
65
+ name: { type: "string" },
66
+ description: { type: "string" }
67
+ },
68
+ additionalProperties: false
69
+ },
70
+ specs: {
71
+ type: "object",
72
+ additionalProperties: {
73
+ type: "object",
74
+ properties: {
75
+ path: { type: "string" },
76
+ type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract"] },
77
+ required: { type: "boolean", default: false },
78
+ requires: { type: "array", items: { type: "string" } }
79
+ },
80
+ required: ["path", "type"],
81
+ additionalProperties: false
82
+ }
83
+ },
84
+ lint: {
85
+ type: "object",
86
+ properties: {
87
+ extends: { type: "string", enum: ["minimal", "recommended", "strict"] },
88
+ rules: { type: "object" },
89
+ ignore: { type: "array", items: { type: "string" } }
90
+ },
91
+ additionalProperties: false
92
+ },
93
+ pack: { type: "object" },
94
+ diff: { type: "object" },
95
+ ci: { type: "object" }
96
+ },
97
+ required: ["version", "specs"],
98
+ additionalProperties: false
99
+ };
100
+
101
+ // ../schema/dist/schemas/prd.json
102
+ var prd_default = {
103
+ $id: "prd",
104
+ $schema: "http://json-schema.org/draft-07/schema#",
105
+ allOf: [
106
+ { $ref: "base-spec" },
107
+ { type: "object", properties: { type: { const: "prd" } }, required: ["type"] }
108
+ ]
109
+ };
110
+
111
+ // ../schema/dist/schemas/technical-design.json
112
+ var technical_design_default = {
113
+ $id: "technical-design",
114
+ $schema: "http://json-schema.org/draft-07/schema#",
115
+ allOf: [
116
+ { $ref: "base-spec" },
117
+ { type: "object", properties: { type: { const: "technical-design" } }, required: ["type"] }
118
+ ]
119
+ };
120
+
121
+ // ../schema/dist/schemas/user-story.json
122
+ var user_story_default = {
123
+ $id: "user-story",
124
+ $schema: "http://json-schema.org/draft-07/schema#",
125
+ allOf: [
126
+ { $ref: "base-spec" },
127
+ {
128
+ type: "object",
129
+ properties: {
130
+ type: { const: "user-story" },
131
+ story_id: { type: "string", minLength: 1 },
132
+ priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
133
+ estimate: { type: "string" }
134
+ },
135
+ required: ["type", "story_id", "priority", "estimate"]
136
+ }
137
+ ]
138
+ };
139
+
140
+ // ../schema/dist/schemas/test-plan.json
141
+ var test_plan_default = {
142
+ $id: "test-plan",
143
+ $schema: "http://json-schema.org/draft-07/schema#",
144
+ allOf: [
145
+ { $ref: "base-spec" },
146
+ { type: "object", properties: { type: { const: "test-plan" } }, required: ["type"] }
147
+ ]
148
+ };
149
+
150
+ // ../schema/dist/schemas/adr.json
151
+ var adr_default = {
152
+ $id: "adr",
153
+ $schema: "http://json-schema.org/draft-07/schema#",
154
+ allOf: [
155
+ { $ref: "base-spec" },
156
+ { type: "object", properties: { type: { const: "adr" } }, required: ["type"] }
157
+ ]
158
+ };
159
+
160
+ // ../schema/dist/schemas/api-contract.json
161
+ var api_contract_default = {
162
+ $id: "api-contract",
163
+ $schema: "http://json-schema.org/draft-07/schema#",
164
+ allOf: [
165
+ { $ref: "base-spec" },
166
+ { type: "object", properties: { type: { const: "api-contract" } }, required: ["type"] }
167
+ ]
168
+ };
169
+
170
+ // ../schema/dist/validator.js
171
+ import * as addFormatsNs from "ajv-formats";
172
+ var addFormats = addFormatsNs.default ?? addFormatsNs;
173
+ var ajv = new AjvClass({ allErrors: true, strict: true });
174
+ addFormats(ajv, ["date"]);
175
+ ajv.addSchema(base_spec_default);
176
+ var specValidators = {
177
+ prd: ajv.compile(prd_default),
178
+ "technical-design": ajv.compile(technical_design_default),
179
+ "user-story": ajv.compile(user_story_default),
180
+ "test-plan": ajv.compile(test_plan_default),
181
+ adr: ajv.compile(adr_default),
182
+ "api-contract": ajv.compile(api_contract_default)
183
+ };
184
+ var configValidator = ajv.compile(config_default);
185
+ function validateSpec(type, data) {
186
+ const validate = specValidators[type];
187
+ if (!validate) {
188
+ return { valid: false, errors: [{ message: `Unknown spec type: "${type}"` }] };
189
+ }
190
+ const valid = validate(data);
191
+ return { valid: !!valid, errors: valid ? null : validate.errors ?? null };
192
+ }
193
+ function validateConfig(data) {
194
+ const valid = configValidator(data);
195
+ return { valid: !!valid, errors: valid ? null : configValidator.errors ?? null };
196
+ }
197
+
198
+ export {
199
+ REQUIRED_SECTIONS,
200
+ validateSpec,
201
+ validateConfig
202
+ };
203
+ //# sourceMappingURL=chunk-KQKWPO7Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../schema/src/sections.ts","../../schema/src/validator.ts","../../schema/dist/schemas/base-spec.json","../../schema/dist/schemas/config.json","../../schema/dist/schemas/prd.json","../../schema/dist/schemas/technical-design.json","../../schema/dist/schemas/user-story.json","../../schema/dist/schemas/test-plan.json","../../schema/dist/schemas/adr.json","../../schema/dist/schemas/api-contract.json"],"sourcesContent":["import type { SpecType } from \"./types.js\";\n\nexport const REQUIRED_SECTIONS: Record<SpecType, string[]> = {\n prd: [\"Problem Statement\", \"Goals\", \"Non-Goals\", \"Features\", \"Success Criteria\"],\n \"technical-design\": [\n \"Overview\",\n \"Architecture\",\n \"Data Model\",\n \"API Design\",\n \"Dependencies\",\n \"Risks\",\n \"Open Questions\",\n ],\n \"user-story\": [\"Description\", \"Acceptance Criteria\", \"Dependencies\", \"Notes\"],\n \"test-plan\": [\"Scope\", \"Test Cases\", \"Coverage Matrix\", \"Edge Cases\"],\n adr: [\"Context\", \"Decision\", \"Status\", \"Consequences\"],\n \"api-contract\": [\"Endpoints\", \"Request/Response Schemas\", \"Auth\", \"Error Codes\"],\n};\n","import { Ajv as AjvClass, type ErrorObject } from \"ajv\";\nimport type { SpecType } from \"./types.js\";\n\nimport baseSpecSchema from \"./schemas/base-spec.json\" with { type: \"json\" };\nimport configSchema from \"./schemas/config.json\" with { type: \"json\" };\nimport prdSchema from \"./schemas/prd.json\" with { type: \"json\" };\nimport technicalDesignSchema from \"./schemas/technical-design.json\" with { type: \"json\" };\nimport userStorySchema from \"./schemas/user-story.json\" with { type: \"json\" };\nimport testPlanSchema from \"./schemas/test-plan.json\" with { type: \"json\" };\nimport adrSchema from \"./schemas/adr.json\" with { type: \"json\" };\nimport apiContractSchema from \"./schemas/api-contract.json\" with { type: \"json\" };\n\n// addFormats is CJS-only; access via the namespace default at runtime\n// The type cast is needed because TypeScript's NodeNext resolution exposes\n// the CJS module as a namespace without a callable default signature.\nimport * as addFormatsNs from \"ajv-formats\";\ntype AddFormatsPlugin = (ajv: AjvClass, formats?: unknown) => AjvClass;\nconst addFormats = ((addFormatsNs as unknown as { default?: AddFormatsPlugin }).default ??\n (addFormatsNs as unknown as AddFormatsPlugin)) as AddFormatsPlugin;\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ErrorObject[] | null;\n}\n\nconst ajv = new AjvClass({ allErrors: true, strict: true });\naddFormats(ajv, [\"date\"]);\najv.addSchema(baseSpecSchema);\n\nconst specValidators: Record<string, ReturnType<typeof ajv.compile>> = {\n prd: ajv.compile(prdSchema),\n \"technical-design\": ajv.compile(technicalDesignSchema),\n \"user-story\": ajv.compile(userStorySchema),\n \"test-plan\": ajv.compile(testPlanSchema),\n adr: ajv.compile(adrSchema),\n \"api-contract\": ajv.compile(apiContractSchema),\n};\n\nconst configValidator = ajv.compile(configSchema);\n\nexport function validateSpec(type: SpecType, data: Record<string, unknown>): ValidationResult {\n const validate = specValidators[type];\n if (!validate) {\n return { valid: false, errors: [{ message: `Unknown spec type: \"${type}\"` } as ErrorObject] };\n }\n const valid = validate(data);\n return { valid: !!valid, errors: valid ? null : (validate.errors ?? null) };\n}\n\nexport function validateConfig(data: Record<string, unknown>): ValidationResult {\n const valid = configValidator(data);\n return { valid: !!valid, errors: valid ? null : (configValidator.errors ?? null) };\n}\n","{\n \"$id\": \"base-spec\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\", \"minLength\": 1 },\n \"type\": { \"type\": \"string\", \"enum\": [\"prd\", \"technical-design\", \"user-story\", \"test-plan\", \"adr\", \"api-contract\"] },\n \"title\": { \"type\": \"string\", \"minLength\": 1 },\n \"status\": { \"type\": \"string\", \"enum\": [\"draft\", \"review\", \"approved\", \"superseded\"] },\n \"version\": { \"type\": \"string\" },\n \"created\": { \"type\": \"string\", \"format\": \"date\" },\n \"updated\": { \"type\": \"string\", \"format\": \"date\" },\n \"authors\": { \"type\": \"array\", \"items\": { \"type\": \"string\" }, \"minItems\": 1 },\n \"tags\": { \"type\": \"array\", \"items\": { \"type\": \"string\" }, \"default\": [] },\n \"references\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\" },\n \"relationship\": { \"type\": \"string\", \"enum\": [\"implemented-by\", \"decomposed-into\", \"depends-on\", \"supersedes\", \"related-to\"] }\n },\n \"required\": [\"id\", \"relationship\"],\n \"additionalProperties\": false\n },\n \"default\": []\n }\n },\n \"required\": [\"id\", \"type\", \"title\", \"status\", \"version\", \"created\", \"authors\"],\n \"additionalProperties\": true\n}\n","{\n \"$id\": \"sdx-config\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"version\": { \"type\": \"string\" },\n \"project\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": { \"type\": \"string\" },\n \"description\": { \"type\": \"string\" }\n },\n \"additionalProperties\": false\n },\n \"specs\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"object\",\n \"properties\": {\n \"path\": { \"type\": \"string\" },\n \"type\": { \"type\": \"string\", \"enum\": [\"prd\", \"technical-design\", \"user-story\", \"test-plan\", \"adr\", \"api-contract\"] },\n \"required\": { \"type\": \"boolean\", \"default\": false },\n \"requires\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n },\n \"required\": [\"path\", \"type\"],\n \"additionalProperties\": false\n }\n },\n \"lint\": {\n \"type\": \"object\",\n \"properties\": {\n \"extends\": { \"type\": \"string\", \"enum\": [\"minimal\", \"recommended\", \"strict\"] },\n \"rules\": { \"type\": \"object\" },\n \"ignore\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n },\n \"additionalProperties\": false\n },\n \"pack\": { \"type\": \"object\" },\n \"diff\": { \"type\": \"object\" },\n \"ci\": { \"type\": \"object\" }\n },\n \"required\": [\"version\", \"specs\"],\n \"additionalProperties\": false\n}\n","{\n \"$id\": \"prd\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"prd\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"technical-design\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"technical-design\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"user-story\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n {\n \"type\": \"object\",\n \"properties\": {\n \"type\": { \"const\": \"user-story\" },\n \"story_id\": { \"type\": \"string\", \"minLength\": 1 },\n \"priority\": { \"type\": \"string\", \"enum\": [\"critical\", \"high\", \"medium\", \"low\"] },\n \"estimate\": { \"type\": \"string\" }\n },\n \"required\": [\"type\", \"story_id\", \"priority\", \"estimate\"]\n }\n ]\n}\n","{\n \"$id\": \"test-plan\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"test-plan\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"adr\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"adr\" } }, \"required\": [\"type\"] }\n ]\n}\n","{\n \"$id\": \"api-contract\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"allOf\": [\n { \"$ref\": \"base-spec\" },\n { \"type\": \"object\", \"properties\": { \"type\": { \"const\": \"api-contract\" } }, \"required\": [\"type\"] }\n ]\n}\n"],"mappings":";AAEO,IAAM,oBAAgD;EAC3D,KAAK,CAAC,qBAAqB,SAAS,aAAa,YAAY,kBAAkB;EAC/E,oBAAoB;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;;EAEF,cAAc,CAAC,eAAe,uBAAuB,gBAAgB,OAAO;EAC5E,aAAa,CAAC,SAAS,cAAc,mBAAmB,YAAY;EACpE,KAAK,CAAC,WAAW,YAAY,UAAU,cAAc;EACrD,gBAAgB,CAAC,aAAa,4BAA4B,QAAQ,aAAa;;;;AChBjF,SAAS,OAAO,gBAAkC;;;ACAlD;AAAA,EACI,KAAO;AAAA,EACP,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,YAAc;AAAA,IACV,IAAM,EAAE,MAAQ,UAAU,WAAa,EAAE;AAAA,IACzC,MAAQ,EAAE,MAAQ,UAAU,MAAQ,CAAC,OAAO,oBAAoB,cAAc,aAAa,OAAO,cAAc,EAAE;AAAA,IAClH,OAAS,EAAE,MAAQ,UAAU,WAAa,EAAE;AAAA,IAC5C,QAAU,EAAE,MAAQ,UAAU,MAAQ,CAAC,SAAS,UAAU,YAAY,YAAY,EAAE;AAAA,IACpF,SAAW,EAAE,MAAQ,SAAS;AAAA,IAC9B,SAAW,EAAE,MAAQ,UAAU,QAAU,OAAO;AAAA,IAChD,SAAW,EAAE,MAAQ,UAAU,QAAU,OAAO;AAAA,IAChD,SAAW,EAAE,MAAQ,SAAS,OAAS,EAAE,MAAQ,SAAS,GAAG,UAAY,EAAE;AAAA,IAC3E,MAAQ,EAAE,MAAQ,SAAS,OAAS,EAAE,MAAQ,SAAS,GAAG,SAAW,CAAC,EAAE;AAAA,IACxE,YAAc;AAAA,MACV,MAAQ;AAAA,MACR,OAAS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G,CAAiB,EAAC;EAC7F;AACA,QAAM,QAAQ,SAAS,IAAI;AAC3B,SAAO,EAAE,OAAO,CAAC,CAAC,OAAO,QAAQ,QAAQ,OAAQ,SAAS,UAAU,KAAK;AAC3E;AAEM,SAAU,eAAe,MAA6B;AAC1D,QAAM,QAAQ,gBAAgB,IAAI;AAClC,SAAO,EAAE,OAAO,CAAC,CAAC,OAAO,QAAQ,QAAQ,OAAQ,gBAAgB,UAAU,KAAK;AAClF;","names":[]}
@@ -0,0 +1,44 @@
1
+ import {
2
+ GraphError,
3
+ buildGraph,
4
+ loadConfig,
5
+ sharedArgs
6
+ } from "./chunk-ADUPKQBA.js";
7
+ import "./chunk-KQKWPO7Y.js";
8
+
9
+ // src/commands/graph.ts
10
+ import { defineCommand } from "citty";
11
+ var graph_default = defineCommand({
12
+ meta: { name: "graph", description: "Print the spec dependency graph" },
13
+ args: { ...sharedArgs },
14
+ async run({ args }) {
15
+ const config = await loadConfig(void 0, process.cwd());
16
+ try {
17
+ const graph = buildGraph(config);
18
+ const sorted = graph.topologicalSort();
19
+ if (args.format === "dot") {
20
+ console.log("digraph specs {");
21
+ for (const edge of graph.edges) console.log(` "${edge.from}" -> "${edge.to}";`);
22
+ console.log("}");
23
+ return;
24
+ }
25
+ console.log("\n Spec Dependency Graph:\n");
26
+ for (const node of sorted) {
27
+ const downstream = graph.getDownstream(node);
28
+ const arrow = downstream.length > 0 ? ` \u2192 ${downstream.join(", ")}` : "";
29
+ console.log(` ${node}${arrow}`);
30
+ }
31
+ console.log("");
32
+ } catch (err) {
33
+ if (err instanceof GraphError) {
34
+ console.error(` \u2717 ${err.message}`);
35
+ process.exit(1);
36
+ }
37
+ throw err;
38
+ }
39
+ }
40
+ });
41
+ export {
42
+ graph_default as default
43
+ };
44
+ //# sourceMappingURL=graph-XJSNQ7B7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/graph.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, buildGraph, GraphError } from \"@sdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"graph\", description: \"Print the spec dependency graph\" },\n args: { ...sharedArgs },\n async run({ args }) {\n const config = await loadConfig(undefined, process.cwd());\n try {\n const graph = buildGraph(config);\n const sorted = graph.topologicalSort();\n if (args.format === \"dot\") {\n console.log(\"digraph specs {\");\n for (const edge of graph.edges) console.log(` \"${edge.from}\" -> \"${edge.to}\";`);\n console.log(\"}\");\n return;\n }\n console.log(\"\\n Spec Dependency Graph:\\n\");\n for (const node of sorted) {\n const downstream = graph.getDownstream(node);\n const arrow = downstream.length > 0 ? ` → ${downstream.join(\", \")}` : \"\";\n console.log(` ${node}${arrow}`);\n }\n console.log(\"\");\n } catch (err) {\n if (err instanceof GraphError) {\n console.error(` ✗ ${err.message}`);\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;;AAAA,SAAS,qBAAqB;AAI9B,IAAO,gBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,SAAS,aAAa,kCAAkC;AAAA,EACtE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,IAAI,EAAE,KAAK,GAAG;AAClB,UAAM,SAAS,MAAM,WAAW,QAAW,QAAQ,IAAI,CAAC;AACxD,QAAI;AACF,YAAM,QAAQ,WAAW,MAAM;AAC/B,YAAM,SAAS,MAAM,gBAAgB;AACrC,UAAI,KAAK,WAAW,OAAO;AACzB,gBAAQ,IAAI,iBAAiB;AAC7B,mBAAW,QAAQ,MAAM,MAAO,SAAQ,IAAI,MAAM,KAAK,IAAI,SAAS,KAAK,EAAE,IAAI;AAC/E,gBAAQ,IAAI,GAAG;AACf;AAAA,MACF;AACA,cAAQ,IAAI,8BAA8B;AAC1C,iBAAW,QAAQ,QAAQ;AACzB,cAAM,aAAa,MAAM,cAAc,IAAI;AAC3C,cAAM,QAAQ,WAAW,SAAS,IAAI,WAAM,WAAW,KAAK,IAAI,CAAC,KAAK;AACtE,gBAAQ,IAAI,KAAK,IAAI,GAAG,KAAK,EAAE;AAAA,MACjC;AACA,cAAQ,IAAI,EAAE;AAAA,IAChB,SAAS,KAAK;AACZ,UAAI,eAAe,YAAY;AAC7B,gBAAQ,MAAM,YAAO,IAAI,OAAO,EAAE;AAClC,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}