@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,166 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
catalogEntryPackageSpec,
|
|
7
|
+
catalogSourceOrDefault,
|
|
8
|
+
findCatalogEntry,
|
|
9
|
+
isCatalogSourceDisabled,
|
|
10
|
+
loadCatalog
|
|
11
|
+
} from "../catalog.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {unknown} error
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
function messageFromError(error) {
|
|
18
|
+
return error instanceof Error ? error.message : String(error);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} templateName
|
|
23
|
+
* @param {string|null} [source]
|
|
24
|
+
* @returns {{ templateName: string, provenance: { id: string, source: string, package: string, version: string, packageSpec: string }|null }}
|
|
25
|
+
*/
|
|
26
|
+
export function resolveCatalogTemplateAlias(templateName, source = null) {
|
|
27
|
+
if (!isCatalogAliasCandidate(templateName)) {
|
|
28
|
+
return { templateName, provenance: null };
|
|
29
|
+
}
|
|
30
|
+
const catalogSource = catalogSourceOrDefault(source);
|
|
31
|
+
if (isCatalogSourceDisabled(catalogSource)) {
|
|
32
|
+
throw new Error(formatCatalogTemplateAliasError(templateName, catalogSource, null));
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const loaded = loadCatalog(catalogSource);
|
|
36
|
+
const entry = findCatalogEntry(loaded.catalog, templateName, "template");
|
|
37
|
+
if (!entry) {
|
|
38
|
+
throw new Error(formatCatalogTemplateAliasError(templateName, loaded.source, null, {
|
|
39
|
+
suggestions: suggestCatalogTemplateIds(loaded.catalog, templateName)
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
const packageSpec = catalogEntryPackageSpec(entry);
|
|
43
|
+
return {
|
|
44
|
+
templateName: packageSpec,
|
|
45
|
+
provenance: {
|
|
46
|
+
id: entry.id,
|
|
47
|
+
source: loaded.source,
|
|
48
|
+
package: entry.package,
|
|
49
|
+
version: entry.defaultVersion,
|
|
50
|
+
packageSpec
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const message = messageFromError(error);
|
|
55
|
+
if (message.startsWith(`Catalog template alias '${templateName}'`)) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
throw new Error(formatCatalogTemplateAliasError(templateName, catalogSource, error));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} templateName
|
|
64
|
+
* @returns {boolean}
|
|
65
|
+
*/
|
|
66
|
+
export function isCatalogAliasCandidate(templateName) {
|
|
67
|
+
return Boolean(templateName) &&
|
|
68
|
+
!templateName.startsWith("@") &&
|
|
69
|
+
!templateName.startsWith("./") &&
|
|
70
|
+
!templateName.startsWith("../") &&
|
|
71
|
+
!path.isAbsolute(templateName) &&
|
|
72
|
+
!templateName.includes("/") &&
|
|
73
|
+
!templateName.endsWith(".tgz");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} templateName
|
|
78
|
+
* @param {string|null} catalogSource
|
|
79
|
+
* @param {unknown} error
|
|
80
|
+
* @param {{ suggestions?: string[] }} [options]
|
|
81
|
+
* @returns {string}
|
|
82
|
+
*/
|
|
83
|
+
export function formatCatalogTemplateAliasError(templateName, catalogSource, error, options = {}) {
|
|
84
|
+
const sourceLabel = catalogSource || "disabled catalog";
|
|
85
|
+
const catalogDisabled = isCatalogSourceDisabled(catalogSource);
|
|
86
|
+
const suggestions = Array.isArray(options.suggestions) ? options.suggestions.filter(Boolean).slice(0, 3) : [];
|
|
87
|
+
const reason = error
|
|
88
|
+
? messageFromError(error)
|
|
89
|
+
: catalogDisabled
|
|
90
|
+
? "Catalog access is disabled, so catalog template aliases cannot be resolved."
|
|
91
|
+
: `No template entry named '${templateName}' was found in the catalog.`;
|
|
92
|
+
return [
|
|
93
|
+
`Catalog template alias '${templateName}' could not be resolved from '${sourceLabel}'.`,
|
|
94
|
+
reason,
|
|
95
|
+
templateName === "hello-web" ? "The default starter 'hello-web' is catalog-backed. Enable catalog access, or pass --template with a local path or full package spec." : null,
|
|
96
|
+
suggestions.length > 0 ? `Suggested templates: ${suggestions.join(", ")}.` : null,
|
|
97
|
+
catalogDisabled ? "Unset TOPOGRAM_CATALOG_SOURCE=none, pass --catalog <source>, or use an explicit local path/package spec." : null,
|
|
98
|
+
"Run `topogram template list` to see available templates, or `topogram catalog show <id>` to inspect a catalog alias.",
|
|
99
|
+
catalogDisabled ? null : "The default catalog is public. For private catalogs, set GITHUB_TOKEN or GH_TOKEN with repository read access, or run `gh auth login`.",
|
|
100
|
+
"For private template packages, configure registry-specific npm auth before installing.",
|
|
101
|
+
"Use a catalog alias such as hello-web/web-api/web-api-db, a local path, or a full package spec such as @topogram/template-todo@0.1.6."
|
|
102
|
+
].filter(Boolean).join("\n");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {{ entries: Array<Record<string, any>> }} catalog
|
|
107
|
+
* @param {string} templateName
|
|
108
|
+
* @returns {string[]}
|
|
109
|
+
*/
|
|
110
|
+
function suggestCatalogTemplateIds(catalog, templateName) {
|
|
111
|
+
const queryTokens = tokenizeSuggestionText(templateName);
|
|
112
|
+
const templates = (catalog.entries || []).filter((entry) => entry.kind === "template");
|
|
113
|
+
return templates
|
|
114
|
+
.map((entry, index) => ({
|
|
115
|
+
id: String(entry.id || ""),
|
|
116
|
+
index,
|
|
117
|
+
score: catalogTemplateSuggestionScore(entry, queryTokens)
|
|
118
|
+
}))
|
|
119
|
+
.filter((item) => item.id && item.score > 0)
|
|
120
|
+
.sort((left, right) => right.score - left.score || left.index - right.index)
|
|
121
|
+
.slice(0, 3)
|
|
122
|
+
.map((item) => item.id);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {Record<string, any>} entry
|
|
127
|
+
* @param {string[]} queryTokens
|
|
128
|
+
* @returns {number}
|
|
129
|
+
*/
|
|
130
|
+
function catalogTemplateSuggestionScore(entry, queryTokens) {
|
|
131
|
+
const id = String(entry.id || "");
|
|
132
|
+
if (queryTokens.length === 0) {
|
|
133
|
+
return id === "hello-web" ? 10 : 1;
|
|
134
|
+
}
|
|
135
|
+
const haystack = tokenizeSuggestionText([
|
|
136
|
+
entry.id,
|
|
137
|
+
entry.description,
|
|
138
|
+
entry.stack,
|
|
139
|
+
...(Array.isArray(entry.tags) ? entry.tags : []),
|
|
140
|
+
...(Array.isArray(entry.surfaces) ? entry.surfaces : []),
|
|
141
|
+
...(Array.isArray(entry.generators) ? entry.generators : [])
|
|
142
|
+
].filter(Boolean).join(" "));
|
|
143
|
+
let score = 0;
|
|
144
|
+
for (const token of queryTokens) {
|
|
145
|
+
if (haystack.includes(token)) {
|
|
146
|
+
score += 10;
|
|
147
|
+
} else if (haystack.some((candidate) => candidate.includes(token) || token.includes(candidate))) {
|
|
148
|
+
score += 3;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (id === "hello-web") {
|
|
152
|
+
score += 1;
|
|
153
|
+
}
|
|
154
|
+
return score;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {string} value
|
|
159
|
+
* @returns {string[]}
|
|
160
|
+
*/
|
|
161
|
+
function tokenizeSuggestionText(value) {
|
|
162
|
+
return String(value || "")
|
|
163
|
+
.toLowerCase()
|
|
164
|
+
.split(/[^a-z0-9]+/)
|
|
165
|
+
.filter(Boolean);
|
|
166
|
+
}
|