@topogram/cli 0.3.34

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 (257) hide show
  1. package/ARCHITECTURE.md +67 -0
  2. package/CHANGELOG.md +240 -0
  3. package/README.md +223 -0
  4. package/package.json +51 -0
  5. package/src/adoption/index.js +3 -0
  6. package/src/adoption/plan.js +702 -0
  7. package/src/adoption/reporting.js +464 -0
  8. package/src/adoption/review-groups.js +313 -0
  9. package/src/agent-ops/query-builders.js +5012 -0
  10. package/src/archive/archive.js +141 -0
  11. package/src/archive/compact.js +26 -0
  12. package/src/archive/jsonl.js +70 -0
  13. package/src/archive/resolver-bridge.js +82 -0
  14. package/src/archive/schema.js +87 -0
  15. package/src/archive/unarchive.js +108 -0
  16. package/src/catalog.js +752 -0
  17. package/src/cli/catalog-alias.js +166 -0
  18. package/src/cli.js +9738 -0
  19. package/src/component-behavior.js +173 -0
  20. package/src/example-implementation.js +91 -0
  21. package/src/format.js +19 -0
  22. package/src/generator/adapters.d.ts +4 -0
  23. package/src/generator/adapters.js +325 -0
  24. package/src/generator/api.d.ts +1 -0
  25. package/src/generator/api.js +1196 -0
  26. package/src/generator/check.js +355 -0
  27. package/src/generator/component-conformance.js +767 -0
  28. package/src/generator/components.js +39 -0
  29. package/src/generator/context/bundle.js +291 -0
  30. package/src/generator/context/diff.js +256 -0
  31. package/src/generator/context/digest.js +182 -0
  32. package/src/generator/context/domain-coverage.js +94 -0
  33. package/src/generator/context/domain-page.js +137 -0
  34. package/src/generator/context/index.js +42 -0
  35. package/src/generator/context/report.js +121 -0
  36. package/src/generator/context/shared.js +1397 -0
  37. package/src/generator/context/slice.js +703 -0
  38. package/src/generator/context/task-mode.js +466 -0
  39. package/src/generator/docs.js +327 -0
  40. package/src/generator/index.js +161 -0
  41. package/src/generator/native/parity-bundle.js +311 -0
  42. package/src/generator/output.js +300 -0
  43. package/src/generator/registry.js +482 -0
  44. package/src/generator/runtime/app-bundle.js +456 -0
  45. package/src/generator/runtime/bundle-shared.js +166 -0
  46. package/src/generator/runtime/compile-check.js +163 -0
  47. package/src/generator/runtime/deployment.js +287 -0
  48. package/src/generator/runtime/environment.js +635 -0
  49. package/src/generator/runtime/index.js +32 -0
  50. package/src/generator/runtime/runtime-check.js +554 -0
  51. package/src/generator/runtime/shared.js +515 -0
  52. package/src/generator/runtime/smoke.js +219 -0
  53. package/src/generator/schema.js +204 -0
  54. package/src/generator/sdlc/board.js +66 -0
  55. package/src/generator/sdlc/doc-page.js +53 -0
  56. package/src/generator/sdlc/index.js +23 -0
  57. package/src/generator/sdlc/release-notes.js +62 -0
  58. package/src/generator/sdlc/traceability-matrix.js +65 -0
  59. package/src/generator/shared.js +29 -0
  60. package/src/generator/surfaces/contracts.js +146 -0
  61. package/src/generator/surfaces/databases/contract.js +40 -0
  62. package/src/generator/surfaces/databases/index.js +84 -0
  63. package/src/generator/surfaces/databases/lifecycle-shared.d.ts +1 -0
  64. package/src/generator/surfaces/databases/lifecycle-shared.js +612 -0
  65. package/src/generator/surfaces/databases/migration-plan.js +281 -0
  66. package/src/generator/surfaces/databases/postgres/capabilities.js +14 -0
  67. package/src/generator/surfaces/databases/postgres/drizzle.js +99 -0
  68. package/src/generator/surfaces/databases/postgres/index.js +9 -0
  69. package/src/generator/surfaces/databases/postgres/lifecycle.js +16 -0
  70. package/src/generator/surfaces/databases/postgres/prisma.js +159 -0
  71. package/src/generator/surfaces/databases/postgres/sql-migration.js +102 -0
  72. package/src/generator/surfaces/databases/postgres/sql-schema.js +34 -0
  73. package/src/generator/surfaces/databases/shared.d.ts +1 -0
  74. package/src/generator/surfaces/databases/shared.js +350 -0
  75. package/src/generator/surfaces/databases/snapshot.js +96 -0
  76. package/src/generator/surfaces/databases/sqlite/capabilities.js +14 -0
  77. package/src/generator/surfaces/databases/sqlite/index.js +8 -0
  78. package/src/generator/surfaces/databases/sqlite/lifecycle.js +16 -0
  79. package/src/generator/surfaces/databases/sqlite/prisma.js +143 -0
  80. package/src/generator/surfaces/databases/sqlite/sql-migration.js +65 -0
  81. package/src/generator/surfaces/databases/sqlite/sql-schema.js +27 -0
  82. package/src/generator/surfaces/index.js +25 -0
  83. package/src/generator/surfaces/native/swiftui-app.js +38 -0
  84. package/src/generator/surfaces/native/swiftui-templates/Package.swift.txt +20 -0
  85. package/src/generator/surfaces/native/swiftui-templates/README.generated.md +26 -0
  86. package/src/generator/surfaces/native/swiftui-templates/runtime/DynamicScreens.swift +682 -0
  87. package/src/generator/surfaces/native/swiftui-templates/runtime/TodoAPIClient.swift +156 -0
  88. package/src/generator/surfaces/native/swiftui-templates/runtime/TodoSwiftUIApp.swift +44 -0
  89. package/src/generator/surfaces/native/swiftui-templates/runtime/Visibility.swift +183 -0
  90. package/src/generator/surfaces/services/express.d.ts +1 -0
  91. package/src/generator/surfaces/services/express.js +766 -0
  92. package/src/generator/surfaces/services/hono.d.ts +1 -0
  93. package/src/generator/surfaces/services/hono.js +204 -0
  94. package/src/generator/surfaces/services/index.js +42 -0
  95. package/src/generator/surfaces/services/persistence-wiring.js +240 -0
  96. package/src/generator/surfaces/services/runtime-helpers.js +631 -0
  97. package/src/generator/surfaces/services/server-contract.js +80 -0
  98. package/src/generator/surfaces/services/stateless.d.ts +1 -0
  99. package/src/generator/surfaces/services/stateless.js +97 -0
  100. package/src/generator/surfaces/shared.js +64 -0
  101. package/src/generator/surfaces/web/api-client.js +1 -0
  102. package/src/generator/surfaces/web/forms.js +1 -0
  103. package/src/generator/surfaces/web/index.d.ts +2 -0
  104. package/src/generator/surfaces/web/index.js +53 -0
  105. package/src/generator/surfaces/web/react-components.js +248 -0
  106. package/src/generator/surfaces/web/react.js +538 -0
  107. package/src/generator/surfaces/web/routes.js +1 -0
  108. package/src/generator/surfaces/web/screens.js +1 -0
  109. package/src/generator/surfaces/web/shared.js +369 -0
  110. package/src/generator/surfaces/web/sveltekit-actions.js +28 -0
  111. package/src/generator/surfaces/web/sveltekit-components.js +234 -0
  112. package/src/generator/surfaces/web/sveltekit.js +426 -0
  113. package/src/generator/surfaces/web/ui-web-contract.js +65 -0
  114. package/src/generator/surfaces/web/vanilla.js +239 -0
  115. package/src/generator/verification.js +84 -0
  116. package/src/generator.js +1 -0
  117. package/src/import/core/context.js +52 -0
  118. package/src/import/core/contracts.js +23 -0
  119. package/src/import/core/registry.js +81 -0
  120. package/src/import/core/runner.js +646 -0
  121. package/src/import/core/shared.js +910 -0
  122. package/src/import/enrichers/auth-session.js +18 -0
  123. package/src/import/enrichers/django-rest.js +226 -0
  124. package/src/import/enrichers/doc-linking.js +20 -0
  125. package/src/import/enrichers/rails-controllers.js +246 -0
  126. package/src/import/enrichers/rails-models.js +130 -0
  127. package/src/import/enrichers/workflow-target-state.js +10 -0
  128. package/src/import/extractors/api/aspnet-core.js +304 -0
  129. package/src/import/extractors/api/django-routes.js +318 -0
  130. package/src/import/extractors/api/express.js +154 -0
  131. package/src/import/extractors/api/fastify.js +371 -0
  132. package/src/import/extractors/api/flutter-dio.js +135 -0
  133. package/src/import/extractors/api/generic-route-fallback.js +90 -0
  134. package/src/import/extractors/api/graphql-code-first.js +565 -0
  135. package/src/import/extractors/api/graphql-sdl.js +309 -0
  136. package/src/import/extractors/api/jaxrs.js +303 -0
  137. package/src/import/extractors/api/micronaut.js +213 -0
  138. package/src/import/extractors/api/next-route.js +50 -0
  139. package/src/import/extractors/api/next-server-action.js +51 -0
  140. package/src/import/extractors/api/nextauth.js +52 -0
  141. package/src/import/extractors/api/openapi-code.js +242 -0
  142. package/src/import/extractors/api/openapi.js +232 -0
  143. package/src/import/extractors/api/rails-routes.js +230 -0
  144. package/src/import/extractors/api/react-native-repository.js +128 -0
  145. package/src/import/extractors/api/retrofit.js +103 -0
  146. package/src/import/extractors/api/spring-web.js +372 -0
  147. package/src/import/extractors/api/swift-webapi.js +116 -0
  148. package/src/import/extractors/api/trpc.js +212 -0
  149. package/src/import/extractors/db/django-models.js +232 -0
  150. package/src/import/extractors/db/dotnet-models.js +93 -0
  151. package/src/import/extractors/db/drizzle.js +242 -0
  152. package/src/import/extractors/db/ef-core.js +221 -0
  153. package/src/import/extractors/db/flutter-entities.js +120 -0
  154. package/src/import/extractors/db/jpa.js +120 -0
  155. package/src/import/extractors/db/liquibase.js +180 -0
  156. package/src/import/extractors/db/mybatis-xml.js +145 -0
  157. package/src/import/extractors/db/prisma.js +185 -0
  158. package/src/import/extractors/db/rails-schema.js +175 -0
  159. package/src/import/extractors/db/react-native-entities.js +95 -0
  160. package/src/import/extractors/db/room.js +193 -0
  161. package/src/import/extractors/db/snapshot.js +112 -0
  162. package/src/import/extractors/db/sql.js +180 -0
  163. package/src/import/extractors/db/swiftdata.js +137 -0
  164. package/src/import/extractors/ui/android-compose.js +230 -0
  165. package/src/import/extractors/ui/backend-only.js +70 -0
  166. package/src/import/extractors/ui/blazor.js +227 -0
  167. package/src/import/extractors/ui/flutter-screens.js +152 -0
  168. package/src/import/extractors/ui/maui-xaml.js +135 -0
  169. package/src/import/extractors/ui/next-app-router.js +83 -0
  170. package/src/import/extractors/ui/next-pages-router.js +141 -0
  171. package/src/import/extractors/ui/razor-pages.js +181 -0
  172. package/src/import/extractors/ui/react-native-screens.js +166 -0
  173. package/src/import/extractors/ui/react-router.js +139 -0
  174. package/src/import/extractors/ui/sveltekit.js +123 -0
  175. package/src/import/extractors/ui/swiftui.js +193 -0
  176. package/src/import/extractors/ui/uikit.js +175 -0
  177. package/src/import/extractors/verification/generic.js +290 -0
  178. package/src/import/extractors/workflows/generic.js +137 -0
  179. package/src/import/index.js +7 -0
  180. package/src/import/provenance.js +158 -0
  181. package/src/new-project.js +2107 -0
  182. package/src/parser.js +439 -0
  183. package/src/policy/review-boundaries.js +165 -0
  184. package/src/project-config.js +535 -0
  185. package/src/proofs/backend-parity.js +19 -0
  186. package/src/proofs/contract-audit.js +220 -0
  187. package/src/proofs/ios-parity.js +7 -0
  188. package/src/proofs/issues-parity.js +10 -0
  189. package/src/proofs/web-parity.js +50 -0
  190. package/src/realization/api/build-api-realization.js +5 -0
  191. package/src/realization/api/index.js +1 -0
  192. package/src/realization/backend/build-backend-runtime-realization.js +82 -0
  193. package/src/realization/backend/index.d.ts +1 -0
  194. package/src/realization/backend/index.js +4 -0
  195. package/src/realization/db/build-db-realization.js +17 -0
  196. package/src/realization/db/index.js +3 -0
  197. package/src/realization/db/migration-plan.js +5 -0
  198. package/src/realization/db/snapshot.js +5 -0
  199. package/src/realization/ui/build-ui-shared-realization.js +305 -0
  200. package/src/realization/ui/build-web-realization.js +189 -0
  201. package/src/realization/ui/index.js +2 -0
  202. package/src/reconcile/docs.js +280 -0
  203. package/src/reconcile/index.js +3 -0
  204. package/src/reconcile/journeys.js +441 -0
  205. package/src/resolver/docs.js +1 -0
  206. package/src/resolver/enrich/acceptance-criterion.js +14 -0
  207. package/src/resolver/enrich/bug.js +12 -0
  208. package/src/resolver/enrich/component.js +2 -0
  209. package/src/resolver/enrich/index.js +1 -0
  210. package/src/resolver/enrich/pitch.js +18 -0
  211. package/src/resolver/enrich/requirement.js +20 -0
  212. package/src/resolver/enrich/task.js +16 -0
  213. package/src/resolver/expressions.js +1 -0
  214. package/src/resolver/index.js +2422 -0
  215. package/src/resolver/normalize.js +1 -0
  216. package/src/resolver.js +1 -0
  217. package/src/sdlc/adopt.js +65 -0
  218. package/src/sdlc/check.js +86 -0
  219. package/src/sdlc/dod/acceptance-criterion.js +22 -0
  220. package/src/sdlc/dod/bug.js +26 -0
  221. package/src/sdlc/dod/document.js +23 -0
  222. package/src/sdlc/dod/index.js +25 -0
  223. package/src/sdlc/dod/pitch.js +23 -0
  224. package/src/sdlc/dod/requirement.js +34 -0
  225. package/src/sdlc/dod/task.js +39 -0
  226. package/src/sdlc/explain.js +116 -0
  227. package/src/sdlc/history.js +80 -0
  228. package/src/sdlc/paths.js +11 -0
  229. package/src/sdlc/release.js +106 -0
  230. package/src/sdlc/scaffold.js +89 -0
  231. package/src/sdlc/status-filter.js +54 -0
  232. package/src/sdlc/transition.js +112 -0
  233. package/src/sdlc/transitions/acceptance-criterion.js +28 -0
  234. package/src/sdlc/transitions/bug.js +31 -0
  235. package/src/sdlc/transitions/document.js +29 -0
  236. package/src/sdlc/transitions/index.js +56 -0
  237. package/src/sdlc/transitions/pitch.js +34 -0
  238. package/src/sdlc/transitions/requirement.js +31 -0
  239. package/src/sdlc/transitions/task.js +34 -0
  240. package/src/template-trust.js +597 -0
  241. package/src/validator/expressions.js +1 -0
  242. package/src/validator/index.js +3424 -0
  243. package/src/validator/kinds.js +346 -0
  244. package/src/validator/per-kind/acceptance-criterion.js +91 -0
  245. package/src/validator/per-kind/bug.js +77 -0
  246. package/src/validator/per-kind/component.js +274 -0
  247. package/src/validator/per-kind/domain.js +205 -0
  248. package/src/validator/per-kind/pitch.js +101 -0
  249. package/src/validator/per-kind/requirement.js +75 -0
  250. package/src/validator/per-kind/task.js +96 -0
  251. package/src/validator/registry.js +1 -0
  252. package/src/validator/utils.js +12 -0
  253. package/src/validator.js +1 -0
  254. package/src/workflows.js +7597 -0
  255. package/src/workspace-docs.js +265 -0
  256. package/template-helpers/react.js +5 -0
  257. package/template-helpers/sveltekit.js +5 -0
