@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,227 @@
1
+ import {
2
+ canonicalCandidateTerm,
3
+ dedupeCandidateRecords,
4
+ findImportFiles,
5
+ idHintify,
6
+ makeCandidateRecord,
7
+ relativeTo,
8
+ titleCase
9
+ } from "../../core/shared.js";
10
+
11
+ function shouldIgnoreFile(filePath) {
12
+ return /\/obj\/|\/bin\/|\/wwwroot\/|\/_Imports\.razor$/.test(filePath);
13
+ }
14
+
15
+ function parsePageRoutes(text) {
16
+ return [...String(text || "").matchAll(/@page\s+"([^"]+)"/g)].map((match) => match[1]);
17
+ }
18
+
19
+ function screenIdFromFile(filePath) {
20
+ const base = filePath.split("/").pop()?.replace(/\.razor(?:\.cs)?$/i, "") || "screen";
21
+ if (/^List$/i.test(base)) return "catalog_item_list";
22
+ if (/^Create$/i.test(base)) return "catalog_item_create";
23
+ if (/^Edit$/i.test(base)) return "catalog_item_edit";
24
+ if (/^Delete$/i.test(base)) return "catalog_item_delete";
25
+ if (/^Details$/i.test(base)) return "catalog_item_detail";
26
+ if (/^Logout$/i.test(base)) return "account_logout";
27
+ return idHintify(canonicalCandidateTerm(base.replace(/([a-z0-9])([A-Z])/g, "$1_$2")));
28
+ }
29
+
30
+ function screenKindFromId(screenId) {
31
+ if (/list/.test(screenId)) return "list";
32
+ if (/detail/.test(screenId)) return "detail";
33
+ if (/create|edit|delete/.test(screenId)) return "form";
34
+ if (/logout|login|account/.test(screenId)) return "auth";
35
+ return "flow";
36
+ }
37
+
38
+ function conceptIdFromScreenId(screenId) {
39
+ if (/catalog_item/.test(screenId)) return "surface_catalog_item";
40
+ if (/account|logout/.test(screenId)) return "surface_account";
41
+ return `surface_${screenId}`;
42
+ }
43
+
44
+ function entityIdFromScreenId(screenId) {
45
+ if (/catalog_item/.test(screenId)) return "entity_catalog-item";
46
+ return null;
47
+ }
48
+
49
+ function routePathForScreen(screenId, explicitRoutes) {
50
+ if (explicitRoutes.length > 0) return explicitRoutes[0];
51
+ if (screenId === "catalog_item_create") return "/admin/catalog-items/create";
52
+ if (screenId === "catalog_item_edit") return "/admin/catalog-items/:id/edit";
53
+ if (screenId === "catalog_item_delete") return "/admin/catalog-items/:id/delete";
54
+ if (screenId === "catalog_item_detail") return "/admin/catalog-items/:id";
55
+ if (screenId === "catalog_item_list") return "/admin";
56
+ if (screenId === "account_logout") return "/logout";
57
+ return `/${screenId.replace(/_/g, "-")}`;
58
+ }
59
+
60
+ function capabilityHintsForText(text) {
61
+ const source = String(text || "");
62
+ const hints = [];
63
+ if (/\bCatalogItemService\.List\s*\(/.test(source)) hints.push("cap_list_catalog_items");
64
+ if (/\bCatalogItemService\.GetById\s*\(/.test(source)) hints.push("cap_get_catalog_item");
65
+ if (/\bCatalogItemService\.Create\s*\(/.test(source)) hints.push("cap_create_catalog_item");
66
+ if (/\bCatalogItemService\.Edit\s*\(/.test(source)) hints.push("cap_update_catalog_item");
67
+ if (/\bCatalogItemService\.Delete\s*\(/.test(source)) hints.push("cap_delete_catalog_item");
68
+ if (/\bPostAsync\(\s*"User\/Logout"/.test(source) || /\bRouteOutside\(\s*"\/Identity\/Account\/Login"/.test(source)) {
69
+ hints.push("cap_sign_out_account");
70
+ }
71
+ return [...new Set(hints)];
72
+ }
73
+
74
+ function combinedComponentText(context, filePath, markupText) {
75
+ const codeBehindPath = `${filePath}.cs`;
76
+ const codeBehindText = context.helpers.readTextIfExists(codeBehindPath) || "";
77
+ return `${markupText || ""}\n${codeBehindText}`;
78
+ }
79
+
80
+ function blazorLayoutSummary(text) {
81
+ const source = String(text || "");
82
+ return {
83
+ shellKind:
84
+ /<AuthorizeRouteView\b/.test(source) ? "authenticated_app"
85
+ : /<Router\b/.test(source) ? "topbar"
86
+ : null,
87
+ patterns: [
88
+ ...new Set([
89
+ /<Router\b/.test(source) ? "route_table" : null,
90
+ /<AuthorizeRouteView\b/.test(source) ? "authenticated_routes" : null,
91
+ /<CascadingAuthenticationState\b/.test(source) ? "auth_state" : null
92
+ ].filter(Boolean))
93
+ ]
94
+ };
95
+ }
96
+
97
+ export const blazorUiExtractor = {
98
+ id: "ui.blazor",
99
+ track: "ui",
100
+ detect(context) {
101
+ const razorFiles = findImportFiles(context.paths, (filePath) => /\.razor$/i.test(filePath))
102
+ .filter((filePath) => !shouldIgnoreFile(filePath));
103
+ const score = razorFiles.length > 0 ? 86 : 0;
104
+ return {
105
+ score,
106
+ reasons: score > 0 ? ["Found Blazor .razor components and pages"] : []
107
+ };
108
+ },
109
+ extract(context) {
110
+ const razorFiles = findImportFiles(context.paths, (filePath) => /\.razor$/i.test(filePath))
111
+ .filter((filePath) => !shouldIgnoreFile(filePath));
112
+ const findings = [];
113
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
114
+
115
+ for (const filePath of razorFiles) {
116
+ const text = context.helpers.readTextIfExists(filePath) || "";
117
+ const combinedText = combinedComponentText(context, filePath, text);
118
+ const relativePath = relativeTo(context.paths.repoRoot, filePath);
119
+ const explicitRoutes = parsePageRoutes(text);
120
+ const baseName = filePath.split("/").pop() || "";
121
+ const isShell = /\/App\.razor$/.test(filePath);
122
+ const isComponent = /\/Pages\/|\/Shared\//.test(filePath);
123
+ if (!isShell && !isComponent) continue;
124
+
125
+ if (isShell) {
126
+ const summary = blazorLayoutSummary(text);
127
+ if (summary.shellKind) {
128
+ candidates.actions.push(makeCandidateRecord({
129
+ kind: "ui_shell",
130
+ idHint: `blazor_${idHintify(summary.shellKind)}_shell`,
131
+ label: titleCase(summary.shellKind),
132
+ confidence: "medium",
133
+ sourceKind: "layout_code",
134
+ provenance: relativePath,
135
+ track: "ui",
136
+ shell_kind: summary.shellKind
137
+ }));
138
+ }
139
+ for (const pattern of summary.patterns) {
140
+ candidates.actions.push(makeCandidateRecord({
141
+ kind: "ui_navigation",
142
+ idHint: `blazor_${idHintify(pattern)}`,
143
+ label: pattern,
144
+ confidence: "medium",
145
+ sourceKind: "layout_code",
146
+ provenance: relativePath,
147
+ track: "ui",
148
+ navigation_pattern: pattern
149
+ }));
150
+ }
151
+ continue;
152
+ }
153
+
154
+ if (/^(MainLayout|NavMenu|RedirectToLogin|Spinner|Toast|CustomInputSelect)\.razor$/i.test(baseName)) continue;
155
+
156
+ const screenId = screenIdFromFile(filePath);
157
+ const conceptId = conceptIdFromScreenId(screenId);
158
+ const entityId = entityIdFromScreenId(screenId);
159
+ const routePath = routePathForScreen(screenId, explicitRoutes);
160
+ const provenance = relativePath;
161
+ const capabilityHints = capabilityHintsForText(combinedText);
162
+
163
+ candidates.screens.push(makeCandidateRecord({
164
+ kind: "screen",
165
+ idHint: screenId,
166
+ label: titleCase(screenId),
167
+ confidence: explicitRoutes.length > 0 ? "high" : "medium",
168
+ sourceKind: explicitRoutes.length > 0 ? "route_code" : "component_code",
169
+ provenance,
170
+ track: "ui",
171
+ entity_id: entityId,
172
+ concept_id: conceptId,
173
+ screen_kind: screenKindFromId(screenId),
174
+ route_path: routePath,
175
+ capability_hints: capabilityHints
176
+ }));
177
+
178
+ candidates.routes.push(makeCandidateRecord({
179
+ kind: "ui_route",
180
+ idHint: `${screenId}_route`,
181
+ label: routePath,
182
+ confidence: explicitRoutes.length > 0 ? "high" : "medium",
183
+ sourceKind: explicitRoutes.length > 0 ? "route_code" : "component_code",
184
+ provenance,
185
+ track: "ui",
186
+ screen_id: screenId,
187
+ entity_id: entityId,
188
+ concept_id: conceptId,
189
+ path: routePath
190
+ }));
191
+
192
+ for (const capabilityHint of capabilityHints) {
193
+ candidates.actions.push(makeCandidateRecord({
194
+ kind: "ui_action",
195
+ idHint: `${screenId}_${idHintify(capabilityHint)}`,
196
+ label: capabilityHint,
197
+ confidence: "medium",
198
+ sourceKind: "component_code",
199
+ provenance,
200
+ track: "ui",
201
+ screen_id: screenId,
202
+ entity_id: entityId,
203
+ concept_id: conceptId,
204
+ capability_hint: capabilityHint,
205
+ prominence: /create|update|delete|sign_out/.test(capabilityHint) ? "primary" : "secondary"
206
+ }));
207
+ }
208
+
209
+ findings.push({
210
+ kind: "blazor_component",
211
+ file: relativePath,
212
+ screen_id: screenId,
213
+ route_count: explicitRoutes.length
214
+ });
215
+ }
216
+
217
+ if (candidates.screens.length > 0) {
218
+ candidates.stacks.push("blazor");
219
+ }
220
+
221
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
222
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
223
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
224
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
225
+ return { findings, candidates };
226
+ }
227
+ };
@@ -0,0 +1,152 @@
1
+ import {
2
+ canonicalCandidateTerm,
3
+ dedupeCandidateRecords,
4
+ findImportFiles,
5
+ idHintify,
6
+ makeCandidateRecord,
7
+ relativeTo,
8
+ titleCase
9
+ } from "../../core/shared.js";
10
+
11
+ function featureStemFromPath(filePath) {
12
+ return canonicalCandidateTerm(filePath.match(/\/features\/([^/]+)\//)?.[1] || "item");
13
+ }
14
+
15
+ function inferScreenId(filePath) {
16
+ const fileStem = filePath.split("/").pop()?.replace(/\.dart$/, "") || "screen";
17
+ const normalized = idHintify(fileStem);
18
+ return normalized.replace(/_screen$/, "");
19
+ }
20
+
21
+ function inferScreenKind(screenId) {
22
+ if (/detail/.test(screenId)) return "detail";
23
+ if (/create|edit/.test(screenId)) return "form";
24
+ if (/list/.test(screenId)) return "list";
25
+ return "flow";
26
+ }
27
+
28
+ function inferRoutePath(featureStem, screenId) {
29
+ if (screenId === `${featureStem}_list`) return `/${featureStem}s`;
30
+ if (screenId === `create_${featureStem}`) return `/${featureStem}s/new`;
31
+ if (screenId === `${featureStem}_detail`) return `/${featureStem}s/:id`;
32
+ return `/${screenId.replace(/_/g, "-")}`;
33
+ }
34
+
35
+ function inferCapabilityHints(featureStem, screenId, text) {
36
+ const hints = new Set();
37
+ if (/refresh|get[A-Z][A-Za-z0-9_]*List|Fetched\(/.test(text) || /ListView\.builder/.test(text)) {
38
+ hints.add(`cap_list_${featureStem}s`);
39
+ }
40
+ if (/create[A-Z]|FloatingActionButton|note_add|Icons\.add/.test(text) || /Mode\.create/.test(text) || /Create[A-Z]/.test(screenId)) {
41
+ hints.add(`cap_create_${featureStem}`);
42
+ }
43
+ if (/update[A-Z]|Mode\.update|Icons\.edit/.test(text) || /edit/.test(screenId)) {
44
+ hints.add(`cap_update_${featureStem}`);
45
+ }
46
+ if (/delete[A-Z]|Icons\.delete|DeleteDialog/.test(text)) {
47
+ hints.add(`cap_delete_${featureStem}`);
48
+ }
49
+ if (/detail/.test(screenId) || /Navigator\.push/.test(text)) {
50
+ hints.add(`cap_list_${featureStem}s`);
51
+ }
52
+ return [...hints];
53
+ }
54
+
55
+ function parseScreenFile(filePath, text, repoRoot) {
56
+ const widgetMatch = String(text || "").match(/class\s+([A-Za-z_][A-Za-z0-9_]*)\s+extends\s+(?:StatefulWidget|StatelessWidget)/);
57
+ if (!widgetMatch) return null;
58
+ const featureStem = featureStemFromPath(filePath);
59
+ const screenId = inferScreenId(filePath);
60
+ const routePath = inferRoutePath(featureStem, screenId);
61
+ const entityId = `entity_${featureStem}`;
62
+ const provenance = `${relativeTo(repoRoot, filePath)}#${widgetMatch[1]}`;
63
+ const capabilityHints = inferCapabilityHints(featureStem, screenId, text);
64
+ return {
65
+ screen: makeCandidateRecord({
66
+ kind: "screen",
67
+ idHint: screenId,
68
+ label: titleCase(screenId),
69
+ confidence: "high",
70
+ sourceKind: "route_code",
71
+ provenance,
72
+ track: "ui",
73
+ entity_id: entityId,
74
+ concept_id: entityId,
75
+ screen_kind: inferScreenKind(screenId),
76
+ route_path: routePath,
77
+ capability_hints: capabilityHints
78
+ }),
79
+ route: makeCandidateRecord({
80
+ kind: "ui_route",
81
+ idHint: `${screenId}_route`,
82
+ label: routePath,
83
+ confidence: "high",
84
+ sourceKind: "route_code",
85
+ provenance,
86
+ track: "ui",
87
+ screen_id: screenId,
88
+ entity_id: entityId,
89
+ concept_id: entityId,
90
+ path: routePath
91
+ }),
92
+ actions: capabilityHints.map((capabilityHint) => makeCandidateRecord({
93
+ kind: "ui_action",
94
+ idHint: `${screenId}_${idHintify(capabilityHint)}`,
95
+ label: capabilityHint,
96
+ confidence: "medium",
97
+ sourceKind: "route_code",
98
+ provenance,
99
+ track: "ui",
100
+ screen_id: screenId,
101
+ entity_id: entityId,
102
+ concept_id: entityId,
103
+ capability_hint: capabilityHint,
104
+ prominence: "primary"
105
+ }))
106
+ };
107
+ }
108
+
109
+ export const flutterScreensUiExtractor = {
110
+ id: "ui.flutter-screens",
111
+ track: "ui",
112
+ detect(context) {
113
+ const files = findImportFiles(
114
+ context.paths,
115
+ (filePath) => /\/lib\/features\/.+\/presentation\/screens\/.+_screen\.dart$/i.test(filePath)
116
+ );
117
+ const score = files.length > 0 ? 84 : 0;
118
+ return {
119
+ score,
120
+ reasons: score > 0 ? ["Found Flutter feature presentation screens"] : []
121
+ };
122
+ },
123
+ extract(context) {
124
+ const files = findImportFiles(
125
+ context.paths,
126
+ (filePath) => /\/lib\/features\/.+\/presentation\/screens\/.+_screen\.dart$/i.test(filePath)
127
+ );
128
+ const findings = [];
129
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
130
+ for (const filePath of files) {
131
+ const text = context.helpers.readTextIfExists(filePath) || "";
132
+ const parsed = parseScreenFile(filePath, text, context.paths.repoRoot);
133
+ if (!parsed) continue;
134
+ findings.push({
135
+ kind: "flutter_screen",
136
+ file: relativeTo(context.paths.repoRoot, filePath),
137
+ screen_id: parsed.screen.id_hint
138
+ });
139
+ candidates.screens.push(parsed.screen);
140
+ candidates.routes.push(parsed.route);
141
+ candidates.actions.push(...parsed.actions);
142
+ }
143
+ if (candidates.screens.length > 0) {
144
+ candidates.stacks.push("flutter_material");
145
+ }
146
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
147
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
148
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
149
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
150
+ return { findings, candidates };
151
+ }
152
+ };
@@ -0,0 +1,135 @@
1
+ import {
2
+ canonicalCandidateTerm,
3
+ dedupeCandidateRecords,
4
+ findImportFiles,
5
+ idHintify,
6
+ makeCandidateRecord,
7
+ relativeTo,
8
+ titleCase
9
+ } from "../../core/shared.js";
10
+
11
+ function screenIdFromClass(className) {
12
+ return idHintify(canonicalCandidateTerm(className.replace(/Page$/, "").replace(/([a-z0-9])([A-Z])/g, "$1_$2")));
13
+ }
14
+
15
+ function entityIdFromScreen(screenId) {
16
+ if (/^todo_(item|list)$/.test(screenId)) return "entity_todo-item";
17
+ if (/main/.test(screenId)) return "entity_item";
18
+ return `entity_${canonicalCandidateTerm(screenId)}`;
19
+ }
20
+
21
+ function parseShellContent(text) {
22
+ const screens = [];
23
+ for (const match of String(text || "").matchAll(/ShellContent[^>]*Title="([^"]+)"[^>]*ContentTemplate="\{DataTemplate\s+views:([A-Za-z_][A-Za-z0-9_]*)\}"[^>]*Route="([^"]+)"/g)) {
24
+ screens.push({
25
+ title: match[1],
26
+ pageClass: match[2],
27
+ route: match[3]
28
+ });
29
+ }
30
+ return screens;
31
+ }
32
+
33
+ function parseCommands(text) {
34
+ return [...String(text || "").matchAll(/Command="\{Binding\s+([A-Za-z_][A-Za-z0-9_]*)\}"/g)]
35
+ .map((entry) => entry[1]);
36
+ }
37
+
38
+ function parseClickedHandlers(text) {
39
+ return [...String(text || "").matchAll(/Clicked="([A-Za-z_][A-Za-z0-9_]*)"/g)]
40
+ .map((entry) => entry[1]);
41
+ }
42
+
43
+ function capabilityHintForHandler(screenId, handlerName) {
44
+ const normalized = String(handlerName || "").replace(/^On/, "").replace(/Clicked$|ButtonClicked$|SelectionChanged$/g, "").toLowerCase();
45
+ if (/save/.test(normalized)) return `cap_update_${canonicalCandidateTerm(screenId)}`;
46
+ if (/delete/.test(normalized)) return `cap_delete_${canonicalCandidateTerm(screenId)}`;
47
+ if (/add/.test(normalized)) return `cap_create_${canonicalCandidateTerm(screenId)}`;
48
+ if (/selection/.test(normalized)) return `cap_get_${canonicalCandidateTerm(screenId)}`;
49
+ if (/cancel/.test(normalized)) return null;
50
+ return `cap_${idHintify(normalized)}_${canonicalCandidateTerm(screenId)}`;
51
+ }
52
+
53
+ export const mauiXamlUiExtractor = {
54
+ id: "ui.maui-xaml",
55
+ track: "ui",
56
+ detect(context) {
57
+ const xamlFiles = findImportFiles(context.paths, (filePath) => /\.xaml$/i.test(filePath));
58
+ const score = xamlFiles.some((filePath) => /ContentPage|Shell/.test(context.helpers.readTextIfExists(filePath) || "")) ? 82 : 0;
59
+ return {
60
+ score,
61
+ reasons: score > 0 ? ["Found .NET MAUI XAML views and shell content"] : []
62
+ };
63
+ },
64
+ extract(context) {
65
+ const shellFiles = findImportFiles(context.paths, (filePath) => /AppShell\.xaml$/i.test(filePath));
66
+ const viewFiles = findImportFiles(context.paths, (filePath) => /\/Views\/.+\.xaml$/i.test(filePath));
67
+ const findings = [];
68
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
69
+ const shellEntries = shellFiles.flatMap((filePath) => parseShellContent(context.helpers.readTextIfExists(filePath) || ""));
70
+ const shellByPage = new Map(shellEntries.map((entry) => [entry.pageClass, entry]));
71
+
72
+ for (const filePath of viewFiles) {
73
+ const text = context.helpers.readTextIfExists(filePath) || "";
74
+ const className = text.match(/x:Class="[^"]+\.([A-Za-z_][A-Za-z0-9_]*)"/)?.[1] || filePath.split("/").pop()?.replace(/\.xaml$/, "") || "page";
75
+ const shellEntry = shellByPage.get(className);
76
+ const screenId = screenIdFromClass(className);
77
+ const routePath = shellEntry ? `/${shellEntry.route.replace(/^\/+/, "")}` : `/${screenId.replace(/_/g, "-")}`;
78
+ const provenance = `${relativeTo(context.paths.repoRoot, filePath)}#${className}`;
79
+ const entityId = entityIdFromScreen(screenId);
80
+ candidates.screens.push(makeCandidateRecord({
81
+ kind: "screen",
82
+ idHint: screenId,
83
+ label: shellEntry?.title || titleCase(screenId),
84
+ confidence: "high",
85
+ sourceKind: "route_code",
86
+ provenance,
87
+ track: "ui",
88
+ entity_id: entityId,
89
+ concept_id: entityId,
90
+ screen_kind: "flow",
91
+ route_path: routePath
92
+ }));
93
+ candidates.routes.push(makeCandidateRecord({
94
+ kind: "ui_route",
95
+ idHint: `${screenId}_route`,
96
+ label: routePath,
97
+ confidence: "high",
98
+ sourceKind: "route_code",
99
+ provenance,
100
+ track: "ui",
101
+ screen_id: screenId,
102
+ entity_id: entityId,
103
+ concept_id: entityId,
104
+ path: routePath
105
+ }));
106
+ for (const commandName of [...parseCommands(text), ...parseClickedHandlers(text)]) {
107
+ const capabilityHint = capabilityHintForHandler(screenId, commandName);
108
+ candidates.actions.push(makeCandidateRecord({
109
+ kind: "ui_action",
110
+ idHint: `${screenId}_${idHintify(commandName)}`,
111
+ label: commandName,
112
+ confidence: "medium",
113
+ sourceKind: "route_code",
114
+ provenance,
115
+ track: "ui",
116
+ screen_id: screenId,
117
+ entity_id: entityId,
118
+ concept_id: entityId,
119
+ capability_hint: capabilityHint,
120
+ prominence: "primary"
121
+ }));
122
+ }
123
+ findings.push({ kind: "maui_xaml_view", file: relativeTo(context.paths.repoRoot, filePath), screen_id: screenId });
124
+ }
125
+
126
+ if (candidates.screens.length > 0) {
127
+ candidates.stacks.push("maui_xaml");
128
+ }
129
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
130
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
131
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
132
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
133
+ return { findings, candidates };
134
+ }
135
+ };
@@ -0,0 +1,83 @@
1
+ import { dedupeCandidateRecords, inferNextAppRoutes, makeCandidateRecord, nextScreenIdForRoute, nextScreenKindForRoute, uiCapabilityHintsForNextRoute, entityIdForNextRoute, conceptIdForNextRoute, relativeTo, titleCase, idHintify } from "../../core/shared.js";
2
+
3
+ export const nextAppRouterUiExtractor = {
4
+ id: "ui.next-app-router",
5
+ track: "ui",
6
+ detect(context) {
7
+ const routes = inferNextAppRoutes(context.paths.workspaceRoot, context.helpers);
8
+ return {
9
+ score: routes.length > 0 ? 100 : 0,
10
+ reasons: routes.length > 0 ? ["Found Next.js App Router pages"] : []
11
+ };
12
+ },
13
+ extract(context) {
14
+ const routes = inferNextAppRoutes(context.paths.workspaceRoot, context.helpers);
15
+ const findings = [];
16
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
17
+ if (routes.length > 0) {
18
+ findings.push({
19
+ kind: "next_app_routes",
20
+ file: relativeTo(context.paths.repoRoot, `${context.paths.workspaceRoot}/app`),
21
+ routes: routes.map((route) => route.path)
22
+ });
23
+ candidates.stacks.push("next_app_router");
24
+ for (const route of routes) {
25
+ if (route.kind !== "page") continue;
26
+ const provenance = `${relativeTo(context.paths.repoRoot, route.file)}#${route.path}`;
27
+ const screenId = nextScreenIdForRoute(route.path);
28
+ const screenKind = nextScreenKindForRoute(route.path);
29
+ const capabilityHints = uiCapabilityHintsForNextRoute(route.path);
30
+ const entityId = entityIdForNextRoute(route.path);
31
+ const conceptId = conceptIdForNextRoute(route.path);
32
+ candidates.screens.push(makeCandidateRecord({
33
+ kind: "screen",
34
+ idHint: screenId,
35
+ label: titleCase(screenId),
36
+ confidence: "medium",
37
+ sourceKind: "route_code",
38
+ provenance,
39
+ track: "ui",
40
+ entity_id: entityId,
41
+ concept_id: conceptId,
42
+ screen_kind: screenKind,
43
+ route_path: route.path,
44
+ capability_hints: capabilityHints
45
+ }));
46
+ candidates.routes.push(makeCandidateRecord({
47
+ kind: "ui_route",
48
+ idHint: `${screenId}_route`,
49
+ label: route.path,
50
+ confidence: "medium",
51
+ sourceKind: "route_code",
52
+ provenance,
53
+ track: "ui",
54
+ screen_id: screenId,
55
+ entity_id: entityId,
56
+ concept_id: conceptId,
57
+ path: route.path
58
+ }));
59
+ if (capabilityHints.primary_action) {
60
+ candidates.actions.push(makeCandidateRecord({
61
+ kind: "ui_action",
62
+ idHint: `${screenId}_${idHintify(capabilityHints.primary_action)}`,
63
+ label: capabilityHints.primary_action,
64
+ confidence: "low",
65
+ sourceKind: "route_code",
66
+ provenance,
67
+ track: "ui",
68
+ screen_id: screenId,
69
+ entity_id: entityId,
70
+ concept_id: conceptId,
71
+ capability_hint: capabilityHints.primary_action,
72
+ prominence: screenKind === "list" ? "primary" : "secondary"
73
+ }));
74
+ }
75
+ }
76
+ }
77
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
78
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
79
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
80
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
81
+ return { findings, candidates };
82
+ }
83
+ };