@kosdev-code/kos-ddk-cli 0.1.0-dev.50 → 0.1.0-dev.55

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.
Files changed (66) hide show
  1. package/README.md +54 -18
  2. package/agent-plugin/kos-ddk-tools/.claude-plugin/plugin.json +1 -1
  3. package/agent-plugin/kos-ddk-tools/catalog/contributions.json +0 -11
  4. package/agent-plugin/kos-ddk-tools/plugin.json +1 -1
  5. package/agent-plugin/kos-ddk-tools/reference/reference.json +108 -57
  6. package/agent-plugin/kos-ddk-tools/servers/kos-ddk.mjs +428 -427
  7. package/agent-plugin/kos-ddk-tools/skills/build-ddk-plugin/SKILL.md +9 -6
  8. package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.stories.tsx__template__ +3 -1
  9. package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.tsx__template__ +1 -1
  10. package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +3 -1
  11. package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +3 -1
  12. package/agent-plugin/kos-ddk-tools/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +3 -1
  13. package/agent-plugin/kos-ddk-tools/templates/nav/__nameDashCase__.stories.tsx__template__ +3 -1
  14. package/agent-plugin/kos-ddk-tools/templates/plugin-project/.storybook/preview.tsx.template +37 -4
  15. package/agent-plugin/kos-ddk-tools/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +3 -1
  16. package/agent-plugin/kos-ddk-tools/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +3 -1
  17. package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.stories.tsx__template__ +3 -1
  18. package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.tsx__template__ +1 -1
  19. package/agent-plugin/kos-ddk-tools/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +3 -1
  20. package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.stories.tsx__template__ +3 -1
  21. package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.tsx__template__ +2 -12
  22. package/catalog/contributions.json +0 -11
  23. package/guides/ddk-dev.md +2 -1
  24. package/guides/getting-started.md +117 -0
  25. package/guides/storybook.md +37 -2
  26. package/package.json +2 -2
  27. package/reference/reference.json +108 -57
  28. package/src/codegen/contribution.mjs +184 -14
  29. package/src/codegen/descriptor.mjs +210 -0
  30. package/src/codegen/ncui-descriptor.mjs +134 -0
  31. package/src/codegen/overrides.mjs +85 -1
  32. package/src/codegen/project.mjs +111 -13
  33. package/src/extension.mjs +10 -0
  34. package/src/generators/agent-install.mjs +3 -2
  35. package/src/generators/catalog.mjs +15 -4
  36. package/src/generators/contributions.mjs +41 -6
  37. package/src/generators/dashboard.mjs +12 -9
  38. package/src/generators/descriptor-entries.mjs +53 -0
  39. package/src/generators/descriptor-project.mjs +79 -0
  40. package/src/generators/dev.mjs +15 -5
  41. package/src/generators/plugin-project.mjs +36 -4
  42. package/src/generators/theme-project.mjs +14 -3
  43. package/src/handlers.mjs +9 -19
  44. package/src/mcp/plugin-inspect.mjs +35 -0
  45. package/src/mcp/reference.mjs +19 -3
  46. package/src/mcp/tools.mjs +118 -21
  47. package/templates/cui/__nameDashCase__.stories.tsx__template__ +3 -1
  48. package/templates/cui/__nameDashCase__.tsx__template__ +1 -1
  49. package/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +3 -1
  50. package/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +3 -1
  51. package/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +3 -1
  52. package/templates/nav/__nameDashCase__.stories.tsx__template__ +3 -1
  53. package/templates/plugin-project/.storybook/preview.tsx.template +37 -4
  54. package/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +3 -1
  55. package/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +3 -1
  56. package/templates/setup/__nameDashCase__.stories.tsx__template__ +3 -1
  57. package/templates/setup/__nameDashCase__.tsx__template__ +1 -1
  58. package/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +3 -1
  59. package/templates/utility/__nameDashCase__.stories.tsx__template__ +3 -1
  60. package/templates/utility/__nameDashCase__.tsx__template__ +2 -12
  61. package/agent-plugin/kos-ddk-tools/templates/setting/__nameDashCase__.stories.tsx__template__ +0 -30
  62. package/agent-plugin/kos-ddk-tools/templates/setting/__nameDashCase__.tsx__template__ +0 -27
  63. package/agent-plugin/kos-ddk-tools/templates/setting/index.ts__template__ +0 -1
  64. package/templates/setting/__nameDashCase__.stories.tsx__template__ +0 -30
  65. package/templates/setting/__nameDashCase__.tsx__template__ +0 -27
  66. package/templates/setting/index.ts__template__ +0 -1
