@kosdev-code/kos-ddk-cli 0.1.0-dev.72 → 0.1.0-dev.75

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.
@@ -27,8 +27,9 @@ component content. Never hand-edit the contributions or experiences the tools wr
27
27
 
28
28
  3. **The extension point.** Read `ddk://extension-point/{id}`: its contribution fields,
29
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 that
31
- edits device configuration (most Settings tabs) follows the `ddk-config-page` skill.
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.
32
33
 
33
34
  4. **Replacing a standard contribution.** `list_ddk_contributions` lists the ones an
34
35
  override can replace. Pass the id as `override`: the tool takes its slot and gives
@@ -38,7 +39,8 @@ component content. Never hand-edit the contributions or experiences the tools wr
38
39
 
39
40
  5. **Write the contribution** with the point's tool, dry run first, then
40
41
  `dryRun: false`. It writes the component, its story, the `.kos.json` contribution
41
- and experience, and the i18n title.
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.
42
44
 
43
45
  Pump cards are keyed by pump type: the backend assembly assigns it to the holder's
44
46
  first pump, and the default dashboard key factory returns it. A new pump type is
@@ -56,9 +58,16 @@ component content. Never hand-edit the contributions or experiences the tools wr
56
58
  has none, and pass `descriptorProject` to `add_utility`, `add_setup_step` or
57
59
  `add_nav_view`. `ddk://guide/descriptor-project` lists each layout's entries and what each option adds.
58
60
 
59
- 7. **Build the component** with the `ddk-content-component` skill.
61
+ 7. **Register the models it uses.** A model the plugin renders is registered by the
62
+ plugin's init lifecycle: `register_model` with `app` set to the plugin project (dry
63
+ run, then `dryRun: false`). It sets `kos.ui.plugin.init: true`, writes
64
+ `src/app/init.ts`, whose `register()` the host calls when it loads the plugin, and
65
+ calls it in `.storybook/registration.ts` before `initDDKRegistration()`. Never use
66
+ `@kosModel({ autoRegister: true })` for a plugin's model.
60
67
 
61
- 8. **Develop it.** In Storybook with the `ddk-storybook` skill. Against a running device
68
+ 8. **Build the component** with the `ddk-content-component` skill.
69
+
70
+ 9. **Develop it.** In Storybook with the `ddk-storybook` skill. Against a running device
62
71
  or simulator with `kosui ddk:dev` (`ddk://guide/ddk-dev`); that is where an override
63
72
  is seen replacing the standard contribution. In `ddk:dev`:
64
73
  - Serve the descriptor project before opening the URL, unless its KAB is installed:
@@ -72,7 +81,7 @@ component content. Never hand-edit the contributions or experiences the tools wr
72
81
  troubles take the place of its card body and detail. Storybook's container picks a
73
82
  holder with the `dashboardKey`.
74
83
 
75
- 9. **Validate.** `validate_ddk_plugin` checks the fields against each point's schema,
84
+ 10. **Validate.** `validate_ddk_plugin` checks the fields against each point's schema,
76
85
  ranks, experiences and their component files, overrides that do not win and tokens
77
86
  set in plugin code. Then delegate to the `kos-ddk-plugin-reviewer` subagent and act
78
87
  on its findings here. Not sure of the plan before step 5? The
@@ -83,3 +92,5 @@ component content. Never hand-edit the contributions or experiences the tools wr
83
92
  - Plugins compose DDK components; the design tokens belong to the DDK app and its
84
93
  themes. A plugin never sets or overrides a token.
85
94
  - Every write goes through a tool, dry run first.
95
+ - A plugin's models register through its init lifecycle (`register_model` into the
96
+ plugin), never with `autoRegister`.
@@ -1,12 +1,13 @@
1
1
  ---
2
2
  name: ddk-config-page
3
3
  description: >-
4
- Build a DDK Settings tab or any DDK page that shows or edits device configuration:
5
- model the configuration (SettingsModel, the plugin's own @kosConfigProperty fields,
6
- one model per repeated entry such as cup sizes with prop keys, or a whole
7
- @kosConfigBean for batched edits), hand the model to the page, and render the
8
- ConfigProp* cards. Use when asked about DDK configuration input components, config
9
- property cards, cup sizes, or a page that changes dispenser settings.
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.
10
11
  ---
11
12
 
12
13
  # Build a DDK page on configuration properties
@@ -17,7 +18,10 @@ The cards are described in `ddk://guide/config-property-cards`.
17
18
  ## Steps
18
19
 
