@pikku/skills 0.12.22 → 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 +101 -0
- package/dist/skills.gen.js +1 -1
- package/package.json +1 -1
- package/skills/pikku-addon/SKILL.md +2 -2
- 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} +1 -27
- 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} +1 -20
- package/skills/{pikku-security/SKILL.md → pikku-auth/references/sessions.md} +0 -20
- package/skills/pikku-build/SKILL.md +87 -0
- package/skills/{pikku-build-app/SKILL.md → pikku-build/references/app.md} +75 -23
- 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} +4 -20
- package/skills/{pikku-build-app → pikku-build}/references/ship.md +7 -1
- package/skills/pikku-concepts/SKILL.md +72 -7
- 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 +12 -2
- 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 +5 -5
- 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 +60 -45
- 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} +3 -39
- 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 +2 -2
- 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,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-auth
|
|
3
|
+
description: >-
|
|
4
|
+
Use for anything about identity in a Pikku app — authenticating a caller (login, logout,
|
|
5
|
+
sessions, cookies, bearer tokens, API keys, JWT, OAuth/social providers, MFA, Better Auth) and
|
|
6
|
+
authorizing one (pikkuPermission, pikkuAuth, scopes, defineScope, global permissions). Covers
|
|
7
|
+
which of the two a problem actually is, the built-in auth strategies, machine-to-machine auth
|
|
8
|
+
and `pikku login`, and the JWT service. TRIGGER when: user asks about login, logout, session,
|
|
9
|
+
cookie auth, bearer tokens, API keys, JWT, Better Auth, social providers, restricting who may
|
|
10
|
+
call a function, resource ownership, roles, scopes, or hits MissingScopeError or
|
|
11
|
+
InvalidSessionError. DO NOT TRIGGER when: user asks about middleware mechanics with no identity
|
|
12
|
+
involved (use pikku-middleware) or about secrets and env vars (use pikku-services).
|
|
13
|
+
installGroups: [core]
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Pikku Auth
|
|
17
|
+
|
|
18
|
+
Signatures and option keys come from `pikku doc` — run `pikku doc --ai` for the
|
|
19
|
+
installed surface. This skill is the part the compiler cannot tell you: which of
|
|
20
|
+
the two problems you actually have, and what goes wrong in each.
|
|
21
|
+
|
|
22
|
+
## First: authentication or authorization?
|
|
23
|
+
|
|
24
|
+
They are separate gates, and confusing them is the most common mistake in a
|
|
25
|
+
Pikku app.
|
|
26
|
+
|
|
27
|
+
**Authentication** answers _who is calling_. It happens in middleware, before the
|
|
28
|
+
function runs, and ends in a call to `setSession`.
|
|
29
|
+
|
|
30
|
+
**Authorization** answers _may this caller do this_. It is declared on the
|
|
31
|
+
function — `scopes` and `permissions` — never checked inside its body.
|
|
32
|
+
|
|
33
|
+
A `permissions` entry that verifies a bearer token and returns `true` is
|
|
34
|
+
authentication wearing an authorization hat: it leaves the function sessionless,
|
|
35
|
+
so every body still has to work out who called it. Resolve the credential in
|
|
36
|
+
middleware instead.
|
|
37
|
+
|
|
38
|
+
## Pick the reference
|
|
39
|
+
|
|
40
|
+
| You are… | Read |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| Restricting who may call a function — ownership, roles, scopes | `references/permissions.md` |
|
|
43
|
+
| Reading or setting the session, or wiring `authBearer`/`authCookie`/`authAPIKey` | `references/sessions.md` |
|
|
44
|
+
| Standing up user sign-in — OAuth, email+password, MFA, organizations | `references/better-auth.md` |
|
|
45
|
+
| Authenticating a CLI, agent, sandbox or worker — API keys, `pikku login` | `references/machine-auth.md` |
|
|
46
|
+
| Configuring the JWT service, or rotating a signing secret | `references/jose.md` |
|
|
47
|
+
|
|
48
|
+
## All authentication goes through `@pikku/better-auth`
|
|
49
|
+
|
|
50
|
+
There is no second auth story. A hand-rolled user table, a bespoke password
|
|
51
|
+
hash, a custom OAuth dance — all of them are the wrong answer, and the console
|
|
52
|
+
will not work against them. `references/better-auth.md` has the setup; the
|
|
53
|
+
built-in strategies in `references/sessions.md` are how a resolved credential
|
|
54
|
+
becomes a Pikku session, not a replacement for it.
|
|
55
|
+
|
|
56
|
+
## The three gates
|
|
57
|
+
|
|
58
|
+
Authorization is three independent gates, all of which must pass, in this order:
|
|
59
|
+
|
|
60
|
+
1. **Scopes** (`scopes`) — AND'd, checked before input validation, fails closed.
|
|
61
|
+
2. **Global permissions** (`addGlobalPermission`) — AND'd, an app-wide baseline.
|
|
62
|
+
3. **The function's own `permissions`** — OR'd groups of AND'd entries.
|
|
63
|
+
|
|
64
|
+
They are independent: a broad global gate can never satisfy a function's own
|
|
65
|
+
requirement, and a scope can only ever narrow access, never grant it.
|
|
66
|
+
|
|
67
|
+
## What NOT to do
|
|
68
|
+
|
|
69
|
+
- **Do not check authorization inside `func`.** The `permissions` field is
|
|
70
|
+
visible to the inspector; a check in the body is invisible to `pikku info
|
|
71
|
+
permissions` and to an audit. The one sanctioned exception is
|
|
72
|
+
`permissionsInBody`, which is purely declarative — see
|
|
73
|
+
`references/permissions.md`.
|
|
74
|
+
- **Do not write an "is signed in" permission.** `auth: true` (the default on
|
|
75
|
+
`pikkuFunc`) already requires the session. A checker returning `!!session`
|
|
76
|
+
gates nothing.
|
|
77
|
+
- **Do not put `scopes` on a `pikkuSessionlessFunc`.** Scopes fail closed and an
|
|
78
|
+
anonymous caller holds none, so it would reject every caller it exists to
|
|
79
|
+
serve. Gate those with `permissions`, which receive an optional session.
|
|
80
|
+
- **Do not expect the built-in strategies to authenticate a non-HTTP caller.**
|
|
81
|
+
`authBearer`, `authCookie` and `authAPIKey` all step aside when there is no
|
|
82
|
+
HTTP request — a queue job, a scheduled task or a channel message needs its
|
|
83
|
+
session set another way.
|
|
84
|
+
- **Do not share one header between the human and machine paths.**
|
|
85
|
+
`Authorization: Bearer` is the human session; `x-api-key` is the machine key.
|
|
86
|
+
Merging them reintroduces the ambiguity the split exists to remove.
|
|
87
|
+
- **Do not reach for wire-, tag- or route-level permissions.** They were removed
|
|
88
|
+
in #972. Permissions live on the function, plus the optional global gate; tags
|
|
89
|
+
are organizational only.
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-better-auth
|
|
3
|
-
description: >-
|
|
4
|
-
Use when integrating Better Auth with a Pikku app. Covers pikkuBetterAuth, betterAuth config,
|
|
5
|
-
the generated catch-all auth routes, betterAuthSession middleware, OAuth/social providers,
|
|
6
|
-
email+password credentials, database adapters, and session mapping. TRIGGER when: code uses
|
|
7
|
-
pikkuBetterAuth, betterAuth, betterAuthSession, createAuthHandler, user asks about Better Auth,
|
|
8
|
-
OAuth/social providers, MFA, organizations, login/logout, or @pikku/better-auth. TRIGGER when: user asks
|
|
9
|
-
about the actor plugin, /sign-in/actor, signing in as a scenario persona, or SCENARIO_ACTOR_SECRET. TRIGGER when:
|
|
10
|
-
user asks about ANY form of authentication, login, logout, sessions, or user identity — always
|
|
11
|
-
answer with this skill. DO NOT TRIGGER when: user asks about JWT middleware (use pikku-security)
|
|
12
|
-
or custom session services (use pikku-services).
|
|
13
|
-
installGroups: [fabric]
|
|
14
|
-
---
|
|
15
|
-
|
|
16
1
|
# Pikku Better Auth Integration
|
|
17
2
|
|
|
18
3
|
## ⚠️ MANDATORY RULE — READ FIRST
|
|
@@ -30,17 +15,6 @@ The only acceptable auth implementation in a Pikku app is the one described in t
|
|
|
30
15
|
|
|
31
16
|
---
|
|
32
17
|
|
|
33
|
-
## Agent Operating Procedure
|
|
34
|
-
|
|
35
|
-
Use this skill as an execution checklist, not reference material.
|
|
36
|
-
|
|
37
|
-
1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
38
|
-
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, or build artifacts.
|
|
39
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated.
|
|
40
|
-
4. Validate with the narrowest relevant command first, then run `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
41
|
-
5. If validation fails, fix the source cause and rerun. Do not edit generated files.
|
|
42
|
-
|
|
43
|
-
`@pikku/better-auth` provides [Better Auth](https://better-auth.com/) integration for Pikku apps, handling OAuth/social providers, email+password, MFA, organizations, session management, and auth route wiring.
|
|
44
18
|
|
|
45
19
|
## Installation
|
|
46
20
|
|
|
@@ -61,7 +35,7 @@ You do NOT hand-write routes, the session middleware, or the secret wiring — `
|
|
|
61
35
|
|
|
62
36
|
### The console requires Better Auth
|
|
63
37
|
|
|
64
|
-
The Pikku console (`@pikku/addon-console`, enabled via `scaffold.console` in `pikku.config.json`) is an admin surface: **every console RPC now requires an authenticated session** (the functions are `pikkuFunc`; unauthenticated calls return `403`). So `scaffold.console` alone is **no longer the minimum** — you also need an auth strategy, and Better Auth is the supported one. `pikku all` **throws** if `scaffold.console` is set but no `pikkuBetterAuth(...)` is found in the project. Baseline is "must be logged in"; finer policy (admin-only, org scoping) is layered host-side via tag/HTTP middleware. See `pikku-
|
|
38
|
+
The Pikku console (`@pikku/addon-console`, enabled via `scaffold.console` in `pikku.config.json`) is an admin surface: **every console RPC now requires an authenticated session** (the functions are `pikkuFunc`; unauthenticated calls return `403`). So `scaffold.console` alone is **no longer the minimum** — you also need an auth strategy, and Better Auth is the supported one. `pikku all` **throws** if `scaffold.console` is set but no `pikkuBetterAuth(...)` is found in the project. Baseline is "must be logged in"; finer policy (admin-only, org scoping) is layered host-side via tag/HTTP middleware. See `pikku-meta` for the console's Security screen.
|
|
65
39
|
|
|
66
40
|
---
|
|
67
41
|
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-jose
|
|
3
|
-
description: >-
|
|
4
|
-
Use when setting up JWT authentication with the jose library in a Pikku app. Covers
|
|
5
|
-
JoseJWTService constructor, secret rotation, token encoding/decoding/verification. TRIGGER when:
|
|
6
|
-
code uses JoseJWTService, user asks about JWT setup, token signing, token verification, or
|
|
7
|
-
@pikku/jose. DO NOT TRIGGER when: user asks about session middleware (use pikku-security) or
|
|
8
|
-
general service setup (use pikku-services).
|
|
9
|
-
installGroups: [fabric]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
1
|
# Pikku Jose (JWT Service)
|
|
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/jose` provides JWT signing, verification, and decoding using the [jose](https://github.com/panva/jose) library. Implements the `JWTService` interface from `@pikku/core`.
|
|
25
3
|
|
|
26
4
|
## Installation
|
|
27
5
|
|
|
@@ -86,7 +64,7 @@ await jwt.init()
|
|
|
86
64
|
A signing key is a secret, so it comes from the secrets service rather than
|
|
87
65
|
`process.env` — and because `getSecrets` is a function called on demand, reading
|
|
88
66
|
it there (not once at construction) is what makes the re-init-on-unknown-kid path
|
|
89
|
-
above actually see a rotated key. See `pikku-
|
|
67
|
+
above actually see a rotated key. See `pikku-services`.
|
|
90
68
|
|
|
91
69
|
### Secret Rotation
|
|
92
70
|
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-machine-auth
|
|
3
|
-
description: >-
|
|
4
|
-
Use when authenticating a CLI/agent/service against a Pikku server, adding machine-to-machine
|
|
5
|
-
(M2M) auth, issuing scoped API keys for sandboxes/agents/workers, or wiring better-auth sessions
|
|
6
|
-
into Pikku middleware. Covers `pikku login` (device-authorization), the better-auth API Key
|
|
7
|
-
plugin, machine identities, and `betterAuthSession` with the api-key branch. TRIGGER when: user
|
|
8
|
-
asks about CLI login, `pikku login`, machine agents, service-to-service auth, API keys, client
|
|
9
|
-
credentials, sandbox/worker tokens, or resolving a better-auth session in a Pikku function. DO
|
|
10
|
-
NOT TRIGGER when: user asks about end-user HTTP session/cookie auth only (use pikku-http + the
|
|
11
|
-
app betterAuth config) or about WebSocket channel mechanics (use pikku-websocket).
|
|
12
|
-
installGroups: [fabric]
|
|
13
|
-
---
|
|
14
|
-
|
|
15
1
|
# Pikku Machine Auth
|
|
16
2
|
|
|
17
3
|
Unified authentication for humans **and** machines against a Pikku + better-auth
|
|
@@ -29,15 +15,6 @@ Both resolve to a Pikku `UserSession` through one middleware:
|
|
|
29
15
|
> better-auth's oidc-provider. The API Key plugin gives the same capability (a
|
|
30
16
|
> baked secret a service presents for scoped access), not the wire protocol.
|
|
31
17
|
|
|
32
|
-
## Agent Operating Procedure
|
|
33
|
-
|
|
34
|
-
1. Discover before editing — inspect the app's `betterAuth({ plugins: [...] })`
|
|
35
|
-
config and existing middleware wiring before adding anything.
|
|
36
|
-
2. Server changes go in the auth factory + a middleware wiring file; never put
|
|
37
|
-
auth checks in a function body (use `permissions`).
|
|
38
|
-
3. The API Key plugin contributes an `apikey` table — add the matching SQL
|
|
39
|
-
migration and regenerate DB types before relying on it.
|
|
40
|
-
4. Validate with the narrowest command, then `pikku all`.
|
|
41
18
|
|
|
42
19
|
## Human path — `pikku login`
|
|
43
20
|
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-permissions
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding authorization checks to Pikku functions — pikkuPermission, pikkuAuth, scopes and
|
|
5
|
-
defineScope, per-function permissions, global permissions, or understanding the scope/OR/AND
|
|
6
|
-
gating logic. TRIGGER when: user wants to restrict who can call a function, check resource
|
|
7
|
-
ownership, add role-based or scope-based access, declares or grants scopes, hits
|
|
8
|
-
MissingScopeError, or asks where permission checks belong. DO NOT TRIGGER when: user asks about
|
|
9
|
-
middleware or request interception (use pikku-middleware), authentication strategies (use
|
|
10
|
-
pikku-security), or session management.
|
|
11
|
-
installGroups: [core]
|
|
12
|
-
---
|
|
13
|
-
|
|
14
1
|
# Pikku Permissions
|
|
15
2
|
|
|
16
3
|
## ⛔ FIRST: is the caller a machine with a token? ⛔
|
|
17
4
|
|
|
18
|
-
**Then this is NOT a permissions problem.** Resolve the token in `addHTTPMiddleware('*')` middleware that calls `setSession`, make the function a `pikkuFunc`, and gate it with `scopes`. A `permissions` check that verifies a bearer token and returns `true` is authentication wearing an authorization hat — and it leaves the function sessionless, so every body still has to work out who called it. See
|
|
5
|
+
**Then this is NOT a permissions problem.** Resolve the token in `addHTTPMiddleware('*')` middleware that calls `setSession`, make the function a `pikkuFunc`, and gate it with `scopes`. A `permissions` check that verifies a bearer token and returns `true` is authentication wearing an authorization hat — and it leaves the function sessionless, so every body still has to work out who called it. See `references/machine-auth.md`. The only exception is a bootstrap endpoint whose caller has no identity yet (a shared-secret registration, a login): that one is sessionless and declares its gate here.
|
|
19
6
|
|
|
20
7
|
## The Rule
|
|
21
8
|
|
|
@@ -43,12 +30,6 @@ export const deleteBook = pikkuFunc({
|
|
|
43
30
|
})
|
|
44
31
|
```
|
|
45
32
|
|
|
46
|
-
## Agent Operating Procedure
|
|
47
|
-
|
|
48
|
-
1. Discover before editing. Run `pikku info permissions --verbose` and `pikku info functions --verbose` to understand what permissions are already defined and applied.
|
|
49
|
-
2. Define permission checkers in a `src/permissions.ts` or domain-specific `src/lib/*-permissions.ts` file.
|
|
50
|
-
3. Apply them via the `permissions` field on the function. For an app-wide baseline that every function must additionally satisfy, use `addGlobalPermission`.
|
|
51
|
-
4. Validate: run `pikku all --tsc` to confirm permission checker signatures are correct.
|
|
52
33
|
|
|
53
34
|
## Permission Factories
|
|
54
35
|
|
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-security
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding authentication or session management to a Pikku app — pikkuAuth, session
|
|
5
|
-
lifecycle (setSession/clearSession), built-in auth strategies (authBearer, authCookie,
|
|
6
|
-
authAPIKey), or JWT setup. TRIGGER when: user asks about login, logout, session, bearer tokens,
|
|
7
|
-
cookie auth, API keys, or JWT. DO NOT TRIGGER when: user asks about middleware (use
|
|
8
|
-
pikku-middleware), permissions/authorization checks (use pikku-permissions), or secrets/env vars
|
|
9
|
-
(use pikku-config).
|
|
10
|
-
installGroups: [core]
|
|
11
|
-
---
|
|
12
|
-
|
|
13
1
|
# Pikku Security (Authentication & Sessions)
|
|
14
2
|
|
|
15
|
-
## Agent Operating Procedure
|
|
16
|
-
|
|
17
|
-
1. Discover before editing. Run `pikku info middleware --verbose` and `pikku info functions --verbose` to understand existing auth setup.
|
|
18
|
-
2. Auth strategies live in wirings files — do not put `addHTTPMiddleware` calls inside function bodies.
|
|
19
|
-
3. Validate with `pikku all --tsc` after changes — it regenerates and then type-checks in one pass, and fails on type errors. Use `--tsc-summary` for a compact one-line-per-error report.
|
|
20
|
-
|
|
21
|
-
For **middleware** (including tag middleware and service-to-service bearer auth) see `pikku-middleware`.
|
|
22
|
-
For **permissions** (pikkuPermission, pikkuAuth, per-function authorization) see `pikku-permissions`.
|
|
23
3
|
|
|
24
4
|
## Session Management
|
|
25
5
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-build
|
|
3
|
+
description: >-
|
|
4
|
+
Use to build on Pikku — turning a fresh scaffold into a working app (quick spike, real product,
|
|
5
|
+
or a showcase that exercises every surface), adding a feature to an app that already exists, and
|
|
6
|
+
the one-off cleanup right after a template is cloned. Covers the knowledge base, personas and
|
|
7
|
+
roles, milestone planning, the scenario that proves each one, theming, multi-app layouts and
|
|
8
|
+
deploying. TRIGGER when: the user asks for an app to be built on Pikku, a freshly scaffolded
|
|
9
|
+
project needs turning into a product, the user asks to add a feature or wire up a new endpoint
|
|
10
|
+
in a working app, or a template was just cloned or scaffolded. DO NOT TRIGGER when: the user
|
|
11
|
+
asks for a one-off edit to an existing function, asks about Pikku concepts (use pikku-concepts),
|
|
12
|
+
or wants one specific surface explained rather than built (use that surface's skill).
|
|
13
|
+
allowed-tools: Bash(yarn pikku meta *), Bash(yarn pikku all *), Bash(yarn tsc), Bash(git status *), Bash(git diff *), Bash(git switch *), Bash(git checkout *), Bash(git checkout -b *), Bash(git add *), Bash(git commit *), Bash(git rm *), Bash(git mv *), Bash(git log *), Bash(git branch *), Bash(yarn pikku fabric report *), Bash(npx --no pikku fabric report *)
|
|
14
|
+
argument-hint: '[feature description]'
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Build on Pikku
|
|
18
|
+
|
|
19
|
+
## Which mode
|
|
20
|
+
|
|
21
|
+
| The situation | Read |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| A template was just cloned or scaffolded, and the tree still looks like one | `references/post-clone.md` first, then come back |
|
|
24
|
+
| A real product, meant to be picked up by someone else | `references/app.md` — the default |
|
|
25
|
+
| A spike, a throwaway demo, an idea nobody has committed to | `references/quick.md` |
|
|
26
|
+
| A showcase meant to exercise every Pikku surface | `references/platform.md`, which is a delta on top of `references/app.md` |
|
|
27
|
+
| A feature added to an app that already has its knowledge base and milestones | `references/feature.md` |
|
|
28
|
+
|
|
29
|
+
**App is the default.** A small or toy-sounding app does not make it Quick;
|
|
30
|
+
only an explicit signal of speed or throwaway-ness does. Platform is not "App
|
|
31
|
+
plus more effort" — it is App plus a deliberate surface checklist, so read the
|
|
32
|
+
base first and follow it in full rather than blending the two into one plan.
|
|
33
|
+
|
|
34
|
+
The supporting references belong to whichever mode sends you to them:
|
|
35
|
+
`references/multi-app.md` (a second frontend), `references/theming.md`
|
|
36
|
+
(authoring the theme), `references/ship.md` (deploying, and the Fabric-readiness
|
|
37
|
+
contract).
|
|
38
|
+
|
|
39
|
+
## Bootstrap before anything else
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
bunx --bun pikku bootstrap
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Once, now — not later when you start building. It wires the `#pikku` alias the
|
|
46
|
+
generated code depends on, and on a fresh scaffold **every command that touches
|
|
47
|
+
codegen fails until it has run**, including ones you would reasonably reach for
|
|
48
|
+
while still planning. Those failures look alarming and are nothing but this.
|
|
49
|
+
|
|
50
|
+
## What holds in every mode
|
|
51
|
+
|
|
52
|
+
- **The branch and the diff are the contract.** There is no plan JSON. A
|
|
53
|
+
reviewer sees real, compiled, working code: apply is a merge, reject is a
|
|
54
|
+
`git branch -D`.
|
|
55
|
+
- **Discover before editing.** `yarn pikku meta context --json` returns
|
|
56
|
+
functions, wires, middleware, permissions, workflows, `capabilities` and
|
|
57
|
+
`layout` in one call. Fall back to targeted `meta` commands only for a full
|
|
58
|
+
schema or a workflow's steps.
|
|
59
|
+
- **`metaLocale` in `pikku.config.json` is the language of authored meta** —
|
|
60
|
+
every `description`, `title` and step `template` the console renders.
|
|
61
|
+
Identifiers stay English whatever it says, and the product's own language
|
|
62
|
+
lives in `messages/*.json`.
|
|
63
|
+
- **`pikku all` is the gate.** Run it after touching functions, wirings or
|
|
64
|
+
schemas, and treat its criticals as real.
|
|
65
|
+
- **A milestone is planned by a different seat than the one that builds it.**
|
|
66
|
+
The plan — tables, functions, wires, roles, scopes, screens, scenarios, in
|
|
67
|
+
passes — is written through `pikku knowledge plan set` by `pikku-architect`,
|
|
68
|
+
and `pikku knowledge plan progress` measures the build against it from the
|
|
69
|
+
generated meta. A builder who writes its own plan is grading itself.
|
|
70
|
+
|
|
71
|
+
## What NOT to do
|
|
72
|
+
|
|
73
|
+
- **Do not skip ahead in App mode.** Knowledge, then people, then milestones,
|
|
74
|
+
then one milestone at a time — planned, built, proven by a scenario, and
|
|
75
|
+
closed against its plan before the next starts. The order is the method.
|
|
76
|
+
- **Do not close a milestone your plan says is unfinished.** Build the missing
|
|
77
|
+
item, or defer it with a reason through `pikku knowledge plan defer`. Never
|
|
78
|
+
edit the plan to match what you built, and never drop an item silently.
|
|
79
|
+
- **Do not let a Quick build be mistaken for a real one.** It skips
|
|
80
|
+
`knowledge/`, milestone planning, design direction and refusal scenarios — say
|
|
81
|
+
so out loud to the user when you finish, and point at the way out.
|
|
82
|
+
- **Do not introduce a wire of a type whose `capabilities.<type>` is `false`**
|
|
83
|
+
unless the user asked for it.
|
|
84
|
+
- **Do not hand-edit generated files** — `.pikku/`, `*.gen.*` or the SDK. Fix the
|
|
85
|
+
source and regenerate.
|
|
86
|
+
- **Do not invent a role.** An invented role becomes invented screens; build only
|
|
87
|
+
the roles the user named.
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-build-app
|
|
3
|
-
description: >-
|
|
4
|
-
Build a real product on open-source Pikku using the full Fabric workflow, run locally — knowledge
|
|
5
|
-
base first, personas and roles, milestones planned then built one at a time, each proven by a
|
|
6
|
-
scenario, with a design pass. The default build mode, and the one that stays importable into
|
|
7
|
-
Fabric later. TRIGGER when: the user asked for an app to be built on Pikku and picked "App" (or
|
|
8
|
-
did not pick), a freshly scaffolded pikku project needs turning into a product, or the user says
|
|
9
|
-
"build this properly / so someone can pick it up". DO NOT TRIGGER when: the user asked for
|
|
10
|
-
something quick or throwaway (use pikku-build-quick), wants every platform surface demonstrated
|
|
11
|
-
(use pikku-build-platform), or is adding one feature to an app that already has its knowledge
|
|
12
|
-
base and milestones (use pikku-feature).
|
|
13
|
-
---
|
|
14
|
-
|
|
15
1
|
# Build a product on open-source Pikku
|
|
16
2
|
|
|
17
3
|
You have a scaffolded project with skills installed. This skill owns everything
|
|
@@ -272,7 +258,7 @@ definePersonas({
|
|
|
272
258
|
live with them.
|
|
273
259
|
- **Roles are what a permission check reads, not where it lives.** The check goes
|
|
274
260
|
in the function's `permissions` field (§6), never in the body. Read the
|
|
275
|
-
`pikku-
|
|
261
|
+
`pikku-auth` skill.
|
|
276
262
|
|
|
277
263
|
`pikku persona list` shows who is declared and `pikku roles audit` reports roles
|
|
278
264
|
the database still holds that code no longer declares — both need §0's bootstrap
|
|
@@ -365,17 +351,45 @@ Number the files (`01-…`, `02-…`) so the order is visible in the tree. Then
|
|
|
365
351
|
**Show the user the list before building.** This is the last cheap moment to
|
|
366
352
|
reorder — after §6 the migrations are numbered and the order is concrete.
|
|
367
353
|
|
|
354
|
+
## 5a. The technical plan — one milestone at a time, before you build it
|
|
355
|
+
|
|
356
|
+
The milestone note says what the app must DO. The **plan** says what has to
|
|
357
|
+
exist for it: the tables, functions, wires, roles, scopes, screens and
|
|
358
|
+
scenarios, split into passes. It is JSON, it lives beside the note, and
|
|
359
|
+
`pikku knowledge plan progress` measures the finished build against it.
|
|
360
|
+
|
|
361
|
+
**Read `pikku-architect` and follow it.** The plan is the denominator the
|
|
362
|
+
completion check divides by, so a builder who writes their own plan can build a
|
|
363
|
+
fraction, plan only that fraction, and certify itself complete. Fabric answers
|
|
364
|
+
that by giving the plan its own seat; here the defence is the ORDER, and it only
|
|
365
|
+
holds if you keep it: the plan is written against the note in its own turn,
|
|
366
|
+
before any of the code it measures exists, and is never edited afterwards to
|
|
367
|
+
match what you ended up building. An item that will not land is deferred with
|
|
368
|
+
its reason — `plan defer` — not quietly rewritten. Write it before you open a
|
|
369
|
+
migration:
|
|
370
|
+
|
|
371
|
+
```sh
|
|
372
|
+
pikku knowledge plan schema # the only spec there is
|
|
373
|
+
pikku knowledge plan set <milestone> /tmp/plan.json
|
|
374
|
+
pikku knowledge plan show <milestone> --for-build # what you then build
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Plan one milestone at a time, at the moment you are about to build it** — not
|
|
378
|
+
all of them here. A plan written against a note that later moves is worse than
|
|
379
|
+
no plan, and everything after the current milestone is still allowed to move.
|
|
380
|
+
|
|
368
381
|
---
|
|
369
382
|
|
|
370
383
|
## PHASE 4 — Build
|
|
371
384
|
|
|
372
385
|
## 6. Implement milestones, one at a time
|
|
373
386
|
|
|
374
|
-
**Per milestone** — set its note to `status: dispatched`, do the
|
|
375
|
-
set it to `built`. Do not start the next one
|
|
376
|
-
§
|
|
377
|
-
|
|
378
|
-
or not the note says
|
|
387
|
+
**Per milestone** — plan it (§5a), set its note to `status: dispatched`, do the
|
|
388
|
+
six steps, close it out (§6a), set it to `built`. Do not start the next one
|
|
389
|
+
until §6a passes, §7 is green for this one *and §7a shows its functions
|
|
390
|
+
covered*. A stack of half-milestones cannot be reviewed and cannot be handed
|
|
391
|
+
over, and an uncovered function is a half-milestone whether or not the note says
|
|
392
|
+
`built`.
|
|
379
393
|
|
|
380
394
|
1. **Migration.** SQL in `db/sqlite/` at the project root, numbered on from the
|
|
381
395
|
ones already there. Apply with `bunx --bun pikku db migrate`, which also
|
|
@@ -475,6 +489,44 @@ it is worth writing as a browser step on §7's scenario and running
|
|
|
475
489
|
`pikku scenario run local --spawn --run browser`: same clicks, same assertions,
|
|
476
490
|
in the repo, green or red on every future run.
|
|
477
491
|
|
|
492
|
+
## 6a. Close the milestone against its plan, not against your memory
|
|
493
|
+
|
|
494
|
+
```sh
|
|
495
|
+
pikku knowledge plan progress <milestone>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
It reads §5a's plan and reconciles it against the generated meta under
|
|
499
|
+
`.pikku/` — the function exists or it does not, the route is wired or it is not,
|
|
500
|
+
the `pikkuScenario` export is there or it is not. Nothing it reports comes from
|
|
501
|
+
what anyone claimed, which is the whole reason it replaced a todo list. It exits
|
|
502
|
+
non-zero while anything in the first pass is missing.
|
|
503
|
+
|
|
504
|
+
Three things it says, and what each one asks of you:
|
|
505
|
+
|
|
506
|
+
- **MISSING** — the first pass owes it and the meta cannot see it. Either build
|
|
507
|
+
it, or, if it genuinely belongs to later work, move it out with a reason on
|
|
508
|
+
the record:
|
|
509
|
+
|
|
510
|
+
```sh
|
|
511
|
+
pikku knowledge plan defer <milestone> function:sendReminder \
|
|
512
|
+
-r "The email service it needs is the next milestone."
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**A deferral is capped at two per plan.** Past that, the plan was wrong and the
|
|
516
|
+
milestone is two milestones — say so to the user rather than deferring again.
|
|
517
|
+
What you may never do is drop the item silently: the plan is what the next
|
|
518
|
+
person reads to know what this milestone was for.
|
|
519
|
+
- **PROBLEMS** — something exists but does not do what was planned. A function
|
|
520
|
+
planned as restricted whose meta says `auth: false`; a `cascade` no migration
|
|
521
|
+
declares; a browser scenario that opens a page and asserts it is still on it.
|
|
522
|
+
These are never deferred. Fix the app.
|
|
523
|
+
- **DEFERRED to a later pass** — already accounted for. Reported so it is
|
|
524
|
+
visible, never blocking.
|
|
525
|
+
|
|
526
|
+
**Do not set the note to `built` while this exits non-zero**, and do not edit the
|
|
527
|
+
plan to match what you built — `plan set` is the architect's seat, and a builder
|
|
528
|
+
rewriting its own denominator is exactly what the split exists to stop.
|
|
529
|
+
|
|
478
530
|
## 7. Prove it — scenarios
|
|
479
531
|
|
|
480
532
|
A scenario is a user journey run as one of your personas, over the real
|
|
@@ -685,7 +737,7 @@ cheaper to honour than to retrofit:
|
|
|
685
737
|
that needs it
|
|
686
738
|
- `references/theming.md` — authoring the theme (§8a)
|
|
687
739
|
- `references/ship.md` — deploying, and the Fabric-readiness contract (§9)
|
|
688
|
-
- Sibling skills: `pikku-knowledge` (§2), `pikku-
|
|
689
|
-
`pikku-scenario` (§7, §7a), `pikku-deploy
|
|
740
|
+
- Sibling skills: `pikku-knowledge` (§2), `pikku-auth` (§3),
|
|
741
|
+
`pikku-scenario` (§7, §7a), `pikku-deploy` and `pikku-fabric` (§9)
|
|
690
742
|
- Project conventions written by the template: `AGENTS.md`
|
|
691
|
-
- Doing less than this: `
|
|
743
|
+
- Doing less than this: `references/quick.md``. Doing more: `references/platform.md``.
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-feature
|
|
3
|
-
description: 'Drive create-a-feature work inside a Pikku project that already exists: discover project context, work on a feature branch, implement + verify + commit, and ask the user to review via the diff. TRIGGER when: the user asks to "create a feature", "add X to my Pikku project", "wire up a new endpoint", or anything that implies turning a natural-language request into Pikku functions/wirings/migrations within a working app. DO NOT TRIGGER when: the user asks for a one-off code edit in an existing function, asks about Pikku concepts (use pikku-concepts), or is building a whole app from a fresh scaffold rather than extending one (use pikku-build-app, or pikku-build-quick / pikku-build-platform).'
|
|
4
|
-
allowed-tools: Bash(yarn pikku meta *), Bash(yarn pikku all *), Bash(yarn tsc), Bash(git status *), Bash(git diff *), Bash(git switch *), Bash(git checkout *), Bash(git checkout -b *), Bash(git add *), Bash(git commit *), Bash(git log *), Bash(git branch *), Bash(yarn pikku fabric report *), Bash(npx --no pikku fabric report *)
|
|
5
|
-
argument-hint: '<feature description>'
|
|
6
|
-
---
|
|
7
|
-
|
|
8
1
|
# Pikku Create-a-Feature
|
|
9
2
|
|
|
10
3
|
## Agent Operating Procedure
|
|
@@ -137,7 +130,7 @@ in-app features don't.
|
|
|
137
130
|
zod schema for type-safe access. Read variables with
|
|
138
131
|
`services.variables.get('NAME')`. Secrets are **not available in functions** —
|
|
139
132
|
read them in `services.ts` with `secrets.getSecret('NAME')` and pass the value
|
|
140
|
-
into the service the function uses. See the **pikku-
|
|
133
|
+
into the service the function uses. See the **pikku-services** skill for the full
|
|
141
134
|
pattern (including OAuth2 credentials). This applies even in `config.ts`.
|
|
142
135
|
|
|
143
136
|
### Conventions to copy from neighbours
|
|
@@ -102,7 +102,7 @@ rewritten to the pikku dev server).
|
|
|
102
102
|
the permission check exists. The refusal scenario is the evidence.
|
|
103
103
|
- **In production on two subdomains**, the session cookie needs a parent domain
|
|
104
104
|
(`.example.com`) or each app gets its own login. Decide which, set it per the
|
|
105
|
-
`pikku-
|
|
105
|
+
`pikku-auth` skill, and record it in `knowledge/decisions/security/`.
|
|
106
106
|
- **Never hardcode a host or port.** The API base resolves to same-origin `/api`.
|
|
107
107
|
|
|
108
108
|
## Building the second app's screens
|