Drop-in tooling that makes a repository ready for AI coding agents.
Codebat is a lightweight, Windows-first launcher/bootstrap layer. Add it as a Git submodule directly inside your project. Collaborators can then launch OpenCode or Pi without manually installing each agent or a global Codebat CLI. Node.js and npm are still required; agent credentials are configured by users through the agents themselves.
For the easiest start, open the Codebat folder and double-click codebat.bat,
then select an agent.
The menu lists the agents by name. Enter a number to launch, or Q to quit.
Invalid selections let you try again. Startup errors wait for acknowledgement;
successful agent launches do not add a pause.
From your project's root in Windows Command Prompt:
git submodule add https://github.com/Geonhui-Lee/codebat.git codebat
git commit -m "chore: add Codebat submodule"
codebat\codebat.bat opencodeOr launch Pi:
codebat\codebat.bat piList agents or forward arguments:
codebat\codebat.bat list
codebat\codebat.bat opencode --help
codebat\codebat.bat pi --versionInside the Codebat directory, the equivalent commands are codebat opencode
and codebat pi. No PATH changes or global Codebat installation are needed.
Running codebat without arguments opens the same menu. Unknown commands print
help and return a nonzero exit code; codebat --help and codebat -h print help
successfully. Explicit commands do not pause on errors.
Important
Keep Codebat directly inside the project root. Its immediate parent is
always the agent's working directory, regardless of where you invoke the
launcher. my-project\tools\codebat would target tools, not my-project.
Paths containing spaces are supported; quote the launcher path when needed.
- Windows and Node.js with npm on
PATH(a currently supported LTS is recommended). - Pi specifically requires Node.js 22.19.0 or newer. This check does not block OpenCode; OpenCode's own upstream requirements still apply.
- Git for Windows; Pi uses its bundled Git Bash by default.
- Internet access for the first installation of each agent.
No root npm install is necessary. The selected agent installs automatically
on first launch. Later launches validate and reuse its local installation.
For a new clone:
git clone --recurse-submodules <repository-url>
cd <repository-directory>
git config --local submodule.recurse trueFor an existing clone, run from the project root:
git submodule update --init --recursive
git config --local submodule.recurse trueThen double-click codebat.bat inside the Codebat folder, or use
codebat\codebat.bat opencode or codebat\codebat.bat pi from Command Prompt.
Each collaborator has their own ignored installation and agent state.
The recursive Git setting is local to each clone, so each collaborator must
set it themselves. With this setting, normal git pull updates Codebat to the
commit recorded by the parent project. If needed, follow a pull with
git submodule update --init --recursive explicitly.
| Agent | Direct command | Compatibility wrapper | npm package |
|---|---|---|---|
| OpenCode | codebat\codebat.bat opencode |
_opencode.bat |
opencode-ai |
| Pi Coding Agent | codebat\codebat.bat pi |
_pi.bat |
@earendil-works/pi-coding-agent |
Use codebat.bat for File Explorer's interactive menu. The existing
_opencode.bat and _pi.bat remain thin compatibility wrappers. They forward
arguments and return the agent's exit code without pausing on errors.
codebat/
├─ codebat.bat # primary entry point
├─ _opencode.bat # compatibility wrapper
├─ _pi.bat # compatibility wrapper
├─ agents.json # packages, versions and agent-specific requirements
├─ lib/
│ ├─ codebat.cjs # shared bootstrap and launch logic
│ └─ install.bat # small Windows npm bridge
├─ runtime/ # generated, ignored
│ ├─ opencode/ # own package.json, lockfile, node_modules, npm cache
│ └─ pi/ # own package.json, lockfile, node_modules, npm cache
├─ .opencode/ # existing project-local OpenCode user state
└─ .pi/agent/ # existing project-local Pi user state
Each runtime is a private npm project. Installing Pi cannot modify OpenCode's
dependency tree or require repairing it, and vice versa. Nothing installs into
the root node_modules or the parent project's dependency environment.
The root package.json only provides dependency-free maintainer tests.
The shared helper:
- Resolves Codebat and its immediate parent workspace.
- Checks Node/npm and the selected agent's additional requirements.
- Checks the configured package version, executable, and
--versionresponse. - Installs missing, mismatched or broken packages in that agent's runtime.
- Validates the installation with visible diagnostics.
- Executes the agent in the parent directory and returns its exit code.
Both installations use npm install --save-exact --ignore-scripts. Only
OpenCode runs npm rebuild opencode-ai for its required installation step;
Pi's dependency lifecycle scripts remain disabled. npm installation/rebuild
output is not suppressed.
Top-level package versions are pinned in agents.json to the existing supported
versions. Changing a pin causes that agent to reinstall on its next launch.
Each collaborator's generated lockfile records their resolved dependencies;
transitive dependencies are not centrally locked by Codebat.
A small Node helper replaces duplicated batch installation logic and avoids
re-parsing agent arguments through cmd.exe. It reads npm package bin
metadata and launches native .exe entries directly or JavaScript entries
with Node. Node was already a prerequisite; the helper adds no dependencies.
Only npm installation uses the batch bridge.
OpenCode receives XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME, and
XDG_STATE_HOME under codebat\.opencode. Pi receives
PI_CODING_AGENT_DIR=codebat\.pi\agent. Existing state directories are
preserved so upgrading does not discard configuration or credentials.
Each agent's npm cache also stays in its own runtime.
runtime/, .opencode/, .pi/, and legacy node_modules/ are ignored by Git.
Do not commit credentials or runtime files. This is state redirection, not a
sandbox: agents can still read project configuration, use external tools,
and create project files. Explicit upstream configuration or third-party tools
may use other locations; Codebat does not replace the user's home directory.
The old root node_modules and package lock are no longer used for launching.
The first v0.2.0 launch installs each selected agent in its isolated runtime.
Existing .opencode / .pi state remains in place. After verifying the new
launchers, you may remove the unused root node_modules yourself. Codebat
does not delete or migrate that directory automatically.
Collaborators normally follow the Codebat commit pinned by their parent project, rather than independently upgrading it.
Project maintainers can intentionally select a newer Codebat commit:
git submodule update --remote codebat
git add codebat
git commit -m "chore: update Codebat submodule"Review/test the new commit before committing the updated submodule pointer. Collaborators receive that pointer through normal project updates.
Install Node.js with npm, open a new Command Prompt, and
check node --version and npm --version. Pi requires at least 22.19.0.
Read the npm or agent output, check internet/proxy access, and retry. To diagnose an existing runtime manually from the project root:
cd codebat\runtime\opencode
npm install --save-exact --ignore-scripts opencode-ai@1.18.29
npm rebuild opencode-aiFor Pi, use its separate runtime and do not rebuild OpenCode:
cd codebat\runtime\pi
npm install --save-exact --ignore-scripts @earendil-works/pi-coding-agent@0.85.0If the runtime is corrupt, close that agent and remove only its
codebat\runtime\<agent> directory, then relaunch. Keep .opencode and
.pi unless you intentionally want to reset user state.
Place the submodule directly inside the intended project. Initialize a missing
submodule with git submodule update --init --recursive from the project root.
Launching the standalone Codebat repository targets its parent, not Codebat.
From the Codebat repository:
npm test
git diff --checkTests use Node's built-in test runner, temporary directories and mock agents/npm.
They do not download agents. Shared-logic tests cover dispatch, quoting-sensitive
arguments, workspace resolution, state, isolated installations, validation,
agent-specific Node requirements, native/JavaScript execution and exit codes.
Windows-only tests exercise the actual .bat entry points and missing
Node/npm handling, menu selection/retry/quit and interactive error acknowledgement.
GitHub Actions runs the full suite on Windows with Node
22.19.0 and 24. Non-Windows hosts can run shared-logic tests, but batch tests
are skipped; agent launching itself remains Windows-only.
To add a future compatible npm-based agent, add its package/version/bin, local
state mapping and any minimum Node requirement to agents.json. Add a thin
root _<agent>.bat wrapper if useful, extend tests, and update this README.
No separate dependency framework or duplicated installer is needed.