sysprom 1.0.7 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +28 -28
  2. package/dist/src/canonical-json.d.ts +2 -0
  3. package/dist/src/cli/commands/add.d.ts +1 -1
  4. package/dist/src/cli/commands/add.js +2 -3
  5. package/dist/src/cli/commands/check.d.ts +6 -8
  6. package/dist/src/cli/commands/check.js +3 -8
  7. package/dist/src/cli/commands/graph.d.ts +3 -4
  8. package/dist/src/cli/commands/graph.js +3 -7
  9. package/dist/src/cli/commands/init.d.ts +15 -1
  10. package/dist/src/cli/commands/init.js +57 -27
  11. package/dist/src/cli/commands/plan.js +21 -39
  12. package/dist/src/cli/commands/query.js +10 -28
  13. package/dist/src/cli/commands/remove.d.ts +1 -1
  14. package/dist/src/cli/commands/remove.js +2 -3
  15. package/dist/src/cli/commands/rename.d.ts +1 -1
  16. package/dist/src/cli/commands/rename.js +2 -3
  17. package/dist/src/cli/commands/search.d.ts +1 -1
  18. package/dist/src/cli/commands/search.js +2 -3
  19. package/dist/src/cli/commands/stats.d.ts +6 -8
  20. package/dist/src/cli/commands/stats.js +3 -8
  21. package/dist/src/cli/commands/task.js +19 -24
  22. package/dist/src/cli/commands/update.js +6 -14
  23. package/dist/src/cli/commands/validate.d.ts +6 -8
  24. package/dist/src/cli/commands/validate.js +3 -8
  25. package/dist/src/cli/shared.d.ts +18 -3
  26. package/dist/src/cli/shared.js +100 -3
  27. package/dist/src/io.d.ts +5 -0
  28. package/dist/src/json-to-md.d.ts +1 -0
  29. package/dist/src/operations/add-node.d.ts +5 -0
  30. package/dist/src/operations/add-node.js +5 -0
  31. package/dist/src/operations/add-plan-task.d.ts +5 -0
  32. package/dist/src/operations/add-plan-task.js +5 -0
  33. package/dist/src/operations/add-relationship.d.ts +5 -0
  34. package/dist/src/operations/add-relationship.js +5 -0
  35. package/dist/src/operations/check.d.ts +5 -0
  36. package/dist/src/operations/check.js +5 -0
  37. package/dist/src/operations/define-operation.d.ts +31 -0
  38. package/dist/src/operations/define-operation.js +8 -0
  39. package/dist/src/operations/graph.d.ts +1 -0
  40. package/dist/src/operations/graph.js +1 -0
  41. package/dist/src/operations/init-document.d.ts +1 -0
  42. package/dist/src/operations/init-document.js +1 -0
  43. package/dist/src/operations/json-to-markdown.d.ts +1 -0
  44. package/dist/src/operations/json-to-markdown.js +1 -0
  45. package/dist/src/operations/mark-task-done.d.ts +5 -0
  46. package/dist/src/operations/mark-task-done.js +5 -0
  47. package/dist/src/operations/mark-task-undone.d.ts +5 -0
  48. package/dist/src/operations/mark-task-undone.js +5 -0
  49. package/dist/src/operations/markdown-to-json.d.ts +1 -0
  50. package/dist/src/operations/markdown-to-json.js +1 -0
  51. package/dist/src/operations/next-id.d.ts +6 -0
  52. package/dist/src/operations/next-id.js +6 -0
  53. package/dist/src/operations/node-history.d.ts +3 -0
  54. package/dist/src/operations/node-history.js +2 -0
  55. package/dist/src/operations/plan-add-task.d.ts +1 -0
  56. package/dist/src/operations/plan-add-task.js +1 -0
  57. package/dist/src/operations/plan-gate.d.ts +4 -0
  58. package/dist/src/operations/plan-gate.js +2 -0
  59. package/dist/src/operations/plan-init.d.ts +1 -0
  60. package/dist/src/operations/plan-init.js +1 -0
  61. package/dist/src/operations/plan-progress.d.ts +2 -0
  62. package/dist/src/operations/plan-progress.js +1 -0
  63. package/dist/src/operations/plan-status.d.ts +2 -0
  64. package/dist/src/operations/plan-status.js +1 -0
  65. package/dist/src/operations/query-node.d.ts +3 -0
  66. package/dist/src/operations/query-node.js +2 -0
  67. package/dist/src/operations/query-nodes.d.ts +1 -0
  68. package/dist/src/operations/query-nodes.js +1 -0
  69. package/dist/src/operations/query-relationships.d.ts +1 -0
  70. package/dist/src/operations/query-relationships.js +1 -0
  71. package/dist/src/operations/remove-node.d.ts +8 -0
  72. package/dist/src/operations/remove-node.js +7 -0
  73. package/dist/src/operations/remove-relationship.d.ts +5 -0
  74. package/dist/src/operations/remove-relationship.js +5 -0
  75. package/dist/src/operations/rename.d.ts +7 -0
  76. package/dist/src/operations/rename.js +7 -0
  77. package/dist/src/operations/search.d.ts +1 -0
  78. package/dist/src/operations/search.js +1 -0
  79. package/dist/src/operations/speckit-diff.d.ts +3 -0
  80. package/dist/src/operations/speckit-diff.js +2 -0
  81. package/dist/src/operations/speckit-export.d.ts +1 -0
  82. package/dist/src/operations/speckit-export.js +1 -0
  83. package/dist/src/operations/speckit-import.d.ts +1 -0
  84. package/dist/src/operations/speckit-import.js +1 -0
  85. package/dist/src/operations/speckit-sync.d.ts +3 -0
  86. package/dist/src/operations/speckit-sync.js +2 -0
  87. package/dist/src/operations/state-at.d.ts +3 -0
  88. package/dist/src/operations/state-at.js +2 -0
  89. package/dist/src/operations/stats.d.ts +3 -0
  90. package/dist/src/operations/stats.js +2 -0
  91. package/dist/src/operations/task-list.d.ts +6 -0
  92. package/dist/src/operations/task-list.js +6 -0
  93. package/dist/src/operations/timeline.d.ts +3 -0
  94. package/dist/src/operations/timeline.js +2 -0
  95. package/dist/src/operations/trace-from-node.d.ts +3 -0
  96. package/dist/src/operations/trace-from-node.js +2 -0
  97. package/dist/src/operations/update-metadata.d.ts +1 -0
  98. package/dist/src/operations/update-metadata.js +1 -0
  99. package/dist/src/operations/update-node.d.ts +5 -0
  100. package/dist/src/operations/update-node.js +5 -0
  101. package/dist/src/operations/update-plan-task.d.ts +5 -0
  102. package/dist/src/operations/update-plan-task.js +5 -0
  103. package/dist/src/operations/validate.d.ts +10 -0
  104. package/dist/src/operations/validate.js +9 -0
  105. package/dist/src/schema.d.ts +44 -0
  106. package/dist/src/schema.js +31 -0
  107. package/dist/src/speckit/generate.d.ts +6 -0
  108. package/dist/src/speckit/generate.js +6 -0
  109. package/dist/src/speckit/parse.d.ts +9 -0
  110. package/dist/src/speckit/parse.js +6 -0
  111. package/dist/src/speckit/plan.d.ts +5 -0
  112. package/dist/src/speckit/project.d.ts +6 -0
  113. package/package.json +1 -1
