sysprom 1.2.0 → 1.2.2

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 (54) hide show
  1. package/README.md +8 -0
  2. package/dist/src/canonical-json.d.ts +5 -1
  3. package/dist/src/canonical-json.js +5 -1
  4. package/dist/src/cli/define-command.d.ts +26 -0
  5. package/dist/src/cli/define-command.js +22 -0
  6. package/dist/src/cli/shared.d.ts +32 -2
  7. package/dist/src/cli/shared.js +29 -2
  8. package/dist/src/index.d.ts +0 -1
  9. package/dist/src/index.js +0 -1
  10. package/dist/src/io.d.ts +9 -2
  11. package/dist/src/io.js +9 -2
  12. package/dist/src/json-to-md.d.ts +13 -3
  13. package/dist/src/json-to-md.js +13 -3
  14. package/dist/src/md-to-json.d.ts +12 -3
  15. package/dist/src/md-to-json.js +12 -3
  16. package/dist/src/operations/add-node.d.ts +1 -2
  17. package/dist/src/operations/add-node.js +1 -2
  18. package/dist/src/operations/add-plan-task.d.ts +1 -2
  19. package/dist/src/operations/add-plan-task.js +1 -2
  20. package/dist/src/operations/add-relationship.d.ts +1 -2
  21. package/dist/src/operations/add-relationship.js +1 -2
  22. package/dist/src/operations/define-operation.d.ts +16 -8
  23. package/dist/src/operations/define-operation.js +12 -2
  24. package/dist/src/operations/mark-task-done.d.ts +1 -2
  25. package/dist/src/operations/mark-task-done.js +1 -2
  26. package/dist/src/operations/mark-task-undone.d.ts +1 -2
  27. package/dist/src/operations/mark-task-undone.js +1 -2
  28. package/dist/src/operations/next-id.d.ts +1 -2
  29. package/dist/src/operations/next-id.js +1 -2
  30. package/dist/src/operations/remove-node.d.ts +1 -2
  31. package/dist/src/operations/remove-node.js +1 -2
  32. package/dist/src/operations/remove-relationship.d.ts +1 -2
  33. package/dist/src/operations/remove-relationship.js +1 -2
  34. package/dist/src/operations/rename.d.ts +1 -2
  35. package/dist/src/operations/rename.js +1 -2
  36. package/dist/src/operations/task-list.d.ts +1 -2
  37. package/dist/src/operations/task-list.js +1 -2
  38. package/dist/src/operations/update-node.d.ts +1 -2
  39. package/dist/src/operations/update-node.js +1 -2
  40. package/dist/src/operations/update-plan-task.d.ts +1 -2
  41. package/dist/src/operations/update-plan-task.js +1 -2
  42. package/dist/src/schema.d.ts +9 -1
  43. package/dist/src/schema.js +9 -1
  44. package/dist/src/speckit/generate.d.ts +60 -6
  45. package/dist/src/speckit/generate.js +114 -6
  46. package/dist/src/speckit/parse.d.ts +61 -6
  47. package/dist/src/speckit/parse.js +105 -6
  48. package/dist/src/speckit/plan.d.ts +50 -0
  49. package/dist/src/speckit/plan.js +117 -0
  50. package/dist/src/speckit/project.d.ts +29 -0
  51. package/dist/src/speckit/project.js +49 -0
  52. package/dist/src/text.d.ts +25 -4
  53. package/dist/src/text.js +25 -4
  54. package/package.json +2 -1
