aidevops 2.172.18 → 2.172.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/aidevops.sh +1 -1
- package/package.json +2 -1
- package/scripts/npm-postinstall.cjs +13 -2
- package/setup-modules/agent-deploy.sh +627 -0
- package/setup-modules/config.sh +183 -0
- package/setup-modules/core.sh +572 -0
- package/setup-modules/mcp-setup.sh +766 -0
- package/setup-modules/migrations.sh +961 -0
- package/setup-modules/plugins.sh +588 -0
- package/setup-modules/shell-env.sh +892 -0
- package/setup-modules/tool-install.sh +1373 -0
- package/setup.sh +1 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Configuration functions: setup_configs, set_permissions, ssh, aidevops-cli, opencode-config, claude-config, validate, extract-prompts, drift-check
|
|
3
|
+
# Part of aidevops setup.sh modularization (t316.3)
|
|
4
|
+
|
|
5
|
+
# Shell safety baseline
|
|
6
|
+
set -Eeuo pipefail
|
|
7
|
+
IFS=$'\n\t'
|
|
8
|
+
# shellcheck disable=SC2154 # rc is assigned by $? in the trap string
|
|
9
|
+
trap 'rc=$?; echo "[ERROR] ${BASH_SOURCE[0]}:${LINENO} exit $rc" >&2' ERR
|
|
10
|
+
shopt -s inherit_errexit 2>/dev/null || true
|
|
11
|
+
|
|
12
|
+
setup_configs() {
|
|
13
|
+
print_info "Setting up configuration files..."
|
|
14
|
+
|
|
15
|
+
# Create configs directory if it doesn't exist
|
|
16
|
+
mkdir -p configs
|
|
17
|
+
|
|
18
|
+
# Copy template configs if they don't exist
|
|
19
|
+
for template in configs/*.txt; do
|
|
20
|
+
if [[ -f "$template" ]]; then
|
|
21
|
+
config_file="${template%.txt}"
|
|
22
|
+
if [[ ! -f "$config_file" ]]; then
|
|
23
|
+
cp "$template" "$config_file"
|
|
24
|
+
print_success "Created $(basename "$config_file")"
|
|
25
|
+
print_warning "Please edit $(basename "$config_file") with your actual credentials"
|
|
26
|
+
else
|
|
27
|
+
print_info "Found existing config: $(basename "$config_file") - Skipping"
|
|
28
|
+
fi
|
|
29
|
+
fi
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
return 0
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
install_aidevops_cli() {
|
|
36
|
+
print_info "Installing aidevops CLI command..."
|
|
37
|
+
|
|
38
|
+
local script_dir
|
|
39
|
+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
40
|
+
local cli_source="$script_dir/aidevops.sh"
|
|
41
|
+
local cli_target="/usr/local/bin/aidevops"
|
|
42
|
+
|
|
43
|
+
if [[ ! -f "$cli_source" ]]; then
|
|
44
|
+
print_warning "aidevops.sh not found - skipping CLI installation"
|
|
45
|
+
return 0
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Check if we can write to /usr/local/bin
|
|
49
|
+
if [[ -w "/usr/local/bin" ]]; then
|
|
50
|
+
# Direct symlink
|
|
51
|
+
ln -sf "$cli_source" "$cli_target"
|
|
52
|
+
print_success "Installed aidevops command to $cli_target"
|
|
53
|
+
elif [[ -w "$HOME/.local/bin" ]] || mkdir -p "$HOME/.local/bin" 2>/dev/null; then
|
|
54
|
+
# Use ~/.local/bin instead
|
|
55
|
+
cli_target="$HOME/.local/bin/aidevops"
|
|
56
|
+
ln -sf "$cli_source" "$cli_target"
|
|
57
|
+
print_success "Installed aidevops command to $cli_target"
|
|
58
|
+
|
|
59
|
+
# Check if ~/.local/bin is in PATH and add it if not
|
|
60
|
+
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
|
|
61
|
+
add_local_bin_to_path
|
|
62
|
+
fi
|
|
63
|
+
else
|
|
64
|
+
# Need sudo
|
|
65
|
+
print_info "Installing aidevops command requires sudo..."
|
|
66
|
+
if sudo ln -sf "$cli_source" "$cli_target"; then
|
|
67
|
+
print_success "Installed aidevops command to $cli_target"
|
|
68
|
+
else
|
|
69
|
+
print_warning "Could not install aidevops command globally"
|
|
70
|
+
print_info "You can run it directly: $cli_source"
|
|
71
|
+
fi
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
return 0
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# Helper: check for a generator script, run it, report result consistently
|
|
78
|
+
_run_generator() {
|
|
79
|
+
local script_path="$1"
|
|
80
|
+
local info_msg="$2"
|
|
81
|
+
local success_msg="$3"
|
|
82
|
+
local failure_msg="$4"
|
|
83
|
+
shift 4
|
|
84
|
+
local script_args=("$@")
|
|
85
|
+
|
|
86
|
+
if [[ ! -f "$script_path" ]]; then
|
|
87
|
+
print_warning "Generator script not found: $script_path"
|
|
88
|
+
return 0
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
print_info "$info_msg"
|
|
92
|
+
# Use ${arr[@]+"${arr[@]}"} pattern for safe expansion under set -u when array may be empty
|
|
93
|
+
if bash "$script_path" ${script_args[@]+"${script_args[@]}"}; then
|
|
94
|
+
print_success "$success_msg"
|
|
95
|
+
else
|
|
96
|
+
print_warning "$failure_msg"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
return 0
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
update_opencode_config() {
|
|
103
|
+
# Respect config (env var or config file)
|
|
104
|
+
if ! is_feature_enabled manage_opencode_config 2>/dev/null; then
|
|
105
|
+
print_info "OpenCode config management disabled via config (integrations.manage_opencode_config)"
|
|
106
|
+
return 0
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
print_info "Updating OpenCode configuration..."
|
|
110
|
+
|
|
111
|
+
# Generate OpenCode commands (independent of opencode.json — writes to ~/.config/opencode/command/)
|
|
112
|
+
# Run this first so /onboarding and other commands exist even if opencode.json hasn't been created yet
|
|
113
|
+
_run_generator ".agents/scripts/generate-opencode-commands.sh" \
|
|
114
|
+
"Generating OpenCode commands..." \
|
|
115
|
+
"OpenCode commands configured" \
|
|
116
|
+
"OpenCode command generation encountered issues"
|
|
117
|
+
|
|
118
|
+
# Generate OpenCode agent configuration (requires opencode.json)
|
|
119
|
+
# - Primary agents: Added to opencode.json (for Tab order & MCP control)
|
|
120
|
+
# - Subagents: Generated as markdown in ~/.config/opencode/agent/
|
|
121
|
+
local opencode_config
|
|
122
|
+
if ! opencode_config=$(find_opencode_config); then
|
|
123
|
+
print_info "OpenCode config (opencode.json) not found — agent configuration skipped (commands still generated)"
|
|
124
|
+
return 0
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
print_info "Found OpenCode config at: $opencode_config"
|
|
128
|
+
|
|
129
|
+
# Create backup (with rotation)
|
|
130
|
+
create_backup_with_rotation "$opencode_config" "opencode"
|
|
131
|
+
|
|
132
|
+
_run_generator ".agents/scripts/generate-opencode-agents.sh" \
|
|
133
|
+
"Generating OpenCode agent configuration..." \
|
|
134
|
+
"OpenCode agents configured (11 primary in JSON, subagents as markdown)" \
|
|
135
|
+
"OpenCode agent generation encountered issues"
|
|
136
|
+
|
|
137
|
+
# Regenerate subagent index for plugin startup (t1040)
|
|
138
|
+
_run_generator ".agents/scripts/subagent-index-helper.sh" \
|
|
139
|
+
"Regenerating subagent index..." \
|
|
140
|
+
"Subagent index regenerated" \
|
|
141
|
+
"Subagent index generation encountered issues" \
|
|
142
|
+
generate
|
|
143
|
+
|
|
144
|
+
return 0
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
update_claude_config() {
|
|
148
|
+
# Respect config (env var or config file)
|
|
149
|
+
if ! is_feature_enabled manage_claude_config 2>/dev/null; then
|
|
150
|
+
print_info "Claude config management disabled via config (integrations.manage_claude_config)"
|
|
151
|
+
return 0
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
# Guard: only run if claude binary exists (t1161)
|
|
155
|
+
if ! command -v claude &>/dev/null; then
|
|
156
|
+
print_info "Claude Code not found — skipping Claude config (install: https://claude.ai/download)"
|
|
157
|
+
return 0
|
|
158
|
+
fi
|
|
159
|
+
|
|
160
|
+
print_info "Updating Claude Code configuration..."
|
|
161
|
+
|
|
162
|
+
# Generate Claude Code commands (writes to ~/.claude/commands/)
|
|
163
|
+
_run_generator ".agents/scripts/generate-claude-commands.sh" \
|
|
164
|
+
"Generating Claude Code commands..." \
|
|
165
|
+
"Claude Code commands configured" \
|
|
166
|
+
"Claude Code command generation encountered issues"
|
|
167
|
+
|
|
168
|
+
# Generate Claude Code agent configuration (MCPs, settings.json, slash commands)
|
|
169
|
+
# Mirrors update_opencode_config() calling generate-opencode-agents.sh (t1161.4)
|
|
170
|
+
_run_generator ".agents/scripts/generate-claude-agents.sh" \
|
|
171
|
+
"Generating Claude Code agent configuration..." \
|
|
172
|
+
"Claude Code agents configured (MCPs, settings, commands)" \
|
|
173
|
+
"Claude Code agent generation encountered issues"
|
|
174
|
+
|
|
175
|
+
# Regenerate subagent index (shared between OpenCode and Claude Code)
|
|
176
|
+
_run_generator ".agents/scripts/subagent-index-helper.sh" \
|
|
177
|
+
"Regenerating subagent index..." \
|
|
178
|
+
"Subagent index regenerated" \
|
|
179
|
+
"Subagent index generation encountered issues" \
|
|
180
|
+
generate
|
|
181
|
+
|
|
182
|
+
return 0
|
|
183
|
+
}
|