diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c64b78e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +{ + "name": "thv + Claude Code", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + }, + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} + }, + "postCreateCommand": "bash .devcontainer/setup.sh", + "postStartCommand": "bash .devcontainer/start-servers.sh", + "customizations": { + "vscode": { + "extensions": [ + "GitHub.copilot", + "GitHub.copilot-chat" + ] + } + } +} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100755 index 0000000..392d9c1 --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Install Claude Code (Node.js provided via devcontainer feature) +npm install -g @anthropic-ai/claude-code + +# Install thv (ToolHive) to ~/.local/bin +mkdir -p "$HOME/.local/bin" +curl -fsSL "https://github.com/stacklok/toolhive/releases/download/v0.11.0/toolhive_0.11.0_linux_amd64.tar.gz" \ + | tar -xz -C "$HOME/.local/bin" thv + +export PATH="$HOME/.local/bin:$PATH" + +# Ensure Claude Code config exists and onboarding is marked complete +if [ ! -f "$HOME/.claude.json" ]; then + echo '{}' > "$HOME/.claude.json" +fi +node -e " +const fs = require('fs'); +const path = '$HOME/.claude.json'; +const config = JSON.parse(fs.readFileSync(path, 'utf8')); +config.hasCompletedOnboarding = true; +config.lastOnboardingVersion = '99.99.99'; +fs.writeFileSync(path, JSON.stringify(config)); +" + +# Ensure VS Code Server MCP config exists so thv can register itself +mkdir -p "$HOME/.vscode-server/data/User" +if [ ! -f "$HOME/.vscode-server/data/User/mcp.json" ]; then + echo '{}' > "$HOME/.vscode-server/data/User/mcp.json" +fi + +# Register clients (Docker not needed for registration) +thv client register claude-code +thv client register vscode-server diff --git a/.devcontainer/start-servers.sh b/.devcontainer/start-servers.sh new file mode 100755 index 0000000..3bd9c94 --- /dev/null +++ b/.devcontainer/start-servers.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -euo pipefail + +export PATH="$HOME/.local/bin:$PATH" + +# Start MCP servers (requires Docker, runs on every Codespace start) +thv run mermaid 2>/dev/null || true +thv run fetch 2>/dev/null || true +thv run osv 2>/dev/null || true +thv run semgrep 2>/dev/null || true