@dkod/pi

dkod extension for Pi — parallel agent execution with AST-level semantic merging

Package details

extension

Install @dkod/pi from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@dkod/pi
Package
@dkod/pi
Version
0.1.7
Published
Apr 18, 2026
Downloads
752/mo · 14/wk
Author
dkod
License
MIT
Types
extension
Size
329.2 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

The Problem

Traditional AI agent workflows hit a wall: Git becomes a bottleneck.

You deploy 3 agents on the same repo. Agent A refactors auth. Agent B adds an endpoint. Agent C writes tests. They all finish in 2 minutes. Then you spend 45 minutes resolving merge conflicts.

Even worse — most tools serialize agents to avoid this. One agent at a time. One PR at a time. Sequential. Slow.

AI agents are fast. Git-based workflows make them wait in line.

The Fix

dkod replaces the bottleneck — not the agents. This extension brings dkod to Pi:

  • Multiple agents from multiple users work on the same functions, same files, same repository — simultaneously
  • Each agent gets an isolated session overlay (copy-on-write, not a clone or worktree)
  • Changes merge by function, type, and import — not by line
  • PRs land with zero conflicts in under 60 seconds

The result: 24 minutes becomes 2 minutes. 4 conflicts becomes 0.

Session Isolation

Each agent gets its own overlay on top of the shared repo. Writes go to the overlay, reads fall through to the base. dkod uses AST-level symbol tracking (via tree-sitter) to understand exactly which functions, classes, and methods each agent touches.

No clones. No worktrees. No locks. No waiting.

10 agents editing simultaneously, each in their own sandbox.

AST-Level Semantic Merge

Forget line-based diffs. dkod detects conflicts at the symbol level — functions, types, constants.

Two agents editing different functions in the same file? No conflict. Merged in under 50ms.

Two agents rewriting the same function? Caught instantly, with a precise report — not a wall of <<<<<<< markers.

Verification Pipeline

Every changeset passes through lint, type-check, and test gates before it touches main. Automated code review with scoring on every submission.

Agents get structured failure data — not log dumps — so they fix issues and retry autonomously.

Average time from submission to verified merge: under 30 seconds.

Autonomous Build Pipeline

One prompt in. Working, tested PR out. Zero human interaction.

The harness orchestrates: Planner decomposes work by symbol, N Generators implement in parallel via dkod sessions, Evaluator tests the live app via chrome-devtools.

Based on Anthropic's Planner-Generator-Evaluator research.

Quick Start

Install

# Install dk CLI
curl -fsSL https://dkod.io/install.sh | sh

# Authenticate
dk login

# Install the Pi extension
pi install npm:@dkod/pi

Build something

/dkh Build a project management webapp with kanban boards, team collaboration, and real-time updates

That's it. The harness does the rest.

Command Description
/dkh <prompt> Full autonomous build — plan, build, land, eval, ship
/dkh:plan <prompt> Planning only — produce spec + parallel work units
/dkh:eval Evaluate current application against criteria
/dkod:config Verify dk CLI installation and authentication

How It Works

%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#06b6d4', 'primaryTextColor': '#f0f0f3', 'lineColor': '#06b6d4' }}}%%
sequenceDiagram
    participant U as User
    participant O as Orchestrator
    participant P as Planner
    participant G as Generators (N)
    participant D as dkod
    participant E as Evaluator

    U->>O: /dkh "build a task app"
    O->>P: expand prompt into spec + work units
    P-->>O: plan with N parallel units

    Note over G,D: Each generator gets an isolated dkod session

    par Generator 1
        O->>G: Pi RPC subprocess
        G->>D: connect → file-write → submit
    and Generator 2
        O->>G: Pi RPC subprocess
        G->>D: connect → file-write → submit
    and Generator N
        O->>G: Pi RPC subprocess
        G->>D: connect → file-write → submit
    end

    Note over D: AST-level merge — zero conflicts

    G-->>O: N changesets
    O->>D: verify → review → approve → merge

    O->>E: start app, test every button via chrome-devtools
    E-->>O: eval report with scores + evidence

    alt PASS
        O->>D: push PR to GitHub
        D-->>U: PR with eval results
    else RETRY
        O->>G: re-dispatch failed units with feedback
    else REPLAN
        O->>P: structural flaw — re-plan from scratch
    end

Why dkod, Not Git Worktrees?

Git worktrees dkod sessions
Setup per agent Full clone or worktree (~seconds) Copy-on-write overlay (~ms)
Merge strategy Line-based diff (conflicts on same file) AST-level symbol merge (conflicts only on same function)
10 agents, same file 10 worktrees, manual conflict resolution 10 overlays, automatic merge
Merge time Minutes + human review Under 50ms, automated
Verification Manual CI pipeline Built-in lint + type-check + test + code review
Disk usage Full copy per agent Overlay only (changed symbols)

Architecture

pi-extension/
├── src/
│   ├── index.ts              Extension entry — registers commands + guard
│   ├── guard.ts              Runtime tool blocker (Write/Edit/git blocked)
│   ├── parallel.ts           RPC subprocess manager (N generators)
│   ├── commands/
│   │   ├── dkh.ts            /dkh — full autonomous pipeline
│   │   ├── plan.ts           /dkh:plan — planning only
│   │   ├── eval.ts           /dkh:eval — evaluate current app
│   │   └── config.ts         /dkod:config — verify setup
│   └── prompts/
│       ├── orchestrator.md   Drives the autonomous loop
│       ├── planner.md        Prompt → spec → parallel work units
│       ├── generator.md      Implements one unit per dkod session
│       └── evaluator.md      Adversarial testing via chrome-devtools
└── skills/dkh/
    └── SKILL.md              Pi skill definition

Key design decisions:

  • dk CLI (--json mode) is the sole dkod interface — no HTTP client, no custom tool wrappers
  • Runtime tool enforcement via Pi's tool_call event — generators are blocked from using Write/Edit/Bash-file-writes at the runtime level, not just prompt instructions
  • Pi RPC subprocesses give true OS-level parallelism for generators — each subprocess is a full Pi instance with its own dkod session
  • Agent prompts adapted from the dkod harness for Pi + dk CLI syntax

Prerequisites

Inspired By

License

MIT — free to use, fork, and build on.