setup ยท diff

git:20260709.5468afb to git:20260710.9903d68

4 added, 2 removed. Audit B to B.

---
description: Install or update the orchestration routing rules into ~/.claude and check the optional permission allow
argument-hint: ''
allowed-tools: Read, Write, Edit, AskUserQuestion, Bash(node:*)
---
Install or reconcile the orchestration layer this plugin ships but Claude Code cannot auto load: the routing rules file. A SessionStart hook already syncs the rules automatically whenever the live copy matches a version the plugin has shipped before, so this command is mainly needed once (first install) or when the hook detects local edits it will not overwrite on its own. Everything else (the tier agents, the panel and doctor commands) is already active through the plugin itself.
Steps:
1. Read the canonical rules at `${CLAUDE_PLUGIN_ROOT}/rules/orchestration.md` and render the content that should be live. Prefer `node --input-type=module` with `renderRulesContent` and `hashRulesTemplate` exported by `${CLAUDE_PLUGIN_ROOT}/scripts/lib/rules-template.mjs`, passing the existing live model table region as `invalidFallbackText` when the live file exists. If no model routing file exists, the rendered content keeps the shipped placeholder. If a valid model routing file exists, the rendered content contains the scored table.
2. Read `~/.claude/rules/orchestration.md` if it exists.
- If it does not exist, write the rendered content there with `Write` and report that the rules are installed.
- If it exists, compute the template hash for the live file and the canonical file after replacing everything between the `<!-- fusion:model-table:start -->` and `<!-- fusion:model-table:end -->` sentinel lines with the fixed normalized marker before computing SHA-256. A live scored model table is expected to differ from the shipped placeholder, so do not compare raw bytes and do not treat that region as drift.
- If the template hashes match, report that the rules are up to date and stop.
- - If the template hashes differ, show the user a compact diff summary outside the normalized model table region and ask with `AskUserQuestion` whether to overwrite (Recommended when the live copy has no local edits the user wants to keep) or keep the live copy. Overwrite with the rendered content only on approval.
+ - If the template hashes differ, first check whether the live hash is a recognized shipped version: read `${CLAUDE_PLUGIN_ROOT}/rules-manifest.json` with `readManifestHashes`, exported by the same `rules-template.mjs` module as `hashRulesTemplate`. A hash present in the manifest is a version the plugin has shipped before, not a local edit, so reconcile it with the rendered content and never ask, the same way the SessionStart hook already syncs this case automatically.
+ - If the template hashes differ and the live hash is not in the manifest, the live file carries true local edits or a stale render, and this is the only case where the overwrite question applies. Before asking anything, consult decision memory: read `~/.claude/plugins/data/fusion-claude-code-fusion/reconcile-decisions.json`, a small JSON object mapping template hash to `{decision, date}` (treat a missing file as `{}`). If the live hash already has a recorded entry, apply that decision without asking and state in one line that a previously recorded decision from that date was applied.
+ - If the live hash has no recorded entry, show the user a compact diff summary outside the normalized model table region and ask with `AskUserQuestion` whether to overwrite (Recommended when the live copy has no local edits the user wants to keep) or keep the live copy. Overwrite with the rendered content only on approval; either way, record the choice under that hash, with today's date, in `reconcile-decisions.json` before finishing this step, creating the file and its parent directory with `Write` if they do not yet exist and preserving every other hash entry already recorded there.
3. Check `~/.claude/settings.json` for a `permissions.allow` entry of `Bash(node:*)`. If absent, tell the user: adding it lets the grok forwarder run the companion without a first use permission prompt, but it is a broad allow; offer to add it via `Edit` and do so only on approval.
4. Report what was installed, what was skipped, and remind the user that future plugin updates sync automatically at the next session start unless the live copy carries local edits, in which case this command is how to reconcile them. When the live rules still carry the shipped placeholder model table, point the user at /fusion:config propose as the next step.
- Follow the flow above exactly: a fresh install (no existing rules file) writes without asking, and every overwrite or settings change happens only on approval. This command touches only `~/.claude/rules/orchestration.md` and, on request, the settings permissions array.
+ Follow the flow above exactly: a fresh install (no existing rules file) writes without asking, a recognized shipped hash reconciles without asking, a hash with a recorded decision replays that decision without asking, and every other overwrite or settings change happens only on approval. This command touches only `~/.claude/rules/orchestration.md`, the decision memory file at `~/.claude/plugins/data/fusion-claude-code-fusion/reconcile-decisions.json`, and, on request, the settings permissions array.