diff --git a/setup.sh b/setup.sh index 0ace3ff36..1ef39aeca 100755 --- a/setup.sh +++ b/setup.sh @@ -2700,6 +2700,26 @@ inject_agents_reference() { print_success "Updated $updated_count AI assistant configuration(s)" fi + # Deploy OpenCode config-level AGENTS.md from managed template + # This controls the session greeting (auto-loaded by OpenCode from config root) + local opencode_config_dir="$HOME/.config/opencode" + local opencode_config_agents="$opencode_config_dir/AGENTS.md" + local template_source="$INSTALL_DIR/templates/opencode-config-agents.md" + + if [[ -d "$opencode_config_dir" && -f "$template_source" ]]; then + # Backup if file exists and differs from template + if [[ -f "$opencode_config_agents" ]]; then + if ! diff -q "$template_source" "$opencode_config_agents" &>/dev/null; then + create_backup_with_rotation "$opencode_config_agents" "opencode-agents" + fi + fi + if cp "$template_source" "$opencode_config_agents"; then + print_success "Deployed greeting template to $opencode_config_agents" + else + print_error "Failed to deploy greeting template to $opencode_config_agents" + fi + fi + return 0 } diff --git a/templates/opencode-config-agents.md b/templates/opencode-config-agents.md index d0682d671..03ac01b5d 100644 --- a/templates/opencode-config-agents.md +++ b/templates/opencode-config-agents.md @@ -5,7 +5,7 @@ Add ~/.aidevops/agents/AGENTS.md to context for AI DevOps capabilities. **On conversation start**: 1. If you have Bash tool: Run `bash ~/.aidevops/agents/scripts/aidevops-update-check.sh` 2. If no Bash tool: Read `~/.aidevops/cache/session-greeting.txt` (cached by agents with Bash) -3. Relay ALL lines from the output in your greeting. The first line is the version string, subsequent lines are runtime context. Format: "Hi!\n\nWe're running https://aidevops.sh v{version}. {runtime context}\n\nWhat would you like to work on?" +3. Parse the first line of output (format: `aidevops v{version} running in {app} v{app_version} | {repo}`). Greet with: "Hi!\n\nWe're running https://aidevops.sh v{version} in {app} v{app_version}.\n\nWhat would you like to work on?" 4. Then respond to the user's actual message If update check output starts with `UPDATE_AVAILABLE|` (e.g., `UPDATE_AVAILABLE|current|latest|AppName`), inform user: "Update available (current → latest). Run `aidevops update` to update."