@topogram/cli 0.3.63 → 0.3.65
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/package.json +1 -1
- package/src/adoption/plan/index.js +703 -0
- package/src/adoption/plan.d.ts +6 -0
- package/src/adoption/plan.js +12 -703
- package/src/adoption/reporting.d.ts +10 -0
- package/src/adoption/review-groups.d.ts +6 -0
- package/src/agent-brief.d.ts +3 -0
- package/src/agent-brief.js +495 -0
- package/src/agent-ops/query-builders/auth.js +375 -0
- package/src/agent-ops/query-builders/change-risk/change-plan.js +123 -0
- package/src/agent-ops/query-builders/change-risk/import-plan.js +49 -0
- package/src/agent-ops/query-builders/change-risk/maintained.js +286 -0
- package/src/agent-ops/query-builders/change-risk/review-packets.js +123 -0
- package/src/agent-ops/query-builders/change-risk/risk.js +189 -0
- package/src/agent-ops/query-builders/change-risk.js +25 -0
- package/src/agent-ops/query-builders/common.js +149 -0
- package/src/agent-ops/query-builders/maintained-risk.js +539 -0
- package/src/agent-ops/query-builders/maintained-shared.js +120 -0
- package/src/agent-ops/query-builders/multi-agent.js +547 -0
- package/src/agent-ops/query-builders/projection-impacts.js +514 -0
- package/src/agent-ops/query-builders/work-packets.js +417 -0
- package/src/agent-ops/query-builders/workflow-context-shared.js +300 -0
- package/src/agent-ops/query-builders/workflow-context.js +398 -0
- package/src/agent-ops/query-builders/workflow-presets-core.js +676 -0
- package/src/agent-ops/query-builders/workflow-presets.js +341 -0
- package/src/agent-ops/query-builders.d.ts +26 -0
- package/src/agent-ops/query-builders.js +42 -5021
- package/src/archive/archive.d.ts +2 -0
- package/src/archive/compact.d.ts +1 -0
- package/src/archive/unarchive.d.ts +1 -0
- package/src/catalog/constants.js +10 -0
- package/src/catalog/copy.js +60 -0
- package/src/catalog/diagnostics.js +15 -0
- package/src/catalog/entries.js +42 -0
- package/src/catalog/files.js +67 -0
- package/src/catalog/provenance.js +122 -0
- package/src/catalog/source.js +150 -0
- package/src/catalog/validation.js +252 -0
- package/src/catalog.d.ts +12 -0
- package/src/catalog.js +18 -750
- package/src/cli/catalog-alias.d.ts +1 -0
- package/src/cli/command-parser.js +38 -0
- package/src/cli/command-parsers/core.js +102 -0
- package/src/cli/command-parsers/generator.js +39 -0
- package/src/cli/command-parsers/import.js +44 -0
- package/src/cli/command-parsers/legacy-workflow.js +21 -0
- package/src/cli/command-parsers/project.js +47 -0
- package/src/cli/command-parsers/sdlc.js +47 -0
- package/src/cli/command-parsers/shared.js +51 -0
- package/src/cli/command-parsers/template.js +48 -0
- package/src/cli/commands/agent.js +47 -0
- package/src/cli/commands/catalog/check.js +31 -0
- package/src/cli/commands/catalog/copy.js +59 -0
- package/src/cli/commands/catalog/doctor.js +248 -0
- package/src/cli/commands/catalog/help.js +21 -0
- package/src/cli/commands/catalog/list.js +52 -0
- package/src/cli/commands/catalog/runner.js +92 -0
- package/src/cli/commands/catalog/shared.js +17 -0
- package/src/cli/commands/catalog/show.js +134 -0
- package/src/cli/commands/catalog.js +32 -0
- package/src/cli/commands/check.js +268 -0
- package/src/cli/commands/doctor.js +268 -0
- package/src/cli/commands/emit.js +149 -0
- package/src/cli/commands/generate.js +96 -0
- package/src/cli/commands/generator-policy/package-info.js +162 -0
- package/src/cli/commands/generator-policy/payloads.js +372 -0
- package/src/cli/commands/generator-policy/printers.js +159 -0
- package/src/cli/commands/generator-policy/runner.js +81 -0
- package/src/cli/commands/generator-policy/shared.js +39 -0
- package/src/cli/commands/generator-policy.js +17 -0
- package/src/cli/commands/generator.js +443 -0
- package/src/cli/commands/import/adopt.js +170 -0
- package/src/cli/commands/import/check.js +91 -0
- package/src/cli/commands/import/diff.js +84 -0
- package/src/cli/commands/import/help.js +47 -0
- package/src/cli/commands/import/paths.js +277 -0
- package/src/cli/commands/import/plan.js +284 -0
- package/src/cli/commands/import/refresh.js +470 -0
- package/src/cli/commands/import/status-history.js +196 -0
- package/src/cli/commands/import/workspace.js +230 -0
- package/src/cli/commands/import-runner.js +157 -0
- package/src/cli/commands/import.js +35 -0
- package/src/cli/commands/inspect.js +55 -0
- package/src/cli/commands/new.js +94 -0
- package/src/cli/commands/package/constants.js +17 -0
- package/src/cli/commands/package/doctor.js +240 -0
- package/src/cli/commands/package/help.js +27 -0
- package/src/cli/commands/package/lockfile.js +135 -0
- package/src/cli/commands/package/npm.js +97 -0
- package/src/cli/commands/package/reporting.js +35 -0
- package/src/cli/commands/package/runner.js +33 -0
- package/src/cli/commands/package/shared.js +9 -0
- package/src/cli/commands/package/update-cli.js +252 -0
- package/src/cli/commands/package/versions.js +35 -0
- package/src/cli/commands/package.js +31 -0
- package/src/cli/commands/query/change-plan.js +68 -0
- package/src/cli/commands/query/definitions.js +202 -0
- package/src/cli/commands/query/import-adopt.js +121 -0
- package/src/cli/commands/query/runner/artifacts.js +102 -0
- package/src/cli/commands/query/runner/boundaries.js +211 -0
- package/src/cli/commands/query/runner/change.js +182 -0
- package/src/cli/commands/query/runner/import-adopt.js +111 -0
- package/src/cli/commands/query/runner/index.js +31 -0
- package/src/cli/commands/query/runner/output.js +12 -0
- package/src/cli/commands/query/runner/workflow.js +241 -0
- package/src/cli/commands/query/runner.js +3 -0
- package/src/cli/commands/query/workflow-context.js +5 -0
- package/src/cli/commands/query/workspace.js +274 -0
- package/src/cli/commands/query.js +11 -0
- package/src/cli/commands/release-rollout.js +257 -0
- package/src/cli/commands/release-shared.js +528 -0
- package/src/cli/commands/release-status.js +429 -0
- package/src/cli/commands/release.js +107 -0
- package/src/cli/commands/sdlc.js +168 -0
- package/src/cli/commands/setup.js +76 -0
- package/src/cli/commands/source.js +291 -0
- package/src/cli/commands/template/baseline.js +100 -0
- package/src/cli/commands/template/check.js +466 -0
- package/src/cli/commands/template/constants.js +8 -0
- package/src/cli/commands/template/diagnostics.js +26 -0
- package/src/cli/commands/template/help.js +28 -0
- package/src/cli/commands/template/lifecycle.js +404 -0
- package/src/cli/commands/template/list-show.js +287 -0
- package/src/cli/commands/template/policy.js +422 -0
- package/src/cli/commands/template/shared.js +127 -0
- package/src/cli/commands/template/updates.js +352 -0
- package/src/cli/commands/template-runner.js +198 -0
- package/src/cli/commands/template.js +43 -0
- package/src/cli/commands/trust.js +219 -0
- package/src/cli/commands/version.js +40 -0
- package/src/cli/commands/widget.js +168 -0
- package/src/cli/commands/workflow.js +63 -0
- package/src/cli/dispatcher.js +392 -0
- package/src/cli/help-dispatch.js +188 -0
- package/src/cli/help.js +296 -0
- package/src/cli/migration-guidance.js +59 -0
- package/src/cli/options.js +96 -0
- package/src/cli/output-safety.js +107 -0
- package/src/cli/path-normalization.js +29 -0
- package/src/cli.js +47 -11711
- package/src/example-implementation.d.ts +2 -0
- package/src/format.d.ts +1 -0
- package/src/generator/api/contracts.js +497 -0
- package/src/generator/api/metadata.js +221 -0
- package/src/generator/api/openapi.js +559 -0
- package/src/generator/api/schema.js +124 -0
- package/src/generator/api/types.d.ts +98 -0
- package/src/generator/api.js +3 -1195
- package/src/generator/check.d.ts +1 -0
- package/src/generator/context/bundle.d.ts +1 -0
- package/src/generator/context/shared/domain-sdlc.js +282 -0
- package/src/generator/context/shared/maintained-boundary.js +665 -0
- package/src/generator/context/shared/metrics.js +85 -0
- package/src/generator/context/shared/primitives.js +64 -0
- package/src/generator/context/shared/relationships.js +453 -0
- package/src/generator/context/shared/summaries.js +263 -0
- package/src/generator/context/shared/types.d.ts +207 -0
- package/src/generator/context/shared.d.ts +44 -0
- package/src/generator/context/shared.js +80 -1390
- package/src/generator/context/slice/core.js +397 -0
- package/src/generator/context/slice/sdlc.js +417 -0
- package/src/generator/context/slice/ui-packets.js +183 -0
- package/src/generator/context/slice.js +2 -859
- package/src/generator/native/parity-bundle.js +2 -1
- package/src/generator/registry/index.js +507 -0
- package/src/generator/registry.js +18 -504
- package/src/generator/runtime/environment/index.js +666 -0
- package/src/generator/runtime/environment.js +4 -666
- package/src/generator/runtime/runtime-check/index.js +554 -0
- package/src/generator/runtime/runtime-check.js +4 -554
- package/src/generator/runtime/shared/index.js +572 -0
- package/src/generator/runtime/shared.js +19 -570
- package/src/generator/shared.d.ts +2 -0
- package/src/generator/surfaces/shared.d.ts +3 -0
- package/src/generator/surfaces/web/html-escape.js +22 -0
- package/src/generator/surfaces/web/react.js +10 -8
- package/src/generator/surfaces/web/sveltekit.js +7 -5
- package/src/generator/surfaces/web/vanilla.js +8 -4
- package/src/generator/widget-conformance/behavior-report.js +258 -0
- package/src/generator/widget-conformance/checks.js +371 -0
- package/src/generator/widget-conformance/projection-context.js +200 -0
- package/src/generator/widget-conformance/report.js +166 -0
- package/src/generator/widget-conformance/types.d.ts +121 -0
- package/src/generator/widget-conformance.js +3 -824
- package/src/generator.d.ts +2 -0
- package/src/github-client.js +520 -0
- package/src/import/core/context.d.ts +3 -0
- package/src/import/core/contracts.d.ts +1 -0
- package/src/import/core/registry.d.ts +4 -0
- package/src/import/core/runner/candidates.js +217 -0
- package/src/import/core/runner/options.js +22 -0
- package/src/import/core/runner/reports.js +50 -0
- package/src/import/core/runner/run.js +79 -0
- package/src/import/core/runner/tracks.js +150 -0
- package/src/import/core/runner/ui-drafts.js +337 -0
- package/src/import/core/runner.js +3 -698
- package/src/import/core/shared/api-routes.js +221 -0
- package/src/import/core/shared/candidates.js +97 -0
- package/src/import/core/shared/files.js +177 -0
- package/src/import/core/shared/next-app.js +389 -0
- package/src/import/core/shared/types.d.ts +51 -0
- package/src/import/core/shared/ui-routes.js +230 -0
- package/src/import/core/shared.js +67 -910
- package/src/import/extractors/api/flutter-dio.js +4 -8
- package/src/import/extractors/api/react-native-repository.js +4 -8
- package/src/import/index.d.ts +4 -0
- package/src/import/provenance.d.ts +4 -0
- package/src/new-project/constants.js +128 -0
- package/src/new-project/create.js +83 -0
- package/src/new-project/json.js +28 -0
- package/src/new-project/metadata.js +96 -0
- package/src/new-project/package-spec.js +161 -0
- package/src/new-project/project-files.js +348 -0
- package/src/new-project/template-policy.js +269 -0
- package/src/new-project/template-resolution.js +368 -0
- package/src/new-project/template-snapshots.js +430 -0
- package/src/new-project/template-updates.js +512 -0
- package/src/new-project/types.d.ts +83 -0
- package/src/new-project.js +6 -2188
- package/src/npm-safety.js +79 -0
- package/src/parser.d.ts +87 -0
- package/src/parser.js +118 -0
- package/src/path-helpers.d.ts +1 -0
- package/src/path-helpers.js +20 -0
- package/src/policy/review-boundaries.d.ts +15 -0
- package/src/project-config/index.js +564 -0
- package/src/project-config.js +19 -560
- package/src/reconcile/docs.d.ts +8 -0
- package/src/reconcile/journeys.d.ts +1 -0
- package/src/resolver/enrich/acceptance-criterion.js +2 -0
- package/src/resolver/enrich/bug.js +2 -0
- package/src/resolver/enrich/pitch.js +2 -0
- package/src/resolver/enrich/requirement.js +2 -0
- package/src/resolver/enrich/task.js +2 -0
- package/src/resolver/index.js +19 -2089
- package/src/resolver/normalize.js +384 -1
- package/src/resolver/plans.js +168 -0
- package/src/resolver/projections-api.js +494 -0
- package/src/resolver/projections-db.js +133 -0
- package/src/resolver/projections-ui.js +317 -0
- package/src/resolver/shapes.js +251 -0
- package/src/resolver/shared.js +278 -0
- package/src/resolver/widgets.js +132 -0
- package/src/resolver.d.ts +1 -0
- package/src/runtime-support.js +29 -0
- package/src/sdlc/adopt.d.ts +1 -0
- package/src/sdlc/check.d.ts +1 -0
- package/src/sdlc/explain.d.ts +1 -0
- package/src/sdlc/release.d.ts +1 -0
- package/src/sdlc/scaffold.d.ts +1 -0
- package/src/sdlc/transition.d.ts +1 -0
- package/src/template-trust/constants.js +62 -0
- package/src/template-trust/content.js +258 -0
- package/src/template-trust/diff.js +92 -0
- package/src/template-trust/policy.js +61 -0
- package/src/template-trust/record.js +90 -0
- package/src/template-trust/status.js +182 -0
- package/src/template-trust.js +24 -687
- package/src/text-helpers.d.ts +7 -0
- package/src/text-helpers.js +245 -0
- package/src/topogram-config.js +306 -0
- package/src/topogram-types.d.ts +69 -0
- package/src/validator/common.js +488 -0
- package/src/validator/data-model.js +237 -0
- package/src/validator/docs.js +167 -0
- package/src/validator/expressions.js +146 -1
- package/src/validator/index.d.ts +23 -0
- package/src/validator/index.js +32 -3585
- package/src/validator/kinds.d.ts +41 -0
- package/src/validator/kinds.js +2 -0
- package/src/validator/model-helpers.js +46 -0
- package/src/validator/per-kind/acceptance-criterion.js +5 -0
- package/src/validator/per-kind/bug.js +6 -0
- package/src/validator/per-kind/domain.js +15 -2
- package/src/validator/per-kind/pitch.js +7 -0
- package/src/validator/per-kind/requirement.js +5 -0
- package/src/validator/per-kind/task.js +7 -0
- package/src/validator/per-kind/widget.js +14 -0
- package/src/validator/projections/api-http-async.js +410 -0
- package/src/validator/projections/api-http-authz.js +88 -0
- package/src/validator/projections/api-http-core.js +205 -0
- package/src/validator/projections/api-http-policies.js +339 -0
- package/src/validator/projections/api-http-responses.js +233 -0
- package/src/validator/projections/api-http.js +44 -0
- package/src/validator/projections/db.js +353 -0
- package/src/validator/projections/generator-defaults.js +45 -0
- package/src/validator/projections/helpers.js +87 -0
- package/src/validator/projections/ui-helpers.js +214 -0
- package/src/validator/projections/ui-navigation.js +344 -0
- package/src/validator/projections/ui-structure.js +364 -0
- package/src/validator/projections/ui-widgets.js +493 -0
- package/src/validator/projections/ui.js +46 -0
- package/src/validator/registry.js +48 -1
- package/src/validator/utils.d.ts +20 -0
- package/src/validator/utils.js +115 -12
- package/src/validator.d.ts +2 -0
- package/src/widget-behavior.d.ts +1 -0
- package/src/workflows/adoption/index.js +26 -0
- package/src/workflows/docs-generate.js +262 -0
- package/src/workflows/docs-scan.js +703 -0
- package/src/workflows/docs.js +15 -0
- package/src/workflows/import-app/api/collect.js +221 -0
- package/src/workflows/import-app/api/openapi.js +257 -0
- package/src/workflows/import-app/api/routes.js +327 -0
- package/src/workflows/import-app/api/sources.js +22 -0
- package/src/workflows/import-app/api.js +4 -0
- package/src/workflows/import-app/db.js +538 -0
- package/src/workflows/import-app/index.js +30 -0
- package/src/workflows/import-app/shared.js +218 -0
- package/src/workflows/import-app/ui.js +443 -0
- package/src/workflows/import-app/workflow.js +159 -0
- package/src/workflows/reconcile/adoption-plan/build.js +208 -0
- package/src/workflows/reconcile/adoption-plan/dependencies.js +75 -0
- package/src/workflows/reconcile/adoption-plan/outputs.js +143 -0
- package/src/workflows/reconcile/adoption-plan/paths.js +58 -0
- package/src/workflows/reconcile/adoption-plan/projection-patches.js +177 -0
- package/src/workflows/reconcile/adoption-plan/reasons.js +107 -0
- package/src/workflows/reconcile/adoption-plan.js +32 -0
- package/src/workflows/reconcile/auth/closures.js +115 -0
- package/src/workflows/reconcile/auth/formatters.js +142 -0
- package/src/workflows/reconcile/auth/inference.js +330 -0
- package/src/workflows/reconcile/auth/roles.js +122 -0
- package/src/workflows/reconcile/auth.js +37 -0
- package/src/workflows/reconcile/bundle-core/index.js +600 -0
- package/src/workflows/reconcile/bundle-core.js +14 -0
- package/src/workflows/reconcile/bundle-shared.js +75 -0
- package/src/workflows/reconcile/candidate-model.js +477 -0
- package/src/workflows/reconcile/canonical-surface.js +264 -0
- package/src/workflows/reconcile/gap-report.js +333 -0
- package/src/workflows/reconcile/ids.js +6 -0
- package/src/workflows/reconcile/impacts/adoption-plan.js +192 -0
- package/src/workflows/reconcile/impacts/indexes.js +101 -0
- package/src/workflows/reconcile/impacts/patches.js +252 -0
- package/src/workflows/reconcile/impacts/reports.js +80 -0
- package/src/workflows/reconcile/impacts.js +16 -0
- package/src/workflows/reconcile/index.js +7 -0
- package/src/workflows/reconcile/renderers.js +461 -0
- package/src/workflows/reconcile/summary.js +90 -0
- package/src/workflows/reconcile/workflow.js +309 -0
- package/src/workflows/shared.js +189 -0
- package/src/workflows/types.d.ts +93 -0
- package/src/workflows.d.ts +1 -0
- package/src/workflows.js +10 -7652
- package/src/workspace-docs.d.ts +29 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export {
|
|
2
|
+
confidenceRank,
|
|
3
|
+
renderCandidateActor,
|
|
4
|
+
renderCandidateRole,
|
|
5
|
+
scanDocsWorkflow
|
|
6
|
+
} from "./docs-scan.js";
|
|
7
|
+
export {
|
|
8
|
+
docDirForKind,
|
|
9
|
+
generateDocsBundleFromGraph,
|
|
10
|
+
generateDocsWorkflow,
|
|
11
|
+
generateJourneyDraftsWorkflow,
|
|
12
|
+
loadResolvedGraph,
|
|
13
|
+
refreshDocsWorkflow,
|
|
14
|
+
tryLoadResolvedGraph
|
|
15
|
+
} from "./docs-generate.js";
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { relativeTo } from "../../../path-helpers.js";
|
|
6
|
+
import { titleCase } from "../../../text-helpers.js";
|
|
7
|
+
import { readTextIfExists } from "../../shared.js";
|
|
8
|
+
import { dedupeCandidateRecords, makeCandidateRecord, normalizeOpenApiPath } from "../shared.js";
|
|
9
|
+
import { inferReactRoutes, inferSvelteRoutes } from "../ui.js";
|
|
10
|
+
import { parseOpenApiDocument, parseOpenApiYaml } from "./openapi.js";
|
|
11
|
+
import {
|
|
12
|
+
inferNextApiRoutes,
|
|
13
|
+
inferNextAuthCapabilities,
|
|
14
|
+
inferNextServerActionCapabilities,
|
|
15
|
+
inferRouteCapabilityId,
|
|
16
|
+
inferServerRoutes
|
|
17
|
+
} from "./routes.js";
|
|
18
|
+
import { discoverApiSources } from "./sources.js";
|
|
19
|
+
|
|
20
|
+
/** @param {WorkspacePaths} paths @returns {any} */
|
|
21
|
+
export function collectApiImport(paths) {
|
|
22
|
+
/** @type {any[]} */
|
|
23
|
+
const findings = [];
|
|
24
|
+
/** @type {WorkflowRecord} */
|
|
25
|
+
const candidates = {
|
|
26
|
+
capabilities: [],
|
|
27
|
+
routes: [],
|
|
28
|
+
stacks: []
|
|
29
|
+
};
|
|
30
|
+
const { openApiFiles } = discoverApiSources(paths);
|
|
31
|
+
let usedOpenApi = false;
|
|
32
|
+
for (const filePath of openApiFiles) {
|
|
33
|
+
const provenance = relativeTo(paths.repoRoot, filePath);
|
|
34
|
+
const text = readTextIfExists(filePath) || "";
|
|
35
|
+
const document = filePath.endsWith(".json") ? JSON.parse(text) : parseOpenApiYaml(text);
|
|
36
|
+
const parsed = parseOpenApiDocument(document, provenance, "openapi");
|
|
37
|
+
usedOpenApi = true;
|
|
38
|
+
findings.push({
|
|
39
|
+
kind: "openapi",
|
|
40
|
+
file: provenance,
|
|
41
|
+
capability_count: parsed.capabilities.length
|
|
42
|
+
});
|
|
43
|
+
candidates.capabilities.push(...parsed.capabilities);
|
|
44
|
+
candidates.routes.push(...parsed.routes.map((/** @type {any} */ route) => ({
|
|
45
|
+
path: route.path,
|
|
46
|
+
method: route.method,
|
|
47
|
+
confidence: "high",
|
|
48
|
+
source_kind: route.source_kind,
|
|
49
|
+
provenance: route.provenance
|
|
50
|
+
})));
|
|
51
|
+
}
|
|
52
|
+
if (!usedOpenApi) {
|
|
53
|
+
const inferredRoutes = [
|
|
54
|
+
...inferNextApiRoutes(paths),
|
|
55
|
+
...inferServerRoutes(paths)
|
|
56
|
+
];
|
|
57
|
+
const inferredServerActions = inferNextServerActionCapabilities(paths);
|
|
58
|
+
const inferredAuthCapabilities = inferNextAuthCapabilities(paths);
|
|
59
|
+
if (inferredRoutes.length > 0) {
|
|
60
|
+
findings.push({
|
|
61
|
+
kind: "route_inventory",
|
|
62
|
+
files: [...new Set(inferredRoutes.map((/** @type {any} */ route) => relativeTo(paths.repoRoot, route.file)))],
|
|
63
|
+
route_count: inferredRoutes.length
|
|
64
|
+
});
|
|
65
|
+
candidates.capabilities.push(
|
|
66
|
+
...inferredRoutes.map((/** @type {any} */ route) =>
|
|
67
|
+
makeCandidateRecord({
|
|
68
|
+
kind: "capability",
|
|
69
|
+
idHint: inferRouteCapabilityId(route),
|
|
70
|
+
label: `${route.method} ${route.path}`,
|
|
71
|
+
confidence: "medium",
|
|
72
|
+
sourceKind: "route_code",
|
|
73
|
+
provenance: `${relativeTo(paths.repoRoot, route.file)}#${route.method} ${route.path}`,
|
|
74
|
+
endpoint: {
|
|
75
|
+
method: route.method,
|
|
76
|
+
path: normalizeOpenApiPath(route.path)
|
|
77
|
+
},
|
|
78
|
+
path_params: (route.path_params || []).map((/** @type {any} */ name) => ({ name, required: true, type: null })),
|
|
79
|
+
query_params: (route.query_params || []).map((/** @type {any} */ name) => ({ name, required: false, type: null })),
|
|
80
|
+
header_params: [],
|
|
81
|
+
input_fields: [],
|
|
82
|
+
output_fields: route.output_fields || [],
|
|
83
|
+
auth_hint: route.auth_hint || "unknown"
|
|
84
|
+
})
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
candidates.routes.push(
|
|
88
|
+
...inferredRoutes.map((/** @type {any} */ route) => ({
|
|
89
|
+
path: normalizeOpenApiPath(route.path),
|
|
90
|
+
method: route.method,
|
|
91
|
+
confidence: "medium",
|
|
92
|
+
source_kind: "route_code",
|
|
93
|
+
provenance: `${relativeTo(paths.repoRoot, route.file)}#${route.method} ${route.path}`
|
|
94
|
+
}))
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (inferredServerActions.length > 0) {
|
|
98
|
+
findings.push({
|
|
99
|
+
kind: "next_server_actions",
|
|
100
|
+
files: [...new Set(inferredServerActions.map((/** @type {any} */ action) => relativeTo(paths.repoRoot, action.file)))],
|
|
101
|
+
action_count: inferredServerActions.length
|
|
102
|
+
});
|
|
103
|
+
candidates.capabilities.push(
|
|
104
|
+
...inferredServerActions.map((/** @type {any} */ action) =>
|
|
105
|
+
makeCandidateRecord({
|
|
106
|
+
kind: "capability",
|
|
107
|
+
idHint: action.id_hint,
|
|
108
|
+
label: titleCase(action.id_hint.replace(/^cap_/, "")),
|
|
109
|
+
confidence: "medium",
|
|
110
|
+
sourceKind: action.source_kind,
|
|
111
|
+
provenance: `${relativeTo(paths.repoRoot, action.file)}#${action.function_name}`,
|
|
112
|
+
endpoint: {
|
|
113
|
+
method: action.method,
|
|
114
|
+
path: normalizeOpenApiPath(action.path)
|
|
115
|
+
},
|
|
116
|
+
path_params: (action.path_params || []).map((/** @type {any} */ name) => ({ name, required: true, type: null })),
|
|
117
|
+
query_params: [],
|
|
118
|
+
header_params: [],
|
|
119
|
+
input_fields: action.input_fields || [],
|
|
120
|
+
output_fields: action.output_fields || [],
|
|
121
|
+
auth_hint: action.auth_hint || "unknown"
|
|
122
|
+
})
|
|
123
|
+
)
|
|
124
|
+
);
|
|
125
|
+
candidates.routes.push(
|
|
126
|
+
...inferredServerActions.map((/** @type {any} */ action) => ({
|
|
127
|
+
path: normalizeOpenApiPath(action.path),
|
|
128
|
+
method: action.method,
|
|
129
|
+
confidence: "medium",
|
|
130
|
+
source_kind: action.source_kind,
|
|
131
|
+
provenance: `${relativeTo(paths.repoRoot, action.file)}#${action.function_name}`
|
|
132
|
+
}))
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
if (inferredAuthCapabilities.length > 0) {
|
|
136
|
+
findings.push({
|
|
137
|
+
kind: "next_auth_flows",
|
|
138
|
+
files: [...new Set(inferredAuthCapabilities.flatMap((/** @type {any} */ capability) => capability.provenance || []))],
|
|
139
|
+
capability_count: inferredAuthCapabilities.length
|
|
140
|
+
});
|
|
141
|
+
candidates.capabilities.push(
|
|
142
|
+
...inferredAuthCapabilities.map((/** @type {any} */ capability) =>
|
|
143
|
+
makeCandidateRecord({
|
|
144
|
+
kind: "capability",
|
|
145
|
+
idHint: capability.id_hint,
|
|
146
|
+
label: capability.label,
|
|
147
|
+
confidence: "medium",
|
|
148
|
+
sourceKind: capability.source_kind,
|
|
149
|
+
provenance: capability.provenance,
|
|
150
|
+
endpoint: {
|
|
151
|
+
method: capability.method,
|
|
152
|
+
path: normalizeOpenApiPath(capability.path)
|
|
153
|
+
},
|
|
154
|
+
path_params: [],
|
|
155
|
+
query_params: [],
|
|
156
|
+
header_params: [],
|
|
157
|
+
input_fields: capability.input_fields || [],
|
|
158
|
+
output_fields: capability.output_fields || [],
|
|
159
|
+
auth_hint: capability.auth_hint || "unknown",
|
|
160
|
+
entity_id: capability.entity_id,
|
|
161
|
+
target_state: capability.target_state || null
|
|
162
|
+
})
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
candidates.routes.push(
|
|
166
|
+
...inferredAuthCapabilities.map((/** @type {any} */ capability) => ({
|
|
167
|
+
path: normalizeOpenApiPath(capability.path),
|
|
168
|
+
method: capability.method,
|
|
169
|
+
confidence: "medium",
|
|
170
|
+
source_kind: capability.source_kind,
|
|
171
|
+
provenance: capability.provenance
|
|
172
|
+
}))
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const reactRoutes = inferReactRoutes(path.join(paths.workspaceRoot, "apps", "web"));
|
|
177
|
+
if (reactRoutes.length > 0) {
|
|
178
|
+
findings.push({
|
|
179
|
+
kind: "react_routes",
|
|
180
|
+
file: relativeTo(paths.repoRoot, path.join(paths.workspaceRoot, "apps", "web", "src", "App.tsx")),
|
|
181
|
+
routes: reactRoutes
|
|
182
|
+
});
|
|
183
|
+
candidates.routes.push(...reactRoutes.map((/** @type {any} */ route) => ({
|
|
184
|
+
path: route,
|
|
185
|
+
method: "GET",
|
|
186
|
+
confidence: "medium",
|
|
187
|
+
source_kind: "generated_artifact",
|
|
188
|
+
provenance: relativeTo(paths.repoRoot, path.join(paths.workspaceRoot, "apps", "web", "src", "App.tsx"))
|
|
189
|
+
})));
|
|
190
|
+
candidates.stacks.push("react_web");
|
|
191
|
+
}
|
|
192
|
+
const svelteRoutes = inferSvelteRoutes(path.join(paths.workspaceRoot, "apps", "web-sveltekit"));
|
|
193
|
+
if (svelteRoutes.length > 0) {
|
|
194
|
+
findings.push({
|
|
195
|
+
kind: "sveltekit_routes",
|
|
196
|
+
file: relativeTo(paths.repoRoot, path.join(paths.workspaceRoot, "apps", "web-sveltekit", "src", "routes")),
|
|
197
|
+
routes: svelteRoutes
|
|
198
|
+
});
|
|
199
|
+
candidates.routes.push(...svelteRoutes.map((/** @type {any} */ route) => ({
|
|
200
|
+
path: route,
|
|
201
|
+
method: "GET",
|
|
202
|
+
confidence: "medium",
|
|
203
|
+
source_kind: "generated_artifact",
|
|
204
|
+
provenance: relativeTo(paths.repoRoot, path.join(paths.workspaceRoot, "apps", "web-sveltekit", "src", "routes"))
|
|
205
|
+
})));
|
|
206
|
+
candidates.stacks.push("sveltekit_web");
|
|
207
|
+
}
|
|
208
|
+
candidates.capabilities = dedupeCandidateRecords(candidates.capabilities, (/** @type {any} */ record) => record.id_hint);
|
|
209
|
+
candidates.routes = dedupeCandidateRecords(
|
|
210
|
+
candidates.routes.map((/** @type {any} */ route) => ({
|
|
211
|
+
...route,
|
|
212
|
+
id_hint: route.id_hint || `${route.method}_${route.path}`
|
|
213
|
+
})),
|
|
214
|
+
(/** @type {any} */ record) => `${record.method}:${record.path}:${record.source_kind}`
|
|
215
|
+
).map((/** @type {any} */ record) => {
|
|
216
|
+
const { id_hint, ...route } = record;
|
|
217
|
+
return route;
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return { findings, candidates };
|
|
221
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { slugify, titleCase } from "../../../text-helpers.js";
|
|
4
|
+
import { makeCandidateRecord } from "../shared.js";
|
|
5
|
+
|
|
6
|
+
/** @param {WorkflowRecord} document @param {any} provenance @param {string} sourceKind @returns {any} */
|
|
7
|
+
export function parseOpenApiDocument(document, provenance, sourceKind = "openapi") {
|
|
8
|
+
/** @type {any[]} */
|
|
9
|
+
const capabilities = [];
|
|
10
|
+
/** @type {any[]} */
|
|
11
|
+
const routes = [];
|
|
12
|
+
const pathsObject = document.paths || {};
|
|
13
|
+
for (const [endpointPath, operations] of Object.entries(pathsObject)) {
|
|
14
|
+
for (const [method, operation] of Object.entries(operations || {})) {
|
|
15
|
+
const normalizedMethod = method.toUpperCase();
|
|
16
|
+
const operationId = operation.operationId || `candidate_${normalizedMethod.toLowerCase()}_${slugify(endpointPath)}`;
|
|
17
|
+
const requestSchema =
|
|
18
|
+
operation.requestBody?.content?.["application/json"]?.schema?.$ref ||
|
|
19
|
+
operation.requestBody?.content?.["application/json"]?.schema?.type ||
|
|
20
|
+
null;
|
|
21
|
+
const successResponse = Object.entries(operation.responses || {}).find((/** @type {any} */ [status]) => /^2/.test(status));
|
|
22
|
+
const responseSchema =
|
|
23
|
+
successResponse?.[1]?.content?.["application/json"]?.schema?.$ref ||
|
|
24
|
+
successResponse?.[1]?.content?.["application/json"]?.schema?.type ||
|
|
25
|
+
null;
|
|
26
|
+
const parameterHints = extractOpenApiParameterHints(document, endpointPath, operation);
|
|
27
|
+
const requestFieldHints = extractOpenApiSchemaFieldHints(document, operation.requestBody?.content?.["application/json"]?.schema);
|
|
28
|
+
const responseFieldHints = extractOpenApiSchemaFieldHints(document, successResponse?.[1]?.content?.["application/json"]?.schema);
|
|
29
|
+
const securitySchemes = extractOpenApiSecuritySchemes(document, operation);
|
|
30
|
+
capabilities.push(
|
|
31
|
+
makeCandidateRecord({
|
|
32
|
+
kind: "capability",
|
|
33
|
+
idHint: operationId,
|
|
34
|
+
label: operation.summary || titleCase(operationId.replace(/^cap_/, "")),
|
|
35
|
+
confidence: "high",
|
|
36
|
+
sourceKind,
|
|
37
|
+
provenance: `${provenance}#${normalizedMethod} ${endpointPath}`,
|
|
38
|
+
endpoint: {
|
|
39
|
+
method: normalizedMethod,
|
|
40
|
+
path: endpointPath
|
|
41
|
+
},
|
|
42
|
+
input_hint: requestSchema,
|
|
43
|
+
output_hint: responseSchema,
|
|
44
|
+
input_fields: requestFieldHints.body_fields,
|
|
45
|
+
output_fields: responseFieldHints.body_fields,
|
|
46
|
+
path_params: parameterHints.path,
|
|
47
|
+
query_params: parameterHints.query,
|
|
48
|
+
header_params: parameterHints.header,
|
|
49
|
+
security_schemes: securitySchemes,
|
|
50
|
+
auth_hint: securitySchemes.length > 0 ? "secured" : "unknown"
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
routes.push({
|
|
54
|
+
path: endpointPath,
|
|
55
|
+
method: normalizedMethod,
|
|
56
|
+
source_kind: sourceKind,
|
|
57
|
+
provenance: `${provenance}#${normalizedMethod} ${endpointPath}`
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { capabilities, routes };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @param {string} ref @returns {any} */
|
|
65
|
+
function openApiRefName(ref) {
|
|
66
|
+
if (!ref || typeof ref !== "string") {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return ref.split("/").pop() || null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @param {WorkflowRecord} document @param {WorkflowRecord} schema @param {Set<any>} seen @returns {any} */
|
|
73
|
+
function resolveOpenApiSchema(document, schema, seen = new Set()) {
|
|
74
|
+
if (!schema || typeof schema !== "object") {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (schema.$ref) {
|
|
78
|
+
if (seen.has(schema.$ref)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
seen.add(schema.$ref);
|
|
82
|
+
if (!schema.$ref.startsWith("#/")) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const segments = schema.$ref.slice(2).split("/");
|
|
86
|
+
let current = document;
|
|
87
|
+
for (const segment of segments) {
|
|
88
|
+
current = current?.[segment];
|
|
89
|
+
if (current == null) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return resolveOpenApiSchema(document, current, seen) || current;
|
|
94
|
+
}
|
|
95
|
+
return schema;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** @param {WorkflowRecord} document @param {WorkflowRecord} schema @param {Set<any>} fields @param {Set<any>} seen @returns {any} */
|
|
99
|
+
function collectOpenApiObjectFields(document, schema, fields = new Set(), seen = new Set()) {
|
|
100
|
+
const resolved = resolveOpenApiSchema(document, schema, seen);
|
|
101
|
+
if (!resolved || typeof resolved !== "object") {
|
|
102
|
+
return fields;
|
|
103
|
+
}
|
|
104
|
+
if (resolved.type === "array" && resolved.items) {
|
|
105
|
+
collectOpenApiObjectFields(document, resolved.items, fields, seen);
|
|
106
|
+
return fields;
|
|
107
|
+
}
|
|
108
|
+
for (const propertyName of Object.keys(resolved.properties || {})) {
|
|
109
|
+
fields.add(propertyName);
|
|
110
|
+
}
|
|
111
|
+
for (const entry of resolved.allOf || []) {
|
|
112
|
+
collectOpenApiObjectFields(document, entry, fields, seen);
|
|
113
|
+
}
|
|
114
|
+
for (const entry of resolved.oneOf || []) {
|
|
115
|
+
collectOpenApiObjectFields(document, entry, fields, seen);
|
|
116
|
+
}
|
|
117
|
+
for (const entry of resolved.anyOf || []) {
|
|
118
|
+
collectOpenApiObjectFields(document, entry, fields, seen);
|
|
119
|
+
}
|
|
120
|
+
return fields;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** @param {WorkflowRecord} document @param {WorkflowRecord} schema @returns {any} */
|
|
124
|
+
function extractOpenApiSchemaFieldHints(document, schema) {
|
|
125
|
+
const fieldNames = [...collectOpenApiObjectFields(document, schema)].sort();
|
|
126
|
+
return {
|
|
127
|
+
schema_ref: openApiRefName(schema?.$ref || null),
|
|
128
|
+
body_fields: fieldNames
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** @param {string} endpointPath @param {WorkflowRecord} operation @returns {any} */
|
|
133
|
+
function collectOpenApiParameters(endpointPath, operation) {
|
|
134
|
+
const pathParams = [...String(endpointPath || "").matchAll(/\{([^}]+)\}/g)].map((/** @type {any} */ match) => ({
|
|
135
|
+
name: match[1],
|
|
136
|
+
in: "path",
|
|
137
|
+
required: true
|
|
138
|
+
}));
|
|
139
|
+
return [...pathParams, ...((operation.parameters || []).filter(Boolean))];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @param {WorkflowRecord} document @param {string} endpointPath @param {WorkflowRecord} operation @returns {any} */
|
|
143
|
+
function extractOpenApiParameterHints(document, endpointPath, operation) {
|
|
144
|
+
/** @type {WorkflowRecord} */
|
|
145
|
+
const grouped = {
|
|
146
|
+
path: [],
|
|
147
|
+
query: [],
|
|
148
|
+
header: []
|
|
149
|
+
};
|
|
150
|
+
for (const parameter of collectOpenApiParameters(endpointPath, operation)) {
|
|
151
|
+
const schema = resolveOpenApiSchema(document, parameter.schema || null);
|
|
152
|
+
const target = parameter.in === "query" ? "query" : parameter.in === "header" ? "header" : "path";
|
|
153
|
+
grouped[target].push({
|
|
154
|
+
name: parameter.name,
|
|
155
|
+
required: Boolean(parameter.required),
|
|
156
|
+
type: schema?.type || null
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
for (const key of Object.keys(grouped)) {
|
|
160
|
+
grouped[key] = grouped[key].sort((/** @type {any} */ a, /** @type {any} */ b) => a.name.localeCompare(b.name));
|
|
161
|
+
}
|
|
162
|
+
return grouped;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** @param {WorkflowRecord} document @param {WorkflowRecord} operation @returns {any} */
|
|
166
|
+
function extractOpenApiSecuritySchemes(document, operation) {
|
|
167
|
+
const securityEntries = [...(operation.security || []), ...(document.security || [])];
|
|
168
|
+
const schemes = new Set();
|
|
169
|
+
for (const entry of securityEntries) {
|
|
170
|
+
for (const key of Object.keys(entry || {})) {
|
|
171
|
+
schemes.add(key);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return [...schemes].sort();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** @param {string} text @returns {any} */
|
|
178
|
+
export function parseOpenApiYaml(text) {
|
|
179
|
+
/** @type {WorkflowRecord} */
|
|
180
|
+
const doc = { paths: {} };
|
|
181
|
+
let currentPath = null;
|
|
182
|
+
let currentMethod = null;
|
|
183
|
+
let inRequestBody = false;
|
|
184
|
+
let inResponses = false;
|
|
185
|
+
let currentResponseStatus = null;
|
|
186
|
+
|
|
187
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
188
|
+
const line = rawLine.replace(/#.*$/, "");
|
|
189
|
+
if (!line.trim()) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const pathMatch = line.match(/^\s{2}(\/[^:]+):\s*$/);
|
|
193
|
+
if (pathMatch) {
|
|
194
|
+
currentPath = pathMatch[1];
|
|
195
|
+
currentMethod = null;
|
|
196
|
+
doc.paths[currentPath] = doc.paths[currentPath] || {};
|
|
197
|
+
inRequestBody = false;
|
|
198
|
+
inResponses = false;
|
|
199
|
+
currentResponseStatus = null;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const methodMatch = line.match(/^\s{4}(get|post|put|patch|delete):\s*$/i);
|
|
203
|
+
if (methodMatch && currentPath) {
|
|
204
|
+
currentMethod = methodMatch[1].toLowerCase();
|
|
205
|
+
doc.paths[currentPath][currentMethod] = { responses: {} };
|
|
206
|
+
inRequestBody = false;
|
|
207
|
+
inResponses = false;
|
|
208
|
+
currentResponseStatus = null;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (!currentPath || !currentMethod) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const operation = doc.paths[currentPath][currentMethod];
|
|
215
|
+
const operationIdMatch = line.match(/^\s{6}operationId:\s*(.+)$/);
|
|
216
|
+
if (operationIdMatch) {
|
|
217
|
+
operation.operationId = operationIdMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const summaryMatch = line.match(/^\s{6}summary:\s*(.+)$/);
|
|
221
|
+
if (summaryMatch) {
|
|
222
|
+
operation.summary = summaryMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (/^\s{6}requestBody:\s*$/.test(line)) {
|
|
226
|
+
inRequestBody = true;
|
|
227
|
+
inResponses = false;
|
|
228
|
+
currentResponseStatus = null;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (/^\s{6}responses:\s*$/.test(line)) {
|
|
232
|
+
inResponses = true;
|
|
233
|
+
inRequestBody = false;
|
|
234
|
+
currentResponseStatus = null;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const responseStatusMatch = line.match(/^\s{8}['"]?([0-9Xx]{3})['"]?:\s*$/);
|
|
238
|
+
if (inResponses && responseStatusMatch) {
|
|
239
|
+
currentResponseStatus = responseStatusMatch[1];
|
|
240
|
+
operation.responses[currentResponseStatus] = operation.responses[currentResponseStatus] || {};
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const refMatch = line.match(/^\s+\$ref:\s*(.+)$/);
|
|
244
|
+
if (refMatch) {
|
|
245
|
+
const ref = refMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
246
|
+
if (inRequestBody) {
|
|
247
|
+
operation.requestBody = operation.requestBody || { content: { "application/json": { schema: {} } } };
|
|
248
|
+
operation.requestBody.content["application/json"].schema.$ref = ref;
|
|
249
|
+
} else if (inResponses && currentResponseStatus) {
|
|
250
|
+
operation.responses[currentResponseStatus].content = operation.responses[currentResponseStatus].content || { "application/json": { schema: {} } };
|
|
251
|
+
operation.responses[currentResponseStatus].content["application/json"].schema.$ref = ref;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return doc;
|
|
257
|
+
}
|