19
20
  1. **Contribute the page.** A Settings tab is a navigation view: `add_nav_view` with a
20
- `settings.<name>` descriptor (build-ddk-plugin skill).
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.
21
25
 
22
26
  2. **Choose the mode.**
23
27
  - **Config properties** (the usual case): the model has one `@kosConfigProperty` per
@@ -31,9 +35,16 @@ The cards are described in `ddk://guide/config-property-cards`.
31
35
  3. **Model the configuration.**
32
36
  - DDK settings (date and time formats, water and beverage visibility) are already on
33
37
  `SettingsModel`.
34
- - Your own values: find the config path and attribute on a live device with the
35
- kos-device tools, then add each with `add_config_property` (build-kos-model skill).
36
- Never hand-write the decorator.
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.
37
48
  - **Repeated entries** (cup sizes and the like: `cups.0.*` … `cups.4.*` in one bean):
38
49
  one model type whose attributes carry a prop key, and a container that creates an
39
50
  instance per entry (`kos://guide/prop-keys`):
@@ -56,13 +67,24 @@ The cards are described in `ddk://guide/config-property-cards`.
56
67
  volume, the largest cup).
57
68
  - A bean: add `@kosConfigBean` by hand; no codegen tool writes it.
58
69
 
59
- 4. **Give the page the model.** Wrap it in a `with…` higher-order component or call a
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
60
79
  `use…` hook that loads the model: `withSettings` from kos-ddk-model-components for
61
80
  `SettingsModel`, and the same pair for your own model (`withCupContainer` /
62
- `useCupContainer`).
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.
63
83
 
64
- 5. **Render it.** One card per property (`ddk://guide/config-property-cards`), or
65
- `ConfigPropertyInput` to let the schema choose. For repeated entries, one card group
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
66
88
  per instance:
67
89
 
68
90
  ```tsx
@@ -79,11 +101,30 @@ The cards are described in `ddk://guide/config-property-cards`.
79
101
  For a bean, build the form from `values` and `getSchemaForProperty(key)`, keep the
80
102
  edits in the page until Save, then write them with `updateProperty`.
81
103
 
82
- 6. **Decide when edits are written.** Cards write as each value changes. To apply a
104
+ 7. **Decide when edits are written.** Cards write as each value changes. To apply a
83
105
  page's edits together, wrap it in `StagedChangesProvider` and call `saveChanges()`
84
106
  from its Save action; only the toggle and time-picker cards stage
85
107
  (`ddk://guide/config-property-cards`).
86
108
 
87
- 7. **Develop and check it.** In Storybook the page reads and writes the simulator's real
109
+ 8. **Develop and check it.** In Storybook the page reads and writes the simulator's real
88
110
  configuration (ddk-storybook skill). In `kosui ddk:dev`, log in as technician: Settings
89
- is technician-only in the standard descriptor.
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.
@@ -25,15 +25,20 @@ is the reference; this is the order to work in.
25
25
  URL, else `KOS_HOST` and `KOS_PORT` in the plugin's `.env` (the generated `.env`
26
26
  sets `KOS_PORT=8081`), else the page's origin.
27
27
 
28
- 4. **What the story needs.** Each story renders inside its extension point's story
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
29
34
  container (the table in the guide). A dashboard card needs an active model at its
30
35
  `dashboardKey`, a pump detail or macro summary a holder with it, a trouble action an
31
36
  active trouble of its `troubleType`. When the simulator has none, the container says
32
37
  so in place of the story: change the simulator's state, not the story.
33
38
 
34
- 5. **Both render modes.** The Render Mode toolbar switches between `standard` and
39
+ 6. **Both render modes.** The Render Mode toolbar switches between `standard` and
35
40
  `compact`; in `compact`, modals render full screen.
36
41
 
37
- 6. **Overrides.** The story renders the override on its own. To see it replace the
42
+ 7. **Overrides.** The story renders the override on its own. To see it replace the
38
43
  standard contribution, load the plugin into a running DDK with `kosui ddk:dev`
39
44
  (`ddk://guide/ddk-dev`).
@@ -6,7 +6,7 @@
6
6
  import { Button } from "@kosdev-code/kos-ddk-components";
7
7
  import { UtilityStoryContainer } from "@kosdev-code/kos-ddk-story-containers";
8
8
  import type { Meta, StoryObj } from "@storybook/react";
9
- import type { ComponentProps } from "react";
9
+ import { Suspense, type ComponentProps } from "react";
10
10
  import { useArgs } from "storybook/preview-api";
11
11
  import { fn } from "storybook/test";
