@pikku/skills 0.12.1

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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/dist/index.d.ts +22 -0
  4. package/dist/index.js +74 -0
  5. package/dist/skills.gen.d.ts +1 -0
  6. package/dist/skills.gen.js +7 -0
  7. package/package.json +36 -0
  8. package/skills/pikku-addon/SKILL.md +243 -0
  9. package/skills/pikku-addon/references/addon-package-manifest.md +63 -0
  10. package/skills/pikku-ai-agent/SKILL.md +231 -0
  11. package/skills/pikku-ai-vercel/SKILL.md +82 -0
  12. package/skills/pikku-ai-voice/SKILL.md +88 -0
  13. package/skills/pikku-audit/SKILL.md +175 -0
  14. package/skills/pikku-aws/SKILL.md +111 -0
  15. package/skills/pikku-backblaze/SKILL.md +71 -0
  16. package/skills/pikku-better-auth/SKILL.md +298 -0
  17. package/skills/pikku-cli/SKILL.md +198 -0
  18. package/skills/pikku-cli/references/complete-example.md +82 -0
  19. package/skills/pikku-concepts/SKILL.md +250 -0
  20. package/skills/pikku-concepts/references/concept-mapping.md +556 -0
  21. package/skills/pikku-concepts/references/packages.md +29 -0
  22. package/skills/pikku-config/SKILL.md +212 -0
  23. package/skills/pikku-cron/SKILL.md +214 -0
  24. package/skills/pikku-deploy-azure/SKILL.md +71 -0
  25. package/skills/pikku-deploy-cloudflare/SKILL.md +82 -0
  26. package/skills/pikku-deploy-express/SKILL.md +86 -0
  27. package/skills/pikku-deploy-fastify/SKILL.md +73 -0
  28. package/skills/pikku-deploy-lambda/SKILL.md +110 -0
  29. package/skills/pikku-deploy-nextjs/SKILL.md +78 -0
  30. package/skills/pikku-deploy-uws/SKILL.md +88 -0
  31. package/skills/pikku-deps/SKILL.md +98 -0
  32. package/skills/pikku-emails/SKILL.md +163 -0
  33. package/skills/pikku-fabric/SKILL.md +318 -0
  34. package/skills/pikku-fabric-debug/SKILL.md +112 -0
  35. package/skills/pikku-feature/SKILL.md +258 -0
  36. package/skills/pikku-gateway-slack/SKILL.md +115 -0
  37. package/skills/pikku-http/SKILL.md +220 -0
  38. package/skills/pikku-http/references/http-options.md +55 -0
  39. package/skills/pikku-i18n/SKILL.md +137 -0
  40. package/skills/pikku-info/SKILL.md +100 -0
  41. package/skills/pikku-jose/SKILL.md +105 -0
  42. package/skills/pikku-kysely/SKILL.md +219 -0
  43. package/skills/pikku-machine-auth/SKILL.md +183 -0
  44. package/skills/pikku-mcp/SKILL.md +241 -0
  45. package/skills/pikku-middleware/SKILL.md +231 -0
  46. package/skills/pikku-middleware/references/middleware-patterns.md +61 -0
  47. package/skills/pikku-mongodb/SKILL.md +105 -0
  48. package/skills/pikku-n8n-import/SKILL.md +109 -0
  49. package/skills/pikku-n8n-import/SPEC.md +84 -0
  50. package/skills/pikku-n8n-import/references/addon-mapping.md +121 -0
  51. package/skills/pikku-n8n-import/references/code-translation.md +121 -0
  52. package/skills/pikku-n8n-import/references/loops-and-control.md +87 -0
  53. package/skills/pikku-paraglide/SKILL.md +117 -0
  54. package/skills/pikku-permissions/SKILL.md +192 -0
  55. package/skills/pikku-pino/SKILL.md +79 -0
  56. package/skills/pikku-product-second-opinion/README.md +43 -0
  57. package/skills/pikku-product-second-opinion/SKILL.md +158 -0
  58. package/skills/pikku-product-second-opinion/example/sample-report.md +90 -0
  59. package/skills/pikku-product-second-opinion/references/report-template.md +73 -0
  60. package/skills/pikku-queue/SKILL.md +240 -0
  61. package/skills/pikku-react/SKILL.md +212 -0
  62. package/skills/pikku-react-query/SKILL.md +242 -0
  63. package/skills/pikku-realtime/SKILL.md +236 -0
  64. package/skills/pikku-realtime/references/other-routes.md +23 -0
  65. package/skills/pikku-redis/SKILL.md +90 -0
  66. package/skills/pikku-rpc/SKILL.md +171 -0
  67. package/skills/pikku-rtl/SKILL.md +219 -0
  68. package/skills/pikku-scenario/SKILL.md +382 -0
  69. package/skills/pikku-schedule/SKILL.md +57 -0
  70. package/skills/pikku-schema-ajv/SKILL.md +62 -0
  71. package/skills/pikku-schema-cfworker/SKILL.md +63 -0
  72. package/skills/pikku-security/SKILL.md +108 -0
  73. package/skills/pikku-services/SKILL.md +248 -0
  74. package/skills/pikku-services/references/audit-wire-service.md +34 -0
  75. package/skills/pikku-software-archaeology/README.md +70 -0
  76. package/skills/pikku-software-archaeology/SKILL.md +186 -0
  77. package/skills/pikku-software-archaeology/references/blueprint.schema.json +625 -0
  78. package/skills/pikku-software-archaeology/references/pikku-mapping.md +49 -0
  79. package/skills/pikku-software-archaeology/scripts/validate.mjs +173 -0
  80. package/skills/pikku-tag-middleware/SKILL.md +13 -0
  81. package/skills/pikku-template-clone/SKILL.md +40 -0
  82. package/skills/pikku-trigger/SKILL.md +181 -0
  83. package/skills/pikku-versioning/SKILL.md +173 -0
  84. package/skills/pikku-websocket/SKILL.md +243 -0
  85. package/skills/pikku-workflow/SKILL.md +172 -0
  86. package/skills/pikku-workflow/references/workflow-reference.md +63 -0
  87. package/skills/pikku-workflows-client/SKILL.md +150 -0
  88. package/skills/pikku-ws/SKILL.md +47 -0
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@pikku/skills",
3
+ "version": "0.12.1",
4
+ "description": "The Pikku agent skills — the instruction set coding agents read to build, wire and deploy Pikku projects",
5
+ "author": "yasser.fadl@gmail.com",
6
+ "license": "MIT",
7
+ "module": "dist/index.js",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "type": "module",
11
+ "scripts": {
12
+ "embed": "node scripts/embed.mjs",
13
+ "tsc": "yarn embed && tsc",
14
+ "build": "yarn embed && tsc -b",
15
+ "ncu": "npx npm-check-updates",
16
+ "test": "bash run-tests.sh",
17
+ "test:watch": "bash run-tests.sh --watch",
18
+ "test:coverage": "bash run-tests.sh --coverage",
19
+ "prepublishOnly": "yarn build"
20
+ },
21
+ "exports": {
22
+ ".": "./dist/index.js"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "skills"
27
+ ],
28
+ "devDependencies": {
29
+ "@types/node": "^24.11.0",
30
+ "typescript": "^6.0.3",
31
+ "yaml": "^2.8.2"
32
+ },
33
+ "engines": {
34
+ "node": ">=24"
35
+ }
36
+ }
@@ -0,0 +1,243 @@
1
+ ---
2
+ name: pikku-addon
3
+ description: >-
4
+ Use when creating or consuming reusable function packages (addons) in Pikku. Covers wireAddon,
5
+ addon(), pikkuAddonServices, pikkuAddonWireServices, addon package structure, and cross-project
6
+ function sharing. TRIGGER when: code uses wireAddon/addon()/pikkuAddonServices, user asks about
7
+ addons, reusable function packages, cross-project sharing, or addon package structure. DO NOT
8
+ TRIGGER when: user asks about internal function composition (use pikku-rpc) or general function
9
+ definitions (use pikku-concepts).
10
+ installGroups: [core]
11
+ ---
12
+
13
+ # Pikku Addons
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
+ Addons are reusable Pikku function packages that can be shared across projects. They bundle functions, services, secrets, and variables into a self-contained NPM package.
26
+
27
+ ## Before You Start
28
+
29
+ ```bash
30
+ pikku info functions --verbose # See existing functions and addons
31
+ pikku info tags --verbose # Understand project organization
32
+ ```
33
+
34
+ See `pikku-concepts` for the core mental model.
35
+
36
+ ## API Reference
37
+
38
+ ### `wireAddon(config)`
39
+
40
+ Register an addon in the consuming project:
41
+
42
+ ```typescript
43
+ import { wireAddon } from '#pikku'
44
+
45
+ wireAddon({
46
+ name: string, // Namespace for addon functions (e.g. 'todos')
47
+ package: string, // NPM package name (e.g. '@pikku/addon-todos')
48
+ rpcEndpoint?: string, // Optional remote RPC endpoint for distributed execution
49
+ auth?: boolean, // Whether addon functions require authentication
50
+ tags?: string[], // Tags applied to all addon functions
51
+ secretOverrides?: Record<string, string>, // Remap secret names
52
+ variableOverrides?: Record<string, string>, // Remap variable names
53
+ })
54
+ ```
55
+
56
+ ### `addon(name)`
57
+
58
+ Type-safe reference to an addon function — use when wiring to HTTP, agents, etc.:
59
+
60
+ ```typescript
61
+ import { addon } from '#pikku'
62
+
63
+ addon('todos:addTodo') // Returns a typed function config
64
+ addon('emails:sendEmail') // Namespace:functionName format
65
+ ```
66
+
67
+ ### `pikkuAddonServices(factory)`
68
+
69
+ Define singleton services for an addon package (created once at startup):
70
+
71
+ ```typescript
72
+ import { pikkuAddonServices } from '#pikku'
73
+
74
+ export const createSingletonServices = pikkuAddonServices(
75
+ async (config, parentServices?) => {
76
+ // parentServices: logger, variables, secrets from the consuming app
77
+ return {
78
+ myStore: new MyStore(),
79
+ }
80
+ }
81
+ )
82
+ ```
83
+
84
+ ### `pikkuAddonWireServices(factory)`
85
+
86
+ Define per-request services for an addon package (created fresh per HTTP request, queue job, etc.):
87
+
88
+ ```typescript
89
+ import { pikkuAddonWireServices } from '#pikku'
90
+
91
+ export const createWireServices = pikkuAddonWireServices(
92
+ async (singletonServices, wire) => {
93
+ // wire: transport context (http, channel, session, etc.)
94
+ const authHeader = wire.http?.request?.header('authorization')
95
+ return {
96
+ myService: new MyService(authHeader),
97
+ }
98
+ }
99
+ )
100
+ ```
101
+
102
+ ## Creating an Addon
103
+
104
+ ### Scaffold
105
+
106
+ ```bash
107
+ npx pikku new addon
108
+ ```
109
+
110
+ This generates `package.json` (exports `.pikku/*` + `dist/`), `pikku.config.json` (`addon: true`), `tsconfig.json` (`#pikku` path mapping), `src/services.ts`, `src/functions/`, and `types/application-types.d.ts`. For the full file contents/exports you rarely hand-edit, read `references/addon-package-manifest.md`.
111
+
112
+ ### Services
113
+
114
+ ```typescript
115
+ // src/services.ts
116
+ import { pikkuAddonServices, pikkuAddonWireServices } from '#pikku'
117
+ import { TodoStore } from './todo-store.service.js'
118
+
119
+ export const createSingletonServices = pikkuAddonServices(async () => {
120
+ const todoStore = new TodoStore()
121
+ return { todoStore }
122
+ })
123
+
124
+ // Optional — only needed if addon functions require per-request services
125
+ export const createWireServices = pikkuAddonWireServices(
126
+ async (singletonServices, wire) => {
127
+ return {}
128
+ }
129
+ )
130
+ ```
131
+
132
+ ### Functions
133
+
134
+ ```typescript
135
+ // src/functions/addTodo.function.ts
136
+ import { z } from 'zod'
137
+ import { pikkuSessionlessFunc } from '#pikku'
138
+
139
+ const AddTodoInput = z.object({ title: z.string() })
140
+ const AddTodoOutput = z.object({ id: z.string(), title: z.string() })
141
+
142
+ export const addTodo = pikkuSessionlessFunc({
143
+ description: 'Adds a new todo',
144
+ input: AddTodoInput,
145
+ output: AddTodoOutput,
146
+ func: async ({ todoStore }, { title }) => {
147
+ return todoStore.add(title)
148
+ },
149
+ })
150
+ ```
151
+
152
+ Optional approval gating (e.g. for agent tools) — add `approvalRequired: true` plus an `approvalDescription` resolver:
153
+
154
+ ```typescript
155
+ approvalRequired: true,
156
+ approvalDescription: async (_services, { title }) => `Add a todo called "${title}"`,
157
+ ```
158
+
159
+ ### Build
160
+
161
+ ```bash
162
+ npx pikku all # Generate types
163
+ yarn tsc # Compile TypeScript
164
+ cp -r .pikku dist/ # Include generated files in dist
165
+ ```
166
+
167
+ ## Consuming an Addon
168
+
169
+ ### Install & Register
170
+
171
+ ```bash
172
+ yarn add @my-org/addon-todos
173
+ ```
174
+
175
+ ```typescript
176
+ // wirings/todos.wirings.ts
177
+ import { wireAddon } from '#pikku'
178
+
179
+ wireAddon({ name: 'todos', package: '@my-org/addon-todos' })
180
+ ```
181
+
182
+ After registration, run `npx pikku all` to generate types for the addon's functions.
183
+
184
+ ### Call via RPC
185
+
186
+ ```typescript
187
+ export const myFunc = pikkuFunc({
188
+ func: async (_services, data, { rpc }) => {
189
+ const todo = await rpc.invoke('todos:addTodo', { title: 'Buy milk' })
190
+ return todo
191
+ },
192
+ })
193
+ ```
194
+
195
+ ### Wire to HTTP
196
+
197
+ ```typescript
198
+ import { wireHTTP, addon } from '#pikku'
199
+
200
+ wireHTTP({
201
+ method: 'get',
202
+ route: '/todos',
203
+ func: addon('todos:listTodos'),
204
+ auth: false,
205
+ })
206
+ ```
207
+
208
+ Or batch multiple addon routes with `defineHTTPRoutes` + `wireHTTPRoutes`:
209
+
210
+ ```typescript
211
+ import { wireHTTPRoutes, defineHTTPRoutes, addon } from '#pikku'
212
+
213
+ const todoRoutes = defineHTTPRoutes({
214
+ tags: ['todos'],
215
+ auth: false,
216
+ routes: {
217
+ list: { method: 'get', route: '/todos', func: addon('todos:listTodos') },
218
+ add: { method: 'post', route: '/todos', func: addon('todos:addTodo') },
219
+ },
220
+ })
221
+
222
+ wireHTTPRoutes({ basePath: '/api', routes: { todos: todoRoutes } })
223
+ ```
224
+
225
+ ### Use in AI Agents
226
+
227
+ ```typescript
228
+ import { pikkuAIAgent } from '#pikku'
229
+ import { addon } from '#pikku'
230
+
231
+ export const todoAgent = pikkuAIAgent({
232
+ name: 'todo-agent',
233
+ description: 'Manages a todo list',
234
+ instructions: 'You help users manage their todos.',
235
+ model: 'openai/gpt-4o',
236
+ tools: [
237
+ addon('todos:listTodos'),
238
+ addon('todos:addTodo'),
239
+ addon('todos:deleteTodo'),
240
+ ],
241
+ maxSteps: 5,
242
+ })
243
+ ```
@@ -0,0 +1,63 @@
1
+ # Addon Package Manifest Reference
2
+
3
+ `npx pikku new addon` scaffolds these files. You rarely hand-edit them — consult this when wiring exports or config by hand.
4
+
5
+ ## Package Structure
6
+
7
+ ```text
8
+ my-addon/
9
+ ├── package.json # Exports .pikku/* and dist/
10
+ ├── pikku.config.json # addon: true + metadata
11
+ ├── tsconfig.json # #pikku path mapping
12
+ ├── src/
13
+ │ ├── services.ts # createSingletonServices (required)
14
+ │ └── functions/
15
+ │ └── *.function.ts # Function definitions
16
+ ├── types/
17
+ │ └── application-types.d.ts # SingletonServices interface
18
+ └── .pikku/ # Generated (gitignored)
19
+ ```
20
+
21
+ ## pikku.config.json
22
+
23
+ ```json
24
+ {
25
+ "tsconfig": "./tsconfig.json",
26
+ "srcDirectories": ["src", "types"],
27
+ "outDir": "./.pikku",
28
+ "addon": true,
29
+ "node": {
30
+ "displayName": "My Addon",
31
+ "description": "What this addon does",
32
+ "categories": ["General"]
33
+ }
34
+ }
35
+ ```
36
+
37
+ ## package.json (key fields)
38
+
39
+ ```json
40
+ {
41
+ "name": "@my-org/addon-todos",
42
+ "imports": {
43
+ "#pikku": "./.pikku/pikku-types.gen.ts",
44
+ "#pikku/*": "./.pikku/*"
45
+ },
46
+ "exports": {
47
+ ".": { "types": "./dist/src/index.d.ts", "import": "./dist/src/index.js" },
48
+ "./.pikku/*": "./.pikku/*",
49
+ "./.pikku/pikku-metadata.gen.json": "./.pikku/pikku-metadata.gen.json",
50
+ "./.pikku/rpc/pikku-rpc-wirings-map.internal.gen.js": {
51
+ "types": "./.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts"
52
+ }
53
+ },
54
+ "files": ["dist", ".pikku"],
55
+ "peerDependencies": {
56
+ "@pikku/core": "*"
57
+ },
58
+ "scripts": {
59
+ "pikku": "pikku all",
60
+ "build": "tsc && cp -r .pikku dist/"
61
+ }
62
+ }
63
+ ```
@@ -0,0 +1,231 @@
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
+ ```
@@ -0,0 +1,82 @@
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.