@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,141 @@
1
+ import path from "node:path";
2
+
3
+ import {
4
+ dedupeCandidateRecords,
5
+ findImportFiles,
6
+ makeCandidateRecord,
7
+ relativeTo,
8
+ titleCase,
9
+ idHintify
10
+ } from "../../core/shared.js";
11
+
12
+ function pagesRoutePath(pagesRoot, filePath) {
13
+ const relative = relativeTo(pagesRoot, filePath);
14
+ return `/${relative}`
15
+ .replace(/\.(tsx|ts|jsx|js|mdx)$/, "")
16
+ .replace(/\/index$/, "")
17
+ .replace(/\[(\.\.\.)?([^\]]+)\]/g, (_match, catchAll, name) => catchAll ? `:${name}*` : `:${name}`)
18
+ .replace(/^\/$/, "/") || "/";
19
+ }
20
+
21
+ function inferTrpcHooks(text) {
22
+ const hooks = [];
23
+ for (const match of String(text || "").matchAll(/trpc\.([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)\.use(Query|InfiniteQuery|Mutation)\b/g)) {
24
+ hooks.push({
25
+ router: match[1],
26
+ procedure: match[2],
27
+ hook: match[3]
28
+ });
29
+ }
30
+ return hooks;
31
+ }
32
+
33
+ function screenFromRouteAndHooks(routePath, hooks) {
34
+ const hasPostHooks = hooks.some((hook) => hook.router === "post");
35
+ if (routePath === "/" && hasPostHooks) return { id: "post_list", kind: "list", entity: "entity_post", concept: "entity_post" };
36
+ if (/^\/post\/:[^/]+$/.test(routePath) && hasPostHooks) return { id: "post_detail", kind: "detail", entity: "entity_post", concept: "entity_post" };
37
+ if (routePath === "/") return { id: "home", kind: "flow", entity: null, concept: "surface_home" };
38
+ const resource = routePath.split("/").filter(Boolean)[0] || "home";
39
+ const normalized = resource.replace(/[^a-zA-Z0-9]+/g, "_").toLowerCase();
40
+ const kind = /\/:[^/]+$/.test(routePath) ? "detail" : "list";
41
+ return {
42
+ id: kind === "detail" ? `${normalized}_detail` : `${normalized}_list`,
43
+ kind,
44
+ entity: normalized === "home" ? null : `entity_${normalized}`,
45
+ concept: normalized === "home" ? "surface_home" : `entity_${normalized}`
46
+ };
47
+ }
48
+
49
+ function capabilityHint(router, procedure) {
50
+ const resource = router.toLowerCase();
51
+ if (procedure === "list") return `cap_list_${resource}s`;
52
+ if (procedure === "byId") return `cap_get_${resource}`;
53
+ if (procedure === "add") return `cap_create_${resource}`;
54
+ return `cap_${idHintify(`${procedure}_${resource}`)}`;
55
+ }
56
+
57
+ export const nextPagesRouterUiExtractor = {
58
+ id: "ui.next-pages-router",
59
+ track: "ui",
60
+ detect(context) {
61
+ const pageFiles = findImportFiles(context.paths, (filePath) => /src\/pages\/.+\.(tsx|ts|jsx|js|mdx)$/i.test(filePath))
62
+ .filter((filePath) => !/\/api\//.test(filePath) && !/\/_(app|document|error)\./.test(filePath) && !/\/404\./.test(filePath));
63
+ return {
64
+ score: pageFiles.length > 0 ? 85 : 0,
65
+ reasons: pageFiles.length > 0 ? ["Found Next.js Pages Router pages"] : []
66
+ };
67
+ },
68
+ extract(context) {
69
+ const pagesRoot = path.join(context.paths.workspaceRoot, "src", "pages");
70
+ const pageFiles = findImportFiles(context.paths, (filePath) => /src\/pages\/.+\.(tsx|ts|jsx|js|mdx)$/i.test(filePath))
71
+ .filter((filePath) => !/\/api\//.test(filePath) && !/\/_(app|document|error)\./.test(filePath) && !/\/404\./.test(filePath));
72
+ const findings = [];
73
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
74
+ if (pageFiles.length > 0) {
75
+ const routes = [];
76
+ for (const filePath of pageFiles) {
77
+ const routePath = pagesRoutePath(pagesRoot, filePath);
78
+ const text = context.helpers.readTextIfExists(filePath) || "";
79
+ const hooks = inferTrpcHooks(text);
80
+ const screen = screenFromRouteAndHooks(routePath, hooks);
81
+ const provenance = `${relativeTo(context.paths.repoRoot, filePath)}#${routePath}`;
82
+ routes.push(routePath);
83
+ candidates.screens.push(makeCandidateRecord({
84
+ kind: "screen",
85
+ idHint: screen.id,
86
+ label: titleCase(screen.id),
87
+ confidence: "medium",
88
+ sourceKind: "route_code",
89
+ provenance,
90
+ track: "ui",
91
+ entity_id: screen.entity,
92
+ concept_id: screen.concept,
93
+ screen_kind: screen.kind,
94
+ route_path: routePath,
95
+ capability_hints: hooks.map((hook) => capabilityHint(hook.router, hook.procedure))
96
+ }));
97
+ candidates.routes.push(makeCandidateRecord({
98
+ kind: "ui_route",
99
+ idHint: `${screen.id}_route`,
100
+ label: routePath,
101
+ confidence: "medium",
102
+ sourceKind: "route_code",
103
+ provenance,
104
+ track: "ui",
105
+ screen_id: screen.id,
106
+ entity_id: screen.entity,
107
+ concept_id: screen.concept,
108
+ path: routePath
109
+ }));
110
+ for (const hook of hooks.filter((hook) => hook.hook === "Mutation")) {
111
+ const capability = capabilityHint(hook.router, hook.procedure);
112
+ candidates.actions.push(makeCandidateRecord({
113
+ kind: "ui_action",
114
+ idHint: `${screen.id}_${idHintify(capability)}`,
115
+ label: capability,
116
+ confidence: "medium",
117
+ sourceKind: "route_code",
118
+ provenance,
119
+ track: "ui",
120
+ screen_id: screen.id,
121
+ entity_id: screen.entity,
122
+ concept_id: screen.concept,
123
+ capability_hint: capability,
124
+ prominence: "primary"
125
+ }));
126
+ }
127
+ }
128
+ findings.push({
129
+ kind: "next_pages_routes",
130
+ file: relativeTo(context.paths.repoRoot, pagesRoot),
131
+ routes: [...new Set(routes)].sort()
132
+ });
133
+ candidates.stacks.push("next_pages_router");
134
+ }
135
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
136
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
137
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
138
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
139
+ return { findings, candidates };
140
+ }
141
+ };
@@ -0,0 +1,181 @@
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\/|\/_ViewImports\.cshtml$|\/_ViewStart\.cshtml$|\/Shared\/_|\/Views\/Shared\/|\/Pages\/Shared\/|\/_[^/]+\.cshtml$/.test(filePath);
13
+ }
14
+
15
+ function inferFromPath(repoRelativePath) {
16
+ const normalized = repoRelativePath.replace(/\\/g, "/");
17
+ if (/\/Pages\/Basket\/Index\.cshtml$/.test(normalized)) return { screenId: "basket", conceptId: "surface_basket", entityId: "entity_basket", routePath: "/basket", screenKind: "list" };
18
+ if (/\/Pages\/Basket\/Checkout\.cshtml$/.test(normalized)) return { screenId: "basket_checkout", conceptId: "surface_basket", entityId: "entity_basket", routePath: "/basket/checkout", screenKind: "form" };
19
+ if (/\/Pages\/Basket\/Success\.cshtml$/.test(normalized)) return { screenId: "basket_success", conceptId: "surface_basket", entityId: "entity_basket", routePath: "/basket/success", screenKind: "detail" };
20
+ if (/\/Pages\/Admin\/Index\.cshtml$/.test(normalized)) return { screenId: "catalog_item_admin", conceptId: "surface_catalog_item_admin", entityId: "entity_catalog-item", routePath: "/admin", screenKind: "list" };
21
+ if (/\/Pages\/Admin\/EditCatalogItem\.cshtml$/.test(normalized)) return { screenId: "catalog_item_admin_edit", conceptId: "surface_catalog_item_admin", entityId: "entity_catalog-item", routePath: "/admin/edit-catalog-item", screenKind: "form" };
22
+ if (/\/Pages\/Index\.cshtml$/.test(normalized)) return { screenId: "catalog_home", conceptId: "surface_catalog", entityId: "entity_item", routePath: "/", screenKind: "list" };
23
+ if (/\/Pages\/Privacy\.cshtml$/.test(normalized)) return { screenId: "privacy", conceptId: "surface_app", entityId: null, routePath: "/privacy", screenKind: "detail" };
24
+ if (/\/Pages\/Error\.cshtml$/.test(normalized)) return { screenId: "error", conceptId: "surface_app", entityId: null, routePath: "/error", screenKind: "detail" };
25
+ if (/\/Areas\/Identity\/Pages\/Account\/Login\.cshtml$/.test(normalized)) return { screenId: "account_login", conceptId: "surface_account", entityId: null, routePath: "/account/login", screenKind: "auth" };
26
+ if (/\/Areas\/Identity\/Pages\/Account\/Register\.cshtml$/.test(normalized)) return { screenId: "account_register", conceptId: "surface_account", entityId: null, routePath: "/account/register", screenKind: "auth" };
27
+ if (/\/Areas\/Identity\/Pages\/Account\/Logout\.cshtml$/.test(normalized)) return { screenId: "account_logout_page", conceptId: "surface_account", entityId: null, routePath: "/account/logout", screenKind: "auth" };
28
+ if (/\/Areas\/Identity\/Pages\/Account\/ConfirmEmail\.cshtml$/.test(normalized)) return { screenId: "account_confirm_email", conceptId: "surface_account", entityId: null, routePath: "/account/confirm-email", screenKind: "auth" };
29
+ if (/\/Views\/Account\//.test(normalized)) {
30
+ const base = normalized.split("/").pop()?.replace(/\.cshtml$/i, "") || "account";
31
+ const stem = idHintify(canonicalCandidateTerm(base.replace(/([a-z0-9])([A-Z])/g, "$1_$2")));
32
+ return { screenId: stem, conceptId: "surface_account", entityId: null, routePath: `/account/${stem.replace(/_/g, "-")}`, screenKind: "auth" };
33
+ }
34
+ if (/\/Views\/Order\/MyOrders\.cshtml$/.test(normalized)) return { screenId: "order_list", conceptId: "surface_order", entityId: "entity_order", routePath: "/order/my-orders", screenKind: "list" };
35
+ if (/\/Views\/Order\/Detail\.cshtml$/.test(normalized)) return { screenId: "order_detail", conceptId: "surface_order", entityId: "entity_order", routePath: "/order/detail", screenKind: "detail" };
36
+ if (/\/Views\/Manage\//.test(normalized)) {
37
+ const base = normalized.split("/").pop()?.replace(/\.cshtml$/i, "") || "manage";
38
+ const stem = idHintify(canonicalCandidateTerm(base.replace(/([a-z0-9])([A-Z])/g, "$1_$2")));
39
+ return { screenId: stem, conceptId: "surface_account", entityId: null, routePath: `/manage/${stem.replace(/_/g, "-")}`, screenKind: "settings" };
40
+ }
41
+
42
+ const base = normalized.split("/").pop()?.replace(/\.cshtml$/i, "") || "view";
43
+ const stem = idHintify(canonicalCandidateTerm(base.replace(/([a-z0-9])([A-Z])/g, "$1_$2")));
44
+ return {
45
+ screenId: stem,
46
+ conceptId: `surface_${stem}`,
47
+ entityId: null,
48
+ routePath: `/${stem.replace(/_/g, "-")}`,
49
+ screenKind: /login|register|logout|account/.test(stem) ? "auth" : /edit|checkout|change/.test(stem) ? "form" : "detail"
50
+ };
51
+ }
52
+
53
+ function routePathForPage(text, fallback) {
54
+ const match = String(text || "").match(/@page\s+"([^"]+)"/);
55
+ return match ? match[1] : fallback;
56
+ }
57
+
58
+ function capabilityHints(text, repoRelativePath, screenId) {
59
+ const source = String(text || "");
60
+ const hints = [];
61
+ if (/asp-page-handler="Update"|name="updatebutton"/.test(source)) hints.push("cap_update_basket");
62
+ if (/asp-page="\.\/Checkout"|Checkout/.test(source) && /basket/i.test(screenId)) hints.push("cap_checkout_basket");
63
+ if (/asp-controller="Order"\s+asp-action="Detail"|Order\/Detail/.test(source)) hints.push("cap_get_order");
64
+ if (/asp-controller="Order"\s+asp-action="cancel"/i.test(source)) hints.push("cap_cancel_order");
65
+ if (/method="post"/.test(source) && /login/i.test(repoRelativePath)) hints.push("cap_sign_in_account");
66
+ if (/method="post"/.test(source) && /register/i.test(repoRelativePath)) hints.push("cap_register_account");
67
+ if (/EditCatalogItem|asp-page="\/Admin\/EditCatalogItem"/.test(source)) hints.push("cap_update_catalog_item");
68
+ if (/Products|CatalogItem|ProductName/.test(source) && /catalog|admin/i.test(repoRelativePath)) hints.push("cap_list_catalog_items");
69
+ return [...new Set(hints)];
70
+ }
71
+
72
+ function shellPatterns(text) {
73
+ const source = String(text || "");
74
+ return [
75
+ /<form\b/.test(source) ? "form_post" : null,
76
+ /asp-page=|asp-controller=|asp-action=/.test(source) ? "server_navigation" : null
77
+ ].filter(Boolean);
78
+ }
79
+
80
+ export const razorPagesUiExtractor = {
81
+ id: "ui.razor-pages",
82
+ track: "ui",
83
+ detect(context) {
84
+ const files = findImportFiles(context.paths, (filePath) => /\.cshtml$/i.test(filePath))
85
+ .filter((filePath) => !shouldIgnoreFile(filePath));
86
+ const score = files.length > 0 ? 84 : 0;
87
+ return {
88
+ score,
89
+ reasons: score > 0 ? ["Found Razor Pages / MVC .cshtml views"] : []
90
+ };
91
+ },
92
+ extract(context) {
93
+ const files = findImportFiles(context.paths, (filePath) => /\.cshtml$/i.test(filePath))
94
+ .filter((filePath) => !shouldIgnoreFile(filePath));
95
+ const findings = [];
96
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
97
+
98
+ for (const filePath of files) {
99
+ const text = context.helpers.readTextIfExists(filePath) || "";
100
+ const repoRelativePath = relativeTo(context.paths.repoRoot, filePath);
101
+ const inferred = inferFromPath(repoRelativePath);
102
+ const routePath = routePathForPage(text, inferred.routePath);
103
+ const hints = capabilityHints(text, repoRelativePath, inferred.screenId);
104
+
105
+ candidates.screens.push(makeCandidateRecord({
106
+ kind: "screen",
107
+ idHint: inferred.screenId,
108
+ label: titleCase(inferred.screenId),
109
+ confidence: /@page|Views\//.test(repoRelativePath) ? "high" : "medium",
110
+ sourceKind: /@page/.test(text) ? "route_code" : "view_code",
111
+ provenance: repoRelativePath,
112
+ track: "ui",
113
+ entity_id: inferred.entityId,
114
+ concept_id: inferred.conceptId,
115
+ screen_kind: inferred.screenKind,
116
+ route_path: routePath,
117
+ capability_hints: hints
118
+ }));
119
+
120
+ candidates.routes.push(makeCandidateRecord({
121
+ kind: "ui_route",
122
+ idHint: `${inferred.screenId}_route`,
123
+ label: routePath,
124
+ confidence: /@page/.test(text) ? "high" : "medium",
125
+ sourceKind: /@page/.test(text) ? "route_code" : "view_code",
126
+ provenance: repoRelativePath,
127
+ track: "ui",
128
+ screen_id: inferred.screenId,
129
+ entity_id: inferred.entityId,
130
+ concept_id: inferred.conceptId,
131
+ path: routePath
132
+ }));
133
+
134
+ for (const hint of hints) {
135
+ candidates.actions.push(makeCandidateRecord({
136
+ kind: "ui_action",
137
+ idHint: `${inferred.screenId}_${idHintify(hint)}`,
138
+ label: hint,
139
+ confidence: "medium",
140
+ sourceKind: "view_code",
141
+ provenance: repoRelativePath,
142
+ track: "ui",
143
+ screen_id: inferred.screenId,
144
+ entity_id: inferred.entityId,
145
+ concept_id: inferred.conceptId,
146
+ capability_hint: hint,
147
+ prominence: /sign|register|checkout|cancel|update/.test(hint) ? "primary" : "secondary"
148
+ }));
149
+ }
150
+
151
+ for (const pattern of shellPatterns(text)) {
152
+ candidates.actions.push(makeCandidateRecord({
153
+ kind: "ui_navigation",
154
+ idHint: `razor_${idHintify(pattern)}`,
155
+ label: pattern,
156
+ confidence: "low",
157
+ sourceKind: "view_code",
158
+ provenance: repoRelativePath,
159
+ track: "ui",
160
+ navigation_pattern: pattern
161
+ }));
162
+ }
163
+
164
+ findings.push({
165
+ kind: "razor_view",
166
+ file: repoRelativePath,
167
+ screen_id: inferred.screenId
168
+ });
169
+ }
170
+
171
+ if (candidates.screens.length > 0) {
172
+ candidates.stacks.push("razor_pages");
173
+ }
174
+
175
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
176
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
177
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
178
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
179
+ return { findings, candidates };
180
+ }
181
+ };
@@ -0,0 +1,166 @@
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(/\/src\/([^/]+)\//)?.[1] || "item");
13
+ }
14
+
15
+ function inferScreenId(filePath) {
16
+ const fileStem = filePath.split("/").pop()?.replace(/\.tsx$/, "") || "screen";
17
+ const normalized = fileStem
18
+ .replace(/([a-z0-9])([A-Z])/g, "$1_$2")
19
+ .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2");
20
+ return idHintify(normalized)
21
+ .replace(/_screen$/, "")
22
+ .replace(/^posts$/, "post_list")
23
+ .replace(/^post$/, "post_detail");
24
+ }
25
+
26
+ function inferScreenKind(screenId) {
27
+ if (/detail$/.test(screenId)) return "detail";
28
+ if (/list$/.test(screenId)) return "list";
29
+ return "flow";
30
+ }
31
+
32
+ function inferRoutePath(featureStem, screenId) {
33
+ if (screenId === `${featureStem}s` || screenId === `${featureStem}_list`) {
34
+ return `/${featureStem}s`;
35
+ }
36
+ if (screenId === featureStem || screenId === `${featureStem}_detail`) {
37
+ return `/${featureStem}s/:id`;
38
+ }
39
+ return `/${screenId.replace(/_/g, "-")}`;
40
+ }
41
+
42
+ function parseNavigatorRoutes(text) {
43
+ const routes = new Map();
44
+ for (const match of String(text || "").matchAll(/<Stack\.Screen\s+name="([^"]+)"\s+component=\{([A-Za-z_][A-Za-z0-9_]*)\}\s*\/>/g)) {
45
+ routes.set(match[2], match[1]);
46
+ }
47
+ return routes;
48
+ }
49
+
50
+ function parseScreenFile(filePath, text, repoRoot, routeNamesByComponent) {
51
+ const componentMatch =
52
+ String(text || "").match(/export\s+default\s+function\s+([A-Za-z_][A-Za-z0-9_]*)/) ||
53
+ String(text || "").match(/const\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(?:observer\()?/);
54
+ if (!componentMatch) return null;
55
+ const componentName = componentMatch[1];
56
+ if (/NotFound/i.test(componentName)) return null;
57
+ const featureStem = featureStemFromPath(filePath);
58
+ const screenId = inferScreenId(filePath);
59
+ const routeName = routeNamesByComponent.get(componentName) || componentName.replace(/Screen$/, "");
60
+ const routePath =
61
+ routeName === "Posts" ? `/${featureStem}s`
62
+ : routeName === "Post" ? `/${featureStem}s/:id`
63
+ : inferRoutePath(featureStem, screenId);
64
+ const entityId = `entity_${featureStem}`;
65
+ const provenance = `${relativeTo(repoRoot, filePath)}#${componentName}`;
66
+ const capabilityHints = [];
67
+ if (/getPosts\(/.test(text) || /FlatList/.test(text)) {
68
+ capabilityHints.push(`cap_list_${featureStem}s`);
69
+ }
70
+ if (/findPost\(/.test(text) || /route\.params/.test(text)) {
71
+ capabilityHints.push(`cap_get_${featureStem}`);
72
+ }
73
+ return {
74
+ screen: makeCandidateRecord({
75
+ kind: "screen",
76
+ idHint: screenId,
77
+ label: titleCase(screenId),
78
+ confidence: "high",
79
+ sourceKind: "route_code",
80
+ provenance,
81
+ track: "ui",
82
+ entity_id: entityId,
83
+ concept_id: entityId,
84
+ screen_kind: inferScreenKind(screenId),
85
+ route_path: routePath,
86
+ capability_hints: capabilityHints
87
+ }),
88
+ route: makeCandidateRecord({
89
+ kind: "ui_route",
90
+ idHint: `${screenId}_route`,
91
+ label: routePath,
92
+ confidence: "high",
93
+ sourceKind: "route_code",
94
+ provenance,
95
+ track: "ui",
96
+ screen_id: screenId,
97
+ entity_id: entityId,
98
+ concept_id: entityId,
99
+ path: routePath
100
+ }),
101
+ actions: capabilityHints.map((capabilityHint) => makeCandidateRecord({
102
+ kind: "ui_action",
103
+ idHint: `${screenId}_${idHintify(capabilityHint)}`,
104
+ label: capabilityHint,
105
+ confidence: "medium",
106
+ sourceKind: "route_code",
107
+ provenance,
108
+ track: "ui",
109
+ screen_id: screenId,
110
+ entity_id: entityId,
111
+ concept_id: entityId,
112
+ capability_hint: capabilityHint,
113
+ prominence: "primary"
114
+ }))
115
+ };
116
+ }
117
+
118
+ export const reactNativeScreensExtractor = {
119
+ id: "ui.react-native-screens",
120
+ track: "ui",
121
+ detect(context) {
122
+ const files = findImportFiles(
123
+ context.paths,
124
+ (filePath) => /\/src\/.+\/presentation\/screens\/.+Screen\.tsx$/i.test(filePath)
125
+ );
126
+ const score = files.length > 0 ? 83 : 0;
127
+ return {
128
+ score,
129
+ reasons: score > 0 ? ["Found React Native presentation screens"] : []
130
+ };
131
+ },
132
+ extract(context) {
133
+ const screenFiles = findImportFiles(
134
+ context.paths,
135
+ (filePath) => /\/src\/.+\/presentation\/screens\/.+Screen\.tsx$/i.test(filePath)
136
+ );
137
+ const navigatorFile = findImportFiles(
138
+ context.paths,
139
+ (filePath) => /\/src\/core\/presentation\/navigation\/RootNavigator\.tsx$/i.test(filePath)
140
+ )[0];
141
+ const routeNamesByComponent = parseNavigatorRoutes(context.helpers.readTextIfExists(navigatorFile) || "");
142
+ const findings = [];
143
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
144
+ for (const filePath of screenFiles) {
145
+ const text = context.helpers.readTextIfExists(filePath) || "";
146
+ const parsed = parseScreenFile(filePath, text, context.paths.repoRoot, routeNamesByComponent);
147
+ if (!parsed) continue;
148
+ findings.push({
149
+ kind: "react_native_screen",
150
+ file: relativeTo(context.paths.repoRoot, filePath),
151
+ screen_id: parsed.screen.id_hint
152
+ });
153
+ candidates.screens.push(parsed.screen);
154
+ candidates.routes.push(parsed.route);
155
+ candidates.actions.push(...parsed.actions);
156
+ }
157
+ if (candidates.screens.length > 0) {
158
+ candidates.stacks.push("react_native");
159
+ }
160
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
161
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
162
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
163
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
164
+ return { findings, candidates };
165
+ }
166
+ };
@@ -0,0 +1,139 @@
1
+ import {
2
+ dedupeCandidateRecords,
3
+ detectUiPresentationFeatures,
4
+ entityIdForRoute,
5
+ inferNavigationStructure,
6
+ inferReactRoutes,
7
+ makeCandidateRecord,
8
+ navigationPatternsFromStructure,
9
+ relativeTo,
10
+ shellKindFromNavigation,
11
+ screenIdForRoute,
12
+ screenKindForRoute,
13
+ uiCapabilityHintsForRoute,
14
+ titleCase,
15
+ idHintify
16
+ } from "../../core/shared.js";
17
+ import path from "node:path";
18
+
19
+ export const reactRouterUiExtractor = {
20
+ id: "ui.react-router",
21
+ track: "ui",
22
+ detect(context) {
23
+ const roots = [
24
+ path.join(context.paths.workspaceRoot, "apps", "web"),
25
+ path.join(context.paths.workspaceRoot, "examples", "maintained", "proof-app")
26
+ ];
27
+ const count = roots.reduce((total, rootDir) => total + inferReactRoutes(rootDir, context.helpers).length, 0);
28
+ return { score: count > 0 ? 70 : 0, reasons: count > 0 ? ["Found React Router UI routes"] : [] };
29
+ },
30
+ extract(context) {
31
+ const findings = [];
32
+ const candidates = { screens: [], routes: [], actions: [], stacks: [] };
33
+ const roots = [
34
+ path.join(context.paths.workspaceRoot, "apps", "web"),
35
+ path.join(context.paths.workspaceRoot, "examples", "maintained", "proof-app")
36
+ ];
37
+ for (const rootDir of roots) {
38
+ const routes = inferReactRoutes(rootDir, context.helpers);
39
+ if (routes.length === 0) continue;
40
+ const provenance = relativeTo(context.paths.repoRoot, path.join(rootDir, "src", "App.tsx"));
41
+ const navigation = inferNavigationStructure(rootDir);
42
+ const features = detectUiPresentationFeatures(rootDir);
43
+ const shellKind = shellKindFromNavigation(navigation);
44
+ const navigationPatterns = navigationPatternsFromStructure(navigation);
45
+ findings.push({ kind: "react_ui_routes", file: provenance, routes });
46
+ findings.push({ kind: "react_ui_navigation", file: provenance, navigation });
47
+ findings.push({ kind: "react_ui_features", file: provenance, features });
48
+ candidates.stacks.push("react_web");
49
+ if (shellKind) {
50
+ candidates.actions.push(makeCandidateRecord({
51
+ kind: "ui_shell",
52
+ idHint: `${path.basename(rootDir)}_shell`,
53
+ label: titleCase(shellKind),
54
+ confidence: "medium",
55
+ sourceKind: "layout_code",
56
+ provenance,
57
+ track: "ui",
58
+ shell_kind: shellKind,
59
+ has_breadcrumbs: navigation.hasBreadcrumbs,
60
+ has_tabs: navigation.hasTabs
61
+ }));
62
+ }
63
+ for (const pattern of navigationPatterns) {
64
+ candidates.actions.push(makeCandidateRecord({
65
+ kind: "ui_navigation",
66
+ idHint: `${path.basename(rootDir)}_${idHintify(pattern)}`,
67
+ label: pattern,
68
+ confidence: "medium",
69
+ sourceKind: "layout_code",
70
+ provenance,
71
+ track: "ui",
72
+ navigation_pattern: pattern
73
+ }));
74
+ }
75
+ for (const routePath of routes) {
76
+ const screenId = screenIdForRoute(routePath);
77
+ const screenKind = screenKindForRoute(routePath);
78
+ const capabilityHints = uiCapabilityHintsForRoute(routePath);
79
+ candidates.screens.push(makeCandidateRecord({
80
+ kind: "screen",
81
+ idHint: screenId,
82
+ label: titleCase(screenId),
83
+ confidence: "medium",
84
+ sourceKind: "route_code",
85
+ provenance: `${provenance}#${routePath}`,
86
+ track: "ui",
87
+ entity_id: entityIdForRoute(routePath),
88
+ screen_kind: screenKind,
89
+ route_path: routePath,
90
+ capability_hints: capabilityHints
91
+ }));
92
+ candidates.routes.push(makeCandidateRecord({
93
+ kind: "ui_route",
94
+ idHint: `${screenId}_route`,
95
+ label: routePath,
96
+ confidence: "medium",
97
+ sourceKind: "route_code",
98
+ provenance: `${provenance}#${routePath}`,
99
+ track: "ui",
100
+ screen_id: screenId,
101
+ entity_id: entityIdForRoute(routePath),
102
+ path: routePath
103
+ }));
104
+ if (capabilityHints.primary_action) {
105
+ candidates.actions.push(makeCandidateRecord({
106
+ kind: "ui_action",
107
+ idHint: `${screenId}_${idHintify(capabilityHints.primary_action)}`,
108
+ label: capabilityHints.primary_action,
109
+ confidence: "low",
110
+ sourceKind: "route_code",
111
+ provenance: `${provenance}#${routePath}`,
112
+ track: "ui",
113
+ screen_id: screenId,
114
+ entity_id: entityIdForRoute(routePath),
115
+ capability_hint: capabilityHints.primary_action,
116
+ prominence: screenKind === "list" ? "primary" : "secondary"
117
+ }));
118
+ }
119
+ }
120
+ for (const feature of features) {
121
+ candidates.actions.push(makeCandidateRecord({
122
+ kind: "ui_presentation",
123
+ idHint: `${path.basename(rootDir)}_${idHintify(feature)}`,
124
+ label: feature,
125
+ confidence: "low",
126
+ sourceKind: "layout_code",
127
+ provenance,
128
+ track: "ui",
129
+ presentation: feature
130
+ }));
131
+ }
132
+ }
133
+ candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
134
+ candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
135
+ candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
136
+ candidates.stacks = [...new Set(candidates.stacks)].sort();
137
+ return { findings, candidates };
138
+ }
139
+ };