66
77# --- Configuration ---
88PLUGIN_PACKAGE=" ${PLUGIN_PACKAGE_OVERRIDE:- github: fpr1m3/ opencode-pai-plugin} "
9- PAI_DIR_DEFAULT=" $HOME /.claude"
9+ CONFIG_BASE=" ${XDG_CONFIG_HOME:- $HOME / .config} "
10+ PAI_DIR_DEFAULT=" $CONFIG_BASE /opencode"
1011
1112# --- UI Helpers ---
1213info () { echo -e " \033[0;34m[PAI INFO]\033[0m $1 " ; }
1314success () { echo -e " \033[0;32m[PAI SUCCESS]\033[0m $1 " ; }
1415warn () { echo -e " \033[0;33m[PAI WARN]\033[0m $1 " ; }
15- error () { echo -e " \033[0;31m[PAI ERROR]\033[0m $1 " ; exit 1; }
16+ error () {
17+ echo -e " \033[0;31m[PAI ERROR]\033[0m $1 "
18+ exit 1
19+ }
1620
1721# --- Logic ---
1822
1923info " Starting PAI Plugin installation..."
2024
2125# 1. Project Detection
2226if [ ! -f " package.json" ]; then
23- error " No package.json found. Please run this script from the root of your OpenCode project."
27+ error " No package.json found. Please run this script from the root of your OpenCode project."
2428fi
2529
2630# 2. Dependency Installation
2731info " Installing plugin package..."
2832if command -v bun > /dev/null 2>&1 ; then
29- bun add " $PLUGIN_PACKAGE "
33+ bun add " $PLUGIN_PACKAGE "
3034elif command -v npm > /dev/null 2>&1 ; then
31- npm install " $PLUGIN_PACKAGE "
35+ npm install " $PLUGIN_PACKAGE "
3236else
33- error " Neither bun nor npm found. Please install a package manager."
37+ error " Neither bun nor npm found. Please install a package manager."
3438fi
3539
3640# 3. Plugin Registration
@@ -39,14 +43,14 @@ mkdir -p .opencode/plugins
3943
4044PLUGIN_REG_FILE=" .opencode/plugins/pai.ts"
4145if [ -f " $PLUGIN_REG_FILE " ]; then
42- warn " $PLUGIN_REG_FILE already exists. Skipping registration."
46+ warn " $PLUGIN_REG_FILE already exists. Skipping registration."
4347else
44- cat > " $PLUGIN_REG_FILE " << EOF
48+ cat > " $PLUGIN_REG_FILE " << EOF
4549import { PAIPlugin } from "opencode-pai-plugin";
4650
4751export default PAIPlugin;
4852EOF
49- success " Plugin registered in $PLUGIN_REG_FILE "
53+ success " Plugin registered in $PLUGIN_REG_FILE "
5054fi
5155
5256# 4. PAI Infrastructure Check
@@ -55,29 +59,29 @@ CORE_SKILL_FILE="$CURRENT_PAI_DIR/skills/core/SKILL.md"
5559info " Checking PAI infrastructure at $CURRENT_PAI_DIR ..."
5660
5761if [ ! -f " $CORE_SKILL_FILE " ]; then
58- warn " PAI core identity not found at $CORE_SKILL_FILE "
59- # Auto-initialize if non-interactive or if user says yes
60- if [[ " $CI " == " true" ]] || [[ " $PAI_NON_INTERACTIVE " == " true" ]]; then
61- INITIALIZE_PAI=" y"
62- else
63- read -p " Would you like to initialize a basic PAI structure now? (y/n) " -n 1 -r
64- echo " "
65- INITIALIZE_PAI=$REPLY
66- fi
62+ warn " PAI core identity not found at $CORE_SKILL_FILE "
63+ # Auto-initialize if non-interactive or if user says yes
64+ if [[ " $CI " == " true" ]] || [[ " $PAI_NON_INTERACTIVE " == " true" ]]; then
65+ INITIALIZE_PAI=" y"
66+ else
67+ read -p " Would you like to initialize a basic PAI structure now? (y/n) " -n 1 -r
68+ echo " "
69+ INITIALIZE_PAI=$REPLY
70+ fi
6771
68- if [[ $INITIALIZE_PAI =~ ^[Yy]$ ]]; then
69- mkdir -p " $CURRENT_PAI_DIR /skills/core"
70- mkdir -p " $CURRENT_PAI_DIR /history/raw-outputs"
71- mkdir -p " $CURRENT_PAI_DIR /history/sessions"
72-
73- cat > " $CORE_SKILL_FILE " << EOF
72+ if [[ $INITIALIZE_PAI =~ ^[Yy]$ ]]; then
73+ mkdir -p " $CURRENT_PAI_DIR /skills/core"
74+ mkdir -p " $CURRENT_PAI_DIR /history/raw-outputs"
75+ mkdir -p " $CURRENT_PAI_DIR /history/sessions"
76+
77+ cat > " $CORE_SKILL_FILE " << EOF
7478# PAI Core Identity
7579You are {{DA}}, a Personal AI Infrastructure.
7680Your primary engineer is {{ENGINEER_NAME}}.
7781EOF
78- info " Created default SKILL.md"
79- success " PAI structure initialized."
80- fi
82+ info " Created default SKILL.md"
83+ success " PAI structure initialized."
84+ fi
8185fi
8286
8387success " PAI Plugin installation complete!"
0 commit comments