Skip to main content
AI Generated Content
πŸ€– This documentation was generated with AI assistance. Please report any issues you find.

Generated Files

When you run pikku, the CLI writes a set of generated files into your outDir (default: .pikku/). These files wire everything together β€” types, metadata, schemas, registration, and service maps. You import from them via the #pikku alias and never edit them by hand.

The #pikku Import Alias​

Your package.json maps #pikku to the generated output directory:

{
"imports": {
"#pikku/*": "./.pikku/*"
}
}

This lets you write clean imports throughout your code:

import { pikkuFunc, wireHTTP } from '#pikku'

Instead of fragile relative paths like ../../.pikku/function/pikku-function-types.gen.js.

Directory Structure​

.pikku/
β”œβ”€β”€ pikku-bootstrap.gen.ts # Master import β€” registers everything
β”œβ”€β”€ pikku-types.gen.ts # Re-exports all wiring-specific types
β”œβ”€β”€ pikku-services.gen.ts # Service dependency map
β”œβ”€β”€ pikku-meta-service.gen.ts # Meta service for Console
β”‚
β”œβ”€β”€ function/
β”‚ β”œβ”€β”€ pikku-function-types.gen.ts # pikkuFunc, pikkuSessionlessFunc, etc.
β”‚ β”œβ”€β”€ pikku-functions.gen.ts # Function registration calls
β”‚ β”œβ”€β”€ pikku-functions-meta.gen.ts # Function metadata (runtime)
β”‚ └── pikku-functions-meta.gen.json # Function metadata (static)
β”‚
β”œβ”€β”€ http/
β”‚ β”œβ”€β”€ pikku-http-types.gen.ts # wireHTTP and related types
β”‚ β”œβ”€β”€ pikku-http-wirings.gen.ts # HTTP route registration
β”‚ β”œβ”€β”€ pikku-http-wirings-meta.gen.ts
β”‚ └── pikku-http-wirings-map.gen.d.ts # Typed route map
β”‚
β”œβ”€β”€ channel/
β”‚ β”œβ”€β”€ pikku-channel-types.gen.ts # wireChannel types
β”‚ β”œβ”€β”€ pikku-channels.gen.ts # Channel registration
β”‚ β”œβ”€β”€ pikku-channels-meta.gen.ts
β”‚ └── pikku-channels-map.gen.d.ts # Typed channel map
β”‚
β”œβ”€β”€ rpc/
β”‚ β”œβ”€β”€ pikku-rpc-wirings-map.gen.d.ts # Public RPC type map
β”‚ β”œβ”€β”€ pikku-rpc-wirings-map.internal.gen.d.ts # Internal RPC type map
β”‚ β”œβ”€β”€ pikku-rpc-wirings-meta.internal.gen.ts # RPC metadata
β”‚ └── pikku-rpc-wirings-meta.internal.gen.json
β”‚
β”œβ”€β”€ queue/
β”‚ β”œβ”€β”€ pikku-queue-types.gen.ts # wireQueueWorker types
β”‚ β”œβ”€β”€ pikku-queue-workers-wirings.gen.ts
β”‚ β”œβ”€β”€ pikku-queue-workers-wirings-meta.gen.ts
β”‚ └── pikku-queue-workers-wirings-map.gen.d.ts
β”‚
β”œβ”€β”€ scheduler/
β”‚ └── pikku-scheduler-types.gen.ts # wireScheduler types
β”‚
β”œβ”€β”€ workflow/
β”‚ β”œβ”€β”€ pikku-workflow-types.gen.ts # Typed workflow definitions
β”‚ β”œβ”€β”€ pikku-workflow-wirings.gen.ts # Workflow registration
β”‚ β”œβ”€β”€ pikku-workflow-wirings-meta.gen.ts
β”‚ β”œβ”€β”€ pikku-workflow-map.gen.d.ts # Typed workflow map
β”‚ └── meta/ # Per-workflow JSON metadata
β”‚ β”œβ”€β”€ myWorkflow.gen.json
β”‚ └── myWorkflow-verbose.gen.json
β”‚
β”œβ”€β”€ agent/
β”‚ β”œβ”€β”€ pikku-agent-types.gen.ts # pikkuAIAgent type helper
β”‚ β”œβ”€β”€ pikku-agent-wirings.gen.ts # Agent registration
β”‚ β”œβ”€β”€ pikku-agent-wirings-meta.gen.ts
β”‚ β”œβ”€β”€ pikku-agent-wirings-meta.gen.json
β”‚ └── pikku-agent-map.gen.d.ts # Typed agent map
β”‚
β”œβ”€β”€ mcp/
β”‚ β”œβ”€β”€ pikku-mcp-types.gen.ts # MCP wiring types
β”‚ β”œβ”€β”€ pikku-mcp-wirings.gen.ts
β”‚ └── pikku-mcp-wirings-meta.gen.ts
β”‚
β”œβ”€β”€ cli/
β”‚ β”œβ”€β”€ pikku-cli-types.gen.ts # wireCLI, pikkuCLICommand types
β”‚ β”œβ”€β”€ pikku-cli-wirings.gen.ts
β”‚ β”œβ”€β”€ pikku-cli-wirings-meta.gen.ts
β”‚ └── pikku-cli-bootstrap.gen.ts
β”‚
β”œβ”€β”€ trigger/
β”‚ β”œβ”€β”€ pikku-trigger-types.gen.ts # wireTrigger types
β”‚ β”œβ”€β”€ pikku-trigger-wirings.gen.ts
β”‚ └── pikku-trigger-wirings-meta.gen.ts
β”‚
β”œβ”€β”€ gateway/
β”‚ └── pikku-gateway-wirings.gen.ts # Gateway registration
β”‚
β”œβ”€β”€ middleware/
β”‚ β”œβ”€β”€ pikku-middleware.gen.ts # Middleware registration
β”‚ └── pikku-middleware-groups-meta.gen.json
β”‚
β”œβ”€β”€ permissions/
β”‚ β”œβ”€β”€ pikku-permissions.gen.ts
β”‚ └── pikku-permissions-groups-meta.gen.json
β”‚
β”œβ”€β”€ schemas/
β”‚ β”œβ”€β”€ register.gen.ts # Schema registration
β”‚ └── schemas/ # Individual JSON schema files
β”‚
β”œβ”€β”€ secrets/
β”‚ β”œβ”€β”€ pikku-secret-types.gen.ts # Typed secret definitions
β”‚ β”œβ”€β”€ pikku-secrets.gen.ts # Typed SecretService wrapper
β”‚ └── pikku-secrets-meta.gen.json
β”‚
β”œβ”€β”€ variables/
β”‚ β”œβ”€β”€ pikku-variable-types.gen.ts # Typed variable definitions
β”‚ β”œβ”€β”€ pikku-variables.gen.ts # Typed VariablesService wrapper
β”‚ └── pikku-variables-meta.gen.json
β”‚
β”œβ”€β”€ credentials/
β”‚ β”œβ”€β”€ pikku-credentials.gen.ts # Typed credential wrappers
β”‚ └── pikku-credentials-meta.gen.json
β”‚
β”œβ”€β”€ addon/
β”‚ β”œβ”€β”€ pikku-package.gen.ts # Addon package registration
β”‚ └── pikku-addon-types.gen.ts # Addon config/service types
β”‚
└── console/
β”œβ”€β”€ pikku-node-types.gen.ts # Console node types
└── pikku-addon-meta.gen.json # Addon metadata for Console

