@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,67 @@
1
+ # Topogram Architecture
2
+
3
+ Topogram turns a `.tg` workspace into generated artifacts and apps through five layers:
4
+
5
+ 1. `Topogram graph`
6
+ 2. `realization`
7
+ 3. normalized `contracts`
8
+ 4. generator manifest + adapter
9
+ 5. optional implementation provider
10
+
11
+ ## Flow
12
+
13
+ 1. `engine/src/parser` reads `.tg` files into an AST.
14
+ 2. `engine/src/validator` validates statements and projection semantics.
15
+ 3. `engine/src/resolver` produces a resolved semantic graph.
16
+ 4. `engine/src/realization` derives target-ready realization objects from that graph.
17
+ 5. `engine/src/generator` builds normalized contracts and resolves topology-bound generator manifests.
18
+ 6. Bundled or package-backed generator adapters render stack-specific files.
19
+ 7. Workspace `implementation/` modules supply project-specific reference behavior that should not live in the generic engine.
20
+
21
+ ## Boundaries
22
+
23
+ `engine/src/realization`
24
+ - Owns normalized semantic interpretation.
25
+ - Converts projections into stable realization objects.
26
+ - Should be domain-agnostic and projection-driven.
27
+
28
+ `engine/src/generator`
29
+ - Owns contract emission, generator manifest validation, and file emission.
30
+ - Dispatches through topology-bound generator adapters.
31
+ - Should be contract-aware and stack-adapter-aware, not example-aware.
32
+
33
+ Generator adapters
34
+ - Own stack-specific realization such as React, SvelteKit, Hono, Express,
35
+ Postgres, SQLite, Prisma, Drizzle, SwiftUI, or future Android files.
36
+ - Consume normalized contracts, topology component metadata, and optional
37
+ implementation hooks.
38
+ - Return generated files and diagnostics through the shared generator interface.
39
+
40
+ Workspace `implementation/`
41
+ - Owns project-specific runtime/reference behavior.
42
+ - Can include seed data, custom page renderers, repository implementations, and runtime-check specifics.
43
+ - Must not be treated as engine contracts.
44
+
45
+ `component` statements live in the semantic graph beside entities, capabilities,
46
+ shapes, and projections. They produce `componentContract` resolver enrichment
47
+ and can be emitted through the `ui-component-contract` generator target without
48
+ requiring an implementation provider.
49
+
50
+ ## Stable Internal Contracts
51
+
52
+ The engine currently treats these realization types as stable internal interfaces:
53
+
54
+ - `ApiRealization`
55
+ - `DbRealization`
56
+ - `UiSharedRealization`
57
+ - `WebAppRealization`
58
+ - `BackendRuntimeRealization`
59
+
60
+ Renderers should consume these contracts instead of rediscovering domain meaning from raw statements.
61
+
62
+ ## Active Proof Targets
63
+
64
+ The active repo proof target is intentionally small:
65
+
66
+ - `engine/tests/fixtures/workspaces/app-basic`: engine-owned authoring-to-app fixture
67
+ - Private `topogram-demo-todo` repo: package-consumer generated app demo
package/CHANGELOG.md ADDED
@@ -0,0 +1,240 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - Install package-backed generator dependencies during `topogram template check`
6
+ before starter validation.
7
+
8
+ ## 0.3.16 - 2026-05-03
9
+
10
+ - Install package-backed generator dependencies during `topogram template check`
11
+ before starter validation.
12
+
13
+ ## 0.3.15 - 2026-05-03
14
+
15
+ - Carry package-backed generator dependencies from template packages into
16
+ generated starter package devDependencies.
17
+
18
+ ## 0.3.14 - 2026-05-03
19
+
20
+ - Add the bundled generator manifest/adapter interface so first-party stack
21
+ generators dispatch through topology-bound generator manifests.
22
+ - Add explicit package-backed generator loading for installed packages with
23
+ `topogram-generator.json` manifests and synchronous adapter exports.
24
+ - Document generator packs as the long-term boundary for reusable stack
25
+ realization while templates compose generator IDs and optional implementation
26
+ customizations.
27
+ - Make SvelteKit route generation contract-complete by default: generic route
28
+ files are generated from the Topogram contract first, and template
29
+ implementation providers may override specific route files.
30
+ - Emit SvelteKit `src/lib/topogram/generation-coverage.json` so generated apps
31
+ record routed-screen coverage, implementation-vs-generator ownership,
32
+ component rendering coverage, and diagnostics when projection intent is not
33
+ realized.
34
+ - Emit the same generation coverage artifact for React apps so web generators
35
+ share a common route and component coverage contract.
36
+
37
+ ## 0.3.13 - 2026-05-01
38
+
39
+ - Add `topogram component check` as a user-facing alias for component
40
+ conformance reports. The command prints a human summary by default, supports
41
+ `--projection`, `--component`, and `--json`, and exits non-zero when
42
+ conformance errors are present.
43
+
44
+ ## 0.3.12 - 2026-05-01
45
+
46
+ - Add `component-conformance-report` generator target. The report compares
47
+ `projection.ui_components` usage against component contracts, includes
48
+ inherited shared-UI usages for concrete web projections, supports
49
+ `--projection` and `--component` filters, and reports repair-oriented checks
50
+ for missing required props, event action context, component status, approvals,
51
+ write scope, and projection/component impact.
52
+
53
+ ## 0.3.11 - 2026-05-01
54
+
55
+ - Add `domain` statement kind for grouping the spec by business slice
56
+ (FIS, RNF, DrugTrac, etc.). Identifier prefix `dom_`. Required fields:
57
+ `name`, `description`, `status`. Optional: `in_scope`, `out_of_scope`,
58
+ `owners`, `parent_domain`, `aliases`. Validator enforces identifier
59
+ prefix, scope-list shapes, owner refs (`actor`|`role`), parent_domain
60
+ refs, and parent-domain cycle detection.
61
+ - Add optional singular `domain` field on `capability`, `entity`, `rule`,
62
+ `verification`, `orchestration`, `operation`, and `decision`. Cross-kind
63
+ validator hard-errors on unknown ids and wrong-kind references.
64
+ - Resolver populates `resolvedDomain` on each tagged statement and a
65
+ reverse-indexed `members` block on each `domain` (capabilities,
66
+ entities, rules, verifications, orchestrations, operations, decisions).
67
+ - `context-slice --domain <id>` returns a focused subgraph
68
+ (`focus.kind === "domain"`, members summarized, projections that
69
+ realize any of its capabilities, plus a `domain_surface` review
70
+ boundary). The same `--domain` selector flows through
71
+ `verification-targets`, `change-plan`, `review-packet`, and the rest
72
+ of the query family.
73
+ - `query domain-coverage --domain <id>` emits a per-platform realization
74
+ matrix (capabilities × platforms) plus the projections involved.
75
+ - `query domain-list` lists all domains with member counts for navigation.
76
+ - New `domain-coverage` and `domain-page` generator targets. The latter
77
+ emits markdown summaries at `topogram/docs-generated/domains/{slug}.md`
78
+ per domain (members, in/out-of-scope, per-platform coverage table).
79
+ - `context-diff` now emits a `domains` section.
80
+ - `workspace-docs` recognizes a singular `domain:` frontmatter field on
81
+ documents; the validator checks the reference.
82
+ - New docs: `docs/domains.md` (full guide); `docs/grammar.md` updated
83
+ with the `domain` row and the optional-field paragraph;
84
+ `docs/topogram-workspace-layout.md` appends a "Domain organization"
85
+ subsection.
86
+ - New fixture `engine/tests/fixtures/domains/feedlot/` (3 domains,
87
+ 10 capabilities, 12 entities, 4 cross-platform projections) and
88
+ golden tests at `engine/tests/active/domain-kind.test.js`.
89
+
90
+ ### SDLC layer (Phase 2)
91
+
92
+ - Add five new SDLC statement kinds: `pitch` (`pitch_`), `requirement`
93
+ (`req_`), `acceptance_criterion` (`ac_`), `task` (`task_`), and `bug`
94
+ (`bug_`). Plus a markdown-only `document` (`doc_`) kind via
95
+ `workspace-docs.js`. Each kind has its own status set, identifier
96
+ pattern, required/allowed fields, and per-kind validator.
97
+ - Generalize `validateStatus` into a per-kind status table
98
+ (`STATUS_SETS_BY_KIND`) so `decision` (existing) and the new SDLC
99
+ kinds (`pitch`, `requirement`, `acceptance_criterion`, `task`, `bug`)
100
+ each enforce their own status sequences.
101
+ - Extend existing kinds: `verification` gains `requirement_refs`,
102
+ `acceptance_refs`, `fixes_bugs`; `decision` gains `pitch`,
103
+ `supersedes`; `rule` gains `from_requirement`. All validate via the
104
+ generalized cross-reference checker.
105
+ - Resolver builds 20+ new SDLC back-link arrays
106
+ (`pitch.requirements`, `requirement.acceptanceCriteria`,
107
+ `acceptance_criterion.tasks`, `task.blockingMe`, `bug.verifiedBy`,
108
+ `rule.introducedByRequirements`, `rule.violatedByBugs`,
109
+ `decision.introducedByTasks`, `capability.affectedByPitches`,
110
+ `capability.affectedByRequirements`, `capability.affectedByTasks`,
111
+ `capability.affectedByBugs`, etc.) so consumers can traverse the
112
+ shape-the-work → ship → defect → verification chain without
113
+ re-walking the graph.
114
+ - Extend `domain.members` with SDLC arrays (`pitches`, `requirements`,
115
+ `tasks`, `bugs`, `documents`).
116
+ - Six new `context-slice` selectors: `--pitch`, `--requirement`,
117
+ `--acceptance`, `--task`, `--bug`, `--document`. Each returns the
118
+ same shape as existing slices (focus + summary + depends_on + related
119
+ + verification + write_scope + review_boundary) with kind-appropriate
120
+ review-boundary reasons (`pitch_scope`, `requirement_scope`,
121
+ `task_scope`, `bug_scope`, `document_scope`).
122
+ - `context-diff` folds SDLC artifact changes into a new `sdlc` section
123
+ covering pitch/requirement/AC/task/bug deltas.
124
+ - New `engine/src/sdlc/` core module: per-kind state machines under
125
+ `transitions/`, per-kind DoD checks under `dod/`, history sidecar
126
+ (`.topogram-sdlc-history.json`) for transition records, default-active
127
+ status filtering, and a top-level orchestrator that surgically rewrites
128
+ `.tg` `status` fields without disturbing surrounding formatting.
129
+ - New `engine/src/archive/` module: year-bucketed JSONL archive
130
+ (`topogram/_archive/{kind}s-{year}.jsonl`), resolver bridge that
131
+ auto-loads frozen entries at workspace-parse time so traceability
132
+ still sees them, plus `archive` / `unarchive` / `compact` operations.
133
+ - New CLI subcommand group: `topogram sdlc transition <id> <status>`,
134
+ `sdlc check`, `sdlc explain <id>` (with structured `next_action`
135
+ output), `sdlc archive`, `sdlc unarchive`, `sdlc compact`,
136
+ `sdlc new <kind> <slug>`, `sdlc adopt`, plus `topogram release`
137
+ for atomic changelog assembly + document `app_version` stamping +
138
+ archive trigger (with `--dry-run`).
139
+ - Four new generator targets: `sdlc-board` (kanban with `--kind`
140
+ filter), `sdlc-doc-page` (rendered markdown per document with
141
+ cross-ref sidebar), `sdlc-release-notes` (assembled from approved
142
+ pitches + done tasks + verified bugs in a release window), and
143
+ `sdlc-traceability-matrix` (pitch → req → AC → task/bug →
144
+ verification table with gap detection).
145
+ - `workspace-docs` extended: 7 new `DOC_KINDS` (`user-guide`, `api`,
146
+ `architecture`, `operations`, `getting-started`, `reference`,
147
+ `development`); 3 new `DOC_STATUSES` (`review`, `published`,
148
+ `archived`); `app_version`, `audience`, `priority`, `version`,
149
+ `affects`, `satisfies`, `approvals` frontmatter fields.
150
+ - New docs: `docs/sdlc.md` (kinds, lifecycles, slices, release flow,
151
+ agent-loop pattern), `docs/lifecycles.md` (per-kind state diagrams
152
+ and DoD reference), and the SDLC layout subsection in
153
+ `docs/topogram-workspace-layout.md`.
154
+ - New fixture `engine/tests/fixtures/workspaces/app-basic/` with one
155
+ pitch + requirement + AC + task + bug + archived JSONL bug, plus 21
156
+ golden tests at `engine/tests/active/sdlc-kinds.test.js` covering
157
+ validators, resolver back-links, six new slice selectors, three
158
+ generators (board/release-notes/traceability), state-machine
159
+ transitions, DoD rules, archive load/save, transition round-trips
160
+ (rewrite + history sidecar), and release dry-run output.
161
+ - Add `projection.ui_components` so projections explicitly own component
162
+ placement and wiring. Component usage validates screen, region, component,
163
+ prop, event, data-source, and event-target references.
164
+ - Remove `component.consumers` from the component grammar before external
165
+ adoption; component usage now flows from projections instead of components
166
+ self-registering consumers.
167
+ - Add structured component `behaviors { ... }` alongside the shorthand
168
+ `behavior [...]`, with validation for supported stack-agnostic behavior
169
+ kinds and behavior references to component props/events.
170
+ - Emit `approvals` and normalized `behaviors` in `ui-component-contract`
171
+ artifacts.
172
+ - Include component usage metadata in generated UI contracts. Concrete web
173
+ projections that realize a shared UI projection now inherit the shared
174
+ projection's component usages and component contracts.
175
+ - Fix component diff impact for removed components by resolving projection
176
+ impact from the baseline graph.
177
+
178
+ ## 0.3.0 - 2026-05-01
179
+
180
+ - Add `component` statement kind for reusable UI/service component contracts
181
+ (props, events, slots, patterns, regions, dependencies, consumers).
182
+ - Add `ui-component-contract` generator target that emits stable JSON per
183
+ component or for the whole workspace; selectable via `--component <id>`.
184
+ - `context-diff` now emits a `components` section, and changed components
185
+ fan out into `affected_generated_surfaces.projections` so consumer
186
+ projections show up in diff payloads.
187
+ - `context-slice --component <id>` returns a first-class component slice with
188
+ `focus.kind === "component"`, dependent shapes/projections/verifications,
189
+ and a `component_surface` review boundary; the same selector flows through
190
+ `verification-targets`, `change-plan`, `risk-summary`, `review-packet`,
191
+ `proceed-decision`, `next-action`, `single-agent-plan`, and
192
+ `resolved-workflow-context`.
193
+ - `topogram generate ... --generate ui-component-contract --component <id>`
194
+ now errors loudly when the id does not match any component (previously it
195
+ wrote a `null` artifact).
196
+ - Component prop defaults preserve real values: `default true`, `default false`,
197
+ `default null`, integers, floats, quoted strings, and `default []` are all
198
+ surfaced in the generated contract instead of collapsing to `null`.
199
+ - Add `docs/grammar.md` as the first authoritative reference for `.tg`
200
+ statement kinds.
201
+
202
+ ## 0.2.22 - 2026-04-29
203
+
204
+ - Record catalog provenance when `topogram new --template <catalog-id>` resolves
205
+ a template alias to a package-backed template.
206
+ - Preserve the catalog alias/source in project template metadata, template file
207
+ baselines, and executable implementation trust records.
208
+
209
+ ## 0.2.21 - 2026-04-29
210
+
211
+ - Add private catalog commands: `topogram catalog list`, `catalog check`, and
212
+ `catalog copy`.
213
+ - Include catalog template aliases in `topogram template list`.
214
+ - Allow `topogram new --template <catalog-id>` to resolve package-backed
215
+ template entries from the catalog.
216
+ - Keep pure topogram catalog entries non-executable in v1.
217
+
218
+ ## 0.1.0 - 2026-04-15
219
+
220
+ Initial `v0.1` release candidate for the Topogram reference toolchain.
221
+
222
+ Highlights:
223
+
224
+ - parser, validator, and semantic resolver for the Topogram DSL
225
+ - typed semantic graph for the Todo reference domain
226
+ - JSON Schema, docs, API contract, OpenAPI, UI contract, DB contract, and debug generators
227
+ - shared UI semantics plus web realization and SvelteKit scaffold generation
228
+ - Postgres and SQLite DB projections
229
+ - DB schema snapshots, additive migration planning, Prisma and Drizzle schema generation
230
+ - repository scaffolds and Hono server generation
231
+ - DB lifecycle automation for greenfield bootstrap and brownfield migration
232
+ - local environment, deployment, smoke-test, compile-check, and polished app-bundle generation
233
+ - seeded demo data path for the generated Todo app golden path
234
+
235
+ Known boundaries:
236
+
237
+ - Prisma is the most complete generated runtime profile
238
+ - Drizzle runtime implementations remain scaffolds
239
+ - destructive or ambiguous DB migrations are intentionally manual
240
+ - deployment bundles are strong starting points, not turnkey production infrastructure
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # Topogram Engine
2
+
3
+ This folder contains the Topogram implementation: parser, validator, resolver, generators, runtime bundle emitters, and CLI.
4
+
5
+ The active product workflow is authoring-to-generated-app. Engine development should stay separate from user-facing demos.
6
+
7
+ ## Package Shape
8
+
9
+ The engine is the publishable private CLI package:
10
+
11
+ ```json
12
+ {
13
+ "name": "@topogram/cli",
14
+ "bin": {
15
+ "topogram": "./src/cli.js"
16
+ }
17
+ }
18
+ ```
19
+
20
+ This lets source checkouts and private-package consumers call:
21
+
22
+ ```bash
23
+ topogram new ../my-app
24
+ topogram version
25
+ topogram version --json
26
+ topogram doctor
27
+ topogram check
28
+ topogram generate
29
+ topogram catalog list
30
+ topogram catalog show todo
31
+ topogram catalog check topograms.catalog.json
32
+ topogram catalog copy hello ../hello-topogram
33
+ topogram import ../existing-app --out ../imported-topogram
34
+ topogram import check ../imported-topogram
35
+ topogram release status
36
+ topogram package update-cli --latest
37
+ topogram source status ../hello-topogram --local
38
+ topogram source status ../hello-topogram --remote
39
+ topogram template list
40
+ topogram template explain
41
+ topogram template status
42
+ topogram template policy check
43
+ topogram template policy pin @scope/template@0.2.0
44
+ topogram template check ../my-template
45
+ topogram template update --plan
46
+ topogram trust template
47
+ ```
48
+
49
+ Publishing is manual through the repo-level `Publish CLI Package` workflow. Create generated projects outside `engine/`; this directory is source and test code.
50
+
51
+ From the repo root, prefer:
52
+
53
+ ```bash
54
+ npm run smoke:test-app
55
+ npm run cli:check
56
+ npm run new -- ./my-topogram-app
57
+ ```
58
+
59
+ ## Layout
60
+
61
+ - `src/` - engine source
62
+ - `tests/active/` - retained active engine tests
63
+ - `tests/fixtures/templates/` - local template fixtures used by engine tests
64
+ - `tests/fixtures/workspaces/` - engine-owned Topogram workspaces
65
+ - `tests/fixtures/expected/` - engine-owned golden outputs
66
+ - `tests/fixtures/invalid/` - invalid model cases
67
+
68
+ The generated Todo demo and Todo starter template live outside this repo in `topogram-demo-todo` and `topogram-template-todo`.
69
+
70
+ ## Active Fixture
71
+
72
+ The current generated-app regression fixture is:
73
+
74
+ ```text
75
+ tests/fixtures/workspaces/app-basic/
76
+ tests/fixtures/expected/app-basic/
77
+ ```
78
+
79
+ It is a fixture, not a user example.
80
+
81
+ ## Commands
82
+
83
+ Run the engine gate:
84
+
85
+ ```bash
86
+ npm run check
87
+ ```
88
+
89
+ Create a starter project from the catalog-backed default `hello-web` alias:
90
+
91
+ ```bash
92
+ topogram new ../my-topogram-app --template hello-web
93
+ cd ../my-topogram-app
94
+ npm install
95
+ npm run doctor
96
+ npm run check
97
+ ```
98
+
99
+ Choose another catalog starter with the template commands:
100
+
101
+ ```bash
102
+ topogram template list
103
+ topogram template show web-api
104
+ topogram new ../web-api-demo --template web-api
105
+ ```
106
+
107
+ Create a starter project from a shared template package:
108
+
109
+ ```bash
110
+ topogram new ../todo-demo --template @topogram/template-todo
111
+ topogram new ../todo-demo --template todo
112
+ ```
113
+
114
+ Catalog aliases resolve through the private catalog index at
115
+ `github:attebury/topograms/topograms.catalog.json`. The catalog is package
116
+ backed; executable starter content still lives in template packages. Use
117
+ `topogram catalog show <id>` to inspect an entry and get the correct `new` or
118
+ `copy` command for that kind. Use `topogram template show <id>` when the entry
119
+ is known to be a starter template and you want the direct `topogram new` flow.
120
+ Pure
121
+ topogram catalog entries can be copied for editing with
122
+ `topogram catalog copy <id> <target>`. Copied topogram projects record
123
+ `.topogram-source.json`; inspect local drift from that import baseline with
124
+ `topogram source status <target> --local`. This metadata is provenance only and does not
125
+ block local edits, checks, or generation. Template baseline divergence means the
126
+ local project owns those edits; executable implementation trust is the separate
127
+ state that can block generation until reviewed.
128
+ Run `topogram template detach <target>` when the project should stop tracking
129
+ template update metadata while keeping normal check/generate behavior.
130
+
131
+ Do not create generated projects under `engine/`. The CLI refuses paths inside the engine directory.
132
+
133
+ Template pack authoring and trust policy are documented in `../docs/template-authoring.md`.
134
+ Catalog layout and private access are documented in `../docs/catalog.md`.
135
+ Projects created from executable templates include `.topogram-template-trust.json`;
136
+ regenerate it with `topogram trust template` after reviewing copied
137
+ `implementation/` code. Use `topogram template status` for the lifecycle
138
+ summary, then `topogram trust status` and `topogram trust diff` to inspect
139
+ changed files before refreshing trust.
140
+
141
+ Projects also include `topogram.template-policy.json`, the allow policy used by
142
+ template update and template check commands. It can restrict candidate template
143
+ sources, template ids, package scopes, executable-template behavior, and pinned
144
+ template versions:
145
+
146
+ ```bash
147
+ topogram template policy check
148
+ topogram template policy explain
149
+ topogram template policy init
150
+ topogram template policy pin @scope/template@0.2.0
151
+ ```
152
+
153
+ Use `topogram template policy explain` for a rule-by-rule view of the current
154
+ project template, package scope, catalog provenance, executable implementation
155
+ setting, and pinned version state.
156
+
157
+ Use `topogram template status --latest` and `topogram template update --latest`
158
+ only for package-backed templates when an explicit registry lookup is desired.
159
+ Plain status and update commands do not query the registry.
160
+
161
+ Use `topogram template update --status [--template <spec>]` to inspect current
162
+ template adoption state with baseline and conflict analysis. Use
163
+ `topogram template update --recommend [--template <spec>]` for a concise
164
+ human/agent next-step summary before applying, adopting, or deleting files. Use
165
+ `topogram template update --plan [--template <spec>]` to compare the current
166
+ project with a candidate template without writing files. Use
167
+ `topogram template update --check [--template <spec>]` as the no-write CI guard;
168
+ it exits nonzero when the project is not aligned with the recorded or supplied
169
+ template. Any update mode can write a machine-readable review report with
170
+ `--out <path>`. After review, `topogram template update --apply [--template
171
+ <spec>]` writes added/changed template-owned files, records a new
172
+ `.topogram-template-files.json` baseline, skips deletes, and refuses local
173
+ conflicts. Existing projects can run `topogram trust template` after review to
174
+ record the first template-owned file baseline. JSON output includes structured
175
+ diagnostics with codes, paths, suggested fixes, and workflow steps.
176
+
177
+ Single-file adoption actions are explicit and baseline-aware:
178
+ `--accept-current <file>` records the current file as the trusted baseline,
179
+ `--accept-candidate <file>` applies one candidate file after baseline checks,
180
+ and `--delete-current <file>` deletes one current-only file only when it still
181
+ matches the trusted baseline.
182
+
183
+ Template authors can run `topogram template check <template-spec-or-path>` to
184
+ validate manifest/layout, temporary starter creation, starter checks, trust
185
+ metadata, and no-write update planning. The JSON form reports structured
186
+ diagnostics with codes, paths, and suggested fixes for authoring feedback.
187
+
188
+ Run the same gate directly:
189
+
190
+ ```bash
191
+ npm test
192
+ ```
193
+
194
+ Run only the active fixture validity check:
195
+
196
+ ```bash
197
+ npm run fixture:check
198
+ ```
199
+
200
+ Inspect the active fixture topology as JSON:
201
+
202
+ ```bash
203
+ npm run fixture:check:json
204
+ ```
205
+
206
+ Generate the active fixture app bundle:
207
+
208
+ ```bash
209
+ npm run fixture:generate
210
+ ```
211
+
212
+ Run the app-generation workflow test:
213
+
214
+ ```bash
215
+ node --test ./tests/active/generated-app-workflow.test.js
216
+ ```
217
+
218
+ Validate or generate through the public CLI shape:
219
+
220
+ ```bash
221
+ node ./src/cli.js check ./tests/fixtures/workspaces/app-basic
222
+ node ./src/cli.js generate ./tests/fixtures/workspaces/app-basic --out /tmp/topogram-app
223
+ ```
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@topogram/cli",
3
+ "version": "0.3.34",
4
+ "description": "Topogram CLI for checking Topogram workspaces and generating app bundles.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/attebury/topogram.git",
9
+ "directory": "engine"
10
+ },
11
+ "type": "module",
12
+ "bin": {
13
+ "topogram": "src/cli.js"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "template-helpers",
18
+ "README.md",
19
+ "ARCHITECTURE.md",
20
+ "CHANGELOG.md"
21
+ ],
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
25
+ "publishConfig": {
26
+ "registry": "https://registry.npmjs.org",
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "new": "node ./src/cli.js new",
31
+ "check": "npm test",
32
+ "fixture:check": "node ./src/cli.js check ./tests/fixtures/workspaces/app-basic",
33
+ "fixture:check:json": "node ./src/cli.js check ./tests/fixtures/workspaces/app-basic --json",
34
+ "fixture:generate": "node ./src/cli.js generate ./tests/fixtures/workspaces/app-basic --out ./.tmp/app-basic",
35
+ "check:fixture": "npm run fixture:check",
36
+ "parse": "node ./src/cli.js ./tests/fixtures/workspaces/app-basic",
37
+ "parse:json": "node ./src/cli.js ./tests/fixtures/workspaces/app-basic --json",
38
+ "validate": "node ./src/cli.js validate ./tests/fixtures/workspaces/app-basic",
39
+ "validate:bad": "node ./src/cli.js validate ./tests/fixtures/invalid/missing-reference",
40
+ "resolve": "node ./src/cli.js ./tests/fixtures/workspaces/app-basic --resolve",
41
+ "generate:app": "npm run fixture:generate",
42
+ "generate:app-bundle": "npm run fixture:generate",
43
+ "test:types": "tsc -p ./tsconfig.check.json",
44
+ "test:active": "npm run test:types && node --test ./tests/active/*.test.js",
45
+ "test": "npm run test:active"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.14.1",
49
+ "typescript": "^5.6.3"
50
+ }
51
+ }
@@ -0,0 +1,3 @@
1
+ export function buildAdoptionStatus(runWorkflow, inputPath, options = {}) {
2
+ return runWorkflow("adoption-status", inputPath, options);
3
+ }