@deksden-com/dd-flow-cli 0.1.0 → 0.2.0
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/README.md +11 -0
- package/dist/build-info.json +11 -0
- package/dist/cli/help.js +63 -1
- package/dist/cli/run-cli.js +104 -0
- package/dist/schemas/archived-flow-manifest.schema.json +112 -0
- package/dist/schemas/merge-stage-report.schema.json +61 -1
- package/dist/schemas/plan-stage-report.schema.json +172 -0
- package/dist/schemas/project-flow-pack-manifest.schema.json +123 -0
- package/dist/schemas/status-report.schema.json +152 -0
- package/dist/services/build-info.js +91 -0
- package/dist/services/canon.js +227 -0
- package/dist/services/lanes.js +6 -2
- package/dist/services/merge-queue.js +59 -3
- package/dist/services/merge-worker.js +148 -0
- package/dist/services/protocols.js +12 -12
- package/dist/services/schema-validation.js +4 -5
- package/dist/services/sessions.js +3 -2
- package/dist/services/status.js +118 -0
- package/dist/services/version-status.js +258 -0
- package/dist/storage/database.js +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "dd-flow/plan-stage-report@1",
|
|
4
|
+
"title": "dd-flow plan stage report data",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"schema_id",
|
|
9
|
+
"generated_at",
|
|
10
|
+
"protocol",
|
|
11
|
+
"overall",
|
|
12
|
+
"route",
|
|
13
|
+
"graph",
|
|
14
|
+
"aspects",
|
|
15
|
+
"plan_items",
|
|
16
|
+
"handoff"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"schema_id": {
|
|
20
|
+
"const": "dd-flow/plan-stage-report@1"
|
|
21
|
+
},
|
|
22
|
+
"generated_at": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"format": "date-time"
|
|
25
|
+
},
|
|
26
|
+
"protocol": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"required": ["id", "title", "project", "branch", "stage"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"id": {"type": "string", "minLength": 1},
|
|
32
|
+
"title": {"type": "string", "minLength": 1},
|
|
33
|
+
"project": {"type": "string", "minLength": 1},
|
|
34
|
+
"branch": {"type": "string", "minLength": 1},
|
|
35
|
+
"stage": {"type": "string", "minLength": 1}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"overall": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"additionalProperties": false,
|
|
41
|
+
"required": ["verdict", "verdict_label", "score", "score_max", "next_action", "summary"],
|
|
42
|
+
"properties": {
|
|
43
|
+
"verdict": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"enum": ["plan_ready", "ready_for_code", "needs_user_decision", "plan_blocked", "degraded"]
|
|
46
|
+
},
|
|
47
|
+
"verdict_label": {"type": "string", "minLength": 1},
|
|
48
|
+
"score": {"type": "number", "minimum": 0},
|
|
49
|
+
"score_max": {"type": "number", "exclusiveMinimum": 0},
|
|
50
|
+
"next_action": {"type": "string", "minLength": 1},
|
|
51
|
+
"summary": {"type": "string", "minLength": 1}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"route": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"minItems": 1,
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"additionalProperties": false,
|
|
60
|
+
"required": ["label", "value", "note"],
|
|
61
|
+
"properties": {
|
|
62
|
+
"label": {"type": "string", "minLength": 1},
|
|
63
|
+
"value": {"type": "string", "minLength": 1},
|
|
64
|
+
"note": {"type": "string", "minLength": 1}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"graph": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"additionalProperties": false,
|
|
71
|
+
"required": ["nodes", "edges"],
|
|
72
|
+
"properties": {
|
|
73
|
+
"nodes": {
|
|
74
|
+
"type": "array",
|
|
75
|
+
"minItems": 1,
|
|
76
|
+
"items": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"required": ["id", "label", "x", "y", "status", "note"],
|
|
80
|
+
"properties": {
|
|
81
|
+
"id": {"type": "string", "minLength": 1},
|
|
82
|
+
"label": {"type": "string", "minLength": 1},
|
|
83
|
+
"x": {"type": "number"},
|
|
84
|
+
"y": {"type": "number"},
|
|
85
|
+
"status": {"type": "string", "enum": ["done", "ready", "watch", "next", "blocked", "skipped"]},
|
|
86
|
+
"note": {"type": "string", "minLength": 1}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"edges": {
|
|
91
|
+
"type": "array",
|
|
92
|
+
"items": {
|
|
93
|
+
"type": "array",
|
|
94
|
+
"items": [
|
|
95
|
+
{"type": "string", "minLength": 1},
|
|
96
|
+
{"type": "string", "minLength": 1}
|
|
97
|
+
],
|
|
98
|
+
"additionalItems": false,
|
|
99
|
+
"minItems": 2,
|
|
100
|
+
"maxItems": 2
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"aspects": {
|
|
106
|
+
"type": "array",
|
|
107
|
+
"minItems": 1,
|
|
108
|
+
"items": {
|
|
109
|
+
"type": "object",
|
|
110
|
+
"additionalProperties": false,
|
|
111
|
+
"required": ["id", "label", "score", "status", "summary", "note", "findings"],
|
|
112
|
+
"properties": {
|
|
113
|
+
"id": {"type": "string", "minLength": 1},
|
|
114
|
+
"label": {"type": "string", "minLength": 1},
|
|
115
|
+
"radar_label": {"type": "string"},
|
|
116
|
+
"relevance": {"type": "string", "enum": ["not_applicable", "light", "deep", "unknown"]},
|
|
117
|
+
"coverage_mode": {"type": "string", "enum": ["orchestrator", "subagent", "grouped_subagent", "degraded"]},
|
|
118
|
+
"subagent_id": {"type": "string"},
|
|
119
|
+
"group_id": {"type": "string"},
|
|
120
|
+
"report_path": {"type": "string"},
|
|
121
|
+
"not_applicable_reason": {"type": "string"},
|
|
122
|
+
"score": {"type": "number", "minimum": 0, "maximum": 5},
|
|
123
|
+
"status": {"type": "string", "enum": ["reviewed", "watch", "blocked", "not_applicable", "degraded"]},
|
|
124
|
+
"summary": {"type": "string", "minLength": 1},
|
|
125
|
+
"note": {"type": "string", "minLength": 1},
|
|
126
|
+
"findings": {
|
|
127
|
+
"type": "array",
|
|
128
|
+
"items": {"type": "string", "minLength": 1}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"plan_items": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"minItems": 1,
|
|
136
|
+
"items": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"additionalProperties": false,
|
|
139
|
+
"required": ["id", "title", "owner", "status", "depends_on", "verification", "note", "details"],
|
|
140
|
+
"properties": {
|
|
141
|
+
"id": {"type": "string", "minLength": 1},
|
|
142
|
+
"title": {"type": "string", "minLength": 1},
|
|
143
|
+
"owner": {"type": "string", "minLength": 1},
|
|
144
|
+
"status": {"type": "string", "enum": ["ready", "watch", "blocked", "done", "skipped"]},
|
|
145
|
+
"depends_on": {
|
|
146
|
+
"type": "array",
|
|
147
|
+
"items": {"type": "string", "minLength": 1}
|
|
148
|
+
},
|
|
149
|
+
"verification": {"type": "string", "minLength": 1},
|
|
150
|
+
"note": {"type": "string", "minLength": 1},
|
|
151
|
+
"details": {
|
|
152
|
+
"type": "array",
|
|
153
|
+
"items": {"type": "string", "minLength": 1}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"handoff": {
|
|
159
|
+
"type": "object",
|
|
160
|
+
"additionalProperties": false,
|
|
161
|
+
"required": ["code_prompt", "must_read", "next_gate"],
|
|
162
|
+
"properties": {
|
|
163
|
+
"code_prompt": {"type": "string", "minLength": 1},
|
|
164
|
+
"must_read": {
|
|
165
|
+
"type": "array",
|
|
166
|
+
"items": {"type": "string", "minLength": 1}
|
|
167
|
+
},
|
|
168
|
+
"next_gate": {"type": "string", "minLength": 1}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "dd-flow/project-flow-pack-manifest@2",
|
|
4
|
+
"title": "Project flow pack manifest",
|
|
5
|
+
"description": "Manifest for the curated project-local dd-flow pack installed under .memory-bank/dd-flow/.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"schema_id",
|
|
10
|
+
"pack_version",
|
|
11
|
+
"flow_origin_policy",
|
|
12
|
+
"canon_root",
|
|
13
|
+
"canon_flow_root",
|
|
14
|
+
"source_commit",
|
|
15
|
+
"installed_at",
|
|
16
|
+
"included_files",
|
|
17
|
+
"excluded_canonical_only_flows"
|
|
18
|
+
],
|
|
19
|
+
"properties": {
|
|
20
|
+
"schema_id": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["dd-flow/project-flow-pack-manifest@1", "dd-flow/project-flow-pack-manifest@2"]
|
|
23
|
+
},
|
|
24
|
+
"pack_version": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"minLength": 1
|
|
27
|
+
},
|
|
28
|
+
"flow_origin_policy": {
|
|
29
|
+
"const": "project_local_pack"
|
|
30
|
+
},
|
|
31
|
+
"canon_root": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"minLength": 1
|
|
34
|
+
},
|
|
35
|
+
"canon_flow_root": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"minLength": 1
|
|
38
|
+
},
|
|
39
|
+
"source_commit": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"minLength": 7
|
|
42
|
+
},
|
|
43
|
+
"canon_version_at_source_commit": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"minLength": 1
|
|
46
|
+
},
|
|
47
|
+
"canon_version": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"minLength": 1
|
|
50
|
+
},
|
|
51
|
+
"flow_contract": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"minLength": 1
|
|
54
|
+
},
|
|
55
|
+
"installed_at": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"minLength": 1
|
|
58
|
+
},
|
|
59
|
+
"included_files": {
|
|
60
|
+
"type": "array",
|
|
61
|
+
"minItems": 1,
|
|
62
|
+
"uniqueItems": true,
|
|
63
|
+
"items": {
|
|
64
|
+
"$ref": "#/definitions/projectLocalFile"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"file_hashes": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"additionalProperties": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"minLength": 1
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"excluded_canonical_only_flows": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"minItems": 4,
|
|
77
|
+
"uniqueItems": true,
|
|
78
|
+
"items": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"enum": ["mb-init.md", "mb-upgrade.md", "mb-upgrade-review.md", "mb-distill.md"]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"generated_allow_patterns": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"items": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"minLength": 1
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"notes": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"allOf": [
|
|
95
|
+
{
|
|
96
|
+
"if": {
|
|
97
|
+
"properties": {
|
|
98
|
+
"schema_id": {
|
|
99
|
+
"const": "dd-flow/project-flow-pack-manifest@2"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"then": {
|
|
104
|
+
"required": ["canon_version_at_source_commit", "flow_contract"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"definitions": {
|
|
109
|
+
"projectLocalFile": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"minLength": 1,
|
|
112
|
+
"pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*//)(?!manifest\\.json$)[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*$",
|
|
113
|
+
"not": {
|
|
114
|
+
"anyOf": [
|
|
115
|
+
{ "pattern": "^(mb-init|mb-upgrade|mb-upgrade-review|mb-distill)\\.md$" },
|
|
116
|
+
{ "pattern": "^(mb-init|mb-upgrade|mb-upgrade-review|mb-distill)/" },
|
|
117
|
+
{ "pattern": "^experiments/" },
|
|
118
|
+
{ "pattern": "^evals/" }
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "dd-flow/status-report@1",
|
|
4
|
+
"title": "dd-flow status report",
|
|
5
|
+
"description": "Read-only status contract for CLI/canon/project Memory Bank version visibility and drift diagnostics.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": true,
|
|
8
|
+
"required": ["ok", "schema_id", "dd_flow_home", "cwd", "cli", "project", "canon"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"ok": { "type": "boolean" },
|
|
11
|
+
"schema_id": { "const": "dd-flow/status-report@1" },
|
|
12
|
+
"dd_flow_home": { "type": "string", "minLength": 1 },
|
|
13
|
+
"cwd": { "type": "string", "minLength": 1 },
|
|
14
|
+
"cli": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"additionalProperties": true,
|
|
17
|
+
"required": ["version", "package_name", "build"],
|
|
18
|
+
"properties": {
|
|
19
|
+
"version": { "type": "string", "minLength": 1 },
|
|
20
|
+
"package_name": { "type": "string", "minLength": 1 },
|
|
21
|
+
"build": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"additionalProperties": true,
|
|
24
|
+
"required": ["status", "built_with_canon"],
|
|
25
|
+
"properties": {
|
|
26
|
+
"status": { "type": "string", "enum": ["present", "degraded"] },
|
|
27
|
+
"built_at": { "type": ["string", "null"] },
|
|
28
|
+
"commit": { "type": ["string", "null"] },
|
|
29
|
+
"reason": { "type": "string" },
|
|
30
|
+
"built_with_canon": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"additionalProperties": true,
|
|
33
|
+
"required": ["version", "commit", "flow_contract", "status"],
|
|
34
|
+
"properties": {
|
|
35
|
+
"version": { "type": ["string", "null"] },
|
|
36
|
+
"commit": { "type": ["string", "null"] },
|
|
37
|
+
"flow_contract": { "type": ["string", "null"] },
|
|
38
|
+
"status": { "type": "string", "enum": ["present", "unknown", "degraded"] },
|
|
39
|
+
"reason": { "type": "string" }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"project": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"additionalProperties": true,
|
|
49
|
+
"required": ["requested_root", "root", "root_source", "registered", "memory_bank", "flow_pack", "drift"],
|
|
50
|
+
"properties": {
|
|
51
|
+
"requested_root": { "type": "string", "minLength": 1 },
|
|
52
|
+
"root": { "type": ["string", "null"] },
|
|
53
|
+
"root_source": { "type": "string", "enum": ["explicit", "git", "cwd"] },
|
|
54
|
+
"registered": { "type": "boolean" },
|
|
55
|
+
"id": { "type": ["string", "null"] },
|
|
56
|
+
"status": { "type": ["string", "null"] },
|
|
57
|
+
"memory_bank": { "$ref": "#/definitions/memoryBank" },
|
|
58
|
+
"flow_pack": { "$ref": "#/definitions/flowPack" },
|
|
59
|
+
"drift": { "$ref": "#/definitions/drift" }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"canon": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"additionalProperties": true,
|
|
65
|
+
"required": ["ok", "resolved", "compatibility"],
|
|
66
|
+
"properties": {
|
|
67
|
+
"ok": { "type": "boolean" },
|
|
68
|
+
"resolved": {
|
|
69
|
+
"type": ["object", "null"],
|
|
70
|
+
"additionalProperties": true
|
|
71
|
+
},
|
|
72
|
+
"compatibility": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": true,
|
|
75
|
+
"required": ["cli_built_with_resolved_canon", "reason"],
|
|
76
|
+
"properties": {
|
|
77
|
+
"cli_built_with_resolved_canon": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"enum": ["same", "behind", "ahead", "unknown"]
|
|
80
|
+
},
|
|
81
|
+
"reason": { "type": "string", "minLength": 1 }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"definitions": {
|
|
88
|
+
"memoryBank": {
|
|
89
|
+
"type": ["object", "null"],
|
|
90
|
+
"additionalProperties": true,
|
|
91
|
+
"required": ["root", "folder_name", "version", "source", "status"],
|
|
92
|
+
"properties": {
|
|
93
|
+
"root": { "type": ["string", "null"] },
|
|
94
|
+
"folder_name": { "type": ["string", "null"], "enum": [".memory-bank", "memory-bank", null] },
|
|
95
|
+
"version": { "type": ["string", "null"] },
|
|
96
|
+
"source": { "type": ["string", "null"] },
|
|
97
|
+
"status": { "type": "string", "enum": ["present", "missing", "invalid", "unknown"] },
|
|
98
|
+
"reason": { "type": "string" }
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"flowPack": {
|
|
102
|
+
"type": ["object", "null"],
|
|
103
|
+
"additionalProperties": true,
|
|
104
|
+
"required": ["manifest_path", "schema_id", "pack_version", "source_commit", "canon_version_at_source_commit", "status", "canonical_only_files"],
|
|
105
|
+
"properties": {
|
|
106
|
+
"manifest_path": { "type": ["string", "null"] },
|
|
107
|
+
"schema_id": { "type": ["string", "null"] },
|
|
108
|
+
"pack_version": { "type": ["string", "null"] },
|
|
109
|
+
"source_commit": { "type": ["string", "null"] },
|
|
110
|
+
"canon_version_at_source_commit": { "type": ["string", "null"] },
|
|
111
|
+
"status": { "type": "string", "enum": ["present", "missing", "invalid", "degraded"] },
|
|
112
|
+
"reason": { "type": "string" },
|
|
113
|
+
"canonical_only_files": {
|
|
114
|
+
"type": "array",
|
|
115
|
+
"items": { "type": "string", "minLength": 1 }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"drift": {
|
|
120
|
+
"type": ["object", "null"],
|
|
121
|
+
"additionalProperties": true,
|
|
122
|
+
"required": ["memory_bank_version", "flow_pack_commit", "overall", "next_action"],
|
|
123
|
+
"properties": {
|
|
124
|
+
"memory_bank_version": { "$ref": "#/definitions/comparison" },
|
|
125
|
+
"flow_pack_commit": { "$ref": "#/definitions/comparison" },
|
|
126
|
+
"overall": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"enum": ["same", "behind", "ahead", "diverged", "missing", "invalid", "unknown", "not_applicable"]
|
|
129
|
+
},
|
|
130
|
+
"next_action": { "type": "string", "minLength": 1 }
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"comparison": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"additionalProperties": true,
|
|
136
|
+
"required": ["status", "confidence", "reason"],
|
|
137
|
+
"properties": {
|
|
138
|
+
"status": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"enum": ["same", "behind", "ahead", "diverged", "missing", "invalid", "unknown", "not_applicable"]
|
|
141
|
+
},
|
|
142
|
+
"confidence": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"enum": ["exact", "semver", "git_ancestry", "declared", "none"]
|
|
145
|
+
},
|
|
146
|
+
"reason": { "type": "string", "minLength": 1 },
|
|
147
|
+
"current": { "type": ["string", "null"] },
|
|
148
|
+
"target": { "type": ["string", "null"] }
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
export function getCliBuildInfo() {
|
|
5
|
+
const packageRoot = findPackageRoot(path.dirname(fileURLToPath(import.meta.url)));
|
|
6
|
+
const packageJson = readPackageJson(packageRoot);
|
|
7
|
+
const version = stringOr(packageJson.version, "0.0.0");
|
|
8
|
+
const packageName = stringOr(packageJson.name, "dd-flow-cli");
|
|
9
|
+
const buildInfoPath = packageRoot ? path.join(packageRoot, "dist", "build-info.json") : null;
|
|
10
|
+
const buildInfo = buildInfoPath && fs.existsSync(buildInfoPath) ? readBuildInfo(buildInfoPath) : null;
|
|
11
|
+
if (!buildInfo) {
|
|
12
|
+
return {
|
|
13
|
+
version,
|
|
14
|
+
package_name: packageName,
|
|
15
|
+
build: {
|
|
16
|
+
status: "degraded",
|
|
17
|
+
built_at: null,
|
|
18
|
+
commit: null,
|
|
19
|
+
reason: "build_info_missing",
|
|
20
|
+
built_with_canon: {
|
|
21
|
+
version: null,
|
|
22
|
+
commit: null,
|
|
23
|
+
flow_contract: null,
|
|
24
|
+
status: "unknown",
|
|
25
|
+
reason: "build_info_missing"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const builtWithCanon = asRecord(buildInfo.built_with_canon);
|
|
31
|
+
const canonVersion = stringOrNull(builtWithCanon?.version);
|
|
32
|
+
const canonCommit = stringOrNull(builtWithCanon?.commit);
|
|
33
|
+
const flowContract = stringOrNull(builtWithCanon?.flow_contract);
|
|
34
|
+
const canonStatus = canonVersion && canonCommit ? "present" : "degraded";
|
|
35
|
+
return {
|
|
36
|
+
version: stringOr(buildInfo.cli_version, version),
|
|
37
|
+
package_name: stringOr(buildInfo.cli_package, packageName),
|
|
38
|
+
build: {
|
|
39
|
+
status: "present",
|
|
40
|
+
built_at: stringOrNull(buildInfo.built_at),
|
|
41
|
+
commit: stringOrNull(buildInfo.cli_commit),
|
|
42
|
+
built_with_canon: {
|
|
43
|
+
version: canonVersion,
|
|
44
|
+
commit: canonCommit,
|
|
45
|
+
flow_contract: flowContract,
|
|
46
|
+
status: canonStatus,
|
|
47
|
+
...(canonStatus === "degraded" ? { reason: "build_canon_metadata_incomplete" } : {})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function findPackageRoot(start) {
|
|
53
|
+
let current = path.resolve(start);
|
|
54
|
+
while (true) {
|
|
55
|
+
const candidate = path.join(current, "package.json");
|
|
56
|
+
if (fs.existsSync(candidate))
|
|
57
|
+
return current;
|
|
58
|
+
const parent = path.dirname(current);
|
|
59
|
+
if (parent === current)
|
|
60
|
+
return null;
|
|
61
|
+
current = parent;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function readPackageJson(packageRoot) {
|
|
65
|
+
if (!packageRoot)
|
|
66
|
+
return {};
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function readBuildInfo(file) {
|
|
75
|
+
try {
|
|
76
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
77
|
+
return asRecord(parsed) ? parsed : null;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function asRecord(value) {
|
|
84
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
85
|
+
}
|
|
86
|
+
function stringOr(value, fallback) {
|
|
87
|
+
return typeof value === "string" && value.length > 0 ? value : fallback;
|
|
88
|
+
}
|
|
89
|
+
function stringOrNull(value) {
|
|
90
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
91
|
+
}
|