@kosdev-code/kos-ddk-cli 0.1.0-dev.75 → 0.1.0-dev.87
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 +1 -0
- package/agent-plugin/kos-ddk-tools/.claude-plugin/plugin.json +1 -1
- package/agent-plugin/kos-ddk-tools/plugin.json +1 -1
- package/agent-plugin/kos-ddk-tools/reference/reference.json +80 -11
- package/agent-plugin/kos-ddk-tools/servers/kos-ddk.mjs +467 -467
- package/agent-plugin/kos-ddk-tools/skills/build-ddk-plugin/SKILL.md +10 -2
- package/agent-plugin/kos-ddk-tools/skills/ddk-content-component/SKILL.md +3 -1
- package/agent-plugin/kos-ddk-tools/skills/ddk-storybook/SKILL.md +2 -1
- package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-region/index.ts__template__ +1 -0
- package/guides/storybook.md +1 -0
- package/package.json +2 -2
- package/reference/reference.json +80 -11
- package/src/codegen/contribution.mjs +48 -1
- package/src/codegen/descriptor.mjs +168 -0
- package/src/codegen/ncui-descriptor.mjs +34 -1
- package/src/generators/dashboard.mjs +44 -3
- package/src/handlers.mjs +20 -0
- package/src/mcp/plugin-inspect.mjs +36 -0
- package/src/mcp/tools.mjs +37 -0
- package/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
- package/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
- package/templates/dashboard-region/index.ts__template__ +1 -0
|
@@ -10,12 +10,18 @@ import {
|
|
|
10
10
|
} from "@kosdev-code/kos-codegen-core";
|
|
11
11
|
import { TEMPLATES_DIR, registerDdkHandlers } from "../handlers.mjs";
|
|
12
12
|
import {
|
|
13
|
+
addDashboardRegion,
|
|
13
14
|
addDescriptorEntry,
|
|
15
|
+
dashboardHasRegion,
|
|
14
16
|
descriptorListsSlot,
|
|
15
17
|
findDescriptorProjects,
|
|
16
18
|
} from "./descriptor.mjs";
|
|
17
19
|
import { stringifyPreserving } from "./json-preserve.mjs";
|
|
18
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
alsoReplacedNotes,
|
|
22
|
+
parseRank,
|
|
23
|
+
resolveOverride,
|
|
24
|
+
} from "./overrides.mjs";
|
|
19
25
|
|
|
20
26
|
/** Extension point → plugin type and what a contribution of it needs. */
|
|
21
27
|
export const CONTRIBUTION_TYPES = {
|
|
@@ -448,6 +454,47 @@ export function generateMacroSummary(
|
|
|
448
454
|
};
|
|
449
455
|
}
|
|
450
456
|
|
|
457
|
+
/**
|
|
458
|
+
* A component that renders a whole dashboard region: the descriptor region whose
|
|
459
|
+
* `component` (else `name`) is `regionKey`. `descriptorProject` adds that region.
|
|
460
|
+
*/
|
|
461
|
+
export function generateDashboardRegion(
|
|
462
|
+
codegenFs,
|
|
463
|
+
{ name, project, regionKey, rank, descriptorProject }
|
|
464
|
+
) {
|
|
465
|
+
assertNameFree(codegenFs, project, name);
|
|
466
|
+
const key = regionKey || normalizeAllValues({ name }).nameCamelCase;
|
|
467
|
+
generate(codegenFs, "ddk.dashboardRegion", {
|
|
468
|
+
name,
|
|
469
|
+
project,
|
|
470
|
+
regionKey: key,
|
|
471
|
+
// The region --descriptorProject adds claims no holders, so its story passes none.
|
|
472
|
+
claimsNothing: !!descriptorProject,
|
|
473
|
+
...rankField(parseRank(rank)),
|
|
474
|
+
});
|
|
475
|
+
const derived = regionKey
|
|
476
|
+
? []
|
|
477
|
+
: [`regionKey "${key}" comes from the name (--regionKey sets it).`];
|
|
478
|
+
let placement;
|
|
479
|
+
if (descriptorProject) {
|
|
480
|
+
placement = addDashboardRegion(codegenFs, {
|
|
481
|
+
project: descriptorProject,
|
|
482
|
+
key,
|
|
483
|
+
});
|
|
484
|
+
} else if (dashboardHasRegion(codegenFs, key)) {
|
|
485
|
+
placement = `Renders the dashboard region "${key}" in place of its built-in cards.`;
|
|
486
|
+
} else {
|
|
487
|
+
const projects = findDescriptorProjects(codegenFs).map((p) => p.name);
|
|
488
|
+
placement = projects.length
|
|
489
|
+
? `No dashboard region in a descriptor project is rendered by "${key}"; add one with --descriptorProject ${projects[0]}, or set a region's component to "${key}".`
|
|
490
|
+
: `The dashboard shows "${key}" only if its descriptor (kondra.ncui.dashboard) has a region named "${key}" or with component "${key}": create a descriptor project with kosui ddk:descriptor-project and pass --descriptorProject.`;
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
label: "DDK Dashboard Region",
|
|
494
|
+
notes: [...beanCollisionNotes(codegenFs, name), ...derived, placement],
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
451
498
|
/**
|
|
452
499
|
* The experience shown while the device has an active `troubleType` trouble.
|
|
453
500
|
* Contributions sharing a stateKey share one experience.
|
|
@@ -197,6 +197,174 @@ export function descriptorListsSlot(codegenFs, type, slot) {
|
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
// `*` is the only wildcard in a dashboard region's holder and summary patterns.
|
|
201
|
+
const matchesPattern = (pattern, value) =>
|
|
202
|
+
new RegExp(
|
|
203
|
+
`^${pattern
|
|
204
|
+
.split("*")
|
|
205
|
+
.map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&"))
|
|
206
|
+
.join(".*")}$`
|
|
207
|
+
).test(value);
|
|
208
|
+
|
|
209
|
+
const SHARE = /^\d+(\.\d+)?%$/;
|
|
210
|
+
const GRID_ALIGN = ["left", "right", "center"];
|
|
211
|
+
const REGION_ALIGN = [...GRID_ALIGN, "full"];
|
|
212
|
+
|
|
213
|
+
function trackProblems(orientation, kind, sizes) {
|
|
214
|
+
if (!sizes) return [];
|
|
215
|
+
const problems = sizes
|
|
216
|
+
.filter((size) => size !== "fit" && !SHARE.test(size))
|
|
217
|
+
.map(
|
|
218
|
+
(size) =>
|
|
219
|
+
`${orientation} ${kind} size "${size}" is not a share like "50%" or fit`
|
|
220
|
+
);
|
|
221
|
+
const shares = sizes.filter((size) => SHARE.test(size));
|
|
222
|
+
const total = shares.reduce((sum, size) => sum + parseFloat(size), 0);
|
|
223
|
+
if (shares.length > 0 && Math.abs(total - 100) > 0.5) {
|
|
224
|
+
problems.push(`${orientation} ${kind} shares add up to ${total}%, not 100%`);
|
|
225
|
+
}
|
|
226
|
+
return problems;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Problems with a descriptor project's dashboard layout for a plugin's summary
|
|
231
|
+
* cards: area names that are no region, summary keys no placed region claims, sizes
|
|
232
|
+
* and alignment it does not know, and region components no workspace plugin contributes.
|
|
233
|
+
*/
|
|
234
|
+
function dashboardProblems(dashboard, summaryKeys, regionKeys) {
|
|
235
|
+
if (!dashboard) return [];
|
|
236
|
+
const regions = dashboard.regions ?? [];
|
|
237
|
+
const names = new Set(regions.map((region) => region.name));
|
|
238
|
+
const problems = [];
|
|
239
|
+
if (!dashboard.layouts?.portrait && !dashboard.layouts?.landscape) {
|
|
240
|
+
problems.push(
|
|
241
|
+
"dashboard has no portrait or landscape layout, so the built-in one shows"
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
for (const region of regions) {
|
|
245
|
+
if (regionKeys && region.component && !regionKeys.includes(region.component)) {
|
|
246
|
+
problems.push(
|
|
247
|
+
`region "${region.name}" component "${region.component}" is contributed by no plugin in the workspace, so the region shows its built-in cards`
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
if (region.justify !== undefined && !REGION_ALIGN.includes(region.justify)) {
|
|
251
|
+
problems.push(
|
|
252
|
+
`region "${region.name}" justify "${region.justify}" is not ${REGION_ALIGN.join(", ")}`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
for (const [orientation, layout] of Object.entries(dashboard.layouts ?? {})) {
|
|
257
|
+
if (layout?.justify !== undefined && !GRID_ALIGN.includes(layout.justify)) {
|
|
258
|
+
problems.push(
|
|
259
|
+
`${orientation} justify "${layout.justify}" is not ${GRID_ALIGN.join(", ")}`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
problems.push(
|
|
263
|
+
...trackProblems(orientation, "column", layout?.columns),
|
|
264
|
+
...trackProblems(orientation, "row", layout?.rows)
|
|
265
|
+
);
|
|
266
|
+
const placed = new Set(
|
|
267
|
+
(layout?.areas ?? [])
|
|
268
|
+
.flatMap((row) => row.trim().split(/\s+/))
|
|
269
|
+
.filter((cell) => !/^\.+$/.test(cell))
|
|
270
|
+
);
|
|
271
|
+
for (const cell of placed) {
|
|
272
|
+
if (!names.has(cell)) {
|
|
273
|
+
problems.push(
|
|
274
|
+
`${orientation} area "${cell}" is not a dashboard region`
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const claiming = regions.filter((region) => placed.has(region.name));
|
|
279
|
+
for (const key of summaryKeys) {
|
|
280
|
+
const claimed = claiming.some((region) =>
|
|
281
|
+
(region.summaries ?? []).some((pattern) => matchesPattern(pattern, key))
|
|
282
|
+
);
|
|
283
|
+
if (!claimed) {
|
|
284
|
+
problems.push(
|
|
285
|
+
`dashboard summary "${key}" is in no ${orientation} region, so it does not show`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return problems;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Dashboard layout problems in each of the workspace's descriptor projects, for
|
|
295
|
+
* the given summary dashboardKeys and the region keys the workspace's plugins
|
|
296
|
+
* contribute: [{project, problem}].
|
|
297
|
+
*/
|
|
298
|
+
export function descriptorDashboardProblems(codegenFs, summaryKeys, regionKeys) {
|
|
299
|
+
return findDescriptorProjects(codegenFs).flatMap(({ name, kosJsonPath }) =>
|
|
300
|
+
dashboardProblems(
|
|
301
|
+
JSON.parse(codegenFs.read(kosJsonPath)).kondra?.ncui?.dashboard,
|
|
302
|
+
summaryKeys,
|
|
303
|
+
regionKeys
|
|
304
|
+
).map((problem) => ({ project: name, problem }))
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const regionKey = (region) => region.component ?? region.name;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Whether a descriptor project's dashboard has a region rendered by `key`, or with no
|
|
312
|
+
* descriptor project, whether the built-in layout has one.
|
|
313
|
+
*/
|
|
314
|
+
export function dashboardHasRegion(codegenFs, key) {
|
|
315
|
+
const projects = findDescriptorProjects(codegenFs);
|
|
316
|
+
const dashboards = projects.length
|
|
317
|
+
? projects.map(
|
|
318
|
+
({ kosJsonPath }) =>
|
|
319
|
+
JSON.parse(codegenFs.read(kosJsonPath)).kondra?.ncui?.dashboard
|
|
320
|
+
)
|
|
321
|
+
: NCUI_LAYOUTS.map((layout) => buildNcuiDescriptor({ layout }).ncui.dashboard);
|
|
322
|
+
return dashboards.some((dashboard) =>
|
|
323
|
+
(dashboard?.regions ?? []).some((region) => regionKey(region) === key)
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Adds a region rendered by `key` to a descriptor project's dashboard, claiming no
|
|
329
|
+
* holders or summaries, as a full-width last row of each layout. Returns the note.
|
|
330
|
+
*/
|
|
331
|
+
export function addDashboardRegion(codegenFs, { project, key }) {
|
|
332
|
+
const { name, kosJsonPath } = descriptorProject(codegenFs, project);
|
|
333
|
+
const original = codegenFs.read(kosJsonPath);
|
|
334
|
+
const kosJson = JSON.parse(original);
|
|
335
|
+
const ncui = ((kosJson.kondra ??= {}).ncui ??= {});
|
|
336
|
+
const notes = [];
|
|
337
|
+
if (!ncui.dashboard) {
|
|
338
|
+
ncui.dashboard = buildNcuiDescriptor({ layout: "standard" }).ncui.dashboard;
|
|
339
|
+
notes.push(`${name} had no dashboard; it now has the built-in standard one.`);
|
|
340
|
+
}
|
|
341
|
+
const regions = (ncui.dashboard.regions ??= []);
|
|
342
|
+
if (regions.some((region) => regionKey(region) === key)) {
|
|
343
|
+
return `${name} already has a dashboard region rendered by "${key}".`;
|
|
344
|
+
}
|
|
345
|
+
if (regions.some((region) => region.name === key)) {
|
|
346
|
+
throw new Error(
|
|
347
|
+
`${name} has a dashboard region named "${key}" with another component; choose another regionKey`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
regions.push({ name: key });
|
|
351
|
+
for (const layout of Object.values(ncui.dashboard.layouts ?? {})) {
|
|
352
|
+
const width = Math.max(
|
|
353
|
+
1,
|
|
354
|
+
...(layout.areas ?? []).map((row) => row.trim().split(/\s+/).length)
|
|
355
|
+
);
|
|
356
|
+
(layout.areas ??= []).push(Array(width).fill(key).join(" "));
|
|
357
|
+
if (layout.rows) layout.rows.push("fit");
|
|
358
|
+
}
|
|
359
|
+
codegenFs.write(kosJsonPath, stringifyPreserving(original, kosJson));
|
|
360
|
+
const setup = descriptorMockSetup(kosJson);
|
|
361
|
+
codegenFs.write(setup.path, setup.content);
|
|
362
|
+
return [
|
|
363
|
+
...notes,
|
|
364
|
+
`Added dashboard region "${key}" to ${name} as the full-width last row of each layout; it claims no holders or summaries, so the component reads the assembly. Move it in kondra.ncui.dashboard.layouts, or give it holders and summaries patterns.`,
|
|
365
|
+
].join(" ");
|
|
366
|
+
}
|
|
367
|
+
|
|
200
368
|
const SLOT_FIELDS = [
|
|
201
369
|
["utilities", "utility", "utilDescriptor"],
|
|
202
370
|
["setupStep", "setup", "setupDescriptor"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The NCUI descriptor a new descriptor project starts from (`kondra.ncui`), for the
|
|
2
2
|
// standard or compact layout and the dispenser's options. Standard navigation marks
|
|
3
3
|
// about and settings `embed` (shown as tabs) and spreads utilities over two columns;
|
|
4
|
-
// compact keeps utilities in one column.
|
|
4
|
+
// compact keeps utilities in one column. Both carry the dashboard layout.
|
|
5
5
|
|
|
6
6
|
export const NCUI_LAYOUTS = ["standard", "compact"];
|
|
7
7
|
|
|
@@ -107,6 +107,38 @@ function navigations(layout, { ice }) {
|
|
|
107
107
|
];
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
// The dashboard layout; the same as the DDK's built-in STANDARD_DASHBOARD_LAYOUT /
|
|
111
|
+
// COMPACT_DASHBOARD_LAYOUT (kos-ddk-models), which apply when no descriptor has one.
|
|
112
|
+
function dashboard(layout) {
|
|
113
|
+
const regions = [
|
|
114
|
+
{ name: "micros", holders: ["*micros*"], perGroup: true },
|
|
115
|
+
{ name: "macros", holders: ["*"], holderCard: false, size: "small" },
|
|
116
|
+
{ name: "assembly", summaries: ["*"], size: "small" },
|
|
117
|
+
];
|
|
118
|
+
const landscape = {
|
|
119
|
+
areas: ["micros micros", "macros assembly"],
|
|
120
|
+
columns: ["50%", "50%"],
|
|
121
|
+
flow: {
|
|
122
|
+
micros: { groups: "vertical", cards: "horizontal", wrap: true },
|
|
123
|
+
macros: { cards: "horizontal", wrap: true },
|
|
124
|
+
assembly: { cards: "horizontal", wrap: true },
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
const portrait =
|
|
128
|
+
layout === "compact"
|
|
129
|
+
? {
|
|
130
|
+
areas: ["micros", "macros", "assembly"],
|
|
131
|
+
columns: ["100%"],
|
|
132
|
+
flow: { micros: { groups: "vertical", cards: "vertical" } },
|
|
133
|
+
}
|
|
134
|
+
: {
|
|
135
|
+
areas: ["micros macros", "micros macros", "micros assembly"],
|
|
136
|
+
columns: ["73%", "27%"],
|
|
137
|
+
flow: { micros: { groups: "horizontal", cards: "vertical" } },
|
|
138
|
+
};
|
|
139
|
+
return { regions, layouts: { portrait, landscape } };
|
|
140
|
+
}
|
|
141
|
+
|
|
110
142
|
/**
|
|
111
143
|
* The `kondra` block of a new descriptor project.
|
|
112
144
|
* @param {{layout?: "standard" | "compact", carb?: boolean, ice?: boolean,
|
|
@@ -129,6 +161,7 @@ export function buildNcuiDescriptor({
|
|
|
129
161
|
setup: { steps: setupSteps(options) },
|
|
130
162
|
utilities: utilities(layout, options),
|
|
131
163
|
navigations: navigations(layout, options),
|
|
164
|
+
dashboard: dashboard(layout),
|
|
132
165
|
},
|
|
133
166
|
};
|
|
134
167
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// ddk:dashboard-card, ddk:pump-detail, ddk:pump-card, ddk:macro-summary
|
|
2
|
-
// ddk:trouble-action.
|
|
1
|
+
// ddk:dashboard-card, ddk:pump-detail, ddk:pump-card, ddk:macro-summary,
|
|
2
|
+
// ddk:dashboard-region and ddk:trouble-action.
|
|
3
3
|
import {
|
|
4
4
|
generateDashboardCard,
|
|
5
|
+
generateDashboardRegion,
|
|
5
6
|
generateMacroSummary,
|
|
6
7
|
generatePumpCard,
|
|
7
8
|
generatePumpDetail,
|
|
@@ -126,6 +127,46 @@ const COMMANDS = [
|
|
|
126
127
|
rank: a.rank,
|
|
127
128
|
}),
|
|
128
129
|
},
|
|
130
|
+
{
|
|
131
|
+
key: "ddk:dashboard-region",
|
|
132
|
+
name: "DDK Dashboard Region",
|
|
133
|
+
description:
|
|
134
|
+
"Create a component that renders a whole dashboard region; --regionKey is the descriptor region's component or name (default: from the name), --descriptorProject adds the region",
|
|
135
|
+
namedArguments: {
|
|
136
|
+
name: "componentName",
|
|
137
|
+
componentName: "componentName",
|
|
138
|
+
project: "componentProject",
|
|
139
|
+
componentProject: "componentProject",
|
|
140
|
+
dryRun: "dryRun",
|
|
141
|
+
interactive: "interactive",
|
|
142
|
+
rank: "rank",
|
|
143
|
+
regionKey: "regionKey",
|
|
144
|
+
descriptorProject: "descriptorProject",
|
|
145
|
+
},
|
|
146
|
+
prompts: [
|
|
147
|
+
{
|
|
148
|
+
type: "input",
|
|
149
|
+
name: "regionKey",
|
|
150
|
+
message:
|
|
151
|
+
"Region key (a descriptor region's component or name; blank: from the name)?",
|
|
152
|
+
default: "",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: "input",
|
|
156
|
+
name: "rank",
|
|
157
|
+
message: "Rank (lower wins; blank: unranked)?",
|
|
158
|
+
default: "",
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
generate: (codegenFs, a) =>
|
|
162
|
+
generateDashboardRegion(codegenFs, {
|
|
163
|
+
name: a.componentName,
|
|
164
|
+
project: a.componentProject,
|
|
165
|
+
regionKey: a.regionKey,
|
|
166
|
+
rank: a.rank,
|
|
167
|
+
descriptorProject: a.descriptorProject,
|
|
168
|
+
}),
|
|
169
|
+
},
|
|
129
170
|
{
|
|
130
171
|
key: "ddk:trouble-action",
|
|
131
172
|
point: "trouble-action",
|
|
@@ -225,7 +266,7 @@ export async function register(plop, { host }) {
|
|
|
225
266
|
message: "Which plugin project should the component be created in?",
|
|
226
267
|
choices: pluginProjects,
|
|
227
268
|
},
|
|
228
|
-
...overridePrompts(command.point),
|
|
269
|
+
...(command.point ? overridePrompts(command.point) : []),
|
|
229
270
|
...command.prompts,
|
|
230
271
|
],
|
|
231
272
|
actions: () =>
|
package/src/handlers.mjs
CHANGED
|
@@ -268,6 +268,25 @@ export class DdkMacroSummaryHandler extends TypedDdkHandler {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
export class DdkDashboardRegionHandler extends TypedDdkHandler {
|
|
272
|
+
pluginType = "ddk.dashboardRegion";
|
|
273
|
+
contributionKey = "dashboardRegion";
|
|
274
|
+
kosJsonKey = "dashboardRegion";
|
|
275
|
+
extensionType = "dashboard.region";
|
|
276
|
+
|
|
277
|
+
getTargetDirectory() {
|
|
278
|
+
return "dashboard/region";
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
getTemplatePath() {
|
|
282
|
+
return "dashboard-region";
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
contributionFields(options) {
|
|
286
|
+
return { regionKey: options.regionKey };
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
271
290
|
export class DdkTroubleActionHandler extends TypedDdkHandler {
|
|
272
291
|
pluginType = "ddk.troubleAction";
|
|
273
292
|
contributionKey = "troubleAction";
|
|
@@ -301,6 +320,7 @@ export const DDK_HANDLERS = [
|
|
|
301
320
|
DdkPumpDetailHandler,
|
|
302
321
|
DdkPumpSummaryHandler,
|
|
303
322
|
DdkMacroSummaryHandler,
|
|
323
|
+
DdkDashboardRegionHandler,
|
|
304
324
|
DdkTroubleActionHandler,
|
|
305
325
|
];
|
|
306
326
|
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
uniqueContributions,
|
|
12
12
|
} from "../codegen/overrides.mjs";
|
|
13
13
|
import {
|
|
14
|
+
dashboardHasRegion,
|
|
15
|
+
descriptorDashboardProblems,
|
|
14
16
|
descriptorListsSlot,
|
|
15
17
|
findDescriptorProjects,
|
|
16
18
|
} from "../codegen/descriptor.mjs";
|
|
@@ -247,6 +249,40 @@ export function validatePlugin(root, project) {
|
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
|
|
252
|
+
// A region component renders only a descriptor region it is the component (or name) of.
|
|
253
|
+
for (const entry of contributes.dashboardRegion ?? []) {
|
|
254
|
+
if (!entry.regionKey || dashboardHasRegion(readFs, entry.regionKey)) continue;
|
|
255
|
+
warnings.push(
|
|
256
|
+
`contributes.dashboardRegion ${entry.id}: regionKey "${entry.regionKey}" is no region's component or name in ${
|
|
257
|
+
descriptorProjects.length
|
|
258
|
+
? `descriptor project ${descriptorProjects.join(", ")}`
|
|
259
|
+
: "the built-in dashboard layout (no descriptor project in the workspace)"
|
|
260
|
+
}, so the dashboard does not show it${
|
|
261
|
+
descriptorProjects.length
|
|
262
|
+
? `; add it with kosui ddk:dashboard-region --descriptorProject ${descriptorProjects[0]}`
|
|
263
|
+
: ""
|
|
264
|
+
}`
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// A dashboard summary shows only where a descriptor's dashboard layout places it.
|
|
269
|
+
const summaryKeys = (contributes.dashboardSummary ?? [])
|
|
270
|
+
.map((entry) => entry.dashboardKey)
|
|
271
|
+
.filter(Boolean);
|
|
272
|
+
const regionKeys = findDdkPlugins(root).flatMap(({ dir }) =>
|
|
273
|
+
(
|
|
274
|
+
readJson(path.join(root, dir, ".kos.json")).kos?.ui?.plugin?.contributes
|
|
275
|
+
?.dashboardRegion ?? []
|
|
276
|
+
).map((entry) => entry.regionKey)
|
|
277
|
+
);
|
|
278
|
+
for (const { project: descriptor, problem } of descriptorDashboardProblems(
|
|
279
|
+
readFs,
|
|
280
|
+
summaryKeys,
|
|
281
|
+
regionKeys
|
|
282
|
+
)) {
|
|
283
|
+
warnings.push(`descriptor project ${descriptor}: ${problem}`);
|
|
284
|
+
}
|
|
285
|
+
|
|
250
286
|
const bySlot = new Map();
|
|
251
287
|
for (const c of described.contributions.filter((c) => c.slot)) {
|
|
252
288
|
const slotKey = `${c.contributionKey} ${JSON.stringify(c.slot)}`;
|
package/src/mcp/tools.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "@kosdev-code/kos-ui-cli/extension/mcp";
|
|
10
10
|
import {
|
|
11
11
|
generateDashboardCard,
|
|
12
|
+
generateDashboardRegion,
|
|
12
13
|
generateDdkContribution,
|
|
13
14
|
generateMacroSummary,
|
|
14
15
|
generatePumpCard,
|
|
@@ -373,6 +374,42 @@ export const ddkTools = [
|
|
|
373
374
|
})
|
|
374
375
|
),
|
|
375
376
|
},
|
|
377
|
+
{
|
|
378
|
+
name: "add_dashboard_region",
|
|
379
|
+
description:
|
|
380
|
+
"Add a component that renders a whole dashboard region in place of its built-in cards: the descriptor region whose component (else name) is regionKey. A built-in region name such as macros replaces that region's cards.",
|
|
381
|
+
inputSchema: {
|
|
382
|
+
type: "object",
|
|
383
|
+
properties: {
|
|
384
|
+
...common,
|
|
385
|
+
regionKey: {
|
|
386
|
+
type: "string",
|
|
387
|
+
description:
|
|
388
|
+
"The descriptor region's component, else its name. Default: from the name.",
|
|
389
|
+
},
|
|
390
|
+
descriptorProject: {
|
|
391
|
+
type: "string",
|
|
392
|
+
description:
|
|
393
|
+
"NCUI descriptor project to add the region to, as a full-width last row claiming no holders or summaries (scaffold_ddk_descriptor_project).",
|
|
394
|
+
},
|
|
395
|
+
rank: {
|
|
396
|
+
type: "integer",
|
|
397
|
+
description: "0-1000; lower wins among plugins rendering the same region.",
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
required: ["name", "project"],
|
|
401
|
+
},
|
|
402
|
+
handler: (args) =>
|
|
403
|
+
run(args, (codegenFs) =>
|
|
404
|
+
generateDashboardRegion(codegenFs, {
|
|
405
|
+
name: args.name,
|
|
406
|
+
project: args.project,
|
|
407
|
+
regionKey: args.regionKey,
|
|
408
|
+
rank: args.rank,
|
|
409
|
+
descriptorProject: args.descriptorProject,
|
|
410
|
+
})
|
|
411
|
+
),
|
|
412
|
+
},
|
|
376
413
|
{
|
|
377
414
|
name: "add_trouble_action",
|
|
378
415
|
description:
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Note: The plugin project Storybook configuration requires that the Studio
|
|
3
|
+
* Simulator is running in order to retrieve model data, unless the story mocks
|
|
4
|
+
* it with parameters.kosMock (ddk://guide/storybook).
|
|
5
|
+
*/
|
|
6
|
+
import { DashboardRegionStoryContainer } from "@kosdev-code/kos-ddk-story-containers";
|
|
7
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
8
|
+
import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof <%= namePascalCase %>> = {
|
|
11
|
+
args: {},
|
|
12
|
+
component: <%= namePascalCase %>,
|
|
13
|
+
decorators: [
|
|
14
|
+
(Story, context) => (
|
|
15
|
+
<% if (locals.claimsNothing) { -%>
|
|
16
|
+
<DashboardRegionStoryContainer regionKey="<%= regionKey %>">
|
|
17
|
+
<% } else { -%>
|
|
18
|
+
<DashboardRegionStoryContainer
|
|
19
|
+
regionKey="<%= regionKey %>"
|
|
20
|
+
holders={["*"]}
|
|
21
|
+
>
|
|
22
|
+
<% } -%>
|
|
23
|
+
{(props) => <Story args={{ ...context.args, ...props }} />}
|
|
24
|
+
</DashboardRegionStoryContainer>
|
|
25
|
+
),
|
|
26
|
+
],
|
|
27
|
+
tags: ["!autodocs"],
|
|
28
|
+
title: "dashboardRegion/<%= namePascalCase %>",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof <%= namePascalCase %>>;
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {
|
|
36
|
+
// parameters: { kosMock: { setups: ["<setup module>"] } },
|
|
37
|
+
render: (props) => <<%= namePascalCase %> {...props} />,
|
|
38
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LabelSmall } from '@kosdev-code/kos-ddk-components';
|
|
2
|
+
import type { DashboardRegionComponentProps } from '@kosdev-code/kos-ddk-models';
|
|
3
|
+
import { KosLog, kosComponent } from '@kosdev-code/kos-ui-sdk';
|
|
4
|
+
|
|
5
|
+
const log = KosLog.createLogger({ name: "<%= nameDashCase %>" });
|
|
6
|
+
log.debug("<%= nameDashCase %> component loaded");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Renders the dashboard region "<%= regionKey %>" in place of its built-in cards. The
|
|
10
|
+
* host passes the holders and summaries the region claimed, and the whole assembly.
|
|
11
|
+
*/
|
|
12
|
+
export const <%= namePascalCase %>: React.FunctionComponent<DashboardRegionComponentProps> =
|
|
13
|
+
kosComponent(({ holderGroups, summaries }) => {
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
{holderGroups.map((group) => (
|
|
17
|
+
<LabelSmall key={group.name}>{group.name}</LabelSmall>
|
|
18
|
+
))}
|
|
19
|
+
{summaries.map((summary) => (
|
|
20
|
+
<LabelSmall key={summary.dashboardKey}>{summary.dashboardKey}</LabelSmall>
|
|
21
|
+
))}
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
<%= namePascalCase %>.displayName = "<%= namePascalCase %>";
|
|
27
|
+
|
|
28
|
+
export default <%= namePascalCase %>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./<%= nameDashCase %>";
|