sysprom 1.0.0 → 1.0.6

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,330 @@
1
+ import * as z from "zod";
2
+ export type DiffResult = z.infer<typeof DiffResult>;
3
+ export declare const DiffResult: z.ZodObject<{
4
+ added: z.ZodArray<z.ZodObject<{
5
+ id: z.ZodString;
6
+ name: z.ZodString;
7
+ }, z.core.$strip>>;
8
+ modified: z.ZodArray<z.ZodObject<{
9
+ id: z.ZodString;
10
+ oldName: z.ZodString;
11
+ newName: z.ZodString;
12
+ }, z.core.$strip>>;
13
+ removed: z.ZodArray<z.ZodObject<{
14
+ id: z.ZodString;
15
+ name: z.ZodString;
16
+ }, z.core.$strip>>;
17
+ }, z.core.$strip>;
18
+ export declare const speckitDiffOp: import("./define-operation.js").DefinedOperation<z.ZodObject<{
19
+ doc: z.ZodObject<{
20
+ $schema: z.ZodOptional<z.ZodString>;
21
+ metadata: z.ZodOptional<z.ZodObject<{
22
+ title: z.ZodOptional<z.ZodString>;
23
+ doc_type: z.ZodOptional<z.ZodString>;
24
+ scope: z.ZodOptional<z.ZodString>;
25
+ status: z.ZodOptional<z.ZodString>;
26
+ version: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
27
+ }, z.core.$loose> & {
28
+ is(value: unknown): value is {
29
+ [x: string]: unknown;
30
+ title?: string | undefined;
31
+ doc_type?: string | undefined;
32
+ scope?: string | undefined;
33
+ status?: string | undefined;
34
+ version?: string | number | undefined;
35
+ };
36
+ }>;
37
+ nodes: z.ZodArray<z.ZodObject<{
38
+ id: z.ZodString;
39
+ type: z.ZodEnum<{
40
+ intent: "intent";
41
+ concept: "concept";
42
+ capability: "capability";
43
+ element: "element";
44
+ realisation: "realisation";
45
+ invariant: "invariant";
46
+ principle: "principle";
47
+ policy: "policy";
48
+ protocol: "protocol";
49
+ stage: "stage";
50
+ role: "role";
51
+ gate: "gate";
52
+ mode: "mode";
53
+ artefact: "artefact";
54
+ artefact_flow: "artefact_flow";
55
+ decision: "decision";
56
+ change: "change";
57
+ view: "view";
58
+ milestone: "milestone";
59
+ version: "version";
60
+ }> & {
61
+ 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";
62
+ };
63
+ name: z.ZodString;
64
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
65
+ is(value: unknown): value is string | string[];
66
+ }>;
67
+ status: z.ZodOptional<z.ZodEnum<{
68
+ deprecated: "deprecated";
69
+ proposed: "proposed";
70
+ accepted: "accepted";
71
+ active: "active";
72
+ implemented: "implemented";
73
+ adopted: "adopted";
74
+ defined: "defined";
75
+ introduced: "introduced";
76
+ in_progress: "in_progress";
77
+ complete: "complete";
78
+ consolidated: "consolidated";
79
+ experimental: "experimental";
80
+ retired: "retired";
81
+ superseded: "superseded";
82
+ abandoned: "abandoned";
83
+ deferred: "deferred";
84
+ }> & {
85
+ is(value: unknown): value is "deprecated" | "proposed" | "accepted" | "active" | "implemented" | "adopted" | "defined" | "introduced" | "in_progress" | "complete" | "consolidated" | "experimental" | "retired" | "superseded" | "abandoned" | "deferred";
86
+ }>;
87
+ lifecycle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>;
88
+ context: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
89
+ is(value: unknown): value is string | string[];
90
+ }>;
91
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
92
+ id: z.ZodString;
93
+ description: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
94
+ is(value: unknown): value is string | string[];
95
+ };
96
+ }, z.core.$loose> & {
97
+ is(value: unknown): value is {
98
+ [x: string]: unknown;
99
+ id: string;
100
+ description: string | string[];
101
+ };
102
+ }>>;
103
+ selected: z.ZodOptional<z.ZodString>;
104
+ rationale: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
105
+ is(value: unknown): value is string | string[];
106
+ }>;
107
+ scope: z.ZodOptional<z.ZodArray<z.ZodString>>;
108
+ operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
109
+ type: z.ZodEnum<{
110
+ link: "link";
111
+ add: "add";
112
+ update: "update";
113
+ remove: "remove";
114
+ }>;
115
+ target: z.ZodOptional<z.ZodString>;
116
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
117
+ is(value: unknown): value is string | string[];
118
+ }>;
119
+ }, z.core.$loose> & {
120
+ is(value: unknown): value is {
121
+ [x: string]: unknown;
122
+ type: "link" | "add" | "update" | "remove";
123
+ target?: string | undefined;
124
+ description?: string | string[] | undefined;
125
+ };
126
+ }>>;
127
+ plan: z.ZodOptional<z.ZodArray<z.ZodObject<{
128
+ description: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
129
+ is(value: unknown): value is string | string[];
130
+ };
131
+ done: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
132
+ }, z.core.$loose> & {
133
+ is(value: unknown): value is {
134
+ [x: string]: unknown;
135
+ description: string | string[];
136
+ done?: boolean | undefined;
137
+ };
138
+ }>>;
139
+ propagation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
140
+ includes: z.ZodOptional<z.ZodArray<z.ZodString>>;
141
+ input: z.ZodOptional<z.ZodString>;
142
+ output: z.ZodOptional<z.ZodString>;
143
+ external_references: z.ZodOptional<z.ZodArray<z.ZodObject<{
144
+ role: z.ZodEnum<{
145
+ output: "output";
146
+ input: "input";
147
+ context: "context";
148
+ evidence: "evidence";
149
+ source: "source";
150
+ standard: "standard";
151
+ prior_art: "prior_art";
152
+ }> & {
153
+ is(value: unknown): value is "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
154
+ };
155
+ identifier: z.ZodString;
156
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
157
+ is(value: unknown): value is string | string[];
158
+ }>;
159
+ node_id: z.ZodOptional<z.ZodString>;
160
+ internalised: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
161
+ is(value: unknown): value is string | string[];
162
+ }>;
163
+ }, z.core.$strip> & {
164
+ is(value: unknown): value is {
165
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
166
+ identifier: string;
167
+ description?: string | string[] | undefined;
168
+ node_id?: string | undefined;
169
+ internalised?: string | string[] | undefined;
170
+ };
171
+ }>>;
172
+ readonly subsystem: z.ZodOptional<z.ZodObject</*elided*/ any, z.core.$strip>>;
173
+ }, z.core.$loose>>;
174
+ relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
175
+ from: z.ZodString;
176
+ to: z.ZodString;
177
+ type: z.ZodEnum<{
178
+ refines: "refines";
179
+ realises: "realises";
180
+ implements: "implements";
181
+ depends_on: "depends_on";
182
+ constrained_by: "constrained_by";
183
+ affects: "affects";
184
+ supersedes: "supersedes";
185
+ must_preserve: "must_preserve";
186
+ performs: "performs";
187
+ part_of: "part_of";
188
+ precedes: "precedes";
189
+ must_follow: "must_follow";
190
+ blocks: "blocks";
191
+ routes_to: "routes_to";
192
+ governed_by: "governed_by";
193
+ modifies: "modifies";
194
+ triggered_by: "triggered_by";
195
+ applies_to: "applies_to";
196
+ produces: "produces";
197
+ consumes: "consumes";
198
+ transforms_into: "transforms_into";
199
+ selects: "selects";
200
+ requires: "requires";
201
+ disables: "disables";
202
+ }> & {
203
+ 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";
204
+ };
205
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
206
+ is(value: unknown): value is string | string[];
207
+ }>;
208
+ }, z.core.$loose> & {
209
+ is(value: unknown): value is {
210
+ [x: string]: unknown;
211
+ from: string;
212
+ to: string;
213
+ 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";
214
+ description?: string | string[] | undefined;
215
+ };
216
+ }>>;
217
+ external_references: z.ZodOptional<z.ZodArray<z.ZodObject<{
218
+ role: z.ZodEnum<{
219
+ output: "output";
220
+ input: "input";
221
+ context: "context";
222
+ evidence: "evidence";
223
+ source: "source";
224
+ standard: "standard";
225
+ prior_art: "prior_art";
226
+ }> & {
227
+ is(value: unknown): value is "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
228
+ };
229
+ identifier: z.ZodString;
230
+ description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
231
+ is(value: unknown): value is string | string[];
232
+ }>;
233
+ node_id: z.ZodOptional<z.ZodString>;
234
+ internalised: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]> & {
235
+ is(value: unknown): value is string | string[];
236
+ }>;
237
+ }, z.core.$strip> & {
238
+ is(value: unknown): value is {
239
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
240
+ identifier: string;
241
+ description?: string | string[] | undefined;
242
+ node_id?: string | undefined;
243
+ internalised?: string | string[] | undefined;
244
+ };
245
+ }>>;
246
+ }, z.core.$strip> & {
247
+ is(value: unknown): value is {
248
+ nodes: {
249
+ [x: string]: unknown;
250
+ id: string;
251
+ type: "intent" | "concept" | "capability" | "element" | "realisation" | "invariant" | "principle" | "policy" | "protocol" | "stage" | "role" | "gate" | "mode" | "artefact" | "artefact_flow" | "decision" | "change" | "view" | "milestone" | "version";
252
+ name: string;
253
+ description?: string | string[] | undefined;
254
+ status?: "deprecated" | "proposed" | "accepted" | "active" | "implemented" | "adopted" | "defined" | "introduced" | "in_progress" | "complete" | "consolidated" | "experimental" | "retired" | "superseded" | "abandoned" | "deferred" | undefined;
255
+ lifecycle?: Record<string, string | boolean> | undefined;
256
+ context?: string | string[] | undefined;
257
+ options?: {
258
+ [x: string]: unknown;
259
+ id: string;
260
+ description: string | string[];
261
+ }[] | undefined;
262
+ selected?: string | undefined;
263
+ rationale?: string | string[] | undefined;
264
+ scope?: string[] | undefined;
265
+ operations?: {
266
+ [x: string]: unknown;
267
+ type: "link" | "add" | "update" | "remove";
268
+ target?: string | undefined;
269
+ description?: string | string[] | undefined;
270
+ }[] | undefined;
271
+ plan?: {
272
+ [x: string]: unknown;
273
+ description: string | string[];
274
+ done?: boolean | undefined;
275
+ }[] | undefined;
276
+ propagation?: Record<string, boolean> | undefined;
277
+ includes?: string[] | undefined;
278
+ input?: string | undefined;
279
+ output?: string | undefined;
280
+ external_references?: {
281
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
282
+ identifier: string;
283
+ description?: string | string[] | undefined;
284
+ node_id?: string | undefined;
285
+ internalised?: string | string[] | undefined;
286
+ }[] | undefined;
287
+ subsystem?: /*elided*/ any | undefined;
288
+ }[];
289
+ $schema?: string | undefined;
290
+ metadata?: {
291
+ [x: string]: unknown;
292
+ title?: string | undefined;
293
+ doc_type?: string | undefined;
294
+ scope?: string | undefined;
295
+ status?: string | undefined;
296
+ version?: string | number | undefined;
297
+ } | undefined;
298
+ relationships?: {
299
+ [x: string]: unknown;
300
+ from: string;
301
+ to: string;
302
+ 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";
303
+ description?: string | string[] | undefined;
304
+ }[] | undefined;
305
+ external_references?: {
306
+ role: "output" | "input" | "context" | "evidence" | "source" | "standard" | "prior_art";
307
+ identifier: string;
308
+ description?: string | string[] | undefined;
309
+ node_id?: string | undefined;
310
+ internalised?: string | string[] | undefined;
311
+ }[] | undefined;
312
+ };
313
+ };
314
+ speckitDir: z.ZodString;
315
+ prefix: z.ZodOptional<z.ZodString>;
316
+ }, z.core.$strip>, z.ZodObject<{
317
+ added: z.ZodArray<z.ZodObject<{
318
+ id: z.ZodString;
319
+ name: z.ZodString;
320
+ }, z.core.$strip>>;
321
+ modified: z.ZodArray<z.ZodObject<{
322
+ id: z.ZodString;
323
+ oldName: z.ZodString;
324
+ newName: z.ZodString;
325
+ }, z.core.$strip>>;
326
+ removed: z.ZodArray<z.ZodObject<{
327
+ id: z.ZodString;
328
+ name: z.ZodString;
329
+ }, z.core.$strip>>;
330
+ }, z.core.$strip>>;
@@ -0,0 +1,89 @@
1
+ import * as z from "zod";
2
+ import { dirname } from "node:path";
3
+ import { defineOperation } from "./define-operation.js";
4
+ import { SysProMDocument } from "../schema.js";
5
+ import { parseSpecKitFeature } from "../speckit/parse.js";
6
+ import { detectSpecKitProject } from "../speckit/project.js";
7
+ function compareDocuments(oldDoc, newDoc) {
8
+ const oldNodes = new Map(oldDoc.nodes.map((n) => [n.id, n]));
9
+ const newNodes = new Map(newDoc.nodes.map((n) => [n.id, n]));
10
+ const added = [];
11
+ const modified = [];
12
+ const removed = [];
13
+ // Find added and modified
14
+ for (const [id, newNode] of newNodes) {
15
+ const oldNode = oldNodes.get(id);
16
+ if (!oldNode) {
17
+ added.push(newNode);
18
+ }
19
+ else if (JSON.stringify(oldNode) !== JSON.stringify(newNode)) {
20
+ modified.push({ old: oldNode, new: newNode });
21
+ }
22
+ }
23
+ // Find removed
24
+ for (const [id, oldNode] of oldNodes) {
25
+ if (!newNodes.has(id)) {
26
+ removed.push(oldNode);
27
+ }
28
+ }
29
+ return { added, modified, removed };
30
+ }
31
+ export const DiffResult = z.object({
32
+ added: z.array(z.object({
33
+ id: z.string(),
34
+ name: z.string(),
35
+ })),
36
+ modified: z.array(z.object({
37
+ id: z.string(),
38
+ oldName: z.string(),
39
+ newName: z.string(),
40
+ })),
41
+ removed: z.array(z.object({
42
+ id: z.string(),
43
+ name: z.string(),
44
+ })),
45
+ });
46
+ export const speckitDiffOp = defineOperation({
47
+ name: "speckitDiff",
48
+ description: "Show differences between a SysProM document and a Spec-Kit directory",
49
+ input: z.object({
50
+ doc: SysProMDocument,
51
+ speckitDir: z.string().describe("Path to Spec-Kit directory"),
52
+ prefix: z
53
+ .string()
54
+ .optional()
55
+ .describe("ID prefix (defaults to directory name)"),
56
+ }),
57
+ output: DiffResult,
58
+ fn: ({ doc: syspromDoc, speckitDir, prefix }) => {
59
+ // Determine the prefix: use flag if provided, otherwise use directory name
60
+ const idPrefix = prefix ?? speckitDir.split("/").pop() ?? "FEAT";
61
+ // Find constitution file
62
+ let constitutionPath;
63
+ let searchDir = dirname(speckitDir);
64
+ for (let i = 0; i < 5; i++) {
65
+ const project = detectSpecKitProject(searchDir);
66
+ if (project.constitutionPath) {
67
+ constitutionPath = project.constitutionPath;
68
+ break;
69
+ }
70
+ const parent = dirname(searchDir);
71
+ if (parent === searchDir)
72
+ break;
73
+ searchDir = parent;
74
+ }
75
+ // Parse Spec-Kit feature
76
+ const specKitDoc = parseSpecKitFeature(speckitDir, idPrefix, constitutionPath);
77
+ // Compare documents
78
+ const diff = compareDocuments(syspromDoc, specKitDoc);
79
+ return {
80
+ added: diff.added.map((n) => ({ id: n.id, name: n.name })),
81
+ modified: diff.modified.map(({ old, new: newNode }) => ({
82
+ id: old.id,
83
+ oldName: old.name,
84
+ newName: newNode.name,
85
+ })),
86
+ removed: diff.removed.map((n) => ({ id: n.id, name: n.name })),
87
+ };
88
+ },
89
+ });