mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
Adds infrastructure for distributing Hapi via npm as a scoped package
(@twsxtd/hapi) with platform-specific optional dependencies. This enables
installation via `npx @twsxtd/hapi` or `bunx @twsxtd/hapi`.
- Add bin/hapi.js wrapper script for platform detection and binary selection
- Create npm/ directory structure for platform-specific packages (darwin-{arm64,x64},
linux-{arm64,x64}, win32-x64)
- Add scripts/prepare-npm-packages.ts to generate platform-specific package.json files
and copy binaries to npm packages
- Add scripts/publish-npm.ts for automated publishing of platform packages
- Update package.json with new scoped name, bin entry, optionalDependencies, and
prepack/publish scripts
- Update .gitignore to ignore generated npm packages and build outputs
- Update .npmignore to only include bin/hapi.js wrapper, excluding source and build files
hapi CLI
Run Claude Code or Codex sessions from your terminal and control them remotely through the hapi server.
What it does
- Starts Claude Code sessions and registers them with hapi-server.
- Starts Codex mode for OpenAI-based sessions.
- Provides an MCP stdio bridge for external tools.
- Manages a background daemon for long-running sessions.
- Includes diagnostics and auth helpers.
Typical flow
- Start the server and set env vars (see ../server/README.md).
- Set the same CLI_API_TOKEN on this machine or run
hapi auth login. - Run
hapito start a session. - Use the web app or Telegram Mini App to monitor and control.
Quickstart
# Point to the server if it is not on localhost:3006
export HAPI_BOT_URL="https://your-server-domain"
hapi # prompts for CLI_API_TOKEN and saves it locally
Commands
hapi- start a Claude Code session (passes through Claude CLI flags)hapi codex- start Codex modehapi mcp- start MCP stdio bridgehapi auth- login/status/logout for CLI_API_TOKENhapi server- start the bundled server (single binary workflow)hapi daemon- manage background servicehapi doctor- diagnostics and cleanup
Configuration
Required:
CLI_API_TOKEN- shared secret; must match the serverHAPI_BOT_URL- server base URL (default: http://localhost:3006)
CLI_API_TOKEN can be set via env or stored in ~/.hapi/settings.json (env wins).
Optional:
HAPI_HOME- config/data directory (default: ~/.hapi)HAPI_EXPERIMENTAL- enable experimental features (true/1/yes)HAPI_HTTP_MCP_URL- default MCP target forhapi mcpHAPI_CLAUDE_PATH- path to a specificclaudeexecutable
Requirements
- Claude CLI installed and logged in (
claudeon PATH). - Bun for building from source.
Build from source
From the repo root:
bun install
bun run build:cli
bun run build:cli:exe
For an all-in-one binary that also embeds the web app:
bun run build:single-exe
Related docs
../server/README.md../web/README.md