-
Notifications
You must be signed in to change notification settings - Fork 11
t316.3: Extract setup modules — modularize setup.sh into focused modules #1253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a1684dc
feat: extract core.sh module (requirements, permissions, location) (t…
marcusquinn a342a16
feat: extract shell-env.sh module (oh-my-zsh, shell-compat, aliases, …
marcusquinn 84bcf8c
feat: extract migrations.sh module (all migrate_* and cleanup_* funct…
marcusquinn af87a04
feat: extract tool-install.sh module (git-clis, fd, ripgrep, shellche…
marcusquinn ed598ee
feat: extract mcp-setup.sh module (install_mcp_packages, resolve_mcp_…
marcusquinn e75732a
feat: extract agent-deploy.sh module (deploy_aidevops_agents, deploy_…
marcusquinn dbfa0b4
feat: extract config.sh module (setup_configs, set_permissions, ssh, …
marcusquinn e994d23
feat: extract plugins.sh module (deploy_plugins, sanitize_plugin_name…
marcusquinn 7b5881b
feat: modularize setup.sh - source all extracted modules (t316.3)
marcusquinn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| #!/usr/bin/env bash | ||
| # Configuration functions: setup_configs, set_permissions, ssh, aidevops-cli, opencode-config, validate, extract-prompts, drift-check | ||
| # Part of aidevops setup.sh modularization (t316.3) | ||
|
|
||
| setup_configs() { | ||
| print_info "Setting up configuration files..." | ||
|
|
||
| # Create configs directory if it doesn't exist | ||
| mkdir -p configs | ||
|
|
||
| # Copy template configs if they don't exist | ||
| for template in configs/*.txt; do | ||
| if [[ -f "$template" ]]; then | ||
| config_file="${template%.txt}" | ||
| if [[ ! -f "$config_file" ]]; then | ||
| cp "$template" "$config_file" | ||
| print_success "Created $(basename "$config_file")" | ||
| print_warning "Please edit $(basename "$config_file") with your actual credentials" | ||
| else | ||
| print_info "Found existing config: $(basename "$config_file") - Skipping" | ||
| fi | ||
| fi | ||
| done | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| install_aidevops_cli() { | ||
| print_info "Installing aidevops CLI command..." | ||
|
|
||
| local script_dir | ||
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| local cli_source="$script_dir/aidevops.sh" | ||
| local cli_target="/usr/local/bin/aidevops" | ||
|
|
||
| if [[ ! -f "$cli_source" ]]; then | ||
| print_warning "aidevops.sh not found - skipping CLI installation" | ||
| return 0 | ||
| fi | ||
|
|
||
| # Check if we can write to /usr/local/bin | ||
| if [[ -w "/usr/local/bin" ]]; then | ||
| # Direct symlink | ||
| ln -sf "$cli_source" "$cli_target" | ||
| print_success "Installed aidevops command to $cli_target" | ||
| elif [[ -w "$HOME/.local/bin" ]] || mkdir -p "$HOME/.local/bin" 2>/dev/null; then | ||
| # Use ~/.local/bin instead | ||
| cli_target="$HOME/.local/bin/aidevops" | ||
| ln -sf "$cli_source" "$cli_target" | ||
| print_success "Installed aidevops command to $cli_target" | ||
|
|
||
| # Check if ~/.local/bin is in PATH and add it if not | ||
| if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then | ||
| add_local_bin_to_path | ||
| fi | ||
| else | ||
| # Need sudo | ||
| print_info "Installing aidevops command requires sudo..." | ||
| if sudo ln -sf "$cli_source" "$cli_target"; then | ||
| print_success "Installed aidevops command to $cli_target" | ||
| else | ||
| print_warning "Could not install aidevops command globally" | ||
| print_info "You can run it directly: $cli_source" | ||
| fi | ||
| fi | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| update_opencode_config() { | ||
| print_info "Updating OpenCode configuration..." | ||
|
|
||
| # Generate OpenCode commands (independent of opencode.json — writes to ~/.config/opencode/command/) | ||
| # Run this first so /onboarding and other commands exist even if opencode.json hasn't been created yet | ||
| local commands_script=".agents/scripts/generate-opencode-commands.sh" | ||
| if [[ -f "$commands_script" ]]; then | ||
| print_info "Generating OpenCode commands..." | ||
| if bash "$commands_script"; then | ||
| print_success "OpenCode commands configured" | ||
| else | ||
| print_warning "OpenCode command generation encountered issues" | ||
| fi | ||
| else | ||
| print_warning "OpenCode command generator not found at $commands_script" | ||
| fi | ||
|
|
||
| # Generate OpenCode agent configuration (requires opencode.json) | ||
| # - Primary agents: Added to opencode.json (for Tab order & MCP control) | ||
| # - Subagents: Generated as markdown in ~/.config/opencode/agent/ | ||
| local opencode_config | ||
| if ! opencode_config=$(find_opencode_config); then | ||
| print_info "OpenCode config (opencode.json) not found — agent configuration skipped (commands still generated)" | ||
| return 0 | ||
| fi | ||
|
|
||
| print_info "Found OpenCode config at: $opencode_config" | ||
|
|
||
| # Create backup (with rotation) | ||
| create_backup_with_rotation "$opencode_config" "opencode" | ||
|
|
||
| local generator_script=".agents/scripts/generate-opencode-agents.sh" | ||
| if [[ -f "$generator_script" ]]; then | ||
| print_info "Generating OpenCode agent configuration..." | ||
| if bash "$generator_script"; then | ||
| print_success "OpenCode agents configured (11 primary in JSON, subagents as markdown)" | ||
| else | ||
| print_warning "OpenCode agent generation encountered issues" | ||
| fi | ||
| else | ||
| print_warning "OpenCode agent generator not found at $generator_script" | ||
| fi | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script is missing
set -euo pipefailright after the shebang. This is required by the repository's shell script style guide (line 10) and is crucial for robust error handling and script safety.References
set -euo pipefailto ensure robust error handling. (link)