|
1 | 1 | # OpenCode PAI Plugin |
2 | 2 |
|
3 | | -This plugin implements the core Personal AI Infrastructure (PAI) logic as a native OpenCode plugin. |
| 3 | +A native OpenCode plugin that implements the **Personal AI Infrastructure (PAI)** logic, replacing legacy hook scripts with a cohesive, lifecycle-aware system. |
4 | 4 |
|
5 | | -## Installation |
| 5 | +## Features |
6 | 6 |
|
7 | | -Install the plugin using your package manager: |
| 7 | +### 1. Identity & Context Injection |
| 8 | +* **Core Skill Loading**: Automatically injects your `skills/core/SKILL.md` (from `PAI_DIR`) into the system prompt. |
| 9 | +* **Dynamic Substitution**: Supports placeholders like `{{DA}}`, `{{DA_COLOR}}`, and `{{ENGINEER_NAME}}` for personalized interactions. |
| 10 | +* **Project Requirements**: Automatically detects and loads `.opencode/dynamic-requirements.md` from your current project, allowing for task-specific instructions. |
8 | 11 |
|
9 | | -```bash |
10 | | -bun add github:fpr1m3/opencode-pai-plugin |
11 | | -``` |
| 12 | +### 2. Intelligent History & Logging |
| 13 | +* **Real-time Event Capture**: Logs all tool calls and SDK events to `PAI_DIR/history/raw-outputs` in an analytics-ready JSONL format. |
| 14 | +* **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. |
| 15 | +* **Agent Mapping**: Tracks session-to-agent relationships (e.g., mapping a subagent session to its specialized type). |
| 16 | + |
| 17 | +### 3. Security & Safety |
| 18 | +* **Security Validator**: A built-in firewall that scans Bash commands for dangerous patterns (reverse shells, recursive deletions, prompt injections) via the `permission.ask` hook. |
| 19 | +* **Safe Confirmations**: Automatically triggers a confirmation prompt for risky but potentially legitimate operations like forced Git pushes. |
| 20 | + |
| 21 | +### 4. Interactive Feedback |
| 22 | +* **Real-time Tab Titles**: Updates your terminal tab title *instantly* when a tool starts (e.g., `Running bash...`, `Editing index.ts...`). |
| 23 | +* **Post-Task Summaries**: Updates the tab title with a concise summary of what was accomplished when a task is completed. |
| 24 | + |
| 25 | +## Configuration |
12 | 26 |
|
13 | | -Or, clone the repository and build it manually: |
| 27 | +The plugin centers around the `PAI_DIR` environment variable. |
| 28 | + |
| 29 | +| Variable | Description | Default | |
| 30 | +| :--- | :--- | :--- | |
| 31 | +| `PAI_DIR` | Root directory for PAI skills and history | `~/.claude` | |
| 32 | +| `DA` | Name of your Digital Assistant | `PAI` | |
| 33 | +| `ENGINEER_NAME` | Your name/identity | `Engineer` | |
| 34 | +| `DA_COLOR` | UI color theme for your DA | `blue` | |
| 35 | + |
| 36 | +## Installation |
14 | 37 |
|
15 | 38 | ```bash |
16 | | -git clone https://github.com/fpr1m3/opencode-pai-plugin.git |
17 | | -cd opencode-pai-plugin |
18 | | -bun install |
19 | | -bun run build |
| 39 | +bun add github:fpr1m3/opencode-pai-plugin |
20 | 40 | ``` |
21 | 41 |
|
22 | 42 | ## Usage |
23 | 43 |
|
24 | | -Create a new file in your project at `.opencode/plugin/my-plugin.ts` and add the following code to register the plugin: |
| 44 | +Register the plugin in your `.opencode/plugins.ts` (or equivalent): |
25 | 45 |
|
26 | 46 | ```typescript |
27 | | -import { PaiPlugin } from "opencode-pai-plugin"; |
| 47 | +import { PAIPlugin } from "@opencode-ai/opencode-pai"; |
28 | 48 |
|
29 | | -export default PaiPlugin; |
| 49 | +export default PAIPlugin; |
30 | 50 | ``` |
31 | 51 |
|
32 | | -Once installed and registered, the plugin will automatically: |
33 | | - |
34 | | -* Load the `CORE/SKILL.md` file as core context at the start of each session. |
35 | | -* Log all events and tool calls to the `.opencode/history/raw-outputs` directory. |
36 | | -* Update the terminal tab title with the current session status (failsafe mode included). |
37 | | -* Create a session summary in `.opencode/history/sessions` when a session ends. |
38 | | - |
39 | 52 | --- |
40 | 53 |
|
41 | | -**Disclaimer:** This project is not built by the OpenCode team and is not affiliated with them in any way. |
| 54 | +**Note**: This plugin is designed to work with the PAI ecosystem and requires a valid `PAI_DIR` structure to function fully. |
0 commit comments