@pikku/skills 0.12.21 → 0.12.25
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/CHANGELOG.md +125 -0
- package/dist/skills.gen.js +1 -1
- package/package.json +1 -1
- package/skills/pikku-addon/SKILL.md +10 -9
- package/skills/pikku-agent/SKILL.md +67 -316
- package/skills/pikku-agent/references/agents.md +299 -0
- package/skills/{pikku-ai-vercel/SKILL.md → pikku-agent/references/runner-vercel.md} +2 -24
- package/skills/{pikku-ai-voice/SKILL.md → pikku-agent/references/voice.md} +1 -22
- package/skills/pikku-architect/SKILL.md +264 -0
- package/skills/pikku-auth/SKILL.md +89 -0
- package/skills/{pikku-better-auth/SKILL.md → pikku-auth/references/better-auth.md} +42 -47
- package/skills/{pikku-jose/SKILL.md → pikku-auth/references/jose.md} +1 -23
- package/skills/{pikku-machine-auth/SKILL.md → pikku-auth/references/machine-auth.md} +0 -23
- package/skills/{pikku-permissions/SKILL.md → pikku-auth/references/permissions.md} +5 -24
- package/skills/{pikku-security/SKILL.md → pikku-auth/references/sessions.md} +3 -23
- package/skills/pikku-build/SKILL.md +87 -0
- package/skills/{pikku-build-app/SKILL.md → pikku-build/references/app.md} +77 -25
- package/skills/{pikku-feature/SKILL.md → pikku-build/references/feature.md} +1 -8
- package/skills/{pikku-build-app → pikku-build}/references/multi-app.md +1 -1
- package/skills/{pikku-build-platform/SKILL.md → pikku-build/references/platform.md} +22 -37
- package/skills/{pikku-template-clone/SKILL.md → pikku-build/references/post-clone.md} +0 -6
- package/skills/{pikku-build-quick/SKILL.md → pikku-build/references/quick.md} +6 -22
- package/skills/{pikku-build-app → pikku-build}/references/ship.md +7 -1
- package/skills/pikku-concepts/SKILL.md +75 -8
- package/skills/pikku-concepts/references/concept-mapping.md +8 -8
- package/skills/pikku-deploy/SKILL.md +158 -0
- package/skills/{pikku-deploy-azure/SKILL.md → pikku-deploy/references/azure.md} +18 -50
- package/skills/pikku-deploy/references/cloudflare.md +104 -0
- package/skills/pikku-deploy/references/express.md +92 -0
- package/skills/{pikku-deploy-fastify/SKILL.md → pikku-deploy/references/fastify.md} +8 -32
- package/skills/{pikku-deploy-lambda/SKILL.md → pikku-deploy/references/lambda.md} +6 -27
- package/skills/{pikku-deploy-nextjs/SKILL.md → pikku-deploy/references/nextjs.md} +9 -33
- package/skills/pikku-deploy/references/uws.md +72 -0
- package/skills/pikku-deploy/references/ws.md +75 -0
- package/skills/pikku-emails/SKILL.md +3 -2
- package/skills/pikku-fabric/SKILL.md +20 -10
- package/skills/{pikku-fabric-debug/SKILL.md → pikku-fabric/references/debugging.md} +0 -6
- package/skills/pikku-i18n/SKILL.md +60 -207
- package/skills/{pikku-paraglide/SKILL.md → pikku-i18n/references/enum-labels.md} +0 -6
- package/skills/pikku-i18n/references/messages.md +218 -0
- package/skills/{pikku-rtl/SKILL.md → pikku-i18n/references/rtl.md} +3 -9
- package/skills/pikku-knowledge/SKILL.md +14 -0
- package/skills/pikku-kysely/SKILL.md +13 -13
- package/skills/pikku-meta/SKILL.md +58 -130
- package/skills/{pikku-deps/SKILL.md → pikku-meta/references/audit.md} +1 -17
- package/skills/pikku-meta/references/meta.md +114 -0
- package/skills/{pikku-versioning/SKILL.md → pikku-meta/references/versioning.md} +0 -26
- package/skills/pikku-middleware/SKILL.md +8 -8
- package/skills/pikku-n8n-import/SKILL.md +0 -1
- package/skills/pikku-react/SKILL.md +50 -298
- package/skills/pikku-react/references/client.md +293 -0
- package/skills/{pikku-react-query/SKILL.md → pikku-react/references/react-query.md} +2 -22
- package/skills/{pikku-workflows-client/SKILL.md → pikku-react/references/workflows.md} +1 -22
- package/skills/pikku-scenario/SKILL.md +64 -49
- package/skills/pikku-scenario/references/persona-run.md +148 -0
- package/skills/pikku-service-backends/SKILL.md +154 -0
- package/skills/pikku-service-backends/references/aws.md +106 -0
- package/skills/pikku-service-backends/references/backblaze.md +57 -0
- package/skills/pikku-service-backends/references/mongodb.md +90 -0
- package/skills/pikku-service-backends/references/redis.md +75 -0
- package/skills/pikku-service-backends/references/schema.md +63 -0
- package/skills/pikku-services/SKILL.md +68 -291
- package/skills/{pikku-audit/SKILL.md → pikku-services/references/audit.md} +0 -22
- package/skills/{pikku-config/SKILL.md → pikku-services/references/config.md} +1 -25
- package/skills/{pikku-pino/SKILL.md → pikku-services/references/pino.md} +0 -20
- package/skills/pikku-services/references/services.md +272 -0
- package/skills/pikku-software-archaeology/README.md +5 -1
- package/skills/pikku-software-archaeology/SKILL.md +15 -2
- package/skills/{pikku-product-second-opinion/example/sample-report.md → pikku-software-archaeology/example/second-opinion-sample-report.md} +1 -1
- package/skills/pikku-software-archaeology/references/blueprint.schema.json +1 -1
- package/skills/pikku-software-archaeology/references/pikku-mapping.md +3 -3
- package/skills/{pikku-product-second-opinion/SKILL.md → pikku-software-archaeology/references/second-opinion.md} +4 -9
- package/skills/pikku-webhook/SKILL.md +199 -0
- package/skills/pikku-wiring/SKILL.md +180 -0
- package/skills/{pikku-websocket/SKILL.md → pikku-wiring/references/channel.md} +2 -35
- package/skills/{pikku-cli/SKILL.md → pikku-wiring/references/cli.md} +1 -33
- package/skills/{pikku-gateway-slack/SKILL.md → pikku-wiring/references/gateway-slack.md} +0 -23
- package/skills/{pikku-http/SKILL.md → pikku-wiring/references/http.md} +4 -40
- package/skills/{pikku-mcp/SKILL.md → pikku-wiring/references/mcp.md} +0 -33
- package/skills/{pikku-queue/SKILL.md → pikku-wiring/references/queue.md} +1 -33
- package/skills/{pikku-realtime/SKILL.md → pikku-wiring/references/realtime.md} +2 -25
- package/skills/{pikku-rpc/SKILL.md → pikku-wiring/references/rpc.md} +0 -32
- package/skills/{pikku-schedule/SKILL.md → pikku-wiring/references/scheduler.md} +1 -35
- package/skills/{pikku-trigger/SKILL.md → pikku-wiring/references/trigger.md} +0 -43
- package/skills/pikku-workflow/SKILL.md +3 -3
- package/skills/pikku-aws/SKILL.md +0 -161
- package/skills/pikku-backblaze/SKILL.md +0 -104
- package/skills/pikku-deploy-cloudflare/SKILL.md +0 -123
- package/skills/pikku-deploy-express/SKILL.md +0 -122
- package/skills/pikku-deploy-uws/SKILL.md +0 -144
- package/skills/pikku-mongodb/SKILL.md +0 -113
- package/skills/pikku-product-second-opinion/README.md +0 -43
- package/skills/pikku-redis/SKILL.md +0 -99
- package/skills/pikku-schema-ajv/SKILL.md +0 -83
- package/skills/pikku-schema-cfworker/SKILL.md +0 -82
- package/skills/pikku-ws/SKILL.md +0 -87
- /package/skills/{pikku-build-app → pikku-build}/references/theming.md +0 -0
- /package/skills/{pikku-product-second-opinion/references/report-template.md → pikku-software-archaeology/references/second-opinion-report-template.md} +0 -0
- /package/skills/{pikku-cli/references/complete-example.md → pikku-wiring/references/cli-complete-example.md} +0 -0
- /package/skills/{pikku-http → pikku-wiring}/references/http-options.md +0 -0
- /package/skills/{pikku-realtime/references/other-routes.md → pikku-wiring/references/realtime-other-routes.md} +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-wiring
|
|
3
|
+
description: >-
|
|
4
|
+
Use when exposing a Pikku function over a transport — HTTP routes and SSE, WebSocket channels,
|
|
5
|
+
typed realtime pub/sub, internal and exposed RPC, queue workers, cron schedules, event triggers,
|
|
6
|
+
MCP tools/resources/prompts, CLI commands, or a Slack gateway. Covers choosing the wiring, the
|
|
7
|
+
model every wiring shares, and what differs: which function type each needs, where a session
|
|
8
|
+
comes from, and which calls throw instead of returning. TRIGGER when: code uses wireHTTP,
|
|
9
|
+
defineHTTPRoutes, wireChannel, wireQueueWorker, wireScheduler, wireTrigger, wireTriggerSource,
|
|
10
|
+
wireCLI, wireMCPResource, wireMCPPrompt, `mcp: true`, `sse: true`, `expose: true`, rpc.invoke,
|
|
11
|
+
SlackGatewayAdapter, or the user asks how to expose, route, schedule, queue, stream or publish a
|
|
12
|
+
function. DO NOT TRIGGER when: writing the function body itself (use pikku-concepts), declaring
|
|
13
|
+
authorization (use pikku-auth), or serving the app on a runtime (use pikku-deploy).
|
|
14
|
+
installGroups: [core]
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Pikku Wiring
|
|
18
|
+
|
|
19
|
+
## Agent Operating Procedure
|
|
20
|
+
|
|
21
|
+
Use this skill as an execution checklist, not reference material.
|
|
22
|
+
|
|
23
|
+
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
24
|
+
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
25
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
26
|
+
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
27
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
28
|
+
|
|
29
|
+
## Before you start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pikku info functions --verbose # existing functions, their types, tags, middleware
|
|
33
|
+
pikku info tags --verbose # project organisation and naming conventions
|
|
34
|
+
pikku info middleware --verbose # what middleware is already applied
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Follow the patterns you find. Option tables and exact signatures come from
|
|
38
|
+
`pikku doc` — run `pikku doc --ai` for the installed surface. This skill is what
|
|
39
|
+
the compiler cannot tell you: which wiring to reach for, and what changes when
|
|
40
|
+
you move a function from one to another.
|
|
41
|
+
|
|
42
|
+
## What a wiring is
|
|
43
|
+
|
|
44
|
+
A **function** owns behaviour, its `input`/`output` schemas, and its
|
|
45
|
+
authorization. A **wiring** owns only the transport: how a caller reaches that
|
|
46
|
+
function. The same function can be wired to several transports at once, which is
|
|
47
|
+
why nothing transport-specific belongs in its body.
|
|
48
|
+
|
|
49
|
+
Three consequences that hold for every wiring below:
|
|
50
|
+
|
|
51
|
+
- **Input and output types are never declared on the wiring.** They come from the
|
|
52
|
+
function's own `input:`/`output:` schemas. Route params, query params and body
|
|
53
|
+
are merged into the function's `data` argument.
|
|
54
|
+
- **Permissions are never declared on the wiring.** Wire-level permissions were
|
|
55
|
+
removed in #972 — declare them on the function (`pikkuFunc({ permissions })`,
|
|
56
|
+
see `pikku-auth`) or app-wide via `addGlobalPermission`. Tags and
|
|
57
|
+
patterns now target *middleware* only.
|
|
58
|
+
- **The wire is the third argument**, not a service. `channel`, `rpc`, `session`,
|
|
59
|
+
`setSession`, `mcp`, `queue`, `scheduledTask` and `cli` all live there.
|
|
60
|
+
|
|
61
|
+
## Import from `#pikku/*`, never `@pikku/core/*`
|
|
62
|
+
|
|
63
|
+
Every wiring factory has two versions. The generated `#pikku/*` entrypoint binds
|
|
64
|
+
it to your project's service, session and middleware types; the `@pikku/core/*`
|
|
65
|
+
export is the unbound generic. **Both compile.** Importing from core costs you
|
|
66
|
+
exactly the typing that makes the wiring worth having, silently.
|
|
67
|
+
|
|
68
|
+
| Wiring | Import from |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `wireHTTP`, `defineHTTPRoutes`, `wireHTTPRoutes` | `#pikku/http` |
|
|
71
|
+
| `wireChannel`, `defineChannelRoutes` | `#pikku/channel` |
|
|
72
|
+
| `wireQueueWorker` | `#pikku/queue` |
|
|
73
|
+
| `wireScheduler` | `#pikku/scheduler` |
|
|
74
|
+
| `wireTrigger`, `wireTriggerSource`, `pikkuTriggerFunc` | `#pikku/trigger` |
|
|
75
|
+
| `wireCLI`, `pikkuCLICommand`, `pikkuCLIRender` | `#pikku/cli` |
|
|
76
|
+
| `pikkuMCPToolFunc`, `pikkuMCPResourceFunc`, `pikkuMCPPromptFunc`, `wireMCPResource`, `wireMCPPrompt` | `#pikku/mcp` |
|
|
77
|
+
|
|
78
|
+
## Pick a wiring
|
|
79
|
+
|
|
80
|
+
| Reach for | When | Reference |
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| **HTTP** | REST endpoints, web APIs, and SSE streams (`sse: true`, `get` only) | `references/http.md` |
|
|
83
|
+
| **Channel** | A hand-designed WebSocket protocol with your own action routing | `references/channel.md` |
|
|
84
|
+
| **Realtime** | Typed pub/sub push — the scaffolded `/events` channel and SSE topics | `references/realtime.md` |
|
|
85
|
+
| **RPC** | One function calling another, or dispatching a name from outside | `references/rpc.md` |
|
|
86
|
+
| **Queue** | Reliable background work that must survive a crash and retry | `references/queue.md` |
|
|
87
|
+
| **Scheduler** | Recurring work on a cron expression | `references/scheduler.md` |
|
|
88
|
+
| **Trigger** | Reacting in-process to an external event source (Redis pub/sub, PG LISTEN) | `references/trigger.md` |
|
|
89
|
+
| **MCP** | Exposing functions to an AI assistant as tools, resources or prompts | `references/mcp.md` |
|
|
90
|
+
| **CLI** | A terminal program with commands, subcommands and options | `references/cli.md` |
|
|
91
|
+
| **Gateway** | An inbound integration from a third-party product — Slack is the shipped adapter | `references/gateway-slack.md` |
|
|
92
|
+
|
|
93
|
+
Realtime and Channel are the pair most often confused. If the shape is "server
|
|
94
|
+
pushes typed events to subscribers", use Realtime — `pikku enable events`
|
|
95
|
+
generates the channel, the SSE route and the cleanup for you. Reach for Channel
|
|
96
|
+
only when the client also sends structured messages you need to route on.
|
|
97
|
+
|
|
98
|
+
## What differs, and where it bites
|
|
99
|
+
|
|
100
|
+
### Each wiring demands a particular function type
|
|
101
|
+
|
|
102
|
+
| Wiring | Function type | Why |
|
|
103
|
+
| --- | --- | --- |
|
|
104
|
+
| HTTP, Channel, Queue, CLI, MCP | `pikkuFunc` / `pikkuSessionlessFunc` | Ordinary request/response |
|
|
105
|
+
| Scheduler | **`pikkuVoidFunc`** | A cron has no input and no caller to return to |
|
|
106
|
+
| Trigger *source* | **`pikkuTriggerFunc`** | Runs **once at startup**, not once per event |
|
|
107
|
+
|
|
108
|
+
A trigger source is the one that surprises people: it sets up a listener, calls
|
|
109
|
+
`trigger.invoke(...)` per event, and returns a teardown function. It receives
|
|
110
|
+
**singleton services only** — no session, no request, no per-wire services,
|
|
111
|
+
because the listener outlives every event it emits.
|
|
112
|
+
|
|
113
|
+
### Where a session comes from is not uniform
|
|
114
|
+
|
|
115
|
+
An HTTP or channel caller arrives with credentials and middleware mints a
|
|
116
|
+
session. Nothing else does.
|
|
117
|
+
|
|
118
|
+
- **A cron runs with no session at all.** It cannot invoke a permission- or
|
|
119
|
+
scope-gated RPC, and nothing it writes can be attributed. A scheduled task is a
|
|
120
|
+
machine principal — give it one in the task's own `middleware`, exactly as a
|
|
121
|
+
bearer-authenticated caller gets one. See the machine-auth section of
|
|
122
|
+
`pikku-middleware`.
|
|
123
|
+
- **A queue worker and a trigger handler are the same case.** Whatever identity
|
|
124
|
+
they need is minted in middleware, not inherited.
|
|
125
|
+
- **A channel authenticates per action.** `setSession` is on the wire, and an
|
|
126
|
+
`auth: false` action (conventionally `authenticate`) is how the session is
|
|
127
|
+
established mid-connection.
|
|
128
|
+
- **`auth` on `wireCLI` guards only the generated websocket channel.** A locally
|
|
129
|
+
executed CLI has no connection to authenticate, so it is not a way to require a
|
|
130
|
+
session for local runs.
|
|
131
|
+
|
|
132
|
+
### Some control-flow calls throw instead of returning
|
|
133
|
+
|
|
134
|
+
`wire.scheduledTask.skip(reason)` and `wire.queue.discard(reason)` both read like
|
|
135
|
+
an early return and are not — they throw, so nothing after the call runs and no
|
|
136
|
+
`return` is needed. The consequence lands in middleware: a `try/catch` around
|
|
137
|
+
`await next()` catches a skip or a discard and reports it as a failure. If your
|
|
138
|
+
middleware distinguishes success from failure, let those pass through rather than
|
|
139
|
+
logging them as errors.
|
|
140
|
+
|
|
141
|
+
### Delivery semantics differ, and that is usually the real choice
|
|
142
|
+
|
|
143
|
+
| Wiring | Delivery | Runs where |
|
|
144
|
+
| --- | --- | --- |
|
|
145
|
+
| Trigger | **At-most-once**, synchronous | In-process, alongside the listener |
|
|
146
|
+
| Queue | **At-least-once** with retries and a dead-letter queue | Distributed workers |
|
|
147
|
+
| Scheduler | Depends on the runtime — see below | Wherever the scheduler service runs |
|
|
148
|
+
|
|
149
|
+
Reach for a trigger to react immediately, and a queue when the work must not be
|
|
150
|
+
lost. A trigger that must not drop events is a queue with extra steps.
|
|
151
|
+
|
|
152
|
+
Scheduled tasks are the trap: on serverless runtimes the same `wireScheduler`
|
|
153
|
+
declaration behaves three different ways, and the deployment unit rather than the
|
|
154
|
+
cron expression can decide which tasks fire. `pikku-deploy` has the comparison.
|
|
155
|
+
|
|
156
|
+
### Codegen owns several wirings — do not hand-write them
|
|
157
|
+
|
|
158
|
+
| Turn it on | Codegen writes | Never hand-write |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| `pikku enable rpc` | `rpc-public.gen.ts` — the `POST /rpc/:rpcName` route | A second route on the same path collides |
|
|
161
|
+
| `pikku enable events` | `events.gen.ts` — the `/events` channel and `GET /events/:topic` | A hand-rolled `/events` misses disconnect cleanup |
|
|
162
|
+
| `wireCLI` | `<program>-channel.gen.ts` — the same commands over a channel | It is regenerated on every build |
|
|
163
|
+
|
|
164
|
+
Enabling the RPC endpoint says the endpoint exists, not who may call it — each
|
|
165
|
+
`expose: true` function is still gated by its own `auth`, permissions and scopes.
|
|
166
|
+
|
|
167
|
+
## What NOT to do
|
|
168
|
+
|
|
169
|
+
- Do not import a wiring factory from `@pikku/core/*`. It compiles and silently
|
|
170
|
+
drops your project's types; use the `#pikku/*` entrypoint.
|
|
171
|
+
- Do not put `permissions` on a wiring. They were removed in #972 and belong on
|
|
172
|
+
the function.
|
|
173
|
+
- Do not declare input or output types on a wiring — they come from the
|
|
174
|
+
function's schemas.
|
|
175
|
+
- Do not `return` after `skip()` or `discard()`, and do not let middleware
|
|
176
|
+
report them as failures.
|
|
177
|
+
- Do not hand-write `/rpc/:rpcName`, `/events`, or a CLI's channel file.
|
|
178
|
+
- Do not reach for a trigger when losing an event matters — use a queue.
|
|
179
|
+
- Do not put `sse: true` on anything but a `get`, or `query` on anything but a
|
|
180
|
+
`post`; the config union rejects both rather than failing at runtime.
|
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-websocket
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding real-time features, WebSocket channels, live updates, chat, or pub/sub to a
|
|
5
|
-
Pikku app. Covers wireChannel, action routing, auth, EventHub pub/sub, channel middleware, and
|
|
6
|
-
generated WebSocket client. TRIGGER when: code uses wireChannel, user asks about WebSocket,
|
|
7
|
-
real-time, live updates, chat, pub/sub, or the generated WebSocket client. DO NOT TRIGGER when:
|
|
8
|
-
user asks about HTTP/REST (use pikku-http), SSE (use pikku-http with sse: true), or WebSocket
|
|
9
|
-
deployment specifics (use pikku-deploy-uws), or typed pub/sub events (use pikku-realtime).
|
|
10
|
-
installGroups: [core]
|
|
11
|
-
---
|
|
12
|
-
|
|
13
1
|
# Pikku WebSocket Wiring
|
|
14
2
|
|
|
15
|
-
## Agent Operating Procedure
|
|
16
|
-
|
|
17
|
-
Use this skill as an execution checklist, not reference material.
|
|
18
|
-
|
|
19
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
20
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
21
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
22
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
23
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
24
|
-
|
|
25
|
-
Wire Pikku functions to WebSocket channels with structured message routing, auth per-action, pub/sub via EventHub, and auto-generated type-safe clients.
|
|
26
|
-
|
|
27
|
-
## Before You Start
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
pikku info functions --verbose # See existing functions and their types
|
|
31
|
-
pikku info tags --verbose # Understand project organization
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Follow existing patterns. See `pikku-concepts` for the core mental model.
|
|
35
|
-
|
|
36
3
|
## API Reference
|
|
37
4
|
|
|
38
5
|
### `wireChannel(config)`
|
|
39
6
|
|
|
40
7
|
```typescript
|
|
41
|
-
import { wireChannel } from '
|
|
8
|
+
import { wireChannel } from '#pikku/channel'
|
|
42
9
|
|
|
43
10
|
wireChannel({
|
|
44
11
|
name: string, // Channel name (e.g. 'todos')
|
|
@@ -66,7 +33,7 @@ wireChannel({
|
|
|
66
33
|
|
|
67
34
|
Note there is **no `permissions` key on a message wiring** — wire-level
|
|
68
35
|
permissions were removed in #972. Authorization lives on the function's own
|
|
69
|
-
`permissions` field (see `pikku-
|
|
36
|
+
`permissions` field (see `pikku-auth`).
|
|
70
37
|
|
|
71
38
|
### `pikkuChannelMiddleware(fn)`
|
|
72
39
|
|
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-cli
|
|
3
|
-
description: >-
|
|
4
|
-
Use when building CLI commands with Pikku. Covers wireCLI, pikkuCLICommand, subcommands,
|
|
5
|
-
options, parameters, custom renderers, and nested command groups. TRIGGER when: code uses
|
|
6
|
-
wireCLI/pikkuCLICommand, user asks about CLI commands, terminal tools, command-line interface,
|
|
7
|
-
or adding subcommands. DO NOT TRIGGER when: user asks about the pikku CLI tool itself (use
|
|
8
|
-
pikku-meta) or HTTP endpoints (use pikku-http).
|
|
9
|
-
installGroups: [core]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
1
|
# Pikku CLI Wiring
|
|
13
2
|
|
|
14
|
-
## Agent Operating Procedure
|
|
15
|
-
|
|
16
|
-
Use this skill as an execution checklist, not reference material.
|
|
17
|
-
|
|
18
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
19
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
20
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
21
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
22
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
23
|
-
|
|
24
|
-
Wire Pikku functions as CLI commands with parameters, options, subcommands, and custom terminal renderers.
|
|
25
|
-
|
|
26
|
-
## Before You Start
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
pikku info functions --verbose # See existing functions and their types
|
|
30
|
-
pikku info tags --verbose # Understand project organization
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
See `pikku-concepts` for the core mental model.
|
|
34
|
-
|
|
35
3
|
## API Reference
|
|
36
4
|
|
|
37
5
|
### `wireCLI(config)`
|
|
@@ -244,4 +212,4 @@ session for local runs. Don't hand-write or edit the generated channel file.
|
|
|
244
212
|
|
|
245
213
|
## Complete Example
|
|
246
214
|
|
|
247
|
-
For a full functions + renderers + nested-subcommand wiring walkthrough, see `
|
|
215
|
+
For a full functions + renderers + nested-subcommand wiring walkthrough, see `cli-complete-example.md`.
|
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-gateway-slack
|
|
3
|
-
description: >-
|
|
4
|
-
Use when integrating Slack with a Pikku app. Covers SlackGatewayAdapter, slash commands, OAuth
|
|
5
|
-
flow, message handling, and signature verification. TRIGGER when: code uses SlackGatewayAdapter,
|
|
6
|
-
parseSlashCommand, buildSlackInstallUrl, or user asks about Slack integration, Slack bots, or
|
|
7
|
-
@pikku/gateway-slack. DO NOT TRIGGER when: user asks about general gateway/webhook patterns (use
|
|
8
|
-
pikku-trigger).
|
|
9
|
-
installGroups: [core]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
1
|
# Pikku Gateway Slack
|
|
13
2
|
|
|
14
|
-
## Agent Operating Procedure
|
|
15
|
-
|
|
16
|
-
Use this skill as an execution checklist, not reference material.
|
|
17
|
-
|
|
18
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
19
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
20
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
21
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
22
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
23
|
-
|
|
24
|
-
`@pikku/gateway-slack` provides a Slack Events API gateway adapter, slash command handling, OAuth installation flow, and message utilities.
|
|
25
|
-
|
|
26
3
|
## Installation
|
|
27
4
|
|
|
28
5
|
```bash
|
|
@@ -1,41 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-http
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding HTTP routes, REST APIs, web endpoints, or SSE streams to a Pikku app. Covers
|
|
5
|
-
wireHTTP, defineHTTPRoutes, route groups, auth, middleware, SSE, and generated
|
|
6
|
-
fetch client. TRIGGER when: code uses wireHTTP/defineHTTPRoutes/wireHTTPRoutes, user asks about
|
|
7
|
-
REST endpoints, API routes, SSE, or the generated fetch client. DO NOT TRIGGER when: user asks
|
|
8
|
-
about WebSocket (use pikku-websocket), queue workers (use pikku-queue), or deployment (use
|
|
9
|
-
pikku-deploy-*).
|
|
10
|
-
installGroups: [core]
|
|
11
|
-
---
|
|
12
|
-
|
|
13
1
|
# Pikku HTTP Wiring
|
|
14
2
|
|
|
15
|
-
## Agent Operating Procedure
|
|
16
|
-
|
|
17
|
-
Use this skill as an execution checklist, not reference material.
|
|
18
|
-
|
|
19
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
20
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
21
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
22
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
23
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
24
|
-
|
|
25
|
-
Wire Pikku functions to HTTP endpoints. Supports single routes, composable route groups, auth, middleware, SSE, and auto-generated type-safe clients. (Authorization lives on the function, not the wiring — see `pikku-permissions`.)
|
|
26
|
-
|
|
27
|
-
## Before You Start
|
|
28
|
-
|
|
29
|
-
Run these commands to understand the current project:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pikku info functions --verbose # See existing functions, their types, tags, middleware
|
|
33
|
-
pikku info tags --verbose # Understand project organization and naming conventions
|
|
34
|
-
pikku info middleware --verbose # See what middleware is already applied
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Follow existing patterns you find (naming, tag usage, file organization). See `pikku-concepts` for the core mental model.
|
|
38
|
-
|
|
39
3
|
## API Reference
|
|
40
4
|
|
|
41
5
|
All three come from `#pikku/http` (the generated `.pikku/http/index.ts`), which
|
|
@@ -50,7 +14,7 @@ Function input/output types come from the function's own `input:`/`output:` zod
|
|
|
50
14
|
|
|
51
15
|
Config cascading across groups: `basePath` concatenates down the chain, `tags` merge (union), `auth` child overrides parent.
|
|
52
16
|
|
|
53
|
-
For the full option tables (every `wireHTTP` field, the `defineHTTPRoutes`/`wireHTTPRoutes` config shape), read `
|
|
17
|
+
For the full option tables (every `wireHTTP` field, the `defineHTTPRoutes`/`wireHTTPRoutes` config shape), read `http-options.md`.
|
|
54
18
|
|
|
55
19
|
### `addHTTPMiddleware(pattern, middlewares)`
|
|
56
20
|
|
|
@@ -59,7 +23,7 @@ addHTTPMiddleware('*', [authBearer()]) // All routes
|
|
|
59
23
|
addHTTPMiddleware('/api/*', [rateLimit()]) // Pattern match
|
|
60
24
|
```
|
|
61
25
|
|
|
62
|
-
> HTTP-route-level permissions (`addHTTPPermission`, a `permissions` field on the wiring) were removed in #972. Declare authorization on the function definition (`pikkuFunc({ permissions })`, see `pikku-
|
|
26
|
+
> HTTP-route-level permissions (`addHTTPPermission`, a `permissions` field on the wiring) were removed in #972. Declare authorization on the function definition (`pikkuFunc({ permissions })`, see `pikku-auth`), or app-wide via `addGlobalPermission`. Tags/patterns are for _middleware_ only now.
|
|
63
27
|
|
|
64
28
|
## Data Flow
|
|
65
29
|
|
|
@@ -122,7 +86,7 @@ wireHTTP({ method: 'get', route: '/books', func: listBooks, auth: false })
|
|
|
122
86
|
wireHTTP({ method: 'delete', route: '/books/:bookId', func: deleteBook })
|
|
123
87
|
```
|
|
124
88
|
|
|
125
|
-
Authorization is not a wiring concern — declare it on the function via `permissions` (see `pikku-
|
|
89
|
+
Authorization is not a wiring concern — declare it on the function via `permissions` (see `pikku-auth`), or app-wide via `addGlobalPermission`.
|
|
126
90
|
|
|
127
91
|
### Middleware
|
|
128
92
|
|
|
@@ -226,7 +190,7 @@ export const getBook = pikkuFunc({
|
|
|
226
190
|
})
|
|
227
191
|
|
|
228
192
|
// wirings/books.http.ts — same defineHTTPRoutes/wireHTTPRoutes shape as the Route Groups example above
|
|
229
|
-
import { addHTTPMiddleware } from '#pikku/
|
|
193
|
+
import { addHTTPMiddleware } from '#pikku/middleware'
|
|
230
194
|
import { cors, authBearer } from '@pikku/core/middleware'
|
|
231
195
|
|
|
232
196
|
addHTTPMiddleware('*', [cors(), authBearer()])
|
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-mcp
|
|
3
|
-
description: >-
|
|
4
|
-
Use when exposing Pikku functions as MCP tools, resources, or prompts for AI assistants. Covers
|
|
5
|
-
mcp: true, pikkuMCPToolFunc, pikkuMCPResourceFunc, pikkuMCPPromptFunc, wireMCPResource,
|
|
6
|
-
wireMCPPrompt, the MCP wire object and PikkuMCPServer. TRIGGER when: code uses mcp: true or any
|
|
7
|
-
pikkuMCP*Func/wireMCP* helper, user asks about MCP, Model Context Protocol, AI tool integration,
|
|
8
|
-
or exposing functions to Claude/ChatGPT. DO NOT TRIGGER when: user asks about AI agents (use
|
|
9
|
-
pikku-agent) or general function definitions (use pikku-concepts).
|
|
10
|
-
installGroups: [core]
|
|
11
|
-
---
|
|
12
|
-
|
|
13
1
|
# Pikku MCP Wiring
|
|
14
2
|
|
|
15
|
-
## Agent Operating Procedure
|
|
16
|
-
|
|
17
|
-
Use this skill as an execution checklist, not reference material.
|
|
18
|
-
|
|
19
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
20
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
21
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
22
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
23
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
24
|
-
|
|
25
|
-
Expose Pikku functions as Model Context Protocol (MCP) tools, resources, and prompts for AI assistants like Claude, ChatGPT, and others.
|
|
26
|
-
|
|
27
|
-
## Before You Start
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
pikku info functions --verbose # See existing functions that could become MCP tools
|
|
31
|
-
pikku info tags --verbose # Understand project organization
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
See `pikku-concepts` for the core mental model.
|
|
35
|
-
|
|
36
3
|
## The shape of MCP in Pikku
|
|
37
4
|
|
|
38
5
|
MCP has three surfaces, and Pikku wires them differently:
|
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-queue
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding background job processing, async task queues, or distributed workers to a Pikku
|
|
5
|
-
app. Covers wireQueueWorker, job enqueuing, progress tracking, retries, BullMQ and PgBoss
|
|
6
|
-
adapters. TRIGGER when: code uses wireQueueWorker, user asks about background jobs, task queues,
|
|
7
|
-
async processing, BullMQ, PgBoss, or job retries. DO NOT TRIGGER when: user asks about scheduled
|
|
8
|
-
cron tasks (use pikku-schedule) or event-driven triggers (use pikku-trigger).
|
|
9
|
-
installGroups: [core]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
1
|
# Pikku Queue Wiring
|
|
13
2
|
|
|
14
|
-
## Agent Operating Procedure
|
|
15
|
-
|
|
16
|
-
Use this skill as an execution checklist, not reference material.
|
|
17
|
-
|
|
18
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
19
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
20
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
21
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
22
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
23
|
-
|
|
24
|
-
Wire Pikku functions as background queue workers. Supports job control (progress, retry, discard), configurable concurrency, and type-safe job publishing.
|
|
25
|
-
|
|
26
|
-
## Before You Start
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
pikku info functions --verbose # See existing functions and their types
|
|
30
|
-
pikku info tags --verbose # Understand project organization
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
See `pikku-concepts` for the core mental model.
|
|
34
|
-
|
|
35
3
|
## API Reference
|
|
36
4
|
|
|
37
5
|
### `wireQueueWorker(config)`
|
|
38
6
|
|
|
39
7
|
```typescript
|
|
40
|
-
import { wireQueueWorker } from '
|
|
8
|
+
import { wireQueueWorker } from '#pikku/queue'
|
|
41
9
|
|
|
42
10
|
wireQueueWorker({
|
|
43
11
|
name: string, // Queue name (unique identifier)
|
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-realtime
|
|
3
|
-
description: 'Use Pikku''s realtime feature — typed pub/sub events over WebSocket (multi-topic) or SSE (single-topic, auto-cleanup). Covers declaring EventHubTopics, scaffolding the /events channel, the auto-generated `PikkuRealtime` client, and publishing events from a function. TRIGGER when: the user asks for realtime updates, pub/sub, push notifications, server-sent events, websocket events, eventhub, or "live" data on the frontend. DO NOT TRIGGER when: the user wants RPC-style request/response (use pikku-rpc / pikku-react-query) or a custom one-off WebSocket channel (use pikku-websocket).'
|
|
4
|
-
---
|
|
5
|
-
|
|
6
1
|
# Pikku Realtime
|
|
7
2
|
|
|
8
|
-
## Agent Operating Procedure
|
|
9
|
-
|
|
10
|
-
Use this skill as an execution checklist, not reference material.
|
|
11
|
-
|
|
12
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
13
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
14
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
15
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
16
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
17
|
-
|
|
18
|
-
Most realtime UI is just typed pub/sub: a server pushes `todo-created`, the client
|
|
19
|
-
renders it. Pikku ships exactly that, two ways — both use the same `EventHubService`
|
|
20
|
-
and the same publish call, so choose by transport, not by code shape:
|
|
21
|
-
|
|
22
|
-
- **WebSocket** at `/events` — one connection, many topic subscriptions.
|
|
23
|
-
- **SSE** at `GET /events/:topic` — one connection per topic, auto-cleanup on
|
|
24
|
-
disconnect. Good when WebSocket is blocked or for trivially streaming one topic.
|
|
25
|
-
|
|
26
3
|
## 1. Declare your topics
|
|
27
4
|
|
|
28
5
|
In your project's types file (e.g. `types/eventhub-topics.d.ts`):
|
|
@@ -118,7 +95,7 @@ export class PikkuRealtime {
|
|
|
118
95
|
handler: (data: EventHubTopics[K]) => void
|
|
119
96
|
): { close: () => void }
|
|
120
97
|
|
|
121
|
-
// generic escape hatches — see
|
|
98
|
+
// generic escape hatches — see realtime-other-routes.md
|
|
122
99
|
subscribeToSSE<T>(
|
|
123
100
|
path: string,
|
|
124
101
|
handler: (data: T) => void
|
|
@@ -261,7 +238,7 @@ function TodoList() {
|
|
|
261
238
|
|
|
262
239
|
The same client also subscribes to generic `sse: true` routes and raw `wireChannel`
|
|
263
240
|
sockets (`subscribeToSSE`, `connectToChannel`). See
|
|
264
|
-
[
|
|
241
|
+
[realtime-other-routes.md](realtime-other-routes.md).
|
|
265
242
|
|
|
266
243
|
## When to pick which transport
|
|
267
244
|
|
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-rpc
|
|
3
|
-
description: >-
|
|
4
|
-
Use when making internal function-to-function calls within a Pikku app, composing functions, or
|
|
5
|
-
exposing RPC endpoints. Covers rpc.invoke, rpc.remote, rpc.exposed, and generated RPC client.
|
|
6
|
-
TRIGGER when: code uses wire.rpc or expose: true, user asks about calling one Pikku function
|
|
7
|
-
from another, function composition, or RPC endpoints. DO NOT TRIGGER when: user asks about HTTP
|
|
8
|
-
routes (use pikku-http) or addon cross-package calls (use pikku-addon).
|
|
9
|
-
installGroups: [fabric]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
1
|
# Pikku RPC Wiring
|
|
13
2
|
|
|
14
|
-
## Agent Operating Procedure
|
|
15
|
-
|
|
16
|
-
Use this skill as an execution checklist, not reference material.
|
|
17
|
-
|
|
18
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
19
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
20
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
21
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
22
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
23
|
-
|
|
24
|
-
Call Pikku functions from other Pikku functions internally with full type safety. Use RPC to compose business logic without importing functions directly.
|
|
25
|
-
|
|
26
|
-
## Before You Start
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
pikku info functions --verbose # See existing functions and which could be called via RPC
|
|
30
|
-
pikku info tags --verbose # Understand project organization
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
See `pikku-concepts` for the core mental model.
|
|
34
|
-
|
|
35
3
|
## API Reference
|
|
36
4
|
|
|
37
5
|
### RPC Methods (on `wire.rpc`)
|
|
@@ -1,45 +1,11 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-schedule
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding scheduled tasks, recurring jobs, or cron-based automation to a Pikku app. Covers
|
|
5
|
-
wireScheduler, cron expressions, the scheduled task wire object, and scheduler middleware.
|
|
6
|
-
TRIGGER when: code uses wireScheduler, user asks about cron, scheduled tasks, recurring jobs, or
|
|
7
|
-
"run every X minutes/hours". DO NOT TRIGGER when: user asks about background jobs with retries
|
|
8
|
-
(use pikku-queue) or event-driven triggers (use pikku-trigger).
|
|
9
|
-
installGroups: [core]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
1
|
# Pikku Scheduled Tasks
|
|
13
2
|
|
|
14
|
-
## Agent Operating Procedure
|
|
15
|
-
|
|
16
|
-
Use this skill as an execution checklist, not reference material.
|
|
17
|
-
|
|
18
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
19
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
20
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
21
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
22
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
23
|
-
|
|
24
|
-
Wire Pikku functions to run on a schedule using cron expressions. Uses `pikkuVoidFunc` (no input/output).
|
|
25
|
-
|
|
26
|
-
`pikku dev`, `pikku serve` and the standalone deploy adapter each register a scheduler service for you, so a wired task runs without any setup. Only register one yourself when deploying somewhere those do not reach, and then take it off the queue factory (`bullFactory.getSchedulerService()`, `pgBossFactory.getSchedulerService()` — see `pikku-queue`) so it survives a restart and is shared between instances.
|
|
27
|
-
|
|
28
|
-
## Before You Start
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
pikku info functions --verbose # See existing functions and their types
|
|
32
|
-
pikku info tags --verbose # Understand project organization
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
See `pikku-concepts` for the core mental model.
|
|
36
|
-
|
|
37
3
|
## API Reference
|
|
38
4
|
|
|
39
5
|
### `wireScheduler(config)`
|
|
40
6
|
|
|
41
7
|
```typescript
|
|
42
|
-
import { wireScheduler } from '
|
|
8
|
+
import { wireScheduler } from '#pikku/scheduler'
|
|
43
9
|
|
|
44
10
|
wireScheduler({
|
|
45
11
|
name: string, // Unique scheduler name
|
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-trigger
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding event-driven functions that respond to system events like Redis pub/sub,
|
|
5
|
-
PostgreSQL LISTEN/NOTIFY, or custom event sources. Covers wireTrigger, wireTriggerSource, and
|
|
6
|
-
pikkuTriggerFunc. TRIGGER when: code uses wireTrigger/wireTriggerSource/pikkuTriggerFunc, user
|
|
7
|
-
asks about event-driven functions, Redis pub/sub, PostgreSQL LISTEN/NOTIFY, or reacting to
|
|
8
|
-
external events. DO NOT TRIGGER when: user asks about scheduled tasks (use pikku-schedule) or
|
|
9
|
-
background job queues (use pikku-queue).
|
|
10
|
-
installGroups: [core]
|
|
11
|
-
---
|
|
12
|
-
|
|
13
1
|
# Pikku Trigger Wiring
|
|
14
2
|
|
|
15
|
-
## Agent Operating Procedure
|
|
16
|
-
|
|
17
|
-
Use this skill as an execution checklist, not reference material.
|
|
18
|
-
|
|
19
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
20
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
21
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
22
|
-
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
23
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
24
|
-
|
|
25
|
-
Wire Pikku functions to fire when external events occur. Triggers connect event sources (Redis pub/sub, PostgreSQL LISTEN/NOTIFY, polling, webhooks) to Pikku functions.
|
|
26
|
-
|
|
27
|
-
## Before You Start
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
pikku info functions --verbose # See existing functions and their types
|
|
31
|
-
pikku info tags --verbose # Understand project organization
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
See `pikku-concepts` for the core mental model.
|
|
35
|
-
|
|
36
3
|
## API Reference
|
|
37
4
|
|
|
38
5
|
All three come from `#pikku`. A trigger is deliberately split in two: the
|
|
@@ -172,16 +139,6 @@ wireTriggerSource({
|
|
|
172
139
|
})
|
|
173
140
|
```
|
|
174
141
|
|
|
175
|
-
### Triggers vs Queues
|
|
176
|
-
|
|
177
|
-
| Feature | Trigger | Queue |
|
|
178
|
-
| ----------- | ---------------------------------- | ------------------------------ |
|
|
179
|
-
| Execution | Synchronous, in-process | Async, distributed |
|
|
180
|
-
| Reliability | At-most-once | At-least-once (with retries) |
|
|
181
|
-
| Use case | React to events immediately | Reliable background processing |
|
|
182
|
-
| Source | External systems (Redis, PG, etc.) | Enqueued programmatically |
|
|
183
|
-
|
|
184
|
-
Use triggers for real-time reactions. Use queues for reliable, retryable background work.
|
|
185
142
|
|
|
186
143
|
## Complete Example
|
|
187
144
|
|