@pikku/cli 0.12.91 → 0.12.92

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 (222) hide show
  1. package/LICENSE +106 -0
  2. package/console-app/assets/{index-CpkvmAGb.js → index-DDpIMCpy.js} +149 -149
  3. package/console-app/index.html +1 -1
  4. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
  5. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
  6. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  7. package/dist/.pikku/cli/pikku-cli-channel.js +6 -1
  8. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  9. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
  10. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
  11. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
  12. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.json +15 -0
  13. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  14. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  15. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  16. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +21 -0
  17. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  18. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  19. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  20. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  21. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  22. package/dist/.pikku/function/pikku-function-types.gen.d.ts +1 -1
  23. package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
  24. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  25. package/dist/.pikku/function/pikku-functions-meta.gen.json +35 -40
  26. package/dist/.pikku/function/pikku-functions.gen.js +1 -3
  27. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  28. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  29. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  30. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  31. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +2 -1
  32. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +2 -1
  33. package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
  34. package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
  35. package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
  36. package/dist/.pikku/pikku-meta-service.gen.js +1 -1
  37. package/dist/.pikku/pikku-services.gen.d.ts +1 -1
  38. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  39. package/dist/.pikku/pikku-types.gen.js +1 -1
  40. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  41. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  42. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  43. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  44. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  45. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  46. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +1 -1
  47. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
  48. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
  49. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
  50. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
  51. package/dist/.pikku/scenarios/schemas/register.gen.d.ts +4 -0
  52. package/dist/.pikku/scenarios/schemas/register.gen.js +4 -0
  53. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  54. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  55. package/dist/.pikku/schemas/register.gen.js +5 -3
  56. package/dist/.pikku/schemas/schemas/FabricSecretsListOutput.schema.json +1 -1
  57. package/dist/.pikku/schemas/schemas/FabricSecretsRotateInput.schema.json +1 -0
  58. package/dist/.pikku/schemas/schemas/FabricSecretsRotateOutput.schema.json +1 -0
  59. package/dist/.pikku/schemas/schemas/FabricSecretsSetOutput.schema.json +1 -1
  60. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  61. package/dist/.pikku/schemas/schemas/ScenarioRunInput.schema.json +1 -1
  62. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
  63. package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
  64. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
  65. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  66. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  67. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  68. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  69. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  70. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  71. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  72. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  73. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  74. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  75. package/dist/.pikku/workflow/meta/allWorkflow.gen.json +2 -8
  76. package/dist/.pikku/workflow/pikku-scenario-actors.gen.d.ts +1 -1
  77. package/dist/.pikku/workflow/pikku-scenario-actors.gen.js +1 -1
  78. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
  79. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
  80. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  81. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  82. package/dist/bin/pikku-bin.mjs +2 -2
  83. package/dist/src/cli.wiring.js +6 -0
  84. package/dist/src/deploy/analyzer/analyzer.js +22 -5
  85. package/dist/src/deploy/build-pipeline.js +5 -1
  86. package/dist/src/fabric/fabric-commands.d.ts +37 -9
  87. package/dist/src/fabric/fabric-commands.js +12 -0
  88. package/dist/src/fabric/functions/domains-add.function.d.ts +4 -4
  89. package/dist/src/fabric/functions/secrets-list.function.d.ts +16 -4
  90. package/dist/src/fabric/functions/secrets-list.function.js +12 -10
  91. package/dist/src/fabric/functions/secrets-rotate.function.d.ts +24 -0
  92. package/dist/src/fabric/functions/secrets-rotate.function.js +36 -0
  93. package/dist/src/fabric/functions/secrets-set.function.d.ts +8 -4
  94. package/dist/src/fabric/functions/secrets-set.function.js +18 -7
  95. package/dist/src/fabric/lib/http.d.ts +7 -1
  96. package/dist/src/fabric/lib/sealed-box.d.ts +16 -0
  97. package/dist/src/fabric/lib/sealed-box.js +72 -0
  98. package/dist/src/functions/commands/dev.js +9 -0
  99. package/dist/src/functions/commands/pikku-command-bootstrap.js +1 -0
  100. package/dist/src/functions/commands/scenario-browser.d.ts +17 -2
  101. package/dist/src/functions/commands/scenario-browser.js +16 -8
  102. package/dist/src/functions/commands/scenario-environment.d.ts +32 -0
  103. package/dist/src/functions/commands/scenario-environment.js +61 -0
  104. package/dist/src/functions/commands/scenario.d.ts +6 -0
  105. package/dist/src/functions/commands/scenario.js +14 -9
  106. package/dist/src/functions/commands/skills.js +27 -61
  107. package/dist/src/functions/db/db-codegen.d.ts +6 -0
  108. package/dist/src/functions/db/db-codegen.js +9 -0
  109. package/dist/src/functions/db/db-migrator.js +14 -0
  110. package/dist/src/functions/db/local-db.d.ts +8 -0
  111. package/dist/src/functions/db/local-db.js +24 -2
  112. package/dist/src/functions/db/migration-identifiers.d.ts +58 -0
  113. package/dist/src/functions/db/migration-identifiers.js +262 -0
  114. package/dist/src/functions/db/migration-provenance.d.ts +35 -0
  115. package/dist/src/functions/db/migration-provenance.js +80 -0
  116. package/dist/src/functions/db/schema-sql.d.ts +43 -0
  117. package/dist/src/functions/db/schema-sql.js +135 -0
  118. package/dist/src/functions/db/sqlite/sqlite-kysely.js +22 -2
  119. package/dist/src/functions/wirings/functions/schemas.js +13 -1
  120. package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +6 -1
  121. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.d.ts +10 -0
  122. package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.js +102 -0
  123. package/dist/src/functions/wirings/scenarios/scenario-partition.d.ts +13 -0
  124. package/dist/src/functions/wirings/scenarios/scenario-partition.js +15 -2
  125. package/dist/src/functions/wirings/scenarios/scenario-schema-partition.d.ts +33 -0
  126. package/dist/src/functions/wirings/scenarios/scenario-schema-partition.js +49 -0
  127. package/dist/src/functions/workflows/all.workflow.js +2 -7
  128. package/dist/src/utils/file-writer.js +14 -2
  129. package/dist/src/utils/pikku-cli-config.d.ts +14 -0
  130. package/dist/src/utils/pikku-cli-config.js +34 -0
  131. package/dist/src/utils/remove-legacy-scaffold-file.d.ts +14 -0
  132. package/dist/src/utils/remove-legacy-scaffold-file.js +23 -0
  133. package/dist/src/utils/serialize-schemas.d.ts +3 -1
  134. package/dist/src/utils/serialize-schemas.js +39 -4
  135. package/dist/tsconfig.tsbuildinfo +1 -1
  136. package/package.json +9 -9
  137. package/dist/.pikku/schemas/schemas/PikkuScenarioFunctionsOutput.schema.json +0 -1
  138. package/dist/src/functions/wirings/scenarios/pikku-command-scenario-functions.d.ts +0 -1
  139. package/dist/src/functions/wirings/scenarios/pikku-command-scenario-functions.js +0 -31
  140. package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.d.ts +0 -10
  141. package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.js +0 -104
  142. package/skills/pikku-addon/SKILL.md +0 -243
  143. package/skills/pikku-addon/references/addon-package-manifest.md +0 -63
  144. package/skills/pikku-ai-agent/SKILL.md +0 -231
  145. package/skills/pikku-ai-vercel/SKILL.md +0 -82
  146. package/skills/pikku-ai-voice/SKILL.md +0 -88
  147. package/skills/pikku-audit/SKILL.md +0 -175
  148. package/skills/pikku-aws/SKILL.md +0 -111
  149. package/skills/pikku-backblaze/SKILL.md +0 -71
  150. package/skills/pikku-better-auth/SKILL.md +0 -298
  151. package/skills/pikku-cli/SKILL.md +0 -198
  152. package/skills/pikku-cli/references/complete-example.md +0 -82
  153. package/skills/pikku-concepts/SKILL.md +0 -250
  154. package/skills/pikku-concepts/references/concept-mapping.md +0 -556
  155. package/skills/pikku-concepts/references/packages.md +0 -29
  156. package/skills/pikku-config/SKILL.md +0 -212
  157. package/skills/pikku-cron/SKILL.md +0 -214
  158. package/skills/pikku-deploy-azure/SKILL.md +0 -71
  159. package/skills/pikku-deploy-cloudflare/SKILL.md +0 -82
  160. package/skills/pikku-deploy-express/SKILL.md +0 -86
  161. package/skills/pikku-deploy-fastify/SKILL.md +0 -73
  162. package/skills/pikku-deploy-lambda/SKILL.md +0 -110
  163. package/skills/pikku-deploy-nextjs/SKILL.md +0 -78
  164. package/skills/pikku-deploy-uws/SKILL.md +0 -88
  165. package/skills/pikku-deps/SKILL.md +0 -98
  166. package/skills/pikku-emails/SKILL.md +0 -163
  167. package/skills/pikku-fabric/SKILL.md +0 -318
  168. package/skills/pikku-fabric-debug/SKILL.md +0 -112
  169. package/skills/pikku-feature/SKILL.md +0 -258
  170. package/skills/pikku-gateway-slack/SKILL.md +0 -115
  171. package/skills/pikku-http/SKILL.md +0 -220
  172. package/skills/pikku-http/references/http-options.md +0 -55
  173. package/skills/pikku-i18n/SKILL.md +0 -137
  174. package/skills/pikku-info/SKILL.md +0 -100
  175. package/skills/pikku-jose/SKILL.md +0 -105
  176. package/skills/pikku-kysely/SKILL.md +0 -219
  177. package/skills/pikku-machine-auth/SKILL.md +0 -183
  178. package/skills/pikku-mcp/SKILL.md +0 -241
  179. package/skills/pikku-middleware/SKILL.md +0 -231
  180. package/skills/pikku-middleware/references/middleware-patterns.md +0 -61
  181. package/skills/pikku-mongodb/SKILL.md +0 -105
  182. package/skills/pikku-n8n-import/SKILL.md +0 -109
  183. package/skills/pikku-n8n-import/SPEC.md +0 -84
  184. package/skills/pikku-n8n-import/references/addon-mapping.md +0 -121
  185. package/skills/pikku-n8n-import/references/code-translation.md +0 -121
  186. package/skills/pikku-n8n-import/references/loops-and-control.md +0 -87
  187. package/skills/pikku-paraglide/SKILL.md +0 -117
  188. package/skills/pikku-permissions/SKILL.md +0 -192
  189. package/skills/pikku-pino/SKILL.md +0 -79
  190. package/skills/pikku-product-second-opinion/README.md +0 -43
  191. package/skills/pikku-product-second-opinion/SKILL.md +0 -158
  192. package/skills/pikku-product-second-opinion/example/sample-report.md +0 -90
  193. package/skills/pikku-product-second-opinion/references/report-template.md +0 -73
  194. package/skills/pikku-queue/SKILL.md +0 -240
  195. package/skills/pikku-react/SKILL.md +0 -212
  196. package/skills/pikku-react-query/SKILL.md +0 -242
  197. package/skills/pikku-realtime/SKILL.md +0 -236
  198. package/skills/pikku-realtime/references/other-routes.md +0 -23
  199. package/skills/pikku-redis/SKILL.md +0 -90
  200. package/skills/pikku-rpc/SKILL.md +0 -171
  201. package/skills/pikku-rtl/SKILL.md +0 -219
  202. package/skills/pikku-scenario/SKILL.md +0 -382
  203. package/skills/pikku-schedule/SKILL.md +0 -57
  204. package/skills/pikku-schema-ajv/SKILL.md +0 -62
  205. package/skills/pikku-schema-cfworker/SKILL.md +0 -63
  206. package/skills/pikku-security/SKILL.md +0 -108
  207. package/skills/pikku-services/SKILL.md +0 -248
  208. package/skills/pikku-services/references/audit-wire-service.md +0 -34
  209. package/skills/pikku-software-archaeology/README.md +0 -70
  210. package/skills/pikku-software-archaeology/SKILL.md +0 -186
  211. package/skills/pikku-software-archaeology/references/blueprint.schema.json +0 -625
  212. package/skills/pikku-software-archaeology/references/pikku-mapping.md +0 -49
  213. package/skills/pikku-software-archaeology/scripts/validate.mjs +0 -173
  214. package/skills/pikku-tag-middleware/SKILL.md +0 -13
  215. package/skills/pikku-template-clone/SKILL.md +0 -40
  216. package/skills/pikku-trigger/SKILL.md +0 -181
  217. package/skills/pikku-versioning/SKILL.md +0 -173
  218. package/skills/pikku-websocket/SKILL.md +0 -243
  219. package/skills/pikku-workflow/SKILL.md +0 -172
  220. package/skills/pikku-workflow/references/workflow-reference.md +0 -63
  221. package/skills/pikku-workflows-client/SKILL.md +0 -150
  222. package/skills/pikku-ws/SKILL.md +0 -47
