@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.
- package/README.md +181 -2
- package/agent-plugin/.claude-plugin/marketplace.json +13 -0
- package/agent-plugin/kos-ddk-tools/.claude-plugin/plugin.json +8 -0
- package/agent-plugin/kos-ddk-tools/.mcp.json +11 -0
- package/agent-plugin/kos-ddk-tools/agents/kos-ddk-plugin-planner.md +45 -0
- package/agent-plugin/kos-ddk-tools/agents/kos-ddk-plugin-reviewer.md +43 -0
- package/agent-plugin/kos-ddk-tools/catalog/contributions.json +965 -0
- package/agent-plugin/kos-ddk-tools/mcp.json +12 -0
- package/agent-plugin/kos-ddk-tools/plugin.json +7 -0
- package/agent-plugin/kos-ddk-tools/reference/reference.json +21161 -0
- package/agent-plugin/kos-ddk-tools/servers/kos-ddk.mjs +48656 -0
- package/agent-plugin/kos-ddk-tools/skills/build-ddk-plugin/SKILL.md +110 -0
- package/agent-plugin/kos-ddk-tools/skills/ddk-config-page/SKILL.md +130 -0
- package/agent-plugin/kos-ddk-tools/skills/ddk-content-component/SKILL.md +59 -0
- package/agent-plugin/kos-ddk-tools/skills/ddk-storybook/SKILL.md +45 -0
- package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.stories.tsx__template__ +32 -0
- package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.tsx__template__ +35 -0
- package/agent-plugin/kos-ddk-tools/templates/cui/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +34 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/__nameDashCase__.tsx__template__ +52 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-region/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +34 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/__nameDashCase__.tsx__template__ +41 -0
- package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +34 -0
- package/agent-plugin/kos-ddk-tools/templates/macro-summary/__nameDashCase__.tsx__template__ +24 -0
- package/agent-plugin/kos-ddk-tools/templates/macro-summary/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/nav/__nameDashCase__.stories.tsx__template__ +32 -0
- package/agent-plugin/kos-ddk-tools/templates/nav/__nameDashCase__.tsx__template__ +27 -0
- package/agent-plugin/kos-ddk-tools/templates/nav/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/plugin-project/.storybook/preview.tsx.template +113 -0
- package/agent-plugin/kos-ddk-tools/templates/plugin-project/.storybook/registration.ts.template +6 -0
- package/agent-plugin/kos-ddk-tools/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +34 -0
- package/agent-plugin/kos-ddk-tools/templates/pump-detail/__nameDashCase__.tsx__template__ +38 -0
- package/agent-plugin/kos-ddk-tools/templates/pump-detail/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +34 -0
- package/agent-plugin/kos-ddk-tools/templates/pump-summary/__nameDashCase__.tsx__template__ +25 -0
- package/agent-plugin/kos-ddk-tools/templates/pump-summary/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.stories.tsx__template__ +32 -0
- package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.tsx__template__ +33 -0
- package/agent-plugin/kos-ddk-tools/templates/setup/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/component.css.template +2 -0
- package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/generic.css.template +2 -0
- package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/semantic.css.template +2 -0
- package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/theme-overlay.css.template +7 -0
- package/agent-plugin/kos-ddk-tools/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +31 -0
- package/agent-plugin/kos-ddk-tools/templates/trouble-action/__nameDashCase__.tsx__template__ +57 -0
- package/agent-plugin/kos-ddk-tools/templates/trouble-action/index.ts__template__ +1 -0
- package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.stories.tsx__template__ +60 -0
- package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.tsx__template__ +88 -0
- package/agent-plugin/kos-ddk-tools/templates/utility/index.ts__template__ +1 -0
- package/catalog/contributions.json +965 -0
- package/guides/config-property-cards.md +77 -0
- package/guides/ddk-dev.md +59 -0
- package/guides/getting-started.md +126 -0
- package/guides/storybook.md +127 -0
- package/package.json +33 -3
- package/reference/reference.json +21161 -0
- package/src/build-paths.mjs +20 -0
- package/src/codegen/contribution.mjs +530 -0
- package/src/codegen/descriptor.mjs +422 -0
- package/src/codegen/json-preserve.mjs +137 -0
- package/src/codegen/ncui-descriptor.mjs +167 -0
- package/src/codegen/overrides.mjs +263 -0
- package/src/codegen/project.mjs +271 -0
- package/src/extension.mjs +32 -0
- package/src/generators/agent-install.mjs +80 -0
- package/src/generators/catalog.mjs +81 -0
- package/src/generators/contributions.mjs +164 -0
- package/src/generators/dashboard.mjs +282 -0
- package/src/generators/descriptor-entries.mjs +53 -0
- package/src/generators/descriptor-project.mjs +84 -0
- package/src/generators/dev.mjs +231 -0
- package/src/generators/override-prompts.mjs +27 -0
- package/src/generators/plugin-project.mjs +71 -0
- package/src/generators/theme-project.mjs +53 -0
- package/src/handlers.mjs +335 -0
- package/src/mcp/pkg-info.mjs +7 -0
- package/src/mcp/plugin-inspect.mjs +328 -0
- package/src/mcp/reference.mjs +315 -0
- package/src/mcp/server.mjs +12 -0
- package/src/mcp/tools.mjs +619 -0
- package/templates/cui/__nameDashCase__.stories.tsx__template__ +32 -0
- package/templates/cui/__nameDashCase__.tsx__template__ +35 -0
- package/templates/cui/index.ts__template__ +1 -0
- package/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +34 -0
- package/templates/dashboard-detail/detail/__nameDashCase__.tsx__template__ +52 -0
- package/templates/dashboard-detail/detail/index.ts__template__ +1 -0
- package/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
- package/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
- package/templates/dashboard-region/index.ts__template__ +1 -0
- package/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +34 -0
- package/templates/dashboard-summary/summary/__nameDashCase__.tsx__template__ +41 -0
- package/templates/dashboard-summary/summary/index.ts__template__ +1 -0
- package/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +34 -0
- package/templates/macro-summary/__nameDashCase__.tsx__template__ +24 -0
- package/templates/macro-summary/index.ts__template__ +1 -0
- package/templates/nav/__nameDashCase__.stories.tsx__template__ +32 -0
- package/templates/nav/__nameDashCase__.tsx__template__ +27 -0
- package/templates/nav/index.ts__template__ +1 -0
- package/templates/plugin-project/.storybook/preview.tsx.template +113 -0
- package/templates/plugin-project/.storybook/registration.ts.template +6 -0
- package/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +34 -0
- package/templates/pump-detail/__nameDashCase__.tsx__template__ +38 -0
- package/templates/pump-detail/index.ts__template__ +1 -0
- package/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +34 -0
- package/templates/pump-summary/__nameDashCase__.tsx__template__ +25 -0
- package/templates/pump-summary/index.ts__template__ +1 -0
- package/templates/setup/__nameDashCase__.stories.tsx__template__ +32 -0
- package/templates/setup/__nameDashCase__.tsx__template__ +33 -0
- package/templates/setup/index.ts__template__ +1 -0
- package/templates/theme-project/theme/assets/component.css.template +2 -0
- package/templates/theme-project/theme/assets/generic.css.template +2 -0
- package/templates/theme-project/theme/assets/semantic.css.template +2 -0
- package/templates/theme-project/theme/assets/theme-overlay.css.template +7 -0
- package/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +31 -0
- package/templates/trouble-action/__nameDashCase__.tsx__template__ +57 -0
- package/templates/trouble-action/index.ts__template__ +1 -0
- package/templates/utility/__nameDashCase__.stories.tsx__template__ +60 -0
- package/templates/utility/__nameDashCase__.tsx__template__ +88 -0
- package/templates/utility/index.ts__template__ +1 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
uri: ddk://guide/config-property-cards
|
|
3
|
+
name: ddk-guide-config-property-cards
|
|
4
|
+
title: Configuration property cards
|
|
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
|
+
---
|
|
7
|
+
|
|
8
|
+
# Configuration property cards
|
|
9
|
+
|
|
10
|
+
`@kosdev-code/kos-ddk-model-components` has one card per kind of configuration value.
|
|
11
|
+
Each takes a `configProperty` (a `KosConfigProperty`), reads its value with
|
|
12
|
+
`useConfigProperty`, and writes it back with `configProperty.updateProperty`.
|
|
13
|
+
|
|
14
|
+
| Card | Property | Renders |
|
|
15
|
+
| ---- | -------- | ------- |
|
|
16
|
+
| `ConfigPropToggleCard` | boolean | a toggle, Enabled / Disabled |
|
|
17
|
+
| `ConfigPropSwitchCard` | string | a segmented switch (`SwitchCard`) over the `options` you pass |
|
|
18
|
+
| `ConfigPropPickerCard` | enum, or a property with options | a picker (`PickerCard`) of the property's options |
|
|
19
|
+
| `ConfigPropInputCard` | string or number | a text input with the property's unit; `displayOptions` `min`/`max` validate it |
|
|
20
|
+
| `ConfigPropInputRangeCard` | int or double | a number input within its range |
|
|
21
|
+
| `ConfigPropTimePickerCard` | a time of day, in seconds | a time picker |
|
|
22
|
+
| `ConfigPropInfoCard` | string | the value, read-only |
|
|
23
|
+
| `ConfigPropSingleInputEnableCard` | any, plus a boolean | one input that a toggle (`enabledConfigProperty`) enables |
|
|
24
|
+
| `ConfigPropMultiInputEnableCard` | several, plus a boolean | several inputs behind one enabling toggle |
|
|
25
|
+
|
|
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.
|
|
31
|
+
|
|
32
|
+
## Choosing a card from the schema
|
|
33
|
+
|
|
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.
|
|
67
|
+
|
|
68
|
+
## When a card writes
|
|
69
|
+
|
|
70
|
+
Each card writes its property as soon as it changes.
|
|
71
|
+
|
|
72
|
+
For an interaction whose edits must be applied together, wrap the page in
|
|
73
|
+
`StagedChangesProvider` (or `withStagedChanges`). Cards that support staging then keep
|
|
74
|
+
the new value instead of writing it; `useStagedChanges()` gives `saveChanges()` to write
|
|
75
|
+
every staged value and `clearStagedChanges()` to drop them. `ConfigPropToggleCard` and
|
|
76
|
+
`ConfigPropTimePickerCard` stage; the other cards write straight away even inside the
|
|
77
|
+
provider.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
uri: ddk://guide/ddk-dev
|
|
3
|
+
name: ddk-guide-ddk-dev
|
|
4
|
+
title: Testing plugins against a running DDK
|
|
5
|
+
description: Serving DDK plugin projects with kosui ddk:dev for a running device or simulator to load with ?pluginDevServers=, choosing plugins and scenarios.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Testing plugins against a running DDK
|
|
9
|
+
|
|
10
|
+
`ddk:dev` starts the dev server of each DDK plugin project and prints the URL that loads
|
|
11
|
+
them into a running DDK, without access to the DDK host source.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
kosui ddk:dev --device http://192.168.1.50:8081
|
|
15
|
+
kosui ddk:dev --plugins my-plugin --device http://192.168.1.50:8081
|
|
16
|
+
kosui ddk:dev --scenario compact --device http://192.168.1.50:8081
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Without `--plugins` or `--scenario` it starts every DDK plugin project. `--plugins`
|
|
20
|
+
takes project names or aliases; `--scenario` names a set in the workspace `.kos.json`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"development": {
|
|
25
|
+
"ddkScenarios": {
|
|
26
|
+
"standard": ["kos-ddk-standard-plugin", "beverage-pour"],
|
|
27
|
+
"compact": ["kos-ddk-compact-plugin", "beverage-pour"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The device loads the plugins with `?pluginDevServers=`; an override wins over the
|
|
34
|
+
standard contribution only when the device's DDK resolves its slots by rank.
|
|
35
|
+
|
|
36
|
+
## The URL it prints
|
|
37
|
+
|
|
38
|
+
`--device` is the URL of the DDK UI on the device or simulator, either its origin or the
|
|
39
|
+
page itself. Given the origin, the printed URL opens the NCUI page,
|
|
40
|
+
`/app/kosdev.ddk/ncui/index.html`, which is where devices and the simulator serve it. The
|
|
41
|
+
printed URL adds `?pluginDevServers=` with one `http://<address>:<port>` per plugin, from
|
|
42
|
+
the `port` of its `serve` target. The address is `localhost` when the device is local and
|
|
43
|
+
the machine's LAN IPv4 address otherwise, so a device on the network can reach the dev
|
|
44
|
+
servers. Without `--device` it prints a `<device-url>` template.
|
|
45
|
+
|
|
46
|
+
Every plugin needs `options.port` on its `serve` target; `ddk:dev` refuses a plugin
|
|
47
|
+
without one.
|
|
48
|
+
|
|
49
|
+
## Translations
|
|
50
|
+
|
|
51
|
+
The DDK app serves the translation namespaces of the plugins in `?pluginDevServers=`
|
|
52
|
+
from their dev servers, which serve the plugin's `src/assets/locales` at
|
|
53
|
+
`/assets/locales/<locale>/<namespace>.json`. Each contribution command adds its keys to
|
|
54
|
+
`src/assets/locales/en/<plugin>.json`, so labels show before the plugin's KAB is
|
|
55
|
+
installed. Every other namespace still comes from the device.
|
|
56
|
+
|
|
57
|
+
A DDK app without this lists a plugin's namespace only once its KAB is installed, so its
|
|
58
|
+
labels show as their keys (`<plugin>.<name>.utility.title`) and the console warns
|
|
59
|
+
`namespace <plugin> not found in descriptor`.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
uri: ddk://guide/getting-started
|
|
3
|
+
name: ddk-guide-getting-started
|
|
4
|
+
title: Getting started with the DDK CLI
|
|
5
|
+
description: Installing kos-ddk-cli in a workspace or globally, checking kosui loads it, working from a repo root, and installing the kos-ddk agent plugin and MCP server.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Getting started with the DDK CLI
|
|
9
|
+
|
|
10
|
+
`@kosdev-code/kos-ddk-cli` is a `kosui` extension: it adds the `ddk:*` commands to the
|
|
11
|
+
`kosui` CLI and ships the `kos-ddk-tools` agent plugin. It has no CLI of its own.
|
|
12
|
+
|
|
13
|
+
## 1. kosui
|
|
14
|
+
|
|
15
|
+
`kosui` (`@kosdev-code/kos-ui-cli`) is installed globally, at 3.0.31 or later.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install -g @kosdev-code/kos-ui-cli
|
|
19
|
+
kosui cli:update
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 2. Install the extension
|
|
23
|
+
|
|
24
|
+
Either in the workspace, which pins the version with the project:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
cd <repo>/ui
|
|
28
|
+
npm install -D @kosdev-code/kos-ddk-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
or globally, beside `kosui`, which adds the commands in every workspace:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install -g @kosdev-code/kos-ddk-cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`kosui` looks in the workspace's `package.json` dependencies first, then beside its own
|
|
38
|
+
global install. When both have it, the workspace copy is used.
|
|
39
|
+
|
|
40
|
+
`latest` is the released version. `@dev` is the build of the DDK's `main` branch, published
|
|
41
|
+
on every push:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install -D @kosdev-code/kos-ddk-cli@dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The DDK libraries' dev builds depend on each other at one exact version, so install them
|
|
48
|
+
together; `--no-save` keeps `package.json` and the lockfile on the release ranges:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npm install --no-save @kosdev-code/kos-ddk@dev @kosdev-code/kos-ddk-components@dev \
|
|
52
|
+
@kosdev-code/kos-ddk-model-components@dev @kosdev-code/kos-ddk-models@dev \
|
|
53
|
+
@kosdev-code/kos-ddk-story-containers@dev @kosdev-code/kos-ddk-styles@dev
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 3. Check kosui loads it
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
kosui extensions
|
|
60
|
+
kosui help
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`kosui extensions` names the package, its version, where it came from (`[workspace]` or
|
|
64
|
+
`[global]`), its status and the commands it adds. `kosui help` lists them under `ddk:`.
|
|
65
|
+
|
|
66
|
+
A workspace can turn it off in its `.kos.json`:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{ "cli": { "disabledExtensions": ["@kosdev-code/kos-ddk-cli"] } }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 4. Repo root or ui workspace
|
|
73
|
+
|
|
74
|
+
Every command and the MCP server work from the ui workspace (the directory with
|
|
75
|
+
`nx.json`) and from a polyglot repo root: when the repo root's `.kos.json` (written by
|
|
76
|
+
`kosui repo`) names a ui workspace in `workspaces.ui`, `kosui` and the server use that
|
|
77
|
+
workspace. An agent started at the repo root, to work across the backend and the UI,
|
|
78
|
+
gets the same commands and tools.
|
|
79
|
+
|
|
80
|
+
## 5. Agent plugin and MCP server
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
kosui plugin install --client claude --scope user
|
|
84
|
+
```
|
|
85
|
+
|
|
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
|
+
`--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.
|
|
90
|
+
|
|
91
|
+
The server is one self-contained file inside the package, so it does not depend on the
|
|
92
|
+
workspace's `node_modules`. It is registered from wherever the package is installed, in
|
|
93
|
+
the workspace or globally.
|
|
94
|
+
|
|
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.
|
|
97
|
+
|
|
98
|
+
## 6. Next
|
|
99
|
+
|
|
100
|
+
- `kosui ddk:plugin-project --name my-plugin` creates a DDK plugin project under
|
|
101
|
+
`plugins/` (`--directory` changes the folder). It tests against the `kosdev.ddk`
|
|
102
|
+
plugin context and registers with the workspace host serving that context, or with
|
|
103
|
+
`--host`; a workspace without a DDK host registers it with none. The contribution
|
|
104
|
+
commands in the README add to it.
|
|
105
|
+
- `kosui ddk:descriptor-project --name my-ncui --layout standard --ice true` (or `compact`) creates the
|
|
106
|
+
NCUI descriptor project a new utility, setup step or navigation view is listed in;
|
|
107
|
+
pass `--descriptorProject my-ncui` to `ddk:utility`, `ddk:setup` and `ddk:nav`. `ddk://guide/descriptor-project` lists what each layout and option writes.
|
|
108
|
+
- `ddk://guide/storybook` for developing contributions in Storybook.
|
|
109
|
+
- `ddk://guide/ddk-dev` for loading plugins into a running DDK.
|
|
110
|
+
|
|
111
|
+
## Upgrading
|
|
112
|
+
|
|
113
|
+
```sh
|
|
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
|
+
```
|
|
118
|
+
|
|
119
|
+
## When the ddk commands are missing
|
|
120
|
+
|
|
121
|
+
- `kosui extensions` does not list the package: it is in neither the workspace's
|
|
122
|
+
`package.json` nor the global install beside the `kosui` on your `PATH`
|
|
123
|
+
(`npm ls -g @kosdev-code/kos-ddk-cli`).
|
|
124
|
+
- It is listed as `incompatible`: `kosui` is older than the extension needs; update it.
|
|
125
|
+
- It is listed as `disabled`: the workspace `.kos.json` names it in
|
|
126
|
+
`cli.disabledExtensions`.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
uri: ddk://guide/storybook
|
|
3
|
+
name: ddk-guide-storybook
|
|
4
|
+
title: Developing DDK contributions in Storybook
|
|
5
|
+
description: Running a plugin's Storybook against a simulator or with KosMock story mocks, where model data comes from, the story container per contribution command, render modes and overrides.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Developing DDK contributions in Storybook
|
|
9
|
+
|
|
10
|
+
Every `ddk:*` contribution command writes a story next to the component, so a contribution
|
|
11
|
+
can be developed in isolation before the plugin is loaded into a running DDK. Stories render
|
|
12
|
+
against live models from a running simulator.
|
|
13
|
+
|
|
14
|
+
## Run it
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx nx run <plugin>:storybook
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Storybook serves on port 4400. The plugin's `serve` target is the module federation dev
|
|
21
|
+
server used by `kosui ddk:dev`; Storybook has its own `storybook` target.
|
|
22
|
+
|
|
23
|
+
## Where model data comes from
|
|
24
|
+
|
|
25
|
+
The preview (`.storybook/preview.tsx`) wraps every story in the providers the DDK hosts use:
|
|
26
|
+
KosCore, translations (`app/system`, `app/kosdev.ddk`), `AssemblyProvider`,
|
|
27
|
+
`ApplicationProvider` and `ApplicationComponentConfigurationProvider`. KosCore connects to the
|
|
28
|
+
first of:
|
|
29
|
+
|
|
30
|
+
1. the `?host=` query parameter on the Storybook URL;
|
|
31
|
+
2. `KOS_HOST` and `KOS_PORT` in the plugin's `.env` (the generated `.env` sets
|
|
32
|
+
`KOS_PORT=8081`, the simulator's default);
|
|
33
|
+
3. the page's own origin.
|
|
34
|
+
|
|
35
|
+
Translations come from the same device: the DDK's namespaces (`app/system`,
|
|
36
|
+
`app/kosdev.ddk`) from its files, and the plugin's own namespace from the plugin's
|
|
37
|
+
`src/assets/locales`, since the device lists it only once the KAB is installed. Each
|
|
38
|
+
contribution command adds its title key, and the keys its component calls, to
|
|
39
|
+
`src/assets/locales/en/<plugin>.json`.
|
|
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
|
+
|
|
59
|
+
Start the simulator before Storybook. A story shows what the simulator has: a dashboard card
|
|
60
|
+
needs an active model at its `dashboardKey`, a trouble action needs an active trouble of its
|
|
61
|
+
`troubleType`.
|
|
62
|
+
|
|
63
|
+
## Mocking what the simulator lacks
|
|
64
|
+
|
|
65
|
+
A story can bring its own data with KosMock, the SDK's transport-level mocks
|
|
66
|
+
(`kos://guide/mocking`), instead of waiting for the simulator to reach a state: an active
|
|
67
|
+
trouble, setup mode, a descriptor entry. It names the mocks as `parameters.kosMock`, and
|
|
68
|
+
the preview's outermost decorator reloads the page into those boot switches
|
|
69
|
+
(`ensureKosMockBoot`):
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
export const ActiveTrouble: Story = {
|
|
73
|
+
parameters: { kosMock: { setups: ["daily-cleaning-trouble"] } },
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`kosMock` takes `setups` (setup modules in `fixtures/setups/`), `fixture` (a recorded
|
|
78
|
+
fixture), `mode` and `fixtureServer`:
|
|
79
|
+
|
|
80
|
+
- `mode: "on"` (the default) mocks only the named endpoints over the running simulator.
|
|
81
|
+
- `mode: "standalone"` boots with no device at all; every endpoint the story reads must
|
|
82
|
+
be mocked.
|
|
83
|
+
|
|
84
|
+
Serve the fixtures beside Storybook:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
kosui fixtures serve
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
A story without `kosMock` reloads without switches, so mocks never carry over between
|
|
91
|
+
stories. Every generated story has a commented `kosMock` line to start from.
|
|
92
|
+
|
|
93
|
+
## Story containers
|
|
94
|
+
|
|
95
|
+
Each story renders the component inside the container for its extension point, from
|
|
96
|
+
`@kosdev-code/kos-ddk-story-containers`:
|
|
97
|
+
|
|
98
|
+
| Command | Container | Gives the component |
|
|
99
|
+
| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------- |
|
|
100
|
+
| `ddk:utility` | `UtilityStoryContainer` | nothing: the utility opens its own `Modal` |
|
|
101
|
+
| `ddk:setup` | `SetupStepStoryContainer` | the setup step frame |
|
|
102
|
+
| `ddk:nav` | `NavStoryContainer` | the navigation view frame |
|
|
103
|
+
| `ddk:cui` | `CUIStoryContainer` | the CUI frame |
|
|
104
|
+
| `ddk:dashboard-card` | `DashboardSummaryStoryContainer`, `DashboardDetailStoryContainer` | `dashboardKey`, `assembly`, `cardModel`, `onComplete` |
|
|
105
|
+
| `ddk:pump-detail` | `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |
|
|
106
|
+
| `ddk:pump-card` | `PumpSummaryStoryContainer`, `PumpDetailStoryContainer` | the first `holder` with the `dashboardKey` |
|
|
107
|
+
| `ddk:macro-summary` | `MacroSummaryStoryContainer` | the first `holder` with the `dashboardKey` |
|
|
108
|
+
| `ddk:dashboard-region` | `DashboardRegionStoryContainer` | the region props for its `holders` and `summaries` |
|
|
109
|
+
| `ddk:trouble-action` | `TroubleActionStoryContainer` | the active `trouble` of the `troubleType` |
|
|
110
|
+
|
|
111
|
+
When the simulator has no matching model, holder or trouble, the container says so in place
|
|
112
|
+
of the story.
|
|
113
|
+
|
|
114
|
+
A utility story has an `open` control. Closing the utility turns it off and logs
|
|
115
|
+
`onComplete` in the Actions panel; the **Open** button behind the modal, or the
|
|
116
|
+
control, opens it again.
|
|
117
|
+
|
|
118
|
+
## Standard and compact modes
|
|
119
|
+
|
|
120
|
+
The **Render Mode** toolbar switches between `standard` and `compact`. It changes the DDK
|
|
121
|
+
styles and the component mode; in `compact`, modals render full screen.
|
|
122
|
+
|
|
123
|
+
## Overrides
|
|
124
|
+
|
|
125
|
+
A story renders the override on its own, so an override of a standard contribution can be
|
|
126
|
+
developed here first. To see it replace the standard contribution, load the plugin into a
|
|
127
|
+
running DDK with `kosui ddk:dev` (see the package README).
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/kos-ddk-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-dev.107",
|
|
4
|
+
"description": "DDK commands for kosui: plugin projects and DDK extension-point contributions.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"kosui": {
|
|
7
|
+
"extension": "./src/extension.mjs",
|
|
8
|
+
"apiVersion": 1
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./src/extension.mjs",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"src",
|
|
16
|
+
"templates",
|
|
17
|
+
"guides",
|
|
18
|
+
"catalog",
|
|
19
|
+
"reference",
|
|
20
|
+
"agent-plugin"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@kosdev-code/kos-codegen-core": "~3.0.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@kosdev-code/kos-ui-cli": "~3.0.0"
|
|
27
|
+
},
|
|
28
|
+
"kos": {
|
|
29
|
+
"build": {
|
|
30
|
+
"gitHash": "e1395e36cf46642482ca4b0fa2ec49f48919c369"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
}
|
|
6
36
|
}
|