@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.
- package/ARCHITECTURE.md +67 -0
- package/CHANGELOG.md +240 -0
- package/README.md +223 -0
- package/package.json +51 -0
- package/src/adoption/index.js +3 -0
- package/src/adoption/plan.js +702 -0
- package/src/adoption/reporting.js +464 -0
- package/src/adoption/review-groups.js +313 -0
- package/src/agent-ops/query-builders.js +5012 -0
- package/src/archive/archive.js +141 -0
- package/src/archive/compact.js +26 -0
- package/src/archive/jsonl.js +70 -0
- package/src/archive/resolver-bridge.js +82 -0
- package/src/archive/schema.js +87 -0
- package/src/archive/unarchive.js +108 -0
- package/src/catalog.js +752 -0
- package/src/cli/catalog-alias.js +166 -0
- package/src/cli.js +9738 -0
- package/src/component-behavior.js +173 -0
- package/src/example-implementation.js +91 -0
- package/src/format.js +19 -0
- package/src/generator/adapters.d.ts +4 -0
- package/src/generator/adapters.js +325 -0
- package/src/generator/api.d.ts +1 -0
- package/src/generator/api.js +1196 -0
- package/src/generator/check.js +355 -0
- package/src/generator/component-conformance.js +767 -0
- package/src/generator/components.js +39 -0
- package/src/generator/context/bundle.js +291 -0
- package/src/generator/context/diff.js +256 -0
- package/src/generator/context/digest.js +182 -0
- package/src/generator/context/domain-coverage.js +94 -0
- package/src/generator/context/domain-page.js +137 -0
- package/src/generator/context/index.js +42 -0
- package/src/generator/context/report.js +121 -0
- package/src/generator/context/shared.js +1397 -0
- package/src/generator/context/slice.js +703 -0
- package/src/generator/context/task-mode.js +466 -0
- package/src/generator/docs.js +327 -0
- package/src/generator/index.js +161 -0
- package/src/generator/native/parity-bundle.js +311 -0
- package/src/generator/output.js +300 -0
- package/src/generator/registry.js +482 -0
- package/src/generator/runtime/app-bundle.js +456 -0
- package/src/generator/runtime/bundle-shared.js +166 -0
- package/src/generator/runtime/compile-check.js +163 -0
- package/src/generator/runtime/deployment.js +287 -0
- package/src/generator/runtime/environment.js +635 -0
- package/src/generator/runtime/index.js +32 -0
- package/src/generator/runtime/runtime-check.js +554 -0
- package/src/generator/runtime/shared.js +515 -0
- package/src/generator/runtime/smoke.js +219 -0
- package/src/generator/schema.js +204 -0
- package/src/generator/sdlc/board.js +66 -0
- package/src/generator/sdlc/doc-page.js +53 -0
- package/src/generator/sdlc/index.js +23 -0
- package/src/generator/sdlc/release-notes.js +62 -0
- package/src/generator/sdlc/traceability-matrix.js +65 -0
- package/src/generator/shared.js +29 -0
- package/src/generator/surfaces/contracts.js +146 -0
- package/src/generator/surfaces/databases/contract.js +40 -0
- package/src/generator/surfaces/databases/index.js +84 -0
- package/src/generator/surfaces/databases/lifecycle-shared.d.ts +1 -0
- package/src/generator/surfaces/databases/lifecycle-shared.js +612 -0
- package/src/generator/surfaces/databases/migration-plan.js +281 -0
- package/src/generator/surfaces/databases/postgres/capabilities.js +14 -0
- package/src/generator/surfaces/databases/postgres/drizzle.js +99 -0
- package/src/generator/surfaces/databases/postgres/index.js +9 -0
- package/src/generator/surfaces/databases/postgres/lifecycle.js +16 -0
- package/src/generator/surfaces/databases/postgres/prisma.js +159 -0
- package/src/generator/surfaces/databases/postgres/sql-migration.js +102 -0
- package/src/generator/surfaces/databases/postgres/sql-schema.js +34 -0
- package/src/generator/surfaces/databases/shared.d.ts +1 -0
- package/src/generator/surfaces/databases/shared.js +350 -0
- package/src/generator/surfaces/databases/snapshot.js +96 -0
- package/src/generator/surfaces/databases/sqlite/capabilities.js +14 -0
- package/src/generator/surfaces/databases/sqlite/index.js +8 -0
- package/src/generator/surfaces/databases/sqlite/lifecycle.js +16 -0
- package/src/generator/surfaces/databases/sqlite/prisma.js +143 -0
- package/src/generator/surfaces/databases/sqlite/sql-migration.js +65 -0
- package/src/generator/surfaces/databases/sqlite/sql-schema.js +27 -0
- package/src/generator/surfaces/index.js +25 -0
- package/src/generator/surfaces/native/swiftui-app.js +38 -0
- package/src/generator/surfaces/native/swiftui-templates/Package.swift.txt +20 -0
- package/src/generator/surfaces/native/swiftui-templates/README.generated.md +26 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/DynamicScreens.swift +682 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/TodoAPIClient.swift +156 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/TodoSwiftUIApp.swift +44 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/Visibility.swift +183 -0
- package/src/generator/surfaces/services/express.d.ts +1 -0
- package/src/generator/surfaces/services/express.js +766 -0
- package/src/generator/surfaces/services/hono.d.ts +1 -0
- package/src/generator/surfaces/services/hono.js +204 -0
- package/src/generator/surfaces/services/index.js +42 -0
- package/src/generator/surfaces/services/persistence-wiring.js +240 -0
- package/src/generator/surfaces/services/runtime-helpers.js +631 -0
- package/src/generator/surfaces/services/server-contract.js +80 -0
- package/src/generator/surfaces/services/stateless.d.ts +1 -0
- package/src/generator/surfaces/services/stateless.js +97 -0
- package/src/generator/surfaces/shared.js +64 -0
- package/src/generator/surfaces/web/api-client.js +1 -0
- package/src/generator/surfaces/web/forms.js +1 -0
- package/src/generator/surfaces/web/index.d.ts +2 -0
- package/src/generator/surfaces/web/index.js +53 -0
- package/src/generator/surfaces/web/react-components.js +248 -0
- package/src/generator/surfaces/web/react.js +538 -0
- package/src/generator/surfaces/web/routes.js +1 -0
- package/src/generator/surfaces/web/screens.js +1 -0
- package/src/generator/surfaces/web/shared.js +369 -0
- package/src/generator/surfaces/web/sveltekit-actions.js +28 -0
- package/src/generator/surfaces/web/sveltekit-components.js +234 -0
- package/src/generator/surfaces/web/sveltekit.js +426 -0
- package/src/generator/surfaces/web/ui-web-contract.js +65 -0
- package/src/generator/surfaces/web/vanilla.js +239 -0
- package/src/generator/verification.js +84 -0
- package/src/generator.js +1 -0
- package/src/import/core/context.js +52 -0
- package/src/import/core/contracts.js +23 -0
- package/src/import/core/registry.js +81 -0
- package/src/import/core/runner.js +646 -0
- package/src/import/core/shared.js +910 -0
- package/src/import/enrichers/auth-session.js +18 -0
- package/src/import/enrichers/django-rest.js +226 -0
- package/src/import/enrichers/doc-linking.js +20 -0
- package/src/import/enrichers/rails-controllers.js +246 -0
- package/src/import/enrichers/rails-models.js +130 -0
- package/src/import/enrichers/workflow-target-state.js +10 -0
- package/src/import/extractors/api/aspnet-core.js +304 -0
- package/src/import/extractors/api/django-routes.js +318 -0
- package/src/import/extractors/api/express.js +154 -0
- package/src/import/extractors/api/fastify.js +371 -0
- package/src/import/extractors/api/flutter-dio.js +135 -0
- package/src/import/extractors/api/generic-route-fallback.js +90 -0
- package/src/import/extractors/api/graphql-code-first.js +565 -0
- package/src/import/extractors/api/graphql-sdl.js +309 -0
- package/src/import/extractors/api/jaxrs.js +303 -0
- package/src/import/extractors/api/micronaut.js +213 -0
- package/src/import/extractors/api/next-route.js +50 -0
- package/src/import/extractors/api/next-server-action.js +51 -0
- package/src/import/extractors/api/nextauth.js +52 -0
- package/src/import/extractors/api/openapi-code.js +242 -0
- package/src/import/extractors/api/openapi.js +232 -0
- package/src/import/extractors/api/rails-routes.js +230 -0
- package/src/import/extractors/api/react-native-repository.js +128 -0
- package/src/import/extractors/api/retrofit.js +103 -0
- package/src/import/extractors/api/spring-web.js +372 -0
- package/src/import/extractors/api/swift-webapi.js +116 -0
- package/src/import/extractors/api/trpc.js +212 -0
- package/src/import/extractors/db/django-models.js +232 -0
- package/src/import/extractors/db/dotnet-models.js +93 -0
- package/src/import/extractors/db/drizzle.js +242 -0
- package/src/import/extractors/db/ef-core.js +221 -0
- package/src/import/extractors/db/flutter-entities.js +120 -0
- package/src/import/extractors/db/jpa.js +120 -0
- package/src/import/extractors/db/liquibase.js +180 -0
- package/src/import/extractors/db/mybatis-xml.js +145 -0
- package/src/import/extractors/db/prisma.js +185 -0
- package/src/import/extractors/db/rails-schema.js +175 -0
- package/src/import/extractors/db/react-native-entities.js +95 -0
- package/src/import/extractors/db/room.js +193 -0
- package/src/import/extractors/db/snapshot.js +112 -0
- package/src/import/extractors/db/sql.js +180 -0
- package/src/import/extractors/db/swiftdata.js +137 -0
- package/src/import/extractors/ui/android-compose.js +230 -0
- package/src/import/extractors/ui/backend-only.js +70 -0
- package/src/import/extractors/ui/blazor.js +227 -0
- package/src/import/extractors/ui/flutter-screens.js +152 -0
- package/src/import/extractors/ui/maui-xaml.js +135 -0
- package/src/import/extractors/ui/next-app-router.js +83 -0
- package/src/import/extractors/ui/next-pages-router.js +141 -0
- package/src/import/extractors/ui/razor-pages.js +181 -0
- package/src/import/extractors/ui/react-native-screens.js +166 -0
- package/src/import/extractors/ui/react-router.js +139 -0
- package/src/import/extractors/ui/sveltekit.js +123 -0
- package/src/import/extractors/ui/swiftui.js +193 -0
- package/src/import/extractors/ui/uikit.js +175 -0
- package/src/import/extractors/verification/generic.js +290 -0
- package/src/import/extractors/workflows/generic.js +137 -0
- package/src/import/index.js +7 -0
- package/src/import/provenance.js +158 -0
- package/src/new-project.js +2107 -0
- package/src/parser.js +439 -0
- package/src/policy/review-boundaries.js +165 -0
- package/src/project-config.js +535 -0
- package/src/proofs/backend-parity.js +19 -0
- package/src/proofs/contract-audit.js +220 -0
- package/src/proofs/ios-parity.js +7 -0
- package/src/proofs/issues-parity.js +10 -0
- package/src/proofs/web-parity.js +50 -0
- package/src/realization/api/build-api-realization.js +5 -0
- package/src/realization/api/index.js +1 -0
- package/src/realization/backend/build-backend-runtime-realization.js +82 -0
- package/src/realization/backend/index.d.ts +1 -0
- package/src/realization/backend/index.js +4 -0
- package/src/realization/db/build-db-realization.js +17 -0
- package/src/realization/db/index.js +3 -0
- package/src/realization/db/migration-plan.js +5 -0
- package/src/realization/db/snapshot.js +5 -0
- package/src/realization/ui/build-ui-shared-realization.js +305 -0
- package/src/realization/ui/build-web-realization.js +189 -0
- package/src/realization/ui/index.js +2 -0
- package/src/reconcile/docs.js +280 -0
- package/src/reconcile/index.js +3 -0
- package/src/reconcile/journeys.js +441 -0
- package/src/resolver/docs.js +1 -0
- package/src/resolver/enrich/acceptance-criterion.js +14 -0
- package/src/resolver/enrich/bug.js +12 -0
- package/src/resolver/enrich/component.js +2 -0
- package/src/resolver/enrich/index.js +1 -0
- package/src/resolver/enrich/pitch.js +18 -0
- package/src/resolver/enrich/requirement.js +20 -0
- package/src/resolver/enrich/task.js +16 -0
- package/src/resolver/expressions.js +1 -0
- package/src/resolver/index.js +2422 -0
- package/src/resolver/normalize.js +1 -0
- package/src/resolver.js +1 -0
- package/src/sdlc/adopt.js +65 -0
- package/src/sdlc/check.js +86 -0
- package/src/sdlc/dod/acceptance-criterion.js +22 -0
- package/src/sdlc/dod/bug.js +26 -0
- package/src/sdlc/dod/document.js +23 -0
- package/src/sdlc/dod/index.js +25 -0
- package/src/sdlc/dod/pitch.js +23 -0
- package/src/sdlc/dod/requirement.js +34 -0
- package/src/sdlc/dod/task.js +39 -0
- package/src/sdlc/explain.js +116 -0
- package/src/sdlc/history.js +80 -0
- package/src/sdlc/paths.js +11 -0
- package/src/sdlc/release.js +106 -0
- package/src/sdlc/scaffold.js +89 -0
- package/src/sdlc/status-filter.js +54 -0
- package/src/sdlc/transition.js +112 -0
- package/src/sdlc/transitions/acceptance-criterion.js +28 -0
- package/src/sdlc/transitions/bug.js +31 -0
- package/src/sdlc/transitions/document.js +29 -0
- package/src/sdlc/transitions/index.js +56 -0
- package/src/sdlc/transitions/pitch.js +34 -0
- package/src/sdlc/transitions/requirement.js +31 -0
- package/src/sdlc/transitions/task.js +34 -0
- package/src/template-trust.js +597 -0
- package/src/validator/expressions.js +1 -0
- package/src/validator/index.js +3424 -0
- package/src/validator/kinds.js +346 -0
- package/src/validator/per-kind/acceptance-criterion.js +91 -0
- package/src/validator/per-kind/bug.js +77 -0
- package/src/validator/per-kind/component.js +274 -0
- package/src/validator/per-kind/domain.js +205 -0
- package/src/validator/per-kind/pitch.js +101 -0
- package/src/validator/per-kind/requirement.js +75 -0
- package/src/validator/per-kind/task.js +96 -0
- package/src/validator/registry.js +1 -0
- package/src/validator/utils.js +12 -0
- package/src/validator.js +1 -0
- package/src/workflows.js +7597 -0
- package/src/workspace-docs.js +265 -0
- package/template-helpers/react.js +5 -0
- package/template-helpers/sveltekit.js +5 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dedupeCandidateRecords,
|
|
3
|
+
detectUiPresentationFeatures,
|
|
4
|
+
entityIdForRoute,
|
|
5
|
+
inferNavigationStructure,
|
|
6
|
+
inferSvelteRoutes,
|
|
7
|
+
makeCandidateRecord,
|
|
8
|
+
navigationPatternsFromStructure,
|
|
9
|
+
relativeTo,
|
|
10
|
+
shellKindFromNavigation,
|
|
11
|
+
screenIdForRoute,
|
|
12
|
+
screenKindForRoute,
|
|
13
|
+
uiCapabilityHintsForRoute,
|
|
14
|
+
titleCase
|
|
15
|
+
} from "../../core/shared.js";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
|
|
18
|
+
export const svelteKitUiExtractor = {
|
|
19
|
+
id: "ui.sveltekit",
|
|
20
|
+
track: "ui",
|
|
21
|
+
detect(context) {
|
|
22
|
+
const roots = [
|
|
23
|
+
path.join(context.paths.workspaceRoot, "apps", "web-sveltekit"),
|
|
24
|
+
path.join(context.paths.workspaceRoot, "apps", "local-stack", "web")
|
|
25
|
+
];
|
|
26
|
+
const count = roots.reduce((total, rootDir) => total + inferSvelteRoutes(rootDir, context.helpers).length, 0);
|
|
27
|
+
return { score: count > 0 ? 65 : 0, reasons: count > 0 ? ["Found SvelteKit routes"] : [] };
|
|
28
|
+
},
|
|
29
|
+
extract(context) {
|
|
30
|
+
const findings = [];
|
|
31
|
+
const candidates = { screens: [], routes: [], actions: [], stacks: [] };
|
|
32
|
+
const roots = [
|
|
33
|
+
path.join(context.paths.workspaceRoot, "apps", "web-sveltekit"),
|
|
34
|
+
path.join(context.paths.workspaceRoot, "apps", "local-stack", "web")
|
|
35
|
+
];
|
|
36
|
+
for (const rootDir of roots) {
|
|
37
|
+
const routes = inferSvelteRoutes(rootDir, context.helpers);
|
|
38
|
+
if (routes.length === 0) continue;
|
|
39
|
+
const provenance = relativeTo(context.paths.repoRoot, path.join(rootDir, "src", "routes"));
|
|
40
|
+
const navigation = inferNavigationStructure(rootDir, { filePatterns: [/(^|\/)\+layout\.svelte$/i] });
|
|
41
|
+
const features = detectUiPresentationFeatures(rootDir);
|
|
42
|
+
const shellKind = shellKindFromNavigation(navigation);
|
|
43
|
+
const navigationPatterns = navigationPatternsFromStructure(navigation);
|
|
44
|
+
findings.push({ kind: "sveltekit_ui_routes", file: provenance, routes });
|
|
45
|
+
findings.push({ kind: "sveltekit_ui_navigation", file: provenance, navigation });
|
|
46
|
+
findings.push({ kind: "sveltekit_ui_features", file: provenance, features });
|
|
47
|
+
candidates.stacks.push("sveltekit_web");
|
|
48
|
+
if (shellKind) {
|
|
49
|
+
candidates.actions.push(makeCandidateRecord({
|
|
50
|
+
kind: "ui_shell",
|
|
51
|
+
idHint: `${path.basename(rootDir)}_shell`,
|
|
52
|
+
label: titleCase(shellKind),
|
|
53
|
+
confidence: "medium",
|
|
54
|
+
sourceKind: "layout_code",
|
|
55
|
+
provenance,
|
|
56
|
+
track: "ui",
|
|
57
|
+
shell_kind: shellKind,
|
|
58
|
+
has_breadcrumbs: navigation.hasBreadcrumbs,
|
|
59
|
+
has_tabs: navigation.hasTabs
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
for (const pattern of navigationPatterns) {
|
|
63
|
+
candidates.actions.push(makeCandidateRecord({
|
|
64
|
+
kind: "ui_navigation",
|
|
65
|
+
idHint: `${path.basename(rootDir)}_${pattern}`,
|
|
66
|
+
label: pattern,
|
|
67
|
+
confidence: "medium",
|
|
68
|
+
sourceKind: "layout_code",
|
|
69
|
+
provenance,
|
|
70
|
+
track: "ui",
|
|
71
|
+
navigation_pattern: pattern
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
for (const routePath of routes) {
|
|
75
|
+
const screenId = screenIdForRoute(routePath);
|
|
76
|
+
const screenKind = screenKindForRoute(routePath);
|
|
77
|
+
const capabilityHints = uiCapabilityHintsForRoute(routePath);
|
|
78
|
+
candidates.screens.push(makeCandidateRecord({
|
|
79
|
+
kind: "screen",
|
|
80
|
+
idHint: screenId,
|
|
81
|
+
label: titleCase(screenId),
|
|
82
|
+
confidence: "medium",
|
|
83
|
+
sourceKind: "route_code",
|
|
84
|
+
provenance: `${provenance}#${routePath}`,
|
|
85
|
+
track: "ui",
|
|
86
|
+
entity_id: entityIdForRoute(routePath),
|
|
87
|
+
screen_kind: screenKind,
|
|
88
|
+
route_path: routePath,
|
|
89
|
+
capability_hints: capabilityHints
|
|
90
|
+
}));
|
|
91
|
+
candidates.routes.push(makeCandidateRecord({
|
|
92
|
+
kind: "ui_route",
|
|
93
|
+
idHint: `${screenId}_route`,
|
|
94
|
+
label: routePath,
|
|
95
|
+
confidence: "medium",
|
|
96
|
+
sourceKind: "route_code",
|
|
97
|
+
provenance: `${provenance}#${routePath}`,
|
|
98
|
+
track: "ui",
|
|
99
|
+
screen_id: screenId,
|
|
100
|
+
entity_id: entityIdForRoute(routePath),
|
|
101
|
+
path: routePath
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
for (const feature of features) {
|
|
105
|
+
candidates.actions.push(makeCandidateRecord({
|
|
106
|
+
kind: "ui_presentation",
|
|
107
|
+
idHint: `${path.basename(rootDir)}_${feature}`,
|
|
108
|
+
label: feature,
|
|
109
|
+
confidence: "low",
|
|
110
|
+
sourceKind: "layout_code",
|
|
111
|
+
provenance,
|
|
112
|
+
track: "ui",
|
|
113
|
+
presentation: feature
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
|
|
118
|
+
candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
|
|
119
|
+
candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
|
|
120
|
+
candidates.stacks = [...new Set(candidates.stacks)].sort();
|
|
121
|
+
return { findings, candidates };
|
|
122
|
+
}
|
|
123
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalCandidateTerm,
|
|
3
|
+
dedupeCandidateRecords,
|
|
4
|
+
findImportFiles,
|
|
5
|
+
idHintify,
|
|
6
|
+
makeCandidateRecord,
|
|
7
|
+
relativeTo,
|
|
8
|
+
titleCase
|
|
9
|
+
} from "../../core/shared.js";
|
|
10
|
+
|
|
11
|
+
function inferScreenId(viewName) {
|
|
12
|
+
if (/CountriesList/i.test(viewName)) return "country_list";
|
|
13
|
+
if (/CountryDetails/i.test(viewName)) return "country_detail";
|
|
14
|
+
if (/ModalFlag/i.test(viewName)) return "country_flag_modal";
|
|
15
|
+
return idHintify(canonicalCandidateTerm(viewName.replace(/View$/, "").replace(/([a-z0-9])([A-Z])/g, "$1_$2")));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function inferRoutePath(screenId) {
|
|
19
|
+
if (screenId === "country_list") return "/countries";
|
|
20
|
+
if (screenId === "country_detail") return "/countries/:alpha3Code";
|
|
21
|
+
if (screenId === "country_flag_modal") return "/countries/:alpha3Code/flag";
|
|
22
|
+
return `/${screenId.replace(/_/g, "-")}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function entityIdForScreen(screenId) {
|
|
26
|
+
if (/country/.test(screenId)) return screenId === "country_detail" || screenId === "country_list" || screenId === "country_flag_modal" ? "entity_country" : "entity_country";
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseSwiftUIView(filePath, text, repoRoot) {
|
|
31
|
+
const views = [];
|
|
32
|
+
for (const match of String(text || "").matchAll(/struct\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*View\s*\{/g)) {
|
|
33
|
+
const viewName = match[1];
|
|
34
|
+
if (/^(ErrorView|ImageView|CountryCell|DetailRow)$/.test(viewName)) continue;
|
|
35
|
+
const screenId = inferScreenId(viewName);
|
|
36
|
+
const routePath = inferRoutePath(screenId);
|
|
37
|
+
const entityId = entityIdForScreen(screenId);
|
|
38
|
+
const provenance = `${relativeTo(repoRoot, filePath)}#${viewName}`;
|
|
39
|
+
const capabilityHints = [];
|
|
40
|
+
if (/loadCountriesList|refreshCountriesList/.test(text)) capabilityHints.push("cap_list_countries");
|
|
41
|
+
if (/loadCountryDetails/.test(text)) capabilityHints.push("cap_get_country_details");
|
|
42
|
+
views.push({
|
|
43
|
+
screen: makeCandidateRecord({
|
|
44
|
+
kind: "screen",
|
|
45
|
+
idHint: screenId,
|
|
46
|
+
label: titleCase(screenId),
|
|
47
|
+
confidence: "high",
|
|
48
|
+
sourceKind: "route_code",
|
|
49
|
+
provenance,
|
|
50
|
+
track: "ui",
|
|
51
|
+
entity_id: entityId,
|
|
52
|
+
concept_id: entityId || `surface_${screenId}`,
|
|
53
|
+
screen_kind: /detail/.test(screenId) ? "detail" : /modal/.test(screenId) ? "flow" : "list",
|
|
54
|
+
route_path: routePath,
|
|
55
|
+
capability_hints: capabilityHints
|
|
56
|
+
}),
|
|
57
|
+
route: makeCandidateRecord({
|
|
58
|
+
kind: "ui_route",
|
|
59
|
+
idHint: `${screenId}_route`,
|
|
60
|
+
label: routePath,
|
|
61
|
+
confidence: "high",
|
|
62
|
+
sourceKind: "route_code",
|
|
63
|
+
provenance,
|
|
64
|
+
track: "ui",
|
|
65
|
+
screen_id: screenId,
|
|
66
|
+
entity_id: entityId,
|
|
67
|
+
concept_id: entityId || `surface_${screenId}`,
|
|
68
|
+
path: routePath
|
|
69
|
+
}),
|
|
70
|
+
actions: capabilityHints.map((capabilityHint) => makeCandidateRecord({
|
|
71
|
+
kind: "ui_action",
|
|
72
|
+
idHint: `${screenId}_${idHintify(capabilityHint)}`,
|
|
73
|
+
label: capabilityHint,
|
|
74
|
+
confidence: "medium",
|
|
75
|
+
sourceKind: "route_code",
|
|
76
|
+
provenance,
|
|
77
|
+
track: "ui",
|
|
78
|
+
screen_id: screenId,
|
|
79
|
+
entity_id: entityId,
|
|
80
|
+
concept_id: entityId || `surface_${screenId}`,
|
|
81
|
+
capability_hint: capabilityHint,
|
|
82
|
+
prominence: "primary"
|
|
83
|
+
}))
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return views;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function swiftUiNavigationSummary(text) {
|
|
90
|
+
const source = String(text || "");
|
|
91
|
+
return {
|
|
92
|
+
shellKind:
|
|
93
|
+
/\bNavigationSplitView\b/.test(source) ? "split_view"
|
|
94
|
+
: /\bTabView\b/.test(source) ? "bottom_tabs"
|
|
95
|
+
: /\bNavigationStack\b|\bNavigationView\b/.test(source) ? "topbar"
|
|
96
|
+
: null,
|
|
97
|
+
patterns: [
|
|
98
|
+
...new Set([
|
|
99
|
+
/\bNavigationStack\b|\bNavigationView\b/.test(source) ? "stack_navigation" : null,
|
|
100
|
+
/\bTabView\b/.test(source) ? "bottom_tabs" : null,
|
|
101
|
+
/\bNavigationSplitView\b/.test(source) ? "split_view" : null,
|
|
102
|
+
/\bPicker\b|\bSegmentedPickerStyle\b/.test(source) ? "segmented_control" : null
|
|
103
|
+
].filter(Boolean))
|
|
104
|
+
],
|
|
105
|
+
features: [
|
|
106
|
+
...new Set([
|
|
107
|
+
/\.sheet\s*\(/.test(source) ? "sheet" : null,
|
|
108
|
+
/\.popover\s*\(/.test(source) ? "popover" : null,
|
|
109
|
+
/\.refreshable\s*\{/.test(source) ? "pull_to_refresh" : null,
|
|
110
|
+
/\.searchable\s*\(/.test(source) ? "search" : null
|
|
111
|
+
].filter(Boolean))
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const swiftUiExtractor = {
|
|
117
|
+
id: "ui.swiftui",
|
|
118
|
+
track: "ui",
|
|
119
|
+
detect(context) {
|
|
120
|
+
const files = findImportFiles(context.paths, (filePath) => /\.swift$/i.test(filePath))
|
|
121
|
+
.filter((filePath) => /:\s*View\b/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
122
|
+
return {
|
|
123
|
+
score: files.length > 0 ? 84 : 0,
|
|
124
|
+
reasons: files.length > 0 ? ["Found SwiftUI views"] : []
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
extract(context) {
|
|
128
|
+
const files = findImportFiles(context.paths, (filePath) => /\.swift$/i.test(filePath))
|
|
129
|
+
.filter((filePath) => /:\s*View\b/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
130
|
+
const findings = [];
|
|
131
|
+
const candidates = { screens: [], routes: [], actions: [], stacks: [] };
|
|
132
|
+
for (const filePath of files) {
|
|
133
|
+
const text = context.helpers.readTextIfExists(filePath) || "";
|
|
134
|
+
const parsed = parseSwiftUIView(filePath, text, context.paths.repoRoot);
|
|
135
|
+
if (parsed.length === 0) continue;
|
|
136
|
+
const summary = swiftUiNavigationSummary(text);
|
|
137
|
+
findings.push({
|
|
138
|
+
kind: "swiftui_views",
|
|
139
|
+
file: relativeTo(context.paths.repoRoot, filePath),
|
|
140
|
+
screen_count: parsed.length
|
|
141
|
+
});
|
|
142
|
+
if (summary.shellKind) {
|
|
143
|
+
candidates.actions.push(makeCandidateRecord({
|
|
144
|
+
kind: "ui_shell",
|
|
145
|
+
idHint: `${idHintify(summary.shellKind)}_shell`,
|
|
146
|
+
label: titleCase(summary.shellKind),
|
|
147
|
+
confidence: "medium",
|
|
148
|
+
sourceKind: "layout_code",
|
|
149
|
+
provenance: relativeTo(context.paths.repoRoot, filePath),
|
|
150
|
+
track: "ui",
|
|
151
|
+
shell_kind: summary.shellKind
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
for (const pattern of summary.patterns) {
|
|
155
|
+
candidates.actions.push(makeCandidateRecord({
|
|
156
|
+
kind: "ui_navigation",
|
|
157
|
+
idHint: `swiftui_${idHintify(pattern)}`,
|
|
158
|
+
label: pattern,
|
|
159
|
+
confidence: "medium",
|
|
160
|
+
sourceKind: "layout_code",
|
|
161
|
+
provenance: relativeTo(context.paths.repoRoot, filePath),
|
|
162
|
+
track: "ui",
|
|
163
|
+
navigation_pattern: pattern
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
for (const feature of summary.features) {
|
|
167
|
+
candidates.actions.push(makeCandidateRecord({
|
|
168
|
+
kind: "ui_presentation",
|
|
169
|
+
idHint: `swiftui_${idHintify(feature)}`,
|
|
170
|
+
label: feature,
|
|
171
|
+
confidence: "low",
|
|
172
|
+
sourceKind: "layout_code",
|
|
173
|
+
provenance: relativeTo(context.paths.repoRoot, filePath),
|
|
174
|
+
track: "ui",
|
|
175
|
+
presentation: feature
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
for (const entry of parsed) {
|
|
179
|
+
candidates.screens.push(entry.screen);
|
|
180
|
+
candidates.routes.push(entry.route);
|
|
181
|
+
candidates.actions.push(...entry.actions);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (candidates.screens.length > 0) {
|
|
185
|
+
candidates.stacks.push("swiftui");
|
|
186
|
+
}
|
|
187
|
+
candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
|
|
188
|
+
candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
|
|
189
|
+
candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
|
|
190
|
+
candidates.stacks = [...new Set(candidates.stacks)].sort();
|
|
191
|
+
return { findings, candidates };
|
|
192
|
+
}
|
|
193
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalCandidateTerm,
|
|
3
|
+
dedupeCandidateRecords,
|
|
4
|
+
findImportFiles,
|
|
5
|
+
idHintify,
|
|
6
|
+
makeCandidateRecord,
|
|
7
|
+
relativeTo,
|
|
8
|
+
titleCase
|
|
9
|
+
} from "../../core/shared.js";
|
|
10
|
+
|
|
11
|
+
function screenIdFromController(className) {
|
|
12
|
+
return idHintify(
|
|
13
|
+
canonicalCandidateTerm(
|
|
14
|
+
className
|
|
15
|
+
.replace(/(Table|Collection)?ViewController$/, "")
|
|
16
|
+
.replace(/ViewController$/, "")
|
|
17
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function screenKindFromClass(className, screenId) {
|
|
23
|
+
if (/TableViewController$/.test(className) || /CollectionViewController$/.test(className)) return "list";
|
|
24
|
+
if (/Settings|Onboarding|Theme|Search/i.test(className) || /settings|onboarding|theme|search/.test(screenId)) return "settings";
|
|
25
|
+
if (/Browser|Home/i.test(className) || /browser|home/.test(screenId)) return "flow";
|
|
26
|
+
if (/About|Tip|TrackingProtection|SiriFavorite/i.test(className)) return "detail";
|
|
27
|
+
return "flow";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function conceptIdFromScreen(screenId) {
|
|
31
|
+
if (/browser|home/.test(screenId)) return "surface_browser";
|
|
32
|
+
if (/^setting$|settings|theme|about|search|tracking_protection|autocomplete|safari_instruction|siri_favorite|add_custom_domain|add_search_engine/.test(screenId)) {
|
|
33
|
+
return "surface_settings";
|
|
34
|
+
}
|
|
35
|
+
if (/onboarding|default_browser|show_me_how|get_started|tooltip|terms_of_service|privacy_policy/.test(screenId)) return "surface_onboarding";
|
|
36
|
+
return `surface_${screenId}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function routePathFromScreen(screenId) {
|
|
40
|
+
if (screenId === "browser") return "/browser";
|
|
41
|
+
if (screenId === "home") return "/";
|
|
42
|
+
return `/${screenId.replace(/_/g, "-")}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function navigationActions(text) {
|
|
46
|
+
const actions = [];
|
|
47
|
+
for (const match of String(text || "").matchAll(/pushViewController\(\s*([A-Z][A-Za-z0-9_]*)\(/g)) {
|
|
48
|
+
actions.push({ kind: "push", targetClass: match[1] });
|
|
49
|
+
}
|
|
50
|
+
for (const match of String(text || "").matchAll(/present\(\s*([A-Z][A-Za-z0-9_]*)\(/g)) {
|
|
51
|
+
actions.push({ kind: "present", targetClass: match[1] });
|
|
52
|
+
}
|
|
53
|
+
for (const match of String(text || "").matchAll(/show\(\s*([A-Z][A-Za-z0-9_]*)\(/g)) {
|
|
54
|
+
actions.push({ kind: "show", targetClass: match[1] });
|
|
55
|
+
}
|
|
56
|
+
return actions;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function shouldIgnoreFile(filePath) {
|
|
60
|
+
return /Tests\/|Preview Files\/|UIHelpers\/|Extensions\/|Widgets\/|InternalSettings\/.*View\.swift$/.test(filePath);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const uiKitExtractor = {
|
|
64
|
+
id: "ui.uikit",
|
|
65
|
+
track: "ui",
|
|
66
|
+
detect(context) {
|
|
67
|
+
const controllerFiles = findImportFiles(context.paths, (filePath) => /\.swift$/i.test(filePath))
|
|
68
|
+
.filter((filePath) => !shouldIgnoreFile(filePath))
|
|
69
|
+
.filter((filePath) => /(UIViewController|UITableViewController|UICollectionViewController)/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
70
|
+
return {
|
|
71
|
+
score: controllerFiles.length > 0 ? 87 : 0,
|
|
72
|
+
reasons: controllerFiles.length > 0 ? ["Found UIKit view controllers"] : []
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
extract(context) {
|
|
76
|
+
const controllerFiles = findImportFiles(context.paths, (filePath) => /\.swift$/i.test(filePath))
|
|
77
|
+
.filter((filePath) => !shouldIgnoreFile(filePath))
|
|
78
|
+
.filter((filePath) => /(UIViewController|UITableViewController|UICollectionViewController)/.test(context.helpers.readTextIfExists(filePath) || ""));
|
|
79
|
+
const findings = [];
|
|
80
|
+
const candidates = { screens: [], routes: [], actions: [], stacks: [] };
|
|
81
|
+
const classIndex = new Map();
|
|
82
|
+
|
|
83
|
+
for (const filePath of controllerFiles) {
|
|
84
|
+
const text = context.helpers.readTextIfExists(filePath) || "";
|
|
85
|
+
for (const match of text.matchAll(/(?:final\s+)?class\s+([A-Z][A-Za-z0-9_]*)\s*:\s*([A-Za-z0-9_, ]*(?:UIViewController|UITableViewController|UICollectionViewController)[A-Za-z0-9_, ]*)/g)) {
|
|
86
|
+
classIndex.set(match[1], { filePath, text, base: match[2] });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for (const [className, entry] of classIndex.entries()) {
|
|
91
|
+
const screenId = screenIdFromController(className);
|
|
92
|
+
const routePath = routePathFromScreen(screenId);
|
|
93
|
+
const conceptId = conceptIdFromScreen(screenId);
|
|
94
|
+
const provenance = `${relativeTo(context.paths.repoRoot, entry.filePath)}#${className}`;
|
|
95
|
+
candidates.screens.push(makeCandidateRecord({
|
|
96
|
+
kind: "screen",
|
|
97
|
+
idHint: screenId,
|
|
98
|
+
label: titleCase(screenId),
|
|
99
|
+
confidence: "high",
|
|
100
|
+
sourceKind: "route_code",
|
|
101
|
+
provenance,
|
|
102
|
+
track: "ui",
|
|
103
|
+
entity_id: null,
|
|
104
|
+
concept_id: conceptId,
|
|
105
|
+
screen_kind: screenKindFromClass(className, screenId),
|
|
106
|
+
route_path: routePath
|
|
107
|
+
}));
|
|
108
|
+
candidates.routes.push(makeCandidateRecord({
|
|
109
|
+
kind: "ui_route",
|
|
110
|
+
idHint: `${screenId}_route`,
|
|
111
|
+
label: routePath,
|
|
112
|
+
confidence: "high",
|
|
113
|
+
sourceKind: "route_code",
|
|
114
|
+
provenance,
|
|
115
|
+
track: "ui",
|
|
116
|
+
screen_id: screenId,
|
|
117
|
+
entity_id: null,
|
|
118
|
+
concept_id: conceptId,
|
|
119
|
+
path: routePath
|
|
120
|
+
}));
|
|
121
|
+
for (const action of navigationActions(entry.text)) {
|
|
122
|
+
const targetScreenId = screenIdFromController(action.targetClass);
|
|
123
|
+
candidates.actions.push(makeCandidateRecord({
|
|
124
|
+
kind: "ui_action",
|
|
125
|
+
idHint: `${screenId}_${action.kind}_${targetScreenId}`,
|
|
126
|
+
label: `${action.kind} ${targetScreenId}`,
|
|
127
|
+
confidence: "medium",
|
|
128
|
+
sourceKind: "route_code",
|
|
129
|
+
provenance,
|
|
130
|
+
track: "ui",
|
|
131
|
+
screen_id: screenId,
|
|
132
|
+
entity_id: null,
|
|
133
|
+
concept_id: conceptId,
|
|
134
|
+
capability_hint: null,
|
|
135
|
+
prominence: "primary"
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
findings.push({
|
|
139
|
+
kind: "uikit_controller",
|
|
140
|
+
file: relativeTo(context.paths.repoRoot, entry.filePath),
|
|
141
|
+
screen_id: screenId
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (candidates.screens.length > 0) {
|
|
146
|
+
candidates.actions.push(makeCandidateRecord({
|
|
147
|
+
kind: "ui_navigation",
|
|
148
|
+
idHint: "uikit_stack_navigation",
|
|
149
|
+
label: "stack_navigation",
|
|
150
|
+
confidence: "medium",
|
|
151
|
+
sourceKind: "layout_code",
|
|
152
|
+
provenance: controllerFiles.map((filePath) => relativeTo(context.paths.repoRoot, filePath)),
|
|
153
|
+
track: "ui",
|
|
154
|
+
navigation_pattern: "stack_navigation"
|
|
155
|
+
}));
|
|
156
|
+
candidates.actions.push(makeCandidateRecord({
|
|
157
|
+
kind: "ui_shell",
|
|
158
|
+
idHint: "uikit_navigation_shell",
|
|
159
|
+
label: "Navigation",
|
|
160
|
+
confidence: "medium",
|
|
161
|
+
sourceKind: "layout_code",
|
|
162
|
+
provenance: controllerFiles.map((filePath) => relativeTo(context.paths.repoRoot, filePath)),
|
|
163
|
+
track: "ui",
|
|
164
|
+
shell_kind: "topbar"
|
|
165
|
+
}));
|
|
166
|
+
candidates.stacks.push("uikit");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
candidates.screens = dedupeCandidateRecords(candidates.screens, (record) => record.id_hint);
|
|
170
|
+
candidates.routes = dedupeCandidateRecords(candidates.routes, (record) => record.id_hint);
|
|
171
|
+
candidates.actions = dedupeCandidateRecords(candidates.actions, (record) => record.id_hint);
|
|
172
|
+
candidates.stacks = [...new Set(candidates.stacks)].sort();
|
|
173
|
+
return { findings, candidates };
|
|
174
|
+
}
|
|
175
|
+
};
|