@@ -80,6 +80,27 @@ export function listOverridableContributions(point) {
80
80
  );
81
81
  }
82
82
 
83
+ /**
84
+ * Each ddk:<point> command's contribution keys and slot fields, naming the keys
85
+ * no standard plugin contributes to.
86
+ */
87
+ export function describeOverridablePoints(point) {
88
+ const { contributions } = loadCatalog();
89
+ return Object.entries(OVERRIDABLE_POINTS)
90
+ .filter(([name]) => !point || name === point)
91
+ .map(([name, spec]) => {
92
+ const unfilled = spec.contributionKeys.filter(
93
+ (key) => !contributions.some((entry) => entry.contributionKey === key)
94
+ );
95
+ return {
96
+ point: name,
97
+ contributionKeys: spec.contributionKeys,
98
+ slot: spec.keys,
99
+ ...(unfilled.length ? { noStandardContributions: unfilled } : {}),
100
+ };
101
+ });
102
+ }
103
+
83
104
  /** Parses a rank from the CLI or a tool call; undefined when none was given. */
84
105
  export function parseRank(rank) {
85
106
  if (rank === undefined || rank === null || rank === "") return undefined;
@@ -95,6 +116,65 @@ export function parseRank(rank) {
95
116
  const describeRank = (rank) =>
96
117
  typeof rank === "number" ? `rank ${rank}` : "unranked";
97
118
 
119
+ /** Notes for standard contributions a new one shares a slot with and does not beat. */
120
+ function slotTakenNotes(point, explicit, rank) {
121
+ const given = Object.entries(explicit).filter(([, value]) => value);
122
+ if (given.length === 0) return [];
123
+ const sharing = uniqueContributions(
124
+ loadCatalog().contributions.filter(
125
+ (entry) =>
126
+ entry.point === point &&
127
+ given.every(([key, value]) => entry.keys[key] === value)
128
+ )
129
+ );
130
+ return sharing
131
+ .filter(
132
+ (entry) =>
133
+ rank === undefined ||
134
+ (typeof entry.rank === "number" && rank >= entry.rank)
135
+ )
136
+ .map((entry) => {
137
+ const slot = given.map(([key, value]) => `${key} "${value}"`).join(", ");
138
+ const rankHint =
139
+ typeof entry.rank === "number"
140
+ ? `give this one a --rank below ${entry.rank} (lower wins)`
141
+ : "give this one any --rank (any rank beats an unranked one)";
142
+ return `${entry.id} (${
143
+ entry.plugin
144
+ }) also fills ${slot} and is ${describeRank(
145
+ entry.rank
146
+ )}, so it still renders. To replace it, ${rankHint}, or use --override ${
147
+ entry.id
148
+ }.`;
149
+ });
150
+ }
151
+
152
+ /**
153
+ * Notes for the other standard contributions an override's shared rank also beats:
154
+ * a dashboard or pump card writes a summary and a detail in one slot, so overriding
155
+ * one replaces both.
156
+ */
157
+ export function alsoReplacedNotes(point, { override, rank, slot, written }) {
158
+ if (!override || rank === undefined) return [];
159
+ return uniqueContributions(
160
+ loadCatalog().contributions.filter(
161
+ (entry) =>
162
+ entry.point === point &&
163
+ entry.id !== override &&
164
+ written.includes(entry.contributionKey) &&
165
+ Object.entries(slot).every(
166
+ ([key, value]) => entry.keys[key] === value
167
+ ) &&
168
+ (typeof entry.rank !== "number" || rank < entry.rank)
169
+ )
170
+ ).map(
171
+ (entry) =>
172
+ `Also replaces ${entry.id} (${entry.plugin}, ${describeRank(
173
+ entry.rank
174
+ )}): the ${entry.contributionKey} in the same slot gets rank ${rank} too.`
175
+ );
176
+ }
177
+
98
178
  /**
99
179
  * Resolves `--override <id>` and `--rank` for a ddk:<point> command.
100
180
  *
@@ -106,7 +186,11 @@ export function resolveOverride(point, { override, rank, explicit = {} }) {
106
186
  const spec = OVERRIDABLE_POINTS[point];
107
187
  const requested = parseRank(rank);
108
188
  if (!override) {
109
- return { fields: {}, rank: requested, notes: [] };
189
+ return {
190
+ fields: {},
191
+ rank: requested,
192
+ notes: slotTakenNotes(point, explicit, requested),
193
+ };
110
194
  }
111
195
 
112
196
  // The standard and compact plugins can share an id; both fill the same slot.
@@ -5,9 +5,14 @@ import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import { findProjectByName } from "@kosdev-code/kos-codegen-core";
7
7
  import { TEMPLATES_DIR } from "../handlers.mjs";
8
+ import { DESCRIPTOR_KAB_TYPE } from "./descriptor.mjs";
9
+ import { buildNcuiDescriptor } from "./ncui-descriptor.mjs";
8
10
 
9
11
  export const DDK_VERSION = "~3.1.0";
10
12
 
13
+ /** The plugin context the DDK hosts load plugins from. */
14
+ export const DDK_PLUGIN_CONTEXT = "kosdev.ddk";
15
+
11
16
  const DDK_PACKAGES = [
12
17
  "@kosdev-code/kos-ddk",
13
18
  "@kosdev-code/kos-ddk-components",
@@ -19,10 +24,7 @@ const DDK_PACKAGES = [
19
24
 
20
25
  const PLUGIN_CONTRIBUTES = {
21
26
  cui: [],
22
- cuiView: [],
23
27
  utilities: [],
24
- utilityView: [],
25
- views: {},
26
28
  };
27
29
 
28
30
  const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf-8"));
@@ -58,6 +60,10 @@ function overlayPlugin(workspaceRoot, projectRoot) {
58
60
  const kosJson = readJson(kosJsonPath);
59
61
  const plugin = kosJson.kos.ui.plugin;
60
62
  plugin.contributes = { ...PLUGIN_CONTRIBUTES, ...plugin.contributes };
63
+ kosJson.test = {
64
+ ...kosJson.test,
65
+ plugin: { ...kosJson.test?.plugin, context: DDK_PLUGIN_CONTEXT },
66
+ };
61
67
  writeJson(kosJsonPath, kosJson);
62
68
 
63
69
  const packageJsonPath = path.join(workspaceRoot, "package.json");
@@ -81,6 +87,14 @@ function overlayTheme(_workspaceRoot, projectRoot) {
81
87
  });
82
88
  }
83
89
 
90
+ function overlayDescriptor(_workspaceRoot, projectRoot, { ncui } = {}) {
91
+ const kosJsonPath = path.join(projectRoot, ".kos.json");
92
+ const kosJson = readJson(kosJsonPath);
93
+ kosJson.type = DESCRIPTOR_KAB_TYPE;
94
+ kosJson.kondra = buildNcuiDescriptor(ncui);
95
+ writeJson(kosJsonPath, kosJson);
96
+ }
97
+
84
98
  const PROJECT_KINDS = {
85
99
  plugin: {
86
100
  generator: "@kosdev-code/kos-nx-plugin:kos-plugin-project",
@@ -92,25 +106,88 @@ const PROJECT_KINDS = {
92
106
  uiType: "ddk.ncui.theme",
93
107
  overlay: overlayTheme,
94
108
  },
109
+ // A content project's .kos.json is its KAB's descriptor.json.
110
+ descriptor: {
111
+ generator: "@kosdev-code/kos-nx-plugin:kos-content-project",
112
+ overlay: overlayDescriptor,
113
+ },
95
114
  };
96
115
 
97
- /** Writes the DDK layer over a generic plugin or theme project at `projectRoot`. */
98
- export function applyDdkLayer(kind, workspaceRoot, projectRoot) {
99
- PROJECT_KINDS[kind].overlay(workspaceRoot, projectRoot);
116
+ /** Writes the DDK layer over a generic plugin, theme or content project at `projectRoot`. */
117
+ export function applyDdkLayer(kind, workspaceRoot, projectRoot, options = {}) {
118
+ PROJECT_KINDS[kind].overlay(workspaceRoot, projectRoot, options);
119
+ }
120
+
121
+ /** The workspace's declared dependencies and devDependencies. */
122
+ function declaredPackages(workspaceRoot) {
123
+ const pkg = readJson(path.join(workspaceRoot, "package.json"));
124
+ return { ...pkg.dependencies, ...pkg.devDependencies };
125
+ }
126
+
127
+ const rootKosJsonPath = (workspaceRoot) =>
128
+ path.join(workspaceRoot, ".kos.json");
129
+
130
+ function workspaceHosts(workspaceRoot) {
131
+ const file = rootKosJsonPath(workspaceRoot);
132
+ return fs.existsSync(file) ? readJson(file).development?.hosts ?? [] : [];
133
+ }
134
+
135
+ /**
136
+ * The host a DDK plugin registers with: the one asked for, else the first host
137
+ * serving the DDK plugin context. A workspace without one registers none.
138
+ */
139
+ export function pluginHost(workspaceRoot, host) {
140
+ if (host) return host;
141
+ return workspaceHosts(workspaceRoot).find(
142
+ (h) => h.pluginContext === DDK_PLUGIN_CONTEXT
143
+ )?.name;
144
+ }
145
+
146
+ /** Undoes the generic generator's default registration with a non-DDK host. */
147
+ export function unregisterPlugin(workspaceRoot, name) {
148
+ const file = rootKosJsonPath(workspaceRoot);
149
+ if (!fs.existsSync(file)) return;
150
+ const rootConfig = readJson(file);
151
+ let changed = false;
152
+ for (const h of rootConfig.development?.hosts ?? []) {
153
+ const plugins = (h.plugins ?? []).filter((p) => p.project !== name);
154
+ if (plugins.length !== (h.plugins ?? []).length) {
155
+ h.plugins = plugins;
156
+ changed = true;
157
+ }
158
+ }
159
+ if (changed) writeJson(file, rootConfig);
100
160
  }
101
161
 
102
162
  /**
103
163
  * Creates a DDK plugin or theme project. A dry run lists the generic generator's
104
164
  * changes and the DDK files that would be written over them.
165
+ * A plugin registers with `host`, else with the workspace's DDK host, else with none.
166
+ *
167
+ * A descriptor project starts from the NCUI descriptor `ncui` describes: its layout
168
+ * (default standard) and options (carb, ice, beveragePourTest; all off by default).
105
169
  *
106
- * @param {"plugin" | "theme"} kind
107
- * @param {{workspaceRoot: string, name: string, dryRun?: boolean, stdio?: "pipe" | "inherit"}} options
170
+ * @param {"plugin" | "theme" | "descriptor"} kind
171
+ * @param {{workspaceRoot: string, name: string, directory?: string, host?: string,
172
+ * ncui?: object, dryRun?: boolean, stdio?: "pipe" | "inherit"}} options
108
173
  */
109
174
  export function createDdkProject(
110
175
  kind,
111
- { workspaceRoot, name, dryRun = false, stdio = "pipe" }
176
+ {
177
+ workspaceRoot,
178
+ name,
179
+ directory,
180
+ host,
181
+ ncui = {},
182
+ dryRun = false,
183
+ stdio = "pipe",
184
+ }
112
185
  ) {
113
186
  const spec = PROJECT_KINDS[kind];
187
+ if (kind === "descriptor") buildNcuiDescriptor(ncui);
188
+ const before = declaredPackages(workspaceRoot);
189
+ const registerWith =
190
+ kind === "plugin" ? pluginHost(workspaceRoot, host) : undefined;
114
191
  const result = spawnSync(
115
192
  "npx",
116
193
  [
@@ -118,7 +195,9 @@ export function createDdkProject(
118
195
  "generate",
119
196
  spec.generator,
120
197
  `--name=${name}`,
121
- `--uiType=${spec.uiType}`,
198
+ ...(spec.uiType ? [`--uiType=${spec.uiType}`] : []),
199
+ ...(directory ? [`--directory=${directory}`] : []),
200
+ ...(registerWith ? [`--host=${registerWith}`] : []),
122
201
  "--no-interactive",
123
202
  ...(dryRun ? ["--dry-run"] : []),
124
203
  ],
@@ -135,10 +214,29 @@ export function createDdkProject(
135
214
  );
136
215
  }
137
216
  const output = result.stdout?.trim() ?? "";
138
- if (dryRun) return { output, ddkFiles: templateFiles(kind) };
217
+ if (dryRun) {
218
+ return {
219
+ output,
220
+ ddkFiles:
221
+ kind === "descriptor"
222
+ ? [
223
+ `.kos.json: type ${DESCRIPTOR_KAB_TYPE}, kondra.ncui for the ${
224
+ ncui.layout ?? "standard"
225
+ } layout`,
226
+ ]
227
+ : templateFiles(kind),
228
+ };
229
+ }
139
230
 
140
231
  const project = findProjectByName(workspaceRoot, name);
141
232
  if (!project) throw new Error(`nx generate did not create project ${name}`);
142
- applyDdkLayer(kind, workspaceRoot, path.join(workspaceRoot, project.root));
143
- return { output, root: project.root };
233
+ if (kind === "plugin" && !registerWith) unregisterPlugin(workspaceRoot, name);
234
+ applyDdkLayer(kind, workspaceRoot, path.join(workspaceRoot, project.root), {
235
+ ncui,
236
+ });
237
+ const installed = path.join(workspaceRoot, "node_modules");
238
+ const toInstall = Object.keys(declaredPackages(workspaceRoot)).filter(
239
+ (name) => !before[name] && !fs.existsSync(path.join(installed, name))
240
+ );
241
+ return { output, root: project.root, toInstall };
144
242
  }
package/src/extension.mjs CHANGED
@@ -4,6 +4,8 @@ import * as agentInstall from "./generators/agent-install.mjs";
4
4
  import * as catalog from "./generators/catalog.mjs";
5
5
  import * as contributions from "./generators/contributions.mjs";
6
6
  import * as dashboard from "./generators/dashboard.mjs";
7
+ import * as descriptorEntries from "./generators/descriptor-entries.mjs";
8
+ import * as descriptorProject from "./generators/descriptor-project.mjs";
7
9
  import * as dev from "./generators/dev.mjs";
8
10
  import * as pluginProject from "./generators/plugin-project.mjs";
9
11
  import * as themeProject from "./generators/theme-project.mjs";
@@ -16,6 +18,14 @@ export default {
16
18
  { metadata: catalog.metadata, register: catalog.register },
17
19
  { metadata: pluginProject.metadata, register: pluginProject.register },
18
20
  { metadata: themeProject.metadata, register: themeProject.register },
21
+ {
22
+ metadata: descriptorProject.metadata,
23
+ register: descriptorProject.register,
24
+ },
25
+ {
26
+ metadata: descriptorEntries.metadata,
27
+ register: descriptorEntries.register,
28
+ },
19
29
  { metadata: dev.metadata, register: dev.register },
20
30
  { metadata: agentInstall.metadata, register: agentInstall.register },
21
31
  ],
@@ -13,6 +13,8 @@ export const AGENT_PLUGIN_DIR = path.resolve(
13
13
  export const metadata = {
14
14
  key: "ddk:agent-install",
15
15
  name: "DDK Agent Plugin Install",
16
+ description:
17
+ "Install the kos-ddk-tools agent plugin (kos-ddk MCP server) for an agent client",
16
18
  invalidateCache: false,
17
19
  namedArguments: {
18
20
  client: "client",
@@ -53,8 +55,7 @@ export async function register(plop, { host }) {
53
55
  });
54
56
 
55
57
  plop.setGenerator("ddk:agent-install", {
56
- description:
57
- "Install the kos-ddk-tools agent plugin (kos-ddk MCP server) for an agent client",
58
+ description: metadata.description,
58
59
  prompts: [
59
60
  ...host.DEFAULT_PROMPTS,
60
61
  {
@@ -1,6 +1,7 @@
1
1
  // ddk:contributions: the standard contributions a ddk:<point> --override can replace.
2
2
  import {
3
3
  OVERRIDABLE_POINTS,
4
+ describeOverridablePoints,
4
5
  listOverridableContributions,
5
6
  } from "../codegen/overrides.mjs";
6
7
 
@@ -8,6 +9,8 @@ export const metadata = [
8
9
  {
9
10
  key: "ddk:contributions",
10
11
  name: "DDK Overridable Contributions",
12
+ description:
13
+ "List the standard DDK contributions a ddk:<point> --override can replace",
11
14
  invalidateCache: false,
12
15
  namedArguments: { point: "point", interactive: "interactive" },
13
16
  },
@@ -21,10 +24,19 @@ export function formatOverridableContributions(point) {
21
24
  const entries = listOverridableContributions(point || undefined);
22
25
  if (entries.length === 0) return "No overridable contributions.";
23
26
  const lines = [];
24
- for (const name of Object.keys(OVERRIDABLE_POINTS)) {
27
+ for (const {
28
+ point: name,
29
+ contributionKeys,
30
+ noStandardContributions,
31
+ } of describeOverridablePoints(point || undefined)) {
25
32
  const group = entries.filter((entry) => entry.point === name);
26
33
  if (group.length === 0) continue;
27
- lines.push(`ddk:${name}`);
34
+ const unfilled = noStandardContributions
35
+ ? `; no standard ${noStandardContributions.join(", ")}`
36
+ : "";
37
+ lines.push(
38
+ `ddk:${name} (writes ${contributionKeys.join(", ")}${unfilled})`
39
+ );
28
40
  for (const entry of group) {
29
41
  const slot = Object.entries(entry.keys)
30
42
  .map(([key, value]) => `${key}=${value}`)
@@ -47,8 +59,7 @@ export async function register(plop, { host }) {
47
59
  formatOverridableContributions(answers.point)
48
60
  );
49
61
  plop.setGenerator("ddk:contributions", {
50
- description:
51
- "List the standard DDK contributions a ddk:<point> --override can replace",
62
+ description: metadata[0].description,
52
63
  prompts: [
53
64
  ...host.DEFAULT_PROMPTS,
54
65
  {
@@ -18,18 +18,22 @@ const rankArguments = {
18
18
  override: "override",
19
19
  rank: "rank",
20
20
  descriptor: "descriptor",
21
+ descriptorProject: "descriptorProject",
22
+ roles: "roles",
21
23
  };
22
24
 
23
25
  export const metadata = Object.entries(CONTRIBUTION_TYPES).map(
24
26
  ([type, spec]) => ({
25
27
  key: `ddk:${type}`,
26
28
  name: spec.label,
29
+ description: spec.description,
27
30
  projectType: "plugin",
28
31
  invalidateCache: false,
29
32
  namedArguments: {
30
33
  ...baseArguments,
31
- ...(spec.group ? { group: "group" } : {}),
32
34
  ...(spec.overridable ? rankArguments : {}),
35
+ ...(spec.descriptorType === "utility" ? { column: "column" } : {}),
36
+ ...(spec.required ? { descriptor: "descriptor" } : {}),
33
37
  },
34
38
  })
35
39
  );
@@ -45,10 +49,12 @@ export async function register(plop, { host }) {
45
49
  type: config.data.type,
46
50
  name: answers.componentName,
47
51
  project: answers.componentProject,
48
- group: answers.group,
49
52
  descriptor: answers.descriptor,
50
53
  override: answers.override,
51
54
  rank: answers.rank,
55
+ descriptorProject: answers.descriptorProject || undefined,
56
+ roles: answers.roles || undefined,
57
+ column: answers.column || undefined,
52
58
  });
53
59
  return host.reportCodegen(
54
60
  codegenFs,
@@ -65,7 +71,7 @@ export async function register(plop, { host }) {
65
71
  const type = meta.key.slice("ddk:".length);
66
72
  const spec = CONTRIBUTION_TYPES[type];
67
73
  plop.setGenerator(meta.key, {
68
- description: `Create a ${spec.label}`,
74
+ description: spec.description,
69
75
  prompts: [
70
76
  ...host.DEFAULT_PROMPTS,
71
77
  {
@@ -80,12 +86,12 @@ export async function register(plop, { host }) {
80
86
  message: "Which plugin project should the component be created in?",
81
87
  choices: pluginProjects,
82
88
  },
83
- ...(spec.group
89
+ ...(spec.required
84
90
  ? [
85
91
  {
86
92
  type: "input",
87
- name: "group",
88
- message: "Which settings group should the setting be located?",
93
+ name: "descriptor",
94
+ message: `${spec.required}?`,
89
95
  validate: host.required,
90
96
  },
91
97
  ]
@@ -100,6 +106,35 @@ export async function register(plop, { host }) {
100
106
  default: "",
101
107
  when: (answers) => !answers.override,
102
108
  },
109
+ {
110
+ type: "input",
111
+ name: "descriptorProject",
112
+ message:
113
+ "Descriptor project to list it in (blank: none; see ddk:descriptor-project)?",
114
+ default: "",
115
+ when: (answers) => !answers.override,
116
+ },
117
+ {
118
+ type: "input",
119
+ name: "roles",
120
+ message:
121
+ "Roles that see it, comma-separated (blank: the default)?",
122
+ default: "",
123
+ when: (answers) =>
124
+ !answers.override && !!answers.descriptorProject,
125
+ },
126
+ ...(spec.descriptorType === "utility"
127
+ ? [
128
+ {
129
+ type: "input",
130
+ name: "column",
131
+ message: "Utilities column (blank: the last)?",
132
+ default: "",
133
+ when: (answers) =>
134
+ !answers.override && !!answers.descriptorProject,
135
+ },
136
+ ]
137
+ : []),
103
138
  ]
104
139
  : []),
105
140
  ],
@@ -35,7 +35,7 @@ const COMMANDS = [
35
35
  point: "dashboard-card",
36
36
  name: "DDK Dashboard Card",
37
37
  description:
38
- "Create a dashboard summary card and the detail it opens, sharing one dashboardKey",
38
+ "Create a dashboard summary card and the detail it opens, sharing one dashboardKey and rank; --detail false writes the summary only",
39
39
  namedArguments: {
40
40
  ...common,
41
41
  dashboardKey: "dashboardKey",
@@ -85,7 +85,7 @@ const COMMANDS = [
85
85
  point: "pump-card",
86
86
  name: "DDK Pump Card",
87
87
  description:
88
- "Create a pump card for a pump type: the holder card body and the pump detail, sharing one dashboardKey",
88
+ "Create a pump card for a pump type: the holder card body and the pump detail, sharing one dashboardKey and rank; --detail false writes the body only",
89
89
  namedArguments: {
90
90
  ...common,
91
91
  dashboardKey: "dashboardKey",
@@ -174,13 +174,16 @@ const COMMANDS = [
174
174
  },
175
175
  ];
176
176
 
177
- export const metadata = COMMANDS.map(({ key, name, namedArguments }) => ({
178
- key,
179
- name,
180
- projectType: "plugin",
181
- invalidateCache: false,
182
- namedArguments,
183
- }));
177
+ export const metadata = COMMANDS.map(
178
+ ({ key, name, description, namedArguments }) => ({
179
+ key,
180
+ name,
181
+ description,
182
+ projectType: "plugin",
183
+ invalidateCache: false,
184
+ namedArguments,
185
+ })
186
+ );
184
187
 
185
188
  export async function register(plop, { host }) {
186
189
  const pluginProjects = await host.getPluginProjectsWithFallback();
@@ -0,0 +1,53 @@
1
+ // ddk:descriptor-entries: lists the utility, setup step and navigation slots a plugin
2
+ // already contributes in an NCUI descriptor project.
3
+ import { addPluginDescriptorEntries } from "../codegen/descriptor.mjs";
4
+
5
+ export const metadata = {
6
+ key: "ddk:descriptor-entries",
7
+ name: "DDK Descriptor Entries",
8
+ description:
9
+ "List a plugin's utility, setup step and navigation slots in an NCUI descriptor project (for contributions written before it)",
10
+ projectType: "plugin",
11
+ invalidateCache: false,
12
+ namedArguments: {
13
+ project: "componentProject",
14
+ descriptorProject: "descriptorProject",
15
+ dryRun: "dryRun",
16
+ interactive: "interactive",
17
+ },
18
+ };
19
+
20
+ export async function register(plop, { host }) {
21
+ const pluginProjects = await host.getPluginProjectsWithFallback();
22
+
23
+ plop.setActionType("ddk:addDescriptorEntries", (answers) => {
24
+ const cwd = process.cwd();
25
+ const dryRun = !!answers.dryRun;
26
+ const codegenFs = host.codegenFsFor(cwd, dryRun);
27
+ const { notes } = addPluginDescriptorEntries(codegenFs, {
28
+ project: answers.componentProject,
29
+ descriptorProject: answers.descriptorProject,
30
+ });
31
+ return host.reportCodegen(codegenFs, cwd, dryRun, notes.join("\n"));
32
+ });
33
+
34
+ plop.setGenerator("ddk:descriptor-entries", {
35
+ description: metadata.description,
36
+ prompts: [
37
+ ...host.DEFAULT_PROMPTS,
38
+ {
39
+ type: "list",
40
+ name: "componentProject",
41
+ message: "Which plugin project?",
42
+ choices: pluginProjects,
43
+ },
44
+ {
45
+ type: "input",
46
+ name: "descriptorProject",
47
+ message: "Which descriptor project?",
48
+ validate: host.required,
49
+ },
50
+ ],
51
+ actions: host.actionFactory("ddk:addDescriptorEntries", metadata),
52
+ });
53
+ }
@@ -0,0 +1,79 @@
1
+ // ddk:descriptor-project: an NCUI descriptor project. kos-nx-plugin's generic content
2
+ // project as a ddk.ncui.descriptor KAB, with the NCUI descriptor for a layout and the
3
+ // dispenser's options.
4
+ import { createDdkProject } from "../codegen/project.mjs";
5
+ import { NCUI_LAYOUTS, NCUI_OPTIONS } from "../codegen/ncui-descriptor.mjs";
6
+
7
+ const installNote = (toInstall) =>
8
+ toInstall?.length
9
+ ? `Run npm install: the project added ${toInstall.join(", ")}.`
10
+ : "";
11
+
12
+ const flag = (value) => value === true || value === "true";
13
+
14
+ export const metadata = {
15
+ key: "ddk:descriptor-project",
16
+ name: "DDK NCUI Descriptor Project",
17
+ description:
18
+ "Create an NCUI descriptor project (a ddk.ncui.descriptor KAB): --layout standard or compact; --carb, --ice and --beveragePourTest add those (off by default)",
19
+ invalidateCache: true,
20
+ namedArguments: {
21
+ name: "name",
22
+ layout: "layout",
23
+ ...Object.fromEntries(Object.keys(NCUI_OPTIONS).map((o) => [o, o])),
24
+ interactive: "interactive",
25
+ },
26
+ };
27
+
28
+ export async function register(plop, { host }) {
29
+ plop.setActionType("ddk:createDescriptorProject", (answers) => {
30
+ const ncui = {
31
+ layout: answers.layout || "standard",
32
+ ...Object.fromEntries(
33
+ Object.keys(NCUI_OPTIONS).map((o) => [o, flag(answers[o])])
34
+ ),
35
+ };
36
+ const { root, toInstall } = createDdkProject("descriptor", {
37
+ workspaceRoot: process.cwd(),
38
+ name: answers.name,
39
+ ncui,
40
+ stdio: "inherit",
41
+ });
42
+ const on = Object.keys(NCUI_OPTIONS).filter((o) => ncui[o]);
43
+ return [
44
+ `DDK NCUI descriptor project ${answers.name} created at ${root}: ${
45
+ ncui.layout
46
+ } layout${on.length ? `, with ${on.join(", ")}` : ""}.`,
47
+ `Installed beside the DDK app, its KAB replaces the system app's NCUI descriptor. List a new utility, setup step or navigation in it with --descriptorProject ${answers.name} on ddk:utility, ddk:setup and ddk:nav.`,
48
+ installNote(toInstall),
49
+ ]
50
+ .filter(Boolean)
51
+ .join("\n");
52
+ });
53
+
54
+ plop.setGenerator("ddk:descriptor-project", {
55
+ description: metadata.description,
56
+ prompts: [
57
+ {
58
+ type: "input",
59
+ name: "name",
60
+ message: "What is the name of the descriptor project?",
61
+ validate: host.required,
62
+ },
63
+ {
64
+ type: "list",
65
+ name: "layout",
66
+ message: "Which layout?",
67
+ choices: NCUI_LAYOUTS,
68
+ default: "standard",
69
+ },
70
+ ...Object.entries(NCUI_OPTIONS).map(([name, what]) => ({
71
+ type: "confirm",
72
+ name,
73
+ message: `Include ${what}?`,
74
+ default: false,
75
+ })),
76
+ ],
77
+ actions: host.actionFactory("ddk:createDescriptorProject", metadata),
78
+ });
79
+ }