feat(skills,cli): dolibarr-sandbox-checkpoint — manage the sandbox iso-prod checkpoint

A skill + CLI group to drive the ADR-0003 sandbox lifecycle, instead of the manual
kubectl/deno/.env dance:

  arcodange sandbox checkpoint status       # liveness + is the write agent armed?
  arcodange sandbox checkpoint refresh --yes # re-seed iso-prod (DESTRUCTIVE, gated)
  arcodange sandbox checkpoint provision     # re-create ai_agent_sandbox (Playwright) + relink
  arcodange sandbox checkpoint relink-env    # rewrite write skill .env from the key + verify

- refresh wraps ops/sandbox/sandbox-lifecycle.sh; requires --yes (it wipes the agent
  too, since iso-prod overwrites llx_user). --db-only skips the documents sync.
- provision runs test/provisionSandbox.ts (you do the admin login — PROD creds,
  iso-prod) then auto-relinks; relink-env writes .env mode 600 and verifies via
  GET /users/info.
- scripts resolve the repo root from ARCO_ROOT (set by bin/arcodange) or their own
  path, so they work via the CLI or standalone.

Tested: status reports armed/not-armed correctly; refresh refuses without --yes
(exit 3); relink-env errors with no key (exit 1); help/usage wired.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-30 07:19:59 +02:00
parent d31e995acd
commit 275a59b478
6 changed files with 224 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# (Re)write the dolibarr-sandbox-write skill .env from the provisioned key file,
# then verify it authenticates. Run this after 'provision' (or any time the key
# changed). The key is instance-encrypted per Dolibarr instance, so a refresh
# invalidates it — re-provision first if this fails to authenticate.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="${ARCO_ROOT:-$(cd "${SCRIPT_DIR}/../../../.." && pwd)}"
SB_URL="${DOLIBARR_SANDBOX_URL:-https://erp-sandbox.arcodange.lab}"
KEY="${ROOT}/test/.ai_agent_sandbox.key"
ENV="${ROOT}/.claude/skills/dolibarr-sandbox-write/.env"
DOLW="${ROOT}/.claude/skills/dolibarr-sandbox-write/scripts/dol-write.sh"
[[ -s "${KEY}" ]] || { echo "checkpoint-relink-env: no key at ${KEY}" >&2
echo " run 'arcodange sandbox checkpoint provision' first." >&2; exit 1; }
umask 077
{ echo "DOLIBARR_SANDBOX_URL=${SB_URL}"
printf 'DOLIBARR_SANDBOX_API_KEY=%s\n' "$(tr -d '\r\n' < "${KEY}")"; } > "${ENV}"
chmod 600 "${ENV}"
echo "✓ wrote ${ENV} (mode 600)"
printf 'verify: '
"${DOLW}" GET /users/info | python3 -c "import json,sys
d = json.load(sys.stdin)
if isinstance(d, dict) and d.get('login'):
print('OK — armed as %s (id %s)' % (d['login'], d.get('id')))
else:
msg = d.get('error', {}).get('message', '?') if isinstance(d, dict) else str(d)
print('FAILED — %s' % msg); sys.exit(1)"