12
12
  import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
@@ -42,14 +42,17 @@ export const Default: Story = {
42
42
  <Button onPointerDown={() => updateArgs({ open: true })}>
43
43
  Open <%= namePascalCase %>
44
44
  </Button>
45
+ {/* A utility that loads a model suspends; keep that out of this render. */}
45
46
  {open && (
46
- <<%= namePascalCase %>
47
- {...props}
48
- onComplete={() => {
49
- onComplete();
50
- updateArgs({ open: false });
51
- }}
52
- />
47
+ <Suspense>
48
+ <<%= namePascalCase %>
49
+ {...props}
50
+ onComplete={() => {
51
+ onComplete();
52
+ updateArgs({ open: false });
53
+ }}
54
+ />
55
+ </Suspense>
53
56
  )}
54
57
  </>
55
58
  );
@@ -2,7 +2,7 @@
2
2
  uri: ddk://guide/config-property-cards
3
3
  name: ddk-guide-config-property-cards
4
4
  title: Configuration property cards
5
- description: The ConfigProp* cards in kos-ddk-model-components that show and edit a KosConfigProperty, ConfigPropertyInput choosing a card from the schema type, and when cards write (immediately, or batched with StagedChangesProvider).
5
+ description: The ConfigProp* cards in kos-ddk-model-components that show and edit a KosConfigProperty, which card fits each schema type (including an int with no min/max), and when cards write (immediately, or batched with StagedChangesProvider).
6
6
  ---
7
7
 
8
8
  # Configuration property cards
@@ -23,15 +23,47 @@ Each takes a `configProperty` (a `KosConfigProperty`), reads its value with
23
23
  | `ConfigPropSingleInputEnableCard` | any, plus a boolean | one input that a toggle (`enabledConfigProperty`) enables |
24
24
  | `ConfigPropMultiInputEnableCard` | several, plus a boolean | several inputs behind one enabling toggle |
25
25
 
26
- The cards take the props of the DDK card they wrap (`label`, `float`, `collapse` and so
27
- on). Lay them out in a `TabContainer`, with a `SettingsSubheading` per group.
26
+ The cards take the props of the DDK card they wrap (`describe_ddk_component` lists them,
27
+ inherited ones included, and which are required). Pass a translated `label` to every
28
+ card; `ConfigPropInputCard` requires it, and only `ConfigPropInputRangeCard` falls back
29
+ to translating the property id in the `config-properties` namespace. Lay them
30
+ out in a `TabContainer`, with a `SettingsSubheading` per group.
28
31
 
29
- ## Letting the schema choose: ConfigPropertyInput
32
+ ## Choosing a card from the schema
30
33
 
31
- `ConfigPropertyInput` renders the card for the property's `schemaType`: boolean → toggle,
32
- int and double → input range, String → input, enum → picker. Without a `label` it
33
- translates the property id in the `config-properties` namespace. In compact mode the input
34
- and picker cards take the compact style. Pass `factory` to map types to other cards.
34
+ Read the attribute's schema first (`describe_config_path` on the kos-device server): its
35
+ type and whether it declares `displayOptions` `min`/`max`.
36
+
37
+ | Schema | Card |
38
+ | ------ | ---- |
39
+ | `boolean` | `ConfigPropToggleCard` |
40
+ | enum, or a value with options | `ConfigPropPickerCard` |
41
+ | `String` | `ConfigPropInputCard` with `hideUnits` |
42
+ | `int` / `double` with `displayOptions` `min` and `max` | `ConfigPropInputRangeCard`, or `ConfigPropInputCard layout="num"` |
43
+ | `int` / `double` with no `min`/`max`, e.g. `{"type":"int"}` | `ConfigPropInputCard layout="num"` with an `isValid` for the bounds |
44
+
45
+ `ConfigPropInputRangeCard` passes the schema's `min`/`max` to `InputRangeCard`, which
46
+ replaces any `isValid` you pass and rejects an out-of-range value only when
47
+ `minValueValidationText` and `maxValueValidationText` are set; with no `min`/`max` in the
48
+ schema it accepts any number.
49
+
50
+ `ConfigPropInputCard` runs your `isValid` first, then the schema's `min`/`max` (with the
51
+ DDK's translated messages). `isValid` returns the error text to show, or `undefined`
52
+ when the value is valid:
53
+
54
+ <ConfigPropInputCard
55
+ configProperty={shelf.ledRed}
56
+ label={t("led.red")}
57
+ layout="num"
58
+ hideUnits
59
+ isValid={(v) => (v && Number(v) > 255 ? t("led.invalidColour") : undefined)}
60
+ />
61
+
62
+ `hideUnits` drops the unit the property carries; leave it off for values with a unit
63
+ (ml, seconds). Use `layout="num"` for numbers so the keypad is numeric.
64
+
65
+ `ConfigPropertyInput`, which picks a card from the schema type, is not exported from the
66
+ package; choose the card yourself from the table above.
35
67
 
