@pikku/skills 0.12.62 → 0.12.63
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/dist/skills.gen.js +1 -1
- package/package.json +1 -1
- package/skills/pikku-addon/SKILL.md +4 -4
- package/skills/pikku-addon/references/addon-package-manifest.md +57 -42
- package/skills/pikku-build/references/mocks.md +12 -0
- package/skills/pikku-build/references/phase-4-build.md +22 -20
- package/skills/pikku-build/references/ship.md +10 -6
- package/skills/pikku-theme/SKILL.md +24 -2
- package/skills/pikku-theme/references/from-a-reference.md +3 -0
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@ wireAddon({
|
|
|
52
52
|
mcp?: boolean | string[], // true: every function the addon declared mcp: true; a list: the tools this app offers, typed against the addon's function names
|
|
53
53
|
expose?: boolean | string[], // opt-in: what rpc.exposed / POST /rpc may reach. true = every function the addon declared expose: true, a list = those of them named (typed; PKU343 on unknown or undeclared names), unset/false = none
|
|
54
54
|
tags?: string[], // Tags applied to all addon functions
|
|
55
|
-
ui?: boolean, // Mount the screens the addon declares with
|
|
55
|
+
ui?: boolean, // Mount the screens the addon declares with definePlugin
|
|
56
56
|
scopes?: string[], // Required of every function, on top of its own
|
|
57
57
|
secretOverrides?: Record<string, string>, // Remap secret names (and grant them)
|
|
58
58
|
variableOverrides?: Record<string, string>, // Remap variable names
|
|
@@ -377,14 +377,14 @@ At runtime an unmapped alias, or the wired name called directly, throws
|
|
|
377
377
|
|
|
378
378
|
### Studio screens
|
|
379
379
|
|
|
380
|
-
An addon declares the screens it adds to Pikku Studio with `
|
|
380
|
+
An addon declares the screens it adds to Pikku Studio with `definePlugin`, in
|
|
381
381
|
`src/screens.ts` (`pikku new addon-ui <name>` scaffolds one). It replaces
|
|
382
382
|
`defineScreens`, which no longer exists.
|
|
383
383
|
|
|
384
384
|
```typescript
|
|
385
|
-
import {
|
|
385
|
+
import { definePlugin } from '@pikku/core/addon'
|
|
386
386
|
|
|
387
|
-
export default
|
|
387
|
+
export default definePlugin({
|
|
388
388
|
title: 'invoices__title', // message key: the addon's name in Studio
|
|
389
389
|
screens: [
|
|
390
390
|
{
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
- Package Structure
|
|
6
6
|
- pikku.config.json
|
|
7
7
|
- package.json (key fields)
|
|
8
|
-
- Platform service contributors (`
|
|
8
|
+
- Platform service contributors (`defineContributors`)
|
|
9
9
|
- tsconfig.json (key fields)
|
|
10
10
|
|
|
11
11
|
`npx pikku new addon` scaffolds these files. You rarely hand-edit them — consult this when wiring exports or config by hand.
|
|
@@ -105,57 +105,72 @@ live in a file that never imports `#pikku` — see "Functions" in the skill.
|
|
|
105
105
|
writes `@my-org/addon-todos/.pikku/rpc/...`, exactly as it would in an
|
|
106
106
|
application, and the leaf stays the package's own business.
|
|
107
107
|
|
|
108
|
-
## Platform service contributors (`
|
|
108
|
+
## Platform service contributors (`defineContributors`)
|
|
109
109
|
|
|
110
|
-
An addon can ship code that
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
An addon can ship code that builds services for the **host's** target — a log
|
|
111
|
+
source over the host's database, a client built from a host secret. The addon
|
|
112
|
+
registers them in code with `defineContributors`; nothing goes in `package.json`
|
|
113
|
+
and `wireAddon` of the addon itself has no field for it. A host that wants one
|
|
114
|
+
opts in by name with `wireAddon({ contributors: ['log-sources'] })`, and gets
|
|
115
|
+
nothing it did not list.
|
|
114
116
|
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
"contributors": [
|
|
125
|
-
{ "module": "@my-org/addon-logs/contributors", "export": "logSources" }
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
}
|
|
117
|
+
```ts
|
|
118
|
+
// src/contributors.ts
|
|
119
|
+
import { defineContributors } from '@pikku/core/contributors'
|
|
120
|
+
import { logSourcesDev } from './log-sources-dev.js'
|
|
121
|
+
import { logSourcesDeploy } from './log-sources-deploy.js'
|
|
122
|
+
|
|
123
|
+
export const contributors = defineContributors({
|
|
124
|
+
'log-sources': { dev: logSourcesDev, deploy: logSourcesDeploy },
|
|
125
|
+
})
|
|
129
126
|
```
|
|
130
127
|
|
|
131
|
-
`module` resolves from the addon's package directory. Every app that wires the
|
|
132
|
-
addon (not `wireRemoteAddon`) picks the contributors up: `pikku all` emits them
|
|
133
|
-
into `.pikku/pikku-dev-platform-services.gen.ts` for `pikku dev`, and
|
|
134
|
-
`pikku deploy plan` / `apply` hands them to the provider adapter, after the
|
|
135
|
-
app's own `deploy.contributors`.
|
|
136
|
-
|
|
137
|
-
Declare what a contributor reads and sets, rather than relying on list order:
|
|
138
|
-
|
|
139
128
|
```ts
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
// src/log-sources-deploy.ts — each variant in its OWN module
|
|
130
|
+
import type { Contributor } from '@pikku/core/contributors'
|
|
131
|
+
import { kyselyLogSource } from './log-source.js'
|
|
132
|
+
|
|
133
|
+
export const logSourcesDeploy: Contributor = {
|
|
142
134
|
needs: ['kysely'], // runtime.kysely, or a contributor's services.kysely
|
|
143
135
|
provides: ['logSources', 'logSources.workspace'],
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
],
|
|
136
|
+
run: (services, _env, runtime) => {
|
|
137
|
+
services.logSources = { workspace: kyselyLogSource(runtime.kysely) }
|
|
138
|
+
},
|
|
148
139
|
}
|
|
149
140
|
```
|
|
150
141
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
`
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
142
|
+
Rules the inspector and the build enforce:
|
|
143
|
+
|
|
144
|
+
- `defineContributors` takes an object literal keyed by contributor name; each
|
|
145
|
+
`dev` / `deploy` value must be a reference to an `export const`. Anything else
|
|
146
|
+
is PKU360; a name defined twice is PKU361.
|
|
147
|
+
- **Each variant lives in its own module.** The build imports the module that
|
|
148
|
+
exports the selected variant, so a `dev` and a `deploy` variant sharing a file
|
|
149
|
+
both reach every bundle, production included.
|
|
150
|
+
- A contributor with no variant for a target is simply not part of it.
|
|
151
|
+
- Run `pikku all` in the addon: it writes
|
|
152
|
+
`.pikku/contributors/pikku-contributors-meta.gen.json`, which a host reads to
|
|
153
|
+
opt in (an unknown name is PKU363). Ship `.pikku` in `files`.
|
|
154
|
+
- `pikku.contributors` in `package.json` is removed and is now an error
|
|
155
|
+
(PKU364), not silently ignored.
|
|
156
|
+
- Contributors run after every contributor providing one of their `needs`; a
|
|
157
|
+
dotted need (`logSources.stage`) is met by a provider of the key or its
|
|
158
|
+
prefix. `run` reads services the target built before it as `runtime.<name>` —
|
|
159
|
+
`pikku dev` has logger, variables, secrets, schema and (with `db`) kysely; the
|
|
160
|
+
standalone entry has logger, kysely (with a database) and its
|
|
161
|
+
scheduler/queue/workflow/trigger services and event hub.
|
|
162
|
+
- Two contributors providing the same key (after `when` / `requires` filtering)
|
|
163
|
+
is a build error naming both, except that a target's baseline services may be
|
|
164
|
+
replaced. A decorator declares `provides: []`. A contributor providing what it
|
|
165
|
+
needs is a cycle. An unmet `needs` is a build error.
|
|
166
|
+
- `requires: ['cloudflare']` on a contributor a host opted in to, for a target
|
|
167
|
+
that cannot supply it, is a build error; use `when` to say "not here".
|
|
168
|
+
- `onServerStart` / `onServerStop` run only where the server lifecycle runs
|
|
169
|
+
(dev, serve, standalone, generic server entry, Cloudflare container). On a
|
|
170
|
+
Worker `onServerStart` is a build error and `onServerStop` a warning.
|
|
171
|
+
- Fail closed: a contributor whose bindings are missing at startup throws.
|
|
172
|
+
|
|
173
|
+
Full reference: `docs/contributors.md` in the pikku repo.
|
|
159
174
|
|
|
160
175
|
## tsconfig.json (key fields)
|
|
161
176
|
|
|
@@ -10,6 +10,18 @@ Read this when a screen needs data no function returns yet, or returns in a diff
|
|
|
10
10
|
|
|
11
11
|
The app loads its mocks with `registerPikkuMocks()` from the generated `mocks.gen.ts` beside `api.gen.ts`, called when `import.meta.env.DEV || import.meta.env.VITE_MOCK`. It covers the app's `.mocks/` and every wired addon's, so never glob `.mocks` or `node_modules` by hand.
|
|
12
12
|
|
|
13
|
+
## Adding a mock
|
|
14
|
+
|
|
15
|
+
`pikku mocks add <rpc>` does the whole job. It checks the RPC is a real function, writes `.mocks/<rpc with : as .>/<state>.json` and `<state>.meta.json`, keeps exactly one default (the first mock is the default, `--default` moves it) and prints the stub hook to use. The response comes from `--body '<json>'` or `--from <file>`; an error mock and an empty mock of a list have a default body.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
pikku mocks add classes:month --body '[{"id":"c1","name":"Yoga"}]' --flag classMonth
|
|
19
|
+
pikku mocks add classes:month --state empty
|
|
20
|
+
pikku mocks add classes:month --state error --status 500
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`--flag <name>` declares the flag in the project's `defineFeatureFlags({ ... })` file when it is not there yet, or prints the entry to add by hand. Nothing is overwritten without `--force`. A body that differs from the function's output is written anyway and reported, because a stub may stand in for data the function does not return yet.
|
|
24
|
+
|
|
13
25
|
## Addon mocks
|
|
14
26
|
|
|
15
27
|
An addon ships default mocks in its own package as `.mocks/<function>/<scenario>.json`, named without a namespace, and lists `.mocks` in `files`. An app that wires the addon as `studio` gets them as `studio:<function>`. The app's `.mocks/studio.<function>/` adds scenarios; one with the same name replaces the addon's, and a `default: true` in the app wins over the addon's default. Put mocks for an addon's functions in the addon, and only the app's own variations in the app.
|
|
@@ -166,29 +166,31 @@ it is worth writing as a browser step on §7's scenario and running
|
|
|
166
166
|
`pikku scenario run local --spawn --run browser`: same clicks, same assertions,
|
|
167
167
|
in the repo, green or red on every future run.
|
|
168
168
|
|
|
169
|
-
**A
|
|
170
|
-
`
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
169
|
+
**A project can take platform services from an addon's contributors.** The addon
|
|
170
|
+
registers them with `defineContributors` (an object keyed by name, each with an
|
|
171
|
+
optional `dev` and `deploy` variant that is a plain `Contributor`), and the
|
|
172
|
+
project opts in by name:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
wireAddon({
|
|
176
|
+
name: 'inbox',
|
|
177
|
+
package: '@my-org/addon-inbox',
|
|
178
|
+
contributors: ['inbox'],
|
|
179
|
+
})
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
generated `createPlatformServices(env, runtime)` gets the local services as `runtime`;
|
|
187
|
-
an unmet need, a key provided twice or a cycle fails `pikku all`. `pikku all` writes `.pikku/pikku-dev-platform-services.gen.ts`
|
|
188
|
-
from them, and `pikku dev` merges what it returns over the local services before
|
|
182
|
+
Nothing is injected without that list. `pikku all` resolves the `dev` variants
|
|
183
|
+
(dropping what `when` or `requires` rules out, ordering by `needs`/`provides`)
|
|
184
|
+
and writes `.pikku/contributors/pikku-dev-contributors.gen.ts`; `pikku dev` and
|
|
185
|
+
`pikku serve` merge what it builds over the local services before
|
|
189
186
|
`createSingletonServices` runs, so a contributed `emailService` beats
|
|
190
|
-
`LocalEmailService` (and the test-mode spy).
|
|
191
|
-
|
|
187
|
+
`LocalEmailService` (and the test-mode spy). Both skip the file under
|
|
188
|
+
`NODE_ENV=production`. A contributor's `onServerStart` runs before the app's
|
|
189
|
+
`beforeStart`; its `onServerStop` after the app's `afterStop`. An unmet need, a
|
|
190
|
+
key provided twice or a cycle fails `pikku all`, and so does a declared database
|
|
191
|
+
(`createConfig` or `db/<dialect>`) with no `db` in the pikku config. A host that
|
|
192
|
+
injects an addon (CI, Studio) writes a gitignored wiring file containing
|
|
193
|
+
`wireAddon({ name, package, contributors })`. Reference: `docs/contributors.md`.
|
|
192
194
|
|
|
193
195
|
## 6a. Close the changeset against its plan, not against your memory
|
|
194
196
|
|
|
@@ -25,12 +25,16 @@ with Node, or a self-contained executable compiled with `bun build --compile`.
|
|
|
25
25
|
factories the deploy codegen expects, and hand-rolling an `ExportedHandler` is
|
|
26
26
|
how a worker deploy fails at runtime instead of at build.
|
|
27
27
|
|
|
28
|
-
Platform services
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
Platform services an addon builds for the bundle come from contributors the
|
|
29
|
+
project opted in to with `wireAddon({ contributors: [...] })`; the addon
|
|
30
|
+
registers them with `defineContributors`. `plan` and `apply` select the `deploy`
|
|
31
|
+
variant of each, drop what `when` rules out, order them by `needs`/`provides`
|
|
32
|
+
and, on standalone, run them after the database is open, with `runtime.logger`
|
|
33
|
+
and `runtime.kysely` in reach. Standalone, the generic server entry and the
|
|
34
|
+
Cloudflare adapter support contributors; a provider without `contributorSupport`
|
|
35
|
+
fails the build when a project opts in to one with a deploy variant. On a
|
|
36
|
+
Cloudflare Worker a contributor with `onServerStart` is a build error. See
|
|
37
|
+
`docs/contributors.md`.
|
|
34
38
|
|
|
35
39
|
Always run `plan` before `apply`, and read it. It names what will be created,
|
|
36
40
|
updated and deleted — the deletions are the reason to look.
|
|
@@ -90,8 +90,9 @@ pikku ui theme apply --preset quorum --structure monopro
|
|
|
90
90
|
| `--structure <id>` | swap in another preset's structure (depth) under this brand |
|
|
91
91
|
| `--primary`, `--secondary`, `--accent` | brand colours, hex |
|
|
92
92
|
| `--font-heading`, `--font-body` | Google Fonts families |
|
|
93
|
-
| `--
|
|
94
|
-
| `--
|
|
93
|
+
| `--mode light\|dark` | `light` (default). `dark` makes `--page`/`--ink` the dark ground and its text (see Dark designs) |
|
|
94
|
+
| `--page` | page colour (`structure.page`) — paper, linen, bone instead of white; with `--mode dark`, the dark ground |
|
|
95
|
+
| `--ink` | text colour (`structure.ink`); with `--mode dark`, the text on the dark ground |
|
|
95
96
|
|
|
96
97
|
Flags are flat scalars, one value each; there is no nested `--colors` object. One call writes the
|
|
97
98
|
theme, makes it active, regenerates `themes/index.ts` (so the running app reloads) and re-brands
|
|
@@ -102,6 +103,27 @@ Fine-grained structure tweaks the flags do not cover (a shadow scale, the radius
|
|
|
102
103
|
the active `themes/<id>.json` `structure`, followed by `pikku ui theme apply` to regenerate
|
|
103
104
|
`theme.css`; keep them in the theme, not in components.
|
|
104
105
|
|
|
106
|
+
## Dark designs
|
|
107
|
+
|
|
108
|
+
`--page`/`--ink` are light-mode colours unless you pass `--mode dark`. For a design that is dark
|
|
109
|
+
(a dark reference, a dark ground in the brief) always pass `--mode dark` with its ground and text:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pikku ui theme apply --preset linear --mode dark \
|
|
113
|
+
--primary '#c6ff3d' --secondary '#22262d' --page '#14161a' --ink '#eef1f4'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Every other token is derived for that ground: card and popover a step lighter, muted a further
|
|
117
|
+
step, muted text a mid tone of the ink at 4.5:1 or better, border and input visibly above the card,
|
|
118
|
+
and each `-foreground` black or white by contrast against its actual fill (so a lime primary gets a
|
|
119
|
+
dark label). The same values are written to `:root` and `.dark` (with `color-scheme: dark`), so a
|
|
120
|
+
stored scheme or `class="dark"` never switches to the preset's unrelated greys. Without
|
|
121
|
+
`--mode dark`, a dark `--page` is derived as a light ground and comes out wrong.
|
|
122
|
+
|
|
123
|
+
After every apply the command prints a contrast report (text/page, muted-text/page,
|
|
124
|
+
primary-foreground/primary, border/page, input/page) and warns on any pair under its target; fix
|
|
125
|
+
the colours and re-run, the exit code stays 0.
|
|
126
|
+
|
|
105
127
|
## Colour rule
|
|
106
128
|
|
|
107
129
|
Every colour in app code comes from the theme: a semantic utility (`bg-primary`, `text-foreground`,
|
|
@@ -20,6 +20,9 @@ has no extractor: you read the design off the source and pass it to `pikku ui th
|
|
|
20
20
|
pikku ui theme apply --preset breeze --primary '#0B6E99' --font-heading 'Manrope' --font-body 'Manrope' --page '#F7F5F0' --ink '#1C2A33'
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
If the reference is dark, add `--mode dark` (then `--page`/`--ink` are the dark ground and its
|
|
24
|
+
text); without it a dark page is derived as a light one.
|
|
25
|
+
|
|
23
26
|
You are the art director: what you read is signal, not a finished theme. Check page and ink
|
|
24
27
|
against each other and against the primary for 4.5:1 before applying.
|
|
25
28
|
|