storybook-addon-designbook 0.4.0 → 0.7.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/dist/cli.js +261 -181
- package/dist/components/pages/DeboSectionPage.js +36 -112
- package/dist/index.js +14 -34
- package/dist/manager.js +15 -24
- package/dist/preset.js +325 -67
- package/dist/preview.js +11 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as actualFS from 'fs';
|
|
3
3
|
import { readFileSync, existsSync, readdirSync, mkdirSync, appendFileSync, renameSync, writeFileSync, statSync, unlinkSync, openSync, closeSync, realpathSync as realpathSync$1, readlinkSync, readdir as readdir$1, lstatSync } from 'fs';
|
|
4
|
+
import { resolve, dirname, basename, parse, join, extname as extname$1, delimiter, relative, win32, posix } from 'path';
|
|
4
5
|
import { load, dump } from 'js-yaml';
|
|
5
|
-
import
|
|
6
|
-
import jsonata9 from 'jsonata';
|
|
6
|
+
import jsonata6 from 'jsonata';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
8
8
|
import Stream from 'stream';
|
|
9
9
|
import { StringDecoder } from 'string_decoder';
|
|
@@ -28,27 +28,73 @@ var __export = (target, all) => {
|
|
|
28
28
|
for (var name in all)
|
|
29
29
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
30
30
|
};
|
|
31
|
-
function
|
|
31
|
+
function namespaceFor(dataModel, entityType, bundle) {
|
|
32
|
+
if (dataModel.content?.[entityType]?.[bundle]) return "content";
|
|
33
|
+
if (dataModel.config?.[entityType]?.[bundle]) return "config";
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function readBundleFiles(dataDir) {
|
|
37
|
+
if (!existsSync(dataDir)) return [];
|
|
38
|
+
const out2 = [];
|
|
39
|
+
for (const file of readdirSync(dataDir)) {
|
|
40
|
+
if (!file.endsWith(".yml")) continue;
|
|
41
|
+
const base = file.slice(0, -".yml".length);
|
|
42
|
+
const dot = base.indexOf(".");
|
|
43
|
+
if (dot < 1) {
|
|
44
|
+
console.warn(`[Designbook] data/${file}: name must be <entity_type>.<bundle>.yml \u2014 skipped`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const records = load(readFileSync(join(dataDir, file), "utf-8"));
|
|
48
|
+
if (!Array.isArray(records)) {
|
|
49
|
+
console.warn(`[Designbook] data/${file}: expected a record array \u2014 skipped`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
out2.push({
|
|
53
|
+
entityType: base.slice(0, dot),
|
|
54
|
+
bundle: base.slice(dot + 1),
|
|
55
|
+
records
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return out2;
|
|
59
|
+
}
|
|
60
|
+
var init_data_pool = __esm({
|
|
61
|
+
"src/renderer/data-pool.ts"() {
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
function validateDesignbookSection(rec, entityType, bundle, errors) {
|
|
65
|
+
const meta = rec.__designbook;
|
|
66
|
+
const sec = meta?.section;
|
|
67
|
+
const okSection = typeof sec === "string" || Array.isArray(sec) && sec.every((s) => typeof s === "string");
|
|
68
|
+
if (sec !== void 0 && !okSection) {
|
|
69
|
+
const rid = rec.id ?? "?";
|
|
70
|
+
errors.push(`Invalid __designbook.section on ${entityType}.${bundle} id=${rid} \u2014 must be string or string[]`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function validateData(dataModelPath, dataDir) {
|
|
32
74
|
const errors = [];
|
|
33
75
|
const warnings = [];
|
|
34
76
|
if (!existsSync(dataModelPath)) {
|
|
35
77
|
return { valid: false, errors: [`data-model.yml not found: ${dataModelPath}`], warnings: [] };
|
|
36
78
|
}
|
|
37
|
-
if (!existsSync(
|
|
38
|
-
return { valid: false, errors: [`data
|
|
79
|
+
if (!existsSync(dataDir)) {
|
|
80
|
+
return { valid: false, errors: [`data/ directory not found: ${dataDir}`], warnings: [] };
|
|
39
81
|
}
|
|
40
82
|
const dataModel = load(readFileSync(dataModelPath, "utf-8"));
|
|
41
|
-
const
|
|
83
|
+
const contentData = {};
|
|
84
|
+
const configData = {};
|
|
85
|
+
for (const { entityType, bundle, records } of readBundleFiles(dataDir)) {
|
|
86
|
+
if (dataModel.content?.[entityType]) {
|
|
87
|
+
(contentData[entityType] ??= {})[bundle] = records;
|
|
88
|
+
} else if (dataModel.config?.[entityType]) {
|
|
89
|
+
(configData[entityType] ??= {})[bundle] = records;
|
|
90
|
+
} else {
|
|
91
|
+
errors.push(`Entity type "${entityType}" not in data-model`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
42
94
|
const contentModel = dataModel.content ?? {};
|
|
43
95
|
const configModel = dataModel.config ?? {};
|
|
44
|
-
const contentData = sampleData.content ?? {};
|
|
45
|
-
const configData = sampleData.config ?? {};
|
|
46
96
|
for (const [entityType, bundles] of Object.entries(contentData)) {
|
|
47
97
|
if (typeof bundles !== "object" || bundles === null) continue;
|
|
48
|
-
if (!(entityType in contentModel)) {
|
|
49
|
-
errors.push(`Entity type "${entityType}" not in data-model`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
98
|
for (const [bundle, records] of Object.entries(bundles)) {
|
|
53
99
|
if (!Array.isArray(records)) continue;
|
|
54
100
|
if (!(bundle in contentModel[entityType])) {
|
|
@@ -60,6 +106,10 @@ function validateData(dataModelPath, dataPath) {
|
|
|
60
106
|
const rid = rec.id ?? "?";
|
|
61
107
|
for (const field of Object.keys(rec)) {
|
|
62
108
|
if (field === "id") continue;
|
|
109
|
+
if (field === "__designbook") {
|
|
110
|
+
validateDesignbookSection(rec, entityType, bundle, errors);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
63
113
|
if (!(field in dmFields)) {
|
|
64
114
|
warnings.push(`Field "${field}" on ${entityType}.${bundle} id=${rid} not in data-model`);
|
|
65
115
|
continue;
|
|
@@ -96,9 +146,15 @@ function validateData(dataModelPath, dataPath) {
|
|
|
96
146
|
errors.push(`Config entity type "${entityType}" not in data-model config`);
|
|
97
147
|
continue;
|
|
98
148
|
}
|
|
99
|
-
for (const [bundle] of Object.entries(bundles)) {
|
|
149
|
+
for (const [bundle, records] of Object.entries(bundles)) {
|
|
100
150
|
if (!(bundle in configModel[entityType])) {
|
|
101
151
|
errors.push(`Config bundle "${entityType}.${bundle}" not in data-model config`);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (Array.isArray(records)) {
|
|
155
|
+
for (const rec of records) {
|
|
156
|
+
validateDesignbookSection(rec, entityType, bundle, errors);
|
|
157
|
+
}
|
|
102
158
|
}
|
|
103
159
|
}
|
|
104
160
|
}
|
|
@@ -106,6 +162,7 @@ function validateData(dataModelPath, dataPath) {
|
|
|
106
162
|
}
|
|
107
163
|
var init_data = __esm({
|
|
108
164
|
"src/validators/data.ts"() {
|
|
165
|
+
init_data_pool();
|
|
109
166
|
}
|
|
110
167
|
});
|
|
111
168
|
|
|
@@ -135,7 +192,7 @@ async function validateEntityMapping(file, config) {
|
|
|
135
192
|
}
|
|
136
193
|
let compiled;
|
|
137
194
|
try {
|
|
138
|
-
compiled =
|
|
195
|
+
compiled = jsonata6(expression);
|
|
139
196
|
} catch (err) {
|
|
140
197
|
return { valid: false, errors: [`JSONata parse error: ${err.message}`], warnings: [] };
|
|
141
198
|
}
|
|
@@ -143,34 +200,13 @@ async function validateEntityMapping(file, config) {
|
|
|
143
200
|
const parts = fileName.split(".");
|
|
144
201
|
const targetEntityType = parts.length >= 3 ? parts[0] : void 0;
|
|
145
202
|
const targetBundle = parts.length >= 3 ? parts[1] : void 0;
|
|
146
|
-
const
|
|
147
|
-
const sectionsDir = resolve(config.data, "sections");
|
|
148
|
-
if (existsSync(sectionsDir)) {
|
|
149
|
-
for (const entry of readdirSync(sectionsDir, { withFileTypes: true })) {
|
|
150
|
-
if (entry.isDirectory()) {
|
|
151
|
-
const sectionData = join(sectionsDir, entry.name, "data.yml");
|
|
152
|
-
if (existsSync(sectionData)) dataPaths.push(sectionData);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const rootData = resolve(config.data, "data.yml");
|
|
157
|
-
if (existsSync(rootData)) dataPaths.push(rootData);
|
|
158
|
-
if (dataPaths.length === 0) {
|
|
159
|
-
return { valid: false, errors: [`No sample data found in sections or at ${rootData}`], warnings: [] };
|
|
160
|
-
}
|
|
203
|
+
const dataDir = resolve(config.data, "data");
|
|
161
204
|
const mergedMap = {};
|
|
162
|
-
for (const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (!mergedMap[entityType]) mergedMap[entityType] = {};
|
|
168
|
-
for (const [bundle, records] of Object.entries(bundles)) {
|
|
169
|
-
if (!Array.isArray(records)) continue;
|
|
170
|
-
if (!mergedMap[entityType][bundle]) mergedMap[entityType][bundle] = [];
|
|
171
|
-
mergedMap[entityType][bundle].push(...records);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
205
|
+
for (const { entityType, bundle, records } of readBundleFiles(dataDir)) {
|
|
206
|
+
(mergedMap[entityType] ??= {})[bundle] = records;
|
|
207
|
+
}
|
|
208
|
+
if (Object.keys(mergedMap).length === 0) {
|
|
209
|
+
return { valid: false, errors: [`No sample data found in ${dataDir}`], warnings: [] };
|
|
174
210
|
}
|
|
175
211
|
const errors = [];
|
|
176
212
|
let recordsTested = 0;
|
|
@@ -208,6 +244,7 @@ async function validateEntityMapping(file, config) {
|
|
|
208
244
|
}
|
|
209
245
|
var init_entity_mapping = __esm({
|
|
210
246
|
"src/validators/entity-mapping.ts"() {
|
|
247
|
+
init_data_pool();
|
|
211
248
|
}
|
|
212
249
|
});
|
|
213
250
|
|
|
@@ -5771,6 +5808,47 @@ var init_scene_metadata = __esm({
|
|
|
5771
5808
|
"src/renderer/scene-metadata.ts"() {
|
|
5772
5809
|
}
|
|
5773
5810
|
});
|
|
5811
|
+
function normalizeUrl(url2) {
|
|
5812
|
+
return url2.toLowerCase().replace(/\/+$/, "");
|
|
5813
|
+
}
|
|
5814
|
+
function hashReferenceUrl(url2) {
|
|
5815
|
+
const normalized = normalizeUrl(url2);
|
|
5816
|
+
return createHash("sha256").update(normalized).digest("hex").slice(0, 12);
|
|
5817
|
+
}
|
|
5818
|
+
var referenceFolderResolver;
|
|
5819
|
+
var init_reference_folder = __esm({
|
|
5820
|
+
"src/resolvers/reference-folder.ts"() {
|
|
5821
|
+
referenceFolderResolver = {
|
|
5822
|
+
name: "reference_folder",
|
|
5823
|
+
resolve(_input, config, context2) {
|
|
5824
|
+
const fromParam = config.from;
|
|
5825
|
+
if (!fromParam) {
|
|
5826
|
+
return {
|
|
5827
|
+
resolved: false,
|
|
5828
|
+
input: "",
|
|
5829
|
+
error: 'Missing "from" field in resolver config'
|
|
5830
|
+
};
|
|
5831
|
+
}
|
|
5832
|
+
const url2 = context2.params[fromParam];
|
|
5833
|
+
if (typeof url2 !== "string" || url2 === "") {
|
|
5834
|
+
return {
|
|
5835
|
+
resolved: false,
|
|
5836
|
+
input: "",
|
|
5837
|
+
error: `Parameter "${fromParam}" is missing or empty`
|
|
5838
|
+
};
|
|
5839
|
+
}
|
|
5840
|
+
const hash = hashReferenceUrl(url2);
|
|
5841
|
+
const folder = resolve(context2.config.data, "references", hash);
|
|
5842
|
+
mkdirSync(folder, { recursive: true });
|
|
5843
|
+
return {
|
|
5844
|
+
resolved: true,
|
|
5845
|
+
value: folder,
|
|
5846
|
+
input: url2
|
|
5847
|
+
};
|
|
5848
|
+
}
|
|
5849
|
+
};
|
|
5850
|
+
}
|
|
5851
|
+
});
|
|
5774
5852
|
function sanitize(str) {
|
|
5775
5853
|
return str.toLowerCase().replace(/[ '–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>{}[\]\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
5776
5854
|
}
|
|
@@ -5818,6 +5896,7 @@ var init_story_entity = __esm({
|
|
|
5818
5896
|
"src/story-entity.ts"() {
|
|
5819
5897
|
init_esm4();
|
|
5820
5898
|
init_scene_metadata();
|
|
5899
|
+
init_reference_folder();
|
|
5821
5900
|
StoryMeta = class _StoryMeta {
|
|
5822
5901
|
storyId;
|
|
5823
5902
|
section;
|
|
@@ -5966,11 +6045,26 @@ var init_story_entity = __esm({
|
|
|
5966
6045
|
// Serialization
|
|
5967
6046
|
// -------------------------------------------------------------------------
|
|
5968
6047
|
toJSON() {
|
|
6048
|
+
const breakpoints2 = {};
|
|
6049
|
+
const bpData = this._meta.reference?.breakpoints ?? {};
|
|
6050
|
+
for (const [bp2, cfg] of Object.entries(bpData)) {
|
|
6051
|
+
const regions = {};
|
|
6052
|
+
for (const [id, region] of Object.entries(cfg.regions ?? {})) {
|
|
6053
|
+
regions[id] = {
|
|
6054
|
+
selector: region.selector ?? "",
|
|
6055
|
+
reference_selector: region.reference_selector ?? ""
|
|
6056
|
+
};
|
|
6057
|
+
}
|
|
6058
|
+
breakpoints2[bp2] = { threshold: cfg.threshold ?? null, regions };
|
|
6059
|
+
}
|
|
6060
|
+
const referenceDir = this.reference.url ? `references/${hashReferenceUrl(this.reference.url)}` : null;
|
|
5969
6061
|
return {
|
|
5970
6062
|
storyId: this.storyId,
|
|
5971
6063
|
section: this.section,
|
|
5972
6064
|
storyDir: this.storyDir,
|
|
5973
|
-
reference: this.reference
|
|
6065
|
+
reference: this.reference,
|
|
6066
|
+
referenceDir,
|
|
6067
|
+
breakpoints: breakpoints2
|
|
5974
6068
|
};
|
|
5975
6069
|
}
|
|
5976
6070
|
// -------------------------------------------------------------------------
|
|
@@ -6196,47 +6290,6 @@ var init_story_url = __esm({
|
|
|
6196
6290
|
};
|
|
6197
6291
|
}
|
|
6198
6292
|
});
|
|
6199
|
-
function normalizeUrl(url2) {
|
|
6200
|
-
return url2.toLowerCase().replace(/\/+$/, "");
|
|
6201
|
-
}
|
|
6202
|
-
function hashUrl(url2) {
|
|
6203
|
-
const normalized = normalizeUrl(url2);
|
|
6204
|
-
return createHash("sha256").update(normalized).digest("hex").slice(0, 12);
|
|
6205
|
-
}
|
|
6206
|
-
var referenceFolderResolver;
|
|
6207
|
-
var init_reference_folder = __esm({
|
|
6208
|
-
"src/resolvers/reference-folder.ts"() {
|
|
6209
|
-
referenceFolderResolver = {
|
|
6210
|
-
name: "reference_folder",
|
|
6211
|
-
resolve(_input, config, context2) {
|
|
6212
|
-
const fromParam = config.from;
|
|
6213
|
-
if (!fromParam) {
|
|
6214
|
-
return {
|
|
6215
|
-
resolved: false,
|
|
6216
|
-
input: "",
|
|
6217
|
-
error: 'Missing "from" field in resolver config'
|
|
6218
|
-
};
|
|
6219
|
-
}
|
|
6220
|
-
const url2 = context2.params[fromParam];
|
|
6221
|
-
if (typeof url2 !== "string" || url2 === "") {
|
|
6222
|
-
return {
|
|
6223
|
-
resolved: false,
|
|
6224
|
-
input: "",
|
|
6225
|
-
error: `Parameter "${fromParam}" is missing or empty`
|
|
6226
|
-
};
|
|
6227
|
-
}
|
|
6228
|
-
const hash = hashUrl(url2);
|
|
6229
|
-
const folder = resolve(context2.config.data, "references", hash);
|
|
6230
|
-
mkdirSync(folder, { recursive: true });
|
|
6231
|
-
return {
|
|
6232
|
-
resolved: true,
|
|
6233
|
-
value: folder,
|
|
6234
|
-
input: url2
|
|
6235
|
-
};
|
|
6236
|
-
}
|
|
6237
|
-
};
|
|
6238
|
-
}
|
|
6239
|
-
});
|
|
6240
6293
|
function breakpointsFromMeta(context2, config) {
|
|
6241
6294
|
const fromParam = typeof config.from === "string" ? config.from : void 0;
|
|
6242
6295
|
if (!fromParam) return null;
|
|
@@ -7076,11 +7129,11 @@ var init_features = __esm({
|
|
|
7076
7129
|
"src/config/features.ts"() {
|
|
7077
7130
|
}
|
|
7078
7131
|
});
|
|
7079
|
-
function
|
|
7132
|
+
function hashUrl(url2) {
|
|
7080
7133
|
return createHash("sha256").update(url2.toLowerCase().replace(/\/+$/, "")).digest("hex").slice(0, 12);
|
|
7081
7134
|
}
|
|
7082
7135
|
function referenceFolder(url2, dataDir) {
|
|
7083
|
-
return resolve(dataDir, "references",
|
|
7136
|
+
return resolve(dataDir, "references", hashUrl(url2));
|
|
7084
7137
|
}
|
|
7085
7138
|
var regionPropertiesResolver;
|
|
7086
7139
|
var init_region_properties = __esm({
|
|
@@ -7126,7 +7179,8 @@ var init_region_properties = __esm({
|
|
|
7126
7179
|
console.warn(`[region-properties] failed to read ${sourcePath}: ${error.message}`);
|
|
7127
7180
|
return { resolved: true, value: void 0, input: url2 };
|
|
7128
7181
|
}
|
|
7129
|
-
const
|
|
7182
|
+
const selector = context2.params.selector;
|
|
7183
|
+
const label = typeof selector === "string" && selector.trim() ? selector.trim() : pickRegionLabel(context2.params);
|
|
7130
7184
|
const region = locateRegion(captured, label);
|
|
7131
7185
|
return { resolved: true, value: region, input: url2 };
|
|
7132
7186
|
}
|
|
@@ -7185,7 +7239,7 @@ async function resolveParams(schema, context2) {
|
|
|
7185
7239
|
if (decl.from) {
|
|
7186
7240
|
let fromValue;
|
|
7187
7241
|
try {
|
|
7188
|
-
fromValue = await
|
|
7242
|
+
fromValue = await jsonata6(decl.from).evaluate(outputParams);
|
|
7189
7243
|
} catch (err) {
|
|
7190
7244
|
unresolved[key] = {
|
|
7191
7245
|
resolved: false,
|
|
@@ -7295,23 +7349,7 @@ function expandEntries(entries) {
|
|
|
7295
7349
|
if (!entry || typeof entry !== "object") {
|
|
7296
7350
|
continue;
|
|
7297
7351
|
}
|
|
7298
|
-
|
|
7299
|
-
if ("entity" in obj && typeof obj.entity === "string" && Array.isArray(obj.records)) {
|
|
7300
|
-
for (const recordIdx of obj.records) {
|
|
7301
|
-
result.push({
|
|
7302
|
-
entity: obj.entity,
|
|
7303
|
-
view_mode: obj.view_mode,
|
|
7304
|
-
record: recordIdx
|
|
7305
|
-
});
|
|
7306
|
-
}
|
|
7307
|
-
} else if ("entity" in obj && typeof obj.entity === "string") {
|
|
7308
|
-
result.push({
|
|
7309
|
-
...obj,
|
|
7310
|
-
record: obj.record ?? 0
|
|
7311
|
-
});
|
|
7312
|
-
} else {
|
|
7313
|
-
result.push(obj);
|
|
7314
|
-
}
|
|
7352
|
+
result.push(entry);
|
|
7315
7353
|
}
|
|
7316
7354
|
return result;
|
|
7317
7355
|
}
|
|
@@ -7439,7 +7477,7 @@ var init_builder_registry = __esm({
|
|
|
7439
7477
|
}
|
|
7440
7478
|
});
|
|
7441
7479
|
function extractFieldMappings(source2) {
|
|
7442
|
-
const expr =
|
|
7480
|
+
const expr = jsonata6(source2);
|
|
7443
7481
|
const ast = expr.ast();
|
|
7444
7482
|
const results = [];
|
|
7445
7483
|
walkExpression(ast, "", "", false, results);
|
|
@@ -7570,18 +7608,25 @@ var init_entity_builder = __esm({
|
|
|
7570
7608
|
bundle = node["bundle"] ?? "";
|
|
7571
7609
|
}
|
|
7572
7610
|
const view_mode = node["view_mode"] ?? "";
|
|
7573
|
-
const
|
|
7611
|
+
const select = node["select"] ?? "";
|
|
7574
7612
|
const jsonataPath = resolve(ctx.designbookDir, "entity-mapping", `${entity_type}.${bundle}.${view_mode}.jsonata`);
|
|
7575
|
-
const entity = { entity_type, bundle, view_mode,
|
|
7613
|
+
const entity = { entity_type, bundle, view_mode, select, mapping: jsonataPath };
|
|
7576
7614
|
const meta = { kind: "entity", entity };
|
|
7577
7615
|
if (!existsSync(jsonataPath)) {
|
|
7578
7616
|
console.warn(`[Designbook] JSONata expression not found: ${jsonataPath}`);
|
|
7579
7617
|
return { nodes: [missingPlaceholder(`missing expression: ${entity_type}.${bundle}.${view_mode}.jsonata`)], meta };
|
|
7580
7618
|
}
|
|
7581
|
-
const
|
|
7582
|
-
const
|
|
7619
|
+
const entityArray = ctx.sampleData?.content?.[entity_type]?.[bundle] ?? ctx.sampleData?.config?.[entity_type]?.[bundle] ?? [];
|
|
7620
|
+
const record = node["record"];
|
|
7621
|
+
let recordData = {};
|
|
7622
|
+
if (select) {
|
|
7623
|
+
const selected = await jsonata6(select).evaluate(entityArray);
|
|
7624
|
+
recordData = selected ?? {};
|
|
7625
|
+
} else if (typeof record === "number") {
|
|
7626
|
+
recordData = entityArray[record] ?? {};
|
|
7627
|
+
}
|
|
7583
7628
|
const source2 = readFileSync(jsonataPath, "utf-8");
|
|
7584
|
-
const expr =
|
|
7629
|
+
const expr = jsonata6(source2);
|
|
7585
7630
|
const result = await expr.evaluate(recordData);
|
|
7586
7631
|
let fieldMappings;
|
|
7587
7632
|
try {
|
|
@@ -8103,43 +8148,43 @@ function loadDesignbookConfig(designbookDir) {
|
|
|
8103
8148
|
return void 0;
|
|
8104
8149
|
}
|
|
8105
8150
|
}
|
|
8106
|
-
function loadSampleData(
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
if (existsSync(sectionDataPath)) {
|
|
8115
|
-
return load(readFileSync(sectionDataPath, "utf-8"));
|
|
8151
|
+
function loadSampleData(designbookDir, dataModel) {
|
|
8152
|
+
const resolvedDataModel = dataModel ?? loadDataModel(designbookDir);
|
|
8153
|
+
const pool = {};
|
|
8154
|
+
for (const { entityType, bundle, records } of readBundleFiles(join(designbookDir, "data"))) {
|
|
8155
|
+
const ns = namespaceFor(resolvedDataModel, entityType, bundle);
|
|
8156
|
+
if (!ns) {
|
|
8157
|
+
console.warn(`[Designbook] data/${entityType}.${bundle}.yml: not in data-model \u2014 skipped`);
|
|
8158
|
+
continue;
|
|
8116
8159
|
}
|
|
8160
|
+
pool[ns] ??= {};
|
|
8161
|
+
pool[ns][entityType] ??= {};
|
|
8162
|
+
pool[ns][entityType][bundle] = records;
|
|
8117
8163
|
}
|
|
8118
|
-
|
|
8119
|
-
if (existsSync(globalDataPath)) {
|
|
8120
|
-
return load(readFileSync(globalDataPath, "utf-8"));
|
|
8121
|
-
}
|
|
8122
|
-
return {};
|
|
8164
|
+
return pool;
|
|
8123
8165
|
}
|
|
8124
|
-
|
|
8125
|
-
const scenesArray = extractScenes(raw);
|
|
8126
|
-
const dataModel = loadDataModel(designbookDir);
|
|
8127
|
-
const firstScene = scenesArray[0];
|
|
8128
|
-
const sampleData = loadSampleData(
|
|
8129
|
-
id,
|
|
8130
|
-
designbookDir,
|
|
8131
|
-
typeof firstScene?.section === "string" ? firstScene.section : void 0
|
|
8132
|
-
);
|
|
8133
|
-
const config = loadDesignbookConfig(designbookDir);
|
|
8166
|
+
function buildRenderContext(args) {
|
|
8134
8167
|
const registry = new BuilderRegistry();
|
|
8135
8168
|
registry.register(componentBuilder);
|
|
8136
8169
|
registry.register(entityBuilder);
|
|
8137
8170
|
registry.register(sceneBuilder);
|
|
8138
8171
|
registry.register(imageStyleBuilder);
|
|
8139
|
-
for (const builder of
|
|
8172
|
+
for (const builder of args.builders ?? []) {
|
|
8140
8173
|
registry.register(builder);
|
|
8141
8174
|
}
|
|
8142
|
-
|
|
8175
|
+
return registry.createContext({
|
|
8176
|
+
dataModel: args.dataModel,
|
|
8177
|
+
sampleData: args.sampleData,
|
|
8178
|
+
designbookDir: args.designbookDir,
|
|
8179
|
+
config: args.config
|
|
8180
|
+
});
|
|
8181
|
+
}
|
|
8182
|
+
async function buildSceneModule(id, raw, designbookDir, options = {}) {
|
|
8183
|
+
const scenesArray = extractScenes(raw);
|
|
8184
|
+
const dataModel = loadDataModel(designbookDir);
|
|
8185
|
+
const sampleData = loadSampleData(designbookDir, dataModel);
|
|
8186
|
+
const config = loadDesignbookConfig(designbookDir);
|
|
8187
|
+
const ctx = buildRenderContext({ dataModel, sampleData, designbookDir, config, builders: options.builders });
|
|
8143
8188
|
const fileBase = fileBaseName(id);
|
|
8144
8189
|
const group = extractGroup(raw, fileBase);
|
|
8145
8190
|
const resolvedScenes = [];
|
|
@@ -8178,6 +8223,7 @@ async function buildSceneModule(id, raw, designbookDir, options = {}) {
|
|
|
8178
8223
|
}
|
|
8179
8224
|
var init_scene_module_builder = __esm({
|
|
8180
8225
|
"src/renderer/scene-module-builder.ts"() {
|
|
8226
|
+
init_data_pool();
|
|
8181
8227
|
init_scene_metadata();
|
|
8182
8228
|
init_parser();
|
|
8183
8229
|
init_builder_registry();
|
|
@@ -8353,7 +8399,11 @@ var init_validation_registry = __esm({
|
|
|
8353
8399
|
validators = {
|
|
8354
8400
|
// JSON-Schema-only validators (component, data-model, tokens) removed —
|
|
8355
8401
|
// schema validation now happens via $ref on result: declarations (see workflowResult).
|
|
8356
|
-
data: async (
|
|
8402
|
+
data: async (_file, config) => toFileResult(
|
|
8403
|
+
validateData(resolve(config.data, "data-model.yml"), resolve(config.data, "data")),
|
|
8404
|
+
resolve(config.data, "data"),
|
|
8405
|
+
"data"
|
|
8406
|
+
),
|
|
8357
8407
|
"entity-mapping": async (file, config) => {
|
|
8358
8408
|
const { validateEntityMapping: validateEntityMapping2 } = await Promise.resolve().then(() => (init_entity_mapping(), entity_mapping_exports));
|
|
8359
8409
|
return toFileResult(await validateEntityMapping2(file, config), file, "entity-mapping");
|
|
@@ -8363,11 +8413,11 @@ var init_validation_registry = __esm({
|
|
|
8363
8413
|
const buildResult = await validateSceneBuild2(file, config);
|
|
8364
8414
|
if (!buildResult.valid) return buildResult;
|
|
8365
8415
|
const { load: parseYaml16 } = await import('js-yaml');
|
|
8366
|
-
const { readFileSync:
|
|
8367
|
-
if (!
|
|
8416
|
+
const { readFileSync: readFileSync24, existsSync: existsSync26 } = await import('fs');
|
|
8417
|
+
if (!existsSync26(file)) return buildResult;
|
|
8368
8418
|
let raw;
|
|
8369
8419
|
try {
|
|
8370
|
-
raw = parseYaml16(
|
|
8420
|
+
raw = parseYaml16(readFileSync24(file, "utf-8"));
|
|
8371
8421
|
} catch {
|
|
8372
8422
|
return buildResult;
|
|
8373
8423
|
}
|
|
@@ -9142,7 +9192,7 @@ var cache = /* @__PURE__ */ new Map();
|
|
|
9142
9192
|
function compile(expr) {
|
|
9143
9193
|
const hit = cache.get(expr);
|
|
9144
9194
|
if (hit) return hit;
|
|
9145
|
-
const compiled =
|
|
9195
|
+
const compiled = jsonata6(expr);
|
|
9146
9196
|
cache.set(expr, compiled);
|
|
9147
9197
|
return compiled;
|
|
9148
9198
|
}
|
|
@@ -9981,6 +10031,13 @@ function resolveFiles(globPattern, context2, config, agentsDir, requireWhen = tr
|
|
|
9981
10031
|
}
|
|
9982
10032
|
return results;
|
|
9983
10033
|
}
|
|
10034
|
+
function isPluginRootPath(p) {
|
|
10035
|
+
return /\/(?:\.cli-skills-root[^/]*|plugins\/cache)\//.test(p.replace(/\\/g, "/"));
|
|
10036
|
+
}
|
|
10037
|
+
function preferProjectRoot(files) {
|
|
10038
|
+
const projectMatches = files.filter((f) => !isPluginRootPath(f.path));
|
|
10039
|
+
return projectMatches.length > 0 ? projectMatches : files;
|
|
10040
|
+
}
|
|
9984
10041
|
function deduplicateByNameAs(files, agentsDir, warnings = []) {
|
|
9985
10042
|
const standalone = [];
|
|
9986
10043
|
const overrides = [];
|
|
@@ -10083,7 +10140,7 @@ function resolveTaskFilesRich(stage, config, agentsDir, sources) {
|
|
|
10083
10140
|
return [];
|
|
10084
10141
|
}
|
|
10085
10142
|
if (broadMatches.length > 0) {
|
|
10086
|
-
return deduplicateByNameAs(broadMatches, agentsDir);
|
|
10143
|
+
return deduplicateByNameAs(preferProjectRoot(broadMatches), agentsDir);
|
|
10087
10144
|
}
|
|
10088
10145
|
const filenameMatches = resolveFiles(
|
|
10089
10146
|
`skills/**/tasks/${stage}.md`,
|
|
@@ -10097,7 +10154,7 @@ function resolveTaskFilesRich(stage, config, agentsDir, sources) {
|
|
|
10097
10154
|
for (const m of filenameMatches) {
|
|
10098
10155
|
console.warn(`[designbook] task "${m.path}" resolved by filename \u2014 add trigger.steps: [${stage}] to frontmatter`);
|
|
10099
10156
|
}
|
|
10100
|
-
return deduplicateByNameAs(filenameMatches, agentsDir);
|
|
10157
|
+
return deduplicateByNameAs(preferProjectRoot(filenameMatches), agentsDir);
|
|
10101
10158
|
}
|
|
10102
10159
|
return [];
|
|
10103
10160
|
}
|
|
@@ -10395,6 +10452,7 @@ async function resolveAllStages(workflowFilePath, config, rawConfig, agentsDir,
|
|
|
10395
10452
|
}
|
|
10396
10453
|
}
|
|
10397
10454
|
let isolate = false;
|
|
10455
|
+
let interactive = false;
|
|
10398
10456
|
if (stageDefs) {
|
|
10399
10457
|
for (const [, stageDef] of Object.entries(stageDefs)) {
|
|
10400
10458
|
if (!stageDef.steps?.includes(step)) continue;
|
|
@@ -10404,6 +10462,7 @@ async function resolveAllStages(workflowFilePath, config, rawConfig, agentsDir,
|
|
|
10404
10462
|
}
|
|
10405
10463
|
}
|
|
10406
10464
|
if (stageDef.isolate) isolate = true;
|
|
10465
|
+
if (stageDef.interactive) interactive = true;
|
|
10407
10466
|
}
|
|
10408
10467
|
}
|
|
10409
10468
|
const isQualified = step.includes(":");
|
|
@@ -10487,7 +10546,8 @@ async function resolveAllStages(workflowFilePath, config, rawConfig, agentsDir,
|
|
|
10487
10546
|
config_rules,
|
|
10488
10547
|
config_instructions,
|
|
10489
10548
|
...hasSchema ? { schema: schemaBlock } : {},
|
|
10490
|
-
...isolate ? { isolate: true } : {}
|
|
10549
|
+
...isolate ? { isolate: true } : {},
|
|
10550
|
+
...interactive ? { interactive: true } : {}
|
|
10491
10551
|
};
|
|
10492
10552
|
} else {
|
|
10493
10553
|
stepResolved[step] = taskFilePaths.map((taskFile) => ({
|
|
@@ -10497,7 +10557,8 @@ async function resolveAllStages(workflowFilePath, config, rawConfig, agentsDir,
|
|
|
10497
10557
|
config_rules,
|
|
10498
10558
|
config_instructions,
|
|
10499
10559
|
...hasSchema ? { schema: schemaBlock } : {},
|
|
10500
|
-
...isolate ? { isolate: true } : {}
|
|
10560
|
+
...isolate ? { isolate: true } : {},
|
|
10561
|
+
...interactive ? { interactive: true } : {}
|
|
10501
10562
|
}));
|
|
10502
10563
|
}
|
|
10503
10564
|
resolvedSteps.push(step);
|
|
@@ -10586,25 +10647,12 @@ function inferTaskType(stage) {
|
|
|
10586
10647
|
if (base.includes("validate")) return "validation";
|
|
10587
10648
|
return "data";
|
|
10588
10649
|
}
|
|
10589
|
-
async function generateTaskTitle(stage, params,
|
|
10650
|
+
async function generateTaskTitle(stage, params, _schemaParams, explicitTitle) {
|
|
10590
10651
|
if (explicitTitle) {
|
|
10591
10652
|
return interpolate(explicitTitle, params);
|
|
10592
10653
|
}
|
|
10593
10654
|
const base = stage.includes(":") ? stage.split(":")[1] : stage;
|
|
10594
|
-
|
|
10595
|
-
if (schemaParams) {
|
|
10596
|
-
for (const [key, defaultValue] of Object.entries(schemaParams)) {
|
|
10597
|
-
if (defaultValue === null && typeof params[key] === "string" && params[key].length > 0) {
|
|
10598
|
-
return `${words}: ${params[key]}`;
|
|
10599
|
-
}
|
|
10600
|
-
}
|
|
10601
|
-
}
|
|
10602
|
-
for (const value of Object.values(params)) {
|
|
10603
|
-
if (typeof value === "string" && value.length > 0) {
|
|
10604
|
-
return `${words}: ${value}`;
|
|
10605
|
-
}
|
|
10606
|
-
}
|
|
10607
|
-
return words;
|
|
10655
|
+
return base.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
10608
10656
|
}
|
|
10609
10657
|
function getExpr(value) {
|
|
10610
10658
|
return typeof value === "string" ? value : value.expr;
|
|
@@ -10618,7 +10666,7 @@ async function resolveEach(each, scope) {
|
|
|
10618
10666
|
const next = [];
|
|
10619
10667
|
for (const combo of combos) {
|
|
10620
10668
|
const innerScope = { ...scope, ...combo };
|
|
10621
|
-
const value = await
|
|
10669
|
+
const value = await jsonata6(expr).evaluate(innerScope);
|
|
10622
10670
|
if (value === void 0 || value === null) continue;
|
|
10623
10671
|
const items = Array.isArray(value) ? value : [value];
|
|
10624
10672
|
for (const item of items) {
|
|
@@ -11059,7 +11107,7 @@ async function expandTasksFromParams(stageLoaded, stages, params, existingTasks,
|
|
|
11059
11107
|
if (filterEntries.length > 0) {
|
|
11060
11108
|
let mismatch = false;
|
|
11061
11109
|
for (const [k, v] of filterEntries) {
|
|
11062
|
-
const actual = await
|
|
11110
|
+
const actual = await jsonata6(k).evaluate(itemParams);
|
|
11063
11111
|
if (actual === void 0 || actual === null) continue;
|
|
11064
11112
|
if (Array.isArray(v)) {
|
|
11065
11113
|
if (!v.map(String).includes(String(actual))) {
|
|
@@ -11101,7 +11149,7 @@ async function expandTasksFromParams(stageLoaded, stages, params, existingTasks,
|
|
|
11101
11149
|
suffix++;
|
|
11102
11150
|
}
|
|
11103
11151
|
existingIds.add(taskId);
|
|
11104
|
-
const title = taskTitle ? await generateTaskTitle(step, mergedParams, schemaParams, taskTitle) : await generateTaskTitle(step, mergedParams
|
|
11152
|
+
const title = taskTitle ? await generateTaskTitle(step, mergedParams, schemaParams, taskTitle) : await generateTaskTitle(step, mergedParams);
|
|
11105
11153
|
const description = taskDescription ? await interpolate(taskDescription, mergedParams) : void 0;
|
|
11106
11154
|
const type = inferTaskType(step);
|
|
11107
11155
|
const files = await expandFileDeclarations(fileDeclarations, mergedParams, envMap, knownValidators);
|
|
@@ -11377,12 +11425,31 @@ async function workflowDone(dataDir, name, taskId, loaded, options) {
|
|
|
11377
11425
|
const stages = data.stages;
|
|
11378
11426
|
const currentStage = data.current_stage;
|
|
11379
11427
|
const configForExpansion = options?.config ?? { data: dataDir, technology: "html", extensions: [] };
|
|
11428
|
+
const emptyEachSteps = /* @__PURE__ */ new Set();
|
|
11429
|
+
const eachDeclForStep = (step, stageDef) => {
|
|
11430
|
+
const stageLoadedEntry = data.stage_loaded?.[step];
|
|
11431
|
+
if (stageLoadedEntry) {
|
|
11432
|
+
const entries = Array.isArray(stageLoadedEntry) ? stageLoadedEntry : [stageLoadedEntry];
|
|
11433
|
+
for (const resolved of entries) {
|
|
11434
|
+
const taskFm = parseFrontmatter(resolved.task_file);
|
|
11435
|
+
if (taskFm?.each && typeof taskFm.each === "object") {
|
|
11436
|
+
return taskFm.each;
|
|
11437
|
+
}
|
|
11438
|
+
}
|
|
11439
|
+
}
|
|
11440
|
+
if (stageDef.each) {
|
|
11441
|
+
return { [stageDef.each]: stageDef.each };
|
|
11442
|
+
}
|
|
11443
|
+
return void 0;
|
|
11444
|
+
};
|
|
11380
11445
|
const getMissingStageSteps = (stageName) => {
|
|
11381
11446
|
const stageDef = stages[stageName];
|
|
11382
11447
|
if (!stageDef?.steps) return [];
|
|
11383
11448
|
const stageHasTrackedSteps = data.tasks.some((t) => t.stage === stageName && typeof t.step === "string" && t.step.length > 0) || stageDef.steps.some((step) => Boolean(data.stage_loaded?.[step]));
|
|
11384
11449
|
if (!stageHasTrackedSteps) return [];
|
|
11385
|
-
return stageDef.steps.filter(
|
|
11450
|
+
return stageDef.steps.filter(
|
|
11451
|
+
(step) => !data.tasks.some((t) => t.stage === stageName && t.step === step) && !emptyEachSteps.has(step)
|
|
11452
|
+
);
|
|
11386
11453
|
};
|
|
11387
11454
|
const expandStageIfNeeded = async (stageName) => {
|
|
11388
11455
|
const missingBefore = getMissingStageSteps(stageName);
|
|
@@ -11401,6 +11468,19 @@ async function workflowDone(dataDir, name, taskId, loaded, options) {
|
|
|
11401
11468
|
Object.entries(resolveResult.unresolved).map(([k, v]) => [k, { input: v.input, error: v.error }])
|
|
11402
11469
|
);
|
|
11403
11470
|
}
|
|
11471
|
+
const expansionLookup = { ...resolveResult.params, ...data.scope ?? {} };
|
|
11472
|
+
for (const step of stageDef.steps ?? []) {
|
|
11473
|
+
const eachDecl = eachDeclForStep(step, stageDef);
|
|
11474
|
+
if (!eachDecl) continue;
|
|
11475
|
+
const firstEntry = Object.entries(eachDecl)[0];
|
|
11476
|
+
if (!firstEntry) continue;
|
|
11477
|
+
const [, firstAxis] = firstEntry;
|
|
11478
|
+
const expr = typeof firstAxis === "string" ? firstAxis : firstAxis.expr;
|
|
11479
|
+
const driverValue = await jsonata6(expr).evaluate(expansionLookup);
|
|
11480
|
+
if (Array.isArray(driverValue) && driverValue.length === 0) {
|
|
11481
|
+
emptyEachSteps.add(step);
|
|
11482
|
+
}
|
|
11483
|
+
}
|
|
11404
11484
|
const expanded = await expandTasksFromParams(
|
|
11405
11485
|
stageLoaded,
|
|
11406
11486
|
{ [stageName]: stageDef },
|
|
@@ -11874,7 +11954,7 @@ function readSummary(opts) {
|
|
|
11874
11954
|
}
|
|
11875
11955
|
async function evaluateMetric(summary, expression) {
|
|
11876
11956
|
try {
|
|
11877
|
-
const v = await
|
|
11957
|
+
const v = await jsonata6(expression).evaluate(summary);
|
|
11878
11958
|
return typeof v === "number" ? v : null;
|
|
11879
11959
|
} catch {
|
|
11880
11960
|
return null;
|
|
@@ -12197,7 +12277,7 @@ async function filterActiveAfterDeclarations(declarations, parentParams) {
|
|
|
12197
12277
|
results.push(decl);
|
|
12198
12278
|
continue;
|
|
12199
12279
|
}
|
|
12200
|
-
const value = await
|
|
12280
|
+
const value = await jsonata6(decl.when).evaluate(parentParams);
|
|
12201
12281
|
if (value) results.push(decl);
|
|
12202
12282
|
}
|
|
12203
12283
|
return results;
|
|
@@ -12217,7 +12297,7 @@ async function createAfterWorkflows(declarations, parentName, parentParams, conf
|
|
|
12217
12297
|
const mapped = {};
|
|
12218
12298
|
if (decl.params) {
|
|
12219
12299
|
for (const [key, expr] of Object.entries(decl.params)) {
|
|
12220
|
-
const value = await
|
|
12300
|
+
const value = await jsonata6(expr).evaluate(parentParams);
|
|
12221
12301
|
if (value === void 0) {
|
|
12222
12302
|
throw new Error(
|
|
12223
12303
|
`after-workflow '${decl.workflow}': param '${key}' expression '${expr}' evaluated to undefined on parent params`
|
|
@@ -12585,7 +12665,7 @@ function register4(program2) {
|
|
|
12585
12665
|
});
|
|
12586
12666
|
}
|
|
12587
12667
|
|
|
12588
|
-
// src/
|
|
12668
|
+
// src/runbook/sources.ts
|
|
12589
12669
|
function classifyInputs(paramProperties, eachKeys, priorOutputs) {
|
|
12590
12670
|
const out2 = [];
|
|
12591
12671
|
for (const [name, declRaw] of Object.entries(paramProperties)) {
|
|
@@ -12609,7 +12689,7 @@ function classifyInputs(paramProperties, eachKeys, priorOutputs) {
|
|
|
12609
12689
|
return out2;
|
|
12610
12690
|
}
|
|
12611
12691
|
|
|
12612
|
-
// src/
|
|
12692
|
+
// src/runbook/examples.ts
|
|
12613
12693
|
var HEADING_RE = /^##\s+example\s+output\s*$/i;
|
|
12614
12694
|
var FENCE_OPEN_RE = /^```[\w-]*\s*$/;
|
|
12615
12695
|
var FENCE_CLOSE_RE = /^```\s*$/;
|
|
@@ -12689,7 +12769,7 @@ function slugifyArtifactName(filePath) {
|
|
|
12689
12769
|
return stem.toLowerCase().replace(/[_\s]+/g, "-").replace(/[^a-z0-9-]+/g, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
12690
12770
|
}
|
|
12691
12771
|
|
|
12692
|
-
// src/
|
|
12772
|
+
// src/runbook/reverse-index.ts
|
|
12693
12773
|
function buildArtifactIndex(stepResolved, stages, kind) {
|
|
12694
12774
|
const out2 = {};
|
|
12695
12775
|
for (const [stageName, stageDef] of Object.entries(stages)) {
|
|
@@ -12710,7 +12790,7 @@ function buildArtifactIndex(stepResolved, stages, kind) {
|
|
|
12710
12790
|
return out2;
|
|
12711
12791
|
}
|
|
12712
12792
|
|
|
12713
|
-
// src/
|
|
12793
|
+
// src/runbook/resolve.ts
|
|
12714
12794
|
function readBody(filePath) {
|
|
12715
12795
|
const raw = readFileSync(filePath, "utf-8");
|
|
12716
12796
|
const parsed = fm(raw);
|
|
@@ -12768,7 +12848,7 @@ function collectRefNamesFromSchema(schema) {
|
|
|
12768
12848
|
Object.values(obj).forEach(walk2);
|
|
12769
12849
|
}
|
|
12770
12850
|
}
|
|
12771
|
-
async function
|
|
12851
|
+
async function buildRenderContext2(workflowFilePath, agentsDir, sources) {
|
|
12772
12852
|
const config = loadConfig();
|
|
12773
12853
|
const configPath = findConfig();
|
|
12774
12854
|
const rawConfig = configPath ? load(readFileSync(configPath, "utf-8")) ?? {} : {};
|
|
@@ -12896,7 +12976,7 @@ function renderPlan(ctx) {
|
|
|
12896
12976
|
}
|
|
12897
12977
|
function renderHeader(ctx) {
|
|
12898
12978
|
return [
|
|
12899
|
-
`#
|
|
12979
|
+
`# Runbook: ${ctx.workflowFrontmatter.title ?? ctx.workflowId}`,
|
|
12900
12980
|
"",
|
|
12901
12981
|
`> ${ctx.workflowFrontmatter.description ?? ""}`,
|
|
12902
12982
|
""
|
|
@@ -13071,16 +13151,16 @@ function formatScalar(value) {
|
|
|
13071
13151
|
return JSON.stringify(value);
|
|
13072
13152
|
}
|
|
13073
13153
|
|
|
13074
|
-
// src/cli/
|
|
13154
|
+
// src/cli/runbook.ts
|
|
13075
13155
|
function register5(program2) {
|
|
13076
|
-
program2.command("
|
|
13156
|
+
program2.command("runbook <workflow>").description("Resolve a workflow definition into a self-contained markdown runbook written to stdout.").action(async (workflowId) => {
|
|
13077
13157
|
try {
|
|
13078
13158
|
const configPath = findConfig();
|
|
13079
13159
|
const configDir = configPath ? dirname(configPath) : process.cwd();
|
|
13080
13160
|
const agentsDir = resolveSkillsRoot(configDir);
|
|
13081
13161
|
const sources = resolveSkillSources(configDir);
|
|
13082
13162
|
const workflowFile = resolveWorkflowFile(workflowId, agentsDir, sources);
|
|
13083
|
-
const ctx = await
|
|
13163
|
+
const ctx = await buildRenderContext2(workflowFile, agentsDir, sources);
|
|
13084
13164
|
const md = renderPlan(ctx);
|
|
13085
13165
|
console.log(md);
|
|
13086
13166
|
} catch (err) {
|
|
@@ -13229,12 +13309,12 @@ program.command("config").description("Output shell export statements for design
|
|
|
13229
13309
|
}
|
|
13230
13310
|
});
|
|
13231
13311
|
var validate = program.command("validate").description("Validate Designbook artifacts against schemas");
|
|
13232
|
-
validate.command("data
|
|
13312
|
+
validate.command("data").description("Validate data/ pool against data-model.yml").action(() => {
|
|
13233
13313
|
const config = loadConfig();
|
|
13234
13314
|
const dataModelPath = resolve(config.data, "data-model.yml");
|
|
13235
|
-
const
|
|
13236
|
-
const result = validateData(dataModelPath,
|
|
13237
|
-
printJson(
|
|
13315
|
+
const dataDir = resolve(config.data, "data");
|
|
13316
|
+
const result = validateData(dataModelPath, dataDir);
|
|
13317
|
+
printJson("data", result.valid, result.errors, result.warnings);
|
|
13238
13318
|
});
|
|
13239
13319
|
validate.command("entity-mapping <name>").description("Validate a .jsonata entity mapping file against sample data").action(async (name) => {
|
|
13240
13320
|
const config = loadConfig();
|