@overmvp/kumi 0.1.0 → 0.3.0

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 (175) hide show
  1. package/README.md +59 -6
  2. package/builder/css-v1.mjs +54 -1
  3. package/builder/css-v1.test.mjs +40 -0
  4. package/builder/link-addon-package.mjs +47 -6
  5. package/builder/module-declarations.test.mjs +9 -18
  6. package/builder/native-kernels.mjs +1 -1
  7. package/builder/src/compiler.rs +180 -8
  8. package/builder/src/main.rs +19 -5
  9. package/builder/src/native_ir.rs +1 -1
  10. package/builder/src/native_signal.rs +46 -10
  11. package/builder/src/numbers.lua +14 -0
  12. package/builder/src/project-front.mjs +385 -34
  13. package/builder/src/routes.rs +11 -14
  14. package/builder/src/setup-store.lua +18 -0
  15. package/builder/src/signal-kernel.fingerprint +1 -1
  16. package/builder/src/ts-lower.mjs +2 -2
  17. package/builder/src/wow-reads.lua +22 -0
  18. package/builder/style-modules.mjs +93 -0
  19. package/config.ts +56 -14
  20. package/eslint.mjs +74 -0
  21. package/form/index.ts +15 -11
  22. package/package.json +11 -7
  23. package/router/index.ts +9 -2
  24. package/router/navigation.ts +22 -0
  25. package/router/router-view.ts +134 -0
  26. package/scripts/addon-build.mjs +364 -0
  27. package/scripts/addon-project.mjs +78 -0
  28. package/scripts/kumi-cli.mjs +52 -17
  29. package/scripts/link-addons.mjs +12 -2
  30. package/src/bindings.ts +2 -2
  31. package/src/css-tokens.ts +16 -11
  32. package/src/css-v1.ts +10 -0
  33. package/src/elements.ts +26 -0
  34. package/src/frame-scheduler.ts +3 -1
  35. package/src/index.ts +1 -0
  36. package/src/jsx-runtime.ts +8 -1
  37. package/src/keyed-list.ts +8 -5
  38. package/src/module-ui.ts +147 -0
  39. package/src/module.ts +42 -8
  40. package/src/owned-collections.ts +8 -0
  41. package/src/providers.ts +7 -1
  42. package/src/reactive-scope.ts +3 -3
  43. package/src/reactivity.ts +28 -7
  44. package/src/result.ts +6 -0
  45. package/src/signal-kernel.ts +35 -2
  46. package/state/index.ts +6 -0
  47. package/state/setup-store-persistence.ts +206 -0
  48. package/state/setup-store-view.ts +10 -0
  49. package/state/setup-store.ts +342 -0
  50. package/state/store.ts +2 -0
  51. package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
  52. package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
  53. package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
  54. package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
  55. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
  56. package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
  57. package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
  58. package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
  59. package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
  60. package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
  61. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
  62. package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
  63. package/templates/addon/AGENTS.md +34 -0
  64. package/templates/addon/Assets/Art/Corner10.tga +0 -0
  65. package/templates/addon/Assets/Art/Corner11.tga +0 -0
  66. package/templates/addon/Assets/Art/Corner12.tga +0 -0
  67. package/templates/addon/Assets/Art/Corner13.tga +0 -0
  68. package/templates/addon/Assets/Art/Corner14.tga +0 -0
  69. package/templates/addon/Assets/Art/Corner15.tga +0 -0
  70. package/templates/addon/Assets/Art/Corner16.tga +0 -0
  71. package/templates/addon/Assets/Art/Corner2.tga +0 -0
  72. package/templates/addon/Assets/Art/Corner3.tga +0 -0
  73. package/templates/addon/Assets/Art/Corner4.tga +0 -0
  74. package/templates/addon/Assets/Art/Corner5.tga +0 -0
  75. package/templates/addon/Assets/Art/Corner6.tga +0 -0
  76. package/templates/addon/Assets/Art/Corner7.tga +0 -0
  77. package/templates/addon/Assets/Art/Corner8.tga +0 -0
  78. package/templates/addon/Assets/Art/Corner9.tga +0 -0
  79. package/templates/addon/Assets/Art/Dot.tga +0 -0
  80. package/templates/addon/Assets/Art/Gear.tga +0 -0
  81. package/templates/addon/Assets/Art/Grip.tga +0 -0
  82. package/templates/addon/Assets/Art/Outline10.tga +0 -0
  83. package/templates/addon/Assets/Art/Outline12.tga +0 -0
  84. package/templates/addon/Assets/Art/Outline13.tga +0 -0
  85. package/templates/addon/Assets/Art/Outline14.tga +0 -0
  86. package/templates/addon/Assets/Art/Outline15.tga +0 -0
  87. package/templates/addon/Assets/Art/Outline2.tga +0 -0
  88. package/templates/addon/Assets/Art/Outline3.tga +0 -0
  89. package/templates/addon/Assets/Art/Outline5.tga +0 -0
  90. package/templates/addon/Assets/Art/Outline7.tga +0 -0
  91. package/templates/addon/Assets/Art/Outline9.tga +0 -0
  92. package/templates/addon/Assets/Art/Round11.tga +0 -0
  93. package/templates/addon/Assets/Art/Round11Border.tga +0 -0
  94. package/templates/addon/Assets/Art/Round4.tga +0 -0
  95. package/templates/addon/Assets/Art/Round4Border.tga +0 -0
  96. package/templates/addon/Assets/Art/Round6.tga +0 -0
  97. package/templates/addon/Assets/Art/Round6Border.tga +0 -0
  98. package/templates/addon/Assets/Art/Round8.tga +0 -0
  99. package/templates/addon/Assets/Art/Round8Border.tga +0 -0
  100. package/templates/addon/Assets/Art/Search.tga +0 -0
  101. package/templates/addon/CLAUDE.md +1 -0
  102. package/templates/addon/README.md +42 -7
  103. package/templates/addon/eslint.config.mjs +3 -9
  104. package/templates/addon/gitignore +1 -0
  105. package/templates/addon/kumi.config.ts +17 -0
  106. package/templates/addon/package.json +4 -5
  107. package/templates/addon/src/app/app.module.ts +18 -0
  108. package/templates/addon/src/app/commands.store.ts +11 -0
  109. package/templates/addon/src/app/layout/AppWindow.module.scss +92 -0
  110. package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
  111. package/templates/addon/src/app/main.ts +5 -0
  112. package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
  113. package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
  114. package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
  115. package/templates/addon/src/app/theme.ts +6 -0
  116. package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
  117. package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
  118. package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
  119. package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
  120. package/templates/addon/src/modules/greeting/ui/Greeting.module.scss +105 -0
  121. package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
  122. package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
  123. package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
  124. package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
  125. package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
  126. package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
  127. package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
  128. package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
  129. package/templates/addon/src/modules/playtime/ui/Playtime.module.scss +25 -0
  130. package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
  131. package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
  132. package/templates/addon/src/shared/api/native-art.ts +28 -0
  133. package/templates/addon/src/shared/assets/close.png +0 -0
  134. package/templates/addon/src/shared/lib/format.ts +20 -0
  135. package/templates/addon/src/shared/styles/_tokens.scss +12 -0
  136. package/templates/addon/src/shared/ui/Button.tsx +29 -0
  137. package/templates/addon/src/shared/ui/Choice.tsx +34 -0
  138. package/templates/addon/src/shared/ui/Controls.module.scss +93 -0
  139. package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
  140. package/templates/addon/src/shared/ui/Slider.tsx +25 -0
  141. package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
  142. package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
  143. package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
  144. package/templates/addon/tsconfig.json +49 -10
  145. package/wow/action-bar-layout.ts +108 -0
  146. package/wow/action-button.ts +219 -0
  147. package/wow/action-catalog.ts +98 -0
  148. package/wow/addon-manifest.ts +36 -0
  149. package/wow/app-ui.ts +221 -0
  150. package/wow/cooldown-timing.ts +24 -0
  151. package/wow/css-box.ts +40 -6
  152. package/wow/css-surfaces.ts +229 -24
  153. package/wow/cursor.ts +45 -0
  154. package/wow/frame-access.ts +23 -1
  155. package/wow/frame-timing.ts +13 -0
  156. package/wow/hooks.ts +133 -0
  157. package/wow/index.ts +18 -4
  158. package/wow/layout-view.ts +26 -14
  159. package/wow/locale-font.ts +15 -0
  160. package/wow/native.ts +18 -0
  161. package/wow/panel-host.ts +97 -0
  162. package/wow/pixel.ts +35 -0
  163. package/wow/plugins.ts +246 -0
  164. package/wow/protect.ts +27 -3
  165. package/wow/protected-view.ts +103 -0
  166. package/wow/range-art.ts +7 -0
  167. package/wow/readable-api.ts +120 -0
  168. package/wow/rounded-texture.ts +33 -6
  169. package/wow/saved-variables.ts +67 -18
  170. package/wow/spell-cooldown.ts +36 -0
  171. package/wow/start-addon.ts +31 -8
  172. package/wow/view.ts +201 -83
  173. package/templates/addon/__ADDON_NAME__.toc +0 -4
  174. package/templates/addon/scripts/build.mjs +0 -25
  175. package/templates/addon/src/app/main.tsx +0 -13
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: kumi-feature
3
+ description: Add a new feature module to a Kumi addon with its api, services, model, ui and widgets layers, and wire it into the app module. Use when the user asks for a new feature, panel, tracker or system in a Kumi project.
4
+ ---
5
+
6
+ # Add a feature
7
+
8
+ 1. Pick a short lowercase name, for example `loot`. Create `src/modules/loot/` with the folders you need: `api/`, `services/`, `model/`, `ui/`, `widgets/`.
9
+ 2. **api/**: one function per WoW call, returning plain values.
10
+
11
+ ```ts
12
+ // src/modules/loot/api/money.api.ts
13
+ import { api } from "@kumi/wow";
14
+ export function readMoney(): number { return api.GetMoney(); }
15
+ ```
16
+
17
+ 3. **services/**: the logic, as an `@Injectable` class that calls `api/`.
18
+
19
+ ```ts
20
+ @Injectable()
21
+ export class LootService {
22
+ money() { return readMoney(); }
23
+ gained(start: number, now: number) { return Math.max(0, now - start); }
24
+ }
25
+ ```
26
+
27
+ 4. **model/**: a store that injects the service. See the kumi-store skill.
28
+ 5. **ui/** and **widgets/**: components that read the store. See the kumi-ui skill.
29
+ 6. **loot.module.ts**: the manifest and public API.
30
+
31
+ ```ts
32
+ export { useLootStore } from "./model/loot.store";
33
+
34
+ const metadata = {
35
+ id: "loot",
36
+ imports: [], // other features this one reads, by their module class
37
+ providers: [LootService],
38
+ stores: [useLootStore],
39
+ views: [], // HUD widgets to show while the feature runs
40
+ exports: {},
41
+ } as const;
42
+
43
+ @Module(metadata)
44
+ export class LootModule extends ModuleType<typeof metadata> {}
45
+ ```
46
+
47
+ 7. Add `LootModule` to `imports` in `src/app/app.module.ts`. If the feature should be optional, make it a plugin instead (kumi-plugin skill) and do not import it.
48
+ 8. Run `npm run check` and `npm run build -- --target forever`.
49
+
50
+ Rules: other features import only `loot.module.ts`. Components never import `api/` or `services/`.
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: kumi-plugin
3
+ description: Add a plugin to a Kumi addon - an optional part that players turn on or off, built as its own addon - or load a part on demand. Use when a feature should be optional, separately toggleable, or loaded only when opened.
4
+ ---
5
+
6
+ # Add a plugin
7
+
8
+ 1. Write the plugin as a normal feature module under `src/modules/<id>/` (kumi-feature skill). It may import core modules, but core code must not import its files.
9
+ 2. Add it to `kumi.config.ts`:
10
+
11
+ ```ts
12
+ plugins: {
13
+ loot: {
14
+ module: "src/modules/loot/loot.module.ts",
15
+ title: "Loot",
16
+ notes: "Counts gold and items",
17
+ load: "startup", // or "demand" to load on first use
18
+ },
19
+ },
20
+ pluginState: "character", // or "account"
21
+ ```
22
+
23
+ 3. Do not add the module to `app.module.ts` imports. Kumi starts startup plugins itself.
24
+ 4. Contribute UI from the plugin's module: `views` for HUD panels, `pages` for window pages, `extensions` for slots such as `"hud.footer"`.
25
+ 5. For a demand plugin, load it from a store action or a button:
26
+
27
+ ```ts
28
+ const loaded = usePlugins().load("loot");
29
+ if (loaded.ok) { /* loaded.value has the module's exports */ }
30
+ ```
31
+
32
+ 6. Run `npm run check` (generates the typed plugin list) and `npm run build -- --target forever`. The build creates `build/addons/<Addon>_<id>/`. Run `npm run link -- <AddOns>` again once so the new folder is linked.
33
+
34
+ The Plugins page (`src/app/routes/(window)/plugins/page.tsx`) lists plugins with `usePlugins()`. Turning one off asks for a reload.
35
+
36
+ If the build says a file "belongs to plugin X, but <Addon> imports it": core code imports a file from the plugin's folder. Use `import type`, or move the shared code into a core module.
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: kumi-store
3
+ description: Create or change a Kumi store (defineStore) - state, computed values, actions that call services, saving to SavedVariables, batch updates, events and timers. Use when adding state, settings or saved data to a Kumi addon.
4
+ ---
5
+
6
+ # Write a store
7
+
8
+ ```ts
9
+ // src/modules/loot/model/loot.store.ts
10
+ import { batch, computed, defineStore, inject, readonly, ref } from "@kumi/state";
11
+ import { useEvent } from "@kumi/wow";
12
+ import { LootService } from "../services/loot.service";
13
+
14
+ export const useLootStore = defineStore("loot", () => {
15
+ const loot = inject(LootService); // only in a store listed in a module's `stores`
16
+ const start = ref(loot.money());
17
+ const copper = ref(loot.money());
18
+ const best = ref(0);
19
+
20
+ useEvent("PLAYER_MONEY", () => { copper.value = loot.money(); });
21
+
22
+ const gained = computed(() => loot.gained(start.value, copper.value));
23
+
24
+ function reset(this: void) {
25
+ return batch(() => { // one save, rolled back together on failure
26
+ start.value = copper.value;
27
+ best.value = 0;
28
+ });
29
+ }
30
+
31
+ return { gained, best: readonly(best), start: readonly(start), reset };
32
+ }, { persist: { pick: ["best", "start"] } });
33
+ ```
34
+
35
+ Steps:
36
+
37
+ 1. Put the store in the owning feature's `model/` and list it in that module's `stores`.
38
+ 2. Return refs for state, `readonly(ref)` for state with rules, `computed` for derived state, functions for actions.
39
+ 3. Save fields with `persist: { pick: [...] }`; add `perCharacter: true` for per-character data. The addon's `savedVariables` in `kumi.config.ts` holds them.
40
+ 4. Actions call services. Never call WoW from a store; add an `api/` function and a service method.
41
+ 5. Read it anywhere with `useLootStore()`. In JSX use `const { gained } = storeToRefs(useLootStore())`.
42
+
43
+ Notes:
44
+
45
+ - Inside setup, `computed(...).value` is a `Result`. Share a plain function between computed values instead of reading one from another.
46
+ - A store used by several features stays in the feature that owns the data; others import that feature's module.
47
+ - `store.$patch({ ... })` writes several writable fields from outside.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: kumi-ui
3
+ description: Build Kumi UI - TSX components, widgets, HUD views, window pages, SCSS styles, forms and animations. Use when adding or changing anything the player sees in a Kumi addon.
4
+ ---
5
+
6
+ # Build UI
7
+
8
+ ## A component (`ui/`)
9
+
10
+ ```tsx
11
+ import type { Binding, NodeRef } from "@kumi/core";
12
+ import styles from "@kumi/styles/modules/loot/ui/Loot";
13
+
14
+ interface LootRowProps {
15
+ readonly label: string;
16
+ readonly value: Binding<string>;
17
+ readonly ref?: NodeRef<"frame">;
18
+ }
19
+
20
+ export function LootRow(props: LootRowProps) {
21
+ return (
22
+ <div className={styles.row} nodeRef={props.ref}>
23
+ <span className={styles.label} value={props.label} />
24
+ <span className={styles.value} value={props.value} />
25
+ </div>
26
+ );
27
+ }
28
+ ```
29
+
30
+ One read-only props object, an optional `ref`, changing data as bindings.
31
+
32
+ ## A widget (`widgets/`)
33
+
34
+ Widgets read stores and compose components:
35
+
36
+ ```tsx
37
+ export function LootPanel() {
38
+ const loot = useLootStore();
39
+ const { gained } = storeToRefs(loot);
40
+ return <LootRow label="Gold" value={computed(() => formatMoney(gained.value))} />;
41
+ }
42
+ ```
43
+
44
+ - On screen all the time: list it in the module's `views`.
45
+ - As a window page: create `src/app/routes/(window)/<name>/page.tsx` with `export const title = "..."` and `export default function Page() { return <LootPanel />; }`.
46
+ - As a plugin page: list `{ path, title, component }` in the module's `pages`.
47
+
48
+ ## Styles
49
+
50
+ `ui/Loot.module.scss` next to the components; import from `@kumi/styles/modules/loot/ui/Loot`. Use tokens from `src/shared/styles/_tokens.scss`. Run `npm run check` once after adding a stylesheet. Supported properties: flex layout, sizes, margin, padding, position, colors, borders (`border`, `border-width`, `border-color`, `border-radius` 0-9/11/12px), font size and weight, states `:hover :active :focus :disabled :checked`.
51
+
52
+ ## Lists
53
+
54
+ `{rows.value.map(row => <LootRow key={row.id} ... />)}` over a ref. For a store field: `const { rows } = storeToRefs(store)`.
55
+
56
+ ## Forms
57
+
58
+ ```tsx
59
+ const form = useForm<Settings>({ defaultValues: DEFAULTS, values: store, commit: store.updateSettings, validate });
60
+ <Form form={form}>{() => <Toggle {...form.register("enabled")} label="Enabled" />}</Form>
61
+ ```
62
+
63
+ ## Animation
64
+
65
+ ```tsx
66
+ const refresh = useAnimation(presets.fadeIn({ from: 0.25 }));
67
+ watch(() => count.value, () => { refresh.play(); });
68
+ <span ref={refresh.ref} value={label} />
69
+ ```
70
+
71
+ Text: alpha presets (`fadeIn`, `flash`, `pulse`). Scale presets (`popIn`, `hop`) on icons and frames only: scaling text stretches it.
72
+
73
+ Reusable controls go in `src/shared/ui` and take everything through props.
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: kumi-wow-api
3
+ description: Call the World of Warcraft API from a Kumi addon - wrap a game function in the api layer, handle secret values, subscribe to events, and bind secure buttons for items, spells and toys. Use when a feature needs data or actions from the game.
4
+ ---
5
+
6
+ # Use the WoW API
7
+
8
+ 1. Find the function in `build/types/wow-api.d.ts` (generated by `npm run check`). It has the exact parameters and results.
9
+ 2. Wrap it in the feature's `api/` folder, returning plain values:
10
+
11
+ ```ts
12
+ import { api, readableApi } from "@kumi/wow";
13
+
14
+ export function readTargetName(): string | undefined {
15
+ const [name] = readableApi.UnitName("target"); // undefined while the client hides it
16
+ return name;
17
+ }
18
+
19
+ export function readBagSlots(bag: number): number {
20
+ return api.C_Container.GetContainerNumSlots(bag);
21
+ }
22
+ ```
23
+
24
+ Use `readableApi` when it has the function: it turns secret values into `undefined`. Destructure multiple results in one statement.
25
+ 3. Call the `api/` function from a service. Stores call the service.
26
+ 4. Events: `useEvent("BAG_UPDATE_DELAYED", () => { ... })` in a store setup, or `@OnEvent("BAG_UPDATE_DELAYED")` on a service method. Payloads are typed.
27
+ 5. Actions that need a click (use an item, cast a spell): a button with `secureAction={{ kind: "item", id: 6948 }}` inside a module view. Cooldown: `readCooldownTiming(kind, id)` from `@kumi/wow` with `<cooldown value={timing} />`.
28
+ 6. Disable protected actions during combat with `useCombat()`.
29
+
30
+ Never call WoW from `services/`, `model/`, `ui/` or `widgets/` directly; ESLint reports it.
@@ -0,0 +1,34 @@
1
+ # Working on this addon
2
+
3
+ This addon is written with Kumi: TypeScript and TSX compiled to Lua 5.1 for World of Warcraft. Follow these rules; `npm run check` enforces most of them.
4
+
5
+ ## Structure
6
+
7
+ - `src/app`: startup (`main.ts`), the root module (`app.module.ts`), the theme, the window layout and the window's pages in `routes/`. Pages are thin and render widgets.
8
+ - `src/modules/<feature>`: one folder per feature.
9
+ - `<feature>.module.ts`: the `@Module` manifest and the feature's public API. Other features import only this file.
10
+ - `api/`: one small function per WoW call, plain values in and out. The only place that uses `api`, `readableApi` or game globals.
11
+ - `services/`: `@Injectable` classes with the logic. They call `api/`.
12
+ - `model/`: stores (`defineStore`). Actions call services, which they get with `inject` during setup.
13
+ - `ui/`: components. `widgets/`: screens built from components (HUD views, page contents).
14
+ - `src/shared`: reusable code that knows nothing about the addon's features: `ui/` controls, `styles/` tokens, `lib/` helpers, `api/` art and fonts.
15
+
16
+ Dependencies go one way: `ui/widgets → model → services → api → @kumi/wow`.
17
+
18
+ ## Code
19
+
20
+ - Components are PascalCase functions with one typed, read-only props object and an optional `ref` forwarded with `nodeRef`. Pass changing data as bindings (refs, computed values, `storeToRefs` fields); do not read `.value` once at setup.
21
+ - Lists in JSX: `{items.value.map(item => <Row key={item.id} ... />)}` over a ref, so the list updates.
22
+ - Stores: `ref` for state, `readonly(ref)` for state only actions change, `computed` for derived state, functions for actions. Save fields with `persist: { pick: [...] }`. Change several saved fields with `batch`. Every `useX()` returns the same store.
23
+ - A store used by several features lives in the feature that owns its data. Other features import that feature's module.
24
+ - Styles live in `.module.scss` next to the components, imported from `@kumi/styles/<path>`. Colors and sizes come from `src/shared/styles/_tokens.scss`. No sizes or colors in TSX.
25
+ - WoW events: `useEvent` in stores and components, `@OnEvent` in services. Timers: `useNow`. Combat: `useCombat`. Slash commands: `useSlashCommand`.
26
+ - Kumi's compiler: no regular expressions, no circular imports, destructure WoW multiple results in one statement, and write explicit conditions (`count > 0`), because `0` and `""` are true in Lua.
27
+
28
+ ## Checks
29
+
30
+ Run `npm run check` and `npm run build -- --target forever` after every change. Fix the first error first; Kumi's errors name the file, line and fix.
31
+
32
+ ## Skills
33
+
34
+ Step-by-step guides for common tasks are in `.claude/skills/` and `.agents/skills/`: a new feature, a store, UI, a plugin, a WoW call, and fixing a failed build.
@@ -0,0 +1 @@
1
+ @AGENTS.md
@@ -1,14 +1,49 @@
1
1
  # __ADDON_NAME__
2
2
 
3
- A minimal World of Warcraft Retail addon written in TypeScript and TSX. Clicking the button increments its count.
3
+ A World of Warcraft addon built with [Kumi](https://github.com/OverMVP/kumi): TypeScript and TSX, compiled to Lua.
4
4
 
5
- Install Node.js 24, Rust with Cargo, and a complete Blizzard documentation export from the target Retail client. Point `KUMI_WOW_DOCS` to that export.
5
+ ## Commands
6
6
 
7
- ```sh
7
+ ```powershell
8
8
  npm install
9
- npm run check
10
- npm run build
11
- npm run link -- "<path-to-WoW-Retail>/Interface/AddOns"
9
+ npm run check # types, styles, routes and project rules
10
+ npm run build -- --target forever # or --target retail
11
+ npm run link -- "D:/Games/World of Warcraft/_forever_/Interface/AddOns"
12
12
  ```
