feat: role-code-mapper script + updated install.sh

- scripts/role-code-mapper: echoes role-code for a given role name
- install.sh now:
  1. Copies ClawRoles to ~/.openclaw/ClawRoles
  2. Copies role-code-mapper to ~/.openclaw/bin
  3. Installs routers to PrismFacet (if present)
  4. Registers rules in PrismFacet rules.json

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
zhi
2026-04-21 12:27:20 +00:00
parent 4218cd99e8
commit be3531b3ad
2 changed files with 68 additions and 33 deletions

27
scripts/role-code-mapper Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
ROLES_DIR="${HOME}/.openclaw/ClawRoles/roles"
if [[ $# -lt 1 ]]; then
echo "Usage: role-code-mapper <role>" >&2
exit 1
fi
ROLE="$1"
ROLE_FILE="${ROLES_DIR}/${ROLE}/ROLE.md"
if [[ ! -f "$ROLE_FILE" ]]; then
echo "Error: ROLE.md not found for role '${ROLE}'" >&2
exit 1
fi
# Extract role-code from YAML frontmatter
CODE=$(sed -n '/^---$/,/^---$/{ /^role-code:/{ s/^role-code:[[:space:]]*//; p; q; } }' "$ROLE_FILE")
if [[ -z "$CODE" ]]; then
echo "Error: role-code not found in ${ROLE_FILE}" >&2
exit 1
fi
echo "$CODE"