{"id":34979169,"url":"https://github.com/fpr1m3/opencode-pai-plugin","last_synced_at":"2026-04-26T17:31:18.274Z","repository":{"id":329635827,"uuid":"1109763682","full_name":"fpr1m3/opencode-pai-plugin","owner":"fpr1m3","description":"A native OpenCode plugin that implements the Personal AI Infrastructure (PAI) history / logging logic","archived":false,"fork":false,"pushed_at":"2026-01-15T03:54:59.000Z","size":182,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-27T21:43:04.145Z","etag":null,"topics":["opencode","opencode-plugin","opencode-plugins"],"latest_commit_sha":null,"homepage":"","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/fpr1m3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-04T08:51:34.000Z","updated_at":"2026-01-15T03:55:04.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fpr1m3/opencode-pai-plugin","commit_stats":null,"previous_names":["fpr1m3/opencode-pai-plugin"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fpr1m3/opencode-pai-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpr1m3%2Fopencode-pai-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpr1m3%2Fopencode-pai-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpr1m3%2Fopencode-pai-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpr1m3%2Fopencode-pai-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fpr1m3","download_url":"https://codeload.github.com/fpr1m3/opencode-pai-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpr1m3%2Fopencode-pai-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32307010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T17:23:19.671Z","status":"ssl_error","status_checked_at":"2026-04-26T17:23:19.195Z","response_time":129,"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":["opencode","opencode-plugin","opencode-plugins"],"created_at":"2025-12-27T00:51:38.183Z","updated_at":"2026-04-26T17:31:18.230Z","avatar_url":"https://github.com/fpr1m3.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCode PAI Plugin\n\nA native OpenCode plugin that implements the **Personal AI Infrastructure (PAI)** logic, replacing legacy hook scripts with a cohesive, lifecycle-aware system.\n\n## Credits \u0026 Inspiration\n\nThis project is an OpenCode-compatible clone of the hook system from **Dan Miessler's** [Personal AI Infrastructure (PAI)](https://github.com/danielmiessler/Personal_AI_Infrastructure) project. A massive shout out to Dan for the architectural vision and the original PAI patterns that this plugin brings to the OpenCode ecosystem.\n\nThe **10-Tier Security Firewall** was inspired by the cutting-edge research of **Johann Rehberger (Trust No AI)**. Special thanks to Johann for the deep-dive research into AI agent exploits (Unicode tags, DNS exfiltration, etc.) featured in his video: [I hacked the new AI Computer-Use agents](https://www.youtube.com/watch?v=TWhKGqYQT9g).\n\n---\n\n**Disclaimer**: This project is independent and is **not** supported by, affiliated with, or endorsed by Dan Miessler or the OpenCode team.\n\n## Features\n\n### 1. Identity \u0026 Context Injection\n*   **Core Skill Loading**: Automatically injects your `skill/core/SKILL.md` (from `PAI_DIR`) into the system prompt.\n*   **Dynamic Substitution**: Supports placeholders like `{{DA}}`, `{{DA_COLOR}}`, and `{{ENGINEER_NAME}}` for personalized interactions.\n*   **Project Requirements**: Automatically detects and loads `.opencode/dynamic-requirements.md` from your current project, allowing for task-specific instructions.\n\n### 2. Intelligent History \u0026 Logging (UOCS)\n*   **Real-time Event Capture**: Logs all tool calls and SDK events to `PAI_DIR/history/raw-outputs` in an analytics-ready JSONL format.\n*   **Universal Output Capture System (UOCS)**: Automatically parses assistant responses for structured sections (SUMMARY, ANALYSIS, etc.) and generates artifacts in `decisions/`, `learnings/`, `research/`, or `execution/` based on context.\n*   **Session Summaries**: Generates human-readable Markdown summaries in `PAI_DIR/history/sessions` at the end of every session, tracking files modified, tools used, and commands executed.\n*   **Agent Mapping**: Tracks session-to-agent relationships (e.g., mapping a subagent session to its specialized type).\n\n### 3. Security \u0026 Safety (10-Tier Firewall)\n*   **Security Validator**: A built-in firewall (`src/lib/security.ts`) that scans Bash commands for dangerous patterns including reverse shells, recursive deletions, and prompt injections.\n*   **Advanced Protection**:\n    *   **Unicode Sanitization**: Automatically strips invisible Unicode \"Tag\" characters (U+E0000-U+E007F) from all inputs and outputs to prevent hidden prompt injections.\n    *   **Network Exfiltration Block**: Prevents unauthorized data egress by blocking DNS-probing tools like `ping`, `dig`, `nslookup`, `nc`, and `wget`.\n    *   **Shell Escape Defense**: Detects and blocks common shell escape bypasses like `find -exec` and `strings`.\n    *   **Self-Modification Protection**: Locks core configuration files and the plugin's own source code from being modified by the agent.\n*   **Safe-by-Default (HITL)**: All potentially dangerous tool executions—including those matching the security firewall—require explicit human confirmation. The firewall has been tuned in v2.1.0 to prioritize human-in-the-loop (HITL) 'Ask' prompts over hard 'Deny' blocks to maintain agent flow. Auto-approval (\"YOLO mode\") is disabled unless the `PAI_I_AM_DANGEROUS=true` environment variable is set.\n*   **Terminal Sanitization**: Automatically strips ANSI escape codes from all logged output to prevent terminal-based attacks and ensure clean history.\n*   **Data Redaction**: Robustly masks secrets (AWS keys, GitHub tokens, Slack/Stripe/Google keys) in both logs and tool outputs.\n\n### 4. Interactive Feedback\n*   **Real-time Tab Titles**: Updates your terminal tab title *instantly* when a tool starts (e.g., `Running bash...`, `Editing index.ts...`).\n*   **Post-Task Summaries**: Updates the tab title with a concise summary of what was accomplished when a task is completed.\n\n## Configuration\n\nThe plugin centers around the `PAI_DIR` environment variable.\n\n| Variable | Description | Default |\n| :--- | :--- | :--- |\n| `PAI_DIR` | Root directory for PAI skill and history | `$XDG_CONFIG_HOME/opencode` |\n| `HISTORY_DIR` | Override directory for session logs | `$PAI_DIR/history` |\n| `DA` | Name of your Digital Assistant | `PAI` |\n| `ENGINEER_NAME` | Your name/identity | `Operator` |\n| `DA_COLOR` | UI color theme for your DA | `blue` |\n| `TIME_ZONE` | Timezone for log timestamps | `system` |\n| `PAI_I_AM_DANGEROUS` | Enable YOLO mode (auto-approve tools) | `false` |\n\n## Quick Start\n\nAdd the plugin to your global `opencode.json` configuration file (typically located at `~/.config/opencode/opencode.json`). OpenCode will automatically install the plugin from the registry on its next startup.\n\n```json\n{\n  \"plugin\": [\n    \"@fpr1m3/opencode-pai-plugin@2.1.0\"\n  ]\n}\n```\n\nUpon first run, the plugin will automatically:\n1. Detect or create your `PAI_DIR` (default: `$XDG_CONFIG_HOME/opencode`).\n2. Initialize the required directory structure for skill and history.\n3. Create a default `SKILL.md` core identity if one does not exist.\n\n## Development \u0026 Testing\n\nWe provide scripts to verify the plugin in a pristine environment:\n\n*   `./scripts/create-test-env.sh`: Creates a fresh, isolated OpenCode project for testing.\n*   `./scripts/test-full-flow.sh`: Runs a complete E2E verification of the plugin lifecycle.\n\n## Roadmap / TODO\n\n- [ ] **Voice Server Integration**: Implementation of the PAI voice notification server to provide audible feedback on task completion.\n- [ ] **Enhanced Agent Mapping**: More granular tracking of subagent state transitions.\n\n---\n\n**Note**: This plugin is designed to work with the PAI ecosystem. While it auto-initializes a basic structure, you can customize your identity by editing `$PAI_DIR/skill/core/SKILL.md`.\n\n---\n\nVibe coded with ❤️ by a mix of **Claude Code** and **OpenCode**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpr1m3%2Fopencode-pai-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffpr1m3%2Fopencode-pai-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpr1m3%2Fopencode-pai-plugin/lists"}