Files
oikos/tools/setup-hermes-soul.sh
dtoro b5c1247093 docs: streamline & consolidate the tree (phase 6)
Problem: after the wiki-hq reorg, agent-instruction and human-doc domains
were still scattered across the repo root, with three now-redundant stub
files cluttering it. The organizing principle wasn't visible in the layout.

Change — enforce three clear buckets:
- .agents/  = how agents operate: OIKOS.md, HERMES.md (moved from root),
  shared/ conventions, domains/ schemas, skills/, and operations/ (operator
  cheatsheet + enrollment + hermes-agent, moved from root).
- knowledge/ = what exists + evidence: wiki/, GLOSSARY.md, and sources/ now
  including investigations/ (incident records are evidence/sources).
- root = substrate + two entry points (AGENTS.md, README.md), plus plans/
  as its own design-intent domain.

Moves:
- investigations/ -> knowledge/sources/investigations/ (incl. archive/, index).
- operations/ -> .agents/operations/.
- HERMES.md -> .agents/HERMES.md.
- Deleted unreferenced root stubs CAVEMAN.md, CONTRIBUTING.md, and OIKOS.md
  (its 7 remaining linkers repointed to .agents/OIKOS.md).

Consumers updated:
- inventory.yaml doc_page (agent-enrollment) + regenerated hosts/*.yaml + cards.
- tools/setup-hermes-soul.sh and bootstrap.sh (x2) -> .agents/HERMES.md.
- bin/homelab help string -> .agents/operations/hermes-agent.md.
- knowledge/operations schemas, llm-wiki, page-templates, incident-investigation
  skill, AGENTS.md/README nav -> new investigations/operations paths.
- All markdown links rewritten via the path-resolving mapper.

Left in place (substrate/executable/separate-domain): hosts/, ledger/, tools/,
plans/, oikos/, mcp/, secrets/, bin/, inventory.yaml.

Verification: docs-lint at baseline (2 intentional cross-repo refs, no new
breakage); gen-topology.py --check exit 0; build_host_files.py idempotent; all
doc_page targets resolve; Hermes provisioning scripts point at the new path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 18:12:14 +02:00

68 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# setup-hermes-soul.sh — auto-provisions Hermes SOUL.md from canonical HERMES.md.
# Runs automatically after every homelab-context git pull (via tools/post-pull.sh).
#
# What it does:
# - Detects if Hermes Agent is installed (~/.hermes/SOUL.md exists)
# - If yes, copies the canonical HERMES.md content into SOUL.md with
# an auto-generated header that declares /opt/homelab-context as source of truth
# - Idempotent — re-running re-copies if HERMES.md content changed
#
# For non-Hermes agents (Goose, Claude Code, etc.), this script is a no-op.
# Those agents use the `.goosehints` symlink mechanism instead.
set -euo pipefail
CONTEXT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
HERMES_MD="$CONTEXT_DIR/.agents/HERMES.md"
SOUL_MD="${HOME}/.hermes/SOUL.md"
# Colors for output (only when connected to a terminal)
if [ -t 1 ]; then
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
else
GREEN=''; YELLOW=''; NC=''
fi
ok() { echo -e "${GREEN}[hermes-soul]${NC} $1"; }
skip() { echo -e "${YELLOW}[hermes-soul]${NC} $1"; }
# --- 1. Check if Hermes is installed ---
if [ ! -f "$SOUL_MD" ]; then
skip "hermes not installed (~/.hermes/SOUL.md not found) — skipping"
exit 0
fi
# --- 2. Check if canonical HERMES.md exists ---
if [ ! -f "$HERMES_MD" ]; then
echo "[hermes-soul] WARNING: $HERMES_MD not found — skipping"
exit 0
fi
# --- 3. Write SOUL.md with canon source header + HERMES.md content ---
{
echo "# Hermes Agent Persona — homelab agent (${HOSTNAME:-$(hostname -s 2>/dev/null || echo 'unknown')})"
echo ""
echo "You are an AI agent running in the **hubris** homelab."
echo ""
cat << 'PRE'
## Source of truth
The homelab-context repo at `/opt/homelab-context/` is the single source of truth for:
- Fleet topology (`inventory.yaml`, `hosts/*.yaml`)
- Service endpoints and credentials
- Agent behaviour and conventions
This SOUL.md is auto-generated from `/opt/homelab-context/HERMES.md` by
`tools/setup-hermes-soul.sh`. Do not edit SOUL.md directly — edit HERMES.md
in the homelab-context repo instead. Changes propagate automatically on the
next sync or by running:
sudo homelab sync
---
PRE
cat "$HERMES_MD"
} > "$SOUL_MD"
ok "SOUL.md provisioned from HERMES.md ($(wc -l < "$SOUL_MD") lines)"