diff --git a/CHANGELOG.md b/CHANGELOG.md index d1a7d548..7c861d63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed + +- Deleted `adapters/codex/install.sh` and `adapters/opencode/install.sh` (#395). Both sourced every command and skill from `plugins/`, a tree removed when plugins moved to standalone repos, so each mapping took the "skipped" branch and the scripts installed nothing while still printing `[OK] Installation complete!` and listing skills they had not written. They were not inert: before copying, they `rm -rf`'d five skill directories and `~/.codex/prompts`, so running one deleted a working install and reported success. `agentsys --tool codex` / `agentsys --tool opencode` (`bin/cli.js`) is the supported install path, with `scripts/dev-install.js` covering dev installs, and the adapter READMEs, the OpenCode plugin checklist, and the `maintain-cross-platform` skill no longer point at the scripts. + ### Security - Claude plugin marketplace/install/update/uninstall in `bin/cli.js` now spawn via `execFileSync` with an argv array, so no plugin ID reaches a shell (#388). diff --git a/__tests__/opencode-compatibility.test.js b/__tests__/opencode-compatibility.test.js index 0a4ae332..d6dc18a8 100644 --- a/__tests__/opencode-compatibility.test.js +++ b/__tests__/opencode-compatibility.test.js @@ -252,80 +252,9 @@ describe('OpenCode Compatibility', () => { }); }); - describe('Install script validation', () => { - it('should have OpenCode install script', () => { - const installPath = path.join(__dirname, '../adapters/opencode/install.sh'); - expect(fs.existsSync(installPath)).toBe(true); - }); - - it('should install lib files to OpenCode commands directory', () => { - const installScript = fs.readFileSync( - path.join(__dirname, '../adapters/opencode/install.sh'), - 'utf-8' - ); - - // Should copy lib files (cp -r or similar) - expect(installScript).toMatch(/cp\s+-r|cp.*\$.*lib/); - - // Should define OPENCODE_CONFIG_DIR using XDG path (not ~/.opencode/) - expect(installScript).toMatch(/OPENCODE_CONFIG_DIR/); - // Should reference both XDG_CONFIG_HOME and .config/opencode - expect(installScript).toContain('XDG_CONFIG_HOME'); - expect(installScript).toContain('.config/opencode'); - }); - - it('should handle empty/whitespace XDG_CONFIG_HOME like JavaScript', () => { - const installScript = fs.readFileSync( - path.join(__dirname, '../adapters/opencode/install.sh'), - 'utf-8' - ); - - // Should check for non-empty AND non-whitespace (matching JS behavior) - // The bash pattern [^[:space:]] ensures whitespace-only values are rejected - expect(installScript).toContain('-n "${XDG_CONFIG_HOME}"'); - expect(installScript).toContain('[^[:space:]]'); - }); - - it('should clean up legacy ~/.opencode/ paths', () => { - const installScript = fs.readFileSync( - path.join(__dirname, '../adapters/opencode/install.sh'), - 'utf-8' - ); - - // Should have legacy cleanup - expect(installScript).toMatch(/LEGACY_OPENCODE_DIR/); - expect(installScript).toMatch(/legacy/i); - }); - - it('should have complete agent list matching dev-install.js', () => { - const installScript = fs.readFileSync( - path.join(__dirname, '../adapters/opencode/install.sh'), - 'utf-8' - ); - - // Critical agents that must be in both lists - const criticalAgents = [ - 'exploration-agent.md', - 'implementation-agent.md', - 'planning-agent.md', - 'perf-orchestrator.md', - 'enhancement-orchestrator.md', - 'worktree-manager.md' - ]; - - for (const agent of criticalAgents) { - expect(installScript).toContain(agent); - } - }); - - it('should handle path substitutions for OpenCode', () => { - const installScript = fs.readFileSync( - path.join(__dirname, '../adapters/opencode/install.sh'), - 'utf-8' - ); - - // Should transform CLAUDE_PLUGIN_ROOT to PLUGIN_ROOT - expect(installScript).toMatch(/CLAUDE_PLUGIN_ROOT.*PLUGIN_ROOT|sed.*PLUGIN_ROOT/); - }); - }); + // The former 'Install script validation' block asserted on + // adapters/opencode/install.sh, which was removed: it sourced files from the + // deleted plugins/ tree and so installed nothing. Installs now go through + // bin/cli.js (npm) or scripts/dev-install.js (dev); the XDG_CONFIG_HOME + // handling those share is covered in dev-install.test.js. }); diff --git a/adapters/README.md b/adapters/README.md index 8c662f66..01daf898 100644 --- a/adapters/README.md +++ b/adapters/README.md @@ -22,9 +22,8 @@ OpenAI's Codex command-line interface. **Installation:** ```bash -git clone https://github.com/agent-sh/agentsys.git -cd agentsys -./adapters/codex/install.sh +npm install -g agentsys +agentsys --tool codex ``` **Usage:** @@ -44,9 +43,8 @@ Open-source AI coding assistant. **Installation:** ```bash -git clone https://github.com/agent-sh/agentsys.git -cd agentsys -./adapters/opencode/install.sh +npm install -g agentsys +agentsys --tool opencode ``` **Usage:** @@ -145,32 +143,28 @@ claude plugin install next-task@agentsys ### Codex CLI ```bash -# Via installer script -./adapters/codex/install.sh +agentsys --tool codex ``` **Pros:** - One-command installation - All commands at once -- Easy updates (re-run installer) +- Easy updates (re-run the CLI) **Cons:** -- Requires git clone first - Manual updates ### OpenCode ```bash -# Via installer script -./adapters/opencode/install.sh +agentsys --tool opencode ``` **Pros:** - One-command installation - OpenCode-specific features (@, !) -- Easy updates (re-run installer) +- Easy updates (re-run the CLI) **Cons:** -- Requires git clone first - Manual updates --- @@ -195,9 +189,8 @@ Automatic via marketplace updates. ### Codex CLI & OpenCode ```bash -cd /path/to/agentsys -git pull origin main -./adapters/codex/install.sh # Or ./adapters/opencode/install.sh +npm install -g agentsys@latest +agentsys --tool codex # Or: agentsys --tool opencode ``` --- @@ -216,7 +209,7 @@ git pull origin main ### Path errors in commands Re-run the installer to fix path substitutions: ```bash -./adapters/[tool]/install.sh +agentsys --tool [tool] ``` ### Node.js errors @@ -240,7 +233,7 @@ Found a bug or want to add support for another tool? 1. Open an issue: https://github.com/agent-sh/agentsys/issues 2. Submit a PR with: - New adapter directory: `adapters/[tool-name]/` - - Installation script: `install.sh` + - Install support in `bin/cli.js` (npm installs) and `scripts/dev-install.js` (dev installs) - Documentation: `README.md` - Update this file diff --git a/adapters/codex/README.md b/adapters/codex/README.md index f376e70c..15bdea8b 100644 --- a/adapters/codex/README.md +++ b/adapters/codex/README.md @@ -5,9 +5,8 @@ Professional-grade slash commands adapted for OpenAI's Codex CLI. ## Quick Install ```bash -git clone https://github.com/agent-sh/agentsys.git -cd agentsys -./adapters/codex/install.sh +npm install -g agentsys +agentsys --tool codex ``` ## Prerequisites @@ -219,9 +218,8 @@ Node.js · Python · Rust · Go · Java To update commands: ```bash -cd /path/to/agentsys -git pull origin main -./adapters/codex/install.sh +npm install -g agentsys@latest +agentsys --tool codex ``` --- @@ -236,7 +234,7 @@ git pull origin main ### Path errors Re-run installer to fix path substitutions: ```bash -./adapters/codex/install.sh +agentsys --tool codex ``` ### Node.js not found diff --git a/adapters/codex/install.sh b/adapters/codex/install.sh deleted file mode 100644 index 0ec10bbc..00000000 --- a/adapters/codex/install.sh +++ /dev/null @@ -1,260 +0,0 @@ -#!/usr/bin/env bash -set -e - -# [DEPRECATED] This script is outdated and uses old plugin names. -# Use instead: agentsys --tool codex -# Or: node scripts/dev-install.js codex - -# Codex CLI Installer for agentsys commands -# This script installs all 5 slash commands for use with OpenAI Codex CLI - -echo "[INSTALL] Installing agentsys commands for Codex CLI..." -echo - -# Configuration -REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -CODEX_CONFIG_DIR="${HOME}/.codex" -CODEX_SKILLS_DIR="${CODEX_CONFIG_DIR}/skills" -CODEX_LIB_DIR="${CODEX_CONFIG_DIR}/agentsys/lib" - -# Detect OS and normalize paths -if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then - IS_WINDOWS=true - # Convert Windows path to Unix-style for bash compatibility - CODEX_CONFIG_DIR="${USERPROFILE}/.codex" - # Replace backslashes with forward slashes - CODEX_CONFIG_DIR="${CODEX_CONFIG_DIR//\\//}" - CODEX_SKILLS_DIR="${CODEX_CONFIG_DIR}/skills" - CODEX_LIB_DIR="${CODEX_CONFIG_DIR}/agentsys/lib" -else - IS_WINDOWS=false -fi - -echo "[CONFIG] Configuration:" -echo " Repository: $REPO_ROOT" -echo " Skills to: $CODEX_SKILLS_DIR" -echo " Libraries to: $CODEX_LIB_DIR" -echo - -# Check prerequisites -echo "[CHECK] Checking prerequisites..." - -# Check Node.js -if ! command -v node &> /dev/null; then - echo "[ERROR] Node.js not found. Install from: https://nodejs.org" - exit 1 -fi -NODE_VERSION=$(node --version) -echo " [OK] Node.js $NODE_VERSION" - -# Check Git -if ! command -v git &> /dev/null; then - echo "[ERROR] Git not found. Install from: https://git-scm.com" - exit 1 -fi -GIT_VERSION=$(git --version | cut -d' ' -f3) -echo " [OK] Git $GIT_VERSION" - -# Check Codex CLI (optional - user may not have it installed yet) -if command -v codex &> /dev/null; then - CODEX_VERSION=$(codex --version 2>&1 | head -n1 || echo "unknown") - echo " [OK] Codex CLI $CODEX_VERSION" -else - echo " [WARN] Codex CLI not found (install from: https://developers.openai.com/codex/cli)" - echo " You can still install commands and use Codex CLI later" -fi - -echo - -# Create directories -echo "[DIR] Creating directories..." -mkdir -p "$CODEX_SKILLS_DIR" -mkdir -p "$CODEX_LIB_DIR"/{platform,patterns,utils} -echo " [OK] Created $CODEX_SKILLS_DIR" -echo " [OK] Created $CODEX_LIB_DIR" -echo - -# Copy library files from shared root lib directory -echo "[LIB] Installing shared libraries..." -# Use explicit iteration to handle paths with spaces safely -for item in "${REPO_ROOT}/lib"/*; do - cp -r "$item" "${CODEX_LIB_DIR}/" -done -echo " [OK] Copied platform detection" -echo " [OK] Copied pattern libraries" -echo " [OK] Copied utility functions" -echo - -# Install skills with proper SKILL.md format -echo "[SETUP] Installing skills..." - -# Skill mappings: skill_name:plugin:source_file:description -# Codex skills require SKILL.md with name and description in YAML frontmatter -SKILL_MAPPINGS=( - "next-task:next-task:next-task:Master workflow orchestrator with autonomous task-to-production automation" - "ship:ship:ship:Complete PR workflow from commit to production with validation" - "deslop-around:deslop-around:deslop-around:AI slop cleanup with minimal diffs and behavior preservation" - "project-review:project-review:project-review:Multi-agent iterative code review until zero issues remain" - "reality-check-scan:reality-check:scan:Deep repository analysis to detect plan drift and code reality gaps" - "delivery-approval:next-task:delivery-approval:Validate task completion and approve for shipping" - "sync-docs:sync-docs:sync-docs:Sync documentation with actual code state" -) - -for mapping in "${SKILL_MAPPINGS[@]}"; do - IFS=':' read -r SKILL_NAME PLUGIN SOURCE_NAME DESCRIPTION <<< "$mapping" - SOURCE_FILE="$REPO_ROOT/plugins/$PLUGIN/commands/$SOURCE_NAME.md" - SKILL_DIR="$CODEX_SKILLS_DIR/$SKILL_NAME" - TARGET_FILE="$SKILL_DIR/SKILL.md" - - if [ -f "$SOURCE_FILE" ]; then - # Create skill directory - mkdir -p "$SKILL_DIR" - - # Create SKILL.md with proper frontmatter - # Remove existing frontmatter and add Codex-compatible format - { - echo "---" - echo "name: $SKILL_NAME" - echo "description: $DESCRIPTION" - echo "---" - echo "" - # Skip original frontmatter if present and include rest of content - sed '1{/^---$/!b};1,/^---$/d' "$SOURCE_FILE" - } > "$TARGET_FILE" - - echo " [OK] Installed skill: \$${SKILL_NAME}" - else - echo " [WARN] Skipped \$${SKILL_NAME} (source not found: $SOURCE_FILE)" - fi -done - -# Install native skills (already have SKILL.md format) -echo -echo "[LIB] Installing native skills..." - -# Native skill mappings: skill_name:plugin:skill_name_in_source -NATIVE_SKILL_MAPPINGS=( - "orchestrate-review:next-task:orchestrate-review" -) - -for mapping in "${NATIVE_SKILL_MAPPINGS[@]}"; do - IFS=':' read -r SKILL_NAME PLUGIN SOURCE_SKILL <<< "$mapping" - SOURCE_SKILL_DIR="$REPO_ROOT/plugins/$PLUGIN/skills/$SOURCE_SKILL" - TARGET_SKILL_DIR="$CODEX_SKILLS_DIR/$SKILL_NAME" - - if [ -d "$SOURCE_SKILL_DIR" ]; then - # Create skill directory - mkdir -p "$TARGET_SKILL_DIR" - - # Copy SKILL.md - if [ -f "$SOURCE_SKILL_DIR/SKILL.md" ]; then - cp "$SOURCE_SKILL_DIR/SKILL.md" "$TARGET_SKILL_DIR/SKILL.md" - echo " [OK] Installed native skill: \$${SKILL_NAME}" - else - echo " [WARN] Skipped \$${SKILL_NAME} (SKILL.md not found)" - continue - fi - - # Copy optional subdirectories (references/, scripts/, assets/) - for subdir in references scripts assets; do - if [ -d "$SOURCE_SKILL_DIR/$subdir" ]; then - cp -r "$SOURCE_SKILL_DIR/$subdir" "$TARGET_SKILL_DIR/" - echo " [OK] Copied $subdir/ directory" - fi - done - else - echo " [WARN] Skipped \$${SKILL_NAME} (source not found: $SOURCE_SKILL_DIR)" - fi -done - -# Remove old/deprecated skills and prompts -OLD_SKILLS=("deslop" "review" "reality-check-set" "pr-merge" "review-orchestrator") -for old_skill in "${OLD_SKILLS[@]}"; do - if [ -d "$CODEX_SKILLS_DIR/$old_skill" ]; then - rm -rf "$CODEX_SKILLS_DIR/$old_skill" - echo " [DEL] Removed deprecated skill: $old_skill" - fi -done - -# Clean up old prompts directory if it exists -OLD_PROMPTS_DIR="$CODEX_CONFIG_DIR/prompts" -if [ -d "$OLD_PROMPTS_DIR" ]; then - rm -rf "$OLD_PROMPTS_DIR" - echo " [DEL] Removed old prompts directory" -fi - -echo - -# Create README -cat > "$CODEX_CONFIG_DIR/AGENTSYS_README.md" << 'EOF' -# agentsys for Codex CLI - -Skills installed for OpenAI Codex CLI. - -## Available Skills - -Access via $ prefix: -- `$next-task` - Master workflow orchestrator -- `$ship` - PR workflow from commit to production -- `$deslop-around` - AI slop cleanup -- `$project-review` - Multi-agent code review -- `$reality-check-scan` - Plan drift detection -- `$delivery-approval` - Validate task completion -- `$sync-docs` - Sync documentation - -## Usage - -In Codex CLI: -```bash -codex -> $next-task -> $ship -> $deslop-around -``` - -Or type `$` to see available skills. - -## Libraries - -Shared libraries at: ~/.codex/agentsys/lib/ - -## Updates - -```bash -cd /path/to/agentsys -./adapters/codex/install.sh -``` - -## Support - -- Repository: https://github.com/agent-sh/agentsys -- Issues: https://github.com/agent-sh/agentsys/issues -EOF - -echo " [OK] Created README" -echo - -# Success message -echo "[OK] Installation complete!" -echo -echo "[LIST] Installed Skills (access via \$ prefix):" -echo " • \$next-task" -echo " • \$ship" -echo " • \$deslop-around" -echo " • \$project-review" -echo " • \$reality-check-scan" -echo " • \$delivery-approval" -echo " • \$sync-docs" -echo -echo "[NEXT] Next Steps:" -echo " 1. Start Codex CLI: codex" -echo " 2. Type: \$ (shows available skills)" -echo " 3. Select a skill or type: \$next-task" -echo " 4. See help: cat $CODEX_CONFIG_DIR/AGENTSYS_README.md" -echo -echo "[TIP] Pro Tip: Type \$ to see all available skills" -echo -echo "[UPDATE] To update skills, re-run this installer:" -echo " ./adapters/codex/install.sh" -echo -echo "Happy coding!" diff --git a/adapters/opencode/README.md b/adapters/opencode/README.md index 40dab1bf..deb5ca84 100644 --- a/adapters/opencode/README.md +++ b/adapters/opencode/README.md @@ -5,9 +5,8 @@ Professional-grade slash commands adapted for OpenCode. ## Quick Install ```bash -git clone https://github.com/agent-sh/agentsys.git -cd agentsys -./adapters/opencode/install.sh +npm install -g agentsys +agentsys --tool opencode ``` ## Prerequisites @@ -232,9 +231,8 @@ Node.js · Python · Rust · Go · Java To update commands: ```bash -cd /path/to/agentsys -git pull origin main -./adapters/opencode/install.sh +npm install -g agentsys@latest +agentsys --tool opencode ``` --- @@ -253,7 +251,7 @@ Currently, OpenCode slash commands are only available in the TUI (Terminal User ### Path errors Re-run installer to fix path substitutions: ```bash -./adapters/opencode/install.sh +agentsys --tool opencode ``` ### Node.js not found diff --git a/adapters/opencode/install.sh b/adapters/opencode/install.sh deleted file mode 100644 index b8295c18..00000000 --- a/adapters/opencode/install.sh +++ /dev/null @@ -1,322 +0,0 @@ -#!/usr/bin/env bash -set -e - -# [DEPRECATED] This script is outdated and uses old plugin names. -# Use instead: agentsys --tool opencode -# Or: node scripts/dev-install.js opencode - -# OpenCode Installer for agentsys commands -# This script installs all 5 slash commands for use with OpenCode - -echo "[INSTALL] Installing agentsys commands for OpenCode..." -echo - -# Configuration -REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - -# Use $HOME which works correctly on all platforms including Git Bash on Windows -# (Git Bash sets HOME to Unix-style path like /c/Users/username) -# OpenCode global config follows XDG Base Directory Specification: -# - Default: ~/.config/opencode/ -# - Override: $XDG_CONFIG_HOME/opencode/ (if XDG_CONFIG_HOME is set and not empty/whitespace) -# Note: Must match logic in scripts/dev-install.js getOpenCodeConfigDir() -if [[ -n "${XDG_CONFIG_HOME}" && "${XDG_CONFIG_HOME}" =~ [^[:space:]] ]]; then - OPENCODE_CONFIG_DIR="${XDG_CONFIG_HOME}/opencode" -else - OPENCODE_CONFIG_DIR="${HOME}/.config/opencode" -fi -# OpenCode expects commands directly in commands/, not a subdirectory -OPENCODE_COMMANDS_DIR="${OPENCODE_CONFIG_DIR}/commands" -LIB_DIR="${OPENCODE_COMMANDS_DIR}/lib" - -# Legacy path for cleanup (incorrect, pre-XDG location) -LEGACY_OPENCODE_DIR="${HOME}/.opencode" - -# Detect OS for platform-specific notes -if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then - IS_WINDOWS=true -else - IS_WINDOWS=false -fi - -echo "[CONFIG] Configuration:" -echo " Repository: $REPO_ROOT" -echo " Install to: $OPENCODE_COMMANDS_DIR" -echo - -# Check prerequisites -echo "[CHECK] Checking prerequisites..." - -# Check Node.js -if ! command -v node &> /dev/null; then - echo "[ERROR] Node.js not found. Install from: https://nodejs.org" - exit 1 -fi -NODE_VERSION=$(node --version) -echo " [OK] Node.js $NODE_VERSION" - -# Check Git -if ! command -v git &> /dev/null; then - echo "[ERROR] Git not found. Install from: https://git-scm.com" - exit 1 -fi -GIT_VERSION=$(git --version | cut -d' ' -f3) -echo " [OK] Git $GIT_VERSION" - -# Check OpenCode (optional - user may not have it installed yet) -if command -v opencode &> /dev/null; then - OPENCODE_VERSION=$(opencode --version 2>&1 | head -n1 || echo "unknown") - echo " [OK] OpenCode $OPENCODE_VERSION" -else - echo " [WARN] OpenCode not found (install from: https://opencode.ai)" - echo " You can still install commands and use OpenCode later" -fi - -echo - -# Create directories -echo "[DIR] Creating directories..." -mkdir -p "$OPENCODE_COMMANDS_DIR" -mkdir -p "$LIB_DIR"/{platform,patterns,utils} -echo " [OK] Created $OPENCODE_COMMANDS_DIR" -echo " [OK] Created $LIB_DIR" -echo - -# Copy library files from shared root lib directory -echo "[LIB] Installing shared libraries..." -# Use explicit iteration to handle paths with spaces safely -for item in "${REPO_ROOT}/lib"/*; do - cp -r "$item" "${LIB_DIR}/" -done -echo " [OK] Copied platform detection" -echo " [OK] Copied pattern libraries" -echo " [OK] Copied utility functions" -echo - -# Install commands with path adjustments -echo "[SETUP] Installing commands..." - -# Command mappings: target_name:plugin:source_file -# Format allows commands from different plugins -COMMAND_MAPPINGS=( - "deslop-around:deslop-around:deslop-around" - "next-task:next-task:next-task" - "delivery-approval:next-task:delivery-approval" - "sync-docs:sync-docs:sync-docs" - "project-review:project-review:project-review" - "ship:ship:ship" - "reality-check-scan:reality-check:scan" -) - -for mapping in "${COMMAND_MAPPINGS[@]}"; do - IFS=':' read -r TARGET_NAME PLUGIN SOURCE_NAME <<< "$mapping" - SOURCE_FILE="$REPO_ROOT/plugins/$PLUGIN/commands/$SOURCE_NAME.md" - TARGET_FILE="$OPENCODE_COMMANDS_DIR/$TARGET_NAME.md" - - if [ -f "$SOURCE_FILE" ]; then - # Copy and transform CLAUDE_PLUGIN_ROOT -> PLUGIN_ROOT for OpenCode - sed 's/\${CLAUDE_PLUGIN_ROOT}/${PLUGIN_ROOT}/g; s/\$CLAUDE_PLUGIN_ROOT/$PLUGIN_ROOT/g' \ - "$SOURCE_FILE" > "$TARGET_FILE" - echo " [OK] Installed /$TARGET_NAME" - else - echo " [WARN] Skipped /$TARGET_NAME (source not found: $SOURCE_FILE)" - fi -done - -# Remove old/legacy commands that no longer exist -OLD_COMMANDS=("pr-merge") -for old_cmd in "${OLD_COMMANDS[@]}"; do - if [ -f "$OPENCODE_COMMANDS_DIR/$old_cmd.md" ]; then - rm "$OPENCODE_COMMANDS_DIR/$old_cmd.md" - echo " [DEL] Removed legacy /$old_cmd" - fi -done - -echo - -# Create environment setup script -echo "[ENV] Creating environment setup..." -cat > "$OPENCODE_COMMANDS_DIR/env.sh" << 'EOF' -#!/usr/bin/env bash -# Environment variables for agentsys commands in OpenCode - -# Set the root directory for commands to find libraries -export OPENCODE_COMMANDS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Add lib directory to NODE_PATH if needed -export NODE_PATH="${OPENCODE_COMMANDS_ROOT}/lib:${NODE_PATH}" - -# Platform detection helpers -export AGENTSYS_PLATFORM_SCRIPT="${OPENCODE_COMMANDS_ROOT}/lib/platform/detect-platform.js" -export AGENTSYS_TOOLS_SCRIPT="${OPENCODE_COMMANDS_ROOT}/lib/platform/verify-tools.js" -EOF - -chmod +x "$OPENCODE_COMMANDS_DIR/env.sh" -echo " [OK] Created environment setup script" -echo - -# Install native OpenCode plugin (auto-thinking, workflow enforcement, compaction) -echo "[PLUGIN] Installing native plugin..." -PLUGIN_DIR="${OPENCODE_CONFIG_DIR}/plugins" -PLUGIN_DEST="${PLUGIN_DIR}/agentsys.ts" -PLUGIN_SRC="${REPO_ROOT}/adapters/opencode-plugin" - -if [ -d "$PLUGIN_SRC" ]; then - mkdir -p "$PLUGIN_DIR" - cp "$PLUGIN_SRC/index.ts" "$PLUGIN_DEST" 2>/dev/null || true - echo " [OK] Installed native plugin to $PLUGIN_DEST" - echo " Features: Auto-thinking selection, workflow enforcement, session compaction" -else - echo " [WARN] Native plugin source not found at $PLUGIN_SRC" -fi -echo - -# Create README -cat > "$OPENCODE_COMMANDS_DIR/README.md" << 'EOF' -# agentsys for OpenCode - -This directory contains the agentsys commands adapted for OpenCode. - -## Available Commands - -- `/deslop-around` - AI slop cleanup with minimal diffs -- `/next-task` - Intelligent task prioritization -- `/project-review` - Multi-agent code review -- `/ship` - Complete PR workflow -- `/pr-merge` - Intelligent PR merge - -## Usage - -In OpenCode TUI, invoke commands directly: - -```bash -/deslop-around -/next-task -/project-review -/ship -/pr-merge -``` - -You can also pass arguments: -```bash -/deslop-around apply -/next-task bug -/ship --strategy rebase -``` - -## OpenCode-Specific Features - -OpenCode supports additional features you can use with these commands: - -- **@filename** - Include file contents in prompt -- **!command** - Include bash command output in prompt - -Example: -```bash -/project-review @src/main.py -/deslop-around apply !git diff --name-only -``` - -## Environment - -Commands use the shared library at: -``` -~/.config/opencode/commands/lib/ -``` - -## Updates - -To update commands, re-run the installer: -```bash -cd /path/to/agentsys -./adapters/opencode/install.sh -``` - -## Support - -- Repository: https://github.com/agent-sh/agentsys -- Issues: https://github.com/agent-sh/agentsys/issues -EOF - -echo " [OK] Created README" -echo - -# Run migration tool to set up native OpenCode agents -echo "[MIGRATE] Setting up native OpenCode agents..." -if [ -f "$REPO_ROOT/scripts/migrate-opencode.js" ]; then - node "$REPO_ROOT/scripts/migrate-opencode.js" --target "$(pwd)" 2>/dev/null || true - echo " [OK] Native agents configured" -else - echo " [SKIP] Migration script not found" -fi -echo - -# Clean up legacy paths (~/.opencode/ - incorrect, pre-XDG location) -echo "[CLEANUP] Checking for legacy installations..." -LEGACY_COMMANDS_DIR="${LEGACY_OPENCODE_DIR}/commands/agentsys" -LEGACY_PLUGINS_DIR="${LEGACY_OPENCODE_DIR}/plugins/agentsys" -LEGACY_AGENTS_DIR="${LEGACY_OPENCODE_DIR}/agents" - -cleaned_legacy=false -if [ -d "$LEGACY_COMMANDS_DIR" ]; then - rm -rf "$LEGACY_COMMANDS_DIR" - echo " [DEL] Removed legacy ~/.opencode/commands/agentsys" - cleaned_legacy=true -fi -if [ -d "$LEGACY_PLUGINS_DIR" ]; then - rm -rf "$LEGACY_PLUGINS_DIR" - echo " [DEL] Removed legacy ~/.opencode/plugins/agentsys" - cleaned_legacy=true -fi -if [ -d "$LEGACY_AGENTS_DIR" ]; then - # Only remove known agent files, not the whole directory - # Must match list in scripts/dev-install.js knownAgents array - # Generated from: ls plugins/*/agents/*.md | xargs basename | sort -u - known_agents=( - 'agent-enhancer.md' 'ci-fixer.md' 'ci-monitor.md' 'claudemd-enhancer.md' - 'delivery-validator.md' 'deslop-agent.md' 'docs-enhancer.md' 'enhancement-orchestrator.md' - 'exploration-agent.md' 'hooks-enhancer.md' 'implementation-agent.md' 'learn-agent.md' - 'map-validator.md' 'perf-analyzer.md' 'perf-code-paths.md' 'perf-investigation-logger.md' - 'perf-orchestrator.md' 'perf-theory-gatherer.md' 'perf-theory-tester.md' 'plan-synthesizer.md' - 'planning-agent.md' 'plugin-enhancer.md' 'prompt-enhancer.md' 'simple-fixer.md' - 'skills-enhancer.md' 'sync-docs-agent.md' 'task-discoverer.md' 'test-coverage-checker.md' - 'worktree-manager.md' - ) - for agent in "${known_agents[@]}"; do - if [ -f "$LEGACY_AGENTS_DIR/$agent" ]; then - rm "$LEGACY_AGENTS_DIR/$agent" - cleaned_legacy=true - fi - done - if [ "$cleaned_legacy" = true ]; then - echo " [DEL] Removed legacy agent files from ~/.opencode/agents" - fi -fi -if [ "$cleaned_legacy" = false ]; then - echo " [OK] No legacy installations found" -fi -echo - -# Success message -echo "[OK] Installation complete!" -echo -echo "[LIST] Installed Commands:" -for mapping in "${COMMAND_MAPPINGS[@]}"; do - IFS=':' read -r cmd _ _ <<< "$mapping" - echo " • /$cmd" -done -echo -echo "[NEXT] Next Steps:" -echo " 1. Start OpenCode TUI: opencode" -echo " 2. Use commands: /next-task, /ship, etc." -echo " 3. See help: cat $OPENCODE_COMMANDS_DIR/README.md" -echo -echo "[TIP] OpenCode Pro Tips:" -echo " • Use @filename to include file contents" -echo " • Use !command to include bash output" -echo " • Example: /project-review @src/main.py" -echo -echo "[UPDATE] To update commands, re-run this installer:" -echo " ./adapters/opencode/install.sh" -echo -echo "Happy coding!" diff --git a/checklists/update-opencode-plugin.md b/checklists/update-opencode-plugin.md index b24e737e..d51808b8 100644 --- a/checklists/update-opencode-plugin.md +++ b/checklists/update-opencode-plugin.md @@ -17,7 +17,7 @@ The native OpenCode plugin provides deep integration: | `adapters/opencode-plugin/index.ts` | Plugin implementation | | `adapters/opencode-plugin/package.json` | Dependencies | | `bin/cli.js` | npm installer (copies plugin) | -| `adapters/opencode/install.sh` | Shell installer (copies plugin) | +| `scripts/dev-install.js` | Dev installer (`agentsys-dev dev-install opencode`) - its own copy of the same logic | | `agent-docs/OPENCODE-REFERENCE.md` | Knowledge base | ## 1. Update Plugin Implementation @@ -115,7 +115,7 @@ output.options.thinkingConfig = { ## Common Pitfalls -- **Don't forget to update both installers** - `bin/cli.js` AND `adapters/opencode/install.sh` +- **Two paths copy the plugin** - `bin/cli.js` (npm installs) and `scripts/dev-install.js` (dev installs); plugin changes land nowhere until both copy them, and they drift if only one is updated - **Match agent names exactly** - Case-sensitive matching against `input.agent` - **Test all providers** - Each has different thinking APIs - **Keep flow.json format stable** - Other parts of the system read it diff --git a/meta/skills/maintain-cross-platform/SKILL.md b/meta/skills/maintain-cross-platform/SKILL.md index e2e9ceff..0cf06a67 100644 --- a/meta/skills/maintain-cross-platform/SKILL.md +++ b/meta/skills/maintain-cross-platform/SKILL.md @@ -126,8 +126,8 @@ permission: | `bin/cli.js` | Main installer (811 lines) - handles all 3 platforms | | `scripts/setup-hooks.js` | Git hooks installer (pre-commit, pre-push) | | `adapters/opencode-plugin/` | Native OpenCode TypeScript plugin | -| `adapters/opencode/` | OpenCode install script (legacy) | -| `adapters/codex/` | Codex install script (legacy) | +| `adapters/opencode/` | Generated OpenCode commands, agents, skills | +| `adapters/codex/` | Generated Codex skills | | `mcp-server/index.js` | Cross-platform MCP server | ### Validation Scripts (All in CI + Pre-Push) diff --git a/scripts/gen-adapters.js b/scripts/gen-adapters.js index 43726708..2a143984 100644 --- a/scripts/gen-adapters.js +++ b/scripts/gen-adapters.js @@ -214,7 +214,7 @@ function computeAdapters() { function findOrphanedAdapters(generatedFiles) { const orphans = []; // Hand-maintained files that should not be treated as orphans - const EXCLUDED_FILES = new Set(['README.md', 'install.sh']); + const EXCLUDED_FILES = new Set(['README.md']); function scanDirectory(dir, relativeBase) { if (!fs.existsSync(dir)) return;