Files
ci/scripts/install.sh
Jon Chery e31afe3b59 docs(rebrand): rename & rebrand CI → CIAgent across all documentation, templates, and scripts
- README.md: title, project name, CLI commands, .ci/ → .ciagent/, ci-files → ciagent-files, CI Modification → CIAgent Modification
- AGENTS.md: title, project name, architecture tree, agent count (18→19), test count (25→31 suites, 218→370 tests), version (0.4.0→0.6.0), ci-files → ciagent-files, CIConfig → CIAgentConfig, CiMetadata → CIAgentMetadata, .ci/ → .ciagent/
- templates/DECISIONS.md: .ci/audit/ → .ciagent/audit/, ci audit → ciagent audit
- scripts/postinstall.js: CI postinstall → CIAgent postinstall
- scripts/install.sh: CI → CIAgent, ci-init → ciagent-init, INSTALL COMPLETE banner
- opencode/ci/workflows/*.md (11 files): .ci/ → .ciagent/, CI → CIAgent project name, ci-command → ciagent-command usage lines
- opencode/ci/references/*.md (5 files): .ci/ → .ciagent/, CI → CIAgent project name, ci-files → ciagent-files references
- opencode/ci/contexts/*.md (3 files): .ci/ → .ciagent/, CI → CIAgent project name
- opencode/agents/ci-*.md (18 files): .ci/ → .ciagent/, CI → CIAgent project name
- opencode/command/ci-*.md (11 files): CI → CIAgent project name

Preserved: ---ci---/---/ci--- markers, opencode/ci/ dir paths, ci-*.md filenames, ci listProjects()/ci setActiveProject() API names, repo URLs

---ci---
phase: 1
milestone: v0.6
plan: 01-01
task: 01-01-01
status: execute
---/ci---
2026-05-29 17:58:48 +00:00

157 lines
5.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
OPENCODE_DIR="${HOME}/.config/opencode"
CI_DIR="$(cd "$(dirname "$0")/.." && pwd)/opencode"
UNINSTALL=false
FORCE=false
for arg in "$@"; do
case "$arg" in
--uninstall) UNINSTALL=true ;;
--force) FORCE=true ;;
--help|-h)
echo "Usage: $(basename "$0") [--uninstall] [--force]"
echo ""
echo "Install CIAgent opencode integration files to ~/.config/opencode/"
echo ""
echo " --uninstall Remove CIAgent integration files"
echo " --force Overwrite existing files without prompting"
echo " --help Show this help"
exit 0
;;
esac
done
if [ "$UNINSTALL" = true ]; then
echo "Uninstalling CIAgent opencode integration..."
rm -f "${OPENCODE_DIR}/agents/ci-"*.md 2>/dev/null || true
rm -f "${OPENCODE_DIR}/command/ci-"*.md 2>/dev/null || true
rm -rf "${OPENCODE_DIR}/ci/" 2>/dev/null || true
echo "CIAgent integration files removed."
echo "Note: opencode.json permissions entry preserved (edit manually if needed)."
exit 0
fi
if [ ! -d "$CI_DIR" ]; then
echo "Error: opencode/ directory not found at ${CI_DIR}"
echo "Ensure you're running from the CIAgent repository root."
exit 1
fi
echo "Installing CIAgent opencode integration..."
echo " Source: ${CI_DIR}"
echo " Target: ${OPENCODE_DIR}"
echo ""
mkdir -p "${OPENCODE_DIR}/agents"
mkdir -p "${OPENCODE_DIR}/command"
mkdir -p "${OPENCODE_DIR}/ci/contexts"
mkdir -p "${OPENCODE_DIR}/ci/references"
mkdir -p "${OPENCODE_DIR}/ci/workflows"
COPIED=0
SKIPPED=0
copy_file() {
local src="$1"
local dest="$2"
if [ -f "$dest" ] && [ "$FORCE" = false ]; then
if cmp -s "$src" "$dest" 2>/dev/null; then
SKIPPED=$((SKIPPED + 1))
return
fi
echo " Conflict: $(basename "$src") already exists. Use --force to overwrite."
SKIPPED=$((SKIPPED + 1))
return
fi
sed "s|__OPENCODE_DIR__|${OPENCODE_DIR}|g" "$src" > "$dest"
COPIED=$((COPIED + 1))
}
echo "Installing agents..."
for f in "${CI_DIR}/agents/ci-"*.md; do
[ -f "$f" ] && copy_file "$f" "${OPENCODE_DIR}/agents/$(basename "$f")"
done
echo "Installing commands..."
for f in "${CI_DIR}/command/ci-"*.md; do
[ -f "$f" ] && copy_file "$f" "${OPENCODE_DIR}/command/$(basename "$f")"
done
echo "Installing contexts..."
for f in "${CI_DIR}/ci/contexts/"*.md; do
[ -f "$f" ] && copy_file "$f" "${OPENCODE_DIR}/ci/contexts/$(basename "$f")"
done
echo "Installing references..."
for f in "${CI_DIR}/ci/references/"*.md; do
[ -f "$f" ] && copy_file "$f" "${OPENCODE_DIR}/ci/references/$(basename "$f")"
done
echo "Installing workflows..."
for f in "${CI_DIR}/ci/workflows/"*.md; do
[ -f "$f" ] && copy_file "$f" "${OPENCODE_DIR}/ci/workflows/$(basename "$f")"
done
echo "Installing VERSION..."
[ -f "${CI_DIR}/ci/VERSION" ] && copy_file "${CI_DIR}/ci/VERSION" "${OPENCODE_DIR}/ci/VERSION"
echo ""
echo "Merging opencode.json permissions..."
OPENCODE_JSON="${OPENCODE_DIR}/opencode.json"
CI_JSON="${CI_DIR}/opencode.json"
if [ -f "$CI_JSON" ]; then
if [ ! -f "$OPENCODE_JSON" ]; then
sed "s|__OPENCODE_DIR__|${OPENCODE_DIR}|g" "$CI_JSON" > "$OPENCODE_JSON"
echo " Created opencode.json"
else
if command -v node &>/dev/null; then
local_ci_json="$(sed "s|__OPENCODE_DIR__|${OPENCODE_DIR}|g" "$CI_JSON")"
echo "$local_ci_json" > /tmp/ci-json-merge.json
node -e "
const fs = require('fs');
const existing = JSON.parse(fs.readFileSync('${OPENCODE_JSON}', 'utf8'));
const ci = JSON.parse(fs.readFileSync('/tmp/ci-json-merge.json', 'utf8'));
const merged = { ...existing };
merged.permission = merged.permission || {};
merged.permission.read = merged.permission.read || {};
merged.permission.external_directory = merged.permission.external_directory || {};
for (const [k, v] of Object.entries(ci.permission?.read || {})) {
if (!merged.permission.read[k]) merged.permission.read[k] = v;
}
for (const [k, v] of Object.entries(ci.permission?.external_directory || {})) {
if (!merged.permission.external_directory[k]) merged.permission.external_directory[k] = v;
}
fs.writeFileSync('${OPENCODE_JSON}', JSON.stringify(merged, null, 2));
console.log(' Merged permissions (preserved existing entries)');
"
rm -f /tmp/ci-json-merge.json
else
echo " Warning: node not found. Manually merge opencode.json permissions."
echo " Add to opencode.json:"
echo ' "~/.config/opencode/ci/*": "allow" (in permission.read and permission.external_directory)'
fi
fi
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " CIAgent ► INSTALL COMPLETE"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo " Copied: ${COPIED} files"
echo " Skipped: ${SKIPPED} files"
echo ""
echo " Commands available: ciagent-init, ciagent-run, ciagent-quick, ciagent-status,"
echo " ciagent-audit, ciagent-verify, ciagent-debug, ciagent-review, ciagent-ship,"
echo " ciagent-rollback, ciagent-clarify"
echo ""
echo " Run --uninstall to remove."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"