cto/install.sh
Svrnty 375417a29b feat(cto): initial scaffold v0.1.0
C-suite instance #3 — CTO profile distribution. Thin orchestrator over
sandcastle for code-modifying work across .NET / Dart / Go / Rust /
Python / Angular / Bash stacks.

v0.1 = scaffold only. Orchestrator skill is a stub; v1.0 wires
executable sandcastle.run() invocation.

Scaffold contents (12 files):
- AGENT.md, CONTRACT.md (T1, 12 sections), CLAUDE.md, README.md
- manifest.yaml (14 external_tool_deps across 9 stacks)
- distribution.yaml (Hermes native install contract)
- install.sh (idempotent, --dry-run support), credbridge.sh (gh CLI)
- schema.sql (work_queue + invocations + agent_runtime)
- skills/cto-agent/SKILL.md (stub w/ per-stack routing table)
- .gitignore, .env.example

External tool catalog covers:
- typescript: sandcastle (mattpocock, MIT, v0.5.11)
- dotnet: lib-dotnet-cqrs, tool-cqrs-plugin, pi-bte-plugin
- dart: lib-cqrs-datasource (gRPC client to .NET CQRS)
- go: lib-llm, core-credentials, core-memory, tool-qa
- rust: core-runtime (zeroclaw)
- bash: tool-bash-plugin
- multi: lib-quality-gates (48 gates), lib-skills-engineering (28 patterns)
- cortex-os: tool-cortex-plugin

DESIGN.md (Google Labs spec) compliance documented — CTO ensures UI
work conforms when Stitch / other DESIGN.md consumers are downstream.

Companion changes in workspace:
- hermes/CLAUDE.md workspace map + .gitignore
- sdo/org.yaml: ceo.delegates_to=[cmo, cto], cto agent block
- sot/06-REGISTRY/EXTERNAL-REFS/SANDCASTLE.md (T2, active)
- sot/06-REGISTRY/CORTEX-TOOLING.md (T2, active)
- sot/README.md links updated

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 11:35:57 -04:00

75 lines
2.9 KiB
Bash

#!/usr/bin/env bash
# install.sh — wire CTO profile distribution into Hermes.
# Idempotent. Creates ~/.hermes/$PROFILE_NAME symlink + registers skills in profile config.
# v0.1 scaffold: schema applied, skill registered, but cto-agent skill is a non-executable stub.
set -euo pipefail
REPO="$(cd "$(dirname "$0")" && pwd)"
PROFILE_NAME="cto-planb" # Hermes profile name (org-scoped); matches distribution.yaml → name + manifest.yaml → profile
HERMES_HOME="${HERMES_HOME:-$HOME/.hermes}"
PROFILE_CFG="$HERMES_HOME/profiles/$PROFILE_NAME/config.yaml"
# --dry-run flag for preflight without mutations
DRY_RUN=0
for arg in "$@"; do
case "$arg" in
--dry-run) DRY_RUN=1 ;;
esac
done
echo "== preflight =="
command -v hermes >/dev/null || { echo "ERROR: hermes CLI not on PATH"; exit 1; }
command -v python3 >/dev/null || { echo "ERROR: python3 not on PATH"; exit 1; }
command -v sqlite3 >/dev/null || { echo "ERROR: sqlite3 not on PATH"; exit 1; }
if [ ! -d "$HERMES_HOME" ]; then
echo "ERROR: HERMES_HOME=$HERMES_HOME does not exist"
exit 1
fi
echo " hermes ✓ python3 ✓ sqlite3 ✓ HERMES_HOME ✓"
# Check sandcastle sibling exists (CTO's primary tool)
SANDCASTLE_REPO="${SANDCASTLE_REPO:-$REPO/../sandcastle}"
if [ ! -d "$SANDCASTLE_REPO" ]; then
echo "WARN: sandcastle sibling not found at $SANDCASTLE_REPO"
echo " CTO v1.0 will require it; v0.1 scaffold works without."
else
echo " sandcastle ✓ ($SANDCASTLE_REPO)"
fi
if [ "$DRY_RUN" -eq 1 ]; then
echo "== DRY RUN — no mutations =="
echo " would: ln -sfn $REPO $HERMES_HOME/$PROFILE_NAME"
echo " would: append $REPO/skills to $PROFILE_CFG → skills.external_dirs"
echo " would: sqlite3 $HERMES_HOME/$PROFILE_NAME/cto.db < $REPO/schema.sql"
exit 0
fi
echo "== link repo → ~/.hermes/$PROFILE_NAME =="
ln -sfn "$REPO" "$HERMES_HOME/$PROFILE_NAME"
echo "== register skills in $PROFILE_NAME profile config =="
SKILL_DIR="$REPO/skills"
mkdir -p "$(dirname "$PROFILE_CFG")"
python3 - "$PROFILE_CFG" "$SKILL_DIR" <<'PY'
import sys, os, yaml
cfg, sk = sys.argv[1], sys.argv[2]
d = yaml.safe_load(open(cfg).read()) if os.path.exists(cfg) else {}
d = d or {}
d.setdefault('skills', {}).setdefault('external_dirs', [])
if sk not in d['skills']['external_dirs']:
d['skills']['external_dirs'].append(sk)
open(cfg, 'w').write(yaml.dump(d, sort_keys=False, allow_unicode=True))
print(" +", sk)
else:
print(" already registered:", sk)
PY
echo "== ${PROFILE_NAME}.db =="
sqlite3 "$HERMES_HOME/$PROFILE_NAME/cto.db" < "$REPO/schema.sql"
echo "== done. canonical install: hermes profile install $REPO =="
echo "== verify: hermes -p $PROFILE_NAME skills list | grep cto-agent =="
echo ""
echo "NOTE: v0.1 is scaffold only. cto-agent skill is a stub — invocations no-op gracefully."
echo " v1.0 milestone wires sandcastle.run() into the orchestrator. See CONTRACT.md §4."