13
13
 
14
- The build produces a native Lua 5.1 addon in `build/addons/__ADDON_NAME__`. The link command expects the AddOns directory to exist.
14
+ `check` and `build` need the WoW API documentation export in `KUMI_WOW_DOCS`. Link once; after that `npm run build` and `/reload` in the game.
15
+
16
+ In the game, type `/__ADDON_SLASH__` to open the window.
17
+
18
+ ## What is inside
19
+
20
+ ```text
21
+ kumi.config.ts Addon name, title, SavedVariables and plugins
22
+ src/app/ Startup, the root module, the window and its pages
23
+ src/modules/greeting/ A feature with every layer:
24
+ api/ WoW calls
25
+ services/ logic
26
+ model/ the store, saved in SavedVariables
27
+ ui/, widgets/ components, the HUD panel, the settings form
28
+ greeting.module.ts the feature's public API
29
+ src/modules/playtime/ A plugin: its own addon, turned on or off in the Plugins page
30
+ src/shared/ Reusable controls, tokens and helpers
31
+ ```
32
+
33
+ Code in a feature depends in one direction: `ui/widgets → model → services → api → WoW`. `npm run check` enforces it.
34
+
35
+ ## Common tasks
36
+
37
+ | Task | Where |
38
+ | --- | --- |
39
+ | Change a text or a rule | `services/` |
40
+ | Add saved state | the feature's store in `model/`, add the field to `persist.pick` |
41
+ | Add a control | `src/shared/ui`, then use it in a widget |
42
+ | Add a window page | `src/app/routes/(window)/<name>/page.tsx`, rendering a widget |
43
+ | Add a panel on screen | a widget, listed in the module's `views` |
44
+ | Add a plugin | a module under `src/modules`, listed in `plugins` in `kumi.config.ts` |
45
+
46
+ ## Learn more
47
+
48
+ - [Kumi guides](https://github.com/OverMVP/kumi/tree/main/docs)
49
+ - `AGENTS.md` and `.claude/skills/` for AI coding agents
@@ -1,12 +1,6 @@
1
1
  import ts from "@typescript-eslint/eslint-plugin";
2
2
  import parser from "@typescript-eslint/parser";
3
+ import { kumiRules } from "__KUMI_PACKAGE__/eslint.mjs";
3
4
 
4
- export default [{
5
- files: ["src/**/*.{ts,tsx}"],
6
- languageOptions: { parser },
7
- plugins: { "@typescript-eslint": ts },
8
- rules: {
9
- "no-debugger": "error",
10
- "@typescript-eslint/consistent-type-imports": "error",
11
- },
12
- }];
5
+ // Kumi's rules: feature layers (api → services → model → ui → widgets), module public APIs and the WoW boundary.
6
+ export default kumiRules({ parser, plugin: ts });
@@ -6,3 +6,4 @@
6
6
  *.log
7
7
  .env
8
8
  .env.*
9
+ /.local/
@@ -0,0 +1,17 @@
1
+ import type { KumiConfig } from "__KUMI_PACKAGE__/config";
2
+
3
+ export default {
4
+ addon: {
5
+ name: "__ADDON_NAME__",
6
+ title: "__ADDON_NAME__",
7
+ notes: "A Kumi addon",
8
+ savedVariables: "__ADDON_DB__",
9
+ },
10
+ plugins: {
11
+ playtime: {
12
+ module: "src/modules/playtime/playtime.module.ts",
13
+ title: "Playtime",
14
+ notes: "Shows how long you have played this session",
15
+ },
16
+ },
17
+ } satisfies KumiConfig;
@@ -4,12 +4,11 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "prepare:types": "node scripts/build.mjs types",
8
- "typecheck": "npm run prepare:types && tsc -p tsconfig.json",
7
+ "typecheck": "kumi check --types-only",
9
8
  "lint": "eslint src",
10
- "check": "npm run typecheck && npm run lint",
11
- "build": "node scripts/build.mjs build",
12
- "link": "kumi link build/addons"
9
+ "check": "kumi check",
10
+ "build": "kumi build",
11
+ "link": "kumi link"
13
12
  },
