@pikku/cli 0.12.20 → 0.12.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.schema.json +1 -1
- package/console-app/assets/index-C52h1B_L.css +1 -0
- package/console-app/assets/index-CAk106ji.js +232 -0
- package/console-app/index.html +3 -6
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +3 -3
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.d.ts +6 -6
- package/dist/.pikku/cli/pikku-cli-channel.js +280 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +792 -8
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +44 -70
- package/dist/.pikku/function/pikku-function-types.gen.js +33 -40
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +1439 -316
- package/dist/.pikku/function/pikku-functions.gen.js +21 -9
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +3 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +3 -1
- package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
- package/dist/.pikku/pikku-meta-service.gen.js +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +2 -1
- package/dist/.pikku/pikku-services.gen.js +1 -0
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +6 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +250 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +5 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +66 -10
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +157 -11
- package/dist/.pikku/schemas/schemas/BinaryInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/DbMigrateInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/DbResetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/DbSeedInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDbSchemaInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDbSchemaOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployApplyInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployApplyOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployListOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployPlanInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployPlanOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployUnitsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployUnitsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsAddInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsAddOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsListOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsRemoveInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsRemoveOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricErrorsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricErrorsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricInitInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricInitOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLLMKeyInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLLMKeyOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLinkInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLinkOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLoginInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLoginOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLogsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLogsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricMetricsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricMetricsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricRollbackInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricRollbackOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsListOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsSetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsSetOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricStatusInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricStatusOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricTraceInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricTraceOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricValidateInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricValidateOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuCommandChannelsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCommandHTTPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCommandQueueOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuEventsScaffoldOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaClientsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaContextInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaFunctionsGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaFunctionsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaMiddlewareGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaMiddlewareListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaPermissionsGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaPermissionsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaSchemasGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaSchemasListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresChannelInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresHttpInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresQueueInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresSchedulerInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresTriggerInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresTypeInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWorkflowsGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWorkflowsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSkillsInstallInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSkillsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuTestsCoverageInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuTestsInitInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/WorkflowRunStatus.schema.json +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/workflow/meta/allWorkflow.gen.json +237 -629
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/bin/pikku-bin.mjs +23 -0
- package/dist/bin/pikku.js +28 -1
- package/dist/src/cli.wiring.js +286 -10
- package/dist/src/deploy/analyzer/analyzer.d.ts +16 -1
- package/dist/src/deploy/analyzer/analyzer.js +83 -43
- package/dist/src/deploy/analyzer/manifest.d.ts +10 -0
- package/dist/src/deploy/build-pipeline.d.ts +2 -0
- package/dist/src/deploy/build-pipeline.js +123 -19
- package/dist/src/deploy/bundler/bundler.d.ts +3 -1
- package/dist/src/deploy/bundler/bundler.js +40 -9
- package/dist/src/deploy/bundler/dep-extractor.d.ts +5 -2
- package/dist/src/deploy/bundler/dep-extractor.js +103 -23
- package/dist/src/deploy/bundler/types.d.ts +5 -1
- package/dist/src/deploy/codegen/per-unit-codegen.d.ts +11 -1
- package/dist/src/deploy/codegen/per-unit-codegen.js +49 -6
- package/dist/src/deploy/plan/planner.js +25 -3
- package/dist/src/deploy/plan/provider.d.ts +2 -0
- package/dist/src/deploy/provider-adapter.d.ts +34 -0
- package/dist/src/deploy/server-entry.d.ts +16 -0
- package/dist/src/deploy/server-entry.js +81 -0
- package/dist/src/fabric/fabric-commands.d.ts +522 -0
- package/dist/src/fabric/fabric-commands.js +299 -0
- package/dist/src/fabric/functions/db-schema.function.d.ts +35 -0
- package/dist/src/fabric/functions/db-schema.function.js +37 -0
- package/dist/src/fabric/functions/deploy-list.function.d.ts +41 -0
- package/dist/src/fabric/functions/deploy-list.function.js +43 -0
- package/dist/src/fabric/functions/deploy-units.function.d.ts +35 -0
- package/dist/src/fabric/functions/deploy-units.function.js +41 -0
- package/dist/src/fabric/functions/deploy.function.d.ts +105 -0
- package/dist/src/fabric/functions/deploy.function.js +122 -0
- package/dist/src/fabric/functions/domains-add.function.d.ts +35 -0
- package/dist/src/fabric/functions/domains-add.function.js +46 -0
- package/dist/src/fabric/functions/domains-list.function.d.ts +20 -0
- package/dist/src/fabric/functions/domains-list.function.js +50 -0
- package/dist/src/fabric/functions/domains-remove.function.d.ts +24 -0
- package/dist/src/fabric/functions/domains-remove.function.js +44 -0
- package/dist/src/fabric/functions/errors.function.d.ts +44 -0
- package/dist/src/fabric/functions/errors.function.js +50 -0
- package/dist/src/fabric/functions/init.function.d.ts +51 -0
- package/dist/src/fabric/functions/init.function.js +54 -0
- package/dist/src/fabric/functions/link.function.d.ts +28 -0
- package/dist/src/fabric/functions/link.function.js +77 -0
- package/dist/src/fabric/functions/llm-key.function.d.ts +46 -0
- package/dist/src/fabric/functions/llm-key.function.js +76 -0
- package/dist/src/fabric/functions/login.function.d.ts +42 -0
- package/dist/src/fabric/functions/login.function.js +68 -0
- package/dist/src/fabric/functions/logs.function.d.ts +40 -0
- package/dist/src/fabric/functions/logs.function.js +84 -0
- package/dist/src/fabric/functions/metrics.function.d.ts +32 -0
- package/dist/src/fabric/functions/metrics.function.js +49 -0
- package/dist/src/fabric/functions/rollback.function.d.ts +76 -0
- package/dist/src/fabric/functions/rollback.function.js +69 -0
- package/dist/src/fabric/functions/secrets-list.function.d.ts +24 -0
- package/dist/src/fabric/functions/secrets-list.function.js +37 -0
- package/dist/src/fabric/functions/secrets-set.function.d.ts +32 -0
- package/dist/src/fabric/functions/secrets-set.function.js +36 -0
- package/dist/src/fabric/functions/status.function.d.ts +34 -0
- package/dist/src/fabric/functions/status.function.js +43 -0
- package/dist/src/fabric/functions/trace.function.d.ts +28 -0
- package/dist/src/fabric/functions/trace.function.js +45 -0
- package/dist/src/fabric/functions/validate.function.d.ts +50 -0
- package/dist/src/fabric/functions/validate.function.js +363 -0
- package/dist/src/fabric/lib/config.d.ts +64 -0
- package/dist/src/fabric/lib/config.js +62 -0
- package/dist/src/fabric/lib/console-url.d.ts +5 -0
- package/dist/src/fabric/lib/console-url.js +13 -0
- package/dist/src/fabric/lib/git.d.ts +53 -0
- package/dist/src/fabric/lib/git.js +151 -0
- package/dist/src/fabric/lib/http.d.ts +4 -0
- package/dist/src/fabric/lib/http.js +12 -0
- package/dist/src/fabric/lib/not-implemented.d.ts +5 -0
- package/dist/src/fabric/lib/not-implemented.js +8 -0
- package/dist/src/fabric/lib/output.d.ts +23 -0
- package/dist/src/fabric/lib/output.js +39 -0
- package/dist/src/fabric/lib/prompt.d.ts +12 -0
- package/dist/src/fabric/lib/prompt.js +32 -0
- package/dist/src/fabric/lib/stage.d.ts +7 -0
- package/dist/src/fabric/lib/stage.js +14 -0
- package/dist/src/fabric/sdk/pikku-fetch.gen.d.ts +14 -0
- package/dist/src/fabric/sdk/pikku-fetch.gen.js +30 -0
- package/dist/src/fabric/sdk/pikku-rpc.gen.d.ts +105 -0
- package/dist/src/fabric/sdk/pikku-rpc.gen.js +126 -0
- package/dist/src/functions/commands/all.d.ts +1 -1
- package/dist/src/functions/commands/binary.d.ts +7 -0
- package/dist/src/functions/commands/binary.js +40 -0
- package/dist/src/functions/commands/bootstrap.d.ts +1 -1
- package/dist/src/functions/commands/bootstrap.js +7 -4
- package/dist/src/functions/commands/console.d.ts +3 -3
- package/dist/src/functions/commands/db-migrate.d.ts +1 -0
- package/dist/src/functions/commands/db-migrate.js +35 -0
- package/dist/src/functions/commands/db-reset.d.ts +1 -0
- package/dist/src/functions/commands/db-reset.js +36 -0
- package/dist/src/functions/commands/db-seed.d.ts +1 -0
- package/dist/src/functions/commands/db-seed.js +27 -0
- package/dist/src/functions/commands/db-shared.d.ts +32 -0
- package/dist/src/functions/commands/db-shared.js +26 -0
- package/dist/src/functions/commands/deploy-apply.d.ts +3 -3
- package/dist/src/functions/commands/deploy-apply.js +6 -4
- package/dist/src/functions/commands/deploy-info.d.ts +1 -1
- package/dist/src/functions/commands/deploy-plan.d.ts +3 -3
- package/dist/src/functions/commands/deploy-plan.js +7 -1
- package/dist/src/functions/commands/dev.d.ts +3 -3
- package/dist/src/functions/commands/dev.js +142 -86
- package/dist/src/functions/commands/enable.d.ts +5 -4
- package/dist/src/functions/commands/enable.js +4 -0
- package/dist/src/functions/commands/info.d.ts +4 -4
- package/dist/src/functions/commands/load-user-project.d.ts +11 -0
- package/dist/src/functions/commands/load-user-project.js +40 -0
- package/dist/src/functions/commands/meta.d.ts +82 -0
- package/dist/src/functions/commands/meta.js +454 -0
- package/dist/src/functions/commands/new-addon.d.ts +3 -3
- package/dist/src/functions/commands/new-function.d.ts +3 -3
- package/dist/src/functions/commands/new-middleware.d.ts +3 -3
- package/dist/src/functions/commands/new-permission.d.ts +3 -3
- package/dist/src/functions/commands/new-wiring.d.ts +3 -3
- package/dist/src/functions/commands/pikku-command-bootstrap.d.ts +1 -1
- package/dist/src/functions/commands/pikku-command-bootstrap.js +15 -1
- package/dist/src/functions/commands/pikku-command-summary.d.ts +1 -1
- package/dist/src/functions/commands/pikku-command-summary.js +7 -1
- package/dist/src/functions/commands/skills.d.ts +26 -0
- package/dist/src/functions/commands/skills.js +184 -0
- package/dist/src/functions/commands/tests-coverage.d.ts +7 -0
- package/dist/src/functions/commands/tests-coverage.js +231 -0
- package/dist/src/functions/commands/tests-init.d.ts +7 -0
- package/dist/src/functions/commands/tests-init.js +225 -0
- package/dist/src/functions/commands/versions-check.d.ts +1 -1
- package/dist/src/functions/commands/versions-init.d.ts +3 -3
- package/dist/src/functions/commands/versions-update.d.ts +1 -1
- package/dist/src/functions/commands/versions-update.js +4 -2
- package/dist/src/functions/commands/watch.d.ts +3 -3
- package/dist/src/functions/commands/watch.js +1 -1
- package/dist/src/functions/db/local-db.d.ts +48 -0
- package/dist/src/functions/db/local-db.js +106 -0
- package/dist/src/functions/db/seed.d.ts +11 -0
- package/dist/src/functions/db/seed.js +22 -0
- package/dist/src/functions/db/sql-migrator.d.ts +26 -0
- package/dist/src/functions/db/sql-migrator.js +104 -0
- package/dist/src/functions/db/sqlite-codegen.d.ts +45 -0
- package/dist/src/functions/db/sqlite-codegen.js +294 -0
- package/dist/src/functions/db/zod-codegen.d.ts +10 -0
- package/dist/src/functions/db/zod-codegen.js +109 -0
- package/dist/src/functions/runtimes/fetch/index.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +21 -2
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-worker-rpc-wrapper.d.ts +1 -0
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-worker-rpc-wrapper.js +163 -0
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.js +5 -2
- package/dist/src/functions/runtimes/tanstack-start/pikku-command-tanstack-start.d.ts +1 -0
- package/dist/src/functions/runtimes/tanstack-start/pikku-command-tanstack-start.js +32 -0
- package/dist/src/functions/runtimes/tanstack-start/serialize-tanstack-start-shim.d.ts +11 -0
- package/dist/src/functions/runtimes/tanstack-start/serialize-tanstack-start-shim.js +36 -0
- package/dist/src/functions/runtimes/websocket/pikku-command-websocket-typed.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +1 -10
- package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +76 -1
- package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +1 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.d.ts +1 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +5 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.d.ts +5 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +8 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +27 -9
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +5 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +13 -3
- package/dist/src/functions/wirings/console/pikku-command-console-functions.d.ts +1 -1
- package/dist/src/functions/wirings/console/pikku-command-console-functions.js +5 -1
- package/dist/src/functions/wirings/console/pikku-command-node-types.d.ts +1 -1
- package/dist/src/functions/wirings/console/pikku-command-nodes-meta.d.ts +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.js +5 -0
- package/dist/src/functions/wirings/credentials/pikku-command-credentials.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.d.ts +5 -1
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.js +7 -2
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
- package/dist/src/functions/wirings/functions/schemas.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-function-types.js +105 -80
- package/dist/src/functions/wirings/gateway/pikku-command-gateway.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-map.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-routes.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-types.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.d.ts +1 -1
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -1
- package/dist/src/functions/wirings/package/pikku-command-package-types.d.ts +2 -2
- package/dist/src/functions/wirings/package/pikku-command-package.d.ts +1 -1
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +1 -1
- package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -1
- package/dist/src/functions/wirings/realtime/pikku-command-events-scaffold.d.ts +1 -0
- package/dist/src/functions/wirings/realtime/pikku-command-events-scaffold.js +26 -0
- package/dist/src/functions/wirings/realtime/pikku-command-realtime.d.ts +1 -0
- package/dist/src/functions/wirings/realtime/pikku-command-realtime.js +35 -0
- package/dist/src/functions/wirings/realtime/serialize-events-scaffold.d.ts +23 -0
- package/dist/src/functions/wirings/realtime/serialize-events-scaffold.js +98 -0
- package/dist/src/functions/wirings/realtime/serialize-realtime-client.d.ts +22 -0
- package/dist/src/functions/wirings/realtime/serialize-realtime-client.js +337 -0
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.js +5 -1
- package/dist/src/functions/wirings/rpc/pikku-command-react-query.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.js +5 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +3 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.d.ts +2 -2
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +2 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +13 -7
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +1 -0
- package/dist/src/functions/wirings/rpc/serialize-react-query-hooks.js +1 -1
- package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +7 -1
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +16 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.d.ts +1 -1
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -1
- package/dist/src/functions/wirings/secrets/pikku-command-secrets.d.ts +1 -1
- package/dist/src/functions/wirings/triggers/pikku-command-trigger-types.d.ts +1 -1
- package/dist/src/functions/wirings/triggers/pikku-command-trigger-types.js +1 -1
- package/dist/src/functions/wirings/triggers/pikku-command-trigger.d.ts +1 -1
- package/dist/src/functions/wirings/variables/pikku-command-variables.d.ts +1 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.d.ts +1 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.js +1 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.d.ts +5 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +18 -4
- package/dist/src/functions/wirings/workflow/serialize-workflow-bootstrap-map.d.ts +3 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-bootstrap-map.js +40 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-routes.js +56 -2
- package/dist/src/functions/workflows/all.workflow.js +45 -12
- package/dist/src/scaffold/rpc-remote.gen.d.ts +3 -3
- package/dist/src/scaffold/rpc-remote.gen.js +7 -2
- package/dist/src/scaffold/workflow-routes.gen.d.ts +18 -18
- package/dist/src/scaffold/workflow-routes.gen.js +33 -1
- package/dist/src/services/cli-logger.service.d.ts +22 -3
- package/dist/src/services/cli-logger.service.js +107 -41
- package/dist/src/services.js +32 -67
- package/dist/src/utils/generate-bootstrap-file.js +3 -0
- package/dist/src/utils/parse-cli-filters.d.ts +18 -0
- package/dist/src/utils/parse-cli-filters.js +99 -0
- package/dist/src/utils/pikku-cli-config.js +29 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -4
- package/skills/pikku-addon/SKILL.md +330 -0
- package/skills/pikku-ai-agent/SKILL.md +227 -0
- package/skills/pikku-ai-vercel/SKILL.md +78 -0
- package/skills/pikku-ai-voice/SKILL.md +85 -0
- package/skills/pikku-auth-js/SKILL.md +106 -0
- package/skills/pikku-aws/SKILL.md +107 -0
- package/skills/pikku-backblaze/SKILL.md +70 -0
- package/skills/pikku-cli/SKILL.md +281 -0
- package/skills/pikku-concepts/SKILL.md +281 -0
- package/skills/pikku-concepts/references/concept-mapping.md +528 -0
- package/skills/pikku-config/SKILL.md +208 -0
- package/skills/pikku-cron/SKILL.md +211 -0
- package/skills/pikku-deploy-azure/SKILL.md +69 -0
- package/skills/pikku-deploy-cloudflare/SKILL.md +80 -0
- package/skills/pikku-deploy-express/SKILL.md +83 -0
- package/skills/pikku-deploy-fastify/SKILL.md +70 -0
- package/skills/pikku-deploy-lambda/SKILL.md +107 -0
- package/skills/pikku-deploy-nextjs/SKILL.md +76 -0
- package/skills/pikku-deploy-uws/SKILL.md +85 -0
- package/skills/pikku-fabric/SKILL.md +245 -0
- package/skills/pikku-feature/SKILL.md +258 -0
- package/skills/pikku-gateway-slack/SKILL.md +112 -0
- package/skills/pikku-http/SKILL.md +317 -0
- package/skills/pikku-i18n/SKILL.md +208 -0
- package/skills/pikku-info/SKILL.md +95 -0
- package/skills/pikku-jose/SKILL.md +102 -0
- package/skills/pikku-kysely/SKILL.md +145 -0
- package/skills/pikku-mcp/SKILL.md +237 -0
- package/skills/pikku-mongodb/SKILL.md +102 -0
- package/skills/pikku-n8n-addon-map/SKILL.md +178 -0
- package/skills/pikku-n8n-code-translate/SKILL.md +166 -0
- package/skills/pikku-pino/SKILL.md +77 -0
- package/skills/pikku-queue/SKILL.md +237 -0
- package/skills/pikku-react/SKILL.md +183 -0
- package/skills/pikku-react-query/SKILL.md +205 -0
- package/skills/pikku-realtime/SKILL.md +285 -0
- package/skills/pikku-redis/SKILL.md +87 -0
- package/skills/pikku-rpc/SKILL.md +168 -0
- package/skills/pikku-rtl/SKILL.md +205 -0
- package/skills/pikku-schedule/SKILL.md +54 -0
- package/skills/pikku-schema-ajv/SKILL.md +60 -0
- package/skills/pikku-schema-cfworker/SKILL.md +60 -0
- package/skills/pikku-security/SKILL.md +243 -0
- package/skills/pikku-services/SKILL.md +247 -0
- package/skills/pikku-template-clone/SKILL.md +39 -0
- package/skills/pikku-testing/SKILL.md +428 -0
- package/skills/pikku-trigger/SKILL.md +177 -0
- package/skills/pikku-versioning/SKILL.md +169 -0
- package/skills/pikku-websocket/SKILL.md +239 -0
- package/skills/pikku-workflow/SKILL.md +283 -0
- package/skills/pikku-workflows-client/SKILL.md +150 -0
- package/skills/pikku-ws/SKILL.md +45 -0
- package/console-app/assets/index-BpY2pSuA.css +0 -10
- package/console-app/assets/index-DXLy-_D4.js +0 -717
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +0 -10
- package/dist/.pikku/cli/pikku-cli-client.gen.js +0 -44
- /package/dist/.pikku/schemas/schemas/{PikkuChannelsOutput.schema.json → PikkuCLIEntryOutput.schema.json} +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-services
|
|
3
|
+
description: 'Use when setting up dependency injection, creating custom services, or configuring the service layer in a Pikku app. Covers pikkuServices (singleton), pikkuWireServices (per-request), service typing, built-in services, and tree-shaking.
|
|
4
|
+
TRIGGER when: code uses pikkuServices/pikkuWireServices, user asks about services.ts, dependency injection, service factories, or built-in services (ConsoleLogger, JoseJWTService).
|
|
5
|
+
DO NOT TRIGGER when: user asks about auth middleware (use pikku-security) or secrets/variables (use pikku-config).'
|
|
6
|
+
installGroups: [core]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Pikku Services (Dependency Injection)
|
|
10
|
+
|
|
11
|
+
## Agent Operating Procedure
|
|
12
|
+
|
|
13
|
+
Use this skill as an execution checklist, not reference material.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
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.
|
|
17
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
18
|
+
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.
|
|
19
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
20
|
+
|
|
21
|
+
Pikku uses factory functions for dependency injection. Singleton services are created once at startup. Wire services are created fresh per request/job/command.
|
|
22
|
+
|
|
23
|
+
## Before You Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pikku info functions --verbose # See which services existing functions use
|
|
27
|
+
pikku info tags --verbose # Understand project organization
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See `pikku-concepts` for the core mental model.
|
|
31
|
+
|
|
32
|
+
## API Reference
|
|
33
|
+
|
|
34
|
+
### `pikkuServices(factory)`
|
|
35
|
+
|
|
36
|
+
Create singleton services — instantiated once at server startup.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { pikkuServices } from '#pikku'
|
|
40
|
+
|
|
41
|
+
const createSingletonServices = pikkuServices(
|
|
42
|
+
async (config, existingServices?) => {
|
|
43
|
+
// config: your CoreConfig object
|
|
44
|
+
// existingServices: optional, for chaining factories
|
|
45
|
+
return {
|
|
46
|
+
config,
|
|
47
|
+
logger: Logger,
|
|
48
|
+
jwt: JWTService,
|
|
49
|
+
database: DatabasePool,
|
|
50
|
+
// ...any custom services
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### `pikkuWireServices(factory)`
|
|
57
|
+
|
|
58
|
+
Create per-request services — fresh instance for each HTTP request, queue job, CLI command, etc.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { pikkuWireServices } from '#pikku'
|
|
62
|
+
|
|
63
|
+
const createWireServices = pikkuWireServices(
|
|
64
|
+
async (singletonServices, wire) => {
|
|
65
|
+
// singletonServices: all singleton services
|
|
66
|
+
// wire: transport context (session, channel, etc.)
|
|
67
|
+
// Pikku merges these with singleton services automatically
|
|
68
|
+
return {
|
|
69
|
+
userSession: UserSessionService,
|
|
70
|
+
dbTransaction: DatabaseTransaction,
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Auto-Generated Service Manifest
|
|
77
|
+
|
|
78
|
+
After `npx pikku prebuild`, Pikku generates a manifest of which services are actually used:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// .pikku/pikku-services.gen.ts (auto-generated)
|
|
82
|
+
export const requiredSingletonServices = {
|
|
83
|
+
database: true, // used by getUser, deleteUser
|
|
84
|
+
audit: true, // used by deleteUser
|
|
85
|
+
cache: false, // not used by any wired function
|
|
86
|
+
jwt: true, // used by auth middleware
|
|
87
|
+
} as const
|
|
88
|
+
|
|
89
|
+
export type RequiredSingletonServices = Pick<
|
|
90
|
+
SingletonServices,
|
|
91
|
+
'database' | 'audit' | 'jwt'
|
|
92
|
+
> &
|
|
93
|
+
Partial<Omit<SingletonServices, 'database' | 'audit' | 'jwt'>>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Usage Patterns
|
|
97
|
+
|
|
98
|
+
### Basic Singleton Services
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const createSingletonServices = pikkuServices(
|
|
102
|
+
async (config, existingServices) => {
|
|
103
|
+
const logger = new ConsoleLogger()
|
|
104
|
+
const database = new DatabasePool(config.database)
|
|
105
|
+
await database.connect()
|
|
106
|
+
|
|
107
|
+
const jwt = new JoseJWTService(
|
|
108
|
+
async () => [{ id: 'my-key', value: JWT_SECRET }],
|
|
109
|
+
logger
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
config,
|
|
114
|
+
logger,
|
|
115
|
+
database,
|
|
116
|
+
jwt,
|
|
117
|
+
books: new BookService(),
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Per-Request Wire Services
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
const createWireServices = pikkuWireServices(
|
|
127
|
+
async (singletonServices, wire) => {
|
|
128
|
+
return {
|
|
129
|
+
userSession: createUserSessionService(wire),
|
|
130
|
+
dbTransaction: new DatabaseTransaction(singletonServices.database),
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Using Services in Functions
|
|
137
|
+
|
|
138
|
+
Functions destructure services from the first parameter:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
const getUser = pikkuFunc({
|
|
142
|
+
title: 'Get User',
|
|
143
|
+
func: async ({ db, logger, jwt }, { userId }) => {
|
|
144
|
+
logger.info('Fetching user', { userId })
|
|
145
|
+
const user = await db.getUser(userId)
|
|
146
|
+
return { user }
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Dynamic Import Optimization
|
|
152
|
+
|
|
153
|
+
Use the generated manifest to conditionally import heavy dependencies:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { requiredSingletonServices } from '.pikku/pikku-services.gen.js'
|
|
157
|
+
|
|
158
|
+
const createSingletonServices = pikkuServices(async (config) => {
|
|
159
|
+
const logger = new ConsoleLogger()
|
|
160
|
+
|
|
161
|
+
let jwt: JWTService | undefined
|
|
162
|
+
if (requiredSingletonServices.jwt) {
|
|
163
|
+
const { JoseJWTService } = await import('@pikku/jose')
|
|
164
|
+
jwt = new JoseJWTService(keys, logger)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let database: Database | undefined
|
|
168
|
+
if (requiredSingletonServices.database) {
|
|
169
|
+
database = await createDatabase(config.databaseUrl)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return { config, logger, jwt, database }
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Built-in Services
|
|
177
|
+
|
|
178
|
+
| Service | Package | Purpose |
|
|
179
|
+
| ----------------------- | ---------------------- | --------------------------- |
|
|
180
|
+
| `ConsoleLogger` | `@pikku/core/services` | Console-based logging |
|
|
181
|
+
| `JoseJWTService` | `@pikku/jose` | JWT sign/verify via jose |
|
|
182
|
+
| `LocalSecretService` | `@pikku/core/services` | Local development secrets |
|
|
183
|
+
| `LocalVariablesService` | `@pikku/core/services` | Local environment variables |
|
|
184
|
+
| `PinoLogger` | `@pikku/pino` | Structured logging via Pino |
|
|
185
|
+
|
|
186
|
+
## Complete Example
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
// services.ts
|
|
190
|
+
import { pikkuServices, pikkuWireServices } from '#pikku'
|
|
191
|
+
import { ConsoleLogger } from '@pikku/core/services'
|
|
192
|
+
import { JoseJWTService } from '@pikku/jose'
|
|
193
|
+
|
|
194
|
+
// Custom service
|
|
195
|
+
class TodoStore {
|
|
196
|
+
private todos: Map<string, Todo> = new Map()
|
|
197
|
+
|
|
198
|
+
async create(title: string, priority: string) {
|
|
199
|
+
const todo = { id: crypto.randomUUID(), title, priority, completed: false }
|
|
200
|
+
this.todos.set(todo.id, todo)
|
|
201
|
+
return todo
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async get(id: string) {
|
|
205
|
+
return this.todos.get(id)
|
|
206
|
+
}
|
|
207
|
+
async list() {
|
|
208
|
+
return [...this.todos.values()]
|
|
209
|
+
}
|
|
210
|
+
async delete(id: string) {
|
|
211
|
+
this.todos.delete(id)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export const createSingletonServices = pikkuServices(async (config) => {
|
|
216
|
+
const logger = new ConsoleLogger()
|
|
217
|
+
const jwt = new JoseJWTService(
|
|
218
|
+
async () => [{ id: 'my-key', value: config.jwtSecret }],
|
|
219
|
+
logger
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
config,
|
|
224
|
+
logger,
|
|
225
|
+
jwt,
|
|
226
|
+
secrets: new LocalSecretService(),
|
|
227
|
+
variables: new LocalVariablesService(),
|
|
228
|
+
todoStore: new TodoStore(),
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
export const createWireServices = pikkuWireServices(
|
|
233
|
+
async (singletonServices, wire) => ({
|
|
234
|
+
scopedLogger: new ScopedLogger(wire.session?.initial?.userId),
|
|
235
|
+
})
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
// functions/todos.functions.ts — services are auto-injected
|
|
239
|
+
export const createTodo = pikkuFunc({
|
|
240
|
+
title: 'Create Todo',
|
|
241
|
+
func: async ({ todoStore, logger }, { title, priority }) => {
|
|
242
|
+
const todo = await todoStore.create(title, priority)
|
|
243
|
+
logger.info('Created todo', { id: todo.id })
|
|
244
|
+
return { todo }
|
|
245
|
+
},
|
|
246
|
+
})
|
|
247
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-template-clone
|
|
3
|
+
description: 'Standard cleanup to run right after a Pikku template is cloned or scaffolded into a new project. TRIGGER when: a Pikku template was just cloned/scaffolded (via `pikku create`, `git clone <template>`, or the user says "I cloned the kanban template / starter / template"), or the working tree still looks like an untouched template (template README, placeholder `@project/*` name in package.json). DO NOT TRIGGER when: working in an established project mid-feature, or editing the template repo itself.'
|
|
4
|
+
allowed-tools: Bash(git status *), Bash(git add *), Bash(git commit *), Bash(git rm *), Bash(git mv *), Bash(git log *)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pikku Template Post-Clone Cleanup
|
|
8
|
+
|
|
9
|
+
## Agent Operating Procedure
|
|
10
|
+
|
|
11
|
+
Run this **once**, right after a template is cloned or scaffolded into a new
|
|
12
|
+
project. The goal is to turn template scaffolding into a real project. Make the
|
|
13
|
+
smallest changes and land them as one focused `chore: post-clone cleanup`
|
|
14
|
+
commit, separate from any feature work.
|
|
15
|
+
|
|
16
|
+
1. **Replace the template README.** The shipped `README.md` describes the
|
|
17
|
+
_template_, not the user's project — leaving it in place is misleading.
|
|
18
|
+
Either delete it (`git rm README.md`) or rewrite it with the new project's
|
|
19
|
+
name and purpose. Never ship a clone with the generic template README.
|
|
20
|
+
2. **Keep the lockfile committed.** Templates ship a committed `yarn.lock`; do
|
|
21
|
+
NOT re-add `yarn.lock` to `.gitignore`. A real project commits its lockfile
|
|
22
|
+
for reproducible installs. The correct pattern is `yarn.lock` followed by
|
|
23
|
+
`!/yarn.lock`, which commits the root lockfile while keeping generated
|
|
24
|
+
per-unit lockfiles under `.deploy/` (and `e2e/`) ignored.
|
|
25
|
+
3. **Rename template identifiers.** Update `name` in the root `package.json`
|
|
26
|
+
(and any `@project/*` or other placeholder names) to the real project.
|
|
27
|
+
4. **Drop template-only artifacts.** Remove any `TEMPLATE.md`, demo docs, or
|
|
28
|
+
placeholder content that only made sense for the template.
|
|
29
|
+
|
|
30
|
+
Do not touch generated files (`.pikku/`, `*.gen.*`) or run a full reinstall as
|
|
31
|
+
part of cleanup — this step is project hygiene, not a build.
|
|
32
|
+
|
|
33
|
+
## Why this exists
|
|
34
|
+
|
|
35
|
+
Templates are structure-only starting points. Without this pass, clones carry a
|
|
36
|
+
misleading README, a placeholder package name, and (historically) a gitignored
|
|
37
|
+
lockfile — all of which leak template assumptions into a real project. Running
|
|
38
|
+
it immediately after clone keeps every Pikku project, OSS or Fabric, starting
|
|
39
|
+
from a clean, honest baseline.
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-testing
|
|
3
|
+
description: 'Use when writing tests for Pikku functions, middleware, permissions, or services. Covers unit testing with direct invocation, runPikkuFunc, service mocking, and integration testing with the HTTP runner.
|
|
4
|
+
TRIGGER when: user asks about testing, writing tests, test setup, mocking services, or integration testing Pikku functions.
|
|
5
|
+
DO NOT TRIGGER when: user asks about running the existing test suite (use Bash) or CI configuration (not a Pikku skill).'
|
|
6
|
+
installGroups: [core]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Pikku Testing
|
|
10
|
+
|
|
11
|
+
## Agent Operating Procedure
|
|
12
|
+
|
|
13
|
+
Use this skill as an execution checklist, not reference material.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
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.
|
|
17
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
18
|
+
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.
|
|
19
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
20
|
+
|
|
21
|
+
Pikku functions are pure business logic — no HTTP, no framework — making them easy to test. Test at three levels: direct function calls, `runPikkuFunc` (with middleware/permissions), and integration tests (full HTTP stack).
|
|
22
|
+
|
|
23
|
+
## Before You Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pikku info functions --verbose # See existing functions and their middleware/permissions
|
|
27
|
+
pikku info middleware --verbose # See middleware applied
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See `pikku-concepts` for the core mental model.
|
|
31
|
+
|
|
32
|
+
## Test Runner Setup
|
|
33
|
+
|
|
34
|
+
Pikku uses Node.js built-in test runner with tsx for TypeScript:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
node --import tsx --test src/**/*.test.ts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Standard test file:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { describe, test, beforeEach } from 'node:test'
|
|
44
|
+
import assert from 'node:assert'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Level 1: Direct Function Invocation
|
|
48
|
+
|
|
49
|
+
The simplest approach — call `func` directly with mock services:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { describe, test } from 'node:test'
|
|
53
|
+
import assert from 'node:assert'
|
|
54
|
+
|
|
55
|
+
describe('createTodo', () => {
|
|
56
|
+
test('should create a todo', async () => {
|
|
57
|
+
const mockServices = {
|
|
58
|
+
todoStore: {
|
|
59
|
+
add: async (title: string) => ({
|
|
60
|
+
id: '1',
|
|
61
|
+
title,
|
|
62
|
+
completed: false,
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const result = await createTodo.func(mockServices as any, {
|
|
68
|
+
title: 'Buy milk',
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
assert.equal(result.title, 'Buy milk')
|
|
72
|
+
assert.equal(result.completed, false)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This tests pure business logic — no middleware, no permissions, no validation.
|
|
78
|
+
|
|
79
|
+
## Level 2: `runPikkuFunc` (Full Pipeline)
|
|
80
|
+
|
|
81
|
+
Tests the function through Pikku's middleware, permissions, and schema validation pipeline:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { runPikkuFunc } from '@pikku/core'
|
|
85
|
+
import { addFunction, addMiddleware, addPermission } from '@pikku/core'
|
|
86
|
+
import { resetPikkuState, pikkuState } from '@pikku/core'
|
|
87
|
+
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
resetPikkuState()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('should run function with middleware', async () => {
|
|
93
|
+
const mockSingletonServices = {
|
|
94
|
+
logger: {
|
|
95
|
+
info: () => {},
|
|
96
|
+
warn: () => {},
|
|
97
|
+
error: () => {},
|
|
98
|
+
debug: () => {},
|
|
99
|
+
},
|
|
100
|
+
} as any
|
|
101
|
+
|
|
102
|
+
// Register function metadata
|
|
103
|
+
pikkuState(null, 'function', 'meta')['myFunc'] = {
|
|
104
|
+
pikkuFuncId: 'myFunc',
|
|
105
|
+
inputSchemaName: null,
|
|
106
|
+
outputSchemaName: null,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Register the function
|
|
110
|
+
addFunction('myFunc', {
|
|
111
|
+
func: async (services, data) => {
|
|
112
|
+
return { greeting: `Hello ${data.name}` }
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const result = await runPikkuFunc('rpc', 'test-wire', 'myFunc', {
|
|
117
|
+
singletonServices: mockSingletonServices,
|
|
118
|
+
getAllServices: () => mockSingletonServices,
|
|
119
|
+
data: () => ({ name: 'World' }),
|
|
120
|
+
auth: false,
|
|
121
|
+
wire: {},
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
assert.deepEqual(result, { greeting: 'Hello World' })
|
|
125
|
+
})
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Testing Middleware Execution Order
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
test('middleware runs in order: wiring tags -> wiring -> func tags -> func', async () => {
|
|
132
|
+
const mockSingletonServices = {
|
|
133
|
+
logger: {
|
|
134
|
+
info: () => {},
|
|
135
|
+
warn: () => {},
|
|
136
|
+
error: () => {},
|
|
137
|
+
debug: () => {},
|
|
138
|
+
},
|
|
139
|
+
} as any
|
|
140
|
+
|
|
141
|
+
const order: string[] = []
|
|
142
|
+
|
|
143
|
+
const createMiddleware =
|
|
144
|
+
(name: string) => async (services: any, wire: any, next: Function) => {
|
|
145
|
+
order.push(name)
|
|
146
|
+
await next()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
addMiddleware('apiTag', [createMiddleware('apiTag')])
|
|
150
|
+
addMiddleware('funcTag', [createMiddleware('funcTag')])
|
|
151
|
+
|
|
152
|
+
pikkuState(null, 'function', 'meta')['myFunc'] = {
|
|
153
|
+
pikkuFuncId: 'myFunc',
|
|
154
|
+
inputSchemaName: null,
|
|
155
|
+
outputSchemaName: null,
|
|
156
|
+
middleware: [{ type: 'tag', tag: 'funcTag' }],
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
addFunction('myFunc', {
|
|
160
|
+
func: async () => {
|
|
161
|
+
order.push('main')
|
|
162
|
+
return 'ok'
|
|
163
|
+
},
|
|
164
|
+
middleware: [createMiddleware('funcMiddleware')],
|
|
165
|
+
tags: ['funcTag'],
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
await runPikkuFunc('rpc', 'test', 'myFunc', {
|
|
169
|
+
singletonServices: mockSingletonServices,
|
|
170
|
+
getAllServices: () => mockSingletonServices,
|
|
171
|
+
data: () => ({}),
|
|
172
|
+
wireMiddleware: [createMiddleware('wiringMiddleware')],
|
|
173
|
+
inheritedMiddleware: [{ type: 'tag', tag: 'apiTag' }],
|
|
174
|
+
auth: false,
|
|
175
|
+
wire: {},
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
assert.deepEqual(order, [
|
|
179
|
+
'apiTag',
|
|
180
|
+
'wiringMiddleware',
|
|
181
|
+
'funcTag',
|
|
182
|
+
'funcMiddleware',
|
|
183
|
+
'main',
|
|
184
|
+
])
|
|
185
|
+
})
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Testing Permissions
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
test('should reject when permission fails', async () => {
|
|
192
|
+
const mockSingletonServices = {
|
|
193
|
+
logger: {
|
|
194
|
+
info: () => {},
|
|
195
|
+
warn: () => {},
|
|
196
|
+
error: () => {},
|
|
197
|
+
debug: () => {},
|
|
198
|
+
},
|
|
199
|
+
} as any
|
|
200
|
+
|
|
201
|
+
addPermission('admin', [
|
|
202
|
+
async () => false, // Always deny
|
|
203
|
+
])
|
|
204
|
+
|
|
205
|
+
pikkuState(null, 'function', 'meta')['adminFunc'] = {
|
|
206
|
+
pikkuFuncId: 'adminFunc',
|
|
207
|
+
inputSchemaName: null,
|
|
208
|
+
outputSchemaName: null,
|
|
209
|
+
permissions: [{ type: 'tag', tag: 'admin' }],
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
addFunction('adminFunc', { func: async () => 'secret' })
|
|
213
|
+
|
|
214
|
+
await assert.rejects(
|
|
215
|
+
runPikkuFunc('rpc', 'test', 'adminFunc', {
|
|
216
|
+
singletonServices: mockSingletonServices,
|
|
217
|
+
getAllServices: () => mockSingletonServices,
|
|
218
|
+
data: () => ({}),
|
|
219
|
+
auth: false,
|
|
220
|
+
wire: {},
|
|
221
|
+
}),
|
|
222
|
+
/Permission/
|
|
223
|
+
)
|
|
224
|
+
})
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Level 3: Integration Testing (HTTP)
|
|
228
|
+
|
|
229
|
+
Test the full HTTP stack using the `fetch` export:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import { fetch, wireHTTP } from '@pikku/core/http'
|
|
233
|
+
import { resetPikkuState, pikkuState, addFunction } from '@pikku/core'
|
|
234
|
+
|
|
235
|
+
const mockSingletonServices = {
|
|
236
|
+
logger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} },
|
|
237
|
+
} as any
|
|
238
|
+
|
|
239
|
+
const listTodos = {
|
|
240
|
+
func: async () => ({ todos: [{ id: '1', title: 'Test todo' }] }),
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
beforeEach(() => {
|
|
244
|
+
resetPikkuState()
|
|
245
|
+
|
|
246
|
+
// Set up singleton services in state
|
|
247
|
+
pikkuState(null, 'package', 'singletonServices', mockSingletonServices)
|
|
248
|
+
pikkuState(null, 'package', 'factories', {
|
|
249
|
+
createWireServices: async () => ({}),
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
test('GET /todos returns todo list', async () => {
|
|
254
|
+
// Register route metadata and function
|
|
255
|
+
pikkuState(null, 'http', 'meta')['get'] =
|
|
256
|
+
pikkuState(null, 'http', 'meta')['get'] || {}
|
|
257
|
+
pikkuState(null, 'http', 'meta')['get']['/todos'] = {
|
|
258
|
+
pikkuFuncId: 'listTodos',
|
|
259
|
+
method: 'get',
|
|
260
|
+
route: '/todos',
|
|
261
|
+
}
|
|
262
|
+
addFunction('listTodos', listTodos)
|
|
263
|
+
wireHTTP({ method: 'get', route: '/todos', func: listTodos })
|
|
264
|
+
|
|
265
|
+
const request = new Request('http://localhost/todos')
|
|
266
|
+
const response = await fetch(request)
|
|
267
|
+
const data = await response.json()
|
|
268
|
+
|
|
269
|
+
assert.equal(response.status, 200)
|
|
270
|
+
assert.ok(Array.isArray(data.todos))
|
|
271
|
+
})
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Testing Services
|
|
275
|
+
|
|
276
|
+
Test custom services in isolation:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
import { describe, test } from 'node:test'
|
|
280
|
+
import assert from 'node:assert'
|
|
281
|
+
import { LocalVariablesService } from '@pikku/core/services'
|
|
282
|
+
|
|
283
|
+
describe('LocalVariablesService', () => {
|
|
284
|
+
test('should get and set variables', () => {
|
|
285
|
+
const service = new LocalVariablesService({ API_KEY: 'test-key' })
|
|
286
|
+
assert.equal(service.get('API_KEY'), 'test-key')
|
|
287
|
+
|
|
288
|
+
service.set('NEW_KEY', 'value')
|
|
289
|
+
assert.equal(service.get('NEW_KEY'), 'value')
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Testing with Real Services (Verifier Pattern)
|
|
295
|
+
|
|
296
|
+
For integration testing with a running server:
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
// services.ts — real service setup for tests
|
|
300
|
+
import { pikkuServices, pikkuWireServices } from '#pikku'
|
|
301
|
+
import { LocalSecretService, LocalVariablesService } from '@pikku/core/services'
|
|
302
|
+
|
|
303
|
+
export const createSingletonServices = pikkuServices(async (config) => {
|
|
304
|
+
const variables = new LocalVariablesService()
|
|
305
|
+
const secrets = new LocalSecretService(variables)
|
|
306
|
+
return { config, variables, secrets, logger: new ConsoleLogger() }
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
export const createWireServices = pikkuWireServices(async () => ({}))
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
// start.ts — bootstrap server for tests
|
|
314
|
+
import './.pikku/pikku-bootstrap.gen.js'
|
|
315
|
+
import { createSingletonServices, createWireServices } from './services.js'
|
|
316
|
+
|
|
317
|
+
const config = {}
|
|
318
|
+
const singletonServices = await createSingletonServices(config)
|
|
319
|
+
const server = new PikkuFastifyServer(
|
|
320
|
+
config,
|
|
321
|
+
singletonServices,
|
|
322
|
+
createWireServices
|
|
323
|
+
)
|
|
324
|
+
await server.init()
|
|
325
|
+
await server.start()
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Common Patterns
|
|
329
|
+
|
|
330
|
+
### Mock Logger
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
const mockLogger = {
|
|
334
|
+
info: () => {},
|
|
335
|
+
warn: () => {},
|
|
336
|
+
error: () => {},
|
|
337
|
+
debug: () => {},
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Mock Singleton Services
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
const mockSingletonServices = {
|
|
345
|
+
logger: mockLogger,
|
|
346
|
+
todoStore: new InMemoryTodoStore(),
|
|
347
|
+
// Add whatever services your functions need
|
|
348
|
+
} as any
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Reset State Between Tests
|
|
352
|
+
|
|
353
|
+
Always reset pikku state in `beforeEach` to isolate tests:
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
import { resetPikkuState } from '@pikku/core'
|
|
357
|
+
|
|
358
|
+
beforeEach(() => {
|
|
359
|
+
resetPikkuState()
|
|
360
|
+
})
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### Async Error Assertions
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
await assert.rejects(
|
|
367
|
+
async () => await myFunc.func(services, { id: 'nonexistent' }),
|
|
368
|
+
{ message: 'Not found' }
|
|
369
|
+
)
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Complete Example
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
// functions/todos.functions.ts
|
|
376
|
+
export const createTodo = pikkuSessionlessFunc({
|
|
377
|
+
description: 'Create a todo',
|
|
378
|
+
input: z.object({ title: z.string().min(1) }),
|
|
379
|
+
output: z.object({ id: z.string(), title: z.string() }),
|
|
380
|
+
func: async ({ todoStore }, { title }) => {
|
|
381
|
+
return todoStore.add(title)
|
|
382
|
+
},
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
// functions/todos.test.ts
|
|
386
|
+
import { describe, test, beforeEach } from 'node:test'
|
|
387
|
+
import assert from 'node:assert'
|
|
388
|
+
|
|
389
|
+
class MockTodoStore {
|
|
390
|
+
private todos: any[] = []
|
|
391
|
+
|
|
392
|
+
async add(title: string) {
|
|
393
|
+
const todo = { id: String(this.todos.length + 1), title, completed: false }
|
|
394
|
+
this.todos.push(todo)
|
|
395
|
+
return todo
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
async list() {
|
|
399
|
+
return this.todos
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
describe('createTodo', () => {
|
|
404
|
+
let todoStore: MockTodoStore
|
|
405
|
+
|
|
406
|
+
beforeEach(() => {
|
|
407
|
+
todoStore = new MockTodoStore()
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
test('creates a todo with the given title', async () => {
|
|
411
|
+
const result = await createTodo.func({ todoStore } as any, {
|
|
412
|
+
title: 'Buy milk',
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
assert.equal(result.id, '1')
|
|
416
|
+
assert.equal(result.title, 'Buy milk')
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
test('increments IDs', async () => {
|
|
420
|
+
await createTodo.func({ todoStore } as any, { title: 'First' })
|
|
421
|
+
const second = await createTodo.func({ todoStore } as any, {
|
|
422
|
+
title: 'Second',
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
assert.equal(second.id, '2')
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
```
|