{
  "title": "Other platforms",
  "content": "tail -f ~/.openclaw/gateway.log\ntypescript theme={null}\nimport { test } from \"vitest\";\nimport { createHookEvent } from \"./src/hooks/hooks.js\";\nimport myHandler from \"./hooks/my-hook/handler.js\";\n\ntest(\"my handler works\", async () => {\n  const event = createHookEvent(\"command\", \"new\", \"test-session\", {\n    foo: \"bar\",\n  });\n\nawait myHandler(event);\n\n// Assert side effects\n});\n\nGateway startup\n    ↓\nScan directories (workspace → managed → bundled)\n    ↓\nParse HOOK.md files\n    ↓\nCheck eligibility (bins, env, config, os)\n    ↓\nLoad handlers from eligible hooks\n    ↓\nRegister handlers for events\n\nUser sends /new\n    ↓\nCommand validation\n    ↓\nCreate hook event\n    ↓\nTrigger hook (all registered handlers)\n    ↓\nCommand processing continues\n    ↓\nSession reset\nbash theme={null}\n   ls -la ~/.openclaw/hooks/my-hook/\n   # Should show: HOOK.md, handler.ts\n   bash theme={null}\n   cat ~/.openclaw/hooks/my-hook/HOOK.md\n   # Should have YAML frontmatter with name and metadata\n   bash theme={null}\n   openclaw hooks list\n   bash theme={null}\nopenclaw hooks info my-hook\nbash theme={null}\n   openclaw hooks list\n   # Should show ✓ next to enabled hooks\n   bash theme={null}\n   ./scripts/clawlog.sh | grep hook\n   bash theme={null}",
  "code_samples": [
    {
      "code": "### Test Hooks Directly\n\nTest your handlers in isolation:",
      "language": "unknown"
    },
    {
      "code": "## Architecture\n\n### Core Components\n\n* **`src/hooks/types.ts`**: Type definitions\n* **`src/hooks/workspace.ts`**: Directory scanning and loading\n* **`src/hooks/frontmatter.ts`**: HOOK.md metadata parsing\n* **`src/hooks/config.ts`**: Eligibility checking\n* **`src/hooks/hooks-status.ts`**: Status reporting\n* **`src/hooks/loader.ts`**: Dynamic module loader\n* **`src/cli/hooks-cli.ts`**: CLI commands\n* **`src/gateway/server-startup.ts`**: Loads hooks at gateway start\n* **`src/auto-reply/reply/commands-core.ts`**: Triggers command events\n\n### Discovery Flow",
      "language": "unknown"
    },
    {
      "code": "### Event Flow",
      "language": "unknown"
    },
    {
      "code": "## Troubleshooting\n\n### Hook Not Discovered\n\n1. Check directory structure:",
      "language": "unknown"
    },
    {
      "code": "2. Verify HOOK.md format:",
      "language": "unknown"
    },
    {
      "code": "3. List all discovered hooks:",
      "language": "unknown"
    },
    {
      "code": "### Hook Not Eligible\n\nCheck requirements:",
      "language": "unknown"
    },
    {
      "code": "Look for missing:\n\n* Binaries (check PATH)\n* Environment variables\n* Config values\n* OS compatibility\n\n### Hook Not Executing\n\n1. Verify hook is enabled:",
      "language": "unknown"
    },
    {
      "code": "2. Restart your gateway process so hooks reload.\n\n3. Check gateway logs for errors:",
      "language": "unknown"
    },
    {
      "code": "### Handler Errors\n\nCheck for TypeScript/import errors:",
      "language": "unknown"
    }
  ],
  "headings": [
    {
      "level": "h3",
      "text": "Test Hooks Directly",
      "id": "test-hooks-directly"
    },
    {
      "level": "h2",
      "text": "Architecture",
      "id": "architecture"
    },
    {
      "level": "h3",
      "text": "Core Components",
      "id": "core-components"
    },
    {
      "level": "h3",
      "text": "Discovery Flow",
      "id": "discovery-flow"
    },
    {
      "level": "h3",
      "text": "Event Flow",
      "id": "event-flow"
    },
    {
      "level": "h2",
      "text": "Troubleshooting",
      "id": "troubleshooting"
    },
    {
      "level": "h3",
      "text": "Hook Not Discovered",
      "id": "hook-not-discovered"
    },
    {
      "level": "h3",
      "text": "Hook Not Eligible",
      "id": "hook-not-eligible"
    },
    {
      "level": "h3",
      "text": "Hook Not Executing",
      "id": "hook-not-executing"
    },
    {
      "level": "h3",
      "text": "Handler Errors",
      "id": "handler-errors"
    }
  ],
  "url": "llms-txt#other-platforms",
  "links": []
}