sysprom 1.0.0 → 1.0.5

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 (148) hide show
  1. package/README.md +207 -0
  2. package/dist/schema.json +510 -0
  3. package/dist/src/canonical-json.d.ts +23 -0
  4. package/dist/src/canonical-json.js +120 -0
  5. package/dist/src/cli/commands/add.d.ts +22 -0
  6. package/dist/src/cli/commands/add.js +95 -0
  7. package/dist/src/cli/commands/check.d.ts +10 -0
  8. package/dist/src/cli/commands/check.js +33 -0
  9. package/dist/src/cli/commands/graph.d.ts +15 -0
  10. package/dist/src/cli/commands/graph.js +32 -0
  11. package/dist/src/cli/commands/init.d.ts +2 -0
  12. package/dist/src/cli/commands/init.js +44 -0
  13. package/dist/src/cli/commands/json2md.d.ts +2 -0
  14. package/dist/src/cli/commands/json2md.js +60 -0
  15. package/dist/src/cli/commands/md2json.d.ts +2 -0
  16. package/dist/src/cli/commands/md2json.js +29 -0
  17. package/dist/src/cli/commands/plan.d.ts +2 -0
  18. package/dist/src/cli/commands/plan.js +227 -0
  19. package/dist/src/cli/commands/query.d.ts +2 -0
  20. package/dist/src/cli/commands/query.js +275 -0
  21. package/dist/src/cli/commands/remove.d.ts +13 -0
  22. package/dist/src/cli/commands/remove.js +50 -0
  23. package/dist/src/cli/commands/rename.d.ts +14 -0
  24. package/dist/src/cli/commands/rename.js +34 -0
  25. package/dist/src/cli/commands/search.d.ts +11 -0
  26. package/dist/src/cli/commands/search.js +37 -0
  27. package/dist/src/cli/commands/speckit.d.ts +2 -0
  28. package/dist/src/cli/commands/speckit.js +318 -0
  29. package/dist/src/cli/commands/stats.d.ts +10 -0
  30. package/dist/src/cli/commands/stats.js +51 -0
  31. package/dist/src/cli/commands/task.d.ts +2 -0
  32. package/dist/src/cli/commands/task.js +162 -0
  33. package/dist/src/cli/commands/update.d.ts +2 -0
  34. package/dist/src/cli/commands/update.js +219 -0
  35. package/dist/src/cli/commands/validate.d.ts +10 -0
  36. package/dist/src/cli/commands/validate.js +30 -0
  37. package/dist/src/cli/define-command.d.ts +34 -0
  38. package/dist/src/cli/define-command.js +237 -0
  39. package/dist/src/cli/index.d.ts +2 -0
  40. package/dist/src/cli/index.js +3 -0
  41. package/dist/src/cli/program.d.ts +4 -0
  42. package/dist/src/cli/program.js +46 -0
  43. package/dist/src/cli/shared.d.ts +26 -0
  44. package/dist/src/cli/shared.js +41 -0
  45. package/dist/src/generate-schema.d.ts +1 -0
  46. package/dist/src/generate-schema.js +9 -0
  47. package/dist/src/index.d.ts +48 -0
  48. package/dist/src/index.js +99 -0
  49. package/dist/src/io.d.ts +22 -0
  50. package/dist/src/io.js +66 -0
  51. package/dist/src/json-to-md.d.ts +26 -0
  52. package/dist/src/json-to-md.js +498 -0
  53. package/dist/src/md-to-json.d.ts +22 -0
  54. package/dist/src/md-to-json.js +548 -0
  55. package/dist/src/operations/add-node.d.ts +887 -0
  56. package/dist/src/operations/add-node.js +21 -0
  57. package/dist/src/operations/add-plan-task.d.ts +594 -0
  58. package/dist/src/operations/add-plan-task.js +25 -0
  59. package/dist/src/operations/add-relationship.d.ts +635 -0
  60. package/dist/src/operations/add-relationship.js +25 -0
  61. package/dist/src/operations/check.d.ts +301 -0
  62. package/dist/src/operations/check.js +66 -0
  63. package/dist/src/operations/define-operation.d.ts +14 -0
  64. package/dist/src/operations/define-operation.js +21 -0
  65. package/dist/src/operations/graph.d.ts +303 -0
  66. package/dist/src/operations/graph.js +71 -0
  67. package/dist/src/operations/index.d.ts +38 -0
  68. package/dist/src/operations/index.js +45 -0
  69. package/dist/src/operations/init-document.d.ts +299 -0
  70. package/dist/src/operations/init-document.js +26 -0
  71. package/dist/src/operations/json-to-markdown.d.ts +298 -0
  72. package/dist/src/operations/json-to-markdown.js +13 -0
  73. package/dist/src/operations/mark-task-done.d.ts +594 -0
  74. package/dist/src/operations/mark-task-done.js +26 -0
  75. package/dist/src/operations/mark-task-undone.d.ts +594 -0
  76. package/dist/src/operations/mark-task-undone.js +26 -0
  77. package/dist/src/operations/markdown-to-json.d.ts +298 -0
  78. package/dist/src/operations/markdown-to-json.js +13 -0
  79. package/dist/src/operations/next-id.d.ts +322 -0
  80. package/dist/src/operations/next-id.js +29 -0
  81. package/dist/src/operations/node-history.d.ts +313 -0
  82. package/dist/src/operations/node-history.js +55 -0
  83. package/dist/src/operations/plan-add-task.d.ts +595 -0
  84. package/dist/src/operations/plan-add-task.js +18 -0
  85. package/dist/src/operations/plan-gate.d.ts +351 -0
  86. package/dist/src/operations/plan-gate.js +41 -0
  87. package/dist/src/operations/plan-init.d.ts +299 -0
  88. package/dist/src/operations/plan-init.js +17 -0
  89. package/dist/src/operations/plan-progress.d.ts +313 -0
  90. package/dist/src/operations/plan-progress.js +23 -0
  91. package/dist/src/operations/plan-status.d.ts +349 -0
  92. package/dist/src/operations/plan-status.js +41 -0
  93. package/dist/src/operations/query-node.d.ts +1065 -0
  94. package/dist/src/operations/query-node.js +27 -0
  95. package/dist/src/operations/query-nodes.d.ts +594 -0
  96. package/dist/src/operations/query-nodes.js +23 -0
  97. package/dist/src/operations/query-relationships.d.ts +343 -0
  98. package/dist/src/operations/query-relationships.js +27 -0
  99. package/dist/src/operations/remove-node.d.ts +895 -0
  100. package/dist/src/operations/remove-node.js +58 -0
  101. package/dist/src/operations/remove-relationship.d.ts +622 -0
  102. package/dist/src/operations/remove-relationship.js +26 -0
  103. package/dist/src/operations/rename.d.ts +594 -0
  104. package/dist/src/operations/rename.js +113 -0
  105. package/dist/src/operations/search.d.ts +593 -0
  106. package/dist/src/operations/search.js +39 -0
  107. package/dist/src/operations/speckit-diff.d.ts +330 -0
  108. package/dist/src/operations/speckit-diff.js +89 -0
  109. package/dist/src/operations/speckit-export.d.ts +300 -0
  110. package/dist/src/operations/speckit-export.js +17 -0
  111. package/dist/src/operations/speckit-import.d.ts +299 -0
  112. package/dist/src/operations/speckit-import.js +39 -0
  113. package/dist/src/operations/speckit-sync.d.ts +900 -0
  114. package/dist/src/operations/speckit-sync.js +116 -0
  115. package/dist/src/operations/state-at.d.ts +309 -0
  116. package/dist/src/operations/state-at.js +53 -0
  117. package/dist/src/operations/stats.d.ts +324 -0
  118. package/dist/src/operations/stats.js +85 -0
  119. package/dist/src/operations/task-list.d.ts +305 -0
  120. package/dist/src/operations/task-list.js +44 -0
  121. package/dist/src/operations/timeline.d.ts +312 -0
  122. package/dist/src/operations/timeline.js +46 -0
  123. package/dist/src/operations/trace-from-node.d.ts +1197 -0
  124. package/dist/src/operations/trace-from-node.js +36 -0
  125. package/dist/src/operations/update-metadata.d.ts +593 -0
  126. package/dist/src/operations/update-metadata.js +18 -0
  127. package/dist/src/operations/update-node.d.ts +957 -0
  128. package/dist/src/operations/update-node.js +24 -0
  129. package/dist/src/operations/update-plan-task.d.ts +595 -0
  130. package/dist/src/operations/update-plan-task.js +31 -0
  131. package/dist/src/operations/validate.d.ts +310 -0
  132. package/dist/src/operations/validate.js +82 -0
  133. package/dist/src/schema.d.ts +891 -0
  134. package/dist/src/schema.js +356 -0
  135. package/dist/src/speckit/generate.d.ts +7 -0
  136. package/dist/src/speckit/generate.js +546 -0
  137. package/dist/src/speckit/index.d.ts +4 -0
  138. package/dist/src/speckit/index.js +4 -0
  139. package/dist/src/speckit/parse.d.ts +11 -0
  140. package/dist/src/speckit/parse.js +712 -0
  141. package/dist/src/speckit/plan.d.ts +125 -0
  142. package/dist/src/speckit/plan.js +636 -0
  143. package/dist/src/speckit/project.d.ts +39 -0
  144. package/dist/src/speckit/project.js +141 -0
  145. package/dist/src/text.d.ts +23 -0
  146. package/dist/src/text.js +32 -0
  147. package/package.json +86 -8
  148. package/schema.json +510 -0