Not every directory is generated for every project β€” only the ones relevant to your wirings. If you don't use workflows, there's no workflow/ directory.

Key Files​

pikku-bootstrap.gen.ts​

The master entry point. Importing this file registers all your functions, wirings, metadata, middleware, schemas, and addon bootstraps. Your runtime entry point should import it before doing anything else:

import './.pikku/pikku-bootstrap.gen.js'

pikku-types.gen.ts​

Re-exports all the type helpers you use in your code β€” pikkuFunc, pikkuSessionlessFunc, wireHTTP, wireChannel, pikkuAIAgent, etc. This is what #pikku resolves to when you write:

import { pikkuFunc } from '#pikku'

pikku-services.gen.ts​

Maps which singleton and wire services your project actually uses. The CLI detects this by analyzing which services your functions destructure. This powers:

  • Type narrowing β€” RequiredSingletonServices only requires the services you use
  • Deploy analysis β€” the deploy pipeline knows what infrastructure each function needs
  • Validation β€” the Console warns if a required service isn't provided

Function Types (function/pikku-function-types.gen.ts)​

This is the big one. It generates type-safe function constructors that are parameterized with your project's specific UserSession, SingletonServices, Services, and Config types:

// These come from your application-types.d.ts
import type { UserSession } from '../../src/application-types.d.js'
import type { SingletonServices } from '../../src/application-types.d.js'
import type { Services } from '../../src/application-types.d.js'

// The generated pikkuFunc knows your exact types
export function pikkuFunc<In, Out>(config: {
func: (services: SingletonServices, data: In, wire: PikkuWire<In, Out, true, UserSession>) => Promise<Out>
// ...
}): { func: CorePikkuFunction<In, Out, SingletonServices, UserSession> }

This is why pikkuFunc "just works" with autocomplete for your services and session β€” the types are generated from your actual code.

Metadata Files​

Files ending in .gen.json contain static metadata used by:

  • The Console β€” displays functions, routes, agents, workflows visually
  • The deploy pipeline β€” analyzes what needs to be deployed
  • OpenAPI generation β€” builds API specs from HTTP metadata
  • MCP servers β€” exposes tool/resource/prompt catalogs

The .gen.ts counterparts register the same metadata at runtime.

Regeneration​

Generated files are fully deterministic β€” same source code always produces the same output. You should:

  • Add .pikku/ to .gitignore β€” regenerate in CI, don't commit
  • Run pikku in your build step β€” "prebuild": "pikku" in package.json
  • Use pikku watch in development β€” files stay in sync as you edit

Next Steps​

  • Configuration β€” Override output paths for any generated file
  • Tree-Shaking β€” How filtering reduces generated output