@@ -1,10 +1,13 @@
1
1
  import * as z from "zod";
2
+ /** Zod schema for a node's active lifecycle states at a point in time. */
2
3
  export declare const NodeState: z.ZodObject<{
3
4
  nodeId: z.ZodString;
4
5
  nodeName: z.ZodString;
5
6
  activeStates: z.ZodArray<z.ZodString>;
6
7
  }, z.core.$strip>;
8
+ /** A node's active lifecycle states at a given point in time. */
7
9
  export type NodeState = z.infer<typeof NodeState>;
10
+ /** Determine the active lifecycle states of all nodes at a specific point in time. Boolean lifecycle values are always included; ISO date values are included if they precede the query timestamp. */
8
11
  export declare const stateAtOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
9
12
  doc: z.ZodObject<{
10
13
  $schema: z.ZodOptional<z.ZodString>;
@@ -1,11 +1,13 @@
1
1
  import * as z from "zod";
2
2
  import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
+ /** Zod schema for a node's active lifecycle states at a point in time. */
4
5
  export const NodeState = z.object({
5
6
  nodeId: z.string(),
6
7
  nodeName: z.string(),
7
8
  activeStates: z.array(z.string()),
8
9
  });
10
+ /** Determine the active lifecycle states of all nodes at a specific point in time. Boolean lifecycle values are always included; ISO date values are included if they precede the query timestamp. */
9
11
  export const stateAtOp = defineOperation({
10
12
  name: "state-at",
11
13
  description: "Determine the active states of all nodes at a specific point in time",
@@ -1,4 +1,5 @@
1
1
  import * as z from "zod";
2
+ /** Zod schema for document statistics — node/relationship counts, subsystem depth, lifecycle breakdown. */
2
3
  export declare const DocumentStats: z.ZodObject<{
3
4
  title: z.ZodString;
4
5
  nodesByType: z.ZodRecord<z.ZodString, z.ZodNumber>;
@@ -12,7 +13,9 @@ export declare const DocumentStats: z.ZodObject<{
12
13
  decisionLifecycle: z.ZodRecord<z.ZodString, z.ZodNumber>;
13
14
  changeLifecycle: z.ZodRecord<z.ZodString, z.ZodNumber>;
14
15
  }, z.core.$strip>;
16
+ /** Computed statistics about a SysProM document. */
15
17
  export type DocumentStats = z.infer<typeof DocumentStats>;
18
+ /** Compute statistics about a SysProM document — node and relationship counts by type, subsystem depth, lifecycle breakdowns, and more. */
16
19
  export declare const statsOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
17
20
  doc: z.ZodObject<{
18
21
  $schema: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,7 @@
1
1
  import * as z from "zod";
2
2
  import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
+ /** Zod schema for document statistics — node/relationship counts, subsystem depth, lifecycle breakdown. */
4
5
  export const DocumentStats = z.object({
5
6
  title: z.string(),
6
7
  nodesByType: z.record(z.string(), z.number()),
@@ -14,6 +15,7 @@ export const DocumentStats = z.object({
14
15
  decisionLifecycle: z.record(z.string(), z.number()),
15
16
  changeLifecycle: z.record(z.string(), z.number()),
16
17
  });
18
+ /** Compute statistics about a SysProM document — node and relationship counts by type, subsystem depth, lifecycle breakdowns, and more. */
17
19
  export const statsOp = defineOperation({
18
20
  name: "stats",
19
21
  description: "Compute statistics about a SysProM document",
@@ -1,4 +1,10 @@
1
1
  import * as z from "zod";
2
+ /**
3
+ * List tasks across change nodes, optionally filtered by change ID and/or
4
+ * pending status. Returns a flat array of task rows tagged with their parent change node.
5
+ *
6
+ * @throws If a specific changeId is provided but not found.
7
+ */
2
8
  export declare const taskListOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
3
9
  doc: z.ZodObject<{
4
10
  $schema: z.ZodOptional<z.ZodString>;
@@ -8,6 +8,12 @@ const TaskRow = z.object({
8
8
  description: z.string(),
9
9
  done: z.boolean(),
10
10
  });
11
+ /**
12
+ * List tasks across change nodes, optionally filtered by change ID and/or
13
+ * pending status. Returns a flat array of task rows tagged with their parent change node.
14
+ *
15
+ * @throws If a specific changeId is provided but not found.
16
+ */
11
17
  export const taskListOp = defineOperation({
12
18
  name: "taskList",
13
19
  description: "List tasks across change nodes. Optionally filter by change ID and/or pending status.",
@@ -1,4 +1,5 @@
1
1
  import * as z from "zod";
2
+ /** Zod schema for a timestamped lifecycle event extracted from a node. */
2
3
  export declare const TimelineEvent: z.ZodObject<{
3
4
  nodeId: z.ZodString;
4
5
  nodeName: z.ZodString;
@@ -6,7 +7,9 @@ export declare const TimelineEvent: z.ZodObject<{
6
7
  state: z.ZodString;
7
8
  timestamp: z.ZodString;
8
9
  }, z.core.$strip>;
10
+ /** A timestamped lifecycle event — when a node entered a particular state. */
9
11
  export type TimelineEvent = z.infer<typeof TimelineEvent>;
12
+ /** Extract all timestamped lifecycle events from a document, sorted chronologically. Recursively includes subsystem events. */
10
13
  export declare const timelineOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
11
14
  doc: z.ZodObject<{
12
15
  $schema: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,7 @@
1
1
  import * as z from "zod";
2
2
  import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
+ /** Zod schema for a timestamped lifecycle event extracted from a node. */
4
5
  export const TimelineEvent = z.object({
5
6
  nodeId: z.string(),
6
7
  nodeName: z.string(),
@@ -8,6 +9,7 @@ export const TimelineEvent = z.object({
8
9
  state: z.string(),
9
10
  timestamp: z.string(),
10
11
  });
12
+ /** Extract all timestamped lifecycle events from a document, sorted chronologically. Recursively includes subsystem events. */
11
13
  export const timelineOp = defineOperation({
12
14
  name: "timeline",
13
15
  description: "Extract all timestamped lifecycle events from a document, sorted chronologically",
@@ -298,6 +298,7 @@ declare const TraceNodeSchema: z.ZodObject<{
298
298
  }>;
299
299
  children: z.ZodArray<typeof TraceNodeSchema>;
300
300
  }, z.core.$strip>;
301
+ /** Zod schema for a node in the refinement trace tree. */
301
302
  export declare const TraceNode: z.ZodObject<{
302
303
  id: z.ZodString;
303
304
  node: z.ZodOptional<z.ZodObject<{
@@ -597,7 +598,9 @@ export declare const TraceNode: z.ZodObject<{
597
598
  }>;
598
599
  children: z.ZodArray<typeof TraceNodeSchema>;
599
600
  }, z.core.$strip>;
601
+ /** A node in the refinement trace tree, with optional children that refine/realise/implement it. */
600
602
  export type TraceNode = z.infer<typeof TraceNodeSchema>;
603
+ /** Trace the refinement chain from a node, following `refines`, `realises`, and `implements` relationships recursively. */
601
604
  export declare const traceFromNodeOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
602
605
  doc: z.ZodObject<{
603
606
  $schema: z.ZodOptional<z.ZodString>;
@@ -9,7 +9,9 @@ const TraceNodeSchema = z.object({
9
9
  return z.array(TraceNodeSchema);
10
10
  },
11
11
  });
12
+ /** Zod schema for a node in the refinement trace tree. */
12
13
  export const TraceNode = TraceNodeSchema;
14
+ /** Trace the refinement chain from a node, following `refines`, `realises`, and `implements` relationships recursively. */
13
15
  export const traceFromNodeOp = defineOperation({
14
16
  name: "trace-from-node",
15
17
  description: "Trace refinement chain from a node (follows refines, realises, implements)",
@@ -1,4 +1,5 @@
1
1
  import * as z from "zod";
2
+ /** Update document-level metadata fields, merging the provided fields into the existing metadata. */
2
3
  export declare const updateMetadataOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
3
4
  doc: z.ZodObject<{
4
5
  $schema: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,7 @@
1
1
  import * as z from "zod";
2
2
  import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
+ /** Update document-level metadata fields, merging the provided fields into the existing metadata. */
4
5
  export const updateMetadataOp = defineOperation({
5
6
  name: "updateMetadata",
6
7
  description: "Update metadata fields. Returns a new document.",
@@ -1,4 +1,9 @@
1
1
  import * as z from "zod";
2
+ /**
3
+ * Update specified fields on a node, merging the provided fields into the existing node.
4
+ *
5
+ * @throws If the node ID is not found.
6
+ */
2
7
  export declare const updateNodeOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
3
8
  doc: z.ZodObject<{
4
9
  $schema: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,11 @@
1
1
  import * as z from "zod";
2
2
  import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument, Node } from "../schema.js";
4
+ /**
5
+ * Update specified fields on a node, merging the provided fields into the existing node.
6
+ *
7
+ * @throws If the node ID is not found.
8
+ */
4
9
  export const updateNodeOp = defineOperation({
5
10
  name: "updateNode",
6
11
  description: "Update specified fields on a node. Throws if the node is not found.",
@@ -1,4 +1,9 @@
1
1
  import * as z from "zod";
2
+ /**
3
+ * Set the done status of a task in a change node's plan array. Returns a new document.
4
+ *
5
+ * @throws If the change node is not found or the task index is out of range.
6
+ */
2
7
  export declare const updatePlanTaskOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
3
8
  doc: z.ZodObject<{
4
9
  $schema: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,11 @@
1
1
  import * as z from "zod";
2
2
  import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
+ /**
5
+ * Set the done status of a task in a change node's plan array. Returns a new document.
6
+ *
7
+ * @throws If the change node is not found or the task index is out of range.
8
+ */
4
9
  export const updatePlanTaskOp = defineOperation({
5
10
  name: "updatePlanTask",
6
11
  description: "Set the done status of a task in a change node's plan array. Returns a new document.",
@@ -1,11 +1,21 @@
1
1
  import * as z from "zod";
2
+ /** Zod schema for the result of validating a SysProM document. */
2
3
  export declare const ValidationResult: z.ZodObject<{
3
4
  valid: z.ZodBoolean;
4
5
  issues: z.ZodArray<z.ZodString>;
5
6
  nodeCount: z.ZodNumber;
6
7
  relationshipCount: z.ZodNumber;
7
8
  }, z.core.$strip>;
9
+ /** Result of document validation: validity flag, issues list, and counts. */
8
10
  export type ValidationResult = z.infer<typeof ValidationResult>;
11
+ /**
12
+ * Validate a SysProM document for structural and semantic correctness.
13
+ *
14
+ * Checks for duplicate node IDs, dangling relationship endpoints, and
15
+ * invariant violations (INV2: changes must reference decisions, INV3:
16
+ * decisions affecting domain nodes must have must_preserve, INV13:
17
+ * decisions must have options and selected).
18
+ */
9
19
  export declare const validateOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
10
20
  doc: z.ZodObject<{
11
21
  $schema: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,7 @@
1
1
  import * as z from "zod";
2
2
  import { defineOperation } from "./define-operation.js";
3
3
  import { SysProMDocument } from "../schema.js";
4
+ /** Zod schema for the result of validating a SysProM document. */
4
5
  export const ValidationResult = z.object({
5
6
  valid: z.boolean(),
6
7
  issues: z.array(z.string()),
@@ -14,6 +15,14 @@ const DOMAIN_TYPES = new Set([
14
15
  "element",
15
16
  "invariant",
16
17
  ]);
18
+ /**
19
+ * Validate a SysProM document for structural and semantic correctness.
20
+ *
21
+ * Checks for duplicate node IDs, dangling relationship endpoints, and
22
+ * invariant violations (INV2: changes must reference decisions, INV3:
23
+ * decisions affecting domain nodes must have must_preserve, INV13:
24
+ * decisions must have options and selected).
25
+ */
17
26
  export const validateOp = defineOperation({
18
27
  name: "validate",
19
28
  description: "Validate a SysProM document for structural and semantic correctness",
@@ -1,8 +1,14 @@
1
1
  import * as z from "zod";
2
+ /**
3
+ * Zod schema for flexible text content — accepts either a single string or an
4
+ * array of lines. Includes a `.is()` type guard for runtime checks.
5
+ */
2
6
  export declare const Text: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
3
7
  is(value: unknown): value is string | string[];
4
8
  };
9
+ /** A text value: either a single string or an array of lines. */
5
10
  export type Text = z.infer<typeof Text>;
11
+ /** Zod schema for the set of valid node types (e.g. `"intent"`, `"decision"`, `"change"`). */
6
12
  export declare const NodeType: z.ZodEnum<{
7
13
  intent: "intent";
8
14
  concept: "concept";
@@ -27,7 +33,9 @@ export declare const NodeType: z.ZodEnum<{
27
33
  }> & {
28
34
  is(value: unknown): value is "intent" | "concept" | "capability" | "element" | "realisation" | "invariant" | "principle" | "policy" | "protocol" | "stage" | "role" | "gate" | "mode" | "artefact" | "artefact_flow" | "decision" | "change" | "view" | "milestone" | "version";
29
35
  };
36
+ /** A valid node type string. */
30
37
  export type NodeType = z.infer<typeof NodeType>;
38
+ /** Map from node type key to its human-readable label (e.g. `intent` → `"Intent"`). */
31
39
  export declare const NODE_TYPE_LABELS: {
32
40
  readonly intent: "Intent";
33
41
  readonly concept: "Concepts";
@@ -50,8 +58,11 @@ export declare const NODE_TYPE_LABELS: {
50
58
  readonly milestone: "Milestones";
51
59
  readonly version: "Versions";
52
60
  };
61
+ /** Reverse map from human-readable label to node type key (e.g. `"Intent"` → `"intent"`). */
53
62
  export declare const NODE_LABEL_TO_TYPE: Record<string, "intent" | "concept" | "capability" | "element" | "realisation" | "invariant" | "principle" | "policy" | "protocol" | "stage" | "role" | "gate" | "mode" | "artefact" | "artefact_flow" | "decision" | "change" | "view" | "milestone" | "version">;
63
+ /** All valid node status values, ordered by typical lifecycle progression. */
54
64
  export declare const NODE_STATUSES: readonly ["proposed", "accepted", "active", "implemented", "adopted", "defined", "introduced", "in_progress", "complete", "consolidated", "experimental", "deprecated", "retired", "superseded", "abandoned", "deferred"];
65
+ /** Zod schema for the set of valid node statuses (e.g. `"proposed"`, `"active"`, `"deprecated"`). */
55
66
  export declare const NodeStatus: z.ZodEnum<{
56
67
  deprecated: "deprecated";
57
68
  proposed: "proposed";
@@ -72,7 +83,9 @@ export declare const NodeStatus: z.ZodEnum<{
72
83
  }> & {
73
84
  is(value: unknown): value is "deprecated" | "proposed" | "accepted" | "active" | "implemented" | "adopted" | "defined" | "introduced" | "in_progress" | "complete" | "consolidated" | "experimental" | "retired" | "superseded" | "abandoned" | "deferred";
74
85
  };
86
+ /** A valid node status string. */
75
87
  export type NodeStatus = z.infer<typeof NodeStatus>;
88
+ /** Zod schema for the set of valid relationship types (e.g. `"refines"`, `"depends_on"`, `"affects"`). */
76
89
  export declare const RelationshipType: z.ZodEnum<{
77
90
  refines: "refines";
78
91
  realises: "realises";
@@ -101,7 +114,9 @@ export declare const RelationshipType: z.ZodEnum<{
101
114
  }> & {
102
115
  is(value: unknown): value is "refines" | "realises" | "implements" | "depends_on" | "constrained_by" | "affects" | "supersedes" | "must_preserve" | "performs" | "part_of" | "precedes" | "must_follow" | "blocks" | "routes_to" | "governed_by" | "modifies" | "triggered_by" | "applies_to" | "produces" | "consumes" | "transforms_into" | "selects" | "requires" | "disables";
103
116
  };
117
+ /** A valid relationship type string. */
104
118
  export type RelationshipType = z.infer<typeof RelationshipType>;
119
+ /** Map from relationship type key to its human-readable label (e.g. `refines` → `"Refines"`). */
105
120
  export declare const RELATIONSHIP_TYPE_LABELS: {
106
121
  readonly refines: "Refines";
107
122
  readonly realises: "Realises";
@@ -128,7 +143,9 @@ export declare const RELATIONSHIP_TYPE_LABELS: {
128
143
  readonly requires: "Requires";
129
144
  readonly disables: "Disables";
130
145
  };
146
+ /** Reverse map from human-readable label to relationship type key (e.g. `"Refines"` → `"refines"`). */
131
147
  export declare const RELATIONSHIP_LABEL_TO_TYPE: Record<string, "refines" | "realises" | "implements" | "depends_on" | "constrained_by" | "affects" | "supersedes" | "must_preserve" | "performs" | "part_of" | "precedes" | "must_follow" | "blocks" | "routes_to" | "governed_by" | "modifies" | "triggered_by" | "applies_to" | "produces" | "consumes" | "transforms_into" | "selects" | "requires" | "disables">;
148
+ /** Zod schema for external reference roles (e.g. `"input"`, `"output"`, `"evidence"`). */
132
149
  export declare const ExternalReferenceRole: z.ZodEnum<{
133
150
  output: "output";
134
151
  input: "input";
@@ -140,7 +157,9 @@ export declare const ExternalReferenceRole: z.ZodEnum<{
140
157
  }> & {
141
158
  is(value: unknown): value is "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
142
159
  };
160
+ /** A valid external reference role string. */
143
161
  export type ExternalReferenceRole = z.infer<typeof ExternalReferenceRole>;
162
+ /** Map from external reference role key to its human-readable label. */
144
163
  export declare const EXTERNAL_REFERENCE_ROLE_LABELS: {
145
164
  readonly input: "Input";
146
165
  readonly output: "Output";
@@ -150,7 +169,9 @@ export declare const EXTERNAL_REFERENCE_ROLE_LABELS: {
150
169
  readonly standard: "Standard";
151
170
  readonly prior_art: "Prior art";
152
171
  };
172
+ /** Reverse map from human-readable label to external reference role key. */
153
173
  export declare const EXTERNAL_REFERENCE_LABEL_TO_ROLE: Record<string, "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art">;
174
+ /** Zod schema for a decision option — an alternative considered during a decision. */
154
175
  export declare const Option: z.ZodObject<{
155
176
  id: z.ZodString;
156
177
  description: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
@@ -163,7 +184,9 @@ export declare const Option: z.ZodObject<{
163
184
  description: string | string[];
164
185
  };
165
186
  };
187
+ /** An alternative considered as part of a decision, with an ID and description. */
166
188
  export type Option = z.infer<typeof Option>;
189
+ /** Zod schema for an atomic operation within a change (add, update, remove, or link). */
167
190
  export declare const Operation: z.ZodObject<{
168
191
  type: z.ZodEnum<{
169
192
  link: "link";
@@ -183,7 +206,9 @@ export declare const Operation: z.ZodObject<{
183
206
  description?: string | string[] | undefined;
184
207
  };
185
208
  };
209
+ /** An atomic operation within a change, targeting a specific node. */
186
210
  export type Operation = z.infer<typeof Operation>;
211
+ /** Zod schema for a task within a change's execution plan. */
187
212
  export declare const Task: z.ZodObject<{
188
213
  description: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
189
214
  is(value: unknown): value is string | string[];
@@ -196,7 +221,9 @@ export declare const Task: z.ZodObject<{
196
221
  done?: boolean | undefined;
197
222
  };
198
223
  };
224
+ /** A single task within a change's execution plan, with a description and done flag. */
199
225
  export type Task = z.infer<typeof Task>;
226
+ /** Zod schema for an external reference — a link to a resource outside the SysProM graph. */
200
227
  export declare const ExternalReference: z.ZodObject<{
201
228
  role: z.ZodEnum<{
202
229
  output: "output";
@@ -226,7 +253,9 @@ export declare const ExternalReference: z.ZodObject<{
226
253
  internalised?: string | string[] | undefined;
227
254
  };
228
255
  };
256
+ /** A reference to a resource outside the SysProM graph (URI, file path, DOI, etc.). */
229
257
  export type ExternalReference = z.infer<typeof ExternalReference>;
258
+ /** Zod schema for document-level metadata (title, scope, status, version). */
230
259
  export declare const Metadata: z.ZodObject<{
231
260
  title: z.ZodOptional<z.ZodString>;
232
261
  doc_type: z.ZodOptional<z.ZodString>;
@@ -243,7 +272,9 @@ export declare const Metadata: z.ZodObject<{
243
272
  version?: string | number | undefined;
244
273
  };
245
274
  };
275
+ /** Document-level metadata — title, scope, status, and version. */
246
276
  export type Metadata = z.infer<typeof Metadata>;
277
+ /** Zod schema for a typed, directed relationship between two nodes. */
247
278
  export declare const Relationship: z.ZodObject<{
248
279
  from: z.ZodString;
249
280
  to: z.ZodString;
@@ -287,6 +318,7 @@ export declare const Relationship: z.ZodObject<{
287
318
  description?: string | string[] | undefined;
288
319
  };
289
320
  };
321
+ /** A typed, directed connection between two nodes, with from/to IDs and a relationship type. */
290
322
  export type Relationship = z.infer<typeof Relationship>;
291
323
  declare const SysProMDocumentSchema: z.ZodObject<{
292
324
  $schema: z.ZodOptional<z.ZodString>;
@@ -517,6 +549,11 @@ declare const NodeSchema: z.ZodObject<{
517
549
  }>>;
518
550
  readonly subsystem: z.ZodOptional<typeof SysProMDocumentSchema>;
519
551
  }, z.core.$loose>;
552
+ /**
553
+ * Zod schema for a complete SysProM document — the root container holding
554
+ * nodes, relationships, external references, and metadata. Includes a `.is()`
555
+ * type guard for runtime validation.
556
+ */
520
557
  export declare const SysProMDocument: z.ZodObject<{
521
558
  $schema: z.ZodOptional<z.ZodString>;
522
559
  metadata: z.ZodOptional<z.ZodObject<{
@@ -676,7 +713,13 @@ export declare const SysProMDocument: z.ZodObject<{
676
713
  }[] | undefined;
677
714
  };
678
715
  };
716
+ /** A complete SysProM document with metadata, nodes, relationships, and external references. */
679
717
  export type SysProMDocument = z.infer<typeof SysProMDocument>;
718
+ /**
719
+ * Zod schema for a single node in the SysProM graph. Nodes are typed entities
720
+ * with optional lifecycle, decisions, operations, and recursive subsystems.
721
+ * Includes a `.is()` type guard for runtime validation.
722
+ */
680
723
  export declare const Node: z.ZodObject<{
681
724
  id: z.ZodString;
682
725
  type: z.ZodEnum<{
@@ -881,6 +924,7 @@ export declare const Node: z.ZodObject<{
881
924
  } | undefined;
882
925
  };
883
926
  };
927
+ /** A uniquely identifiable entity within the SysProM graph. */
884
928
  export type Node = z.infer<typeof Node>;
885
929
  /** Which node types belong in which document file. */
886
930
  export declare const NODE_FILE_MAP: Record<string, string[]>;
@@ -12,6 +12,10 @@ function defineSchema(schema) {
12
12
  // ---------------------------------------------------------------------------
13
13
  // Text type — allows a string or an array of lines
14
14
  // ---------------------------------------------------------------------------
15
+ /**
16
+ * Zod schema for flexible text content — accepts either a single string or an
17
+ * array of lines. Includes a `.is()` type guard for runtime checks.
18
+ */
15
19
  export const Text = defineSchema(z.union([z.string(), z.array(z.string())]));
16
20
  // ---------------------------------------------------------------------------
17
21
  // Extensible string types
@@ -70,12 +74,16 @@ const nodeTypeDef = labelledEnum({
70
74
  milestone: "Milestones",
71
75
  version: "Versions",
72
76
  });
77
+ /** Zod schema for the set of valid node types (e.g. `"intent"`, `"decision"`, `"change"`). */
73
78
  export const NodeType = nodeTypeDef.schema;
79
+ /** Map from node type key to its human-readable label (e.g. `intent` → `"Intent"`). */
74
80
  export const NODE_TYPE_LABELS = nodeTypeDef.labels;
81
+ /** Reverse map from human-readable label to node type key (e.g. `"Intent"` → `"intent"`). */
75
82
  export const NODE_LABEL_TO_TYPE = nodeTypeDef.reverse;
76
83
  // ---------------------------------------------------------------------------
77
84
  // Node statuses
78
85
  // ---------------------------------------------------------------------------
86
+ /** All valid node status values, ordered by typical lifecycle progression. */
79
87
  export const NODE_STATUSES = [
80
88
  "proposed",
81
89
  "accepted",
@@ -94,6 +102,7 @@ export const NODE_STATUSES = [
94
102
  "abandoned",
95
103
  "deferred",
96
104
  ];
105
+ /** Zod schema for the set of valid node statuses (e.g. `"proposed"`, `"active"`, `"deprecated"`). */
97
106
  export const NodeStatus = defineSchema(z.enum(NODE_STATUSES));
98
107
  // ---------------------------------------------------------------------------
99
108
  // Relationship types
@@ -124,8 +133,11 @@ const relationshipTypeDef = labelledEnum({
124
133
  requires: "Requires",
125
134
  disables: "Disables",
126
135
  });
136
+ /** Zod schema for the set of valid relationship types (e.g. `"refines"`, `"depends_on"`, `"affects"`). */
127
137
  export const RelationshipType = relationshipTypeDef.schema;
138
+ /** Map from relationship type key to its human-readable label (e.g. `refines` → `"Refines"`). */
128
139
  export const RELATIONSHIP_TYPE_LABELS = relationshipTypeDef.labels;
140
+ /** Reverse map from human-readable label to relationship type key (e.g. `"Refines"` → `"refines"`). */
129
141
  export const RELATIONSHIP_LABEL_TO_TYPE = relationshipTypeDef.reverse;
130
142
  // ---------------------------------------------------------------------------
131
143
  // External reference roles
@@ -139,18 +151,23 @@ const externalReferenceRoleDef = labelledEnum({
139
151
  standard: "Standard",
140
152
  prior_art: "Prior art",
141
153
  });
154
+ /** Zod schema for external reference roles (e.g. `"input"`, `"output"`, `"evidence"`). */
142
155
  export const ExternalReferenceRole = externalReferenceRoleDef.schema;
156
+ /** Map from external reference role key to its human-readable label. */
143
157
  export const EXTERNAL_REFERENCE_ROLE_LABELS = externalReferenceRoleDef.labels;
158
+ /** Reverse map from human-readable label to external reference role key. */
144
159
  export const EXTERNAL_REFERENCE_LABEL_TO_ROLE = externalReferenceRoleDef.reverse;
145
160
  // ---------------------------------------------------------------------------
146
161
  // Leaf schemas
147
162
  // ---------------------------------------------------------------------------
163
+ /** Zod schema for a decision option — an alternative considered during a decision. */
148
164
  export const Option = defineSchema(z
149
165
  .looseObject({
150
166
  id: z.string(),
151
167
  description: Text,
152
168
  })
153
169
  .describe("An alternative considered as part of a decision."));
170
+ /** Zod schema for an atomic operation within a change (add, update, remove, or link). */
154
171
  export const Operation = defineSchema(z
155
172
  .looseObject({
156
173
  type: z.enum(["add", "update", "remove", "link"]),
@@ -158,12 +175,14 @@ export const Operation = defineSchema(z
158
175
  description: Text.optional(),
159
176
  })
160
177
  .describe("An atomic operation within a change."));
178
+ /** Zod schema for a task within a change's execution plan. */
161
179
  export const Task = defineSchema(z
162
180
  .looseObject({
163
181
  description: Text,
164
182
  done: z.boolean().default(false).optional(),
165
183
  })
166
184
  .describe("A single task within a change's execution plan."));
185
+ /** Zod schema for an external reference — a link to a resource outside the SysProM graph. */
167
186
  export const ExternalReference = defineSchema(z
168
187
  .object({
169
188
  role: ExternalReferenceRole,
@@ -178,6 +197,7 @@ export const ExternalReference = defineSchema(z
178
197
  internalised: Text.describe("Inline content captured from the external resource. When present, the node is self-contained and does not depend on the external identifier being resolvable.").optional(),
179
198
  })
180
199
  .describe("A reference to a resource outside the SysProM graph."));
200
+ /** Zod schema for document-level metadata (title, scope, status, version). */
181
201
  export const Metadata = defineSchema(z
182
202
  .looseObject({
183
203
  title: z.string().optional(),
@@ -193,6 +213,7 @@ export const Metadata = defineSchema(z
193
213
  version: z.union([z.string(), z.int()]).optional(),
194
214
  })
195
215
  .describe("Document-level metadata. Analogous to front matter in Markdown."));
216
+ /** Zod schema for a typed, directed relationship between two nodes. */
196
217
  export const Relationship = defineSchema(z
197
218
  .looseObject({
198
219
  from: z.string().describe("Source node ID."),
@@ -288,7 +309,17 @@ const NodeSchema = z
288
309
  })
289
310
  .describe("A uniquely identifiable entity within the system.");
290
311
  // Attach .is() type guards after both schemas are declared
312
+ /**
313
+ * Zod schema for a complete SysProM document — the root container holding
314
+ * nodes, relationships, external references, and metadata. Includes a `.is()`
315
+ * type guard for runtime validation.
316
+ */
291
317
  export const SysProMDocument = defineSchema(SysProMDocumentSchema);
318
+ /**
319
+ * Zod schema for a single node in the SysProM graph. Nodes are typed entities
320
+ * with optional lifecycle, decisions, operations, and recursive subsystems.
321
+ * Includes a `.is()` type guard for runtime validation.
322
+ */
292
323
  export const Node = defineSchema(NodeSchema);
293
324
  // ---------------------------------------------------------------------------
294
325
  // Domain constants
@@ -1,7 +1,13 @@
1
1
  import type { SysProMDocument } from "../schema.js";
2
+ /** Generate a Spec-Kit constitution file from a SysProM document's principles and invariants. */
2
3
  export declare function generateConstitution(doc: SysProMDocument, prefix: string): string;
4
+ /** Generate a Spec-Kit specification file from a SysProM document's user stories, FRs, and acceptance criteria. */
3
5
  export declare function generateSpec(doc: SysProMDocument, prefix: string): string;
6
+ /** Generate a Spec-Kit plan file from a SysProM document's phases and milestones. */
4
7
  export declare function generatePlan(doc: SysProMDocument, prefix: string): string;
8
+ /** Generate a Spec-Kit tasks file from a SysProM document's change nodes. */
5
9
  export declare function generateTasks(doc: SysProMDocument, prefix: string): string;
10
+ /** Generate a Spec-Kit checklist file from a SysProM document's gate nodes. */
6
11
  export declare function generateChecklist(doc: SysProMDocument, prefix: string): string;
12
+ /** Generate a complete Spec-Kit project directory from a SysProM document — constitution, spec, plan, tasks, and checklist files. */
7
13
  export declare function generateSpecKitProject(doc: SysProMDocument, outputDir: string, prefix: string): void;
@@ -87,6 +87,7 @@ function formatStatus(status) {
87
87
  // ============================================================================
88
88
  // generate Constitution
89
89
  // ============================================================================
90
+ /** Generate a Spec-Kit constitution file from a SysProM document's principles and invariants. */
90
91
  export function generateConstitution(doc, prefix) {
91
92
  const protocolId = `${prefix}-CONST`;
92
93
  const protocol = findNode(doc, protocolId);
@@ -159,6 +160,7 @@ export function generateConstitution(doc, prefix) {
159
160
  // ============================================================================
160
161
  // generateSpec
161
162
  // ============================================================================
163
+ /** Generate a Spec-Kit specification file from a SysProM document's user stories, FRs, and acceptance criteria. */
162
164
  export function generateSpec(doc, prefix) {
163
165
  const specId = `${prefix}-SPEC`;
164
166
  const spec = findNode(doc, specId);
@@ -272,6 +274,7 @@ export function generateSpec(doc, prefix) {
272
274
  // ============================================================================
273
275
  // generatePlan
274
276
  // ============================================================================
277
+ /** Generate a Spec-Kit plan file from a SysProM document's phases and milestones. */
275
278
  export function generatePlan(doc, prefix) {
276
279
  const implProtocolId = `${prefix}-PROT-IMPL`;
277
280
  const protocol = findNode(doc, implProtocolId);
@@ -322,6 +325,7 @@ export function generatePlan(doc, prefix) {
322
325
  // ============================================================================
323
326
  // generateTasks
324
327
  // ============================================================================
328
+ /** Generate a Spec-Kit tasks file from a SysProM document's change nodes. */
325
329
  export function generateTasks(doc, prefix) {
326
330
  const implProtocolId = `${prefix}-PROT-IMPL`;
327
331
  const protocol = findNode(doc, implProtocolId);
@@ -461,6 +465,7 @@ export function generateTasks(doc, prefix) {
461
465
  // ============================================================================
462
466
  // generateChecklist
463
467
  // ============================================================================
468
+ /** Generate a Spec-Kit checklist file from a SysProM document's gate nodes. */
464
469
  export function generateChecklist(doc, prefix) {
465
470
  const gateId = `${prefix}-CHK`;
466
471
  const gate = findNode(doc, gateId);
@@ -515,6 +520,7 @@ export function generateChecklist(doc, prefix) {
515
520
  // ============================================================================
516
521
  // generateSpecKitProject
517
522
  // ============================================================================
523
+ /** Generate a complete Spec-Kit project directory from a SysProM document — constitution, spec, plan, tasks, and checklist files. */
518
524
  export function generateSpecKitProject(doc, outputDir, prefix) {
519
525
  // Create output directory if it doesn't exist
520
526
  mkdirSync(outputDir, { recursive: true });
@@ -1,11 +1,20 @@
1
1
  import type { SysProMDocument, Node, Relationship } from "../schema.js";
2
+ /** Result of parsing a Spec-Kit file — extracted nodes and relationships. */
2
3
  export interface ParseResult {
4
+ /** Nodes extracted from the parsed content. */
3
5
  nodes: Node[];
6
+ /** Relationships extracted from the parsed content. */
4
7
  relationships: Relationship[];
5
8
  }
9
+ /** Parse a Spec-Kit constitution file into SysProM nodes (principles and invariants) and relationships. */
6
10
  export declare function parseConstitution(content: string, idPrefix: string): ParseResult;
11
+ /** Parse a Spec-Kit specification file into SysProM nodes (user stories, functional requirements, acceptance criteria). */
7
12
  export declare function parseSpec(content: string, idPrefix: string): ParseResult;
13
+ /** Parse a Spec-Kit plan file into SysProM nodes (phases, milestones) and relationships. */
8
14
  export declare function parsePlan(content: string, idPrefix: string): ParseResult;
15
+ /** Parse a Spec-Kit tasks file into SysProM change nodes with task plans. */
9
16
  export declare function parseTasks(content: string, idPrefix: string): ParseResult;
17
+ /** Parse a Spec-Kit checklist file into SysProM gate nodes with task plans. */
10
18
  export declare function parseChecklist(content: string, idPrefix: string): ParseResult;
19
+ /** Parse an entire Spec-Kit feature directory into a SysProM document, combining constitution, spec, plan, tasks, and checklist. */
11
20
  export declare function parseSpecKitFeature(featureDir: string, idPrefix: string, constitutionPath?: string): SysProMDocument;