@pikku/cli 0.12.91 → 0.12.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/LICENSE +106 -0
  2. package/console-app/assets/{index-D0HG8q0B.css → index-BYj7ZbUU.css} +1 -1
  3. package/console-app/assets/{index-CpkvmAGb.js → index-CmAplHjZ.js} +151 -149
  4. package/console-app/index.html +2 -2
  5. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
  6. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
  7. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  8. package/dist/.pikku/cli/pikku-cli-channel.js +16 -1
  9. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  10. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
  11. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
  12. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
  13. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.json +15 -0
  14. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  15. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  16. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  17. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +48 -0
  18. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  19. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  20. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  21. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  22. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  23. package/dist/.pikku/function/pikku-function-types.gen.d.ts +1 -1
  24. package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
  25. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  26. package/dist/.pikku/function/pikku-functions-meta.gen.json +73 -40
  27. package/dist/.pikku/function/pikku-functions.gen.js +1 -3
  28. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  29. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  30. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  31. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  32. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +2 -1
  33. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +2 -1
  34. package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
  35. package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
  36. package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
  37. package/dist/.pikku/pikku-meta-service.gen.js +1 -1
  38. package/dist/.pikku/pikku-services.gen.d.ts +1 -1
  39. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  40. package/dist/.pikku/pikku-types.gen.js +1 -1
  41. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  42. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  43. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  44. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  45. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  46. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  47. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +3 -1
  48. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
  49. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
  50. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
  51. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
  52. package/dist/.pikku/scenarios/schemas/register.gen.d.ts +4 -0
  53. package/dist/.pikku/scenarios/schemas/register.gen.js +4 -0
  54. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  55. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  56. package/dist/.pikku/schemas/register.gen.js +13 -3
  57. package/dist/.pikku/schemas/schemas/FabricSecretsListOutput.schema.json +1 -1
  58. package/dist/.pikku/schemas/schemas/FabricSecretsRotateInput.schema.json +1 -0
  59. package/dist/.pikku/schemas/schemas/FabricSecretsRotateOutput.schema.json +1 -0
  60. package/dist/.pikku/schemas/schemas/FabricSecretsSetOutput.schema.json +1 -1
  61. package/dist/.pikku/schemas/schemas/KnowledgeIndexInput.schema.json +1 -0
  62. package/dist/.pikku/schemas/schemas/KnowledgeIndexOutput.schema.json +1 -0
  63. package/dist/.pikku/schemas/schemas/KnowledgeValidateInput.schema.json +1 -0
  64. package/dist/.pikku/schemas/schemas/KnowledgeValidateOutput.schema.json +1 -0
  65. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  66. package/dist/.pikku/schemas/schemas/ScenarioRunInput.schema.json +1 -1
  67. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
  68. package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
  69. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
  70. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  71. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  72. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  73. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  74. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  75. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  76. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  77. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  78. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  79. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  80. package/dist/.pikku/workflow/meta/allWorkflow.gen.json +2 -8
  81. package/dist/.pikku/workflow/pikku-scenario-actors.gen.d.ts +1 -1
  82. package/dist/.pikku/workflow/pikku-scenario-actors.gen.js +1 -1
  83. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
  84. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
  85. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  86. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  87. package/dist/bin/pikku-bin.mjs +2 -2
  88. package/dist/src/cli.wiring.js +29 -0
  89. package/dist/src/deploy/analyzer/analyzer.js +22 -5
  90. package/dist/src/deploy/build-pipeline.js +5 -1
  91. package/dist/src/fabric/fabric-commands.d.ts +37 -9
  92. package/dist/src/fabric/fabric-commands.js +12 -0
  93. package/dist/src/fabric/functions/domains-add.function.d.ts +4 -4
  94. package/dist/src/fabric/functions/secrets-list.function.d.ts +16 -4
  95. package/dist/src/fabric/functions/secrets-list.function.js +12 -10
  96. package/dist/src/fabric/functions/secrets-rotate.function.d.ts +24 -0
  97. package/dist/src/fabric/functions/secrets-rotate.function.js +36 -0
  98. package/dist/src/fabric/functions/secrets-set.function.d.ts +8 -4
  99. package/dist/src/fabric/functions/secrets-set.function.js +18 -7
  100. package/dist/src/fabric/functions/validate.function.js +16 -7
  101. package/dist/src/fabric/lib/http.d.ts +7 -1
  102. package/dist/src/fabric/lib/sealed-box.d.ts +16 -0
  103. package/dist/src/fabric/lib/sealed-box.js +72 -0
  104. package/dist/src/functions/commands/dev.js +9 -0
  105. package/dist/src/functions/commands/knowledge-index.d.ts +30 -0
  106. package/dist/src/functions/commands/knowledge-index.js +11 -0
  107. package/dist/src/functions/commands/knowledge-validate.d.ts +33 -0
  108. package/dist/src/functions/commands/knowledge-validate.js +11 -0
  109. package/dist/src/functions/commands/new-addon.d.ts +18 -0
  110. package/dist/src/functions/commands/new-addon.js +40 -24
  111. package/dist/src/functions/commands/pikku-command-bootstrap.js +1 -0
  112. package/dist/src/functions/commands/scenario-browser.d.ts +17 -2
  113. package/dist/src/functions/commands/scenario-browser.js +16 -8
  114. package/dist/src/functions/commands/scenario-environment.d.ts +32 -0
  115. package/dist/src/functions/commands/scenario-environment.js +61 -0
  116. package/dist/src/functions/commands/scenario.d.ts +6 -0
  117. package/dist/src/functions/commands/scenario.js +14 -9
  118. package/dist/src/functions/commands/skills.js +27 -61
  119. package/dist/src/functions/db/db-codegen.d.ts +6 -0
  120. package/dist/src/functions/db/db-codegen.js +9 -0
  121. package/dist/src/functions/db/db-migrator.js +14 -0
  122. package/dist/src/functions/db/local-db.d.ts +8 -0
  123. package/dist/src/functions/db/local-db.js +24 -2
  124. package/dist/src/functions/db/migration-identifiers.d.ts +58 -0
  125. package/dist/src/functions/db/migration-identifiers.js +262 -0
  126. package/dist/src/functions/db/migration-provenance.d.ts +35 -0
  127. package/dist/src/functions/db/migration-provenance.js +80 -0
  128. package/dist/src/functions/db/schema-sql.d.ts +43 -0
  129. package/dist/src/functions/db/schema-sql.js +135 -0
  130. package/dist/src/functions/db/sqlite/sqlite-kysely.js +22 -2
  131. package/dist/src/functions/knowledge/render.d.ts +3 -0
  132. package/dist/src/functions/knowledge/render.js +66 -0
  133. package/dist/src/functions/knowledge/schemas.d.ts +51 -0
  134. package/dist/src/functions/knowledge/schemas.js +25 -0
  135. package/dist/src/functions/wirings/credentials/serialize-credentials-types.js +8 -1
  136. package/dist/src/functions/wirings/functions/schemas.js +13 -1
  137. package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +6 -1
  138. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.d.ts +10 -0
  139. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.js +102 -0
  140. package/dist/src/functions/wirings/scenarios/scenario-partition.d.ts +13 -0
  141. package/dist/src/functions/wirings/scenarios/scenario-partition.js +15 -2
  142. package/dist/src/functions/wirings/scenarios/scenario-schema-partition.d.ts +33 -0
  143. package/dist/src/functions/wirings/scenarios/scenario-schema-partition.js +49 -0
  144. package/dist/src/functions/wirings/secrets/serialize-secrets-types.js +10 -3
  145. package/dist/src/functions/wirings/variables/serialize-variables-types.js +8 -1
  146. package/dist/src/functions/workflows/all.workflow.js +2 -7
  147. package/dist/src/utils/file-writer.js +14 -2
  148. package/dist/src/utils/pikku-cli-config.d.ts +14 -0
  149. package/dist/src/utils/pikku-cli-config.js +34 -0
  150. package/dist/src/utils/remove-legacy-scaffold-file.d.ts +14 -0
  151. package/dist/src/utils/remove-legacy-scaffold-file.js +23 -0
  152. package/dist/src/utils/serialize-schemas.d.ts +3 -1
  153. package/dist/src/utils/serialize-schemas.js +39 -4
  154. package/dist/tsconfig.tsbuildinfo +1 -1
  155. package/package.json +10 -9
  156. package/dist/.pikku/schemas/schemas/PikkuScenarioFunctionsOutput.schema.json +0 -1
  157. package/dist/src/functions/wirings/scenarios/pikku-command-scenario-functions.d.ts +0 -1
  158. package/dist/src/functions/wirings/scenarios/pikku-command-scenario-functions.js +0 -31
  159. package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.d.ts +0 -10
  160. package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.js +0 -104
  161. package/skills/pikku-addon/SKILL.md +0 -243
  162. package/skills/pikku-addon/references/addon-package-manifest.md +0 -63
  163. package/skills/pikku-ai-agent/SKILL.md +0 -231
  164. package/skills/pikku-ai-vercel/SKILL.md +0 -82
  165. package/skills/pikku-ai-voice/SKILL.md +0 -88
  166. package/skills/pikku-audit/SKILL.md +0 -175
  167. package/skills/pikku-aws/SKILL.md +0 -111
  168. package/skills/pikku-backblaze/SKILL.md +0 -71
  169. package/skills/pikku-better-auth/SKILL.md +0 -298
  170. package/skills/pikku-cli/SKILL.md +0 -198
  171. package/skills/pikku-cli/references/complete-example.md +0 -82
  172. package/skills/pikku-concepts/SKILL.md +0 -250
  173. package/skills/pikku-concepts/references/concept-mapping.md +0 -556
  174. package/skills/pikku-concepts/references/packages.md +0 -29
  175. package/skills/pikku-config/SKILL.md +0 -212
  176. package/skills/pikku-cron/SKILL.md +0 -214
  177. package/skills/pikku-deploy-azure/SKILL.md +0 -71
  178. package/skills/pikku-deploy-cloudflare/SKILL.md +0 -82
  179. package/skills/pikku-deploy-express/SKILL.md +0 -86
  180. package/skills/pikku-deploy-fastify/SKILL.md +0 -73
  181. package/skills/pikku-deploy-lambda/SKILL.md +0 -110
  182. package/skills/pikku-deploy-nextjs/SKILL.md +0 -78
  183. package/skills/pikku-deploy-uws/SKILL.md +0 -88
  184. package/skills/pikku-deps/SKILL.md +0 -98
  185. package/skills/pikku-emails/SKILL.md +0 -163
  186. package/skills/pikku-fabric/SKILL.md +0 -318
  187. package/skills/pikku-fabric-debug/SKILL.md +0 -112
  188. package/skills/pikku-feature/SKILL.md +0 -258
  189. package/skills/pikku-gateway-slack/SKILL.md +0 -115
  190. package/skills/pikku-http/SKILL.md +0 -220
  191. package/skills/pikku-http/references/http-options.md +0 -55
  192. package/skills/pikku-i18n/SKILL.md +0 -137
  193. package/skills/pikku-info/SKILL.md +0 -100
  194. package/skills/pikku-jose/SKILL.md +0 -105
  195. package/skills/pikku-kysely/SKILL.md +0 -219
  196. package/skills/pikku-machine-auth/SKILL.md +0 -183
  197. package/skills/pikku-mcp/SKILL.md +0 -241
  198. package/skills/pikku-middleware/SKILL.md +0 -231
  199. package/skills/pikku-middleware/references/middleware-patterns.md +0 -61
  200. package/skills/pikku-mongodb/SKILL.md +0 -105
  201. package/skills/pikku-n8n-import/SKILL.md +0 -109
  202. package/skills/pikku-n8n-import/SPEC.md +0 -84
  203. package/skills/pikku-n8n-import/references/addon-mapping.md +0 -121
  204. package/skills/pikku-n8n-import/references/code-translation.md +0 -121
  205. package/skills/pikku-n8n-import/references/loops-and-control.md +0 -87
  206. package/skills/pikku-paraglide/SKILL.md +0 -117
  207. package/skills/pikku-permissions/SKILL.md +0 -192
  208. package/skills/pikku-pino/SKILL.md +0 -79
  209. package/skills/pikku-product-second-opinion/README.md +0 -43
  210. package/skills/pikku-product-second-opinion/SKILL.md +0 -158
  211. package/skills/pikku-product-second-opinion/example/sample-report.md +0 -90
  212. package/skills/pikku-product-second-opinion/references/report-template.md +0 -73
  213. package/skills/pikku-queue/SKILL.md +0 -240
  214. package/skills/pikku-react/SKILL.md +0 -212
  215. package/skills/pikku-react-query/SKILL.md +0 -242
  216. package/skills/pikku-realtime/SKILL.md +0 -236
  217. package/skills/pikku-realtime/references/other-routes.md +0 -23
  218. package/skills/pikku-redis/SKILL.md +0 -90
  219. package/skills/pikku-rpc/SKILL.md +0 -171
  220. package/skills/pikku-rtl/SKILL.md +0 -219
  221. package/skills/pikku-scenario/SKILL.md +0 -382
  222. package/skills/pikku-schedule/SKILL.md +0 -57
  223. package/skills/pikku-schema-ajv/SKILL.md +0 -62
  224. package/skills/pikku-schema-cfworker/SKILL.md +0 -63
  225. package/skills/pikku-security/SKILL.md +0 -108
  226. package/skills/pikku-services/SKILL.md +0 -248
  227. package/skills/pikku-services/references/audit-wire-service.md +0 -34
  228. package/skills/pikku-software-archaeology/README.md +0 -70
  229. package/skills/pikku-software-archaeology/SKILL.md +0 -186
  230. package/skills/pikku-software-archaeology/references/blueprint.schema.json +0 -625
  231. package/skills/pikku-software-archaeology/references/pikku-mapping.md +0 -49
  232. package/skills/pikku-software-archaeology/scripts/validate.mjs +0 -173
  233. package/skills/pikku-tag-middleware/SKILL.md +0 -13
  234. package/skills/pikku-template-clone/SKILL.md +0 -40
  235. package/skills/pikku-trigger/SKILL.md +0 -181
  236. package/skills/pikku-versioning/SKILL.md +0 -173
  237. package/skills/pikku-websocket/SKILL.md +0 -243
  238. package/skills/pikku-workflow/SKILL.md +0 -172
  239. package/skills/pikku-workflow/references/workflow-reference.md +0 -63
  240. package/skills/pikku-workflows-client/SKILL.md +0 -150
  241. package/skills/pikku-ws/SKILL.md +0 -47
