fix: fix: create .profile repos for all existing bot agents via hire-an-agent (#234)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

This commit is contained in:
Agent 2026-04-05 16:26:10 +00:00
parent bbc8ec8031
commit 76e4fc409a

202
scripts/hire-profile-repos.sh Executable file
View file

@ -0,0 +1,202 @@
#!/usr/bin/env bash
# scripts/hire-profile-repos.sh
#
# Creates .profile repos for all existing bot agents via hire-an-agent.
#
# This script should be run from the disinto repo root:
# cd ~/disinto
# ./scripts/hire-profile-repos.sh
#
# Each command creates a .profile repo with:
# - formula.toml (agent's role formula)
# - journal/.gitkeep
# - knowledge/.gitkeep
#
# Prerequisites:
# - Forgejo instance running and accessible
# - FORGE_TOKEN and FORGE_URL set in .env
# - Bot users exist (created separately via disinto init or manually)
#
# Order of execution:
# 1. architect-bot (full hire — needs user + token + .profile)
# 2. dev-bot (hire --formula formulas/dev.toml)
# 3. review-bot (hire --formula formulas/review-pr.toml)
# 4. planner-bot (hire --formula formulas/run-planner.toml)
# 5. gardener-bot (hire --formula formulas/run-gardener.toml)
# 6. supervisor-bot (hire --formula formulas/run-supervisor.toml)
# 7. predictor-bot (hire --formula formulas/run-predictor.toml)
# 8. vault-bot (no formula — skip or use a placeholder)
# 9. dev-qwen (hire --formula formulas/dev.toml)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FACTORY_ROOT="$(dirname "$SCRIPT_DIR")"
DISINTO="${FACTORY_ROOT}/bin/disinto"
cd "$FACTORY_ROOT"
# Source env for FORGE_TOKEN, FORGE_URL
if [ -f "${FACTORY_ROOT}/.env" ]; then
source "${FACTORY_ROOT}/.env"
elif [ -f "${FACTORY_ROOT}/.env.enc" ]; then
# Try to decrypt if sops is available
if command -v sops >/dev/null 2>&1; then
sops -d "${FACTORY_ROOT}/.env.enc" > "${FACTORY_ROOT}/.env" 2>/dev/null || true
source "${FACTORY_ROOT}/.env"
fi
fi
# Validate prerequisites
if [ -z "${FORGE_TOKEN:-}" ]; then
echo "ERROR: FORGE_TOKEN not set" >&2
echo " Set it in .env or .env.enc" >&2
exit 1
fi
if [ -z "${FORGE_URL:-}" ]; then
echo "ERROR: FORGE_URL not set" >&2
echo " Set it in .env or .env.enc" >&2
exit 1
fi
echo "Forge URL: ${FORGE_URL}"
echo "Agent: $(whoami)"
echo ""
# Function to hire an agent with formula
hire_agent() {
local agent_name="$1"
local role="$2"
local formula_path="${FACTORY_ROOT}/formulas/${role}.toml"
# Try alternative naming convention
if [ ! -f "$formula_path" ]; then
formula_path="${FACTORY_ROOT}/formulas/run-${role}.toml"
fi
if [ ! -f "$formula_path" ]; then
echo "WARNING: formula not found for ${agent_name} (${role}), skipping" >&2
return 1
fi
echo "────────────────────────────────────────────────────────────────"
echo "Hiring: ${agent_name} (role: ${role})"
echo "Formula: ${formula_path}"
if "${DISINTO}" hire-an-agent "$agent_name" "$role" --formula "$formula_path"; then
echo "✓ Successfully hired ${agent_name}"
else
echo "✗ Failed to hire ${agent_name}"
return 1
fi
echo ""
}
# 1. architect-bot - full hire (needs user + token + .profile)
# This creates the user, generates a token, and sets up .profile
echo "══════════════════════════════════════════════════════════════"
echo "1. architect-bot (full hire — creates user, token, .profile)"
echo "══════════════════════════════════════════════════════════════"
echo ""
echo "This will:"
echo " - Create user 'architect-bot' on Forgejo"
echo " - Generate API token for architect-bot"
echo " - Create architect-bot/.profile repo"
echo " - Set up initial formula.toml"
echo ""
echo "IMPORTANT: After this runs, copy FORGE_ARCHITECT_TOKEN from output"
echo "and add it to your .env file:"
echo " FORGE_ARCHITECT_TOKEN=<token-from-above>"
echo ""
# Note: We use 'architect' as the role since the formula is run-architect.toml
# But the user will be 'architect-bot'
if "${DISINTO}" hire-an-agent architect-bot architect --formula "${FACTORY_ROOT}/formulas/run-architect.toml"; then
echo "✓ architect-bot hired successfully"
echo ""
echo "IMPORTANT: Add this token to your .env file:"
echo " FORGE_ARCHITECT_TOKEN=<token-shown-above>"
else
echo "✗ architect-bot hire failed - check Forgejo API access"
fi
# 2. dev-bot
echo "────────────────────────────────────────────────────────────────"
echo "2. dev-bot"
echo "────────────────────────────────────────────────────────────────"
hire_agent "dev-bot" "dev" || true
# 3. review-bot
echo "────────────────────────────────────────────────────────────────"
echo "3. review-bot"
echo "────────────────────────────────────────────────────────────────"
hire_agent "review-bot" "review" || true
# 4. planner-bot
echo "────────────────────────────────────────────────────────────────"
echo "4. planner-bot"
echo "────────────────────────────────────────────────────────────────"
hire_agent "planner-bot" "planner" || true
# 5. gardener-bot
echo "────────────────────────────────────────────────────────────────"
echo "5. gardener-bot"
echo "────────────────────────────────────────────────────────────────"
hire_agent "gardener-bot" "gardener" || true
# 6. supervisor-bot
echo "────────────────────────────────────────────────────────────────"
echo "6. supervisor-bot"
echo "────────────────────────────────────────────────────────────────"
hire_agent "supervisor-bot" "supervisor" || true
# 7. predictor-bot
echo "────────────────────────────────────────────────────────────────"
echo "7. predictor-bot"
echo "────────────────────────────────────────────────────────────────"
hire_agent "predictor-bot" "predictor" || true
# 8. vault-bot - no formula (vault is being redesigned)
# Skip for now - vault is being redesigned as PR-based workflow (#73-#77)
echo "────────────────────────────────────────────────────────────────"
echo "8. vault-bot"
echo "────────────────────────────────────────────────────────────────"
echo "SKIPPED: vault-bot - vault is being redesigned (PR-based workflow)"
echo "See issues #73-#77 for details."
echo ""
# 9. dev-qwen
echo "────────────────────────────────────────────────────────────────"
echo "9. dev-qwen"
echo "────────────────────────────────────────────────────────────────"
hire_agent "dev-qwen" "dev" || true
echo "══════════════════════════════════════════════════════════════"
echo "Summary"
echo "══════════════════════════════════════════════════════════════"
echo ""
echo "The following .profile repos should now exist on Forgejo:"
echo " - architect-bot/.profile (requires FORGE_ARCHITECT_TOKEN in .env)"
echo " - dev-bot/.profile"
echo " - review-bot/.profile"
echo " - planner-bot/.profile"
echo " - gardener-bot/.profile"
echo " - supervisor-bot/.profile"
echo " - predictor-bot/.profile"
echo " - dev-qwen/.profile"
echo ""
echo "vault-bot/.profile was skipped (vault redesign in progress)"
echo ""
echo "Each .profile repo contains:"
echo " - formula.toml (agent's role formula)"
echo " - journal/.gitkeep"
echo " - knowledge/.gitkeep"
echo ""
echo "Next steps:"
echo " 1. Verify repos exist: curl -u disinto-admin:\$FORGE_ADMIN_PASS \\"
echo " \"\${FORGE_URL}/api/v1/repos/architect-bot/.profile\""
echo " 2. Update .env with FORGE_ARCHITECT_TOKEN if not already set"
echo " 3. Agents will automatically clone .profile on next run"
echo " 4. Agents will write journals and load lessons learned"
echo ""