Work in progress — the project is under active construction. Contributions, ideas, and feedback of any kind are very welcome! Feel free to open an issue or submit a pull request.
An OpenCode AI agent that helps developers build decentralized applications on the Midnight Network blockchain.
The agent handles all the surrounding complexity of a Midnight dApp — project scaffolding, package wiring, workspace configuration, API plumbing, CLI setup, and UI skeleton — so that developers can open their editor and immediately focus on what actually matters: writing the smart contract.
It is intentionally not designed to author the smart contract for you. The Compact contract is the core of your application, and that creative and architectural work should remain in the developer's hands. The agent clears everything else out of the way so that writing the contract is the first thing you do, not the tenth.
.opencode/
├── agents/
│ ├── main.md # Orchestrator — routes tasks to sub-agents
│ └── subagents/
│ └── midnight-dapp-initializer.md # Scaffolds the full dApp folder structure
└── skills/
└── midnight-dapp-init/ # Reusable skill: initialise a new dApp
├── SKILL.md # Skill definition and workflow
└── templates/ # Template files copied into new dApps
├── root/ # Workspace-level files
├── contracts/ # Compact contract + TypeScript witnesses
├── api/ # Backend API package
├── cli/ # CLI package
└── ui/ # React frontend package
The main agent is the entry point. It analyses your request and either answers directly or delegates work to the appropriate sub-agent:
- Information requests — questions about Midnight docs, Compact syntax, version compatibility, or example projects are answered directly by the main agent using the
midnight-mcptools. - Scaffolding requests — new project setup is delegated to the
midnight-dapp-initializersub-agent.
Currently available sub-agent:
| Sub-agent | Responsibility |
|---|---|
midnight-dapp-initializer |
Creates the monorepo layout (contracts, api, cli, ui packages) from templates, fetches the latest package versions from the Midnight compatibility matrix, and wires everything together |
<your-dapp>/
└── packages/
├── contracts/ # Compact smart contract + TypeScript witnesses
├── api/ # Backend service that talks to the Midnight node
├── cli/ # Command-line interface for contract deployment & interaction
└── ui/ # Frontend application
# Clone the repo
git clone https://github.com/navigate226/midnight-opencode-agent
cd midnight-opencode-agent
# Launch OpenCode with this agent
opencode --agent mainOnce OpenCode is running, describe the dApp you want to build and the agent will take it from there.
The agent uses the following Model Context Protocol servers to access Midnight-specific knowledge and tooling:
| Server | Source |
|---|---|
midnight-mcp |
https://github.com/Olanetsoft/midnight-mcp |
The server is configured in opencode.json.