@@ -1,231 +0,0 @@
1
- ---
2
- name: pikku-ai-agent
3
- description: >-
4
- Use when building AI agents, chatbots, or LLM-powered assistants with Pikku. Covers
5
- pikkuAIAgent, tool registration, memory, streaming, and agent invocation. TRIGGER when: code
6
- uses pikkuAIAgent/runAIAgent/streamAIAgent, user asks about AI agents, chatbots, LLM assistants,
7
- tool-calling agents, or agent memory/streaming. DO NOT TRIGGER when: user asks about MCP tool
8
- exposure (use pikku-mcp) or general function definitions (use pikku-concepts).
9
- installGroups: [core]
10
- ---
11
-
12
- # Pikku AI Agent Wiring
13
-
14
- ## Agent Operating Procedure
15
-
16
- Use this skill as an execution checklist, not reference material.
17
-
18
- 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.
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
- Build AI agents that use Pikku functions as tools. Agents support conversation memory, streaming, and multi-step tool execution.
25
-
26
- ## Before You Start
27
-
28
- ```bash
29
- pikku info functions --verbose # See existing functions that can be used as agent tools
30
- pikku info tags --verbose # Understand project organization
31
- ```
32
-
33
- See `pikku-concepts` for the core mental model.
34
-
35
- ## API Reference
36
-
37
- ### `pikkuAIAgent(config)`
38
-
39
- ```typescript
40
- import { pikkuAIAgent } from '#pikku'
41
-
42
- pikkuAIAgent({
43
- name: string, // Unique agent identifier
44
- description: string, // What the agent does
45
- instructions: string | string[], // System prompt / behavior instructions
46
- model: string, // LLM model (e.g. 'openai/gpt-5-mini')
47
- tools?: PikkuFunc[], // Pikku functions the agent can call
48
- agents?: AIAgentConfig[], // Sub-agents this agent can delegate to
49
- memory?: {
50
- storage?: string, // Service name for persistence (e.g. 'aiStorage')
51
- vector?: string, // Vector store service name
52
- embedder?: string, // Embedding service name
53
- lastMessages?: number, // How many messages to retain in context
54
- workingMemory?: ZodSchema, // Schema for structured working memory
55
- },
56
- maxSteps?: number, // Max tool-call rounds per invocation
57
- temperature?: number, // LLM temperature (0-1)
58
- toolChoice?: 'auto' | 'required' | 'none',
59
- input?: ZodSchema, // Input validation schema
60
- output?: ZodSchema, // Output validation schema
61
- tags?: string[], // For grouping and middleware targeting
62
- aiMiddleware?: PikkuAIMiddlewareHooks[], // AI-specific middleware
63
- middleware?: PikkuMiddleware[],
64
- permissions?: PermissionGroup,
65
- })
66
- ```
67
-
68
- ### `runAIAgent(name, input, options)` — Non-streaming
69
-
70
- ```typescript
71
- const result = await runAIAgent(
72
- agentName,
73
- {
74
- message: string, // User message
75
- threadId: string, // Conversation thread ID
76
- resourceId: string, // User/resource identifier
77
- },
78
- { singletonServices }
79
- )
80
-
81
- result.text // Agent's text response
82
- result.steps // Array of tool calls made
83
- result.usage // Token usage { inputTokens, outputTokens }
84
- ```
85
-
86
- ### `streamAIAgent(name, input, channel, options)` — Streaming
87
-
88
- ```typescript
89
- await streamAIAgent(
90
- agentName,
91
- {
92
- message: string,
93
- threadId: string,
94
- resourceId: string,
95
- },
96
- channel,
97
- { singletonServices }
98
- )
99
-
100
- // Channel receives events:
101
- // { type: 'step-start', stepNumber: 1 }
102
- // { type: 'text-delta', text: '...' }
103
- // { type: 'reasoning-delta', text: '...' }
104
- // { type: 'tool-call', toolCallId, toolName, args }
105
- // { type: 'tool-result', toolCallId, toolName, result }
106
- // { type: 'agent-call', agentName, session, input }
107
- // { type: 'agent-result', agentName, session, result }
108
- // { type: 'approval-request', toolCallId, toolName, args, reason? }
109
- // { type: 'usage', tokens: { input, output }, model }
110
- // { type: 'error', message }
111
- // { type: 'done' }
112
- ```
113
-
114
- ## Usage Patterns
115
-
116
- ### Define an Agent
117
-
118
- ```typescript
119
- const todoAssistant = pikkuAIAgent({
120
- name: 'todo-assistant',
121
- description: 'A helpful assistant that manages todos',
122
- instructions:
123
- 'You help users manage their todo lists. Be concise and helpful.',
124
- model: 'openai/gpt-5-mini',
125
- tools: [listTodos, createTodo, completeTodo],
126
- memory: {
127
- storage: 'aiStorage',
128
- lastMessages: 20,
129
- },
130
- maxSteps: 5,
131
- temperature: 0.7,
132
- })
133
- ```
134
-
135
- ### Invoke Non-Streaming
136
-
137
- ```typescript
138
- const result = await runAIAgent(
139
- 'todo-assistant',
140
- {
141
- message: 'Create a task for tomorrow: buy groceries',
142
- threadId: 'thread-123',
143
- resourceId: 'user-456',
144
- },
145
- { singletonServices }
146
- )
147
-
148
- console.log(result.text) // "I've created a task 'buy groceries' for tomorrow."
149
- console.log(result.steps) // [{ tool: 'createTodo', args: {...}, result: {...} }]
150
- console.log(result.usage) // { inputTokens: 150, outputTokens: 42 }
151
- ```
152
-
153
- ### Stream Responses
154
-
155
- ```typescript
156
- await streamAIAgent(
157
- 'todo-assistant',
158
- {
159
- message: 'Create a task for tomorrow',
160
- threadId: 'thread-123',
161
- resourceId: 'user-456',
162
- },
163
- channel,
164
- { singletonServices }
165
- )
166
- ```
167
-
168
- ## Complete Example
169
-
170
- ```typescript
171
- // functions/todos.functions.ts
172
- export const listTodos = pikkuSessionlessFunc({
173
- description: 'List all todo items',
174
- func: async ({ db }, { status }) => {
175
- return { todos: await db.listTodos(status) }
176
- },
177
- })
178
-
179
- export const createTodo = pikkuFunc({
180
- description: 'Create a new todo item',
181
- func: async ({ db }, { text, priority, dueDate }) => {
182
- return await db.createTodo({ text, priority, dueDate })
183
- },
184
- })
185
-
186
- export const completeTodo = pikkuFunc({
187
- description: 'Mark a todo as complete',
188
- func: async ({ db }, { todoId }) => {
189
- return await db.completeTodo(todoId)
190
- },
191
- })
192
-
193
- // agents/todo-assistant.ts
194
- const todoAssistant = pikkuAIAgent({
195
- name: 'todo-assistant',
196
- description: 'A helpful assistant that manages todos',
197
- instructions: `You help users manage their todo lists.
198
- - Be concise and helpful
199
- - When creating todos, infer priority if not specified
200
- - When listing todos, summarize the results`,
201
- model: 'openai/gpt-5-mini',
202
- tools: [listTodos, createTodo, completeTodo],
203
- memory: {
204
- storage: 'aiStorage',
205
- lastMessages: 20,
206
- },
207
- maxSteps: 5,
208
- temperature: 0.7,
209
- })
210
-
211
- // Wire to HTTP for chat endpoint
212
- wireHTTP({
213
- method: 'post',
214
- route: '/chat',
215
- func: pikkuFunc({
216
- title: 'Chat',
217
- func: async (services, { message, threadId }, wire) => {
218
- const { session } = wire
219
- return await runAIAgent(
220
- 'todo-assistant',
221
- {
222
- message,
223
- threadId,
224
- resourceId: session.userId,
225
- },
226
- { singletonServices: services }
227
- )
228
- },
229
- }),
230
- })
231
- ```
@@ -1,82 +0,0 @@
1
- ---
2
- name: pikku-ai-vercel
3
- description: >-
4
- Use when setting up AI agent execution with the Vercel AI SDK in a Pikku app. Covers
5
- VercelAIAgentRunner for streaming and non-streaming AI agent steps. TRIGGER when: code uses
6
- VercelAIAgentRunner, user asks about Vercel AI SDK integration, AI agent runners, or
7
- @pikku/ai-vercel. DO NOT TRIGGER when: user asks about AI agent wiring (use pikku-ai-agent) or
8
- voice I/O (use pikku-ai-voice).
9
- installGroups: [core]
10
- ---
11
-
12
- # Pikku AI Vercel (Agent Runner)
13
-
14
- ## Agent Operating Procedure
15
-
16
- Use this skill as an execution checklist, not reference material.
17
-
18
- 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.
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/ai-vercel` provides an AI agent runner backed by the [Vercel AI SDK](https://sdk.vercel.ai/). Implements `AIAgentRunnerService` from `@pikku/core`.
25
-
26
- ## Installation
27
-
28
- ```bash
29
- yarn add @pikku/ai-vercel ai @ai-sdk/openai # or any AI SDK provider
30
- ```
31
-
32
- ## API Reference
33
-
34
- ### `VercelAIAgentRunner`
35
-
36
- ```typescript
37
- import { VercelAIAgentRunner } from '@pikku/ai-vercel'
38
-
39
- const runner = new VercelAIAgentRunner(
40
- providers: Record<string, any> // Map of provider name → Vercel AI SDK provider instance
41
- )
42
- ```
43
-
44
- **Methods:**
45
-
46
- - `stream(params: AIAgentRunnerParams, channel: AIStreamChannel): Promise<AIAgentStepResult>` — Stream AI responses with tool calls
47
- - `run(params: AIAgentRunnerParams): Promise<AIAgentStepResult>` — Execute a single AI step (non-streaming)
48
-
49
- The `providers` map lets you register multiple AI providers. Model strings use `provider:model` format (e.g., `"openai:gpt-4o"`).
50
-
51
- ## Usage Patterns
52
-
53
- ### Basic Setup
54
-
55
- ```typescript
56
- import { VercelAIAgentRunner } from '@pikku/ai-vercel'
57
- import { openai } from '@ai-sdk/openai'
58
- import { anthropic } from '@ai-sdk/anthropic'
59
-
60
- const createSingletonServices = pikkuServices(async (config) => {
61
- const aiRunner = new VercelAIAgentRunner({
62
- openai: openai,
63
- anthropic: anthropic,
64
- })
65
- return { config, aiRunner }
66
- })
67
- ```
68
-
69
- ### With AI Agent Wiring
70
-
71
- ```typescript
72
- import { wireAIAgent } from '@pikku/core/ai-agent'
73
-
74
- wireAIAgent({
75
- name: 'assistant',
76
- model: 'openai:gpt-4o',
77
- systemPrompt: 'You are a helpful assistant.',
78
- func: myAgentFunc,
79
- })
80
- ```
81
-
82
- The `VercelAIAgentRunner` is used internally by Pikku's AI agent wiring to execute model calls. See `pikku-ai-agent` for wiring details.
@@ -1,88 +0,0 @@
1
- ---
2
- name: pikku-ai-voice
3
- description: >-
4
- Use when adding voice input (speech-to-text) or voice output (text-to-speech) to AI agents in a
5
- Pikku app. Covers voiceInput/voiceOutput middleware hooks and STT/TTS service interfaces.
6
- TRIGGER when: code uses voiceInput, voiceOutput, STTService, TTSService, or user asks about
7
- voice, speech-to-text, text-to-speech, or @pikku/ai-voice. DO NOT TRIGGER when: user asks about
8
- AI agent wiring (use pikku-ai-agent) or Vercel AI SDK (use pikku-ai-vercel).
9
- ---
10
-
11
- # Pikku AI Voice (Speech I/O)
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
- `@pikku/ai-voice` provides speech-to-text and text-to-speech middleware hooks for Pikku AI agents.
24
-
25
- ## Installation
26
-
27
- ```bash
28
- yarn add @pikku/ai-voice
29
- ```
30
-
31
- ## API Reference
32
-
33
- ### Service Interfaces
34
-
35
- ```typescript
36
- interface STTService {
37
- transcribe(
38
- audio: Uint8Array,
39
- options?: { language?: string; format?: string }
40
- ): Promise<string>
41
- }
42
-
43
- interface TTSService {
44
- synthesize(
45
- text: string,
46
- options?: { voice?: string; format?: string }
47
- ): Promise<Uint8Array>
48
- synthesizeStream?(
49
- text: string,
50
- options?: { voice?: string; format?: string }
51
- ): AsyncIterable<Uint8Array>
52
- }
53
- ```
54
-
55
- ### Middleware Hooks
56
-
57
- ```typescript
58
- import { voiceInput, voiceOutput } from '@pikku/ai-voice'
59
-
60
- voiceInput(config?: { language?: string }): PikkuAIMiddlewareHooks
61
- voiceOutput(config?: { format?: string; voice?: string }): PikkuAIMiddlewareHooks
62
- ```
63
-
64
- These return middleware hooks that can be attached to AI agent wirings to automatically transcribe audio input and synthesize audio output.
65
-
66
- ## Usage Patterns
67
-
68
- ### Voice-Enabled Agent
69
-
70
- ```typescript
71
- import { voiceInput, voiceOutput } from '@pikku/ai-voice'
72
- import { wireAIAgent } from '@pikku/core/ai-agent'
73
-
74
- wireAIAgent({
75
- name: 'voice-assistant',
76
- model: 'openai:gpt-4o',
77
- systemPrompt: 'You are a voice assistant.',
78
- middlewareHooks: [
79
- voiceInput({ language: 'en' }),
80
- voiceOutput({ voice: 'alloy', format: 'mp3' }),
81
- ],
82
- func: myAgentFunc,
83
- })
84
- ```
85
-
86
- ### Custom STT/TTS Services
87
-
88
- Implement the `STTService` and `TTSService` interfaces with your provider (OpenAI Whisper, ElevenLabs, etc.) and register them as singleton services.
@@ -1,175 +0,0 @@
1
- ---
2
- name: pikku-audit
3
- description: >-
4
- Use when adding audit / activity-history / change-tracking to a Pikku app, or when a function
5
- needs to record who changed what. Covers the built-in AuditService sink, the per-invocation
6
- auditLog buffer (createInvocationAudit / pikkuWireServices), the `audit: true` function flag,
7
- explicit `auditLog.write()` domain events, automatic query-level capture via
8
- createAuditedKysely, and the durable KyselyAuditService sink. TRIGGER when: user asks for an
9
- audit log, change history, activity feed, "who did this", or a custom audit/history table; code
10
- uses auditLog, createInvocationAudit, createAuditedKysely, or AuditService. DO NOT TRIGGER when:
11
- user wants app logging/telemetry (use the logger) or DB migrations in general (use
12
- pikku-kysely).
13
- installGroups: [core]
14
- ---
15
-
16
- # Pikku Audit
17
-
18
- ## Agent Operating Procedure
19
-
20
- Use this skill as an execution checklist, not reference material.
21
-
22
- 1. Discover before editing. Check how services are wired (`services.ts`) and whether an `audit` table migration exists before adding audit calls.
23
- 2. NEVER hand-roll a custom `audit_log` / history table with direct `insertInto('audit_log')` calls. The framework owns audit. A bespoke table drifts from the runtime (missing actor/trace/wire context, hand-written CHECK constraints that reject valid events, no prod sink). Use the built-in path below.
24
- 3. Make the smallest source change: mark the function `audit: true`, inject `auditLog`, call `auditLog.write(...)`. Do not invent a new service.
25
- 4. Validate with `pikku all` (regenerates the service flags) then run the app / e2e.
26
-
27
- ## Mental model — two layers
28
-
29
- - **`audit` (singleton `AuditService`)** — the durable **sink**. Write-only: `audit(event)` + optional `write(batch)`. Defaults to `NoopAuditService` (discards). Swap in a real sink to persist (see Sinks).
30
- - **`auditLog` (wire service `AuditLog`)** — a per-invocation **buffer** built from the sink via `createInvocationAudit(audit, wire)`. `auditLog.write(input)` enriches each event with `functionId`, `wireType`, `traceId`, `occurredAt`, and `actor` (from the wire session) automatically, then flushes to the sink when the invocation ends.
31
-
32
- An event only persists when the function opts in with **`audit: true`** — otherwise `auditLog` is a no-op that warns.
33
-
34
- ## Wiring (services.ts)
35
-
36
- ```typescript
37
- import { NoopAuditService, createInvocationAudit } from '@pikku/core/services'
38
-
39
- export const createSingletonServices = pikkuServices(async (config, existing) => {
40
- // Prod platforms may inject a queue-backed sink as existing.audit.
41
- const audit = existing?.audit ?? new NoopAuditService()
42
- return { ...existing, config, /* ... */ audit }
43
- })
44
-
45
- // auditLog is created per invocation from the sink. Returned unconditionally so
46
- // a write from a function that forgot `audit: true` warns instead of vanishing.
47
- export const createWireServices = pikkuWireServices(async (services, wire) => {
48
- if (!services.audit) return {}
49
- return { auditLog: createInvocationAudit(services.audit, wire) }
50
- })
51
- ```
52
-
53
- `audit` and `auditLog` are already declared on `CoreSingletonServices` / `CoreServices`, so no type change is needed to inject them.
54
-
55
- ## Recording events — explicit domain events (default)
56
-
57
- Mark the function `audit: true` and call `auditLog?.write(...)`. Domain history goes in `metadata`; the actor is derived from the session, so do NOT pass it manually.
58
-
59
- ```typescript
60
- export const cancelInvoice = pikkuFunc({
61
- audit: true, // REQUIRED — else write() is a no-op
62
- input: CancelInvoiceInput,
63
- output: CancelInvoiceOutput,
64
- func: async ({ kysely, auditLog }, { invoiceId }, { session }) => {
65
- const inv = await kysely.selectFrom('invoice')/* ... */.executeTakeFirstOrThrow()
66
- await kysely.updateTable('invoice').set({ status: 'cancelled' })/* ... */.execute()
67
-
68
- await auditLog?.write({
69
- type: 'invoice.update',
70
- source: 'explicit',
71
- metadata: {
72
- entity: 'invoice',
73
- entityId: invoiceId,
74
- action: 'update',
75
- field: 'status',
76
- before: inv.status,
77
- after: 'cancelled',
78
- },
79
- })
80
- return { ok: true }
81
- },
82
- })
83
- ```
84
-
85
- For a **system/cron** function there is no session, so `actor` is simply absent (nulls out `actor_user_id`). Use `pikkuVoidFunc({ audit: true, func: async ({ auditLog }) => { ... } })` — the void/config form accepts `audit`.
86
-
87
- Helper functions (in `lib/`) that record audit take `auditLog?: AuditLog` in their services arg and are passed it from a `audit: true` caller — never import a service.
88
-
89
- Note: events buffer and flush on invocation close. For a write inside a DB transaction, call `auditLog.write()` **after** the transaction commits — the sink is not part of your `trx`, so only record committed state.
90
-
91
- ## Recording events — automatic query capture (optional)
92
-
93
- To audit every DB mutation without explicit calls, wrap kysely so each query emits an event. Note this captures table/column changes only — it cannot see semantic events that do no DB write (e.g. "email sent"), so combine with explicit writes when you need those.
94
-
95
- ```typescript
96
- import { createAuditedKysely } from '@pikku/kysely'
97
- export const createWireServices = pikkuWireServices(async (services, wire) => {
98
- if (!services.audit) return {}
99
- const auditLog = createInvocationAudit(services.audit, wire)
100
- return { auditLog, kysely: createAuditedKysely(services.kysely, { audit: auditLog }) }
101
- })
102
- ```
103
-
104
- ## Sinks
105
-
106
- - **`NoopAuditService`** (`@pikku/core/services`) — default; discards events. Fine when audit isn't needed.
107
- - **`KyselyAuditService`** (`@pikku/kysely`) — durable: persists events to an `audit` table via kysely. Use as the local/dev sink so events are queryable without a platform queue: `new KyselyAuditService(kysely)`.
108
- - **Platform-injected sink** — a deploy platform may inject its own queue-backed `audit` (hence the `existing?.audit ??` fallback above). Its rows land in the same `audit` table shape.
109
-
110
- ### The `audit` table (add this migration if you persist audit)
111
-
112
- ```sql
113
- CREATE TABLE IF NOT EXISTS audit (
114
- audit_id TEXT NOT NULL PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
115
- occurred_at TEXT NOT NULL DEFAULT (datetime('now')),
116
- type TEXT NOT NULL,
117
- source TEXT NOT NULL DEFAULT 'auto',
118
- outcome TEXT,
119
- function_id TEXT,
120
- wire_type TEXT,
121
- trace_id TEXT,
122
- transaction_id TEXT,
123
- query_id TEXT,
124
- actor_user_id TEXT,
125
- actor_org_id TEXT,
126
- tables TEXT, -- JSON: table names touched (auto capture)
127
- changed_cols TEXT, -- JSON: changed column names (auto capture)
128
- event TEXT, -- custom event label
129
- old TEXT, -- JSON: previous values
130
- data TEXT -- JSON: metadata / new values / event payload
131
- );
132
- ```
133
-
134
- `auditLog.write({ metadata })` lands in the `data` column. Read history back by filtering it (SQLite `json_extract`, Postgres `->>`):
135
-
136
- ```typescript
137
- const rows = await kysely
138
- .selectFrom('audit')
139
- .leftJoin('user', 'user.id', 'audit.actorUserId')
140
- .where(sql<boolean>`json_extract(audit.data, '$.entity') = 'invoice'`)
141
- .where(sql<boolean>`json_extract(audit.data, '$.entityId') = ${invoiceId}`)
142
- .orderBy('audit.occurredAt', 'desc')
143
- .select([
144
- 'audit.auditId',
145
- sql<string>`json_extract(audit.data, '$.action')`.as('action'),
146
- 'audit.occurredAt as at',
147
- 'user.name as userName',
148
- ])
149
- .execute()
150
- ```
151
-
152
- ## AuditEvent shape
153
-
154
- ```typescript
155
- type AuditEvent = {
156
- type: string // e.g. 'invoice.update'
157
- source: 'auto' | 'explicit'
158
- occurredAt: string // auto-filled by auditLog
159
- outcome?: string
160
- functionId?; wireType?; wireId?; traceId?; transactionId?; queryId? // auto
161
- actor?: { userId?; orgId? } // auto from wire session
162
- input?: unknown
163
- metadata?: Record<string, unknown> // your domain payload
164
- }
165
- ```
166
-
167
- `auditLog.write()` takes `Omit<AuditEvent, 'occurredAt'>` — you only supply `type`, `source`, and `metadata` (and `actor` if overriding the session default).
168
-
169
- ## Do / Don't
170
-
171
- - DO mark recording functions `audit: true`, inject `auditLog`, and call `auditLog.write({ type, source: 'explicit', metadata })`.
172
- - DO let the actor come from the session — don't thread `userId` into metadata for the actor.
173
- - DON'T create a custom `audit_log`/history table or `insertInto('audit_log')` by hand.
174
- - DON'T annotate the function's I/O from audit; audit is a side channel, not part of `input`/`output`.
175
- - DON'T write audit inside a DB transaction expecting rollback — record after commit.
@@ -1,111 +0,0 @@
1
- ---
2
- name: pikku-aws
3
- description: >-
4
- Use when setting up AWS services (S3, SQS, Secrets Manager) in a Pikku app. Covers S3Content for
5
- file storage, SQSQueueService for queues, and AWSSecrets for secret management. TRIGGER when:
6
- code uses S3Content, SQSQueueService, AWSSecrets, or user asks about AWS integration, S3
7
- uploads, SQS queues, or AWS Secrets Manager with Pikku. DO NOT TRIGGER when: user asks about AWS
8
- Lambda runtime (use pikku-deploy-lambda).
9
- ---
10
-
11
- # Pikku AWS Services
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
- `@pikku/aws-services` provides AWS-backed implementations of Pikku's content, queue, and secret service interfaces.
24
-
25
- ## Installation
26
-
27
- ```bash
28
- yarn add @pikku/aws-services
29
- ```
30
-
31
- ## API Reference
32
-
33
- ### `S3Content` (File Storage)
34
-
35
- ```typescript
36
- import { S3Content } from '@pikku/aws-services'
37
-
38
- const content = new S3Content(
39
- config: S3ContentConfig,
40
- logger: Logger,
41
- signConfig: { keyPairId: string; privateKey: string }
42
- )
43
- ```
44
-
45
- **Methods:**
46
-
47
- - `signURL(url: string, dateLessThan: Date, dateGreaterThan?: Date): Promise<string>` — Sign a CloudFront URL
48
- - `signContentKey(key: string, dateLessThan: Date, dateGreaterThan?: Date): Promise<string>` — Sign a content key
49
- - `getUploadURL(Key: string, ContentType: string): Promise<{ uploadUrl, assetKey }>` — Get presigned upload URL
50
- - `readFile(Key: string): Promise<ReadableStream>` — Read file as stream
51
- - `readFileAsBuffer(Key: string): Promise<Buffer>` — Read file as buffer
52
- - `writeFile(Key: string, stream: ReadableStream): Promise<boolean>` — Write file from stream
53
- - `copyFile(Key: string, fromAbsolutePath: string): Promise<boolean>` — Copy local file to S3
54
- - `deleteFile(Key: string): Promise<boolean>` — Delete file
55
-
56
- ### `SQSQueueService` (Queue)
57
-
58
- ```typescript
59
- import { SQSQueueService } from '@pikku/aws-services'
60
-
61
- const queue = new SQSQueueService(config: SQSQueueServiceConfig)
62
- ```
63
-
64
- Implements `QueueService`. Note: `supportsResults = false` — job status tracking is not supported.
65
-
66
- **Methods:**
67
-
68
- - `add<T>(queueName: string, data: T, options?: JobOptions): Promise<string>` — Enqueue a message
69
-
70
- ### `AWSSecrets` (Secrets Manager)
71
-
72
- ```typescript
73
- import { AWSSecrets } from '@pikku/aws-services'
74
-
75
- const secrets = new AWSSecrets(config: AWSConfig)
76
- ```
77
-
78
- **Methods:**
79
-
80
- - `getSecret<T = string>(SecretId: string): Promise<T>` — Get a secret value; a JSON secret is parsed automatically, so pass a shape as `T` (a non-JSON value comes back as the raw string)
81
- - `getSecrets<T>(SecretIds: (keyof T & string)[]): Promise<Partial<T>>` — Batch fetch; missing keys are omitted rather than thrown
82
- - `hasSecret(SecretId: string): Promise<boolean>` — Check if secret exists
83
- - `setSecret` / `deleteSecret` — **not implemented** for `AWSSecrets`; it throws. Manage AWS secrets out of band.
84
-
85
- ## Usage Patterns
86
-
87
- ### S3 Content Service
88
-
89
- ```typescript
90
- const createSingletonServices = pikkuServices(async (config) => {
91
- const logger = new PinoLogger()
92
- const content = new S3Content(
93
- { bucket: config.s3Bucket, region: config.awsRegion },
94
- logger,
95
- { keyPairId: config.cfKeyPairId, privateKey: config.cfPrivateKey }
96
- )
97
- return { config, logger, content }
98
- })
99
- ```
100
-
101
- ### SQS Queue
102
-
103
- ```typescript
104
- const createSingletonServices = pikkuServices(async (config) => {
105
- const queue = new SQSQueueService({
106
- region: config.awsRegion,
107
- queueUrlPrefix: config.sqsUrlPrefix,
108
- })
109
- return { config, queue }
110
- })
111
- ```