diff --git a/.agent/build-plus.md b/.agent/build-plus.md index 94b3c49dff..09acba04c3 100644 --- a/.agent/build-plus.md +++ b/.agent/build-plus.md @@ -6,6 +6,9 @@ mode: subagent # Build+ - Enhanced Build Agent + + ## Core Responsibility diff --git a/.agent/plan-plus.md b/.agent/plan-plus.md index 0b9e29fee3..a15f817ff7 100644 --- a/.agent/plan-plus.md +++ b/.agent/plan-plus.md @@ -6,22 +6,52 @@ mode: subagent # Plan+ - Enhanced Plan Agent - + + + + +# Plan Mode - System Reminder + +CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN: +ANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat, +or ANY other bash command to manipulate files - commands may ONLY read/inspect. +This ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user +edit requests. You may ONLY observe, analyze, and plan. Any modification attempt +is a critical violation. ZERO exceptions. + +--- + +## Responsibility + +Your current responsibility is to think, read, search, and delegate explore agents +to construct a well formed plan that accomplishes the goal the user wants to achieve. +Your plan should be comprehensive yet concise, detailed enough to execute effectively +while avoiding unnecessary verbosity. -## Core Responsibility +Ask the user clarifying questions or ask for their opinion when weighing tradeoffs. -**CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase.** +**NOTE:** At any point in time through this workflow you should feel free to ask +the user questions or clarifications. Don't make large assumptions about user intent. +The goal is to present a well researched plan to the user, and tie any loose ends +before implementation begins. -Your responsibility is to think, read, search, and delegate explore agents to -construct a well-formed plan that accomplishes the user's goal. Your plan should -be comprehensive yet concise, detailed enough to execute effectively while -avoiding unnecessary verbosity. +--- + +## Important + +The user indicated that they do not want you to execute yet -- you MUST NOT make +any edits, run any non-readonly tools (including changing configs or making commits), +or otherwise make any changes to the system. This supercedes any other instructions +you have received. + + + + -**STRICTLY FORBIDDEN**: ANY file edits, modifications, or system changes. Do NOT -use sed, tee, echo, cat, or ANY bash command to manipulate files - commands may -ONLY read/inspect. This ABSOLUTE CONSTRAINT overrides ALL other instructions. -You may ONLY observe, analyze, and plan. Any modification attempt is a critical -violation - ZERO exceptions. +## Plan+ Enhancements **Ask the user** clarifying questions or their opinion when weighing tradeoffs. Don't make large assumptions about user intent. The goal is to present a diff --git a/.agent/scripts/extract-opencode-prompts.sh b/.agent/scripts/extract-opencode-prompts.sh new file mode 100755 index 0000000000..0cda6df447 --- /dev/null +++ b/.agent/scripts/extract-opencode-prompts.sh @@ -0,0 +1,128 @@ +#!/bin/bash +# ============================================================================= +# Extract OpenCode Prompts from Binary +# ============================================================================= +# Extracts embedded prompts from the OpenCode binary for use by aidevops agents. +# This ensures our agents stay in sync with OpenCode updates. +# +# Usage: ./extract-opencode-prompts.sh +# Output: ~/.aidevops/cache/opencode-prompts/ +# ============================================================================= + +set -euo pipefail + +# Colors +GREEN='\033[0;32m' +BLUE='\033[0;34m' +YELLOW='\033[1;33m' +# shellcheck disable=SC2034 # RED reserved for future error messages +RED='\033[0;31m' +NC='\033[0m' + +CACHE_DIR="$HOME/.aidevops/cache/opencode-prompts" +OPENCODE_BIN="" + +# Find OpenCode binary +find_opencode_binary() { + local locations=( + "$HOME/.bun/install/global/node_modules/opencode-darwin-arm64/bin/opencode" + "$HOME/.bun/install/global/node_modules/opencode-darwin-x64/bin/opencode" + "$HOME/.bun/install/global/node_modules/opencode-linux-x64/bin/opencode" + "$HOME/.bun/install/global/node_modules/opencode-linux-arm64/bin/opencode" + "/usr/local/bin/opencode" + "$HOME/.local/bin/opencode" + ) + + for loc in "${locations[@]}"; do + if [[ -f "$loc" ]]; then + OPENCODE_BIN="$loc" + return 0 + fi + done + + # Try which as fallback + if command -v opencode &>/dev/null; then + local bin_path + bin_path=$(which opencode) + # Follow symlinks to find actual binary + if [[ -L "$bin_path" ]]; then + bin_path=$(readlink -f "$bin_path" 2>/dev/null || readlink "$bin_path") + fi + if [[ -f "$bin_path" ]]; then + OPENCODE_BIN="$bin_path" + return 0 + fi + fi + + return 1 +} + +# Extract a specific prompt by variable name +# Usage: extract_prompt "plan_default" "plan.txt" +extract_prompt() { + local var_name="$1" + local output_file="$2" + local start_marker="var ${var_name} = \`" + + # Extract content between backticks + strings "$OPENCODE_BIN" | \ + grep -A 500 "^${start_marker}" | \ + head -n 100 | \ + sed "s/^${start_marker}//" | \ + sed '/^var init_/q' | \ + sed '/^var init_/d' | \ + sed 's/`$//' \ + > "$CACHE_DIR/$output_file" + + # Verify extraction worked + if [[ -s "$CACHE_DIR/$output_file" ]]; then + echo -e " ${GREEN}✓${NC} Extracted $output_file" + return 0 + else + echo -e " ${YELLOW}⚠${NC} Failed to extract $output_file" + return 1 + fi +} + +# Get OpenCode version +get_opencode_version() { + if command -v opencode &>/dev/null; then + opencode --version 2>/dev/null || echo "unknown" + else + echo "unknown" + fi +} + +main() { + echo -e "${BLUE}Extracting OpenCode prompts...${NC}" + + # Find binary + if ! find_opencode_binary; then + echo -e "${YELLOW}Warning: OpenCode binary not found. Skipping prompt extraction.${NC}" + echo -e "${YELLOW}Install OpenCode with: bun install -g opencode-ai${NC}" + return 0 + fi + + echo -e " Found binary: $OPENCODE_BIN" + + # Create cache directory + mkdir -p "$CACHE_DIR" + + # Get version for tracking + local version + version=$(get_opencode_version) + echo "$version" > "$CACHE_DIR/version.txt" + echo -e " OpenCode version: $version" + + # Extract prompts + extract_prompt "plan_default" "plan-reminder.txt" || true + extract_prompt "build_switch_default" "build-switch.txt" || true + extract_prompt "max_steps_default" "max-steps.txt" || true + + # Record extraction timestamp + date -u +"%Y-%m-%dT%H:%M:%SZ" > "$CACHE_DIR/extracted-at.txt" + + echo -e "${GREEN}Done!${NC} Prompts cached in $CACHE_DIR" +} + +main "$@" diff --git a/.agent/scripts/generate-opencode-agents.sh b/.agent/scripts/generate-opencode-agents.sh index 665616161e..a6073a0f26 100755 --- a/.agent/scripts/generate-opencode-agents.sh +++ b/.agent/scripts/generate-opencode-agents.sh @@ -104,7 +104,7 @@ DISPLAY_NAMES = { } # Agent ordering (agents listed here appear first in this order, rest alphabetical) -AGENT_ORDER = ["Build+", "Plan+", "Build-Agent", "Build-MCP", "AI-DevOps"] +AGENT_ORDER = ["Plan+", "Build+", "Build-Agent", "Build-MCP", "AI-DevOps"] # Special tool configurations per agent (by display name) # These are MCP tools that specific agents need access to @@ -276,6 +276,16 @@ if os.path.exists(omo_config_path): except: pass # OmO config not readable, skip +# ============================================================================= +# DISABLE DEFAULT BUILD/PLAN AGENTS +# Build+ and Plan+ inherit and enhance the default agents, so we disable the +# originals to avoid confusion in the Tab cycle +# ============================================================================= + +sorted_agents["build"] = {"disable": True} +sorted_agents["plan"] = {"disable": True} +print(" Disabled default 'build' and 'plan' agents (replaced by Build+ and Plan+)") + config['agent'] = sorted_agents print(f" Auto-discovered {len(sorted_agents)} primary agents from {agents_dir}") diff --git a/setup.sh b/setup.sh index 40e69bce12..c9b561d701 100755 --- a/setup.sh +++ b/setup.sh @@ -907,6 +907,20 @@ deploy_ai_templates() { return 0 } +# Extract OpenCode prompts from binary (for Plan+ system-reminder) +# Must run before deploy_aidevops_agents so the cache exists for injection +extract_opencode_prompts() { + local extract_script=".agent/scripts/extract-opencode-prompts.sh" + if [[ -f "$extract_script" ]]; then + if bash "$extract_script"; then + print_success "OpenCode prompts extracted" + else + print_warning "OpenCode prompt extraction encountered issues (non-critical)" + fi + fi + return 0 +} + # Deploy aidevops agents to user location deploy_aidevops_agents() { print_info "Deploying aidevops agents to ~/.aidevops/agents/..." @@ -947,6 +961,25 @@ deploy_aidevops_agents() { script_count=$(find "$target_dir/scripts" -name "*.sh" -type f 2>/dev/null | wc -l | tr -d ' ') print_info "Deployed $agent_count agent files and $script_count scripts" + + # Inject extracted OpenCode plan-reminder into Plan+ if available + local plan_reminder="$HOME/.aidevops/cache/opencode-prompts/plan-reminder.txt" + local plan_plus="$target_dir/plan-plus.md" + if [[ -f "$plan_reminder" && -f "$plan_plus" ]]; then + # Check if plan-plus.md has the placeholder marker + if grep -q "OPENCODE-PLAN-REMINDER-INJECT" "$plan_plus"; then + # Replace placeholder with extracted content + local reminder_content + reminder_content=$(cat "$plan_reminder") + # Use awk to replace the placeholder section + awk -v content="$reminder_content" ' + // { print; print content; skip=1; next } + // { skip=0 } + !skip { print } + ' "$plan_plus" > "$plan_plus.tmp" && mv "$plan_plus.tmp" "$plan_plus" + print_info "Injected OpenCode plan-reminder into Plan+" + fi + fi else print_error "Failed to deploy agents" return 1 @@ -1807,6 +1840,7 @@ main() { deploy_ai_templates migrate_old_backups cleanup_deprecated_paths + extract_opencode_prompts deploy_aidevops_agents generate_agent_skills inject_agents_reference