refactor(prism-facet): become a pure registration framework

Strip all Hangman-Lab-specific content out of PrismFacet so it can be
reused by any project. Content (always router, pcexec-convention prompt,
fabric-chat-injector hook) moves to the new sibling plugin ClawPrompts.

Mechanism additions:
- `globalThis.__prismFacet` cross-plugin API installed at module-import
  time (so consumers loaded before PrismFacet can still register):
    .addRouter(name, resolveFn)
    .addRule(router, key, { file })
- core/rule-store: tier rules into `persistent` (rules.json, mutated by
  the prompt-rules admin tool) and `external` (in-memory, registered by
  other plugins via the API). Persistent overrides external on conflict.
- core/router-loader: addExternalRouter() for programmatic registration
  into the same map the file-based loader uses.
- index.ts: drops registerFabricChatInjector wiring, registerBeforePromptBuild
  remains.

Removed (now shipped from ClawPrompts):
- plugin/routers/always.ts
- plugin/hooks/fabric-chat-injector.ts
- plugin/prompts/pcexec-convention.md
- plugin/rules.json: now `{}`; ClawPrompts registers its rule externally

What still lives in PrismFacet:
- before_prompt_build hook (the wiring between routers/rules and the
  agent's system prompt)
- prompt-rules admin tool (lists + mutates persistent rules)
- file-based routersDir / rulesFile scanning (kept for operator ad-hoc
  use; ClawPrompts uses the API instead)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
h z
2026-05-25 10:19:39 +01:00
parent b0fd02c50b
commit 241cced780
11 changed files with 175 additions and 146 deletions

0
plugin/prompts/.gitkeep Normal file
View File

View File

@@ -1,31 +0,0 @@
# Hangman-Lab Site Convention — Shell Execution
This claw (sim or prod) keeps Hangman-Lab site binaries at `~/.openclaw/bin/`
and **does not** symlink them into `/usr/local/bin`. Your shell tool's PATH
does not include them by default, so calling them with the codex built-in
shell yields `command not found`.
**Rule:** any command that invokes one of these binaries MUST be run through
the `pcexec` tool, not the codex built-in shell:
- `hf` (HarborForge CLI)
- `secret-mgr` (per-agent secret store)
- `ego-mgr` (per-agent identity store; reads `role`, `position`, `default-username`, etc.)
- `fabric-register` (Fabric account provisioning)
- `pcguard` (PaddedCell guard)
- `lock-mgr`
- `tea`
`pcexec` injects `~/.openclaw/bin` into PATH and also wires the
`AGENT_ID`, `AGENT_WORKSPACE`, and `AGENT_VERIFY` env vars that
`secret-mgr` / `ego-mgr` need to authenticate as the calling agent.
## Examples
- ✅ Call the `pcexec` tool with `command: "hf calendar show --json"`
- ✅ Call the `pcexec` tool with `command: "HFT=$(secret-mgr get-secret --key hf-token); hf task list --token \"$HFT\" --json"` (the whole pipeline goes in one `pcexec` call)
- ❌ Sending `hf calendar show` to the codex built-in shell → `command not found`
If a workflow's `Procedure` shows a raw shell snippet involving these CLIs,
pass the **whole snippet** as a single `command:` argument to `pcexec`
don't split into multiple non-pcexec calls.