CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 53s
CI & Build / integration (push) Successful in 1m2s
CI & Build / Python tests (push) Failing after 1m26s
CI & Build / Build & push image (push) Skipped
Step 3 of the Scribe -> Grimoire rename. - Plugin `grimoire` in marketplace `grimoire-plugin`, MCP server key `grimoire`, so tools reach a session as mcp__plugin_grimoire_grimoire__*. - hooks/scribe_* -> hooks/grimoire_*, their shell functions and the TMPDIR ledgers with them; SCRIBE_URL / SCRIBE_TOKEN / SCRIBE_HOOK_DIR / SCRIBE_LEDGER_DIRS -> GRIMOIRE_*; the project marker is `.grimoire`. - skills/using-scribe -> using-grimoire, /grimoire:sync, stored processes arrive as grimoire-proc-<slug>; moment_actions names them the same way. - Migration 0124 rewrites stored skill names (rule_moments, rule_moment_judgments, moment_mappings) from scribe:/scribe-proc- to grimoire:/grimoire-proc-, so a rule mounted on a skill keeps firing. - Settings' install commands and MCP-only defaults, the docs and the tests follow. - scripts/check_plugin.py drops the smoke event for a report-check hook that has no file in plugin/hooks. Kept on purpose: the secret-sealing label, and the names that let backups written as Scribe restore and be counted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.5 KiB
Bash
Executable File
56 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Grimoire — record that this session said what a rule DID, not merely that it
|
|
# read one.
|
|
#
|
|
# THE THIRD LEDGER, AND WHY THE OTHER TWO ARE NOT ENOUGH.
|
|
#
|
|
# `.rules.ids` says a rule was NAMED. `.opened.ids` says it was READ (a
|
|
# PostToolUse hook watches the `get_rule` call, so it is a recorded event
|
|
# rather than a model's claim about its own context). Neither can say what
|
|
# happened next: a rule read and followed and a rule read and forgotten leave
|
|
# identical traces.
|
|
#
|
|
# `rule_outcome` is the call that closes that gap, and the server
|
|
# records it. But the server's row carries no session — `rule_usage_events` is
|
|
# per user over a window — so a SESSION-scoped readout cannot be asked of it.
|
|
# The question "which rules changed something in THIS session" has to be
|
|
# answered where a session is a thing that exists, which is here.
|
|
#
|
|
# SAME EVIDENCE CLASS AS `.opened.ids`, deliberately. A tool call happened or
|
|
# it did not, and the harness reports it either way; nothing here asks the
|
|
# model whether it followed anything, so it is evidence, not self-report.
|
|
#
|
|
# WHAT IT CANNOT SAY: that the rule was followed WELL, or that `applied` was
|
|
# honest. It records that an outcome was declared. The value of that is not the
|
|
# claim itself — it is that the absence of one becomes visible.
|
|
#
|
|
# EXIT 0, ALWAYS. This decorates a ledger; a bookkeeping failure must never
|
|
# turn a successful tool call into a hook error.
|
|
set -uo pipefail
|
|
|
|
# shellcheck source=plugin/hooks/grimoire_defs.sh
|
|
. "$(dirname "${BASH_SOURCE[0]}")/grimoire_defs.sh"
|
|
|
|
event=$(cat 2>/dev/null || true)
|
|
[ -n "$event" ] || exit 0
|
|
|
|
event_flat=$(printf '%s' "$event" | grimoire_json_flat)
|
|
session_id=$(grimoire_json_pick "$event_flat" '.session_id')
|
|
[ -n "$session_id" ] || exit 0
|
|
|
|
# The matcher in hooks.json narrows to the rule_outcome tools, but the server
|
|
# segment of an MCP tool name varies with how the plugin was installed, so the
|
|
# id is read from the field rather than from an assumed tool name — the same
|
|
# reasoning grimoire_record_opened.sh gives.
|
|
rule_id=$(grimoire_json_pick "$event_flat" '.tool_input.rule_id')
|
|
rule_id=$(printf '%s' "$rule_id" | tr -cd '0-9')
|
|
[ -n "$rule_id" ] || exit 0
|
|
|
|
state_dir="${TMPDIR:-/tmp}/grimoire-priorart"
|
|
mkdir -p "$state_dir" 2>/dev/null || true
|
|
safe_sid=$(printf '%s' "$session_id" | tr -c 'A-Za-z0-9._-' '_')
|
|
|
|
# Stamped and append-only like its two siblings, so one reader ages them all.
|
|
printf '%s\n' "$rule_id" | grimoire_rules_append "$state_dir/${safe_sid}.acted.ids"
|
|
exit 0
|