@kosdev-code/kos-ddk-cli 0.0.0-stage → 0.1.0-dev.107

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 (124) hide show
  1. package/README.md +181 -2
  2. package/agent-plugin/.claude-plugin/marketplace.json +13 -0
  3. package/agent-plugin/kos-ddk-tools/.claude-plugin/plugin.json +8 -0
  4. package/agent-plugin/kos-ddk-tools/.mcp.json +11 -0
  5. package/agent-plugin/kos-ddk-tools/agents/kos-ddk-plugin-planner.md +45 -0
  6. package/agent-plugin/kos-ddk-tools/agents/kos-ddk-plugin-reviewer.md +43 -0
  7. package/agent-plugin/kos-ddk-tools/catalog/contributions.json +965 -0
  8. package/agent-plugin/kos-ddk-tools/mcp.json +12 -0
  9. package/agent-plugin/kos-ddk-tools/plugin.json +7 -0
  10. package/agent-plugin/kos-ddk-tools/reference/reference.json +21161 -0
  11. package/agent-plugin/kos-ddk-tools/servers/kos-ddk.mjs +48656 -0
  12. package/agent-plugin/kos-ddk-tools/skills/build-ddk-plugin/SKILL.md +110 -0
  13. package/agent-plugin/kos-ddk-tools/skills/ddk-config-page/SKILL.md +130 -0
  14. package/agent-plugin/kos-ddk-tools/skills/ddk-content-component/SKILL.md +59 -0
  15. package/agent-plugin/kos-ddk-tools/skills/ddk-storybook/SKILL.md +45 -0
  16. package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.stories.tsx__template__ +32 -0
  17. package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.tsx__template__ +35 -0
  18. package/agent-plugin/kos-ddk-tools/templates/cui/index.ts__template__ +1 -0
  19. package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +34 -0
  20. package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/__nameDashCase__.tsx__template__ +52 -0
  21. package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/index.ts__template__ +1 -0
  22. package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
  23. package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
  24. package/agent-plugin/kos-ddk-tools/templates/dashboard-region/index.ts__template__ +1 -0
  25. package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +34 -0
  26. package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/__nameDashCase__.tsx__template__ +41 -0
  27. package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/index.ts__template__ +1 -0
  28. package/agent-plugin/kos-ddk-tools/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  29. package/agent-plugin/kos-ddk-tools/templates/macro-summary/__nameDashCase__.tsx__template__ +24 -0
  30. package/agent-plugin/kos-ddk-tools/templates/macro-summary/index.ts__template__ +1 -0
  31. package/agent-plugin/kos-ddk-tools/templates/nav/__nameDashCase__.stories.tsx__template__ +32 -0
  32. package/agent-plugin/kos-ddk-tools/templates/nav/__nameDashCase__.tsx__template__ +27 -0
  33. package/agent-plugin/kos-ddk-tools/templates/nav/index.ts__template__ +1 -0
  34. package/agent-plugin/kos-ddk-tools/templates/plugin-project/.storybook/preview.tsx.template +113 -0
  35. package/agent-plugin/kos-ddk-tools/templates/plugin-project/.storybook/registration.ts.template +6 -0
  36. package/agent-plugin/kos-ddk-tools/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +34 -0
  37. package/agent-plugin/kos-ddk-tools/templates/pump-detail/__nameDashCase__.tsx__template__ +38 -0
  38. package/agent-plugin/kos-ddk-tools/templates/pump-detail/index.ts__template__ +1 -0
  39. package/agent-plugin/kos-ddk-tools/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  40. package/agent-plugin/kos-ddk-tools/templates/pump-summary/__nameDashCase__.tsx__template__ +25 -0
  41. package/agent-plugin/kos-ddk-tools/templates/pump-summary/index.ts__template__ +1 -0
  42. package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.stories.tsx__template__ +32 -0
  43. package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.tsx__template__ +33 -0
  44. package/agent-plugin/kos-ddk-tools/templates/setup/index.ts__template__ +1 -0
  45. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/component.css.template +2 -0
  46. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/generic.css.template +2 -0
  47. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/semantic.css.template +2 -0
  48. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/theme-overlay.css.template +7 -0
  49. package/agent-plugin/kos-ddk-tools/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +31 -0
  50. package/agent-plugin/kos-ddk-tools/templates/trouble-action/__nameDashCase__.tsx__template__ +57 -0
  51. package/agent-plugin/kos-ddk-tools/templates/trouble-action/index.ts__template__ +1 -0
  52. package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.stories.tsx__template__ +60 -0
  53. package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.tsx__template__ +88 -0
  54. package/agent-plugin/kos-ddk-tools/templates/utility/index.ts__template__ +1 -0
  55. package/catalog/contributions.json +965 -0
  56. package/guides/config-property-cards.md +77 -0
  57. package/guides/ddk-dev.md +59 -0
  58. package/guides/getting-started.md +126 -0
  59. package/guides/storybook.md +127 -0
  60. package/package.json +33 -3
  61. package/reference/reference.json +21161 -0
  62. package/src/build-paths.mjs +20 -0
  63. package/src/codegen/contribution.mjs +530 -0
  64. package/src/codegen/descriptor.mjs +422 -0
  65. package/src/codegen/json-preserve.mjs +137 -0
  66. package/src/codegen/ncui-descriptor.mjs +167 -0
  67. package/src/codegen/overrides.mjs +263 -0
  68. package/src/codegen/project.mjs +271 -0
  69. package/src/extension.mjs +32 -0
  70. package/src/generators/agent-install.mjs +80 -0
  71. package/src/generators/catalog.mjs +81 -0
  72. package/src/generators/contributions.mjs +164 -0
  73. package/src/generators/dashboard.mjs +282 -0
  74. package/src/generators/descriptor-entries.mjs +53 -0
  75. package/src/generators/descriptor-project.mjs +84 -0
  76. package/src/generators/dev.mjs +231 -0
  77. package/src/generators/override-prompts.mjs +27 -0
  78. package/src/generators/plugin-project.mjs +71 -0
  79. package/src/generators/theme-project.mjs +53 -0
  80. package/src/handlers.mjs +335 -0
  81. package/src/mcp/pkg-info.mjs +7 -0
  82. package/src/mcp/plugin-inspect.mjs +328 -0
  83. package/src/mcp/reference.mjs +315 -0
  84. package/src/mcp/server.mjs +12 -0
  85. package/src/mcp/tools.mjs +619 -0
  86. package/templates/cui/__nameDashCase__.stories.tsx__template__ +32 -0
  87. package/templates/cui/__nameDashCase__.tsx__template__ +35 -0
  88. package/templates/cui/index.ts__template__ +1 -0
  89. package/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +34 -0
  90. package/templates/dashboard-detail/detail/__nameDashCase__.tsx__template__ +52 -0
  91. package/templates/dashboard-detail/detail/index.ts__template__ +1 -0
  92. package/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
  93. package/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
  94. package/templates/dashboard-region/index.ts__template__ +1 -0
  95. package/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +34 -0
  96. package/templates/dashboard-summary/summary/__nameDashCase__.tsx__template__ +41 -0
  97. package/templates/dashboard-summary/summary/index.ts__template__ +1 -0
  98. package/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  99. package/templates/macro-summary/__nameDashCase__.tsx__template__ +24 -0
  100. package/templates/macro-summary/index.ts__template__ +1 -0
  101. package/templates/nav/__nameDashCase__.stories.tsx__template__ +32 -0
  102. package/templates/nav/__nameDashCase__.tsx__template__ +27 -0
  103. package/templates/nav/index.ts__template__ +1 -0
  104. package/templates/plugin-project/.storybook/preview.tsx.template +113 -0
  105. package/templates/plugin-project/.storybook/registration.ts.template +6 -0
  106. package/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +34 -0
  107. package/templates/pump-detail/__nameDashCase__.tsx__template__ +38 -0
  108. package/templates/pump-detail/index.ts__template__ +1 -0
  109. package/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  110. package/templates/pump-summary/__nameDashCase__.tsx__template__ +25 -0
  111. package/templates/pump-summary/index.ts__template__ +1 -0
  112. package/templates/setup/__nameDashCase__.stories.tsx__template__ +32 -0
  113. package/templates/setup/__nameDashCase__.tsx__template__ +33 -0
  114. package/templates/setup/index.ts__template__ +1 -0
  115. package/templates/theme-project/theme/assets/component.css.template +2 -0
  116. package/templates/theme-project/theme/assets/generic.css.template +2 -0
  117. package/templates/theme-project/theme/assets/semantic.css.template +2 -0
  118. package/templates/theme-project/theme/assets/theme-overlay.css.template +7 -0
  119. package/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +31 -0
  120. package/templates/trouble-action/__nameDashCase__.tsx__template__ +57 -0
  121. package/templates/trouble-action/index.ts__template__ +1 -0
  122. package/templates/utility/__nameDashCase__.stories.tsx__template__ +60 -0
  123. package/templates/utility/__nameDashCase__.tsx__template__ +88 -0
  124. package/templates/utility/index.ts__template__ +1 -0
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: build-ddk-plugin
3
+ description: >-
4
+ Build or extend a DDK plugin with the kos-ddk MCP server: find the extension point
5
+ for a need, write the contribution with its tool (including overrides of standard
6
+ contributions), build its component from DDK components, develop it in Storybook or
7
+ against a running DDK, and validate it. Use when adding a utility, setup step, nav
8
+ view (including a Settings tab), CUI configuration, dashboard card, pump detail, macro summary,
9
+ dashboard region or trouble action to a DDK plugin, or replacing a standard one.
10
+ ---
11
+
12
+ # Build a DDK plugin
13
+
14
+ A DDK plugin contributes to extension points in its `.kos.json` and renders DDK
15
+ components inside them. The `kos-ddk` tools write the contributions; you write the
16
+ component content. Never hand-edit the contributions or experiences the tools write.
17
+
18
+ ## Workflow
19
+
20
+ 1. **Ground yourself.** Read `ddk://index`. Ask `find_ddk_capability` in plain words
21
+ ("replace the carb tank card", "a utility that downloads logs"): it names the
22
+ extension point, the standard contribution to replace, the components and the tool.
23
+
24
+ 2. **The plugin project.** For an existing project, `describe_ddk_plugin` shows what it
25
+ already contributes. For a new one, `scaffold_ddk_plugin_project` (dry run, then
26
+ `dryRun: false`). Project names are dash-case.
27
+
28
+ 3. **The extension point.** Read `ddk://extension-point/{id}`: its contribution fields,
29
+ the props your component receives and the standard contributions. A Settings tab
30
+ is a navigation view: `add_nav_view` with a `settings.<name>` descriptor. A page or
31
+ utility that edits device configuration (most Settings tabs, a utility that
32
+ configures a service) follows the `ddk-config-page` skill.
33
+
34
+ 4. **Replacing a standard contribution.** `list_ddk_contributions` lists the ones an
35
+ override can replace. Pass the id as `override`: the tool takes its slot and gives
36
+ the contribution a winning rank. The framework resolves the slot by rank (lowest wins;
37
+ an unranked contribution loses to any ranked one), so never add precedence logic of
38
+ your own.
39
+
40
+ 5. **Write the contribution** with the point's tool, dry run first, then
41
+ `dryRun: false`. It writes the component, its story, the `.kos.json` contribution
42
+ and experience, and the i18n title. If the result warns that the component shares
43
+ its name with a model's registration bean, choose another name before writing.
44
+
45
+ Pump cards are keyed by pump type: the backend assembly assigns it to the holder's
46
+ first pump, and the default dashboard key factory returns it. A new pump type is
47
+ `add_pump_card` with `dashboardKey` set to that type (the card body and the pump
48
+ detail); no factory is needed. A dashboard key factory is for variants of a pump
49
+ type (e.g. `lfcv-x` from pump or holder properties) and for nonstandard cards keyed
50
+ from another part of the assembly. Register it in the plugin's `src/app/init.ts`
51
+ with `ExtensionManager.registerDashboardKeyFactory({ rank, factory })`, rank below
52
+ 999, returning `undefined` for holders it does not recognise. A holder gets every
53
+ key its factories return, lowest rank first, then its pump type; each card uses
54
+ the first key it has a contribution for, so `lfcv-x` holders fall back to the
55
+ `lfcv` summary or detail when the plugin contributes only one of them.
56
+
57
+ 6. **The NCUI descriptor.** A utility, setup step or nav view appears only if the
58
+ device's NCUI descriptor lists its descriptor (`kondra.ncui` `utilities`,
59
+ `setup.steps`, `navigations`). An override reuses a slot the descriptor already
60
+ lists; a new slot goes in an NCUI descriptor project (a `ddk.ncui.descriptor` KAB
61
+ installed beside the DDK app, which replaces the system app's descriptor): create one
62
+ with `scaffold_ddk_descriptor_project` (layout `standard` or `compact`, and `carb`, `ice`,
63
+ `beveragePourTest` for the dispenser) if the workspace
64
+ has none, and pass `descriptorProject` to `add_utility`, `add_setup_step` or
65
+ `add_nav_view`. `ddk://guide/descriptor-project` lists each layout's entries and what each option adds.
66
+
67
+ A whole dashboard region is `add_dashboard_region`: its component renders the
68
+ descriptor region whose `component` (else `name`) is `regionKey`, in place of that
69
+ region's built-in cards. A built-in region name (`micros`, `macros`, `assembly`)
70
+ replaces that region's cards. A region of its own, such as a dispenser map, is
71
+ `descriptorProject`: it adds a region that claims no holders or summaries, so every
72
+ card stays where it was and the component reads the `assembly`; the region shows
73
+ only while a plugin contributes its key.
74
+
75
+ 7. **Register the models it uses.** A model the plugin renders is registered by the
76
+ plugin's init lifecycle: `register_model` with `app` set to the plugin project (dry
77
+ run, then `dryRun: false`). It sets `kos.ui.plugin.init: true`, writes
78
+ `src/app/init.ts`, whose `register()` the host calls when it loads the plugin, and
79
+ calls it in `.storybook/registration.ts` before `initDDKRegistration()`. Never use
80
+ `@kosModel({ autoRegister: true })` for a plugin's model.
81
+
82
+ 8. **Build the component** with the `ddk-content-component` skill.
83
+
84
+ 9. **Develop it.** In Storybook with the `ddk-storybook` skill. Against a running device
85
+ or simulator with `kosui ddk:dev` (`ddk://guide/ddk-dev`); that is where an override
86
+ is seen replacing the standard contribution. In `ddk:dev`:
87
+ - Serve the descriptor project before opening the URL, unless its KAB is installed:
88
+ `kosui fixtures serve` in the workspace, and add
89
+ `&kosMock=on&kosFixtureServer=&kosSetup=<descriptor-project>` to the printed URL.
90
+ A new slot shows only once the descriptor lists it, and so does an override of a
91
+ slot only the descriptor project adds (`carbTank` with `carb`).
92
+ - Log in with a role the slot lists: Utilities and Settings are technician-only in
93
+ the standard descriptor.
94
+ - Show pump cards and pump details on a holder with no active troubles; a holder's
95
+ troubles take the place of its card body and detail. Storybook's container picks a
96
+ holder with the `dashboardKey`.
97
+
98
+ 10. **Validate.** `validate_ddk_plugin` checks the fields against each point's schema,
99
+ ranks, experiences and their component files, overrides that do not win and tokens
100
+ set in plugin code. Then delegate to the `kos-ddk-plugin-reviewer` subagent and act
101
+ on its findings here. Not sure of the plan before step 5? The
102
+ `kos-ddk-plugin-planner` subagent returns the tool calls without writing anything.
103
+
104
+ ## Rules
105
+
106
+ - Plugins compose DDK components; the design tokens belong to the DDK app and its
107
+ themes. A plugin never sets or overrides a token.
108
+ - Every write goes through a tool, dry run first.
109
+ - A plugin's models register through its init lifecycle (`register_model` into the
110
+ plugin), never with `autoRegister`.
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: ddk-config-page
3
+ description: >-
4
+ Build a DDK Settings tab, a utility, or any DDK page that shows or edits device
5
+ configuration: model the configuration (SettingsModel, the plugin's own
6
+ @kosConfigProperty fields, one model per repeated entry such as cup sizes with prop
7
+ keys, or a whole @kosConfigBean for batched edits), register the model through the
8
+ plugin's init lifecycle, hand it to the page, and render the ConfigProp* cards. Use
9
+ when asked about DDK configuration input components, config property cards, cup
10
+ sizes, a utility that configures a service, or a page that changes dispenser settings.
11
+ ---
12
+
13
+ # Build a DDK page on configuration properties
14
+
15
+ The page renders configuration that lives on a model; the model binds it to the device.
16
+ The cards are described in `ddk://guide/config-property-cards`.
17
+
18
+ ## Steps
19
+
20
+ 1. **Contribute the page.** A Settings tab is a navigation view: `add_nav_view` with a
21
+ `settings.<name>` descriptor. A utility that configures a service is `add_utility`;
22
+ name it `<thing>-config` so its component (`<Thing>Config`) does not share a name
23
+ with the model's registration bean (the tool warns when it would). See the
24
+ build-ddk-plugin skill for the descriptor entry.
25
+
26
+ 2. **Choose the mode.**
27
+ - **Config properties** (the usual case): the model has one `@kosConfigProperty` per
28
+ value. Each is a typed `KosConfigProperty` with unit conversion, formatting and
29
+ `options`, and each card writes its own property.
30
+ - **A config bean**: the model holds the whole bean at a path with `@kosConfigBean`
31
+ (`kos://decorator/kosConfigBean`): `values`, the schema, and `updateProperty(key,
32
+ value)`, which posts the whole bean. Use it when the page edits a set of values and
33
+ applies them together, or walks the schema. No unit conversion.
34
+
35
+ 3. **Model the configuration.**
36
+ - DDK settings (date and time formats, water and beverage visibility) are already on
37
+ `SettingsModel`.
38
+ - Your own values: find the config path and each attribute on a live device with the
39
+ kos-device tools (`search_config`, then `describe_config_path` for each attribute's
40
+ type and any `displayOptions` `min`/`max`). Scaffold the model in the workspace's
41
+ models project with `scaffold_model` (`singleton: true` for one config bean, and
42
+ no `autoRegister`), then add each value with `add_config_property`, passing the
43
+ config path exactly as the device gives it, e.g.
44
+ `app:kondra.fdt.triple-nozzle:service:shelf`. The tool declares a
45
+ `CONFIG_PATH_<NAME>` constant for it and reuses it
46
+ for every later attribute on that path. `valueType` is `string` for a String and
47
+ `number` for an int or double. Never hand-write the decorator.
48
+ - **Repeated entries** (cup sizes and the like: `cups.0.*` … `cups.4.*` in one bean):
49
+ one model type whose attributes carry a prop key, and a container that creates an
50
+ instance per entry (`kos://guide/prop-keys`):
51
+
52
+ ```typescript
53
+ const PROP_INDEX = createPropKey<CupModel>("index");
54
+
55
+ @kosConfigProperty({ path: PATH, attribute: `cups.${PROP_INDEX}.volume` })
56
+ volume!: KosConfigProperty<number>;
57
+
58
+ constructor(modelId: string, options: CupOptions) {
59
+ this.id = modelId;
60
+ this.index = options.index.toString(); // set before the properties resolve
61
+ }
62
+ ```
63
+
64
+ The container (`add_container_support`, singleton) builds the instances in `init`
65
+ (`Cup.instance(id).options({ index }).build()`, then `addModel`), registers `Cup`
66
+ with `addRelatedModel`, and adds the views the UI needs (enabled cups sorted by
67
+ volume, the largest cup).
68
+ - A bean: add `@kosConfigBean` by hand; no codegen tool writes it.
69
+
70
+ 4. **Register the model through the plugin's init lifecycle.** A model the plugin uses
71
+ is registered when the host loads the plugin, never by `@kosModel({ autoRegister:
72
+ true })`. Run `register_model` with `app` set to the plugin project (dry run, then
73
+ `dryRun: false`). It sets `kos.ui.plugin.init: true` in the plugin's `.kos.json`,
74
+ writes `src/app/init.ts` (a default class whose `register()` calls
75
+ `<Bean>.register()`), and calls it in `.storybook/registration.ts` before
76
+ `initDDKRegistration()`, which creates KosCore.
77
+
78
+ 5. **Give the page the model.** Wrap it in a `with…` higher-order component or call a
79
+ `use…` hook that loads the model: `withSettings` from kos-ddk-model-components for
80
+ `SettingsModel`, and the same pair for your own model (`withCupContainer` /
81
+ `useCupContainer`). Generate the pair with `create_hook` in the workspace's
82
+ model-components project; it exports the hooks from the project's entry point.
83
+
84
+ 6. **Render it.** One card per property, chosen from its schema
85
+ (`ddk://guide/config-property-cards`): an int with no `min`/`max` is a
86
+ `ConfigPropInputCard` with `layout="num"` and an `isValid`, not a range card. Every
87
+ `ConfigPropInputCard` needs a translated `label`. For repeated entries, one card group
88
+ per instance:
89
+
90
+ ```tsx
91
+ const { model: cupContainer } = useCupContainer();
92
+ return cupContainer?.allCups.map((cup) => (
93
+ <Card key={cup.id}>
94
+ <ConfigPropInputCard configProperty={cup.name} label={t("portion")} />
95
+ <ConfigPropInputCard configProperty={cup.volume} label={t("portion-size")} />
96
+ <ConfigPropToggleCard configProperty={cup.enabled} />
97
+ </Card>
98
+ ));
99
+ ```
100
+
101
+ For a bean, build the form from `values` and `getSchemaForProperty(key)`, keep the
102
+ edits in the page until Save, then write them with `updateProperty`.
103
+
104
+ 7. **Decide when edits are written.** Cards write as each value changes. To apply a
105
+ page's edits together, wrap it in `StagedChangesProvider` and call `saveChanges()`
106
+ from its Save action; only the toggle and time-picker cards stage
107
+ (`ddk://guide/config-property-cards`).
108
+
109
+ 8. **Develop and check it.** In Storybook the page reads and writes the simulator's real
110
+ configuration (ddk-storybook skill). In `kosui ddk:dev`, log in as technician: Settings
111
+ and Utilities are technician-only in the standard descriptor.
112
+
113
+ 9. **Validate.** `validate_model` on the model, `validate_ddk_plugin` on the plugin, then
114
+ `nx lint`, `nx run-many -t typecheck` and `nx run <plugin>:build`. Then the
115
+ `kos-model-reviewer` and `kos-ddk-plugin-reviewer` subagents.
116
+
117
+ ## A utility that edits one config bean
118
+
119
+ The order of tool calls, each dry run first:
120
+
121
+ 1. kos-device: `search_config` for the service, `describe_config_path` for its
122
+ attributes.
123
+ 2. `scaffold_model` in the models project (`singleton: true`, no `autoRegister`).
124
+ 3. `add_config_property` per attribute, with the raw config path.
125
+ 4. `register_model` with `app` = the plugin project.
126
+ 5. `create_hook` for the model in the model-components project.
127
+ 6. `add_utility` named `<thing>-config`, with `descriptorProject` when the slot is new.
128
+ 7. Write the utility's cards from `ddk://guide/config-property-cards` inside the
129
+ `useUtilityModal` modal the tool wrote, and its translation keys.
130
+ 8. Storybook, then the step 9 checks.
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: ddk-content-component
3
+ description: >-
4
+ Build the component a DDK contribution renders by composing components from
5
+ kos-ddk-components and kos-ddk-model-components, using the props its extension point
6
+ passes in and leaving styling to the DDK design system. Use after a kos-ddk tool has
7
+ written a contribution's component file, or when changing what a contribution shows.
8
+ ---
9
+
10
+ # Build a DDK content component
11
+
12
+ The component a contribution renders sits inside a DDK surface (a utility frame, a
13
+ dashboard card, a trouble screen). It is built from DDK components, so it takes the
14
+ look of whichever theme the DDK app applies.
15
+
16
+ ## Workflow
17
+
18
+ 1. **Its inputs.** The extension point resource (`ddk://extension-point/{id}`, "Props
19
+ your component receives") lists what the component is given: `assembly` and
20
+ `cardModel` for dashboard cards, `holder` for pump details and macro summaries,
21
+ `trouble` for trouble actions, and for a dashboard region the `holderGroups` and
22
+ `summaries` it claimed, the `assembly`, its card `size` and `flow`. Read data from
23
+ those props.
24
+
25
+ 2. **Find the components.** `find_ddk_capability` with what the component must show,
26
+ then `list_ddk_components` with a query. Two libraries:
27
+
28
+ - `@kosdev-code/kos-ddk-model-components`: components bound to DDK models (a carb
29
+ tank summary, config property cards, pump cards). When one exists for the model,
30
+ render it, as the standard carb tank summary renders `CarbTankSummary`.
31
+ - `@kosdev-code/kos-ddk-components`: cards, buttons, toggles, pickers, modals and
32
+ the typography components.
33
+
34
+ 3. **Read each component before using it.** `describe_ddk_component` gives its props as
35
+ typed, the components and hooks it uses (for example
36
+ `useComponentConfigurationContext`, which switches it to compact mode), and the
37
+ tokens it reads. Pass props; never guess them.
38
+
39
+ 4. **A utility renders in a modal.** `useUtilityModal({ onComplete, layout, onBack })`
40
+ from `@kosdev-code/kos-ddk-components` gives the `Modal` and `Header` props for the
41
+ standard or compact mode the DDK runs in, and `close()`, which runs `onComplete`
42
+ once the modal has closed. Keep the generated `Modal` / `Header` / `Content` /
43
+ `Footer` and spread its props; do not switch on `componentModeOverride` yourself.
44
+ `layout: "fullscreen"` covers the display (a screen test); in compact mode render
45
+ a Back button in the `Footer` when `showFooterBack` is true.
46
+
47
+ 5. **Text** through the typography components (`Heading`, `Subheading`, `BodyMedium`,
48
+ `LabelSmall` and the rest) rather than styled text of your own.
49
+
50
+ 6. **Check it** in Storybook (the `ddk-storybook` skill), in both render modes.
51
+
52
+ ## Rules
53
+
54
+ - Compose; do not restyle. Do not set or override `--ddk-*` tokens, and do not
55
+ re-create a component the libraries already have.
56
+ - `ddk://design/{theme}` describes the themes for reference. Tokens change only to
57
+ create a new component (component tokens pointing at semantic tokens), which belongs
58
+ in the DDK libraries, or a theme (semantic tokens), which belongs in a theme project
59
+ (`scaffold_ddk_theme_project`). Never in a plugin.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: ddk-storybook
3
+ description: >-
4
+ Develop a DDK contribution in its plugin's Storybook against a running simulator:
5
+ start it, point it at the right KOS host, read what the story container needs from the
6
+ simulator, check both render modes, and know when to move to kosui ddk:dev. Use when
7
+ developing or checking a contribution's component in isolation.
8
+ ---
9
+
10
+ # Develop a DDK contribution in Storybook
11
+
12
+ Every contribution tool writes a story beside the component. `ddk://guide/storybook`
13
+ is the reference; this is the order to work in.
14
+
15
+ ## Workflow
16
+
17
+ 1. **Start the simulator first.** Stories render live models; there is no mock data by
18
+ default.
19
+
20
+ 2. **Start Storybook:** `npx nx run <plugin>:storybook` (port 4400). The plugin's
21
+ `serve` target is the module federation dev server for `kosui ddk:dev`, not
22
+ Storybook.
23
+
24
+ 3. **The KOS host.** KosCore connects to the `?host=` query parameter on the Storybook
25
+ URL, else `KOS_HOST` and `KOS_PORT` in the plugin's `.env` (the generated `.env`
26
+ sets `KOS_PORT=8081`), else the page's origin.
27
+
28
+ 4. **The plugin's models.** A story that loads a model the plugin registers needs
29
+ `.storybook/registration.ts` to run the plugin's init before
30
+ `initDDKRegistration()` (`register_model` into the plugin writes it;
31
+ `ddk://guide/storybook`). A model missing there never loads in the story.
32
+
33
+ 5. **What the story needs.** Each story renders inside its extension point's story
34
+ container (the table in the guide). A dashboard card needs an active model at its
35
+ `dashboardKey`, a pump detail or macro summary a holder with it, a trouble action an
36
+ active trouble of its `troubleType`. A dashboard region story names the holder
37
+ patterns and summary keys its region claims on the container. When the simulator has none, the container says
38
+ so in place of the story: change the simulator's state, not the story.
39
+
40
+ 6. **Both render modes.** The Render Mode toolbar switches between `standard` and
41
+ `compact`; in `compact`, modals render full screen.
42
+
43
+ 7. **Overrides.** The story renders the override on its own. To see it replace the
44
+ standard contribution, load the plugin into a running DDK with `kosui ddk:dev`
45
+ (`ddk://guide/ddk-dev`).
@@ -0,0 +1,32 @@
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 { CUIStoryContainer } 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
+ <CUIStoryContainer>
16
+ <Story args={{ ...context.args }} />
17
+ </CUIStoryContainer>
18
+ ),
19
+ ],
20
+ tags: ["!autodocs"],
21
+ title: "CUI/<%= namePascalCase %>",
22
+ };
23
+
24
+ export default meta;
25
+
26
+ type Story = StoryObj<typeof <%= namePascalCase %>>;
27
+
28
+ export const Default: Story = {
29
+ // parameters: { kosMock: { setups: ["<setup module>"] } },
30
+ render: (props) => <<%= namePascalCase %> {...props} />,
31
+ };
32
+
@@ -0,0 +1,35 @@
1
+ import styled from '@emotion/styled';
2
+ import {
3
+ Button,
4
+ Footer,
5
+ type Experience,
6
+ } from '@kosdev-code/kos-ddk-components';
7
+ import {
8
+ KosLog,
9
+ kosComponent,
10
+ useKosTranslation,
11
+ } from '@kosdev-code/kos-ui-sdk';
12
+
13
+ const log = KosLog.createLogger({name: "<%= nameDashCase %>"})
14
+ log.debug("<%= nameDashCase %> component loaded");
15
+
16
+ const <%= namePascalCase %>Container = styled.div`
17
+ align-items: center;
18
+ display: flex;
19
+ flex-direction: column;
20
+ width: 100%;
21
+ `;
22
+
23
+ export const <%= namePascalCase %>: Experience = kosComponent(({ onComplete }) => {
24
+ const { t } = useKosTranslation('<%= appProject %>');
25
+ return (
26
+ <<%= namePascalCase %>Container>
27
+ Hello from <%= namePascalCase %> CUI Configuration
28
+ <Footer>
29
+ <Button onClick={onComplete}>{t('proceed')}</Button>
30
+ </Footer>
31
+ </<%= namePascalCase %>Container>
32
+ );
33
+ });
34
+
35
+ export default <%= namePascalCase %>
@@ -0,0 +1 @@
1
+ export * from "./<%= nameDashCase %>";
@@ -0,0 +1,34 @@
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 { DashboardDetailStoryContainer } from "@kosdev-code/kos-ddk-story-containers";
7
+ import type { Meta, StoryObj } from "@storybook/react";
8
+ import { <%= namePascalCase %>Detail } from "./<%= nameDashCase %>";
9
+
10
+ const meta: Meta<typeof <%= namePascalCase %>Detail> = {
11
+ args: {},
12
+ component: <%= namePascalCase %>Detail,
13
+ decorators: [
14
+ (Story, context) => (
15
+ <DashboardDetailStoryContainer
16
+ dashboardKey="<%= dashboardKey %>"
17
+ title="<%= namePascalCase %>"
18
+ >
19
+ {(props) => <Story args={{ ...context.args, ...props }} />}
20
+ </DashboardDetailStoryContainer>
21
+ ),
22
+ ],
23
+ tags: ["!autodocs"],
24
+ title: "dashboard/<%= namePascalCase %>/Detail",
25
+ };
26
+
27
+ export default meta;
28
+
29
+ type Story = StoryObj<typeof <%= namePascalCase %>Detail>;
30
+
31
+ export const Default: Story = {
32
+ // parameters: { kosMock: { setups: ["<setup module>"] } },
33
+ render: (props) => <<%= namePascalCase %>Detail {...props} />,
34
+ };
@@ -0,0 +1,52 @@
1
+ import styled from '@emotion/styled';
2
+ import {
3
+ Button,
4
+ Content,
5
+ Footer,
6
+ LabelSmall,
7
+ } from '@kosdev-code/kos-ddk-components';
8
+ import type { AssemblyModel } from '@kosdev-code/kos-dispense-sdk';
9
+ import {
10
+ KosLog,
11
+ kosComponent,
12
+ useKosTranslation,
13
+ type IKosDataModel,
14
+ } from '@kosdev-code/kos-ui-sdk';
15
+
16
+ const log = KosLog.createLogger({ name: "<%= nameDashCase %>-detail" });
17
+ log.debug("<%= nameDashCase %> detail component loaded");
18
+
19
+ const <%= namePascalCase %>DetailContainer = styled.div`
20
+ display: flex;
21
+ flex-direction: column;
22
+ height: 100%;
23
+ `;
24
+
25
+ interface <%= namePascalCase %>DetailProps {
26
+ dashboardKey?: string;
27
+ assembly?: AssemblyModel;
28
+ /** The assembly's "<%= dashboardKey %>" model whose card was selected. */
29
+ cardModel?: IKosDataModel;
30
+ /** Closes the modal the host shows this detail in. */
31
+ onComplete?: () => void;
32
+ }
33
+
34
+ /** Detail for the "<%= dashboardKey %>" dashboard card, shown in the host's modal. */
35
+ export const <%= namePascalCase %>Detail: React.FunctionComponent<<%= namePascalCase %>DetailProps> =
36
+ kosComponent(({ cardModel, onComplete }) => {
37
+ const { t } = useKosTranslation('<%= appProject %>');
38
+ return (
39
+ <<%= namePascalCase %>DetailContainer>
40
+ <Content>
41
+ <LabelSmall>{cardModel?.id}</LabelSmall>
42
+ </Content>
43
+ <Footer>
44
+ <Button onClick={onComplete}>{t('close')}</Button>
45
+ </Footer>
46
+ </<%= namePascalCase %>DetailContainer>
47
+ );
48
+ });
49
+
50
+ <%= namePascalCase %>Detail.displayName = "<%= namePascalCase %>Detail";
51
+
52
+ export default <%= namePascalCase %>Detail;
@@ -0,0 +1 @@
1
+ export * from "./<%= nameDashCase %>";
@@ -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 %>";
@@ -0,0 +1,34 @@
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 { DashboardSummaryStoryContainer } from "@kosdev-code/kos-ddk-story-containers";
7
+ import type { Meta, StoryObj } from "@storybook/react";
8
+ import { <%= namePascalCase %>Summary } from "./<%= nameDashCase %>";
9
+
10
+ const meta: Meta<typeof <%= namePascalCase %>Summary> = {
11
+ args: {},
12
+ component: <%= namePascalCase %>Summary,
13
+ decorators: [
14
+ (Story, context) => (
15
+ <DashboardSummaryStoryContainer
16
+ dashboardKey="<%= dashboardKey %>"
17
+ title="<%= namePascalCase %>"
18
+ >
19
+ {(props) => <Story args={{ ...context.args, ...props }} />}
20
+ </DashboardSummaryStoryContainer>
21
+ ),
22
+ ],
23
+ tags: ["!autodocs"],
24
+ title: "dashboard/<%= namePascalCase %>/Summary",
25
+ };
26
+
27
+ export default meta;
28
+
29
+ type Story = StoryObj<typeof <%= namePascalCase %>Summary>;
30
+
31
+ export const Default: Story = {
32
+ // parameters: { kosMock: { setups: ["<setup module>"] } },
33
+ render: (props) => <<%= namePascalCase %>Summary {...props} />,
34
+ };
@@ -0,0 +1,41 @@
1
+ import styled from '@emotion/styled';
2
+ import { LabelSmall } from '@kosdev-code/kos-ddk-components';
3
+ import type { AssemblyModel } from '@kosdev-code/kos-dispense-sdk';
4
+ import {
5
+ KosLog,
6
+ kosComponent,
7
+ type IKosDataModel,
8
+ } from '@kosdev-code/kos-ui-sdk';
9
+
10
+ const log = KosLog.createLogger({ name: "<%= nameDashCase %>-summary" });
11
+ log.debug("<%= nameDashCase %> summary component loaded");
12
+
13
+ const <%= namePascalCase %>SummaryContainer = styled.div`
14
+ display: flex;
15
+ flex-direction: column;
16
+ gap: var(--ddk-generic-padding-small);
17
+ `;
18
+
19
+ interface <%= namePascalCase %>SummaryProps {
20
+ dashboardKey?: string;
21
+ assembly?: AssemblyModel;
22
+ /** The assembly's "<%= dashboardKey %>" model this card renders for. */
23
+ cardModel?: IKosDataModel;
24
+ }
25
+
26
+ /**
27
+ * Body of the "<%= dashboardKey %>" dashboard card. The host draws one card per
28
+ * active "<%= dashboardKey %>" model and opens the detail when a technician selects it.
29
+ */
30
+ export const <%= namePascalCase %>Summary: React.FunctionComponent<<%= namePascalCase %>SummaryProps> =
31
+ kosComponent(({ cardModel }) => {
32
+ return (
33
+ <<%= namePascalCase %>SummaryContainer>
34
+ <LabelSmall>{cardModel?.id}</LabelSmall>
35
+ </<%= namePascalCase %>SummaryContainer>
36
+ );
37
+ });
38
+
39
+ <%= namePascalCase %>Summary.displayName = "<%= namePascalCase %>Summary";
40
+
41
+ export default <%= namePascalCase %>Summary;
@@ -0,0 +1 @@
1
+ export * from "./<%= nameDashCase %>";