sysprom 1.2.1 → 1.2.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.
package/README.md CHANGED
@@ -124,24 +124,33 @@ SysProM models systems as directed graphs across abstraction layers — intent,
124
124
 
125
125
  ## How SysProM Compares
126
126
 
127
- | System | Readable | Parseable | State | Rationale | History | Constraints | Nesting | Diagrams | Inference | Impact | Temporal | Scaffolding | Planning | Tracking |
128
- |--------|----------|-----------|-------|-----------|---------|-------------|---------|----------|-----------|--------|----------|-------------|----------|----------|
129
- | [MBSE (SysML)](https://www.omg.org/spec/SysML/) | 🔶 | ✅ | ✅ | 🔶 | 🔶 | | ✅ | | | ✅ | | | | |
130
- | [Knowledge Graphs](https://www.w3.org/TR/rdf12-concepts/) | | ✅ | ✅ | | | 🔶 | | 🔶 | | | | | | |
131
- | [EA (ArchiMate)](https://pubs.opengroup.org/architecture/archimate-spec/) | ✅ | 🔶 | ✅ | | | 🔶 | 🔶 | | | ✅ | | | | |
132
- | [Git](https://git-scm.com/) | 🔶 | ✅ | ✅ | | | | | | | | | | | 🔶 |
133
- | [Event Sourcing](https://martinfowler.com/eaaDev/EventSourcing.html) | | ✅ | 🔶 | | | 🔶 | | | | | | | | |
134
- | [DDD](https://www.domainlanguage.com/ddd/) | ✅ | | ✅ | | | 🔶 | 🔶 | | | | | | | |
135
- | [C4](https://c4model.com/) | ✅ | | ✅ | | | | 🔶 | | | | | | | |
136
- | [Traceability Matrices](https://en.wikipedia.org/wiki/Traceability_matrix) | ✅ | | ✅ | | | 🔶 | | | | 🔶 | | | | 🔶 |
137
- | [Spec Kit](https://github.com/github/spec-kit) | ✅ | | | 🔶 | 🔶 | | 🔶 | | | | | | ✅ | |
138
- | [ADR](https://adr.github.io/) | ✅ | | | | 🔶 | | | | | | | | | |
139
- | [RFC Processes](https://www.rfc-editor.org/rfc/rfc2026) | ✅ | | | | 🔶 | | | | | | | | 🔶 | 🔶 |
140
- | [Ralplan](https://github.com/yeachan-heo/oh-my-claudecode/blob/main/skills/ralplan/SKILL.md) | ✅ | | 🔶 | | | 🔶 | | | | | | | | 🔶 |
141
- | [GSD](https://github.com/gsd-build/get-shit-done) | ✅ | | | 🔶 | | 🔶 | | | | | | | | |
142
- | [OpenSpec](https://github.com/Fission-AI/OpenSpec) | ✅ | 🔶 | | | ✅ | | 🔶 | | | | | | ✅ | |
143
- | [Superpowers](https://github.com/obra/superpowers) | ✅ | 🔶 | 🔶 | 🔶 | 🔶 | ✅ | 🔶 | | | 🔶 | | | | |
144
- | **SysProM** | ✅ | | ✅ | ✅ | | | ✅ | 🔶 | | 🔶 | ✅ | ✅ | ✅ | ✅ |
127
+ | System | Readable | Parseable | State | Nesting | Diagrams | Rationale | Constraints | History | Temporal | Inference | Impact | Scaffolding | Planning | Tracking |
128
+ |--------|----------|-----------|-------|---------|----------|-----------|-------------|---------|----------|-----------|--------|-------------|----------|----------|
129
+ | [MBSE (SysML)](https://www.omg.org/spec/SysML/) | 🔶 | ✅ | ✅ | | | 🔶 | ✅ | 🔶 | | | ✅ | | | |
130
+ | [Knowledge Graphs](https://www.w3.org/TR/rdf12-concepts/) | | ✅ | ✅ | | 🔶 | | 🔶 | | | | | | | |
131
+ | [EA (ArchiMate)](https://pubs.opengroup.org/architecture/archimate-spec/) | ✅ | 🔶 | ✅ | 🔶 | | | 🔶 | | | | ✅ | | | |
132
+ | [Git](https://git-scm.com/) | 🔶 | ✅ | ✅ | | | | | | | | | | | 🔶 |
133
+ | [Event Sourcing](https://martinfowler.com/eaaDev/EventSourcing.html) | | ✅ | 🔶 | | | | 🔶 | | | | | | | |
134
+ | [DDD](https://www.domainlanguage.com/ddd/) | ✅ | | ✅ | 🔶 | | | 🔶 | | | | | | | |
135
+ | [C4](https://c4model.com/) | ✅ | | ✅ | 🔶 | | | | | | | | | | |
136
+ | [Traceability Matrices](https://en.wikipedia.org/wiki/Traceability_matrix) | ✅ | | ✅ | | | | 🔶 | | | | 🔶 | | | 🔶 |
137
+ | [PRD](https://en.wikipedia.org/wiki/Product_requirements_document) | ✅ | | 🔶 | 🔶 | 🔶 | | 🔶 | 🔶 | | | 🔶 | | ✅ | 🔶 |
138
+ | [ADR](https://adr.github.io/) | ✅ | | | | | | | 🔶 | | | | | | |
139
+ | [RFC Processes](https://www.rfc-editor.org/rfc/rfc2026) | ✅ | | | | | | | 🔶 | | | | | 🔶 | 🔶 |
140
+ | [BDD (Gherkin)](https://cucumber.io/docs/gherkin/) | ✅ | | 🔶 | 🔶 | | | | | | | | 🔶 | 🔶 | ✅ |
141
+ | [Spec Kit](https://github.com/github/spec-kit) | ✅ | | | 🔶 | | 🔶 | | 🔶 | | | | | | |
142
+ | [Ralplan](https://github.com/yeachan-heo/oh-my-claudecode/blob/main/skills/ralplan/SKILL.md) | ✅ | | 🔶 | | | ✅ | 🔶 | | | | | | ✅ | 🔶 |
143
+ | [GSD](https://github.com/gsd-build/get-shit-done) | ✅ | | | | | 🔶 | 🔶 | | | | | | | |
144
+ | [GSD-2](https://github.com/gsd-build/gsd-2) | ✅ | 🔶 | ✅ | ✅ | | 🔶 | 🔶 | ✅ | | | 🔶 | ✅ | ✅ | ✅ |
145
+ | [Taskmaster](https://github.com/eyaltoledano/claude-task-master) | ✅ | ✅ | ✅ | ✅ | | 🔶 | | 🔶 | | 🔶 | 🔶 | 🔶 | ✅ | ✅ |
146
+ | [OpenSpec](https://github.com/Fission-AI/OpenSpec) | ✅ | 🔶 | ✅ | 🔶 | | ✅ | | ✅ | | | | ✅ | ✅ | ✅ |
147
+ | [Kiro](https://github.com/kirodotdev/Kiro) | ✅ | 🔶 | ✅ | 🔶 | | 🔶 | 🔶 | 🔶 | | | 🔶 | ✅ | ✅ | ✅ |
148
+ | [cc-sdd](https://github.com/gotalab/cc-sdd) | ✅ | 🔶 | ✅ | 🔶 | | 🔶 | 🔶 | 🔶 | | | 🔶 | ✅ | ✅ | ✅ |
149
+ | [Ouroboros](https://github.com/Q00/ouroboros) | ✅ | 🔶 | ✅ | | | ✅ | ✅ | 🔶 | | ✅ | 🔶 | 🔶 | ✅ | 🔶 |
150
+ | [Spec Kitty](https://github.com/Priivacy-ai/spec-kitty) | ✅ | 🔶 | ✅ | 🔶 | | 🔶 | 🔶 | 🔶 | | | 🔶 | ✅ | ✅ | ✅ |
151
+ | [Shotgun](https://github.com/shotgun-sh/shotgun) | ✅ | 🔶 | 🔶 | | | 🔶 | | 🔶 | | | 🔶 | 🔶 | ✅ | 🔶 |
152
+ | [Superpowers](https://github.com/obra/superpowers) | ✅ | 🔶 | 🔶 | 🔶 | | 🔶 | ✅ | 🔶 | | ✅ | 🔶 | ✅ | ✅ | ✅ |
153
+ | **SysProM** | ✅ | ✅ | ✅ | ✅ | 🔶 | ✅ | ✅ | ✅ | ✅ | | 🔶 | ✅ | ✅ | ✅ |
145
154
 
146
155
  ✅ = first-class support. 🔶 = partial or implicit.
147
156
 
@@ -20,5 +20,10 @@ export interface FormatOptions {
20
20
  * @param value - The value to serialise.
21
21
  * @param options - Formatting options (e.g. indentation).
22
22
  * @returns The canonical JSON string.
23
+ * @example
24
+ * ```ts
25
+ * canonicalise({ b: 1, a: 2 }) // => '{"a":2,"b":1}'
26
+ * canonicalise({ b: 1 }, { indent: "\t" }) // => '{\n\t"b": 1\n}'
27
+ * ```
23
28
  */
24
29
  export declare function canonicalise(value: unknown, options?: FormatOptions): string;
@@ -15,6 +15,11 @@
15
15
  * @param value - The value to serialise.
16
16
  * @param options - Formatting options (e.g. indentation).
17
17
  * @returns The canonical JSON string.
18
+ * @example
19
+ * ```ts
20
+ * canonicalise({ b: 1, a: 2 }) // => '{"a":2,"b":1}'
21
+ * canonicalise({ b: 1 }, { indent: "\t" }) // => '{\n\t"b": 1\n}'
22
+ * ```
18
23
  */
19
24
  export function canonicalise(value, options = {}) {
20
25
  const indent = options.indent ?? "";
@@ -15,6 +15,12 @@ export interface CommandDef<TArgs extends z.ZodObject<z.ZodRawShape> = z.ZodObje
15
15
  * @param def - The command definition to build from.
16
16
  * @param parent - The parent Commander command to attach to.
17
17
  * @returns The constructed Commander command.
18
+ * @example
19
+ * ```ts
20
+ * const program = new Command();
21
+ * buildCommander(myCommandDef, program);
22
+ * program.parse(process.argv);
23
+ * ```
18
24
  */
19
25
  export declare function buildCommander(def: CommandDef, parent: Command): Command;
20
26
  /** Extracted documentation for a CLI positional argument. */
@@ -45,5 +51,10 @@ export interface CommandDoc {
45
51
  * Extract structured documentation from a CommandDef by introspecting its Zod schemas for args and options.
46
52
  * @param def - The command definition to extract docs from.
47
53
  * @returns Structured documentation for the command.
54
+ * @example
55
+ * ```ts
56
+ * const docs = extractDocs(validateCommand);
57
+ * console.log(docs.name, docs.args, docs.opts);
58
+ * ```
48
59
  */
49
60
  export declare function extractDocs(def: CommandDef): CommandDoc;
@@ -82,6 +82,12 @@ function collect(value, previous) {
82
82
  * @param def - The command definition to build from.
83
83
  * @param parent - The parent Commander command to attach to.
84
84
  * @returns The constructed Commander command.
85
+ * @example
86
+ * ```ts
87
+ * const program = new Command();
88
+ * buildCommander(myCommandDef, program);
89
+ * program.parse(process.argv);
90
+ * ```
85
91
  */
86
92
  export function buildCommander(def, parent) {
87
93
  const cmd = parent.command(def.name);
@@ -200,6 +206,11 @@ export function buildCommander(def, parent) {
200
206
  * Extract structured documentation from a CommandDef by introspecting its Zod schemas for args and options.
201
207
  * @param def - The command definition to extract docs from.
202
208
  * @returns Structured documentation for the command.
209
+ * @example
210
+ * ```ts
211
+ * const docs = extractDocs(validateCommand);
212
+ * console.log(docs.name, docs.args, docs.opts);
213
+ * ```
203
214
  */
204
215
  export function extractDocs(def) {
205
216
  const args = [];
@@ -17,6 +17,11 @@ export declare const noArgs: z.ZodObject<{}, z.core.$strict>;
17
17
  * @param input - Explicit document path, or undefined for auto-detection.
18
18
  * @param cwd - Working directory to search from (defaults to `.`).
19
19
  * @returns The resolved document path.
20
+ * @example
21
+ * ```ts
22
+ * resolveInput() // => auto-detects ".spm.json" in cwd
23
+ * resolveInput("my-doc.spm.json") // => "my-doc.spm.json"
24
+ * ```
20
25
  */
21
26
  export declare function resolveInput(input?: string, cwd?: string): string;
22
27
  /** Common output/persistence options for read-only commands. */
@@ -45,6 +50,10 @@ export interface LoadedDoc {
45
50
  * Load a document from a CLI input path (auto-resolved if omitted).
46
51
  * @param input - Explicit document path, or undefined for auto-detection.
47
52
  * @returns The loaded document with format and resolved path.
53
+ * @example
54
+ * ```ts
55
+ * const { doc, format, path } = loadDoc();
56
+ * ```
48
57
  */
49
58
  export declare function loadDoc(input?: string): LoadedDoc;
50
59
  /**
@@ -52,5 +61,11 @@ export declare function loadDoc(input?: string): LoadedDoc;
52
61
  * @param doc - The document to save.
53
62
  * @param loaded - The original loaded document (provides format and path).
54
63
  * @param opts - Mutation options (e.g. sync-to-markdown flag).
64
+ * @example
65
+ * ```ts
66
+ * const loaded = loadDoc();
67
+ * const updated = addNodeOp({ doc: loaded.doc, node });
68
+ * persistDoc(updated, loaded, { syncMd: "./SysProM" });
69
+ * ```
55
70
  */
56
71
  export declare function persistDoc(doc: SysProMDocument, loaded: LoadedDoc, opts: MutationOpts): void;
@@ -32,6 +32,11 @@ const pathOpt = z
32
32
  * @param input - Explicit document path, or undefined for auto-detection.
33
33
  * @param cwd - Working directory to search from (defaults to `.`).
34
34
  * @returns The resolved document path.
35
+ * @example
36
+ * ```ts
37
+ * resolveInput() // => auto-detects ".spm.json" in cwd
38
+ * resolveInput("my-doc.spm.json") // => "my-doc.spm.json"
39
+ * ```
35
40
  */
36
41
  export function resolveInput(input, cwd) {
37
42
  if (input)
@@ -129,6 +134,10 @@ export const mutationOpts = z.object({
129
134
  * Load a document from a CLI input path (auto-resolved if omitted).
130
135
  * @param input - Explicit document path, or undefined for auto-detection.
131
136
  * @returns The loaded document with format and resolved path.
137
+ * @example
138
+ * ```ts
139
+ * const { doc, format, path } = loadDoc();
140
+ * ```
132
141
  */
133
142
  export function loadDoc(input) {
134
143
  return loadDocument(resolveInput(input));
@@ -138,6 +147,12 @@ export function loadDoc(input) {
138
147
  * @param doc - The document to save.
139
148
  * @param loaded - The original loaded document (provides format and path).
140
149
  * @param opts - Mutation options (e.g. sync-to-markdown flag).
150
+ * @example
151
+ * ```ts
152
+ * const loaded = loadDoc();
153
+ * const updated = addNodeOp({ doc: loaded.doc, node });
154
+ * persistDoc(updated, loaded, { syncMd: "./SysProM" });
155
+ * ```
141
156
  */
142
157
  export function persistDoc(doc, loaded, opts) {
143
158
  if (!opts.dryRun) {
package/dist/src/io.d.ts CHANGED
@@ -14,6 +14,10 @@ export interface LoadedDocument {
14
14
  * Load a SysProM document from a file (JSON or Markdown).
15
15
  * @param input - File path or directory to load from.
16
16
  * @returns The loaded document with its detected format and resolved path.
17
+ * @example
18
+ * ```ts
19
+ * const { doc, format } = loadDocument("project.spm.json");
20
+ * ```
17
21
  */
18
22
  export declare function loadDocument(input: string): LoadedDocument;
19
23
  /**
@@ -21,5 +25,10 @@ export declare function loadDocument(input: string): LoadedDocument;
21
25
  * @param doc - The SysProM document to save.
22
26
  * @param format - Output format: 'json', 'single-md', or 'multi-md'.
23
27
  * @param path - Destination file path or directory.
28
+ * @example
29
+ * ```ts
30
+ * saveDocument(doc, "json", "output.spm.json");
31
+ * saveDocument(doc, "multi-md", "./SysProM");
32
+ * ```
24
33
  */
25
34
  export declare function saveDocument(doc: SysProMDocument, format: Format, path: string): void;
package/dist/src/io.js CHANGED
@@ -16,6 +16,10 @@ function detectFormat(input) {
16
16
  * Load a SysProM document from a file (JSON or Markdown).
17
17
  * @param input - File path or directory to load from.
18
18
  * @returns The loaded document with its detected format and resolved path.
19
+ * @example
20
+ * ```ts
21
+ * const { doc, format } = loadDocument("project.spm.json");
22
+ * ```
19
23
  */
20
24
  export function loadDocument(input) {
21
25
  const path = resolve(input);
@@ -48,6 +52,11 @@ export function loadDocument(input) {
48
52
  * @param doc - The SysProM document to save.
49
53
  * @param format - Output format: 'json', 'single-md', or 'multi-md'.
50
54
  * @param path - Destination file path or directory.
55
+ * @example
56
+ * ```ts
57
+ * saveDocument(doc, "json", "output.spm.json");
58
+ * saveDocument(doc, "multi-md", "./SysProM");
59
+ * ```
51
60
  */
52
61
  export function saveDocument(doc, format, path) {
53
62
  switch (format) {
@@ -7,12 +7,21 @@ export interface ConvertOptions {
7
7
  * Convert a SysProM document to a single Markdown string.
8
8
  * @param doc - The SysProM document to convert.
9
9
  * @returns The Markdown representation.
10
+ * @example
11
+ * ```ts
12
+ * const md = jsonToMarkdownSingle(doc);
13
+ * writeFileSync("output.spm.md", md);
14
+ * ```
10
15
  */
11
16
  export declare function jsonToMarkdownSingle(doc: SysProMDocument): string;
12
17
  /**
13
18
  * Convert a SysProM document to a multi-document Markdown folder.
14
19
  * @param doc - The SysProM document to convert.
15
20
  * @param outDir - Output directory path.
21
+ * @example
22
+ * ```ts
23
+ * jsonToMarkdownMultiDoc(doc, "./SysProM");
24
+ * ```
16
25
  */
17
26
  export declare function jsonToMarkdownMultiDoc(doc: SysProMDocument, outDir: string): void;
18
27
  /**
@@ -20,5 +29,9 @@ export declare function jsonToMarkdownMultiDoc(doc: SysProMDocument, outDir: str
20
29
  * @param doc - The SysProM document to convert.
21
30
  * @param output - Output file or directory path.
22
31
  * @param options - Conversion options specifying single-file or multi-doc form.
32
+ * @example
33
+ * ```ts
34
+ * jsonToMarkdown(doc, "output.spm.md", { form: "single-file" });
35
+ * ```
23
36
  */
24
37
  export declare function jsonToMarkdown(doc: SysProMDocument, output: string, options: ConvertOptions): void;
@@ -362,6 +362,11 @@ function generateDocFile(doc, fileName, types, fromIdx) {
362
362
  * Convert a SysProM document to a single Markdown string.
363
363
  * @param doc - The SysProM document to convert.
364
364
  * @returns The Markdown representation.
365
+ * @example
366
+ * ```ts
367
+ * const md = jsonToMarkdownSingle(doc);
368
+ * writeFileSync("output.spm.md", md);
369
+ * ```
365
370
  */
366
371
  export function jsonToMarkdownSingle(doc) {
367
372
  const fromIdx = indexRelationshipsFrom(doc.relationships ?? []);
@@ -418,6 +423,10 @@ export function jsonToMarkdownSingle(doc) {
418
423
  * Convert a SysProM document to a multi-document Markdown folder.
419
424
  * @param doc - The SysProM document to convert.
420
425
  * @param outDir - Output directory path.
426
+ * @example
427
+ * ```ts
428
+ * jsonToMarkdownMultiDoc(doc, "./SysProM");
429
+ * ```
421
430
  */
422
431
  export function jsonToMarkdownMultiDoc(doc, outDir) {
423
432
  mkdirSync(outDir, { recursive: true });
@@ -484,6 +493,10 @@ export function jsonToMarkdownMultiDoc(doc, outDir) {
484
493
  * @param doc - The SysProM document to convert.
485
494
  * @param output - Output file or directory path.
486
495
  * @param options - Conversion options specifying single-file or multi-doc form.
496
+ * @example
497
+ * ```ts
498
+ * jsonToMarkdown(doc, "output.spm.md", { form: "single-file" });
499
+ * ```
487
500
  */
488
501
  export function jsonToMarkdown(doc, output, options) {
489
502
  if (options.form === "single-file") {
@@ -3,17 +3,29 @@ import { type SysProMDocument } from "./schema.js";
3
3
  * Parse a single Markdown file into a SysProM document.
4
4
  * @param content - The Markdown content to parse.
5
5
  * @returns The parsed SysProM document.
6
+ * @example
7
+ * ```ts
8
+ * const doc = markdownSingleToJson(readFileSync("doc.spm.md", "utf8"));
9
+ * ```
6
10
  */
7
11
  export declare function markdownSingleToJson(content: string): SysProMDocument;
8
12
  /**
9
13
  * Parse a multi-document Markdown folder into a SysProM document.
10
14
  * @param dir - Path to the directory containing Markdown files.
11
15
  * @returns The parsed SysProM document.
16
+ * @example
17
+ * ```ts
18
+ * const doc = markdownMultiDocToJson("./SysProM");
19
+ * ```
12
20
  */
13
21
  export declare function markdownMultiDocToJson(dir: string): SysProMDocument;
14
22
  /**
15
23
  * Parse Markdown into a SysProM document, auto-detecting single-file or multi-doc format.
16
24
  * @param input - File path or directory path to parse.
17
25
  * @returns The parsed SysProM document.
26
+ * @example
27
+ * ```ts
28
+ * const doc = markdownToJson("./SysProM");
29
+ * ```
18
30
  */
19
31
  export declare function markdownToJson(input: string): SysProMDocument;
@@ -430,6 +430,10 @@ function parseRelationshipTable(body) {
430
430
  * Parse a single Markdown file into a SysProM document.
431
431
  * @param content - The Markdown content to parse.
432
432
  * @returns The parsed SysProM document.
433
+ * @example
434
+ * ```ts
435
+ * const doc = markdownSingleToJson(readFileSync("doc.spm.md", "utf8"));
436
+ * ```
433
437
  */
434
438
  export function markdownSingleToJson(content) {
435
439
  const { front, body } = parseFrontMatter(content);
@@ -461,6 +465,10 @@ export function markdownSingleToJson(content) {
461
465
  * Parse a multi-document Markdown folder into a SysProM document.
462
466
  * @param dir - Path to the directory containing Markdown files.
463
467
  * @returns The parsed SysProM document.
468
+ * @example
469
+ * ```ts
470
+ * const doc = markdownMultiDocToJson("./SysProM");
471
+ * ```
464
472
  */
465
473
  export function markdownMultiDocToJson(dir) {
466
474
  const readmeContent = readFileSync(join(dir, "README.md"), "utf8");
@@ -536,6 +544,10 @@ export function markdownMultiDocToJson(dir) {
536
544
  * Parse Markdown into a SysProM document, auto-detecting single-file or multi-doc format.
537
545
  * @param input - File path or directory path to parse.
538
546
  * @returns The parsed SysProM document.
547
+ * @example
548
+ * ```ts
549
+ * const doc = markdownToJson("./SysProM");
550
+ * ```
539
551
  */
540
552
  export function markdownToJson(input) {
541
553
  if (statSync(input).isDirectory()) {
@@ -38,5 +38,16 @@ export type DefinedOperation<TInput extends z.ZodType = z.ZodType, TOutput exten
38
38
  * @param def - The operation definition with name, schemas, and implementation.
39
39
  * @returns A callable function with `.def`, `.inputSchema`, and `.outputSchema` attached.
40
40
  * @throws {Error} If the input fails Zod validation.
41
+ * @example
42
+ * ```ts
43
+ * const myOp = defineOperation({
44
+ * name: "greet",
45
+ * description: "Say hello",
46
+ * input: z.object({ name: z.string() }),
47
+ * output: z.string(),
48
+ * fn: ({ name }) => `Hello, ${name}!`,
49
+ * });
50
+ * myOp({ name: "world" }); // => "Hello, world!"
51
+ * ```
41
52
  */
42
53
  export declare function defineOperation<TInput extends z.ZodType, TOutput extends z.ZodType>(def: OperationDef<TInput, TOutput>): DefinedOperation<TInput, TOutput>;
@@ -7,6 +7,17 @@
7
7
  * @param def - The operation definition with name, schemas, and implementation.
8
8
  * @returns A callable function with `.def`, `.inputSchema`, and `.outputSchema` attached.
9
9
  * @throws {Error} If the input fails Zod validation.
10
+ * @example
11
+ * ```ts
12
+ * const myOp = defineOperation({
13
+ * name: "greet",
14
+ * description: "Say hello",
15
+ * input: z.object({ name: z.string() }),
16
+ * output: z.string(),
17
+ * fn: ({ name }) => `Hello, ${name}!`,
18
+ * });
19
+ * myOp({ name: "world" }); // => "Hello, world!"
20
+ * ```
10
21
  */
11
22
  export function defineOperation(def) {
12
23
  function execute(input) {
@@ -933,6 +933,11 @@ export declare const NODE_ID_PREFIX: Record<string, string>;
933
933
  /**
934
934
  * Generate the JSON Schema representation of the SysProM document schema.
935
935
  * @returns The JSON Schema object with Draft 2020-12 metadata.
936
+ * @example
937
+ * ```ts
938
+ * const schema = toJSONSchema();
939
+ * writeFileSync("schema.json", JSON.stringify(schema, null, 2));
940
+ * ```
936
941
  */
937
942
  export declare function toJSONSchema(): Record<string, unknown>;
938
943
  export {};
@@ -374,6 +374,11 @@ function isRecord(value) {
374
374
  /**
375
375
  * Generate the JSON Schema representation of the SysProM document schema.
376
376
  * @returns The JSON Schema object with Draft 2020-12 metadata.
377
+ * @example
378
+ * ```ts
379
+ * const schema = toJSONSchema();
380
+ * writeFileSync("schema.json", JSON.stringify(schema, null, 2));
381
+ * ```
377
382
  */
378
383
  export function toJSONSchema() {
379
384
  const generated = z.toJSONSchema(SysProMDocument, {
@@ -4,6 +4,10 @@ import type { SysProMDocument } from "../schema.js";
4
4
  * @param doc - The SysProM document.
5
5
  * @param prefix - ID prefix identifying nodes to include.
6
6
  * @returns The generated markdown.
7
+ * @example
8
+ * ```ts
9
+ * const md = generateConstitution(doc, "FEAT");
10
+ * ```
7
11
  */
8
12
  export declare function generateConstitution(doc: SysProMDocument, prefix: string): string;
9
13
  /**
@@ -11,6 +15,10 @@ export declare function generateConstitution(doc: SysProMDocument, prefix: strin
11
15
  * @param doc - The SysProM document.
12
16
  * @param prefix - ID prefix identifying nodes to include.
13
17
  * @returns The generated markdown.
18
+ * @example
19
+ * ```ts
20
+ * const md = generateSpec(doc, "FEAT");
21
+ * ```
14
22
  */
15
23
  export declare function generateSpec(doc: SysProMDocument, prefix: string): string;
16
24
  /**
@@ -18,6 +26,10 @@ export declare function generateSpec(doc: SysProMDocument, prefix: string): stri
18
26
  * @param doc - The SysProM document.
19
27
  * @param prefix - ID prefix identifying nodes to include.
20
28
  * @returns The generated markdown.
29
+ * @example
30
+ * ```ts
31
+ * const md = generatePlan(doc, "FEAT");
32
+ * ```
21
33
  */
22
34
  export declare function generatePlan(doc: SysProMDocument, prefix: string): string;
23
35
  /**
@@ -25,6 +37,10 @@ export declare function generatePlan(doc: SysProMDocument, prefix: string): stri
25
37
  * @param doc - The SysProM document.
26
38
  * @param prefix - ID prefix identifying nodes to include.
27
39
  * @returns The generated markdown.
40
+ * @example
41
+ * ```ts
42
+ * const md = generateTasks(doc, "FEAT");
43
+ * ```
28
44
  */
29
45
  export declare function generateTasks(doc: SysProMDocument, prefix: string): string;
30
46
  /**
@@ -32,6 +48,10 @@ export declare function generateTasks(doc: SysProMDocument, prefix: string): str
32
48
  * @param doc - The SysProM document.
33
49
  * @param prefix - ID prefix identifying nodes to include.
34
50
  * @returns The generated markdown.
51
+ * @example
52
+ * ```ts
53
+ * const md = generateChecklist(doc, "FEAT");
54
+ * ```
35
55
  */
36
56
  export declare function generateChecklist(doc: SysProMDocument, prefix: string): string;
37
57
  /**
@@ -39,5 +59,9 @@ export declare function generateChecklist(doc: SysProMDocument, prefix: string):
39
59
  * @param doc - The SysProM document.
40
60
  * @param outputDir - Output directory path.
41
61
  * @param prefix - ID prefix identifying nodes to include.
62
+ * @example
63
+ * ```ts
64
+ * generateSpecKitProject(doc, "./output", "FEAT");
65
+ * ```
42
66
  */
43
67
  export declare function generateSpecKitProject(doc: SysProMDocument, outputDir: string, prefix: string): void;
@@ -9,6 +9,10 @@ import { textToString } from "../text.js";
9
9
  * @param doc - The document to search.
10
10
  * @param id - The node ID to find.
11
11
  * @returns The matching node, or null.
12
+ * @example
13
+ * ```ts
14
+ * findNode(doc, "D1")
15
+ * ```
12
16
  */
13
17
  function findNode(doc, id) {
14
18
  return doc.nodes.find((n) => n.id === id) ?? null;
@@ -18,6 +22,10 @@ function findNode(doc, id) {
18
22
  * @param doc - The document to search.
19
23
  * @param type - The node type to filter by.
20
24
  * @returns Matching nodes.
25
+ * @example
26
+ * ```ts
27
+ * const decisions = findNodesByType(doc, "decision");
28
+ * ```
21
29
  */
22
30
  function findNodesByType(doc, type) {
23
31
  return doc.nodes.filter((n) => n.type === type);
@@ -28,6 +36,10 @@ function findNodesByType(doc, type) {
28
36
  * @param fromId - Source node ID.
29
37
  * @param relationType - Optional relationship type filter.
30
38
  * @returns Matching relationships.
39
+ * @example
40
+ * ```ts
41
+ * const rels = findRelationshipsFrom(doc, "D1", "affects");
42
+ * ```
31
43
  */
32
44
  function findRelationshipsFrom(doc, fromId, relationType) {
33
45
  return (doc.relationships ?? []).filter((r) => {
@@ -44,6 +56,10 @@ function findRelationshipsFrom(doc, fromId, relationType) {
44
56
  * @param toId - Target node ID.
45
57
  * @param relationType - Optional relationship type filter.
46
58
  * @returns Matching relationships.
59
+ * @example
60
+ * ```ts
61
+ * const rels = findRelationshipsTo(doc, "INV1", "must_preserve");
62
+ * ```
47
63
  */
48
64
  function findRelationshipsTo(doc, toId, relationType) {
49
65
  return (doc.relationships ?? []).filter((r) => {
@@ -59,6 +75,10 @@ function findRelationshipsTo(doc, toId, relationType) {
59
75
  * Looks for patterns like "P1", "P2", "Priority: P1", etc.
60
76
  * @param node - The node to extract priority from.
61
77
  * @returns Priority string (e.g. "P1").
78
+ * @example
79
+ * ```ts
80
+ * const priority = extractPriority(node);
81
+ * ```
62
82
  */
63
83
  function extractPriority(node) {
64
84
  const text = [
@@ -75,6 +95,10 @@ function extractPriority(node) {
75
95
  * Extract numeric suffix from an ID (e.g., "PREFIX-SPEC-001" -> "001").
76
96
  * @param id - The node ID.
77
97
  * @returns The numeric suffix.
98
+ * @example
99
+ * ```ts
100
+ * getIdSuffix("FEAT-SPEC-001"); // => "001"
101
+ * ```
78
102
  */
79
103
  function getIdSuffix(id) {
80
104
  const parts = id.split("-");
@@ -84,6 +108,10 @@ function getIdSuffix(id) {
84
108
  * Parse tasks from a change node's plan array.
85
109
  * @param node - The change node.
86
110
  * @returns Array of task descriptions and done flags.
111
+ * @example
112
+ * ```ts
113
+ * const tasks = parseTasks(changeNode);
114
+ * ```
87
115
  */
88
116
  function parseTasks(node) {
89
117
  return (node.plan ?? []).map((task) => ({
@@ -95,6 +123,10 @@ function parseTasks(node) {
95
123
  * Format the status for spec output: "proposed" -> "Draft", etc.
96
124
  * @param status - The node status string.
97
125
  * @returns Formatted status label.
126
+ * @example
127
+ * ```ts
128
+ * formatStatus("proposed"); // => "Draft"
129
+ * ```
98
130
  */
99
131
  function formatStatus(status) {
100
132
  if (!status)
@@ -114,6 +146,10 @@ function formatStatus(status) {
114
146
  * @param doc - The SysProM document.
115
147
  * @param prefix - ID prefix identifying nodes to include.
116
148
  * @returns The generated markdown.
149
+ * @example
150
+ * ```ts
151
+ * const md = generateConstitution(doc, "FEAT");
152
+ * ```
117
153
  */
118
154
  export function generateConstitution(doc, prefix) {
119
155
  const protocolId = `${prefix}-CONST`;
@@ -192,6 +228,10 @@ export function generateConstitution(doc, prefix) {
192
228
  * @param doc - The SysProM document.
193
229
  * @param prefix - ID prefix identifying nodes to include.
194
230
  * @returns The generated markdown.
231
+ * @example
232
+ * ```ts
233
+ * const md = generateSpec(doc, "FEAT");
234
+ * ```
195
235
  */
196
236
  export function generateSpec(doc, prefix) {
197
237
  const specId = `${prefix}-SPEC`;
@@ -311,6 +351,10 @@ export function generateSpec(doc, prefix) {
311
351
  * @param doc - The SysProM document.
312
352
  * @param prefix - ID prefix identifying nodes to include.
313
353
  * @returns The generated markdown.
354
+ * @example
355
+ * ```ts
356
+ * const md = generatePlan(doc, "FEAT");
357
+ * ```
314
358
  */
315
359
  export function generatePlan(doc, prefix) {
316
360
  const implProtocolId = `${prefix}-PROT-IMPL`;
@@ -367,6 +411,10 @@ export function generatePlan(doc, prefix) {
367
411
  * @param doc - The SysProM document.
368
412
  * @param prefix - ID prefix identifying nodes to include.
369
413
  * @returns The generated markdown.
414
+ * @example
415
+ * ```ts
416
+ * const md = generateTasks(doc, "FEAT");
417
+ * ```
370
418
  */
371
419
  export function generateTasks(doc, prefix) {
372
420
  const implProtocolId = `${prefix}-PROT-IMPL`;
@@ -512,6 +560,10 @@ export function generateTasks(doc, prefix) {
512
560
  * @param doc - The SysProM document.
513
561
  * @param prefix - ID prefix identifying nodes to include.
514
562
  * @returns The generated markdown.
563
+ * @example
564
+ * ```ts
565
+ * const md = generateChecklist(doc, "FEAT");
566
+ * ```
515
567
  */
516
568
  export function generateChecklist(doc, prefix) {
517
569
  const gateId = `${prefix}-CHK`;
@@ -572,6 +624,10 @@ export function generateChecklist(doc, prefix) {
572
624
  * @param doc - The SysProM document.
573
625
  * @param outputDir - Output directory path.
574
626
  * @param prefix - ID prefix identifying nodes to include.
627
+ * @example
628
+ * ```ts
629
+ * generateSpecKitProject(doc, "./output", "FEAT");
630
+ * ```
575
631
  */
576
632
  export function generateSpecKitProject(doc, outputDir, prefix) {
577
633
  // Create output directory if it doesn't exist