36
68
  ## When a card writes
37
69
 
@@ -80,19 +80,20 @@ gets the same commands and tools.
80
80
  ## 5. Agent plugin and MCP server
81
81
 
82
82
  ```sh
83
- kosui ddk:agent-install --client claude --scope user
83
+ kosui plugin install --client claude --scope user
84
84
  ```
85
85
 
86
- This registers the package's `kos-ddk-tools` plugin with the agent client and installs
87
- it; the plugin runs the `kos-ddk` MCP server. `--scope user` installs it for every repo,
86
+ This installs the SDK's `kos-tools` plugin and, beside it, the package's `kos-ddk-tools`
87
+ plugin, which runs the `kos-ddk` MCP server. `--scope user` installs them for every repo,
88
88
  `--scope repo` for the current checkout only. Without `--client` it detects the client.
89
+ `kosui ddk:agent-install` installs `kos-ddk-tools` alone, with the same flags.
89
90
 
90
91
  The server is one self-contained file inside the package, so it does not depend on the
91
92
  workspace's `node_modules`. It is registered from wherever the package is installed, in
92
93
  the workspace or globally.
93
94
 
94
- Run `ddk:agent-install` again after upgrading or reinstalling the package: the client
95
- keeps its copy of the plugin until the registration is refreshed.
95
+ Run `kosui plugin install` again after upgrading the CLIs (`kosui cli:update`): the
96
+ client keeps its copy of each plugin until the registration is refreshed.
96
97
 
97
98
  ## 6. Next
98
99
 
@@ -110,10 +111,9 @@ keeps its copy of the plugin until the registration is refreshed.
110
111
  ## Upgrading
111
112
 
112
113
  ```sh
113
- kosui cli:update # kosui
114
- npm install -D @kosdev-code/kos-ddk-cli@latest # workspace install
115
- npm install -g @kosdev-code/kos-ddk-cli@latest # global install
116
- kosui ddk:agent-install --client claude --scope user
114
+ kosui cli:update # kosui, and a global kos-ddk-cli
115
+ npm install -D @kosdev-code/kos-ddk-cli@latest # a workspace install
116
+ kosui plugin install --client claude --scope user # both agent plugins
117
117
  ```
118
118
 
119
119
  ## When the ddk commands are missing
@@ -38,6 +38,24 @@ Translations come from the same device: the DDK's namespaces (`app/system`,
38
38
  contribution command adds its title key, and the keys its component calls, to
39
39
  `src/assets/locales/en/<plugin>.json`.
40
40
 
41
+ ## Plugin models in Storybook
42
+
43
+ The DDK host registers a plugin's models by loading its `./InitPlugin`
44
+ (`src/app/init.ts`); Storybook does not. `.storybook/registration.ts` runs the same
45
+ init itself, before `initDDKRegistration()`, because that call creates KosCore and a
46
+ model registered afterwards is not seen:
47
+
48
+ ```ts
49
+ import { initDDKRegistration } from "@kosdev-code/kos-ddk-model-components";
50
+ import InitPlugin from "../src/app/init";
51
+
52
+ new InitPlugin().register();
53
+
54
+ const { KosCoreContextProvider } = initDDKRegistration();
55
+ ```
56
+
57
+ `register_model` with the plugin as `app` writes both files.
58
+
41
59
  Start the simulator before Storybook. A story shows what the simulator has: a dashboard card
42
60
  needs an active model at its `dashboardKey`, a trouble action needs an active trouble of its
43
61
  `troubleType`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ddk-cli",
3
- "version": "0.1.0-dev.72",
3
+ "version": "0.1.0-dev.75",
4
4
  "description": "DDK commands for kosui: plugin projects and DDK extension-point contributions.",
5
5
  "type": "module",
6
6
  "kosui": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "kos": {
29
29
  "build": {
30
- "gitHash": "7b6007fe34bf59d0ca34fd94b151869b4c29d5c6"
30
+ "gitHash": "94a4601c8d51b3717bb903e93903ed6ce5cf763f"
31
31
  }
32
32
  },
33
33
  "publishConfig": {