Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

v2 init

cyhhao3faf4712966b
diff --git a/.env.example b/.env.example
deleted file mode 100644
index a8590bd3b..000000000
--- a/.env.example
+++ /dev/null
@@ -1,74 +0,0 @@
-# IM Platform Selection
-# Options: slack,telegram
-IM_PLATFORM=slack
-
-# ============== Slack Configuration ==============
-# Required for Slack
-SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
-
-# Required for Socket Mode (recommended)
-SLACK_APP_TOKEN=xapp-your-slack-app-token
-
-# Optional: For webhook mode instead of Socket Mode
-SLACK_SIGNING_SECRET=your-signing-secret
-
-# Optional: Whitelist of allowed channel IDs (comma-separated)
-# Examples:
-# null or omit: Accept all channels
-# [C1234567890,C0987654321]: Only accept messages from these channel IDs
-SLACK_TARGET_CHANNEL=[]
-
-# Optional: Require @mention in channels (ignored in DMs)
-# If true, bot only responds when @mentioned in channels. Default: false
-SLACK_REQUIRE_MENTION=false
-
-# ============== Telegram Configuration ==============
-TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
-
-# Optional: Whitelist of allowed chat IDs (comma-separated)
-# Examples:
-# null or omit: Accept all chats
-# [123456789,987654321]: Only accept messages from these chat IDs
-TELEGRAM_TARGET_CHAT_ID=[]
-
-# Claude Configuration
-CLAUDE_PERMISSION_MODE=bypassPermissions
-
-# Default working directory for all agents (recommended)
-AGENT_DEFAULT_CWD=./_tmp
-# Legacy alias (still supported):
-# CLAUDE_DEFAULT_CWD=./_tmp
-# Optional: Custom system prompt
-CLAUDE_SYSTEM_PROMPT=
-
-# Application Configuration
-LOG_LEVEL=INFO
-
-# Acknowledgement mode before agent processing
-# Options:
-# - reaction (default): add 👀 / :eyes: to the user's message
-# - message: send "📨 <agent> received, processing..." as a bot message
-ACK_MODE=reaction
-
-# Agent routing & Codex (optional)
-# Enable Codex CLI support (requires codex to be installed locally). Defaults to true.
-CODEX_ENABLED=true
-# Override Codex CLI binary (defaults to "codex")
-CODEX_CLI_PATH=codex
-# Extra CLI args appended to every codex exec invocation (use shell-style quoting)
-CODEX_EXTRA_ARGS=
-# Optionally force a specific Codex model
-CODEX_DEFAULT_MODEL=
-
-# OpenCode (optional)
-# Enable OpenCode support (requires opencode to be installed). Defaults to false.
-OPENCODE_ENABLED=false
-# Override OpenCode CLI binary (defaults to "opencode")
-OPENCODE_CLI_PATH=opencode
-# OpenCode server port (defaults to 4096)
-OPENCODE_PORT=4096
-# Note: OpenCode agent/model/reasoningEffort settings are read from ~/.config/opencode/opencode.json
-# and can be overridden per-channel via the Agent Settings dialog in Slack.
-
-# Path to agent routing file (YAML/JSON). Defaults to config/agent_routes.yaml when present.
-AGENT_ROUTE_FILE=
diff --git a/.gitignore b/.gitignore
index 8471ffe46..50b0c5a94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -148,6 +148,7 @@ demolog.log
_tmp/
.DS_Store
logs/
+.vibe_remote/
.bot.pid
user_settings.json
agent_routes.yaml
diff --git a/AGENTS.md b/AGENTS.md
index 7a6fc6a46..2aaf18fbe 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -41,7 +41,7 @@ This file defines how coding agents should work in this repository.
### Git Hygiene & Security
- Commit messages: use `type(scope): summary`.
-- Never commit secrets (e.g., `.env`, tokens, credentials files).
+- Never commit secrets (tokens, credentials files).
- Avoid destructive git operations unless explicitly requested (e.g., `reset --hard`, force-push).
## 2) Project-Specific (Vibe Remote)
diff --git a/CLAUDE.md b/CLAUDE.md
index b2528f00c..250403c76 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -34,7 +34,7 @@ This file defines how coding agents should work in this repository.
### Git Hygiene & Security
- Commit messages: use `type(scope): summary`.
-- Never commit secrets (e.g., `.env`, tokens, credentials files).
+- Never commit secrets (tokens, credentials files).
- Avoid destructive git operations unless explicitly requested (e.g., `reset --hard`, force-push).
## 2) Project-Specific (Vibe Remote)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 42ab36336..33d809bf5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -5,9 +5,8 @@ Thanks for your interest in contributing!
## Getting Started
- Fork the repo and create a feature branch
-- Create and activate a virtualenv
-- Install deps: `pip install -r requirements.txt`
-- Copy `.env.example` to `.env` and fill values
+- Install the CLI with `uv tool install vibe`
+- Run `vibe` to complete the setup UI
## Development
diff --git a/config/__init__.py b/config/__init__.py
index cfa8a32c1..12c99c5cc 100644
--- a/config/__init__.py
+++ b/config/__init__.py
@@ -4,6 +4,10 @@ from .paths import (
get_state_dir,
get_logs_dir,
get_runtime_dir,
+ get_runtime_pid_path,
+ get_runtime_ui_pid_path,
+ get_runtime_status_path,
+ get_runtime_doctor_path,
get_config_path,
get_settings_path,
get_sessions_path,
@@ -22,6 +26,10 @@ __all__ = [
"get_state_dir",
"get_logs_dir",
"get_runtime_dir",
+ "get_runtime_pid_path",
+ "get_runtime_ui_pid_path",
+ "get_runtime_status_path",
+ "get_runtime_doctor_path",
"get_config_path",
"get_settings_path",
"get_sessions_path",
diff --git a/config/paths.py b/config/paths.py
index fbfc18a0a..b752df223 100644
--- a/config/paths.py
+++ b/config/paths.py
@@ -21,6 +21,22 @@ def get_runtime_dir() -> Path:
return get_vibe_remote_dir() / "runtime"
+def get_runtime_pid_path() -> Path:
+ return get_runtime_dir() / "vibe.pid"
+
+
+def get_runtime_ui_pid_path() -> Path:
+ return get_runtime_dir() / "vibe-ui.pid"
+
+
+def get_runtime_status_path() -> Path:
+ return get_runtime_dir() / "status.json"
+
+
+def get_runtime_doctor_path() -> Path:
+ return get_runtime_dir() / "doctor.json"
+
+
def get_config_path() -> Path:
return get_config_dir() / "config.json"
diff --git a/config/v2_config.py b/config/v2_config.py
index a0337f6b7..dea635a9c 100644
--- a/config/v2_config.py
+++ b/config/v2_config.py
@@ -21,6 +21,10 @@ class SlackConfig(BaseIMConfig):
require_mention: bool = False
target_channels: Optional[List[str]] = None
+ @classmethod
+ def from_env(cls):
+ raise RuntimeError("V2 does not support env-based config")
+
def validate(self) -> None:
if not self.bot_token or not self.bot_token.startswith("xoxb-"):
raise ValueError("Invalid Slack bot token format (should start with xoxb-)")
diff --git a/docs/CODEX_SETUP.md b/docs/CODEX_SETUP.md
index 8cb7e419d..71132943e 100644
--- a/docs/CODEX_SETUP.md
+++ b/docs/CODEX_SETUP.md
@@ -14,13 +14,18 @@ Codex CLI must be available on the PATH of the host running Vibe Remote. The bot
## 2. Configure environment variables
-In `.env` (copied from `.env.example`):
-
-```
-CODEX_ENABLED=true # default; set false only if CLI is unavailable
-CODEX_CLI_PATH=codex # customise if the binary lives elsewhere
-CODEX_DEFAULT_MODEL=gpt-5-codex # optional
-CODEX_EXTRA_ARGS=--ask-for-approval never # optional extra flags
+In `~/.vibe_remote/config/config.json`:
+
+```json
+{
+ "agents": {
+ "codex": {
+ "enabled": true,
+ "cli_path": "codex",
+ "default_model": "gpt-5-codex"
+ }
+ }
+}
```
No additional flag is required to bypass approvals—the bot always adds `--dangerously-bypass-approvals-and-sandbox`.
@@ -50,8 +55,7 @@ Each Slack channel ID (starts with `C`) gets its own agent. Routes fall back to
## 4. Restart the bot and test
```bash
-source venv/bin/activate
-./start.sh
+vibe
```
In a routed Slack channel run `@VibeRemote status` or any question—you should see the bot react with 👀 (default) or an acknowledgement like `📨 Codex received, processing...` (when `ACK_MODE=message`), followed by Codex’s reply. If the CLI is missing, the bot will reply with “Agent `codex` is not configured”.
diff --git a/docs/DYNAMIC_ROUTING_DESIGN.md b/docs/DYNAMIC_ROUTING_DESIGN.md
index 627c39150..a58a132f3 100644
--- a/docs/DYNAMIC_ROUTING_DESIGN.md
+++ b/docs/DYNAMIC_ROUTING_DESIGN.md
@@ -53,7 +53,7 @@ class UserSettings:
## Routing Resolution Priority
```
-1. channel_routing.agent_backend (from user_settings.json)
+1. channel_routing.agent_backend (from `~/.vibe_remote/state/settings.json`)
↓ if null
2. agent_routes.yaml overrides[channel_id]
↓ if not found
diff --git a/docs/plans/message_consolidation_and_toolcall.md b/docs/plans/message_consolidation_and_toolcall.md
index 259f7561a..1c9d64066 100644
--- a/docs/plans/message_consolidation_and_toolcall.md
+++ b/docs/plans/message_consolidation_and_toolcall.md
@@ -69,5 +69,5 @@ Toolcall 是“Agent 调用工具”的简洁表示:
## 配置 / 兼容性
-- OpenCode 单次 HTTP 请求超时固定为 60s(目前不通过 `.env` 配置),用于轮询等请求,不限制任务运行时长。
+- OpenCode 单次 HTTP 请求超时固定为 60s(目前不通过 config.json 配置),用于轮询等请求,不限制任务运行时长。
- 历史配置兼容:旧的 `response/user` message type 会 canonicalize 为 `toolcall`。
diff --git a/docs/plans/v2/04_v2_milestones.md b/docs/plans/v2/04_v2_milestones.md
index 14fa7d793..12e4e3f76 100644
--- a/docs/plans/v2/04_v2_milestones.md
+++ b/docs/plans/v2/04_v2_milestones.md
@@ -29,11 +29,10 @@ Proposed structure:
- One-line install (Bash + `uv` tooling).
- CLI commands:
- - `vibe-remote setup` (launch local config UI)
- - `vibe-remote start` (run service)
- - `vibe-remote status` (runtime status)
- - `vibe-remote stop` (stop runtime)
- - `vibe-remote doctor` (self-check)
+ - `vibe` (smart entrypoint for setup/start)
+ - `vibe status` (runtime status)
+ - `vibe stop` (stop runtime)
+ - `vibe doctor` (self-check)
### M3: Local Web UI (Setup Wizard)
diff --git a/docs/plans/v2/07_repo_and_split.md b/docs/plans/v2/07_repo_and_split.md
index 29ca824a7..e04ea954b 100644
--- a/docs/plans/v2/07_repo_and_split.md
+++ b/docs/plans/v2/07_repo_and_split.md
@@ -69,8 +69,8 @@ Keep one repo for fast iteration. Add a `cloud/` module:
Split into two repos after V2 stabilizes:
-- `vibe-remote-gateway` (client)
-- `vibe-remote-cloud` (server)
+- `vibe-gateway` (client)
+- `vibe-cloud` (server)
## Notes
diff --git a/docs/plans/v2/08_web_ui_flow.md b/docs/plans/v2/08_web_ui_flow.md
index 80acf2210..36affeb16 100644
--- a/docs/plans/v2/08_web_ui_flow.md
+++ b/docs/plans/v2/08_web_ui_flow.md
@@ -4,7 +4,7 @@ This document defines the local setup UI flow, covering SaaS and self-host modes
## Entry
-- CLI command: `vibe-remote setup`
+- CLI command: `vibe`
- Starts a local web server and opens the browser.
## Page Outline
diff --git a/modules/im/__init__.py b/modules/im/__init__.py
index 6fdce8ff1..b0f9cda28 100644
--- a/modules/im/__init__.py
+++ b/modules/im/__init__.py
@@ -61,11 +61,3 @@ def get_supported_platforms():
return IMFactory.get_supported_platforms()
-# Version info
-def get_version():
- """Get package version
-
- Returns:
- Version string
- """
- return __version__
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 31e17f105..fa52e97b4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,10 +1,7 @@
claude-code-sdk>=0.0.25
-python-telegram-bot>=20.0
-python-dotenv>=1.0.0
anyio>=4.0.0
slack-sdk>=3.26.0
aiohttp>=3.8.0
-telegramify-markdown>=0.5.0
markdown_to_mrkdwn>=0.2.0
typing_extensions>=4.12.2
PyYAML>=6.0
diff --git a/start.sh b/start.sh
deleted file mode 100755
index 06f8dd766..000000000
--- a/start.sh
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/bash
-
-# Get the absolute path of current directory
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-LOG_DIR="$SCRIPT_DIR/logs"
-LOG_FILE="$LOG_DIR/bot_$(date +%Y%m%d_%H%M%S).log"
-PID_FILE="$SCRIPT_DIR/.bot.pid"
-MAIN_PATH="$SCRIPT_DIR/main.py"
-
-# Create logs directory if it doesn't exist
-mkdir -p "$LOG_DIR"
-
-echo "Starting Telegram Bot Manager..."
-echo "Working directory: $SCRIPT_DIR"
-echo "Log file: $LOG_FILE"
-
-# Function to kill the current instance safely
-kill_current_instance() {
- if [ -f "$PID_FILE" ]; then
- OLD_PID=$(cat "$PID_FILE")
-
- # Check if the process exists and is our process
- if ps -p "$OLD_PID" > /dev/null 2>&1; then
- # Verify it's our python process by absolute main.py path
- PROCESS_CMD=$(ps -p "$OLD_PID" -o command= 2>/dev/null || echo "")
- if [[ "$PROCESS_CMD" == *"$MAIN_PATH"* ]]; then
- echo "Found running instance (PID: $OLD_PID), stopping..."
- kill -TERM "$OLD_PID" 2>/dev/null
-
- # Wait for process to terminate gracefully
- for i in {1..10}; do
- if ! ps -p "$OLD_PID" > /dev/null 2>&1; then
- echo "Process stopped successfully"
- break
- fi
- sleep 1
- done
-
- # Force kill if still running
- if ps -p "$OLD_PID" > /dev/null 2>&1; then
- echo "Force killing process..."
- kill -KILL "$OLD_PID" 2>/dev/null
- sleep 1
- fi
- else
- echo "PID file exists but process is not our bot, removing stale PID file"
- fi
- else
- echo "No running instance found (stale PID file)"
- fi
-
- # Remove PID file
- rm -f "$PID_FILE"
- else
- echo "No previous instance found"
- fi
-}
-
-# Kill current instance
-kill_current_instance
-
-# Change to script directory
-cd "$SCRIPT_DIR"
-
-# Load environment variables from .env file if it exists
-if [ -f .env ]; then
- # shellcheck disable=SC2046
- export $(grep -v '^#' .env | xargs)
-else
- echo "ERROR: .env file not found!"
- echo "Please create a .env file with required environment variables."
- echo "You can start from the template:"
- echo " cp .env.example .env && edit .env"
- exit 1
-fi
-
-# Create working directory if it doesn't exist
-mkdir -p ./_tmp
-
-# Check if virtual environment exists
-if [ -d "venv" ]; then
- echo "Activating virtual environment..."
- source venv/bin/activate
-elif [ -d ".venv" ]; then
- echo "Activating virtual environment..."
- source .venv/bin/activate
-else
- echo "No virtual environment found, using system Python"
-fi
-
-# Start the bot with output redirected to log file
-echo "Starting bot..."
-echo "============================================" >> "$LOG_FILE"
-echo "Bot started at: $(date)" >> "$LOG_FILE"
-echo "============================================" >> "$LOG_FILE"
-
-# Run python in unbuffered mode for real-time logging
-nohup python3 -u "$MAIN_PATH" >> "$LOG_FILE" 2>&1 &
-
-# Save new PID
-NEW_PID=$!
-echo "$NEW_PID" > "$PID_FILE"
-
-# Check if process started successfully
-sleep 2
-if ps -p "$NEW_PID" > /dev/null 2>&1; then
- echo "Bot started successfully (PID: $NEW_PID)"
- echo "Logs are being written to: $LOG_FILE"
- echo ""
- echo "To view logs in real-time:"
- echo " tail -f $LOG_FILE"
- echo ""
- echo "To stop the bot:"
- echo " $SCRIPT_DIR/stop.sh"
-else
- echo "ERROR: Failed to start bot!"
- echo "Check the log file for errors: $LOG_FILE"
- tail -n 20 "$LOG_FILE"
- rm -f "$PID_FILE"
- exit 1
-fi
\ No newline at end of file
diff --git a/status.sh b/status.sh
deleted file mode 100755
index 1f9876e51..000000000
--- a/status.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-
-# Get the absolute path of current directory
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-PID_FILE="$SCRIPT_DIR/.bot.pid"
-LOG_DIR="$SCRIPT_DIR/logs"
-MAIN_PATH="$SCRIPT_DIR/main.py"
-
-echo "Claude Proxy Status"
-echo "==================="
-
-if [ -f "$PID_FILE" ]; then
- PID=$(cat "$PID_FILE")
-
- # Check if the process exists
- if ps -p "$PID" > /dev/null 2>&1; then
- # Verify it's our python process by absolute main.py path
- PROCESS_CMD=$(ps -p "$PID" -o command= 2>/dev/null || echo "")
- if [[ "$PROCESS_CMD" == *"$MAIN_PATH"* ]]; then
- echo "Status: RUNNING"
- echo "PID: $PID"
-
- # Show process info
- echo ""
- echo "Process info:"
- ps -p "$PID" -o pid,vsz,rss,pcpu,pmem,etime,command
-
- # Show latest log file
- if [ -d "$LOG_DIR" ]; then
- LATEST_LOG=$(ls -t "$LOG_DIR"/bot_*.log 2>/dev/null | head -1)
- if [ -n "$LATEST_LOG" ]; then
- echo ""
- echo "Latest log file: $LATEST_LOG"
- echo "Last 10 lines:"
- echo "---"
- tail -n 10 "$LATEST_LOG"
- fi
- fi
- else
- echo "Status: STOPPED (stale PID file)"
- echo "PID file exists but process is not our bot"
- fi
- else
- echo "Status: STOPPED (stale PID file)"
- echo "Bot is not running"
- fi
-else
- echo "Status: STOPPED"
- echo "Bot is not running (no PID file)"
-fi
\ No newline at end of file
diff --git a/stop.sh b/stop.sh
deleted file mode 100755
index 282448793..000000000
--- a/stop.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-# Get the absolute path of current directory
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-PID_FILE="$SCRIPT_DIR/.bot.pid"
-MAIN_PATH="$SCRIPT_DIR/main.py"
-
-echo "Stopping Claude Proxy..."
-
-if [ -f "$PID_FILE" ]; then
- PID=$(cat "$PID_FILE")
-
- # Check if the process exists
- if ps -p "$PID" > /dev/null 2>&1; then
- # Verify it's our python process by absolute main.py path
- PROCESS_CMD=$(ps -p "$PID" -o command= 2>/dev/null || echo "")
- if [[ "$PROCESS_CMD" == *"$MAIN_PATH"* ]]; then
- echo "Found bot process (PID: $PID), stopping..."
- kill -TERM "$PID" 2>/dev/null
-
- # Wait for process to terminate gracefully
- for i in {1..10}; do
- if ! ps -p "$PID" > /dev/null 2>&1; then
- echo "Bot stopped successfully"
- rm -f "$PID_FILE"
- exit 0
- fi
- sleep 1
- done
-
- # Force kill if still running
- if ps -p "$PID" > /dev/null 2>&1; then
- echo "Force killing process..."
- kill -KILL "$PID" 2>/dev/null
- sleep 1
- fi
-
- if ! ps -p "$PID" > /dev/null 2>&1; then
- echo "Bot stopped (force killed)"
- rm -f "$PID_FILE"
- else
- echo "ERROR: Failed to stop bot!"
- exit 1
- fi
- else
- echo "PID file exists but process is not our bot"
- echo "Removing stale PID file"
- rm -f "$PID_FILE"
- fi
- else
- echo "Bot is not running (stale PID file)"
- rm -f "$PID_FILE"
- fi
-else
- echo "Bot is not running (no PID file found)"
-fi
\ No newline at end of file
diff --git a/tests/test_vibe_cli.py b/tests/test_vibe_cli.py
new file mode 100644
index 000000000..d44821ceb
--- /dev/null
+++ b/tests/test_vibe_cli.py
@@ -0,0 +1,31 @@
+import json
+import os
+import signal
+import sys
+from pathlib import Path
+
+from config import paths
+from vibe import runtime
+
+
+def test_default_config_written(tmp_path, monkeypatch):
+ monkeypatch.setattr(paths, "get_vibe_remote_dir", lambda: tmp_path / ".vibe_remote")
+ runtime.ensure_dirs()
+ config = runtime.ensure_config()
+ assert config.mode == "self_host"
+ assert (tmp_path / ".vibe_remote" / "config" / "config.json").exists()
+
+
+def test_status_written(tmp_path, monkeypatch):
+ monkeypatch.setattr(paths, "get_vibe_remote_dir", lambda: tmp_path / ".vibe_remote")
+ runtime.ensure_dirs()
+ runtime.write_status("running", detail="pid=123")
+ payload = json.loads(paths.get_runtime_status_path().read_text(encoding="utf-8"))
+ assert payload["state"] == "running"
+ assert payload["detail"] == "pid=123"
+
+
+def test_stop_process_handles_missing_pid(tmp_path, monkeypatch):
+ monkeypatch.setattr(paths, "get_vibe_remote_dir", lambda: tmp_path / ".vibe_remote")
+ runtime.ensure_dirs()
+ assert runtime.stop_process(paths.get_runtime_pid_path()) is False
diff --git a/ui/.gitignore b/ui/.gitignore
new file mode 100644
index 000000000..a547bf36d
--- /dev/null
+++ b/ui/.gitignore
@@ -0,0 +1,24 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+dist
+dist-ssr
+*.local
+
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
diff --git a/ui/README.md b/ui/README.md
new file mode 100644
index 000000000..d2e77611f
--- /dev/null
+++ b/ui/README.md
@@ -0,0 +1,73 @@
+# React + TypeScript + Vite
+
+This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
+
+Currently, two official plugins are available:
+
+- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
+- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
+
+## React Compiler
+
+The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
+
+## Expanding the ESLint configuration
+
+If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
+
+```js
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ // Other configs...
+
+ // Remove tseslint.configs.recommended and replace with this
+ tseslint.configs.recommendedTypeChecked,
+ // Alternatively, use this for stricter rules
+ tseslint.configs.strictTypeChecked,
+ // Optionally, add this for stylistic rules
+ tseslint.configs.stylisticTypeChecked,
+
+ // Other configs...
+ ],
+ languageOptions: {
+ parserOptions: {
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
+ tsconfigRootDir: import.meta.dirname,
+ },
+ // other options...
+ },
+ },
+])
+```
+
+You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
+
+```js
+// eslint.config.js
+import reactX from 'eslint-plugin-react-x'
+import reactDom from 'eslint-plugin-react-dom'
+
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ // Other configs...
+ // Enable lint rules for React
+ reactX.configs['recommended-typescript'],
+ // Enable lint rules for React DOM
+ reactDom.configs.recommended,
+ ],
+ languageOptions: {
+ parserOptions: {
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
+ tsconfigRootDir: import.meta.dirname,
+ },
+ // other options...
+ },
+ },
+])
+```
diff --git a/ui/eslint.config.js b/ui/eslint.config.js
new file mode 100644
index 000000000..5e6b472f5
--- /dev/null
+++ b/ui/eslint.config.js
@@ -0,0 +1,23 @@
+import js from '@eslint/js'
+import globals from 'globals'
+import reactHooks from 'eslint-plugin-react-hooks'
+import reactRefresh from 'eslint-plugin-react-refresh'
+import tseslint from 'typescript-eslint'
+import { defineConfig, globalIgnores } from 'eslint/config'
+
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ js.configs.recommended,
+ tseslint.configs.recommended,
+ reactHooks.configs.flat.recommended,
+ reactRefresh.configs.vite,
+ ],
+ languageOptions: {
+ ecmaVersion: 2020,
+ globals: globals.browser,
+ },
+ },
+])
diff --git a/ui/index.html b/ui/index.html
new file mode 100644
index 000000000..592716ba6
--- /dev/null
+++ b/ui/index.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>ui</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/src/main.tsx"></script>
+ </body>
+</html>
diff --git a/ui/package.json b/ui/package.json
new file mode 100644
index 000000000..4a4f96722
--- /dev/null
+++ b/ui/package.json
@@ -0,0 +1,30 @@
+{
+ "name": "ui",
+ "private": true,
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "tsc -b && vite build",
+ "lint": "eslint .",
+ "preview": "vite preview"
+ },
+ "dependencies": {
+ "react": "^19.2.0",
+ "react-dom": "^19.2.0"
+ },
+ "devDependencies": {
+ "@eslint/js": "^9.39.1",
+ "@types/node": "^24.10.1",
+ "@types/react": "^19.2.5",
+ "@types/react-dom": "^19.2.3",
+ "@vitejs/plugin-react": "^5.1.1",
+ "eslint": "^9.39.1",
+ "eslint-plugin-react-hooks": "^7.0.1",
+ "eslint-plugin-react-refresh": "^0.4.24",
+ "globals": "^16.5.0",
+ "typescript": "~5.9.3",
+ "typescript-eslint": "^8.46.4",
+ "vite": "^7.2.4"
+ }
+}
diff --git a/ui/public/vite.svg b/ui/public/vite.svg
new file mode 100644
index 000000000..e7b8dfb1b
--- /dev/null
+++ b/ui/public/vite.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
\ No newline at end of file
diff --git a/ui/src/App.css b/ui/src/App.css
new file mode 100644
index 000000000..b9d355df2
--- /dev/null
+++ b/ui/src/App.css
@@ -0,0 +1,42 @@
+#root {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 2rem;
+ text-align: center;
+}
+
+.logo {
+ height: 6em;
+ padding: 1.5em;
+ will-change: filter;
+ transition: filter 300ms;
+}
+.logo:hover {
+ filter: drop-shadow(0 0 2em #646cffaa);
+}
+.logo.react:hover {
+ filter: drop-shadow(0 0 2em #61dafbaa);
+}
+
+@keyframes logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ a:nth-of-type(2) .logo {
+ animation: logo-spin infinite 20s linear;
+ }
+}
+
+.card {
+ padding: 2em;
+}
+
+.read-the-docs {
+ color: #888;
+}
diff --git a/ui/src/App.tsx b/ui/src/App.tsx
new file mode 100644
index 000000000..3d7ded3ff
--- /dev/null
+++ b/ui/src/App.tsx
@@ -0,0 +1,35 @@
+import { useState } from 'react'
+import reactLogo from './assets/react.svg'
+import viteLogo from '/vite.svg'
+import './App.css'
+
+function App() {
+ const [count, setCount] = useState(0)
+
+ return (
+ <>
+ <div>
+ <a href="https://vite.dev" target="_blank">
+ <img src={viteLogo} className="logo" alt="Vite logo" />
+ </a>
+ <a href="https://react.dev" target="_blank">
+ <img src={reactLogo} className="logo react" alt="React logo" />
+ </a>
+ </div>
+ <h1>Vite + React</h1>
+ <div className="card">
+ <button onClick={() => setCount((count) => count + 1)}>
+ count is {count}
+ </button>
+ <p>
+ Edit <code>src/App.tsx</code> and save to test HMR
+ </p>
+ </div>
+ <p className="read-the-docs">
+ Click on the Vite and React logos to learn more
+ </p>
+ </>
+ )
+}
+
+export default App
diff --git a/ui/src/assets/react.svg b/ui/src/assets/react.svg
new file mode 100644
index 000000000..6c87de9bb
--- /dev/null
+++ b/ui/src/assets/react.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
\ No newline at end of file
diff --git a/ui/src/index.css b/ui/src/index.css
new file mode 100644
index 000000000..08a3ac9e1
--- /dev/null
+++ b/ui/src/index.css
@@ -0,0 +1,68 @@
+:root {
+ font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
+ line-height: 1.5;
+ font-weight: 400;
+
+ color-scheme: light dark;
+ color: rgba(255, 255, 255, 0.87);
+ background-color: #242424;
+
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+a {
+ font-weight: 500;
+ color: #646cff;
+ text-decoration: inherit;
+}
+a:hover {
+ color: #535bf2;
+}
+
+body {
+ margin: 0;
+ display: flex;
+ place-items: center;
+ min-width: 320px;
+ min-height: 100vh;
+}
+
+h1 {
+ font-size: 3.2em;
+ line-height: 1.1;
+}
+
+button {
+ border-radius: 8px;
+ border: 1px solid transparent;
+ padding: 0.6em 1.2em;
+ font-size: 1em;
+ font-weight: 500;
+ font-family: inherit;
+ background-color: #1a1a1a;
+ cursor: pointer;
+ transition: border-color 0.25s;
+}
+button:hover {
+ border-color: #646cff;
+}
+button:focus,
+button:focus-visible {
+ outline: 4px auto -webkit-focus-ring-color;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ color: #213547;
+ background-color: #ffffff;
+ }
+ a:hover {
+ color: #747bff;
+ }
+ button {
+ background-color: #f9f9f9;
+ }
+}
diff --git a/ui/src/main.tsx b/ui/src/main.tsx
new file mode 100644
index 000000000..bef5202a3
--- /dev/null
+++ b/ui/src/main.tsx
@@ -0,0 +1,10 @@
+import { StrictMode } from 'react'
+import { createRoot } from 'react-dom/client'
+import './index.css'
+import App from './App.tsx'
+
+createRoot(document.getElementById('root')!).render(
+ <StrictMode>
+ <App />
+ </StrictMode>,
+)
diff --git a/ui/tsconfig.app.json b/ui/tsconfig.app.json
new file mode 100644
index 000000000..a9b5a59ca
--- /dev/null
+++ b/ui/tsconfig.app.json
@@ -0,0 +1,28 @@
+{
+ "compilerOptions": {
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
+ "target": "ES2022",
+ "useDefineForClassFields": true,
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "types": ["vite/client"],
+ "skipLibCheck": true,
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "verbatimModuleSyntax": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+ "jsx": "react-jsx",
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "erasableSyntaxOnly": true,
+ "noFallthroughCasesInSwitch": true,
+ "noUncheckedSideEffectImports": true
+ },
+ "include": ["src"]
+}
diff --git a/ui/tsconfig.json b/ui/tsconfig.json
new file mode 100644
index 000000000..1ffef600d
--- /dev/null
+++ b/ui/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "files": [],
+ "references": [
+ { "path": "./tsconfig.app.json" },
+ { "path": "./tsconfig.node.json" }
+ ]
+}
diff --git a/ui/tsconfig.node.json b/ui/tsconfig.node.json
new file mode 100644
index 000000000..8a67f62f4
--- /dev/null
+++ b/ui/tsconfig.node.json
@@ -0,0 +1,26 @@
+{
+ "compilerOptions": {
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
+ "target": "ES2023",
+ "lib": ["ES2023"],
+ "module": "ESNext",
+ "types": ["node"],
+ "skipLibCheck": true,
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "verbatimModuleSyntax": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "erasableSyntaxOnly": true,
+ "noFallthroughCasesInSwitch": true,
+ "noUncheckedSideEffectImports": true
+ },
+ "include": ["vite.config.ts"]
+}
diff --git a/ui/vite.config.ts b/ui/vite.config.ts
new file mode 100644
index 000000000..8b0f57b91
--- /dev/null
+++ b/ui/vite.config.ts
@@ -0,0 +1,7 @@
+import { defineConfig } from 'vite'
+import react from '@vitejs/plugin-react'
+
+// https://vite.dev/config/
+export default defineConfig({
+ plugins: [react()],
+})
diff --git a/vibe/__init__.py b/vibe/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/vibe/__main__.py b/vibe/__main__.py
new file mode 100644
index 000000000..f72b8a783
--- /dev/null
+++ b/vibe/__main__.py
@@ -0,0 +1,5 @@
+from vibe.cli import main
+
+
+if __name__ == "__main__":
+ main()
diff --git a/vibe/cli.py b/vibe/cli.py
new file mode 100644
index 000000000..7f772fca9
--- /dev/null
+++ b/vibe/cli.py
@@ -0,0 +1,248 @@
+import argparse
+import json
+import os
+import signal
+import subprocess
+import sys
+import time
+from pathlib import Path
+
+from config import paths
+from config.v2_config import (
+ AgentsConfig,
+ ClaudeConfig,
+ CodexConfig,
+ OpenCodeConfig,
+ RuntimeConfig,
+ SlackConfig,
+ V2Config,
+)
+from vibe.ui_server import run_ui_server
+
+
+def _write_json(path, payload):
+ path.write_text(json.dumps(payload, indent=2), encoding="utf-8")
+
+
+def _read_json(path):
+ if not path.exists():
+ return None
+ return json.loads(path.read_text(encoding="utf-8"))
+
+
+def _pid_alive(pid):
+ try:
+ os.kill(pid, 0)
+ return True
+ except OSError:
+ return False
+
+
+def _open_browser(url):
+ try:
+ subprocess.Popen(["open", url])
+ except Exception:
+ pass
+
+
+def _default_config():
+ return V2Config(
+ mode="self_host",
+ version="v2",
+ slack=SlackConfig(bot_token="", app_token=""),
+ runtime=RuntimeConfig(default_cwd=str(Path.cwd())),
+ agents=AgentsConfig(
+ default_backend="opencode",
+ opencode=OpenCodeConfig(enabled=True, cli_path="opencode"),
+ claude=ClaudeConfig(enabled=True, cli_path="claude"),
+ codex=CodexConfig(enabled=False, cli_path="codex"),
+ ),
+ )
+
+
+def _ensure_config():
+ config_path = paths.get_config_path()
+ if not config_path.exists():
+ default = _default_config()
+ default.save(config_path)
+ return V2Config.load(config_path)
+
+
+def _write_status(state, detail=None):
+ payload = {
+ "state": state,
+ "detail": detail,
+ "updated_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
+ }
+ _write_json(paths.get_runtime_status_path(), payload)
+
+
+def _spawn_background(args, pid_path):
+ process = subprocess.Popen(
+ args,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ start_new_session=True,
+ )
+ pid_path.write_text(str(process.pid), encoding="utf-8")
+ return process.pid
+
+
+def _stop_process(pid_path):
+ if not pid_path.exists():
+ return False
+ pid = int(pid_path.read_text(encoding="utf-8").strip())
+ if not _pid_alive(pid):
+ pid_path.unlink(missing_ok=True)
+ return False
+ os.kill(pid, signal.SIGTERM)
+ pid_path.unlink(missing_ok=True)
+ return True
+
+
+def _render_status():
+ status = _read_json(paths.get_runtime_status_path()) or {}
+ pid_path = paths.get_runtime_pid_path()
+ pid = pid_path.read_text(encoding="utf-8").strip() if pid_path.exists() else None
+ running = bool(pid and pid.isdigit() and _pid_alive(int(pid)))
+ status["running"] = running
+ status["pid"] = int(pid) if pid and pid.isdigit() else None
+ return json.dumps(status, indent=2)
+
+
+def _doctor():
+ checks = {}
+ config_path = paths.get_config_path()
+ if config_path.exists():
+ checks["config"] = {
+ "status": "ok",
+ "detail": str(config_path),
+ }
+ else:
+ checks["config"] = {"status": "error", "detail": "config.json not found"}
+
+ config = None
+ try:
+ config = V2Config.load(config_path)
+ checks["config_load"] = {"status": "ok", "detail": "loaded"}
+ except Exception as exc:
+ checks["config_load"] = {"status": "error", "detail": str(exc)}
+
+ if config:
+ try:
+ config.slack.validate()
+ checks["slack"] = {"status": "ok", "detail": "token format ok"}
+ except Exception as exc:
+ checks["slack"] = {"status": "error", "detail": str(exc)}
+
+ checks["opencode"] = {
+ "status": "ok" if config.agents.opencode.enabled else "skip",
+ "detail": config.agents.opencode.cli_path,
+ }
+ checks["claude"] = {
+ "status": "ok" if config.agents.claude.enabled else "skip",
+ "detail": config.agents.claude.cli_path,
+ }
+ checks["codex"] = {
+ "status": "ok" if config.agents.codex.enabled else "skip",
+ "detail": config.agents.codex.cli_path,
+ }
+
+ ok = all(check["status"] in ("ok", "skip") for check in checks.values())
+ result = {"ok": ok, "checks": checks}
+ _write_json(paths.get_runtime_doctor_path(), result)
+ return result
+
+
+def _run_background_service():
+ python = sys.executable
+ return _spawn_background([python, "-m", "vibe", "run"], paths.get_runtime_pid_path())
+
+
+def _run_background_ui(port):
+ python = sys.executable
+ return _spawn_background(
+ [python, "-m", "vibe", "ui", "--port", str(port)],
+ paths.get_runtime_ui_pid_path(),
+ )
+
+
+def cmd_run():
+ os.execv(sys.executable, [sys.executable, "main.py"])
+ return 0
+
+
+def cmd_ui(port):
+ run_ui_server(port)
+ return 0
+
+
+def cmd_vibe():
+ paths.ensure_data_dirs()
+ config = _ensure_config()
+ if not config.slack.bot_token:
+ _write_status("setup", "missing Slack bot token")
+ else:
+ _write_status("starting")
+
+ service_pid = _run_background_service()
+ _run_background_ui(config.ui.setup_port)
+ _write_status("running", "pid={}".format(service_pid))
+
+ ui_url = "http://127.0.0.1:{}".format(config.ui.setup_port)
+ if config.ui.open_browser:
+ _open_browser(ui_url)
+
+ return 0
+
+
+def cmd_stop():
+ stopped = _stop_process(paths.get_runtime_pid_path())
+ _stop_process(paths.get_runtime_ui_pid_path())
+ if stopped:
+ _write_status("stopped")
+ return 0
+ return 1
+
+
+def cmd_status():
+ print(_render_status())
+ return 0
+
+
+def cmd_doctor():
+ result = _doctor()
+ print(json.dumps(result, indent=2))
+ return 0 if result["ok"] else 1
+
+
+def build_parser():
+ parser = argparse.ArgumentParser(prog="vibe")
+ subparsers = parser.add_subparsers(dest="command")
+
+ subparsers.add_parser("stop")
+ subparsers.add_parser("status")
+ subparsers.add_parser("doctor")
+ subparsers.add_parser("run")
+
+ ui_parser = subparsers.add_parser("ui")
+ ui_parser.add_argument("--port", type=int, default=5123)
+ return parser
+
+
+def main():
+ parser = build_parser()
+ args = parser.parse_args()
+
+ if args.command == "stop":
+ sys.exit(cmd_stop())
+ if args.command == "status":
+ sys.exit(cmd_status())
+ if args.command == "doctor":
+ sys.exit(cmd_doctor())
+ if args.command == "run":
+ sys.exit(cmd_run())
+ if args.command == "ui":
+ sys.exit(cmd_ui(args.port))
+
+ sys.exit(cmd_vibe())
diff --git a/vibe/runtime.py b/vibe/runtime.py
new file mode 100644
index 000000000..e0c89c021
--- /dev/null
+++ b/vibe/runtime.py
@@ -0,0 +1,137 @@
+import json
+import os
+import signal
+import subprocess
+import sys
+import time
+from pathlib import Path
+
+from config import paths
+from config.v2_config import (
+ AgentsConfig,
+ ClaudeConfig,
+ CodexConfig,
+ OpenCodeConfig,
+ RuntimeConfig,
+ SlackConfig,
+ V2Config,
+)
+
+
+ROOT_DIR = Path(__file__).resolve().parents[1]
+MAIN_PATH = ROOT_DIR / "main.py"
+
+
+def ensure_dirs():
+ paths.ensure_data_dirs()
+
+
+def default_config():
+ return V2Config(
+ mode="self_host",
+ version="v2",
+ slack=SlackConfig(bot_token="", app_token=""),
+ runtime=RuntimeConfig(default_cwd=str(ROOT_DIR / "_tmp")),
+ agents=AgentsConfig(
+ default_backend="opencode",
+ opencode=OpenCodeConfig(enabled=True, cli_path="opencode"),
+ claude=ClaudeConfig(enabled=True, cli_path="claude"),
+ codex=CodexConfig(enabled=False, cli_path="codex"),
+ ),
+ )
+
+
+def ensure_config():
+ config_path = paths.get_config_path()
+ if not config_path.exists():
+ default = default_config()
+ default.save(config_path)
+ return V2Config.load(config_path)
+
+
+def write_json(path, payload):
+ path.write_text(json.dumps(payload, indent=2), encoding="utf-8")
+
+
+def read_json(path):
+ if not path.exists():
+ return None
+ return json.loads(path.read_text(encoding="utf-8"))
+
+
+def pid_alive(pid):
+ try:
+ os.kill(pid, 0)
+ return True
+ except OSError:
+ return False
+
+
+def spawn_background(args, pid_path):
+ process = subprocess.Popen(
+ args,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ start_new_session=True,
+ cwd=str(ROOT_DIR),
+ )
+ pid_path.write_text(str(process.pid), encoding="utf-8")
+ return process.pid
+
+
+def stop_process(pid_path):
+ if not pid_path.exists():
+ return False
+ pid = int(pid_path.read_text(encoding="utf-8").strip())
+ if not pid_alive(pid):
+ pid_path.unlink(missing_ok=True)
+ return False
+ os.kill(pid, signal.SIGTERM)
+ pid_path.unlink(missing_ok=True)
+ return True
+
+
+def write_status(state, detail=None, service_pid=None, ui_pid=None):
+ payload = {
+ "state": state,
+ "detail": detail,
+ "service_pid": service_pid,
+ "ui_pid": ui_pid,
+ "updated_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
+ }
+ write_json(paths.get_runtime_status_path(), payload)
+
+
+def read_status():
+ return read_json(paths.get_runtime_status_path()) or {}
+
+
+def render_status():
+ status = read_status()
+ pid_path = paths.get_runtime_pid_path()
+ pid = pid_path.read_text(encoding="utf-8").strip() if pid_path.exists() else None
+ running = bool(pid and pid.isdigit() and pid_alive(int(pid)))
+ status["running"] = running
+ status["pid"] = int(pid) if pid and pid.isdigit() else None
+ return json.dumps(status, indent=2)
+
+
+def start_service():
+ return spawn_background(
+ [sys.executable, str(MAIN_PATH)], paths.get_runtime_pid_path()
+ )
+
+
+def start_ui(port):
+ return spawn_background(
+ [sys.executable, "-m", "vibe", "ui", "--port", str(port)],
+ paths.get_runtime_ui_pid_path(),
+ )
+
+
+def stop_service():
+ return stop_process(paths.get_runtime_pid_path())
+
+
+def stop_ui():
+ return stop_process(paths.get_runtime_ui_pid_path())
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
new file mode 100644
index 000000000..5b073aa70
--- /dev/null
+++ b/vibe/ui_server.py
@@ -0,0 +1,68 @@
+import http.server
+import json
+import socketserver
+from typing import Optional
+
+from config import paths
+
+
+class UiHandler(http.server.BaseHTTPRequestHandler):
+ def _send_json(self, payload: dict, status: int = 200) -> None:
+ body = json.dumps(payload).encode("utf-8")
+ self.send_response(status)
+ self.send_header("Content-Type", "application/json")
+ self.send_header("Content-Length", str(len(body)))
+ self.end_headers()
+ self.wfile.write(body)
+
+ def _read_json(self) -> dict:
+ length = int(self.headers.get("Content-Length", "0"))
+ data = self.rfile.read(length) if length else b"{}"
+ return json.loads(data.decode("utf-8"))
+
+ def do_GET(self) -> None:
+ if self.path == "/" or self.path.startswith("/index"):
+ html = (
+ "<html><head><title>Vibe Setup</title></head>"
+ "<body><h1>Vibe Setup</h1>"
+ "<p>Setup UI is starting. Use /status for runtime status.</p>"
+ "</body></html>"
+ )
+ body = html.encode("utf-8")
+ self.send_response(200)
+ self.send_header("Content-Type", "text/html")
+ self.send_header("Content-Length", str(len(body)))
+ self.end_headers()
+ self.wfile.write(body)
+ return
+ if self.path == "/health":
+ self._send_json({"status": "ok"})
+ return
+ if self.path == "/status":
+ payload = {}
+ status_path = paths.get_runtime_status_path()
+ if status_path.exists():
+ payload = json.loads(status_path.read_text(encoding="utf-8"))
+ self._send_json(payload)
+ return
+ self._send_json({"error": "not_found"}, status=404)
+
+ def do_POST(self) -> None:
+ if self.path == "/control":
+ payload = self._read_json()
+ action = payload.get("action")
+ status_path = paths.get_runtime_status_path()
+ status = {}
+ if status_path.exists():
+ status = json.loads(status_path.read_text(encoding="utf-8"))
+ status["last_action"] = action
+ status_path.write_text(json.dumps(status, indent=2), encoding="utf-8")
+ self._send_json({"ok": True, "action": action})
+ return
+ self._send_json({"error": "not_found"}, status=404)
+
+
+def run_ui_server(port: int) -> None:
+ paths.ensure_data_dirs()
+ with socketserver.TCPServer(("127.0.0.1", port), UiHandler) as httpd:
+ httpd.serve_forever()