2026-03-12 12:44:15 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# env.sh — Load environment and shared utilities
|
|
|
|
|
# Source this at the top of every script: source "$(dirname "$0")/lib/env.sh"
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
# Resolve script root (parent of lib/)
|
|
|
|
|
FACTORY_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
|
|
2026-03-24 18:53:55 +00:00
|
|
|
# Container detection: when running inside the agent container, DISINTO_CONTAINER
|
|
|
|
|
# is set by docker-compose.yml. Adjust paths so phase files, logs, and thread
|
|
|
|
|
# maps land on the persistent volume instead of /tmp (which is ephemeral).
|
|
|
|
|
if [ "${DISINTO_CONTAINER:-}" = "1" ]; then
|
|
|
|
|
DISINTO_DATA_DIR="${HOME}/data"
|
2026-03-27 14:29:22 +00:00
|
|
|
DISINTO_LOG_DIR="${DISINTO_DATA_DIR}/logs"
|
|
|
|
|
mkdir -p "${DISINTO_DATA_DIR}" "${DISINTO_LOG_DIR}"/{dev,action,review,supervisor,vault,site,metrics}
|
|
|
|
|
else
|
|
|
|
|
DISINTO_LOG_DIR="${FACTORY_ROOT}"
|
2026-03-24 18:53:55 +00:00
|
|
|
fi
|
2026-03-27 14:29:22 +00:00
|
|
|
export DISINTO_LOG_DIR
|
2026-03-24 18:53:55 +00:00
|
|
|
|
2026-03-25 07:10:55 +00:00
|
|
|
# Load secrets: prefer .env.enc (SOPS-encrypted), fall back to plaintext .env.
|
2026-03-28 13:43:17 +00:00
|
|
|
# Always source .env — cron jobs inside the container do NOT inherit compose
|
|
|
|
|
# env vars (FORGE_TOKEN, etc.). Compose-injected vars (like FORGE_URL) are
|
|
|
|
|
# already set and won't be clobbered since env.sh uses ${VAR:-default} patterns
|
|
|
|
|
# for derived values. FORGE_URL from .env (localhost:3000) is overridden below
|
|
|
|
|
# by the compose-injected value when running via docker exec.
|
|
|
|
|
if [ -f "$FACTORY_ROOT/.env.enc" ] && command -v sops &>/dev/null; then
|
|
|
|
|
set -a
|
2026-03-28 13:59:07 +00:00
|
|
|
_saved_forge_url="${FORGE_URL:-}"
|
2026-03-29 07:56:38 +00:00
|
|
|
_saved_forge_token="${FORGE_TOKEN:-}"
|
2026-03-28 13:43:17 +00:00
|
|
|
eval "$(sops -d --output-type dotenv "$FACTORY_ROOT/.env.enc" 2>/dev/null)" \
|
|
|
|
|
|| echo "Warning: failed to decrypt .env.enc — secrets not loaded" >&2
|
|
|
|
|
set +a
|
2026-03-28 13:58:46 +00:00
|
|
|
[ -n "$_saved_forge_url" ] && export FORGE_URL="$_saved_forge_url"
|
2026-03-29 07:56:38 +00:00
|
|
|
[ -n "$_saved_forge_token" ] && export FORGE_TOKEN="$_saved_forge_token"
|
2026-03-28 13:43:17 +00:00
|
|
|
elif [ -f "$FACTORY_ROOT/.env" ]; then
|
2026-03-28 13:58:46 +00:00
|
|
|
# Preserve compose-injected FORGE_URL (localhost in .env != forgejo in Docker)
|
2026-03-28 13:59:07 +00:00
|
|
|
_saved_forge_url="${FORGE_URL:-}"
|
2026-03-29 07:56:38 +00:00
|
|
|
_saved_forge_token="${FORGE_TOKEN:-}"
|
2026-03-28 13:43:17 +00:00
|
|
|
set -a
|
|
|
|
|
# shellcheck source=/dev/null
|
|
|
|
|
source "$FACTORY_ROOT/.env"
|
|
|
|
|
set +a
|
2026-03-28 13:58:46 +00:00
|
|
|
[ -n "$_saved_forge_url" ] && export FORGE_URL="$_saved_forge_url"
|
2026-03-29 07:56:38 +00:00
|
|
|
[ -n "$_saved_forge_token" ] && export FORGE_TOKEN="$_saved_forge_token"
|
2026-03-12 12:44:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# PATH: foundry, node, system
|
2026-03-14 17:18:15 +01:00
|
|
|
export PATH="${HOME}/.local/bin:${HOME}/.foundry/bin:${HOME}/.nvm/versions/node/v22.20.0/bin:/usr/local/bin:/usr/bin:/bin:${PATH}"
|
2026-03-12 12:44:15 +00:00
|
|
|
export HOME="${HOME:-/home/debian}"
|
|
|
|
|
|
refactor: split supervisor into infra + per-project, make poll scripts config-driven
Supervisor split (#26):
- Layer 1 (infra): P0 memory, P1 disk, P4 housekeeping — runs once, project-agnostic
- Layer 2 (per-project): P2 CI/dev-agent, P3 PRs/deps — iterates projects/*.toml
- Adding a new project requires only a new TOML file, no code changes
Poll scripts accept project TOML arg (#27):
- dev-poll.sh, review-poll.sh, gardener-poll.sh accept optional project TOML as $1
- env.sh loads PROJECT_TOML if set, overriding .env defaults
- Cron: `dev-poll.sh projects/versi.toml` targets that project
New files:
- lib/load-project.sh: TOML to env var loader (Python tomllib)
- projects/versi.toml: current project config extracted from .env
Backwards compatible: scripts without a TOML arg fall back to .env config.
Closes #26, Closes #27
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 08:57:18 +01:00
|
|
|
# Load project TOML if PROJECT_TOML is set (by poll scripts that accept project arg)
|
|
|
|
|
if [ -n "${PROJECT_TOML:-}" ] && [ -f "$PROJECT_TOML" ]; then
|
|
|
|
|
source "${FACTORY_ROOT}/lib/load-project.sh" "$PROJECT_TOML"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-23 18:58:33 +00:00
|
|
|
# Forge token: new FORGE_TOKEN > legacy CODEBERG_TOKEN
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
if [ -z "${FORGE_TOKEN:-}" ]; then
|
|
|
|
|
FORGE_TOKEN="${CODEBERG_TOKEN:-}"
|
2026-03-12 12:44:15 +00:00
|
|
|
fi
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
export FORGE_TOKEN
|
|
|
|
|
export CODEBERG_TOKEN="${FORGE_TOKEN}" # backwards compat
|
|
|
|
|
|
|
|
|
|
# Review bot token: FORGE_REVIEW_TOKEN > legacy REVIEW_BOT_TOKEN
|
|
|
|
|
export FORGE_REVIEW_TOKEN="${FORGE_REVIEW_TOKEN:-${REVIEW_BOT_TOKEN:-}}"
|
|
|
|
|
export REVIEW_BOT_TOKEN="${FORGE_REVIEW_TOKEN}" # backwards compat
|
|
|
|
|
|
fix: Per-agent Forgejo accounts — identity and permissions via authorship (#747)
Each agent now gets its own Forgejo account (dev-bot, review-bot,
planner-bot, gardener-bot, vault-bot, supervisor-bot, predictor-bot,
action-bot) with a dedicated API token. This enables:
- Audit trail: every forge action attributable to a specific agent
- Permission boundaries: agents act under their own identity
- Vault authorization model: vault-bot comments = proof of approval
Changes:
- bin/disinto: setup_forge() creates all 8 bot accounts during init,
stores per-agent tokens (FORGE_*_TOKEN) in .env, adds all bots as
repo collaborators
- lib/env.sh: exports per-agent token vars with fallback to FORGE_TOKEN
for backwards compat; sets FORGE_BOT_USERNAMES default to all 8 bots
- Agent scripts: each agent overrides FORGE_TOKEN with its per-agent
token after sourcing env.sh (gardener, planner, supervisor, predictor,
vault, action)
- .env.example: documents all per-agent token fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:16:13 +00:00
|
|
|
# Per-agent tokens (#747): each agent gets its own Forgejo identity.
|
|
|
|
|
# Falls back to FORGE_TOKEN for backwards compat with single-token setups.
|
|
|
|
|
export FORGE_PLANNER_TOKEN="${FORGE_PLANNER_TOKEN:-${FORGE_TOKEN}}"
|
|
|
|
|
export FORGE_GARDENER_TOKEN="${FORGE_GARDENER_TOKEN:-${FORGE_TOKEN}}"
|
|
|
|
|
export FORGE_VAULT_TOKEN="${FORGE_VAULT_TOKEN:-${FORGE_TOKEN}}"
|
|
|
|
|
export FORGE_SUPERVISOR_TOKEN="${FORGE_SUPERVISOR_TOKEN:-${FORGE_TOKEN}}"
|
|
|
|
|
export FORGE_PREDICTOR_TOKEN="${FORGE_PREDICTOR_TOKEN:-${FORGE_TOKEN}}"
|
|
|
|
|
export FORGE_ACTION_TOKEN="${FORGE_ACTION_TOKEN:-${FORGE_TOKEN}}"
|
|
|
|
|
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
# Bot usernames filter: FORGE_BOT_USERNAMES > legacy CODEBERG_BOT_USERNAMES
|
fix: Per-agent Forgejo accounts — identity and permissions via authorship (#747)
Each agent now gets its own Forgejo account (dev-bot, review-bot,
planner-bot, gardener-bot, vault-bot, supervisor-bot, predictor-bot,
action-bot) with a dedicated API token. This enables:
- Audit trail: every forge action attributable to a specific agent
- Permission boundaries: agents act under their own identity
- Vault authorization model: vault-bot comments = proof of approval
Changes:
- bin/disinto: setup_forge() creates all 8 bot accounts during init,
stores per-agent tokens (FORGE_*_TOKEN) in .env, adds all bots as
repo collaborators
- lib/env.sh: exports per-agent token vars with fallback to FORGE_TOKEN
for backwards compat; sets FORGE_BOT_USERNAMES default to all 8 bots
- Agent scripts: each agent overrides FORGE_TOKEN with its per-agent
token after sourcing env.sh (gardener, planner, supervisor, predictor,
vault, action)
- .env.example: documents all per-agent token fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:16:13 +00:00
|
|
|
export FORGE_BOT_USERNAMES="${FORGE_BOT_USERNAMES:-${CODEBERG_BOT_USERNAMES:-dev-bot,review-bot,planner-bot,gardener-bot,vault-bot,supervisor-bot,predictor-bot,action-bot}}"
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
export CODEBERG_BOT_USERNAMES="${FORGE_BOT_USERNAMES}" # backwards compat
|
2026-03-12 12:44:15 +00:00
|
|
|
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
# Project config (FORGE_* preferred, CODEBERG_* fallback)
|
|
|
|
|
export FORGE_REPO="${FORGE_REPO:-${CODEBERG_REPO:-}}"
|
|
|
|
|
export CODEBERG_REPO="${FORGE_REPO}" # backwards compat
|
|
|
|
|
export FORGE_URL="${FORGE_URL:-http://localhost:3000}"
|
|
|
|
|
export FORGE_API="${FORGE_API:-${FORGE_URL}/api/v1/repos/${FORGE_REPO}}"
|
|
|
|
|
export FORGE_WEB="${FORGE_WEB:-${FORGE_URL}/${FORGE_REPO}}"
|
|
|
|
|
export CODEBERG_API="${FORGE_API}" # backwards compat
|
|
|
|
|
export CODEBERG_WEB="${FORGE_WEB}" # backwards compat
|
2026-03-25 12:20:15 +00:00
|
|
|
# tea CLI login name: derived from FORGE_URL (codeberg vs local forgejo)
|
|
|
|
|
if [ -z "${TEA_LOGIN:-}" ]; then
|
|
|
|
|
case "${FORGE_URL}" in
|
|
|
|
|
*codeberg.org*) TEA_LOGIN="codeberg" ;;
|
|
|
|
|
*) TEA_LOGIN="forgejo" ;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
export TEA_LOGIN
|
|
|
|
|
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
export PROJECT_NAME="${PROJECT_NAME:-${FORGE_REPO##*/}}"
|
2026-03-20 15:01:28 +00:00
|
|
|
export PROJECT_REPO_ROOT="${PROJECT_REPO_ROOT:-/home/${USER}/${PROJECT_NAME}}"
|
2026-03-14 13:49:09 +01:00
|
|
|
export PRIMARY_BRANCH="${PRIMARY_BRANCH:-master}"
|
fix: {project}-ops repo — separate operations from code (#757) (#767)
Fixes #757
## Changes
Separate operations from code into {project}-ops repo pattern. Added OPS_REPO_ROOT infrastructure (env.sh, load-project.sh, formula-session.sh with ensure_ops_repo helper). Updated all 8 agent scripts and 7 formulas to read/write vault items, journals, evidence, prerequisites, RESOURCES.md, and knowledge from the ops repo. Added setup_ops_repo() to disinto init for automatic ops repo creation and seeding. Removed migrated data from code repo (vault data dirs, planner journal/memory/prerequisites, supervisor journal/best-practices, evidence, RESOURCES.md). Updated all documentation. 55 files changed, ShellCheck clean, all 38 phase tests pass.
Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/disinto/pulls/767
Reviewed-by: Disinto_bot <disinto_bot@noreply.codeberg.org>
2026-03-26 19:55:12 +01:00
|
|
|
|
|
|
|
|
# Ops repo: operational data (vault items, journals, evidence, prerequisites).
|
|
|
|
|
# Default convention: sibling directory named {project}-ops.
|
|
|
|
|
export OPS_REPO_ROOT="${OPS_REPO_ROOT:-/home/${USER}/${PROJECT_NAME}-ops}"
|
|
|
|
|
|
|
|
|
|
# Forge repo slug for the ops repo (used by agents that commit to ops).
|
|
|
|
|
export FORGE_OPS_REPO="${FORGE_OPS_REPO:-${FORGE_REPO:+${FORGE_REPO}-ops}}"
|
2026-03-20 15:01:28 +00:00
|
|
|
export WOODPECKER_REPO_ID="${WOODPECKER_REPO_ID:-}"
|
2026-03-12 12:44:15 +00:00
|
|
|
export WOODPECKER_SERVER="${WOODPECKER_SERVER:-http://localhost:8000}"
|
|
|
|
|
export CLAUDE_TIMEOUT="${CLAUDE_TIMEOUT:-7200}"
|
|
|
|
|
|
2026-03-26 16:59:57 +00:00
|
|
|
# Vault-only token guard (#745): external-action tokens (GITHUB_TOKEN, CLAWHUB_TOKEN)
|
|
|
|
|
# must NEVER be available to agents. They live in .env.vault.enc and are injected
|
|
|
|
|
# only into the ephemeral vault-runner container at fire time. Unset them here so
|
|
|
|
|
# even an accidental .env inclusion cannot leak them into agent sessions.
|
|
|
|
|
unset GITHUB_TOKEN 2>/dev/null || true
|
|
|
|
|
unset CLAWHUB_TOKEN 2>/dev/null || true
|
|
|
|
|
|
2026-03-26 13:21:22 +00:00
|
|
|
# Disable Claude Code auto-updater, telemetry, error reporting in factory sessions.
|
|
|
|
|
# Factory processes must never phone home or auto-update mid-session (#725).
|
|
|
|
|
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
|
|
|
|
|
2026-03-12 12:44:15 +00:00
|
|
|
# Shared log helper
|
|
|
|
|
log() {
|
|
|
|
|
printf '[%s] %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC')" "$*"
|
|
|
|
|
}
|
|
|
|
|
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
# Forge API helper — usage: forge_api GET /issues?state=open
|
|
|
|
|
forge_api() {
|
2026-03-12 12:44:15 +00:00
|
|
|
local method="$1" path="$2"
|
|
|
|
|
shift 2
|
|
|
|
|
curl -sf -X "$method" \
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
-H "Authorization: token ${FORGE_TOKEN}" \
|
2026-03-12 12:44:15 +00:00
|
|
|
-H "Content-Type: application/json" \
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
"${FORGE_API}${path}" "$@"
|
2026-03-12 12:44:15 +00:00
|
|
|
}
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
# Backwards-compat alias
|
|
|
|
|
codeberg_api() { forge_api "$@"; }
|
2026-03-12 12:44:15 +00:00
|
|
|
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
# Paginate a Forge API GET endpoint and return all items as a merged JSON array.
|
|
|
|
|
# Usage: forge_api_all /path (no existing query params)
|
|
|
|
|
# forge_api_all /path?a=b (with existing params — appends &limit=50&page=N)
|
|
|
|
|
# forge_api_all /path TOKEN (optional second arg: token; defaults to $FORGE_TOKEN)
|
|
|
|
|
forge_api_all() {
|
2026-03-18 08:13:43 +00:00
|
|
|
local path_prefix="$1"
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
local FORGE_TOKEN="${2:-${FORGE_TOKEN}}"
|
2026-03-18 08:13:43 +00:00
|
|
|
local sep page page_items count all_items="[]"
|
|
|
|
|
case "$path_prefix" in
|
|
|
|
|
*"?"*) sep="&" ;;
|
|
|
|
|
*) sep="?" ;;
|
|
|
|
|
esac
|
|
|
|
|
page=1
|
|
|
|
|
while true; do
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
page_items=$(forge_api GET "${path_prefix}${sep}limit=50&page=${page}")
|
2026-03-18 08:13:43 +00:00
|
|
|
count=$(printf '%s' "$page_items" | jq 'length')
|
|
|
|
|
[ "$count" -eq 0 ] && break
|
|
|
|
|
all_items=$(printf '%s\n%s' "$all_items" "$page_items" | jq -s 'add')
|
|
|
|
|
[ "$count" -lt 50 ] && break
|
|
|
|
|
page=$((page + 1))
|
|
|
|
|
done
|
|
|
|
|
printf '%s' "$all_items"
|
|
|
|
|
}
|
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
|
|
|
# Backwards-compat alias
|
|
|
|
|
codeberg_api_all() { forge_api_all "$@"; }
|
2026-03-18 08:13:43 +00:00
|
|
|
|
2026-03-12 12:44:15 +00:00
|
|
|
# Woodpecker API helper
|
|
|
|
|
woodpecker_api() {
|
|
|
|
|
local path="$1"
|
|
|
|
|
shift
|
2026-03-14 16:25:33 +01:00
|
|
|
curl -sfL \
|
2026-03-12 12:44:15 +00:00
|
|
|
-H "Authorization: Bearer ${WOODPECKER_TOKEN}" \
|
|
|
|
|
"${WOODPECKER_SERVER}/api${path}" "$@"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Woodpecker DB query helper
|
|
|
|
|
wpdb() {
|
|
|
|
|
PGPASSWORD="${WOODPECKER_DB_PASSWORD}" psql \
|
|
|
|
|
-U "${WOODPECKER_DB_USER:-woodpecker}" \
|
|
|
|
|
-h "${WOODPECKER_DB_HOST:-127.0.0.1}" \
|
|
|
|
|
-d "${WOODPECKER_DB_NAME:-woodpecker}" \
|
|
|
|
|
-t "$@" 2>/dev/null
|
|
|
|
|
}
|
2026-03-14 16:25:33 +01:00
|
|
|
|
2026-03-26 15:00:12 +00:00
|
|
|
# Memory guard — exit 0 (skip) if available RAM is below MIN_MB.
|
|
|
|
|
# Usage: memory_guard [MIN_MB] (default 2000)
|
|
|
|
|
memory_guard() {
|
|
|
|
|
local min_mb="${1:-2000}"
|
|
|
|
|
local avail_mb
|
|
|
|
|
avail_mb=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo)
|
|
|
|
|
if [ "${avail_mb:-0}" -lt "$min_mb" ]; then
|
|
|
|
|
log "SKIP: only ${avail_mb}MB available (need ${min_mb}MB)"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 12:20:15 +00:00
|
|
|
# Source tea helpers (available when tea binary is installed)
|
|
|
|
|
if command -v tea &>/dev/null; then
|
|
|
|
|
# shellcheck source=tea-helpers.sh
|
|
|
|
|
source "$(dirname "${BASH_SOURCE[0]}")/tea-helpers.sh"
|
|
|
|
|
fi
|