package/README.md CHANGED
@@ -135,10 +135,18 @@ SysProM models systems as directed graphs across abstraction layers — intent,
135
135
  | [C4](https://c4model.com/) | ✅ | | ✅ | | | | 🔶 | ✅ | | | | | | |
136
136
  | [Traceability Matrices](https://en.wikipedia.org/wiki/Traceability_matrix) | ✅ | | ✅ | | | 🔶 | | | | 🔶 | | | | 🔶 |
137
137
  | [Spec Kit](https://github.com/github/spec-kit) | ✅ | | ✅ | 🔶 | 🔶 | | 🔶 | | | | | ✅ | ✅ | ✅ |
138
+ | [PRD](https://en.wikipedia.org/wiki/Product_requirements_document) | ✅ | | 🔶 | ✅ | 🔶 | 🔶 | 🔶 | 🔶 | | 🔶 | | | ✅ | 🔶 |
138
139
  | [ADR](https://adr.github.io/) | ✅ | | | ✅ | 🔶 | | | | | | | | | |
139
140
  | [RFC Processes](https://www.rfc-editor.org/rfc/rfc2026) | ✅ | | | ✅ | 🔶 | | | | | | | | 🔶 | 🔶 |
140
141
  | [Ralplan](https://github.com/yeachan-heo/oh-my-claudecode/blob/main/skills/ralplan/SKILL.md) | ✅ | | 🔶 | ✅ | | 🔶 | | | | | | | ✅ | 🔶 |
141
142
  | [GSD](https://github.com/gsd-build/get-shit-done) | ✅ | | | 🔶 | | 🔶 | | | | | | | | |
143
+ | [GSD-2](https://github.com/gsd-build/gsd-2) | ✅ | 🔶 | ✅ | 🔶 | ✅ | 🔶 | ✅ | | | 🔶 | | ✅ | ✅ | ✅ |
144
+ | [OpenSpec](https://github.com/Fission-AI/OpenSpec) | ✅ | 🔶 | ✅ | ✅ | ✅ | | 🔶 | | | | | ✅ | ✅ | ✅ |
145
+ | [Kiro](https://github.com/kirodotdev/Kiro) | ✅ | 🔶 | ✅ | 🔶 | 🔶 | 🔶 | 🔶 | | | 🔶 | | ✅ | ✅ | ✅ |
146
+ | [cc-sdd](https://github.com/gotalab/cc-sdd) | ✅ | 🔶 | ✅ | 🔶 | 🔶 | 🔶 | 🔶 | | | 🔶 | | ✅ | ✅ | ✅ |
147
+ | [Ouroboros](https://github.com/Q00/ouroboros) | ✅ | 🔶 | ✅ | ✅ | 🔶 | ✅ | | | ✅ | 🔶 | | 🔶 | ✅ | 🔶 |
148
+ | [Spec Kitty](https://github.com/Priivacy-ai/spec-kitty) | ✅ | 🔶 | ✅ | 🔶 | 🔶 | 🔶 | 🔶 | | | 🔶 | | ✅ | ✅ | ✅ |
149
+ | [Shotgun](https://github.com/shotgun-sh/shotgun) | ✅ | 🔶 | 🔶 | 🔶 | 🔶 | | | | | 🔶 | | 🔶 | ✅ | 🔶 |
142
150
  | [Superpowers](https://github.com/obra/superpowers) | ✅ | 🔶 | 🔶 | 🔶 | 🔶 | ✅ | 🔶 | | ✅ | 🔶 | | ✅ | ✅ | ✅ |
143
151
  | **SysProM** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 🔶 | | 🔶 | ✅ | ✅ | ✅ | ✅ |
144
152
 
@@ -17,9 +17,13 @@ export interface FormatOptions {
17
17
  }
18
18
  /**
19
19
  * Serialise a value to canonical JSON with RFC 8785 key ordering.
20
- *
21
20
  * @param value - The value to serialise.
22
21
  * @param options - Formatting options (e.g. indentation).
23
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
+ * ```
24
28
  */
25
29
  export declare function canonicalise(value: unknown, options?: FormatOptions): string;
@@ -12,10 +12,14 @@
12
12
  */
13
13
  /**
14
14
  * Serialise a value to canonical JSON with RFC 8785 key ordering.
15
- *
16
15
  * @param value - The value to serialise.
17
16
  * @param options - Formatting options (e.g. indentation).
18
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
+ * ```
19
23
  */
20
24
  export function canonicalise(value, options = {}) {
21
25
  const indent = options.indent ?? "";
@@ -1,5 +1,6 @@
1
1
  import * as z from "zod";
2
2
  import { Command } from "commander";
3
+ /** Definition of a CLI command — name, description, Zod schemas for args/opts, optional subcommands, and action handler. */
3
4
  export interface CommandDef<TArgs extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOpts extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> {
4
5
  name: string;
5
6
  description: string;
@@ -9,13 +10,27 @@ export interface CommandDef<TArgs extends z.ZodObject<z.ZodRawShape> = z.ZodObje
9
10
  action?: (args: z.infer<TArgs>, opts: z.infer<TOpts>) => void;
10
11
  apiLink?: string;
11
12
  }
13
+ /**
14
+ * Build a Commander.js command tree from a declarative CommandDef, wiring up Zod-validated args, options, and actions.
15
+ * @param def - The command definition to build from.
16
+ * @param parent - The parent Commander command to attach to.
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
+ * ```
24
+ */
12
25
  export declare function buildCommander(def: CommandDef, parent: Command): Command;
26
+ /** Extracted documentation for a CLI positional argument. */
13
27
  export interface ArgDoc {
14
28
  name: string;
15
29
  description: string;
16
30
  required: boolean;
17
31
  choices?: string[];
18
32
  }
33
+ /** Extracted documentation for a CLI option/flag. */
19
34
  export interface OptDoc {
20
35
  flag: string;
21
36
  description: string;
@@ -23,6 +38,7 @@ export interface OptDoc {
23
38
  repeatable: boolean;
24
39
  choices?: string[];
25
40
  }
41
+ /** Extracted documentation for a CLI command, including its arguments, options, and subcommands. */
26
42
  export interface CommandDoc {
27
43
  name: string;
28
44
  description: string;
@@ -31,4 +47,14 @@ export interface CommandDoc {
31
47
  subcommands?: CommandDoc[];
32
48
  apiLink?: string;
33
49
  }
50
+ /**
51
+ * Extract structured documentation from a CommandDef by introspecting its Zod schemas for args and options.
52
+ * @param def - The command definition to extract docs from.
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
+ * ```
59
+ */
34
60
  export declare function extractDocs(def: CommandDef): CommandDoc;
@@ -77,6 +77,18 @@ function getShape(schema) {
77
77
  function collect(value, previous) {
78
78
  return [...previous, value];
79
79
  }
80
+ /**
81
+ * Build a Commander.js command tree from a declarative CommandDef, wiring up Zod-validated args, options, and actions.
82
+ * @param def - The command definition to build from.
83
+ * @param parent - The parent Commander command to attach to.
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
+ * ```
91
+ */
80
92
  export function buildCommander(def, parent) {
81
93
  const cmd = parent.command(def.name);
82
94
  cmd.description(def.description);
@@ -190,6 +202,16 @@ export function buildCommander(def, parent) {
190
202
  }
191
203
  return cmd;
192
204
  }
205
+ /**
206
+ * Extract structured documentation from a CommandDef by introspecting its Zod schemas for args and options.
207
+ * @param def - The command definition to extract docs from.
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
+ * ```
214
+ */
193
215
  export function extractDocs(def) {
194
216
  const args = [];
195
217
  {
@@ -14,6 +14,14 @@ export declare const noArgs: z.ZodObject<{}, z.core.$strict>;
14
14
  * 10. *.sysprom.json 11. *.sysprom.md 12. *.sysprom/
15
15
  *
16
16
  * All matching is case-insensitive. Glob tiers must have exactly one match.
17
+ * @param input - Explicit document path, or undefined for auto-detection.
18
+ * @param cwd - Working directory to search from (defaults to `.`).
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
+ * ```
17
25
  */
18
26
  export declare function resolveInput(input?: string, cwd?: string): string;
19
27
  /** Common output/persistence options for read-only commands. */
@@ -28,14 +36,36 @@ export declare const mutationOpts: z.ZodObject<{
28
36
  dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
29
37
  sync: z.ZodOptional<z.ZodString>;
30
38
  }, z.core.$strip>;
39
+ /** Inferred type for read-only CLI options (input path, JSON output flag). */
31
40
  export type ReadOpts = z.infer<typeof readOpts>;
41
+ /** Inferred type for mutation CLI options (extends ReadOpts with sync-to-markdown). */
32
42
  export type MutationOpts = z.infer<typeof mutationOpts>;
43
+ /** A document loaded from a CLI input path with its format and resolved path. */
33
44
  export interface LoadedDoc {
34
45
  doc: SysProMDocument;
35
46
  format: Format;
36
47
  path: string;
37
48
  }
38
- /** Load a document from a CLI input path (auto-resolved if omitted). */
49
+ /**
50
+ * Load a document from a CLI input path (auto-resolved if omitted).
51
+ * @param input - Explicit document path, or undefined for auto-detection.
52
+ * @returns The loaded document with format and resolved path.
53
+ * @example
54
+ * ```ts
55
+ * const { doc, format, path } = loadDoc();
56
+ * ```
57
+ */
39
58
  export declare function loadDoc(input?: string): LoadedDoc;
40
- /** Persist a document and optionally sync to markdown. */
59
+ /**
60
+ * Persist a document and optionally sync to markdown.
61
+ * @param doc - The document to save.
62
+ * @param loaded - The original loaded document (provides format and path).
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
+ * ```
70
+ */
41
71
  export declare function persistDoc(doc: SysProMDocument, loaded: LoadedDoc, opts: MutationOpts): void;
@@ -29,6 +29,14 @@ const pathOpt = z
29
29
  * 10. *.sysprom.json 11. *.sysprom.md 12. *.sysprom/
30
30
  *
31
31
  * All matching is case-insensitive. Glob tiers must have exactly one match.
32
+ * @param input - Explicit document path, or undefined for auto-detection.
33
+ * @param cwd - Working directory to search from (defaults to `.`).
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
+ * ```
32
40
  */
33
41
  export function resolveInput(input, cwd) {
34
42
  if (input)
@@ -122,11 +130,30 @@ export const mutationOpts = z.object({
122
130
  .optional()
123
131
  .describe("sync to markdown directory after saving"),
124
132
  });
125
- /** Load a document from a CLI input path (auto-resolved if omitted). */
133
+ /**
134
+ * Load a document from a CLI input path (auto-resolved if omitted).
135
+ * @param input - Explicit document path, or undefined for auto-detection.
136
+ * @returns The loaded document with format and resolved path.
137
+ * @example
138
+ * ```ts
139
+ * const { doc, format, path } = loadDoc();
140
+ * ```
141
+ */
126
142
  export function loadDoc(input) {
127
143
  return loadDocument(resolveInput(input));
128
144
  }
129
- /** Persist a document and optionally sync to markdown. */
145
+ /**
146
+ * Persist a document and optionally sync to markdown.
147
+ * @param doc - The document to save.
148
+ * @param loaded - The original loaded document (provides format and path).
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
+ * ```
156
+ */
130
157
  export function persistDoc(doc, loaded, opts) {
131
158
  if (!opts.dryRun) {
132
159
  saveDocument(doc, loaded.format, loaded.path);
@@ -3,7 +3,6 @@
3
3
  *
4
4
  * A recursive, decision-driven model for recording where every part of a
5
5
  * system came from, what decisions shaped it, and how it reached its current form.
6
- *
7
6
  * @packageDocumentation
8
7
  */
9
8
  export { SysProMDocument, Node, Relationship, NodeType, NodeStatus, RelationshipType, Text, Option, Operation, Task, ExternalReference, ExternalReferenceRole, Metadata, NODE_TYPE_LABELS, NODE_LABEL_TO_TYPE, RELATIONSHIP_TYPE_LABELS, RELATIONSHIP_LABEL_TO_TYPE, EXTERNAL_REFERENCE_ROLE_LABELS, EXTERNAL_REFERENCE_LABEL_TO_ROLE, NODE_STATUSES, NODE_FILE_MAP, NODE_ID_PREFIX, toJSONSchema, } from "./schema.js";
package/dist/src/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  *
4
4
  * A recursive, decision-driven model for recording where every part of a
5
5
  * system came from, what decisions shaped it, and how it reached its current form.
6
- *
7
6
  * @packageDocumentation
8
7
  */
9
8
  // Schema types and validators
package/dist/src/io.d.ts CHANGED
@@ -12,16 +12,23 @@ export interface LoadedDocument {
12
12
  }
13
13
  /**
14
14
  * Load a SysProM document from a file (JSON or Markdown).
15
- *
16
15
  * @param input - File path or directory to load from.
17
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
+ * ```
18
21
  */
19
22
  export declare function loadDocument(input: string): LoadedDocument;
20
23
  /**
21
24
  * Save a SysProM document to a file (JSON or Markdown).
22
- *
23
25
  * @param doc - The SysProM document to save.
24
26
  * @param format - Output format: 'json', 'single-md', or 'multi-md'.
25
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
+ * ```
26
33
  */
27
34
  export declare function saveDocument(doc: SysProMDocument, format: Format, path: string): void;
package/dist/src/io.js CHANGED
@@ -14,9 +14,12 @@ function detectFormat(input) {
14
14
  }
15
15
  /**
16
16
  * Load a SysProM document from a file (JSON or Markdown).
17
- *
18
17
  * @param input - File path or directory to load from.
19
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
+ * ```
20
23
  */
21
24
  export function loadDocument(input) {
22
25
  const path = resolve(input);
@@ -46,10 +49,14 @@ export function loadDocument(input) {
46
49
  }
47
50
  /**
48
51
  * Save a SysProM document to a file (JSON or Markdown).
49
- *
50
52
  * @param doc - The SysProM document to save.
51
53
  * @param format - Output format: 'json', 'single-md', or 'multi-md'.
52
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
+ * ```
53
60
  */
54
61
  export function saveDocument(doc, format, path) {
55
62
  switch (format) {
@@ -5,23 +5,33 @@ export interface ConvertOptions {
5
5
  }
6
6
  /**
7
7
  * Convert a SysProM document to a single Markdown string.
8
- *
9
8
  * @param doc - The SysProM document to convert.
10
9
  * @returns The Markdown representation.
10
+ * @example
11
+ * ```ts
12
+ * const md = jsonToMarkdownSingle(doc);
13
+ * writeFileSync("output.spm.md", md);
14
+ * ```
11
15
  */
12
16
  export declare function jsonToMarkdownSingle(doc: SysProMDocument): string;
13
17
  /**
14
18
  * Convert a SysProM document to a multi-document Markdown folder.
15
- *
16
19
  * @param doc - The SysProM document to convert.
17
20
  * @param outDir - Output directory path.
21
+ * @example
22
+ * ```ts
23
+ * jsonToMarkdownMultiDoc(doc, "./SysProM");
24
+ * ```
18
25
  */
19
26
  export declare function jsonToMarkdownMultiDoc(doc: SysProMDocument, outDir: string): void;
20
27
  /**
21
28
  * Convert a SysProM document to Markdown, writing to the specified output path.
22
- *
23
29
  * @param doc - The SysProM document to convert.
24
30
  * @param output - Output file or directory path.
25
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
+ * ```
26
36
  */
27
37
  export declare function jsonToMarkdown(doc: SysProMDocument, output: string, options: ConvertOptions): void;
@@ -360,9 +360,13 @@ function generateDocFile(doc, fileName, types, fromIdx) {
360
360
  }
361
361
  /**
362
362
  * Convert a SysProM document to a single Markdown string.
363
- *
364
363
  * @param doc - The SysProM document to convert.
365
364
  * @returns The Markdown representation.
365
+ * @example
366
+ * ```ts
367
+ * const md = jsonToMarkdownSingle(doc);
368
+ * writeFileSync("output.spm.md", md);
369
+ * ```
366
370
  */
367
371
  export function jsonToMarkdownSingle(doc) {
368
372
  const fromIdx = indexRelationshipsFrom(doc.relationships ?? []);
@@ -417,9 +421,12 @@ export function jsonToMarkdownSingle(doc) {
417
421
  }
418
422
  /**
419
423
  * Convert a SysProM document to a multi-document Markdown folder.
420
- *
421
424
  * @param doc - The SysProM document to convert.
422
425
  * @param outDir - Output directory path.
426
+ * @example
427
+ * ```ts
428
+ * jsonToMarkdownMultiDoc(doc, "./SysProM");
429
+ * ```
423
430
  */
424
431
  export function jsonToMarkdownMultiDoc(doc, outDir) {
425
432
  mkdirSync(outDir, { recursive: true });
@@ -483,10 +490,13 @@ export function jsonToMarkdownMultiDoc(doc, outDir) {
483
490
  }
484
491
  /**
485
492
  * Convert a SysProM document to Markdown, writing to the specified output path.
486
- *
487
493
  * @param doc - The SysProM document to convert.
488
494
  * @param output - Output file or directory path.
489
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
+ * ```
490
500
  */
491
501
  export function jsonToMarkdown(doc, output, options) {
492
502
  if (options.form === "single-file") {
@@ -1,22 +1,31 @@
1
1
  import { type SysProMDocument } from "./schema.js";
2
2
  /**
3
3
  * Parse a single Markdown file into a SysProM document.
4
- *
5
4
  * @param content - The Markdown content to parse.
6
5
  * @returns The parsed SysProM document.
6
+ * @example
7
+ * ```ts
8
+ * const doc = markdownSingleToJson(readFileSync("doc.spm.md", "utf8"));
9
+ * ```
7
10
  */
8
11
  export declare function markdownSingleToJson(content: string): SysProMDocument;
9
12
  /**
10
13
  * Parse a multi-document Markdown folder into a SysProM document.
11
- *
12
14
  * @param dir - Path to the directory containing Markdown files.
13
15
  * @returns The parsed SysProM document.
16
+ * @example
17
+ * ```ts
18
+ * const doc = markdownMultiDocToJson("./SysProM");
19
+ * ```
14
20
  */
15
21
  export declare function markdownMultiDocToJson(dir: string): SysProMDocument;
16
22
  /**
17
23
  * Parse Markdown into a SysProM document, auto-detecting single-file or multi-doc format.
18
- *
19
24
  * @param input - File path or directory path to parse.
20
25
  * @returns The parsed SysProM document.
26
+ * @example
27
+ * ```ts
28
+ * const doc = markdownToJson("./SysProM");
29
+ * ```
21
30
  */
22
31
  export declare function markdownToJson(input: string): SysProMDocument;
@@ -428,9 +428,12 @@ function parseRelationshipTable(body) {
428
428
  // ---------------------------------------------------------------------------
429
429
  /**
430
430
  * Parse a single Markdown file into a SysProM document.
431
- *
432
431
  * @param content - The Markdown content to parse.
433
432
  * @returns The parsed SysProM document.
433
+ * @example
434
+ * ```ts
435
+ * const doc = markdownSingleToJson(readFileSync("doc.spm.md", "utf8"));
436
+ * ```
434
437
  */
435
438
  export function markdownSingleToJson(content) {
436
439
  const { front, body } = parseFrontMatter(content);
@@ -460,9 +463,12 @@ export function markdownSingleToJson(content) {
460
463
  }
461
464
  /**
462
465
  * Parse a multi-document Markdown folder into a SysProM document.
463
- *
464
466
  * @param dir - Path to the directory containing Markdown files.
465
467
  * @returns The parsed SysProM document.
468
+ * @example
469
+ * ```ts
470
+ * const doc = markdownMultiDocToJson("./SysProM");
471
+ * ```
466
472
  */
467
473
  export function markdownMultiDocToJson(dir) {
468
474
  const readmeContent = readFileSync(join(dir, "README.md"), "utf8");
@@ -536,9 +542,12 @@ export function markdownMultiDocToJson(dir) {
536
542
  }
537
543
  /**
538
544
  * Parse Markdown into a SysProM document, auto-detecting single-file or multi-doc format.
539
- *
540
545
  * @param input - File path or directory path to parse.
541
546
  * @returns The parsed SysProM document.
547
+ * @example
548
+ * ```ts
549
+ * const doc = markdownToJson("./SysProM");
550
+ * ```
542
551
  */
543
552
  export function markdownToJson(input) {
544
553
  if (statSync(input).isDirectory()) {
@@ -1,8 +1,7 @@
1
1
  import * as z from "zod";
2
2
  /**
3
3
  * Add a node to a SysProM document. Returns a new document with the node appended.
4
- *
5
- * @throws If a node with the same ID already exists.
4
+ * @throws {Error} If a node with the same ID already exists.
6
5
  */
7
6
  export declare const addNodeOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
8
7
  doc: z.ZodObject<{
@@ -3,8 +3,7 @@ import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument, Node } from "../schema.js";
4
4
  /**
5
5
  * Add a node to a SysProM document. Returns a new document with the node appended.
6
- *
7
- * @throws If a node with the same ID already exists.
6
+ * @throws {Error} If a node with the same ID already exists.
8
7
  */
9
8
  export const addNodeOp = defineOperation({
10
9
  name: "addNode",
@@ -1,8 +1,7 @@
1
1
  import * as z from "zod";
2
2
  /**
3
3
  * Append a new task to a change node's plan array. Returns a new document with the task added.
4
- *
5
- * @throws If the change node is not found.
4
+ * @throws {Error} If the change node is not found.
6
5
  */
7
6
  export declare const addPlanTaskOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
8
7
  doc: z.ZodObject<{
@@ -3,8 +3,7 @@ import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
4
  /**
5
5
  * Append a new task to a change node's plan array. Returns a new document with the task added.
6
- *
7
- * @throws If the change node is not found.
6
+ * @throws {Error} If the change node is not found.
8
7
  */
9
8
  export const addPlanTaskOp = defineOperation({
10
9
  name: "addPlanTask",
@@ -1,8 +1,7 @@
1
1
  import * as z from "zod";
2
2
  /**
3
3
  * Add a relationship to a SysProM document. Returns a new document with the relationship appended.
4
- *
5
- * @throws If either endpoint node does not exist in the document.
4
+ * @throws {Error} If either endpoint node does not exist in the document.
6
5
  */
7
6
  export declare const addRelationshipOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
8
7
  doc: z.ZodObject<{
@@ -3,8 +3,7 @@ import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument, Relationship } from "../schema.js";
4
4
  /**
5
5
  * Add a relationship to a SysProM document. Returns a new document with the relationship appended.
6
- *
7
- * @throws If either endpoint node does not exist in the document.
6
+ * @throws {Error} If either endpoint node does not exist in the document.
8
7
  */
9
8
  export const addRelationshipOp = defineOperation({
10
9
  name: "addRelationship",
@@ -2,9 +2,8 @@ import * as z from "zod";
2
2
  /**
3
3
  * Definition of a SysProM operation — a named, typed function with Zod schemas
4
4
  * for input validation and output description.
5
- *
6
- * @typeParam TInput - Zod schema type for the operation's input.
7
- * @typeParam TOutput - Zod schema type for the operation's output.
5
+ * @template TInput - Zod schema type for the operation's input.
6
+ * @template TOutput - Zod schema type for the operation's output.
8
7
  */
9
8
  export interface OperationDef<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> {
10
9
  /** Machine-readable operation name (e.g. `"addNode"`). */
@@ -22,9 +21,8 @@ export interface OperationDef<TInput extends z.ZodType = z.ZodType, TOutput exte
22
21
  * A callable operation with attached metadata. Can be invoked directly as a
23
22
  * function, and also exposes `.def`, `.inputSchema`, and `.outputSchema` for
24
23
  * introspection.
25
- *
26
- * @typeParam TInput - Zod schema type for the operation's input.
27
- * @typeParam TOutput - Zod schema type for the operation's output.
24
+ * @template TInput - Zod schema type for the operation's input.
25
+ * @template TOutput - Zod schema type for the operation's output.
28
26
  */
29
27
  export type DefinedOperation<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> = ((input: z.infer<TInput>) => z.infer<TOutput>) & {
30
28
  /** The full operation definition including name, description, and schemas. */
@@ -37,9 +35,19 @@ export type DefinedOperation<TInput extends z.ZodType = z.ZodType, TOutput exten
37
35
  /**
38
36
  * Create a callable operation from a definition. The returned function validates
39
37
  * input against the Zod schema before delegating to the implementation.
40
- *
41
38
  * @param def - The operation definition with name, schemas, and implementation.
42
39
  * @returns A callable function with `.def`, `.inputSchema`, and `.outputSchema` attached.
43
- * @throws If the input fails Zod validation.
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
+ * ```
44
52
  */
45
53
  export declare function defineOperation<TInput extends z.ZodType, TOutput extends z.ZodType>(def: OperationDef<TInput, TOutput>): DefinedOperation<TInput, TOutput>;
@@ -4,10 +4,20 @@
4
4
  /**
5
5
  * Create a callable operation from a definition. The returned function validates
6
6
  * input against the Zod schema before delegating to the implementation.
7
- *
8
7
  * @param def - The operation definition with name, schemas, and implementation.
9
8
  * @returns A callable function with `.def`, `.inputSchema`, and `.outputSchema` attached.
10
- * @throws If the input fails Zod validation.
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
+ * ```
11
21
  */
12
22
  export function defineOperation(def) {
13
23
  function execute(input) {
@@ -1,8 +1,7 @@
1
1
  import * as z from "zod";
2
2
  /**
3
3
  * Mark a task as done within a change node's plan.
4
- *
5
- * @throws If the change node is not found or the task index is out of range.
4
+ * @throws {Error} If the change node is not found or the task index is out of range.
6
5
  */
7
6
  export declare const markTaskDoneOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
8
7
  doc: z.ZodObject<{
@@ -3,8 +3,7 @@ import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
4
  /**
5
5
  * Mark a task as done within a change node's plan.
6
- *
7
- * @throws If the change node is not found or the task index is out of range.
6
+ * @throws {Error} If the change node is not found or the task index is out of range.
8
7
  */
9
8
  export const markTaskDoneOp = defineOperation({
10
9
  name: "markTaskDone",
@@ -1,8 +1,7 @@
1
1
  import * as z from "zod";
2
2
  /**
3
3
  * Mark a task as undone (incomplete) within a change node's plan.
4
- *
5
- * @throws If the change node is not found or the task index is out of range.
4
+ * @throws {Error} If the change node is not found or the task index is out of range.
6
5
  */
7
6
  export declare const markTaskUndoneOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
8
7
  doc: z.ZodObject<{
@@ -3,8 +3,7 @@ import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
4
  /**
5
5
  * Mark a task as undone (incomplete) within a change node's plan.
6
- *
7
- * @throws If the change node is not found or the task index is out of range.
6
+ * @throws {Error} If the change node is not found or the task index is out of range.
8
7
  */
9
8
  export const markTaskUndoneOp = defineOperation({
10
9
  name: "markTaskUndone",