Commit Graph

12 Commits

Author SHA1 Message Date
h z
b0fd02c50b Merge pull request '#3 feat(hooks): fabric-chat-injector' into main 2026-05-25 08:56:05 +00:00
33fcd17746 feat(hooks): fabric-chat-injector — suggest chat workflow on channel turns
New before_prompt_build hook that appends a "next action: workflow_start
chat" hint to the system prompt whenever the agent's turn was triggered
by a message in a fabric channel.

If Meridian (`globalThis.__meridian.getChatJournalForChannel`) reports
an existing chat journal for this (agentId, channelId), the hint
includes `from="<journal-id>"` so the agent resumes the conversation
file instead of starting a fresh one each turn.

Activation:
  - ctx.agentId AND ctx.channelId present
  - ctx.messageProvider in {fabric, '' (empty/omitted by gateway)}

TODO(phase-2): once Fabric exposes per-channel type info (DM / group /
triage) via a cross-plugin API, narrow this to xType === 'dm' only.
Today we fire on any fabric channel — chat workflow is a no-op outside
DMs, so the false positives are just prompt-text noise.

Dedup via WeakSet keyed on the event object (same pattern as the
existing before-prompt-build hook) so each turn injects at most once
even when multiple harness call sites trigger the hook.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 09:46:34 +01:00
f3e2e74d36 feat(prism-facet): add 'always' router + Hangman-Lab pcexec convention prompt
The 'always' router resolves to the constant key "always" for every
agent — pair with a rule like 'always:always → some-prompt.md' to
inject a prompt fragment unconditionally (no ego/role/position
lookup needed).

Bundle a site-specific prompt 'pcexec-convention.md' that tells every
agent: Hangman-Lab keeps site binaries at ~/.openclaw/bin (hf,
secret-mgr, ego-mgr, fabric-register, pcguard, lock-mgr, tea) — not
symlinked to /usr/local/bin — so they MUST be invoked via the pcexec
tool, not the codex built-in shell. Without this, agents would call
those CLIs directly and get 'command not found' (observed during the
2026-05-23 hf-wakeup runs on prod t2).

Register the binding in rules.json so it loads at gateway startup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 08:48:05 +01:00
h z
be5b5f1922 Merge pull request 'fix: declare prompt_rules tool in contracts.tools' (#2) from fix/declare-contracts-tools into main 2026-05-20 14:48:08 +00:00
4d7f7dc6c8 fix: declare prompt_rules tool in contracts.tools
Same class of bug as Meridian (zhi/Meridian#2), HarborForge.OpenclawPlugin
(zhi/HarborForge.OpenclawPlugin#6), and PaddedCell (already fixed in
787d88c). OpenClaw's plugin host requires that any tool registered via
`api.registerTool()` is also declared in `contracts.tools` in the
plugin manifest, or the tool is silently dropped from the agent's
available tool list. plugin doctor was warning:

  prism-facet: plugin must declare contracts.tools before registering
  agent tools

PrismFacet registers exactly one tool, `prompt_rules` (in
tools/prompt-rules.js). Declaring it in the manifest. Verified in sim
that with this change the warning disappears and the tool becomes
visible to agents.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 14:49:42 +01:00
h z
bd851f2b9d Merge pull request 'zhi-2026-04-18' (#1) from zhi-2026-04-18 into main
Reviewed-on: #1
2026-05-01 07:21:25 +00:00
zhi
6a70a68c7e fix: use parameters + content[] format per OpenClaw plugin spec
- inputSchema → parameters
- { result: text } → { content: [{ type: "text", text }] }

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-22 12:04:41 +00:00
zhi
76ac2e959a refactor: remove built-in routers
PrismFacet is a generic framework — routers are registered by
consumers (e.g., ClawRoles), not bundled with the plugin.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 10:35:28 +00:00
zhi
bee3dcb84c fix: correct routers/rules path resolution
pluginDir already points to the plugin install root, no need for ..

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 19:54:20 +00:00
zhi
d5c057a3f9 refactor: restructure PrismFacet per OpenClaw plugin spec
- plugin/ directory structure: hooks/, tools/, core/
- export default { id, name, register } entry format
- globalThis state management with lifecycle protection
- WeakSet dedup on before_prompt_build hook
- Tool uses inputSchema + execute (not parameters + handler)
- additionalProperties: false in config schema
- Core logic in plugin/core/ (no plugin-sdk dependency)
- Install/uninstall script (scripts/install.mjs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 17:22:17 +00:00
zhi
c4a72b13c0 feat: PrismFacet core implementation
- Plugin scaffold: manifest, tsconfig, package.json
- Router loader with dynamic import + cache busting for hot reload
- Rule store: CRUD on rules.json
- Prompt injector: resolve routers → match rules → read files → inject
- MCP tool: prompt_rules (add/remove/list/test/reload-routers/list-routers)
- Built-in routers: agent-id (zero-dep), role, position (ego.json)
- before_prompt_build hook for system prompt injection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 17:12:10 +00:00
zhi
3a36605238 init: PrismFacet project plan
Dynamic system prompt injection plugin for OpenClaw.
Routes agent context through configurable routers, matches
against registered rules, and injects prompt files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 11:02:57 +00:00