@topogram/cli 0.3.63 → 0.3.64
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.d.ts +6 -0
- 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.d.ts +26 -0
- 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.d.ts +10 -0
- package/src/catalog.js +62 -66
- 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.js +617 -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.js +785 -0
- package/src/cli/commands/generator.js +443 -0
- package/src/cli/commands/import-runner.js +157 -0
- package/src/cli/commands/import.js +1734 -0
- package/src/cli/commands/inspect.js +55 -0
- package/src/cli/commands/new.js +94 -0
- package/src/cli/commands/package.js +815 -0
- package/src/cli/commands/query.js +1302 -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-runner.js +198 -0
- package/src/cli/commands/template.js +2145 -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/check.d.ts +1 -0
- package/src/generator/context/bundle.d.ts +1 -0
- package/src/generator/context/shared.d.ts +2 -0
- package/src/generator/native/parity-bundle.js +2 -1
- 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.d.ts +2 -0
- package/src/github-client.js +520 -0
- package/src/import/core/shared.js +20 -62
- 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.js +100 -11
- package/src/npm-safety.js +79 -0
- package/src/parser.d.ts +1 -0
- package/src/path-helpers.d.ts +1 -0
- package/src/path-helpers.js +20 -0
- package/src/project-config.js +1 -0
- package/src/reconcile/docs.d.ts +8 -0
- package/src/reconcile/journeys.d.ts +1 -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/text-helpers.d.ts +6 -0
- package/src/text-helpers.js +245 -0
- package/src/topogram-config.js +306 -0
- package/src/validator.d.ts +2 -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.js +799 -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.js +742 -0
- package/src/workflows/reconcile/auth.js +692 -0
- package/src/workflows/reconcile/bundle-core.js +600 -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.js +625 -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
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { idHintify, titleCase } from "../../text-helpers.js";
|
|
3
|
+
import { scanDocsWorkflow } from "../docs.js";
|
|
4
|
+
import { collectApiImport } from "./api.js";
|
|
5
|
+
import { collectDbImport } from "./db.js";
|
|
6
|
+
import { dedupeCandidateRecords, inferCapabilityEntityId, makeCandidateRecord } from "./shared.js";
|
|
7
|
+
|
|
8
|
+
/** @param {WorkflowRecord} capability @returns {any} */
|
|
9
|
+
function workflowEntityIdForCapability(capability) {
|
|
10
|
+
return inferCapabilityEntityId(capability);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** @param {WorkflowRecord} entity @param {any} enumCandidatesById @returns {any} */
|
|
14
|
+
function findEntityStatusFields(entity, enumCandidatesById) {
|
|
15
|
+
return (entity?.fields || []).filter((/** @type {any} */ field) =>
|
|
16
|
+
["status", "state"].includes(field.name) && enumCandidatesById.has(idHintify(field.field_type))
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** @param {WorkflowRecord} capability @param {any[]} knownStates @returns {any} */
|
|
21
|
+
function targetStateForCapability(capability, knownStates) {
|
|
22
|
+
if (capability.target_state) {
|
|
23
|
+
const explicitState = idHintify(capability.target_state);
|
|
24
|
+
if (knownStates.length === 0 || knownStates.includes(explicitState)) {
|
|
25
|
+
return explicitState;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const id = capability.id_hint || "";
|
|
29
|
+
const method = String(capability.endpoint?.method || "").toUpperCase();
|
|
30
|
+
const candidates = [
|
|
31
|
+
["sign_in", "authenticated"],
|
|
32
|
+
["login", "authenticated"],
|
|
33
|
+
["authenticate", "authenticated"],
|
|
34
|
+
["register", "registered"],
|
|
35
|
+
["approve", "approved"],
|
|
36
|
+
["reject", "rejected"],
|
|
37
|
+
["revision", "needs_revision"],
|
|
38
|
+
["request_revision", "needs_revision"],
|
|
39
|
+
["submit", "submitted"],
|
|
40
|
+
["close", "closed"],
|
|
41
|
+
["complete", "completed"],
|
|
42
|
+
["archive", "archived"],
|
|
43
|
+
["delete", "deleted"],
|
|
44
|
+
[method === "POST" && id.startsWith("cap_create_") ? "create" : "", knownStates[0] || "created"]
|
|
45
|
+
].filter((/** @type {any} */ [needle]) => needle);
|
|
46
|
+
for (const [needle, state] of candidates) {
|
|
47
|
+
if (id.includes(needle) && state) {
|
|
48
|
+
const canonicalState = idHintify(state);
|
|
49
|
+
if (knownStates.length === 0 || knownStates.includes(canonicalState)) {
|
|
50
|
+
return canonicalState;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @param {WorkspacePaths} paths @returns {any} */
|
|
58
|
+
export function collectWorkflowImport(paths) {
|
|
59
|
+
/** @type {any[]} */
|
|
60
|
+
const findings = [];
|
|
61
|
+
/** @type {WorkflowRecord} */
|
|
62
|
+
const candidates = {
|
|
63
|
+
workflows: [],
|
|
64
|
+
workflow_states: [],
|
|
65
|
+
workflow_transitions: []
|
|
66
|
+
};
|
|
67
|
+
const dbImport = collectDbImport(paths);
|
|
68
|
+
const apiImport = collectApiImport(paths);
|
|
69
|
+
const docScan = scanDocsWorkflow(paths.topogramRoot).summary;
|
|
70
|
+
const enumCandidatesById = new Map((dbImport.candidates.enums || []).map((/** @type {any} */ entry) => [entry.id_hint, entry]));
|
|
71
|
+
const entityCandidatesById = new Map((dbImport.candidates.entities || []).map((/** @type {any} */ entry) => [entry.id_hint, entry]));
|
|
72
|
+
const workflowDocs = (docScan.candidate_docs || []).filter((/** @type {any} */ doc) => doc.kind === "workflow");
|
|
73
|
+
const workflows = new Map();
|
|
74
|
+
|
|
75
|
+
for (const capability of apiImport.candidates.capabilities || []) {
|
|
76
|
+
const entityId = workflowEntityIdForCapability(capability);
|
|
77
|
+
const workflowId = `workflow_${entityId.replace(/^entity_/, "")}`;
|
|
78
|
+
const capabilityActors =
|
|
79
|
+
capability.auth_hint === "secured" ? ["user"] :
|
|
80
|
+
capability.auth_hint === "public" ? ["anonymous"] :
|
|
81
|
+
[];
|
|
82
|
+
if (!workflows.has(workflowId)) {
|
|
83
|
+
const entity = entityCandidatesById.get(entityId);
|
|
84
|
+
const statusFields = findEntityStatusFields(entity, enumCandidatesById);
|
|
85
|
+
const states = statusFields.flatMap((/** @type {any} */ field) => enumCandidatesById.get(idHintify(field.field_type))?.values || []).map(idHintify);
|
|
86
|
+
workflows.set(workflowId, {
|
|
87
|
+
workflow: makeCandidateRecord({
|
|
88
|
+
kind: "workflow",
|
|
89
|
+
idHint: workflowId,
|
|
90
|
+
label: `${titleCase(entityId.replace(/^entity_/, ""))} Workflow`,
|
|
91
|
+
confidence: "medium",
|
|
92
|
+
sourceKind: "generated_artifact",
|
|
93
|
+
provenance: capability.provenance || [],
|
|
94
|
+
track: "workflows",
|
|
95
|
+
entity_id: entityId,
|
|
96
|
+
actor_hints: capabilityActors,
|
|
97
|
+
related_capabilities: []
|
|
98
|
+
}),
|
|
99
|
+
states: states.map((/** @type {any} */ state) =>
|
|
100
|
+
makeCandidateRecord({
|
|
101
|
+
kind: "workflow_state",
|
|
102
|
+
idHint: `${workflowId}_${state}`,
|
|
103
|
+
label: titleCase(state),
|
|
104
|
+
confidence: "medium",
|
|
105
|
+
sourceKind: "schema",
|
|
106
|
+
provenance: entity?.provenance || capability.provenance || [],
|
|
107
|
+
track: "workflows",
|
|
108
|
+
workflow_id: workflowId,
|
|
109
|
+
entity_id: entityId,
|
|
110
|
+
state_id: state
|
|
111
|
+
})
|
|
112
|
+
),
|
|
113
|
+
transitions: []
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const workflow = workflows.get(workflowId);
|
|
117
|
+
workflow.workflow.related_capabilities.push(capability.id_hint);
|
|
118
|
+
workflow.workflow.actor_hints = [...new Set([...(workflow.workflow.actor_hints || []), ...capabilityActors])].sort();
|
|
119
|
+
const knownStates = workflow.states.map((/** @type {any} */ entry) => entry.state_id);
|
|
120
|
+
const targetState = targetStateForCapability(capability, knownStates);
|
|
121
|
+
if (targetState) {
|
|
122
|
+
workflow.transitions.push(
|
|
123
|
+
makeCandidateRecord({
|
|
124
|
+
kind: "workflow_transition",
|
|
125
|
+
idHint: `${workflowId}_${idHintify(capability.id_hint)}`,
|
|
126
|
+
label: titleCase(capability.id_hint.replace(/^cap_/, "")),
|
|
127
|
+
confidence: "low",
|
|
128
|
+
sourceKind: capability.source_kind || "generated_artifact",
|
|
129
|
+
provenance: capability.provenance || [],
|
|
130
|
+
track: "workflows",
|
|
131
|
+
workflow_id: workflowId,
|
|
132
|
+
entity_id: entityId,
|
|
133
|
+
capability_id: capability.id_hint,
|
|
134
|
+
actor_hints: capabilityActors,
|
|
135
|
+
to_state: targetState
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const workflow of workflows.values()) {
|
|
142
|
+
workflow.workflow.related_capabilities = [...new Set(workflow.workflow.related_capabilities)].sort();
|
|
143
|
+
candidates.workflows.push(workflow.workflow);
|
|
144
|
+
candidates.workflow_states.push(...workflow.states);
|
|
145
|
+
candidates.workflow_transitions.push(...workflow.transitions);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
findings.push({
|
|
149
|
+
kind: "workflow_inference",
|
|
150
|
+
workflow_count: candidates.workflows.length,
|
|
151
|
+
workflow_doc_signals: workflowDocs.map((/** @type {any} */ doc) => doc.id)
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
candidates.workflows = dedupeCandidateRecords(candidates.workflows, (/** @type {any} */ record) => record.id_hint);
|
|
155
|
+
candidates.workflow_states = dedupeCandidateRecords(candidates.workflow_states, (/** @type {any} */ record) => record.id_hint);
|
|
156
|
+
candidates.workflow_transitions = dedupeCandidateRecords(candidates.workflow_transitions, (/** @type {any} */ record) => record.id_hint);
|
|
157
|
+
|
|
158
|
+
return { findings, candidates };
|
|
159
|
+
}
|