@@ -1,212 +0,0 @@
1
- ---
2
- name: pikku-config
3
- description: >-
4
- Use when managing secrets, environment variables, config, or OAuth2 credentials in a Pikku app.
5
- Covers wireSecret, wireVariable, wireOAuth2Credential, and typed config access. TRIGGER when:
6
- code uses wireSecret/wireVariable/wireOAuth2Credential, user asks about env vars, secrets,
7
- config, OAuth2, or "how do I access environment variables". DO NOT TRIGGER when: user asks about
8
- API versioning/breaking changes (use pikku-versioning), service factories (use pikku-services),
9
- or auth middleware (use pikku-security).
10
- installGroups: [core]
11
- ---
12
-
13
- # Pikku Config, Secrets & OAuth2
14
-
15
- ## Agent Operating Procedure
16
-
17
- Use this skill as an execution checklist, not reference material.
18
-
19
- 1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise 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
- Manage secrets, variables, and OAuth2 credentials. Never use `process.env` in Pikku functions — use typed services instead.
26
-
27
- ## Before You Start
28
-
29
- ```bash
30
- pikku info functions --verbose # See existing functions and their versions
31
- pikku info tags --verbose # Understand project organization
32
- ```
33
-
34
- See `pikku-concepts` for the core mental model.
35
-
36
- ## Secrets & Variables
37
-
38
- ### `wireSecret(config)`
39
-
40
- Declare a secret with a Zod schema for type-safe access:
41
-
42
- ```typescript
43
- wireSecret({
44
- name: string, // Secret identifier
45
- schema: ZodSchema, // Shape and validation
46
- })
47
- ```
48
-
49
- ### `wireVariable(config)`
50
-
51
- Declare a variable (non-sensitive config) with a Zod schema:
52
-
53
- ```typescript
54
- wireVariable({
55
- name: string,
56
- schema: ZodSchema,
57
- })
58
- ```
59
-
60
- ### Accessing in Functions
61
-
62
- ```typescript
63
- // Secrets — encrypted, sensitive values
64
- const config = await services.secrets.getSecret('SECRET_NAME')
65
-
66
- // Variables — plain-text configuration
67
- const flags = await services.variables.getVariableJSON('VARIABLE_NAME')
68
-
69
- // Simple string access
70
- const apiKey = services.variables.get('API_KEY')
71
- ```
72
-
73
- ### Local Development Services
74
-
75
- ```typescript
76
- import { LocalSecretService, LocalVariablesService } from '@pikku/core/services'
77
-
78
- const createSingletonServices = pikkuServices(async (config) => ({
79
- secrets: new LocalSecretService(), // Reads from .env or local files
80
- variables: new LocalVariablesService(), // Reads from environment
81
- }))
82
- ```
83
-
84
- ### Usage Patterns
85
-
86
- ```typescript
87
- // Declare secrets with typed schemas
88
- wireSecret({
89
- name: 'STRIPE_CONFIG',
90
- schema: z.object({
91
- apiKey: z.string().startsWith('sk_'),
92
- webhookSecret: z.string(),
93
- }),
94
- })
95
-
96
- // In your function — fully typed
97
- const config = await secrets.getSecret('STRIPE_CONFIG')
98
- // config.apiKey → string (autocompleted)
99
- // config.webhookSecret → string (autocompleted)
100
-
101
- // Declare variables
102
- wireVariable({
103
- name: 'FEATURE_FLAGS',
104
- schema: z.object({
105
- darkMode: z.boolean(),
106
- maxUploadMB: z.number().default(10),
107
- }),
108
- })
109
-
110
- // Read it — typed and validated
111
- const flags = await variables.getVariableJSON('FEATURE_FLAGS')
112
- // flags.darkMode → boolean
113
- // flags.maxUploadMB → number
114
- ```
115
-
116
- ## OAuth2 Credentials
117
-
118
- ### `wireOAuth2Credential(config)`
119
-
120
- ```typescript
121
- wireOAuth2Credential({
122
- name: string, // Credential identifier
123
- displayName: string, // Human-readable name
124
- secretId: string, // Secret holding { clientId, clientSecret }
125
- tokenSecretId: string, // Secret for token storage (auto-refreshed)
126
- authorizationUrl: string, // OAuth2 authorization endpoint
127
- tokenUrl: string, // OAuth2 token endpoint
128
- scopes: string[], // Required OAuth2 scopes
129
- })
130
- ```
131
-
132
- ### Usage
133
-
134
- ```typescript
135
- wireOAuth2Credential({
136
- name: 'slackOAuth',
137
- displayName: 'Slack OAuth',
138
- secretId: 'SLACK_OAUTH_APP',
139
- tokenSecretId: 'SLACK_OAUTH_TOKENS',
140
- authorizationUrl: 'https://slack.com/oauth/v2/authorize',
141
- tokenUrl: 'https://slack.com/api/oauth.v2.access',
142
- scopes: ['chat:write', 'channels:read'],
143
- })
144
-
145
- // In your function — tokens refresh automatically
146
- const response = await slackOAuth.request(
147
- 'https://slack.com/api/chat.postMessage',
148
- {
149
- method: 'POST',
150
- body: JSON.stringify({ channel, text }),
151
- }
152
- )
153
- const data = await response.json()
154
- ```
155
-
156
- ## Key Rule
157
-
158
- **Never use `process.env` inside Pikku functions.** Use the `variables` or `secrets` service:
159
-
160
- ```typescript
161
- // ❌ Wrong
162
- const apiKey = process.env.API_KEY
163
-
164
- // ✅ Correct
165
- const apiKey = services.variables.get('API_KEY')
166
- ```
167
-
168
- `process.env` belongs only in server bootstrap code (`start.ts`).
169
-
170
- ## Complete Example
171
-
172
- ```typescript
173
- // schemas/config.ts
174
- wireSecret({
175
- name: 'DATABASE_CONFIG',
176
- schema: z.object({
177
- connectionString: z.string().url(),
178
- maxPoolSize: z.number().default(10),
179
- }),
180
- })
181
-
182
- wireVariable({
183
- name: 'APP_CONFIG',
184
- schema: z.object({
185
- appName: z.string(),
186
- maxUploadSizeMB: z.number().default(10),
187
- maintenanceMode: z.boolean().default(false),
188
- }),
189
- })
190
-
191
- wireOAuth2Credential({
192
- name: 'githubOAuth',
193
- displayName: 'GitHub OAuth',
194
- secretId: 'GITHUB_OAUTH_APP',
195
- tokenSecretId: 'GITHUB_OAUTH_TOKENS',
196
- authorizationUrl: 'https://github.com/login/oauth/authorize',
197
- tokenUrl: 'https://github.com/login/oauth/access_token',
198
- scopes: ['read:user', 'repo'],
199
- })
200
-
201
- // functions/admin.functions.ts
202
- export const getAppStatus = pikkuSessionlessFunc({
203
- title: 'Get App Status',
204
- func: async ({ variables, secrets }) => {
205
- const appConfig = await variables.getVariableJSON('APP_CONFIG')
206
- return {
207
- appName: appConfig.appName,
208
- maintenanceMode: appConfig.maintenanceMode,
209
- }
210
- },
211
- })
212
- ```
@@ -1,214 +0,0 @@
1
- ---
2
- name: pikku-cron
3
- description: >-
4
- Use when adding scheduled tasks, recurring jobs, or cron-based automation to a Pikku app. Covers
5
- wireScheduler, cron expressions, scheduled task wire object, and scheduler middleware. TRIGGER
6
- when: code uses wireScheduler, user asks about cron, scheduled tasks, recurring jobs, or "run
7
- every X minutes/hours". DO NOT TRIGGER when: user asks about background jobs with retries (use
8
- pikku-queue) or event-driven triggers (use pikku-trigger).
9
- ---
10
-
11
- # Pikku Cron/Scheduler Wiring
12
-
13
- ## Agent Operating Procedure
14
-
15
- Use this skill as an execution checklist, not reference material.
16
-
17
- 1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
18
- 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.
19
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
20
- 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.
21
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
22
-
23
- Wire Pikku functions to run on a schedule using cron expressions. Uses `pikkuVoidFunc` (no input/output).
24
-
25
- ## Before You Start
26
-
27
- ```bash
28
- pikku info functions --verbose # See existing functions and their types
29
- pikku info tags --verbose # Understand project organization
30
- ```
31
-
32
- See `pikku-concepts` for the core mental model.
33
-
34
- ## API Reference
35
-
36
- ### `wireScheduler(config)`
37
-
38
- ```typescript
39
- import { wireScheduler } from '@pikku/core/scheduler'
40
-
41
- wireScheduler({
42
- name: string, // Unique scheduler name
43
- schedule: string, // Cron expression
44
- func: PikkuVoidFunc, // Must be pikkuVoidFunc (no input/output)
45
- middleware?: PikkuMiddleware[],
46
- })
47
- ```
48
-
49
- ### Wire Object (`wire.scheduledTask`)
50
-
51
- Inside scheduled functions:
52
-
53
- ```typescript
54
- wire.scheduledTask.name // Scheduler name
55
- wire.scheduledTask.schedule // Cron expression string
56
- wire.scheduledTask.executionTime // When this execution was triggered
57
- wire.scheduledTask.skip(reason) // Skip this execution (no error)
58
- ```
59
-
60
- ### Cron Expression Reference
61
-
62
- ```
63
- ┌───────────── minute (0-59)
64
- │ ┌───────────── hour (0-23)
65
- │ │ ┌───────────── day of month (1-31)
66
- │ │ │ ┌───────────── month (1-12)
67
- │ │ │ │ ┌───────────── day of week (0-7, 0 and 7 = Sunday)
68
- │ │ │ │ │
69
- * * * * *
70
- ```
71
-
72
- Common patterns:
73
-
74
- | Expression | Meaning |
75
- | ------------- | -------------------------- |
76
- | `*/5 * * * *` | Every 5 minutes |
77
- | `0 9 * * *` | Daily at 9:00 AM |
78
- | `0 9 * * 1` | Every Monday at 9:00 AM |
79
- | `0 0 1 * *` | First of month at midnight |
80
- | `0 */6 * * *` | Every 6 hours |
81
- | `30 2 * * 0` | Sundays at 2:30 AM |
82
-
83
- ## Usage Patterns
84
-
85
- ### Basic Scheduled Task
86
-
87
- ```typescript
88
- const dailySummary = pikkuVoidFunc({
89
- title: 'Daily Summary',
90
- func: async ({ db, emailService, logger }) => {
91
- logger.info('Generating daily summary')
92
- const stats = await db.getDailyStats()
93
- await emailService.sendSummary(stats)
94
- },
95
- })
96
-
97
- wireScheduler({
98
- name: 'dailySummary',
99
- schedule: '0 9 * * *',
100
- func: dailySummary,
101
- })
102
- ```
103
-
104
- ### Using the Wire Object
105
-
106
- ```typescript
107
- const weeklyCleanup = pikkuVoidFunc({
108
- title: 'Weekly Cleanup',
109
- func: async ({ db, logger }, _input, wire) => {
110
- logger.info(`Running: ${wire.scheduledTask.name}`)
111
- logger.info(`Schedule: ${wire.scheduledTask.schedule}`)
112
- logger.info(`Execution time: ${wire.scheduledTask.executionTime}`)
113
-
114
- const staleCount = await db.countStaleTodos()
115
- if (staleCount === 0) {
116
- wire.scheduledTask.skip('No stale todos found')
117
- return
118
- }
119
-
120
- await db.deleteCompletedTodos({ olderThan: '30d' })
121
- logger.info(`Cleaned ${staleCount} stale todos`)
122
- },
123
- })
124
-
125
- wireScheduler({
126
- name: 'weeklyCleanup',
127
- schedule: '0 0 * * 0',
128
- func: weeklyCleanup,
129
- })
130
- ```
131
-
132
- ### Scheduler Middleware
133
-
134
- ```typescript
135
- const schedulerMetrics = pikkuMiddleware(
136
- async ({ logger }, { scheduledTask }, next) => {
137
- const start = Date.now()
138
- logger.info(`Task started: ${scheduledTask.name}`)
139
-
140
- try {
141
- await next()
142
- logger.info(`Task completed: ${scheduledTask.name}`, {
143
- duration: Date.now() - start,
144
- })
145
- } catch (error) {
146
- logger.error(`Task failed: ${scheduledTask.name}`, {
147
- error: error.message,
148
- duration: Date.now() - start,
149
- })
150
- throw error
151
- }
152
- }
153
- )
154
-
155
- wireScheduler({
156
- name: 'dailySummary',
157
- schedule: '0 9 * * *',
158
- func: dailySummary,
159
- middleware: [schedulerMetrics],
160
- })
161
- ```
162
-
163
- ## Complete Example
164
-
165
- ```typescript
166
- // functions/scheduled.functions.ts
167
- export const dailySummary = pikkuVoidFunc({
168
- title: 'Daily Summary',
169
- func: async ({ db, emailService, logger }) => {
170
- const stats = await db.getDailyStats()
171
- await emailService.sendSummary(stats)
172
- logger.info('Daily summary sent', { stats })
173
- },
174
- })
175
-
176
- export const cleanupExpired = pikkuVoidFunc({
177
- title: 'Cleanup Expired',
178
- func: async ({ db, logger }, _input, wire) => {
179
- const count = await db.countExpiredSessions()
180
- if (count === 0) {
181
- wire.scheduledTask.skip('No expired sessions')
182
- return
183
- }
184
- await db.deleteExpiredSessions()
185
- logger.info(`Cleaned ${count} expired sessions`)
186
- },
187
- })
188
-
189
- export const syncInventory = pikkuVoidFunc({
190
- title: 'Sync Inventory',
191
- func: async ({ inventoryApi, db, logger }) => {
192
- const updates = await inventoryApi.getChanges()
193
- await db.applyInventoryUpdates(updates)
194
- logger.info(`Synced ${updates.length} inventory changes`)
195
- },
196
- })
197
-
198
- // wirings/scheduler.wiring.ts
199
- wireScheduler({
200
- name: 'dailySummary',
201
- schedule: '0 9 * * *',
202
- func: dailySummary,
203
- })
204
- wireScheduler({
205
- name: 'cleanupExpired',
206
- schedule: '0 */6 * * *',
207
- func: cleanupExpired,
208
- })
209
- wireScheduler({
210
- name: 'syncInventory',
211
- schedule: '*/15 * * * *',
212
- func: syncInventory,
213
- })
214
- ```
@@ -1,71 +0,0 @@
1
- ---
2
- name: pikku-deploy-azure
3
- description: >-
4
- Use when deploying a Pikku app to Azure Functions. Covers PikkuAzFunctionsLogger and
5
- PikkuAzTimerRequest for Azure Functions runtime. TRIGGER when: user asks about Azure Functions,
6
- Azure deployment, or @pikku/azure-functions. DO NOT TRIGGER when: user asks about AWS Lambda
7
- (use pikku-deploy-lambda) or Cloudflare Workers (use pikku-deploy-cloudflare).
8
- ---
9
-
10
- # Pikku Azure Functions Deployment
11
-
12
- ## Agent Operating Procedure
13
-
14
- Use this skill as an execution checklist, not reference material.
15
-
16
- 1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
17
- 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.
18
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
19
- 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.
20
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
21
-
22
- `@pikku/azure-functions` provides Azure Functions runtime adapters for Pikku.
23
-
24
- ## Installation
25
-
26
- ```bash
27
- yarn add @pikku/azure-functions @azure/functions
28
- ```
29
-
30
- ## API Reference
31
-
32
- ### `PikkuAzFunctionsLogger`
33
-
34
- Logger implementation that integrates with Azure Functions' built-in logging context.
35
-
36
- ### `PikkuAzTimerRequest`
37
-
38
- Timer trigger request handler for running Pikku scheduled functions as Azure Timer Triggers.
39
-
40
- ## Usage Patterns
41
-
42
- ### HTTP Function
43
-
44
- ```typescript
45
- import { app } from '@azure/functions'
46
- import { PikkuAzFunctionsLogger } from '@pikku/azure-functions'
47
-
48
- app.http('api', {
49
- methods: ['GET', 'POST', 'PUT', 'DELETE'],
50
- route: '{*path}',
51
- handler: async (request, context) => {
52
- const logger = new PikkuAzFunctionsLogger(context)
53
- // Wire Pikku HTTP runner with Azure request/response
54
- },
55
- })
56
- ```
57
-
58
- ### Timer Trigger
59
-
60
- ```typescript
61
- import { app } from '@azure/functions'
62
- import { PikkuAzTimerRequest } from '@pikku/azure-functions'
63
-
64
- app.timer('scheduler', {
65
- schedule: '0 */5 * * * *',
66
- handler: async (timer, context) => {
67
- const request = new PikkuAzTimerRequest(timer)
68
- // Process scheduled Pikku functions
69
- },
70
- })
71
- ```
@@ -1,82 +0,0 @@
1
- ---
2
- name: pikku-deploy-cloudflare
3
- description: >-
4
- Use when deploying a Pikku app to Cloudflare Workers. Covers HTTP fetch handler, scheduled
5
- tasks, and WebSocket via Durable Objects. TRIGGER when: code imports @pikku/cloudflare, user
6
- mentions Cloudflare Workers deployment, or worker entry uses ExportedHandler/wrangler.toml. DO
7
- NOT TRIGGER when: just defining functions/wirings without Cloudflare-specific code.
8
- installGroups: [fabric]
9
- ---
10
-
11
- # Pikku Cloudflare Workers Deployment
12
-
13
- ## Agent Operating Procedure
14
-
15
- Use this skill as an execution checklist, not reference material.
16
-
17
- 1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
18
- 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.
19
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
20
- 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.
21
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
22
-
23
- ```bash
24
- yarn add @pikku/cloudflare
25
- ```
26
-
27
- ## Worker Entry
28
-
29
- ```typescript
30
- import { runFetch, runScheduled } from '@pikku/cloudflare'
31
- import { setupServices } from './setup-services.js'
32
- import './.pikku/pikku-bootstrap.gen.js'
33
-
34
- export default {
35
- async scheduled(controller, env) {
36
- await setupServices(env)
37
- await runScheduled(controller)
38
- },
39
-
40
- async fetch(request, env): Promise<Response> {
41
- await setupServices(env)
42
- return await runFetch(request as unknown as Request)
43
- },
44
- } satisfies ExportedHandler<Record<string, string>>
45
- ```
46
-
47
- ## Service Setup
48
-
49
- Cloudflare passes env variables per-request — wrap them with Pikku services:
50
-
51
- ```typescript
52
- // setup-services.ts
53
- import { LocalVariablesService, LocalSecretService } from '@pikku/core/services'
54
- import { createConfig, createSingletonServices } from './services.js'
55
-
56
- export const setupServices = async (
57
- env: Record<string, string | undefined>
58
- ) => {
59
- const localVariables = new LocalVariablesService(env)
60
- const config = await createConfig(localVariables)
61
- const localSecrets = new LocalSecretService(localVariables)
62
- return await createSingletonServices(config, {
63
- variables: localVariables,
64
- secrets: localSecrets,
65
- })
66
- }
67
- ```
68
-
69
- ## WebSocket (Durable Objects)
70
-
71
- ```typescript
72
- import { CloudflareWebSocketHibernationServer } from '@pikku/cloudflare'
73
-
74
- export class WebSocketHibernationServer extends CloudflareWebSocketHibernationServer {
75
- protected async getParams() {
76
- const singletonServices = await setupServices(this.env)
77
- return { singletonServices }
78
- }
79
- }
80
- ```
81
-
82
- Register the Durable Object in `wrangler.toml` and export from the worker entry.
@@ -1,86 +0,0 @@
1
- ---
2
- name: pikku-deploy-express
3
- description: >-
4
- Use when deploying a Pikku app with Express. Covers PikkuExpressServer standalone and
5
- pikkuExpressMiddleware for existing Express apps. TRIGGER when: code imports @pikku/express or
6
- @pikku/express-middleware, user mentions Express deployment, or start.ts creates a
7
- PikkuExpressServer. DO NOT TRIGGER when: just defining functions/wirings without
8
- Express-specific code.
9
- ---
10
-
11
- # Pikku Express Deployment
12
-
13
- ## Agent Operating Procedure
14
-
15
- Use this skill as an execution checklist, not reference material.
16
-
17
- 1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
18
- 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.
19
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
20
- 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.
21
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
22
-
23
- ## Standalone Server
24
-
25
- ```bash
26
- yarn add @pikku/express
27
- ```
28
-
29
- ```typescript
30
- import { PikkuExpressServer } from '@pikku/express'
31
- import './.pikku/pikku-bootstrap.gen.js'
32
- import { createConfig, createSingletonServices } from './services.js'
33
-
34
- const config = await createConfig()
35
- const singletonServices = await createSingletonServices(config)
36
-
37
- const appServer = new PikkuExpressServer(
38
- { ...config, port: 4002, hostname: 'localhost' },
39
- singletonServices.logger
40
- )
41
- appServer.enableExitOnSigInt()
42
- await appServer.init()
43
- await appServer.start()
44
- ```
45
-
46
- **Constructor:** `new PikkuExpressServer(config, logger)`
47
-
48
- **Config extends CoreConfig with:**
49
-
50
- - `port: number`
51
- - `hostname: string`
52
- - `healthCheckPath?: string`
53
- - `limits?: Partial<Record<string, string>>`
54
- - `content?: LocalContentConfig` (for static assets / file uploads)
55
-
56
- **Methods:**
57
-
58
- - `init(httpOptions?): Promise<void>` — Register middleware and routes
59
- - `start(): Promise<void>` — Start listening
60
- - `stop(): Promise<void>` — Graceful shutdown
61
- - `enableExitOnSigInt(): Promise<void>` — SIGINT handler
62
- - `enableCors(options): void` — Enable CORS
63
- - `enableStaticAssets(): void` — Serve static files (requires `content` config)
64
-
65
- **Property:** `app: Express` — Direct access to Express instance for custom middleware.
66
-
67
- ## Middleware (existing Express app)
68
-
69
- ```bash
70
- yarn add @pikku/express-middleware
71
- ```
72
-
73
- ```typescript
74
- import express from 'express'
75
- import { pikkuExpressMiddleware } from '@pikku/express-middleware'
76
- import './.pikku/pikku-bootstrap.gen.js'
77
-
78
- const app = express()
79
- app.use(
80
- pikkuExpressMiddleware({
81
- logger: singletonServices.logger,
82
- logRoutes: true,
83
- loadSchemas: true,
84
- })
85
- )
86
- ```