fix(config): resolve Python reliably, add command-safety hook, harden CI

- Resolve Python 3.11+ through shared Resolve-Python.ps1/resolve-python.sh,
  which probe python, python3 and py -3 and skip the Windows Store alias.
  Build and capability checks fail early with an actionable message; doctor
  reports missing Python and the skipped hooks.
- Fix check-capabilities.sh comparing only the major version.
- Register Validate-CommandSafety as a PreToolUse hook for Claude and Codex;
  shared logic in command-safety.py catches rm -rf variants, git reset --hard,
  git clean -f, Remove-Item -Recurse, del/rd /s /q and nested shells.
- Replace duplicated placeholder chains in both builds with
  adapters/placeholders.tsv.
- Restore shell parity: add test-capabilities.sh, rename credentials.ps1 to
  with-credential.ps1 and qmd-warm.sh to start-qmd-warm.sh.
- CI: build once and pass generated/ as an artifact, lint Python with ruff
  and JavaScript modules with node --check, require SHA pins for all actions.
- Add evals for all own skills and update documentation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian LechnerandClaude Opus 5.5 committed 2026-11-05 09:34:54 +01:00
1 parent e19aa2e27c
commit 79694fbaa2
95 files changed
+1838 -218

No files matched your search

+39 -60
View File
@@ -9,6 +9,10 @@ while [ $# -gt 0 ]; do
done
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
# shellcheck source=../../shared/hooks/scripts/resolve-python.sh
. "$root/shared/hooks/scripts/resolve-python.sh"
# Fail early with an actionable message instead of a generic validation error after the build.
resolve_python || { python_missing_message >&2; exit 1; }
shared="$root/shared"
final="$root/generated"
sandbox_supported=false
@@ -27,6 +31,32 @@ sandbox='{"enabled": false}'
[ "$sandbox_supported" != true ] || sandbox='{"enabled": true, "allowUnsandboxedCommands": false, "failIfUnavailable": true, "network": {"allowedDomains": ["mcp.context7.com"]}}'
plugin_manifest="$root/adapters/plugins.tsv"
capability_manifest="$root/adapters/claude/capabilities.tsv"
placeholder_manifest="$root/adapters/placeholders.tsv"
# Shell-specific template values live in one table shared with build.ps1, so adding a hook or
# script means adding one row instead of editing both builds.
[ -f "$placeholder_manifest" ] || { printf 'Missing placeholder manifest: %s\n' "$placeholder_manifest" >&2; exit 1; }
placeholder_names=()
placeholder_powershell=()
placeholder_bash=()
while IFS=$'\t' read -r placeholder powershell_value bash_value; do
bash_value=${bash_value%$'\r'}
[ "$placeholder" != placeholder ] || continue
[ -n "$placeholder" ] || continue
[[ "$placeholder" =~ ^__[A-Z0-9_]+__$ ]] && [ -n "$powershell_value" ] && [ -n "$bash_value" ] || { printf 'Invalid placeholder manifest row: %s\n' "$placeholder" >&2; exit 1; }
placeholder_names+=("$placeholder")
placeholder_powershell+=("$powershell_value")
placeholder_bash+=("$bash_value")
done < "$placeholder_manifest"
expand_shell_placeholders() {
local text=$1 shell=$2 index value
for index in "${!placeholder_names[@]}"; do
if [ "$shell" = powershell ]; then value=${placeholder_powershell[$index]}; else value=${placeholder_bash[$index]}; fi
text=${text//"${placeholder_names[$index]}"/"$value"}
done
printf '%s' "$text"
}
[ -f "$plugin_manifest" ] || { printf 'Missing plugin manifest: %s\n' "$plugin_manifest" >&2; exit 1; }
awk -F '\t' 'NR == 1 { next } NF == 0 { next } $1 == "" || $3 == "" || $6 == "" { print "Invalid plugin manifest row." > "/dev/stderr"; exit 1 } seen[$1]++ { print "Duplicate plugin name in manifest: " $1 > "/dev/stderr"; exit 1 }' "$plugin_manifest"
@@ -151,18 +181,10 @@ while IFS= read -r rule_path; do
fi
done < <(find "$shared/rules" -mindepth 1 -type f -name '*.md' -printf '%P\n' | sort)
shared_template=$(<"$shared/global-instructions.md")
instructions_content=$(expand_shell_placeholders "$(<"$shared/global-instructions.md")" "$shell")
general_content=$(<"$shared/rules/general.md")
credential_helper_extension='sh'
[ "$shell" != powershell ] || credential_helper_extension='ps1'
agents_content=${shared_template//__CLIENT__/codex}
agents_content=${agents_content//__SHELL__/$credential_helper_extension}
printf '%s\n\n---\n\n%s\n' "${agents_content%$'\n'}" "$general_content" > "$output/codex-$shell/AGENTS.md"
claude_content=${shared_template//__CLIENT__/claude}
claude_content=${claude_content//__SHELL__/$credential_helper_extension}
printf '%s\n\n---\n\n%s\n' "${claude_content%$'\n'}" "$general_content" > "$output/claude-$shell/CLAUDE.md"
printf '%s\n\n---\n\n%s\n' "${instructions_content%$'\n'}" "$general_content" > "$output/codex-$shell/AGENTS.md"
printf '%s\n\n---\n\n%s\n' "${instructions_content%$'\n'}" "$general_content" > "$output/claude-$shell/CLAUDE.md"
cp "$root/adapters/codex/config/config.toml" "$output/codex-$shell/config.toml"
cp "$root/adapters/claude/config/settings.json" "$output/claude-$shell/settings.json"
@@ -178,65 +200,22 @@ for client in codex claude; do
if [ "$client" = codex ]; then
printf 'name = %s\ndescription = %s\ndeveloper_instructions = %s\n' "$(quote_toml "$name")" "$(quote_toml "$description")" "$(quote_toml "$instructions")" > "$agents_output/$name.toml"
else
tools=${agent_tools[$name]:-}
shell_tool=Bash
[ "$shell" != powershell ] || shell_tool=PowerShell
tools=${tools//__SHELL__/$shell_tool}
tools=$(expand_shell_placeholders "${agent_tools[$name]:-}" "$shell")
if [ -n "$tools" ]; then printf '%s\nname: %s\ndescription: %s\ntools: %s\n%s\n\n%s\n' '---' "$name" "$description" "$tools" '---' "$instructions" > "$agents_output/$name.md"; else printf '%s\nname: %s\ndescription: %s\n%s\n\n%s\n' '---' "$name" "$description" '---' "$instructions" > "$agents_output/$name.md"; fi
fi
done
done
for client in codex claude; do
file=config.toml
[ "$client" != claude ] || file=settings.json
command=bash
script=flashbang.sh
statusline_script=statusline.sh
compact_script=record-compact.sh
pointer_script=show-session-state-pointer.sh
qmd_warm_script=qmd-warm.sh
correction_prompt_script=show-correction-prompt.sh
completion_evidence_script=check-completion-evidence.sh
if [ "$shell" = powershell ]; then
command='__POWERSHELL_COMMAND__'
script=flashbang.ps1
statusline_script=statusline.ps1
compact_script=Record-Compact.ps1
pointer_script=Show-SessionStatePointer.ps1
qmd_warm_script=Start-QmdWarm.ps1
correction_prompt_script=Show-CorrectionPrompt.ps1
completion_evidence_script=Check-CompletionEvidence.ps1
fi
path="$output/$client-$shell/$file"
content=$(<"$path")
# Claude can offer both shell tools on Windows, so every package denies the destructive commands in both.
deny_rules='["PowerShell(git reset --hard*)","PowerShell(git clean*)","PowerShell(Remove-Item *-Recurse*)","Bash(git reset --hard*)","Bash(git clean*)","Bash(rm -rf*)"]'
if [ "$shell" = powershell ]; then
allow_rules='["Agent","PowerShell(mcporter call context7.*)"]'
else
allow_rules='["Agent","Bash(mcporter call context7.*)"]'
fi
content=${content//__HOOK_COMMAND__/$command}
content=${content//__POWERSHELL_HOOK_COMMAND__/$command}
content=${content//__HOOK_SCRIPT__/$script}
content=${content//__POWERSHELL_HOOK_SCRIPT__/$script}
content=${content//__COMPACT_SCRIPT__/$compact_script}
content=${content//__SESSION_POINTER_SCRIPT__/$pointer_script}
content=${content//__QMD_WARM_SCRIPT__/$qmd_warm_script}
content=${content//__CORRECTION_PROMPT_SCRIPT__/$correction_prompt_script}
content=${content//__COMPLETION_EVIDENCE_SCRIPT__/$completion_evidence_script}
content=${content//__STATUSLINE_COMMAND__/$command}
content=${content//__STATUSLINE_SCRIPT__/$statusline_script}
content=${content//__CLAUDE_SANDBOX__/$sandbox}
content=${content//__CLAUDE_DENY_RULES__/$deny_rules}
content=${content//__CLAUDE_ALLOW_RULES__/$allow_rules}
for path in "$output/codex-$shell/config.toml" "$output/claude-$shell/settings.json"; do
content=$(expand_shell_placeholders "$(<"$path")" "$shell")
# The sandbox depends on the build platform, not the shell, so it is not part of the placeholder table.
content=${content//__CLAUDE_SANDBOX__/"$sandbox"}
printf '%s\n' "$content" > "$path"
done
toml_path="$output/codex-$shell/config.toml"
settings_path="$output/claude-$shell/settings.json"
python3 "$root/scripts/checks/validate-config.py" "$toml_path" "$settings_path"
run_python "$root/scripts/checks/validate-config.py" "$toml_path" "$settings_path"
if command -v codex >/dev/null; then
schema_home=$(mktemp -d)
cp "$toml_path" "$schema_home/config.toml"