@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 +0,0 @@
1
- { "$schema": "http://json-schema.org/draft-07/schema#", "type": "boolean", "enum": [false, true], "definitions": {} }
@@ -1 +0,0 @@
1
- export declare const pikkuScenarioFunctions: import("#pikku").PikkuFunctionConfig<void, boolean, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, boolean, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<void, boolean, "rpc" | "session", import("#pikku").WiredServices>, undefined, undefined>;
@@ -1,31 +0,0 @@
1
- import { pikkuSessionlessFunc } from '#pikku';
2
- import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
3
- import { writeFileInDir } from '../../../utils/file-writer.js';
4
- import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
5
- import { removeLegacyScaffoldFile } from '../../../utils/remove-legacy-scaffold-file.js';
6
- import { serializeScenarioFunctions } from './serialize-scenario-functions.js';
7
- export const pikkuScenarioFunctions = pikkuSessionlessFunc({
8
- func: async ({ logger, config, variables }) => {
9
- const deployCodegenFlag = await variables.get('PIKKU_DEPLOY_CODEGEN');
10
- if (deployCodegenFlag === '1') {
11
- return false;
12
- }
13
- if (config.scaffold?.scenarios &&
14
- config.scenariosFunctionsFile &&
15
- config.scenariosSchemasFile) {
16
- const pathToPikkuTypes = getFileImportRelativePath(config.scenariosFunctionsFile, config.typesDeclarationFile, config.packageMappings);
17
- const { schemas, functions } = serializeScenarioFunctions(pathToPikkuTypes, config.scaffold.scenarios === 'auth');
18
- await writeFileInDir(logger, config.scenariosSchemasFile, schemas);
19
- await writeFileInDir(logger, config.scenariosFunctionsFile, functions);
20
- await removeLegacyScaffoldFile(config.scenariosFunctionsFile);
21
- return true;
22
- }
23
- return false;
24
- },
25
- middleware: [
26
- logCommandInfoAndTime({
27
- commandStart: 'Generating Scenario functions',
28
- commandEnd: 'Generated Scenario functions',
29
- }),
30
- ],
31
- });
@@ -1,10 +0,0 @@
1
- export interface ScenarioGenOutput {
2
- schemas: string;
3
- functions: string;
4
- }
5
- /**
6
- * Generate the scenario instrumentation functions (`pikku scenario` coverage
7
- * snapshots and stub-call inspection) into the project scaffold, so scenario
8
- * runs work against any server without requiring the console addon.
9
- */
10
- export declare const serializeScenarioFunctions: (pathToPikkuTypes: string, requireAuth?: boolean) => ScenarioGenOutput;
@@ -1,104 +0,0 @@
1
- /**
2
- * Generate the scenario instrumentation functions (`pikku scenario` coverage
3
- * snapshots and stub-call inspection) into the project scaffold, so scenario
4
- * runs work against any server without requiring the console addon.
5
- */
6
- export const serializeScenarioFunctions = (pathToPikkuTypes, requireAuth = true) => {
7
- const authFlag = requireAuth ? 'true' : 'false';
8
- const schemas = `/**
9
- * Auto-generated scenario instrumentation schemas
10
- * Do not edit manually - regenerate with 'npx pikku'
11
- */
12
- import { z } from 'zod'
13
-
14
- export const StubCallsQuery = z.object({
15
- service: z.string().optional(),
16
- })
17
-
18
- export const Enabled = z.object({ enabled: z.boolean() })
19
- `;
20
- const functions = `/**
21
- * Auto-generated scenario instrumentation functions
22
- * Do not edit manually - regenerate with 'npx pikku'
23
- */
24
- import { readFile } from 'node:fs/promises'
25
- import { join } from 'node:path'
26
- import { pikkuFunc } from '${pathToPikkuTypes}'
27
- import {
28
- getStubTracker,
29
- isTestRun,
30
- type CoverageFunctionMeta,
31
- } from '@pikku/core/services'
32
- import { StubCallsQuery, Enabled } from './scenarios.schemas.gen.js'
33
-
34
- export const pikkuScenarioTakeLiveCoverage = pikkuFunc({
35
- tags: ['pikku'],
36
- title: 'Take Live Coverage',
37
- description:
38
- 'Snapshots the live coverage collected since the server started (or since the last reset) — V8 precise coverage on Node, istanbul instrumentation on Bun — and maps it onto function body spans. Returns null unless the server was started with coverage enabled (pikku dev --coverage).',
39
- expose: true,
40
- auth: ${authFlag},
41
- func: async ({ coverageService, metaService }) => {
42
- if (!coverageService?.takeReport || !metaService?.basePath) return null
43
- let functionsMeta: Record<string, CoverageFunctionMeta>
44
- try {
45
- const content = await readFile(
46
- join(
47
- metaService.basePath,
48
- 'function',
49
- 'pikku-functions-meta-verbose.gen.json'
50
- ),
51
- 'utf-8'
52
- )
53
- functionsMeta = JSON.parse(content)
54
- } catch {
55
- return null
56
- }
57
- return await coverageService.takeReport(functionsMeta)
58
- },
59
- })
60
-
61
- export const pikkuScenarioResetLiveCoverage = pikkuFunc({
62
- tags: ['pikku'],
63
- title: 'Reset Live Coverage',
64
- description:
65
- 'Clears V8 precise-coverage call counts so the next takeLiveCoverage snapshot is attributable to a single scenario run. Reports enabled: false when the server was not started with coverage enabled.',
66
- expose: true,
67
- auth: ${authFlag},
68
- output: Enabled,
69
- func: async ({ coverageService }) => {
70
- if (!coverageService) return { enabled: false }
71
- await coverageService.reset()
72
- return { enabled: true }
73
- },
74
- })
75
-
76
- export const pikkuScenarioResetStubs = pikkuFunc({
77
- tags: ['pikku'],
78
- title: 'Reset Stubs',
79
- description:
80
- 'Clears recorded stub calls so the next getStubCalls result is attributable to a single scenario run. Reports enabled: false when the server was not started in test mode.',
81
- expose: true,
82
- auth: ${authFlag},
83
- output: Enabled,
84
- func: async () => {
85
- getStubTracker().reset()
86
- return { enabled: isTestRun() }
87
- },
88
- })
89
-
90
- export const pikkuScenarioGetStubCalls = pikkuFunc({
91
- tags: ['pikku'],
92
- title: 'Get Stub Calls',
93
- description:
94
- 'Returns calls recorded against stubbed/spied services (via the stub()/spy() core utils). Empty unless the server records service calls (pikku dev --test).',
95
- expose: true,
96
- auth: ${authFlag},
97
- input: StubCallsQuery,
98
- func: async (_services, data) => {
99
- return getStubTracker().getCalls(data?.service ?? undefined)
100
- },
101
- })
102
- `;
103
- return { schemas, functions };
104
- };
@@ -1,243 +0,0 @@
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
- ```
@@ -1,63 +0,0 @@
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
- ```
@@ -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
- ```