@@ -0,0 +1,327 @@
1
+ import { fieldSignature, refList, symbolList } from "./shared.js";
2
+
3
+ function invariantSummary(invariant) {
4
+ switch (invariant.type) {
5
+ case "comparison":
6
+ return `\`${invariant.left} ${invariant.operator} ${invariant.right?.value}\``;
7
+ case "requires":
8
+ return `\`${invariant.field}\` requires \`${invariant.predicate?.left} ${invariant.predicate?.operator} ${invariant.predicate?.right?.value}\``;
9
+ case "length_check":
10
+ return `\`${invariant.field}\` length ${invariant.operator} ${invariant.value?.value}`;
11
+ case "format_check":
12
+ return `\`${invariant.field}\` format ${invariant.operator} \`${invariant.format}\``;
13
+ case "implication":
14
+ if (invariant.then?.type === "state_check") {
15
+ return `if \`${invariant.when?.left} ${invariant.when?.operator} ${invariant.when?.right?.value}\`, then \`${invariant.then.field} is ${invariant.then.value?.value}\``;
16
+ }
17
+ return `if \`${invariant.when?.left} ${invariant.when?.operator} ${invariant.when?.right?.value}\`, then \`${invariant.then?.left} ${invariant.then?.operator} ${invariant.then?.right?.value}\``;
18
+ default:
19
+ return invariant.raw ? `\`${invariant.raw.join(" ")}\`` : "`unknown invariant`";
20
+ }
21
+ }
22
+
23
+ function relationSummary(relation) {
24
+ if (relation.type === "reference" && relation.target) {
25
+ return `\`${relation.sourceField}\` references \`${relation.target.id}.${relation.target.field}\``;
26
+ }
27
+
28
+ return relation.raw.map((value) => (Array.isArray(value) ? `[${value.join(", ")}]` : `\`${value}\``)).join(" ");
29
+ }
30
+
31
+ export function generateDocs(graph) {
32
+ const decisions = graph.byKind.decision || [];
33
+ const enums = graph.byKind.enum || [];
34
+ const actors = graph.byKind.actor || [];
35
+ const roles = graph.byKind.role || [];
36
+ const entities = graph.byKind.entity || [];
37
+ const shapes = graph.byKind.shape || [];
38
+ const capabilities = graph.byKind.capability || [];
39
+ const rules = graph.byKind.rule || [];
40
+ const projections = graph.byKind.projection || [];
41
+ const verifications = graph.byKind.verification || [];
42
+ const operations = graph.byKind.operation || [];
43
+
44
+ const lines = [];
45
+ lines.push("# Topogram Domain");
46
+ lines.push("");
47
+ lines.push(`Generated from \`${graph.root}\``);
48
+ lines.push("");
49
+
50
+ lines.push("## Enums");
51
+ lines.push("");
52
+ for (const item of enums) {
53
+ lines.push(`### \`${item.id}\``);
54
+ lines.push("");
55
+ lines.push(`Values: ${symbolList(item.values)}`);
56
+ lines.push("");
57
+ }
58
+
59
+ if (actors.length > 0) {
60
+ lines.push("## Actors");
61
+ lines.push("");
62
+ for (const actor of actors) {
63
+ lines.push(`### \`${actor.id}\` - ${actor.name || actor.id}`);
64
+ lines.push("");
65
+ if (actor.description) {
66
+ lines.push(actor.description);
67
+ lines.push("");
68
+ }
69
+ lines.push(`Status: \`${actor.status}\``);
70
+ lines.push("");
71
+ }
72
+ }
73
+
74
+ if (roles.length > 0) {
75
+ lines.push("## Roles");
76
+ lines.push("");
77
+ for (const role of roles) {
78
+ lines.push(`### \`${role.id}\` - ${role.name || role.id}`);
79
+ lines.push("");
80
+ if (role.description) {
81
+ lines.push(role.description);
82
+ lines.push("");
83
+ }
84
+ lines.push(`Status: \`${role.status}\``);
85
+ lines.push("");
86
+ }
87
+ }
88
+
89
+ if (decisions.length > 0) {
90
+ lines.push("## Decisions");
91
+ lines.push("");
92
+ for (const decision of decisions) {
93
+ lines.push(`### \`${decision.id}\` - ${decision.name || decision.id}`);
94
+ lines.push("");
95
+ if (decision.description) {
96
+ lines.push(decision.description);
97
+ lines.push("");
98
+ }
99
+ lines.push(`Context: ${symbolList(decision.context)}`);
100
+ lines.push(`Consequences: ${symbolList(decision.consequences)}`);
101
+ lines.push(`Status: \`${decision.status}\``);
102
+ lines.push("");
103
+ }
104
+ }
105
+
106
+ lines.push("## Entities");
107
+ lines.push("");
108
+ for (const entity of entities) {
109
+ lines.push(`### \`${entity.id}\` - ${entity.name || entity.id}`);
110
+ lines.push("");
111
+ if (entity.description) {
112
+ lines.push(entity.description);
113
+ lines.push("");
114
+ }
115
+ lines.push("Fields:");
116
+ for (const field of entity.fields) {
117
+ lines.push(`- ${fieldSignature(field)}`);
118
+ }
119
+ if (entity.relations.length > 0) {
120
+ lines.push("");
121
+ lines.push("Relations:");
122
+ for (const relation of entity.relations) {
123
+ lines.push(`- ${relationSummary(relation)}`);
124
+ }
125
+ }
126
+ if (entity.invariants.length > 0) {
127
+ lines.push("");
128
+ lines.push("Invariants:");
129
+ for (const invariant of entity.invariants) {
130
+ lines.push(`- ${invariantSummary(invariant)}`);
131
+ }
132
+ }
133
+ lines.push("");
134
+ }
135
+
136
+ lines.push("## Shapes");
137
+ lines.push("");
138
+ for (const shape of shapes) {
139
+ lines.push(`### \`${shape.id}\` - ${shape.name || shape.id}`);
140
+ lines.push("");
141
+ if (shape.description) {
142
+ lines.push(shape.description);
143
+ lines.push("");
144
+ }
145
+ if (shape.from?.id) {
146
+ lines.push(`Derived from: \`${shape.from.id}\``);
147
+ lines.push("");
148
+ }
149
+ if (shape.transformGraph?.transforms?.length > 0) {
150
+ lines.push("Transforms:");
151
+ for (const transform of shape.transformGraph.transforms) {
152
+ if (transform.type === "rename_field") {
153
+ lines.push(`- rename \`${transform.from}\` -> \`${transform.to}\``);
154
+ continue;
155
+ }
156
+ if (transform.type === "override_field") {
157
+ const changes = [];
158
+ if (transform.changes.requiredness) {
159
+ changes.push(transform.changes.requiredness);
160
+ }
161
+ if (transform.changes.fieldType) {
162
+ changes.push(`type \`${transform.changes.fieldType}\``);
163
+ }
164
+ if (transform.changes.defaultValue != null) {
165
+ changes.push(`default \`${transform.changes.defaultValue}\``);
166
+ }
167
+ lines.push(`- override \`${transform.field}\`: ${changes.join(", ")}`);
168
+ }
169
+ }
170
+ lines.push("");
171
+ }
172
+ lines.push("Projected fields:");
173
+ for (const field of shape.projectedFields || shape.fields) {
174
+ lines.push(`- ${fieldSignature(field)}`);
175
+ }
176
+ lines.push("");
177
+ }
178
+
179
+ lines.push("## Capabilities");
180
+ lines.push("");
181
+ for (const capability of capabilities) {
182
+ lines.push(`### \`${capability.id}\` - ${capability.name || capability.id}`);
183
+ lines.push("");
184
+ if (capability.description) {
185
+ lines.push(capability.description);
186
+ lines.push("");
187
+ }
188
+ lines.push(`Actors: ${refList(capability.actors)}`);
189
+ lines.push(`Roles: ${refList(capability.roles)}`);
190
+ lines.push(`Reads: ${refList(capability.reads)}`);
191
+ lines.push(`Creates: ${refList(capability.creates)}`);
192
+ lines.push(`Updates: ${refList(capability.updates)}`);
193
+ lines.push(`Deletes: ${refList(capability.deletes)}`);
194
+ lines.push(`Input: ${refList(capability.input)}`);
195
+ lines.push(`Output: ${refList(capability.output)}`);
196
+ lines.push("");
197
+ }
198
+
199
+ if (rules.length > 0) {
200
+ lines.push("## Rules");
201
+ lines.push("");
202
+ for (const rule of rules) {
203
+ lines.push(`### \`${rule.id}\` - ${rule.name || rule.id}`);
204
+ lines.push("");
205
+ if (rule.description) {
206
+ lines.push(rule.description);
207
+ lines.push("");
208
+ }
209
+ lines.push(`Applies to: ${refList(rule.appliesTo)}`);
210
+ lines.push(`Actors: ${refList(rule.actors)}`);
211
+ lines.push(`Roles: ${refList(rule.roles)}`);
212
+ if (rule.requirementNode?.raw) {
213
+ lines.push(`Requirement: \`${rule.requirementNode.raw}\``);
214
+ }
215
+ if (rule.conditionNode?.raw) {
216
+ lines.push(`Condition: \`${rule.conditionNode.raw}\``);
217
+ }
218
+ lines.push(`Severity: \`${rule.severity}\``);
219
+ lines.push("");
220
+ }
221
+ }
222
+
223
+ lines.push("## Projections");
224
+ lines.push("");
225
+ for (const projection of projections) {
226
+ lines.push(`### \`${projection.id}\` - ${projection.name || projection.id}`);
227
+ lines.push("");
228
+ if (projection.description) {
229
+ lines.push(projection.description);
230
+ lines.push("");
231
+ }
232
+ lines.push(`Platform: \`${projection.platform}\``);
233
+ lines.push(`Realizes: ${refList(projection.realizes)}`);
234
+ lines.push(`Outputs: ${symbolList(projection.outputs)}`);
235
+ lines.push("");
236
+ }
237
+
238
+ if (verifications.length > 0) {
239
+ lines.push("## Verification");
240
+ lines.push("");
241
+ for (const verification of verifications) {
242
+ lines.push(`### \`${verification.id}\` - ${verification.name || verification.id}`);
243
+ lines.push("");
244
+ if (verification.description) {
245
+ lines.push(verification.description);
246
+ lines.push("");
247
+ }
248
+ lines.push(`Method: \`${verification.method}\``);
249
+ lines.push(`Validates: ${refList(verification.validates)}`);
250
+ lines.push(`Scenarios: ${symbolList(verification.scenarios)}`);
251
+ lines.push("");
252
+ }
253
+ }
254
+
255
+ if (operations.length > 0) {
256
+ lines.push("## Operations");
257
+ lines.push("");
258
+ for (const operation of operations) {
259
+ lines.push(`### \`${operation.id}\` - ${operation.name || operation.id}`);
260
+ lines.push("");
261
+ if (operation.description) {
262
+ lines.push(operation.description);
263
+ lines.push("");
264
+ }
265
+ lines.push(`Observes: ${refList(operation.observes)}`);
266
+ lines.push(`Metrics: ${symbolList(operation.metrics)}`);
267
+ lines.push(`Alerts: ${symbolList(operation.alerts)}`);
268
+ lines.push("");
269
+ }
270
+ }
271
+
272
+ if ((graph.docs || []).length > 0) {
273
+ lines.push("## Companion Docs");
274
+ lines.push("");
275
+ for (const doc of graph.docs) {
276
+ lines.push(`### \`${doc.id}\` - ${doc.title}`);
277
+ lines.push("");
278
+ lines.push(`Kind: \`${doc.kind}\``);
279
+ lines.push(`Status: \`${doc.status}\``);
280
+ if (doc.summary) {
281
+ lines.push("");
282
+ lines.push(doc.summary);
283
+ }
284
+ if (doc.relatedEntities.length > 0) {
285
+ lines.push("");
286
+ lines.push(`Related entities: ${doc.relatedEntities.map((id) => `\`${id}\``).join(", ")}`);
287
+ }
288
+ if (doc.relatedCapabilities.length > 0) {
289
+ lines.push(`Related capabilities: ${doc.relatedCapabilities.map((id) => `\`${id}\``).join(", ")}`);
290
+ }
291
+ lines.push("");
292
+ }
293
+ }
294
+
295
+ return `${lines.join("\n").trimEnd()}\n`;
296
+ }
297
+
298
+ export function generateDocsIndex(graph) {
299
+ const docs = (graph.docs || []).map((doc) => ({
300
+ id: doc.id,
301
+ kind: doc.kind,
302
+ title: doc.title,
303
+ status: doc.status,
304
+ summary: doc.summary,
305
+ aliases: doc.aliases,
306
+ related_entities: doc.relatedEntities,
307
+ related_capabilities: doc.relatedCapabilities,
308
+ related_shapes: doc.relatedShapes,
309
+ related_projections: doc.relatedProjections,
310
+ related_docs: doc.relatedDocs,
311
+ source_of_truth: doc.sourceOfTruth,
312
+ confidence: doc.confidence,
313
+ review_required: doc.reviewRequired,
314
+ provenance: doc.provenance,
315
+ tags: doc.tags,
316
+ file: doc.file,
317
+ relative_path: doc.relativePath,
318
+ body: doc.body
319
+ }));
320
+
321
+ return {
322
+ type: "docs_index",
323
+ root: graph.root,
324
+ count: docs.length,
325
+ docs
326
+ };
327
+ }
@@ -0,0 +1,161 @@
1
+ import { resolveWorkspace } from "../resolver.js";
2
+ import { generateDocs, generateDocsIndex } from "./docs.js";
3
+ import {
4
+ generateJsonSchema,
5
+ generateShapeTransformDebug,
6
+ generateShapeTransformGraph
7
+ } from "./schema.js";
8
+ import {
9
+ generateApiContractDebug,
10
+ generateApiContractGraph,
11
+ generateOpenApi
12
+ } from "./api.js";
13
+ import { generateVerificationChecklist, generateVerificationPlan } from "./verification.js";
14
+ import { generateUiComponentContract } from "./components.js";
15
+ import {
16
+ generateComponentBehaviorReport,
17
+ generateComponentConformanceReport
18
+ } from "./component-conformance.js";
19
+ import { generateDbTarget } from "./surfaces/databases/index.js";
20
+ import { generateAppTarget } from "./surfaces/index.js";
21
+ import { generateRuntimeTarget } from "./runtime/index.js";
22
+ import { generateContextTarget } from "./context/index.js";
23
+ import { generateSdlcTarget } from "./sdlc/index.js";
24
+ import { buildOutputFiles } from "./output.js";
25
+
26
+ function okResult(target, artifact) {
27
+ return {
28
+ ok: true,
29
+ target,
30
+ artifact
31
+ };
32
+ }
33
+
34
+ export function generateWorkspace(workspaceAst, options = {}) {
35
+ const resolved = resolveWorkspace(workspaceAst);
36
+ if (!resolved.ok) {
37
+ return {
38
+ ok: false,
39
+ validation: resolved.validation
40
+ };
41
+ }
42
+
43
+ const { graph } = resolved;
44
+ const { target } = options;
45
+
46
+ if (target === "json-schema") {
47
+ return okResult(target, generateJsonSchema(graph, options));
48
+ }
49
+ if (target === "docs") {
50
+ return okResult(target, generateDocs(graph, options));
51
+ }
52
+ if (target === "docs-index") {
53
+ return okResult(target, generateDocsIndex(graph, options));
54
+ }
55
+ if (target === "shape-transform-graph") {
56
+ return okResult(target, generateShapeTransformGraph(graph, options));
57
+ }
58
+ if (target === "shape-transform-debug") {
59
+ return okResult(target, generateShapeTransformDebug(graph, options));
60
+ }
61
+ if (target === "api-contract-graph") {
62
+ return okResult(target, generateApiContractGraph(graph, options));
63
+ }
64
+ if (target === "api-contract-debug") {
65
+ return okResult(target, generateApiContractDebug(graph, options));
66
+ }
67
+ if (target === "openapi") {
68
+ return okResult(target, generateOpenApi(graph, options));
69
+ }
70
+ if (target === "verification-plan") {
71
+ return okResult(target, generateVerificationPlan(graph, options));
72
+ }
73
+ if (target === "verification-checklist") {
74
+ return okResult(target, generateVerificationChecklist(graph, options));
75
+ }
76
+ if (target === "ui-component-contract") {
77
+ return okResult(target, generateUiComponentContract(graph, options));
78
+ }
79
+ if (target === "component-conformance-report") {
80
+ return okResult(target, generateComponentConformanceReport(graph, options));
81
+ }
82
+ if (target === "component-behavior-report") {
83
+ return okResult(target, generateComponentBehaviorReport(graph, options));
84
+ }
85
+
86
+ if (
87
+ target === "db-contract-graph" ||
88
+ target === "db-contract-debug" ||
89
+ target === "db-schema-snapshot" ||
90
+ target === "db-migration-plan" ||
91
+ target === "db-lifecycle-plan" ||
92
+ target === "db-lifecycle-bundle" ||
93
+ target === "sql-schema" ||
94
+ target === "sql-migration" ||
95
+ target === "prisma-schema" ||
96
+ target === "drizzle-schema"
97
+ ) {
98
+ return okResult(target, generateDbTarget(target, graph, options));
99
+ }
100
+
101
+ if (
102
+ target === "ui-contract-graph" ||
103
+ target === "ui-contract-debug" ||
104
+ target === "ui-web-contract" ||
105
+ target === "ui-web-debug" ||
106
+ target === "sveltekit-app" ||
107
+ target === "server-contract" ||
108
+ target === "persistence-scaffold" ||
109
+ target === "hono-server" ||
110
+ target === "express-server" ||
111
+ target === "swiftui-app"
112
+ ) {
113
+ return okResult(target, generateAppTarget(target, graph, options));
114
+ }
115
+
116
+ if (
117
+ target === "context-digest" ||
118
+ target === "context-diff" ||
119
+ target === "context-slice" ||
120
+ target === "context-bundle" ||
121
+ target === "context-report" ||
122
+ target === "context-task-mode" ||
123
+ target === "domain-coverage" ||
124
+ target === "domain-list" ||
125
+ target === "domain-page"
126
+ ) {
127
+ return okResult(target, generateContextTarget(target, graph, options));
128
+ }
129
+
130
+ if (
131
+ target === "sdlc-board" ||
132
+ target === "sdlc-doc-page" ||
133
+ target === "sdlc-release-notes" ||
134
+ target === "sdlc-traceability-matrix"
135
+ ) {
136
+ return okResult(target, generateSdlcTarget(target, graph, options));
137
+ }
138
+
139
+ if (
140
+ target === "environment-plan" ||
141
+ target === "environment-bundle" ||
142
+ target === "deployment-plan" ||
143
+ target === "deployment-bundle" ||
144
+ target === "runtime-smoke-plan" ||
145
+ target === "runtime-smoke-bundle" ||
146
+ target === "runtime-check-plan" ||
147
+ target === "runtime-check-bundle" ||
148
+ target === "compile-check-plan" ||
149
+ target === "compile-check-bundle" ||
150
+ target === "app-bundle-plan" ||
151
+ target === "app-bundle" ||
152
+ target === "native-parity-plan" ||
153
+ target === "native-parity-bundle"
154
+ ) {
155
+ return okResult(target, generateRuntimeTarget(target, graph, options));
156
+ }
157
+
158
+ throw new Error(`Unsupported generator target '${target}'`);
159
+ }
160
+
161
+ export { buildOutputFiles };