PUNKthe adaptive runtime

//DOCS Development

Monorepo workflow, package boundaries, tests, and doc rules.

Development

This guide is for contributors working inside the Punk monorepo.

Setup

bun install
bun run dev
bun run demo

Validation:

bun test
bun run typecheck

macOS menu bar app:

bun run menubar
open apps/menubar/dist/Punk.app

Workspace Layout

apps/
  api/       gateway, REST API, dashboard, router, providers
  worker/    durable job worker
  demo/      narrated demo agent
  mcp/       Runtime Engine MCP server and prompt ingest hook
  menubar/   native macOS companion

packages/
  trace-schema/
  database/
  cache-core/
  fingerprint/
  governance-core/
  web-core/
  workflow-core/
  mcp-client/
  artifact-core/
  replay-core/
  synthesis/
  learning/
  jobs/
  sdk/

Development Rules

Keep Contracts Central

Runtime entity types belong in @punk/trace-schema.

Do not invent parallel run, artifact, approval, policy, SOM, or route types in app code unless they are strict view models.

Keep Storage Behind PunkStore

No raw SQL outside packages/database.

If a feature needs storage, add a named method to PunkStore, then implement it in:

  • SQLite adapter.
  • Memory adapter.
  • Postgres adapter.
  • Conformance tests where relevant.

Keep App Packages Thin

App packages wire process lifecycle, Hono routes, provider IO, static assets, and CLI/demo UX. Core logic should live in packages.

Prefer Evidence Over Magic

Any optimization feature should produce:

  • Trace events.
  • Route explanation.
  • Evaluation evidence where relevant.
  • Audit event when governance/operator decision is involved.
  • Fallback behavior.

Update Docs With Behavior

When changing:

Testing Map

AreaTests
API integration/security/streaming/approvalsapps/api/test/*.test.ts
Cachepackages/cache-core/test/*.test.ts
Databasepackages/database/test/*.test.ts
Fingerprintspackages/fingerprint/test/*.test.ts
Governancepackages/governance-core/test/*.test.ts
Learningpackages/learning/test/*.test.ts
Replaypackages/replay-core/src/*.test.ts
SDKpackages/sdk/test/*.test.ts
Synthesispackages/synthesis/test/*.test.ts
Web runtimepackages/web-core/test/*.test.ts
Workflow runtimepackages/workflow-core/test/*.test.ts, apps/api/test/workflows.test.ts
MCP client and registryapps/api/test/mcp.test.ts
Workerpackages/jobs/test/*.test.ts

Adding An Endpoint

  1. Add the route in apps/api/src/api.ts.
  2. Reuse existing auth context and tenant scoping.
  3. Add storage methods to PunkStore if needed.
  4. Add tests in apps/api/test/.
  5. Update API.
  6. Add dashboard/SDK support only after the route contract is stable.

Adding A Package

  1. Add packages/<name>/package.json.
  2. Keep exports explicit.
  3. Depend on @punk/trace-schema for shared contracts.
  4. Avoid app-level imports from packages.
  5. Add tests.
  6. Add it to Architecture.

Active Development Expectations

Punk moves quickly. Before starting a large change:

git pull --ff-only origin main
git status --short

While working, assume files may change. Before finalizing docs or code, re-read the specific files you touched and run targeted validation.