@pikku/skills 0.12.59 → 0.12.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/skills",
3
- "version": "0.12.59",
3
+ "version": "0.12.60",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -5,6 +5,7 @@
5
5
  - Package Structure
6
6
  - pikku.config.json
7
7
  - package.json (key fields)
8
+ - Platform service contributors (`pikku.contributors`)
8
9
  - tsconfig.json (key fields)
9
10
 
10
11
  `npx pikku new addon` scaffolds these files. You rarely hand-edit them — consult this when wiring exports or config by hand.
@@ -98,6 +99,58 @@ live in a file that never imports `#pikku` — see "Functions" in the skill.
98
99
  writes `@my-org/addon-todos/.pikku/rpc/...`, exactly as it would in an
99
100
  application, and the leaf stays the package's own business.
100
101
 
102
+ ## Platform service contributors (`pikku.contributors`)
103
+
104
+ An addon can ship code that runs in the **host's** generated
105
+ `createPlatformServices` — a log source over the host's database, a client
106
+ built from a host secret. `wireAddon` has no field for it; the package declares
107
+ it in its own `package.json`, the same shape as the host's `dev.contributors`:
108
+
109
+ ```json
110
+ {
111
+ "exports": {
112
+ "./contributors": {
113
+ "types": "./dist/src/contributors.d.ts",
114
+ "import": "./dist/src/contributors.js"
115
+ }
116
+ },
117
+ "pikku": {
118
+ "contributors": [
119
+ { "module": "@my-org/addon-logs/contributors", "export": "logSources" }
120
+ ]
121
+ }
122
+ }
123
+ ```
124
+
125
+ `module` resolves from the addon's package directory. Every app that wires the
126
+ addon (not `wireRemoteAddon`) picks the contributors up: `pikku all` emits them
127
+ into `.pikku/pikku-dev-platform-services.gen.ts` for `pikku dev`, and
128
+ `pikku deploy plan` / `apply` hands them to the provider adapter, after the
129
+ app's own `deploy.contributors`.
130
+
131
+ Declare what a contributor reads and sets, rather than relying on list order:
132
+
133
+ ```ts
134
+ export const logSources: PlatformServiceContributor = {
135
+ name: 'log-sources',
136
+ needs: ['kysely'], // runtime.kysely, or a contributor's services.kysely
137
+ provides: ['logSources', 'logSources.workspace'],
138
+ imports: [`import { kyselyLogSource } from '@my-org/addon-logs/log-source'`],
139
+ emit: () => [
140
+ ` services.logSources = { workspace: kyselyLogSource(runtime.kysely) }`,
141
+ ],
142
+ }
143
+ ```
144
+
145
+ Contributors are sorted so each runs after every contributor providing one of
146
+ its `needs`; a dotted need (`logSources.stage`) is met by a provider of the key
147
+ or of its prefix. Emitted lines read services the entry built before them as
148
+ `runtime.<name>` — `pikku dev` has logger, variables, secrets, schema and (with
149
+ `db`) kysely; the standalone entry has logger, kysely (with a database) and its
150
+ scheduler/queue/workflow/trigger services and event hub. Codegen **fails** on a
151
+ need nothing meets, on two contributors providing the same key, and on a cycle,
152
+ naming the contributors involved.
153
+
101
154
  ## tsconfig.json (key fields)
102
155
 
103
156
  ```json
@@ -179,8 +179,12 @@ in the repo, green or red on every future run.
179
179
  }
180
180
  ```
181
181
 
182
- The module exports a `PlatformServiceContributor` (`{ name, imports?, emit }`, the
183
- type `@pikku/deploy` takes). `pikku all` writes `.pikku/pikku-dev-platform-services.gen.ts`
182
+ The module exports a `PlatformServiceContributor` (`{ name, needs?, provides?, imports?, emit }`, the
183
+ type `@pikku/deploy` takes). Addons the project wires add their own, declared in their
184
+ package.json as `pikku.contributors` (see the pikku-addon skill's package manifest
185
+ reference). Contributors run in the order their `needs`/`provides` require, and the
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`
184
188
  from them, and `pikku dev` merges what it returns over the local services before
185
189
  `createSingletonServices` runs, so a contributed `emailService` beats
186
190
  `LocalEmailService` (and the test-mode spy). Nothing is written without
@@ -25,6 +25,13 @@ 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 a host injects into the bundle come from contributors:
29
+ `deploy.contributors` in `pikku.config.json` (`[{ "module", "export"? }]`, the
30
+ same shape as `dev.contributors`) plus the `pikku.contributors` every wired addon
31
+ declares in its package.json. `plan` and `apply` pass them all to the adapter,
32
+ which orders them by `needs`/`provides` and, on standalone, runs them after the
33
+ database is open, with `runtime.logger` and `runtime.kysely` in reach.
34
+
28
35
  Always run `plan` before `apply`, and read it. It names what will be created,
29
36
  updated and deleted — the deletions are the reason to look.
30
37
 
@@ -124,6 +124,13 @@ Config lives in `pikku.config.json`:
124
124
  }
125
125
  ```
126
126
 
127
+ A config can `extends` another (`"extends": "./pikku.config.json"`) and state only
128
+ what differs. The child merges into the parent: objects merge key by key,
129
+ `srcDirectories` is the parent's list plus the child's new entries, every other
130
+ array and value the child sets replaces the parent's, and `null` removes a
131
+ parent value. Each file's paths are relative to that file, and `rootDir` is
132
+ inherited unless the child sets its own.
133
+
127
134
  ## Project Structure Convention
128
135
 
129
136
  ```text