14
13
  "devDependencies": {
15
14
  "__KUMI_PACKAGE__": "__KUMI_VERSION__",
@@ -0,0 +1,18 @@
1
+ import { Module, ModuleType } from "@kumi/core";
2
+ import { router } from "@kumi/routes";
3
+ import { GreetingModule } from "../modules/greeting/greeting.module";
4
+ import { useCommands } from "./commands.store";
5
+ import { AppWindow } from "./layout/AppWindow";
6
+
7
+ // The root module: the core features, the addon window and app-wide stores.
8
+ const metadata = {
9
+ id: "app",
10
+ imports: [GreetingModule],
11
+ providers: [],
12
+ stores: [useCommands],
13
+ window: { routes: router, layout: AppWindow, width: 460, height: 360, start: "/home" },
14
+ exports: {},
15
+ } as const;
16
+
17
+ @Module(metadata)
18
+ export class AppModule extends ModuleType<typeof metadata> {}
@@ -0,0 +1,11 @@
1
+ import { defineStore } from "@kumi/state";
2
+ import { useSlashCommand, useWindow } from "@kumi/wow";
3
+
4
+ /** Slash commands of the addon. `/__ADDON_SLASH__` opens the window, `/__ADDON_SLASH__ settings` the settings page. */
5
+ export const useCommands = defineStore("commands", () => {
6
+ const window = useWindow();
7
+ useSlashCommand(["/__ADDON_SLASH__"], input => {
8
+ window.toggle(input === "settings" ? "/settings" : undefined);
9
+ });
10
+ return {};
11
+ });
@@ -0,0 +1,92 @@
1
+ @use "../../shared/styles/tokens" as *;
2
+
3
+ .window {
4
+ display: flex;
5
+ flex-direction: column;
6
+ width: 460px;
7
+ height: 360px;
8
+ background-color: $panel;
9
+ border: 1px solid $line;
10
+ border-radius: 8px;
11
+ }
12
+
13
+ .header {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 10px;
17
+ height: 36px;
18
+ padding: 0 12px 0 16px;
19
+ margin: 1px 1px 0;
20
+ background-color: $header;
21
+ border-radius: 6px;
22
+ }
23
+
24
+ .title {
25
+ flex-grow: 1;
26
+ font-size: 15px;
27
+ text-align: left;
28
+ color: $gold;
29
+ }
30
+
31
+ .close {
32
+ width: 26px;
33
+ min-width: 26px;
34
+ height: 26px;
35
+ border-radius: 4px;
36
+ background-color: $header;
37
+ }
38
+
39
+ .close:hover { background-color: $raised; }
40
+
41
+ .tabs {
42
+ display: flex;
43
+ gap: 6px;
44
+ padding: 8px 16px 0;
45
+ border-bottom: 1px solid $line;
46
+ }
47
+
48
+ .content {
49
+ flex-grow: 1;
50
+ min-height: 0;
51
+ }
52
+
53
+ .page {
54
+ position: absolute;
55
+ inset: 0;
56
+ display: flex;
57
+ flex-direction: column;
58
+ }
59
+
60
+ .list {
61
+ display: flex;
62
+ flex-direction: column;
63
+ gap: 10px;
64
+ padding: 16px;
65
+ }
66
+
67
+ .listRow {
68
+ display: flex;
69
+ align-items: center;
70
+ gap: 12px;
71
+ height: 44px;
72
+ border-bottom: 1px solid $line;
73
+ }
74
+
75
+ .listText {
76
+ display: flex;
77
+ flex-direction: column;
78
+ flex-grow: 1;
79
+ gap: 2px;
80
+ }
81
+
82
+ .listTitle {
83
+ font-size: 14px;
84
+ text-align: left;
85
+ color: $text;
86
+ }
87
+
88
+ .listNote {
89
+ font-size: 12px;
90
+ text-align: left;
91
+ color: $muted;
92
+ }
@@ -0,0 +1,32 @@
1
+ import { computed, storeToRefs } from "@kumi/state";
2
+ import { RouterView } from "@kumi/router";
3
+ import styles from "@kumi/styles/app/layout/AppWindow";
4
+ import { useWindow } from "@kumi/wow";
5
+ import { Button } from "../../shared/ui/Button";
6
+ import { Glyph } from "../../shared/ui/Glyph";
7
+
8
+ /** The frame of the addon window: title, page tabs and the active page. */
9
+ export function AppWindow() {
10
+ const window = useWindow();
11
+ // storeToRefs gives refs, so the tab list follows pages that plugins add later.
12
+ const { pages, path } = storeToRefs(window);
13
+ return (
14
+ <div fullWidth className={styles.window}>
15
+ <div className={styles.header}>
16
+ <span className={styles.title} value="__ADDON_NAME__" />
17
+ <button unstyled className={styles.close} ariaLabel="Close" onClick={window.close}>
18
+ <Glyph name="Close" />
19
+ </button>
20
+ </div>
21
+ <div className={styles.tabs}>
22
+ {pages.value.map(page => (
23
+ <Button key={page.path} label={page.title} checked={computed(() => path.value === page.path)}
24
+ onClick={() => { window.navigate(page.path); }} />
25
+ ))}
26
+ </div>
27
+ <div className={styles.content}>
28
+ <RouterView className={styles.page} />
29
+ </div>
30
+ </div>
31
+ );
32
+ }