Contributing to Qodewk

Engineering and contribution guidelines for the Qodewk monorepo.

Thank you for contributing to Qodewk — the universal telemetry and digital receipt generator for the AI coding agent era.

Qodewk is built as a strict, high-performance monorepo adhering to clean architectural boundaries, zero source code exfiltration, and reproducible telemetry.

Monorepo Architecture

The repository is structured into isolated packages with hard boundary invariants:

Qodewk/
├── apps/
│   └── web/            # Next.js App Router (Tailwind v4, Satori, Edge/Serverless)
├── packages/
│   ├── protocol/       # Canonical Zod schemas (ReceiptV1Schema, AttributionModeSchema)
│   ├── pricing/        # Multi-model rate card registry (Claude, OpenAI, Gemini, DeepSeek)
│   ├── core/           # Git engine (simple-git), SQLite, AST complexity, dual estimation
│   ├── cli/            # Terminal binary (Commander, monospace box drawing, qr/barcode)
│   └── action/         # GitHub Action composite workflow for sticky PR comments

Invariant Monorepo Boundary Rules

Edge/Serverless Boundary: apps/web MUST NEVER import packages/core directly. packages/core relies on native Node.js filesystem bindings, SQLite binaries, and local git processes that cannot run in Edge runtimes. apps/web may only import zero-native packages (packages/protocol and packages/pricing).

Development Setup

1. Clone the repository

git clone https://github.com/abushaidislam/Qodewk.git
cd Qodewk

2. Install dependencies

We use pnpm exclusively across all packages:

pnpm install

3. Build workspace packages

Build all workspace packages before running the development server:

pnpm build

4. Start local development

Run the Next.js web application:

pnpm --filter @qodewk/web dev

Or test the CLI locally:

pnpm --filter @qodewk/cli dev

Testing Mandate

All features and bug fixes MUST include corresponding tests using Vitest.

# Run all monorepo test suites
pnpm test

# Run tests for a specific package
pnpm --filter @qodewk/core test

Package Test Guidelines

  1. packages/protocol: Verify Zod schemas reject invalid hashes, negative token counts, or malformed session IDs.
  2. packages/pricing: Test model rate lookup, fuzzy fallbacks, and multi-tier pricing calculation.
  3. packages/core: Ensure footprint harvesters gracefully handle missing transcript directories and non-git environments.
  4. packages/cli: Validate flag parsing, output sanitization, and barcode rendering.
  5. apps/web: Ensure Edge storage adapters and API routes enforce the 50 KB ceiling.

Git Hook Performance Rules

Git hooks (post-commit, post-rewrite) generated by Qodewk must be non-blocking and finish in under 5ms:

# Hook script pattern
(qodewk record-event &) > /dev/null 2>&1
exit 0

Never introduce synchronous remote network calls or blocking file audits into standard Git hooks.