@@ -0,0 +1,324 @@
1
+ import * as z from "zod";
2
+ export declare const DocumentStats: z.ZodObject<{
3
+ title: z.ZodString;
4
+ nodesByType: z.ZodRecord<z.ZodString, z.ZodNumber>;
5
+ relationshipsByType: z.ZodRecord<z.ZodString, z.ZodNumber>;
6
+ totalNodes: z.ZodNumber;
7
+ totalRelationships: z.ZodNumber;
8
+ subsystemCount: z.ZodNumber;
9
+ maxSubsystemDepth: z.ZodNumber;
10
+ viewCount: z.ZodNumber;
11
+ externalReferenceCount: z.ZodNumber;
12
+ decisionLifecycle: z.ZodRecord<z.ZodString, z.ZodNumber>;
13
+ changeLifecycle: z.ZodRecord<z.ZodString, z.ZodNumber>;
14
+ }, z.core.$strip>;
15
+ export type DocumentStats = z.infer<typeof DocumentStats>;
16
+ export declare const statsOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
17
+ doc: z.ZodObject<{
18
+ $schema: z.ZodOptional<z.ZodString>;
19
+ metadata: z.ZodOptional<z.ZodObject<{
20
+ title: z.ZodOptional<z.ZodString>;
21
+ doc_type: z.ZodOptional<z.ZodString>;
22
+ scope: z.ZodOptional<z.ZodString>;
23
+ status: z.ZodOptional<z.ZodString>;
24
+ version: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
25
+ }, z.core.$loose> & {
26
+ is(value: unknown): value is {
27
+ [x: string]: unknown;
28
+ title?: string | undefined;
29
+ doc_type?: string | undefined;
30
+ scope?: string | undefined;
31
+ status?: string | undefined;
32
+ version?: string | number | undefined;
33
+ };
34
+ }>;
35
+ nodes: z.ZodArray<z.ZodObject<{
36
+ id: z.ZodString;
37
+ type: z.ZodEnum<{
38
+ intent: "intent";
39
+ concept: "concept";
40
+ capability: "capability";
41
+ element: "element";
42
+ realisation: "realisation";
43
+ invariant: "invariant";
44
+ principle: "principle";
45
+ policy: "policy";
46
+ protocol: "protocol";
47
+ stage: "stage";
48
+ role: "role";
49
+ gate: "gate";
50
+ mode: "mode";
51
+ artefact: "artefact";
52
+ artefact_flow: "artefact_flow";
53
+ decision: "decision";
54
+ change: "change";
55
+ view: "view";
56
+ milestone: "milestone";
57
+ version: "version";
58
+ }> & {
59
+ 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";
60
+ };
61
+ name: z.ZodString;
62
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
63
+ is(value: unknown): value is string | string[];
64
+ }>;
65
+ status: z.ZodOptional<z.ZodEnum<{
66
+ deprecated: "deprecated";
67
+ proposed: "proposed";
68
+ accepted: "accepted";
69
+ active: "active";
70
+ implemented: "implemented";
71
+ adopted: "adopted";
72
+ defined: "defined";
73
+ introduced: "introduced";
74
+ in_progress: "in_progress";
75
+ complete: "complete";
76
+ consolidated: "consolidated";
77
+ experimental: "experimental";
78
+ retired: "retired";
79
+ superseded: "superseded";
80
+ abandoned: "abandoned";
81
+ deferred: "deferred";
82
+ }> & {
83
+ is(value: unknown): value is "deprecated" | "proposed" | "accepted" | "active" | "implemented" | "adopted" | "defined" | "introduced" | "in_progress" | "complete" | "consolidated" | "experimental" | "retired" | "superseded" | "abandoned" | "deferred";
84
+ }>;
85
+ lifecycle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>;
86
+ context: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
87
+ is(value: unknown): value is string | string[];
88
+ }>;
89
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
+ id: z.ZodString;
91
+ description: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
92
+ is(value: unknown): value is string | string[];
93
+ };
94
+ }, z.core.$loose> & {
95
+ is(value: unknown): value is {
96
+ [x: string]: unknown;
97
+ id: string;
98
+ description: string | string[];
99
+ };
100
+ }>>;
101
+ selected: z.ZodOptional<z.ZodString>;
102
+ rationale: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
103
+ is(value: unknown): value is string | string[];
104
+ }>;
105
+ scope: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
+ operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
107
+ type: z.ZodEnum<{
108
+ link: "link";
109
+ add: "add";
110
+ update: "update";
111
+ remove: "remove";
112
+ }>;
113
+ target: z.ZodOptional<z.ZodString>;
114
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
115
+ is(value: unknown): value is string | string[];
116
+ }>;
117
+ }, z.core.$loose> & {
118
+ is(value: unknown): value is {
119
+ [x: string]: unknown;
120
+ type: "link" | "add" | "update" | "remove";
121
+ target?: string | undefined;
122
+ description?: string | string[] | undefined;
123
+ };
124
+ }>>;
125
+ plan: z.ZodOptional<z.ZodArray<z.ZodObject<{
126
+ description: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
127
+ is(value: unknown): value is string | string[];
128
+ };
129
+ done: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
130
+ }, z.core.$loose> & {
131
+ is(value: unknown): value is {
132
+ [x: string]: unknown;
133
+ description: string | string[];
134
+ done?: boolean | undefined;
135
+ };
136
+ }>>;
137
+ propagation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
138
+ includes: z.ZodOptional<z.ZodArray<z.ZodString>>;
139
+ input: z.ZodOptional<z.ZodString>;
140
+ output: z.ZodOptional<z.ZodString>;
141
+ external_references: z.ZodOptional<z.ZodArray<z.ZodObject<{
142
+ role: z.ZodEnum<{
143
+ output: "output";
144
+ input: "input";
145
+ context: "context";
146
+ evidence: "evidence";
147
+ source: "source";
148
+ standard: "standard";
149
+ prior_art: "prior_art";
150
+ }> & {
151
+ is(value: unknown): value is "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
152
+ };
153
+ identifier: z.ZodString;
154
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
155
+ is(value: unknown): value is string | string[];
156
+ }>;
157
+ node_id: z.ZodOptional<z.ZodString>;
158
+ internalised: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
159
+ is(value: unknown): value is string | string[];
160
+ }>;
161
+ }, z.core.$strip> & {
162
+ is(value: unknown): value is {
163
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
164
+ identifier: string;
165
+ description?: string | string[] | undefined;
166
+ node_id?: string | undefined;
167
+ internalised?: string | string[] | undefined;
168
+ };
169
+ }>>;
170
+ readonly subsystem: z.ZodOptional<z.ZodObject</*elided*/ any, z.core.$strip>>;
171
+ }, z.core.$loose>>;
172
+ relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
173
+ from: z.ZodString;
174
+ to: z.ZodString;
175
+ type: z.ZodEnum<{
176
+ refines: "refines";
177
+ realises: "realises";
178
+ implements: "implements";
179
+ depends_on: "depends_on";
180
+ constrained_by: "constrained_by";
181
+ affects: "affects";
182
+ supersedes: "supersedes";
183
+ must_preserve: "must_preserve";
184
+ performs: "performs";
185
+ part_of: "part_of";
186
+ precedes: "precedes";
187
+ must_follow: "must_follow";
188
+ blocks: "blocks";
189
+ routes_to: "routes_to";
190
+ governed_by: "governed_by";
191
+ modifies: "modifies";
192
+ triggered_by: "triggered_by";
193
+ applies_to: "applies_to";
194
+ produces: "produces";
195
+ consumes: "consumes";
196
+ transforms_into: "transforms_into";
197
+ selects: "selects";
198
+ requires: "requires";
199
+ disables: "disables";
200
+ }> & {
201
+ 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";
202
+ };
203
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
204
+ is(value: unknown): value is string | string[];
205
+ }>;
206
+ }, z.core.$loose> & {
207
+ is(value: unknown): value is {
208
+ [x: string]: unknown;
209
+ from: string;
210
+ to: string;
211
+ type: "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";
212
+ description?: string | string[] | undefined;
213
+ };
214
+ }>>;
215
+ external_references: z.ZodOptional<z.ZodArray<z.ZodObject<{
216
+ role: z.ZodEnum<{
217
+ output: "output";
218
+ input: "input";
219
+ context: "context";
220
+ evidence: "evidence";
221
+ source: "source";
222
+ standard: "standard";
223
+ prior_art: "prior_art";
224
+ }> & {
225
+ is(value: unknown): value is "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
226
+ };
227
+ identifier: z.ZodString;
228
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
229
+ is(value: unknown): value is string | string[];
230
+ }>;
231
+ node_id: z.ZodOptional<z.ZodString>;
232
+ internalised: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
233
+ is(value: unknown): value is string | string[];
234
+ }>;
235
+ }, z.core.$strip> & {
236
+ is(value: unknown): value is {
237
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
238
+ identifier: string;
239
+ description?: string | string[] | undefined;
240
+ node_id?: string | undefined;
241
+ internalised?: string | string[] | undefined;
242
+ };
243
+ }>>;
244
+ }, z.core.$strip> & {
245
+ is(value: unknown): value is {
246
+ nodes: {
247
+ [x: string]: unknown;
248
+ id: string;
249
+ type: "intent" | "concept" | "capability" | "element" | "realisation" | "invariant" | "principle" | "policy" | "protocol" | "stage" | "role" | "gate" | "mode" | "artefact" | "artefact_flow" | "decision" | "change" | "view" | "milestone" | "version";
250
+ name: string;
251
+ description?: string | string[] | undefined;
252
+ status?: "deprecated" | "proposed" | "accepted" | "active" | "implemented" | "adopted" | "defined" | "introduced" | "in_progress" | "complete" | "consolidated" | "experimental" | "retired" | "superseded" | "abandoned" | "deferred" | undefined;
253
+ lifecycle?: Record<string, string | boolean> | undefined;
254
+ context?: string | string[] | undefined;
255
+ options?: {
256
+ [x: string]: unknown;
257
+ id: string;
258
+ description: string | string[];
259
+ }[] | undefined;
260
+ selected?: string | undefined;
261
+ rationale?: string | string[] | undefined;
262
+ scope?: string[] | undefined;
263
+ operations?: {
264
+ [x: string]: unknown;
265
+ type: "link" | "add" | "update" | "remove";
266
+ target?: string | undefined;
267
+ description?: string | string[] | undefined;
268
+ }[] | undefined;
269
+ plan?: {
270
+ [x: string]: unknown;
271
+ description: string | string[];
272
+ done?: boolean | undefined;
273
+ }[] | undefined;
274
+ propagation?: Record<string, boolean> | undefined;
275
+ includes?: string[] | undefined;
276
+ input?: string | undefined;
277
+ output?: string | undefined;
278
+ external_references?: {
279
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
280
+ identifier: string;
281
+ description?: string | string[] | undefined;
282
+ node_id?: string | undefined;
283
+ internalised?: string | string[] | undefined;
284
+ }[] | undefined;
285
+ subsystem?: /*elided*/ any | undefined;
286
+ }[];
287
+ $schema?: string | undefined;
288
+ metadata?: {
289
+ [x: string]: unknown;
290
+ title?: string | undefined;
291
+ doc_type?: string | undefined;
292
+ scope?: string | undefined;
293
+ status?: string | undefined;
294
+ version?: string | number | undefined;
295
+ } | undefined;
296
+ relationships?: {
297
+ [x: string]: unknown;
298
+ from: string;
299
+ to: string;
300
+ type: "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";
301
+ description?: string | string[] | undefined;
302
+ }[] | undefined;
303
+ external_references?: {
304
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
305
+ identifier: string;
306
+ description?: string | string[] | undefined;
307
+ node_id?: string | undefined;
308
+ internalised?: string | string[] | undefined;
309
+ }[] | undefined;
310
+ };
311
+ };
312
+ }, z.core.$strip>, z.ZodObject<{
313
+ title: z.ZodString;
314
+ nodesByType: z.ZodRecord<z.ZodString, z.ZodNumber>;
315
+ relationshipsByType: z.ZodRecord<z.ZodString, z.ZodNumber>;
316
+ totalNodes: z.ZodNumber;
317
+ totalRelationships: z.ZodNumber;
318
+ subsystemCount: z.ZodNumber;
319
+ maxSubsystemDepth: z.ZodNumber;
320
+ viewCount: z.ZodNumber;
321
+ externalReferenceCount: z.ZodNumber;
322
+ decisionLifecycle: z.ZodRecord<z.ZodString, z.ZodNumber>;
323
+ changeLifecycle: z.ZodRecord<z.ZodString, z.ZodNumber>;
324
+ }, z.core.$strip>>;
@@ -0,0 +1,85 @@
1
+ import * as z from "zod";
2
+ import { defineOperation } from "./define-operation.js";
3
+ import { SysProMDocument } from "../schema.js";
4
+ export const DocumentStats = z.object({
5
+ title: z.string(),
6
+ nodesByType: z.record(z.string(), z.number()),
7
+ relationshipsByType: z.record(z.string(), z.number()),
8
+ totalNodes: z.number(),
9
+ totalRelationships: z.number(),
10
+ subsystemCount: z.number(),
11
+ maxSubsystemDepth: z.number(),
12
+ viewCount: z.number(),
13
+ externalReferenceCount: z.number(),
14
+ decisionLifecycle: z.record(z.string(), z.number()),
15
+ changeLifecycle: z.record(z.string(), z.number()),
16
+ });
17
+ export const statsOp = defineOperation({
18
+ name: "stats",
19
+ description: "Compute statistics about a SysProM document",
20
+ input: z.object({
21
+ doc: SysProMDocument,
22
+ }),
23
+ output: DocumentStats,
24
+ fn: (input) => {
25
+ // Node counts by type
26
+ const nodesByType = {};
27
+ for (const n of input.doc.nodes) {
28
+ nodesByType[n.type] = (nodesByType[n.type] ?? 0) + 1;
29
+ }
30
+ // Relationship counts by type
31
+ const relationshipsByType = {};
32
+ for (const r of input.doc.relationships ?? []) {
33
+ relationshipsByType[r.type] = (relationshipsByType[r.type] ?? 0) + 1;
34
+ }
35
+ // Subsystem stats
36
+ let subsystemCount = 0;
37
+ let maxDepth = 0;
38
+ function countSubsystems(nodes, depth) {
39
+ for (const n of nodes) {
40
+ if (n.subsystem) {
41
+ subsystemCount++;
42
+ if (depth + 1 > maxDepth)
43
+ maxDepth = depth + 1;
44
+ countSubsystems(n.subsystem.nodes, depth + 1);
45
+ }
46
+ }
47
+ }
48
+ countSubsystems(input.doc.nodes, 0);
49
+ // Lifecycle status for decisions and changes
50
+ const decisionLifecycle = {};
51
+ const changeLifecycle = {};
52
+ for (const n of input.doc.nodes) {
53
+ if (n.lifecycle) {
54
+ const statusMap = n.type === "decision"
55
+ ? decisionLifecycle
56
+ : n.type === "change"
57
+ ? changeLifecycle
58
+ : null;
59
+ if (statusMap) {
60
+ for (const [state, done] of Object.entries(n.lifecycle)) {
61
+ if (done) {
62
+ statusMap[state] = (statusMap[state] ?? 0) + 1;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ // View count
69
+ const viewCount = input.doc.nodes.filter((n) => n.type === "view").length;
70
+ const externalReferenceCount = (input.doc.external_references ?? []).length;
71
+ return {
72
+ title: input.doc.metadata?.title ?? "(untitled)",
73
+ nodesByType,
74
+ relationshipsByType,
75
+ totalNodes: input.doc.nodes.length,
76
+ totalRelationships: (input.doc.relationships ?? []).length,
77
+ subsystemCount,
78
+ maxSubsystemDepth: maxDepth,
79
+ viewCount,
80
+ externalReferenceCount,
81
+ decisionLifecycle,
82
+ changeLifecycle,
83
+ };
84
+ },
85
+ });