{"id":47793859,"url":"https://github.com/anditurdiu/pai-opencode-adapter","last_synced_at":"2026-04-03T16:01:36.833Z","repository":{"id":347755111,"uuid":"1195171573","full_name":"anditurdiu/pai-opencode-adapter","owner":"anditurdiu","description":"Run PAI (Personal AI Infrastructure) without an Anthropic subscription. Adapter layer for OpenCode — use any LLM provider.","archived":false,"fork":false,"pushed_at":"2026-03-29T11:35:40.000Z","size":234,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-29T13:48:17.586Z","etag":null,"topics":["adapter","ai","claude","gemini","llm","ollama","openai","opencode","pai","personal-ai"],"latest_commit_sha":null,"homepage":"https://github.com/danielmiessler/Personal_AI_Infrastructure","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anditurdiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-29T10:23:11.000Z","updated_at":"2026-03-29T13:25:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/anditurdiu/pai-opencode-adapter","commit_stats":null,"previous_names":["anditurdiu/pai-opencode-adapter"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/anditurdiu/pai-opencode-adapter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anditurdiu%2Fpai-opencode-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anditurdiu%2Fpai-opencode-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anditurdiu%2Fpai-opencode-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anditurdiu%2Fpai-opencode-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anditurdiu","download_url":"https://codeload.github.com/anditurdiu/pai-opencode-adapter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anditurdiu%2Fpai-opencode-adapter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31362680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T15:19:21.178Z","status":"ssl_error","status_checked_at":"2026-04-03T15:19:20.670Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adapter","ai","claude","gemini","llm","ollama","openai","opencode","pai","personal-ai"],"created_at":"2026-04-03T16:01:25.350Z","updated_at":"2026-04-03T16:01:36.768Z","avatar_url":"https://github.com/anditurdiu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PAI-OpenCode Adapter\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Version](https://img.shields.io/badge/version-0.9.1-blue.svg)](https://github.com/anditurdiu/pai-opencode-adapter)\n[![Test Status](https://img.shields.io/badge/tests-765%20pass-green.svg)](https://github.com/anditurdiu/pai-opencode-adapter)\n\n**Run [PAI](https://github.com/danielmiessler/Personal_AI_Infrastructure) without an Anthropic subscription.** Use any LLM provider — OpenAI, Google, Ollama, or Anthropic — through [OpenCode](https://opencode.ai), the open-source AI coding assistant.\n\n\u003e **Background:** PAI (Personal AI Infrastructure) is a powerful personal AI system by Daniel Miessler, but it currently requires Claude Code and an Anthropic Max subscription. This adapter removes that lock-in by translating PAI's hook system into OpenCode's plugin API. Born from [community request (issue #98)](https://github.com/danielmiessler/Personal_AI_Infrastructure/issues/98).\n\n## Why This Adapter?\n\nPAI gives you structured AI workflows (the Algorithm), 63+ skills, 14 agents, memory systems, and a life OS (TELOS). But today it only runs on Claude Code, which requires an Anthropic Max subscription ($100-200/mo).\n\nThis adapter lets you run the **full PAI experience** on OpenCode with **any LLM provider**:\n\n| Provider | Models | Cost |\n|----------|--------|------|\n| **Anthropic** | Claude Sonnet/Opus | API pay-as-you-go (no Max sub needed) |\n| **OpenAI** | GPT-4o, o1 | API pay-as-you-go |\n| **Google** | Gemini Pro/Flash | Free tier available |\n| **Ollama** | Llama 3, Mistral | Free (runs locally) |\n| **Any OpenCode-supported provider** | Various | Varies |\n\n## Overview\n\nThe PAI-OpenCode Adapter is a **plugin adapter layer**, not a fork. It sits between PAI content (hooks, settings, agents) and the OpenCode plugin API, translating events and configurations so your PAI workflows run unchanged on OpenCode.\n\n**What it does:** Event translation (20 PAI hooks → 7 OpenCode hooks), config translation, session state management, security validation, compaction handling, voice notifications, and subagent reliability (error detection, model fallback, stall detection, reasoning loop detection).\n\n**What it doesn't do:** Modify PAI source files, add npm dependencies beyond TypeScript, or auto-merge updates.\n\n\u003e 📖 **Detailed docs:** [Architecture](docs/architecture.md) · [Agents](docs/agents.md) · [Features](docs/features.md) · [Configuration](docs/configuration.md) · [Self-Updater](docs/self-updater.md) · [Troubleshooting](docs/troubleshooting.md)\n\n---\n\n## Quick Start\n\n### Step 1: Clone the repository\n\n```bash\ncd ~/projects\ngit clone https://github.com/anditurdiu/pai-opencode-adapter.git\ncd pai-opencode-adapter\n```\n\n### Step 2: Install dependencies\n\n```bash\nbun install\n```\n\n### Step 3: Build the plugin\n\n```bash\nbun build src/plugin/pai-unified.ts --target=bun --outdir=dist --external opencode\n```\n\n### Step 4: Configure OpenCode\n\nAdd the plugin to your `~/.config/opencode/opencode.json`:\n\n```json\n{\n  \"provider\": \"anthropic\",\n  \"model\": \"claude-sonnet-4-5\",\n  \"plugin\": [\n    \"file:///absolute/path/to/pai-opencode-adapter/src/plugin/pai-unified.ts\"\n  ]\n}\n```\n\n**Important:** The `plugin` path **must** use a `file://` prefix for local plugins. PAI adapter-specific settings (identity, voice, notifications) go in a separate `~/.config/opencode/pai-adapter.json` file — see [Configuration](docs/configuration.md).\n\n### Step 5: Run OpenCode\n\n```bash\nopencode\n# Or with tmux for StatusLine support:\ntmux new-session -s pai opencode\n```\n\n**Verify** the plugin loaded:\n\n```bash\ntail -f /tmp/pai-opencode-debug.log\n# Should show: [pai-unified] plugin initialized\n```\n\n\u003e 📖 **Full setup guide:** [Getting Started](GETTING_STARTED.md)\n\n---\n\n## PAI-Native Experience\n\nThe adapter deploys PAI-native agents, themes, and commands into OpenCode.\n\n### Agents\n\n| Agent | Type | Model | Purpose |\n|-------|------|-------|---------|\n| **Algorithm** | Primary (Tab) | Claude Sonnet 4.6 | Full PAI Algorithm v3.5.0 — structured 7-phase workflow |\n| **Native** | Primary (Tab) | Claude Sonnet 4.6 | Fast, direct task execution without Algorithm overhead |\n| **Architect** | Subagent (@) | Claude Opus 4.6 | System design, architecture review, implementation specs |\n| **Engineer** | Subagent (@) | Claude Sonnet 4.6 | Implementation, bug fixes, refactoring — full file access |\n| **Thinker** | Subagent (@) | Claude Sonnet 4.6 | Deep reasoning, first principles analysis, tradeoff evaluation |\n| **Research** | Subagent (@) | GLM-4.7 | Web research, documentation retrieval, content extraction |\n| **Explorer** | Subagent (@) | GLM-4.7 | Fast read-only codebase exploration, pattern searching |\n| **Intern** | Subagent (@) | GLM-4.7 | Lightweight tasks — data transformation, templating, boilerplate |\n\nSwitch between Algorithm and Native with **Tab**. Invoke subagents with **@architect**, **@engineer**, **@thinker**, **@research**, **@explorer**, or **@intern**.\n\n\u003e 📖 **Full agent reference:** [docs/agents.md](docs/agents.md)\n\n### Commands\n\n| Command | Description |\n|---------|-------------|\n| `/pai-setup` | Interactive onboarding wizard — configure identity, voice, preferences |\n| `/algorithm [task]` | Start a task using the full PAI Algorithm workflow |\n| `/native [task]` | Quick task execution in Native mode |\n| `/telos [action]` | Review and update your TELOS life goals |\n\n### Theme\n\nThe PAI theme (`pai.json`) provides a dark blue/slate color scheme. Auto-applied during installation; change with `/theme` in the TUI.\n\n---\n\n## Prerequisites\n\n| Tool | Version | Purpose | Install |\n|------|---------|---------|---------|\n| [OpenCode](https://opencode.ai) | ≥1.0 | Host CLI for plugin | `curl -fsSL https://opencode.ai/install \\| bash` |\n| [PAI v4.0.3](https://github.com/danielmiessler/Personal_AI_Infrastructure) | 4.0.3 | Source of hooks, agents, skills | `git clone` (see [Getting Started](GETTING_STARTED.md)) |\n| [Bun](https://bun.sh) | ≥1.0 | Runtime and build tool | `curl -fsSL https://bun.sh/install \\| bash` |\n\n**Optional:** tmux (StatusLine), jq (StatusLine JSON), gh CLI (self-updater PRs), ElevenLabs API key (voice TTS).\n\n---\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for setup, testing, and PR guidelines.\n\n**Adding a new handler?** Create a handler in `src/handlers/`, register it in `src/plugin/pai-unified.ts`, write tests in `src/__tests__/`, then run `bun test` to verify all 765 tests pass.\n\n**Code style:** TypeScript strict, `fileLog()` only (never `console.log`), session-scoped state, adapter pattern (never modify `~/.claude/`).\n\n---\n\n## License\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**MIT License** — See [LICENSE](LICENSE) for full text.\n\nBoth [PAI](https://github.com/danielmiessler/Personal_AI_Infrastructure) and [OpenCode](https://opencode.ai) are also MIT licensed.\n\n---\n\n## Related Projects\n\n- **[Personal AI Infrastructure (PAI)](https://github.com/danielmiessler/Personal_AI_Infrastructure)** — Original PAI v4.0.3 for Claude Code (MIT licensed)\n- **[OpenCode](https://opencode.ai)** — Open-source AI coding assistant (MIT licensed)\n- **[PAI Issue #98](https://github.com/danielmiessler/Personal_AI_Infrastructure/issues/98)** — The community request that motivated this adapter\n\n---\n\n## Changelog\n\n### v0.9.1 (2026-03-31)\n\n**Subagent reliability suite:**\n\n- Enhanced error detection — checks top-level error fields AND full Task output body for provider errors\n- Actionable model fallback guidance — injects alternative `subagent_type` suggestions on provider failures\n- Stall detection — 3-minute inactivity heartbeat monitor per subagent, warns primary agent\n- Reasoning loop detection — hashes reasoning text in rolling window, detects repetitive thinking patterns\n- Env-loader — auto-loads API keys from `~/.config/PAI/.env`\n- Skill-loader — native OpenCode skill tool support\n- Agent model sync — `model:` field in agent `.md` files, synced from `pai-adapter.json` on startup\n- PAI protection rule — prevents accidental modification of upstream PAI files\n- 8 agents (added Architect, Engineer, Intern)\n- 765 tests, 0 failures\n\n### v0.7.0 (2026-03-31)\n\n**Subagent context isolation:**\n\n- Subagent preamble injection prevents recursive agent spawning\n- Task tool blocking for subagent sessions (defense-in-depth)\n- Skill tool remains available to subagents for loading workflows\n\n### v0.1.0 (2026-03-21)\n\n**Initial release:**\n\n- Event translation for 20 PAI hooks across 7 OpenCode plugin hooks\n- Config translation with merge semantics\n- Session-scoped state management\n- Security validator with tool gating\n- Dual compaction strategy (proactive + reactive)\n- Voice notifications (ElevenLabs, ntfy, Discord)\n- StatusLine tmux integration\n- Self-updater with draft PR creation\n- File-based logging (never console.log)\n- 546 tests, 0 failures\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**PAI-OpenCode Adapter** — Run PAI on OpenCode, not Claude Code.\n\n[Report Issue](https://github.com/anditurdiu/pai-opencode-adapter/issues) · [Request Feature](https://github.com/anditurdiu/pai-opencode-adapter/discussions)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanditurdiu%2Fpai-opencode-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanditurdiu%2Fpai-opencode-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanditurdiu%2Fpai-opencode-adapter/lists"}