# Oclaw Integration Complete setup and usage guide for integrating the self-improvement skill with Oclaw. ## 概览 Oclaw uses workspace-based prompt injection combined with event-driven hooks. Context is injected from workspace files at session start, and hooks can trigger on lifecycle events. ## Workspace Structure ``` ~/.oclaw/ ├── workspace/ # Working directory │ ├── AGENTS.md # Multi-agent coordination patterns │ ├── SOUL.md # Behavioral guidelines and personality │ ├── TOOLS.md # Tool capabilities and gotchas │ ├── MEMORY.md # Long-term memory (main session only) │ └── memory/ # Daily memory files │ └── YYYY-MM-DD.md ├── skills/ # Installed skills │ └── / │ └── SKILL.md └── hooks/ # Custom hooks └── / ├── HOOK.md └── handler.ts ``` ## 快速配置 ### 1. Install the Skill ```bash clawdhub install self-improving-agent ``` Or copy manually: ```bash cp -r self-improving-agent ~/.oclaw/runtime/skills/ ``` ### 2. Install the Hook (Optional) Copy the hook to Oclaw's hooks directory: ```bash cp -r hooks/oclaw ~/.oclaw/hooks/self-improvement ``` Enable the hook: ```bash oclaw hooks enable self-improvement ``` ### 3. Ensure Wiki Improvement Notes Exist Create or initialize these Wiki notes under your configured wiki root: - `improvement/learnings.md` - `improvement/errors.md` - `improvement/feature-requests.md` ## Injected Prompt Files ### AGENTS.md Purpose: Multi-agent workflows and delegation patterns. ```markdown # Agent Coordination ## Delegation Rules - Use explore agent for open-ended codebase questions - Spawn sub-agents for long-running tasks - Use sessions_send for cross-session communication ## Session Handoff When delegating to another session: 1. Provide full context in the handoff message 2. Include relevant file paths 3. Specify expected output format ``` ### SOUL.md Purpose: Behavioral guidelines and communication style. ```markdown # Behavioral Guidelines ## Communication Style - Be direct and concise - Avoid unnecessary caveats and disclaimers - Use technical language appropriate to context ## Error Handling - Admit mistakes promptly - Provide corrected information immediately - Log significant errors to learnings ``` ### TOOLS.md Purpose: Tool capabilities, integration gotchas, local configuration. ```markdown # Tool Knowledge ## 自我改进技能 Log learnings to Wiki `improvement/*.md` notes for continuous improvement. ## Local Tools - Document tool-specific gotchas here - Note authentication requirements - Track integration quirks ``` ## Learning Workflow ### Capturing Learnings 1. **In-session**: Log to Wiki improvement notes (`improvement/*.md`) 2. **Cross-session**: Promote to workspace files ### Promotion Decision Tree ``` Is the learning project-specific? ├── Yes → Keep in improvement/learnings.md └── No → Is it behavioral/style-related? ├── Yes → Promote to SOUL.md └── No → Is it tool-related? ├── Yes → Promote to TOOLS.md └── No → Promote to AGENTS.md (workflow) ``` ### Promotion Format Examples **From learning:** > Git push to GitHub fails without auth configured - triggers desktop prompt **To TOOLS.md:** ```markdown ## Git - Don't push without confirming auth is configured - Use `gh auth status` to check GitHub CLI auth ``` ## Inter-Agent Communication Oclaw provides tools for cross-session communication: Use these only when cross-session sharing is explicitly needed and the environment is trusted. Prefer short sanitized summaries over raw transcripts, command output, or secret-bearing content. ### sessions_list View active and recent sessions: ``` sessions_list(activeMinutes=30, messageLimit=3) ``` ### sessions_history Read transcript from another session: ``` sessions_history(sessionKey="session-id", limit=50) ``` Only read another session's transcript when the user explicitly wants shared context or continuation across sessions. ### sessions_send Send message to another session: ``` sessions_send(sessionKey="session-id", message="Learning: API requires X-Custom-Header") ``` Prefer sending a concise learning summary plus relevant paths rather than forwarding raw transcript content. ### sessions_spawn Spawn a background sub-agent: ``` sessions_spawn(task="Research X and report back", label="research") ``` ## Available Hook Events | Event | When It Fires | |-------|---------------| | `agent:bootstrap` | Before workspace files inject | | `command:new` | When `/new` command issued | | `command:reset` | When `/reset` command issued | | `command:stop` | When `/stop` command issued | | `gateway:startup` | When gateway starts | ## Detection Triggers ### Standard Triggers - User corrections ("No, that's wrong...") - Command failures (non-zero exit codes) - API errors - Knowledge gaps ### Oclaw-Specific Triggers | Trigger | Action | |---------|--------| | Tool call error | Log to TOOLS.md with tool name | | Session handoff confusion | Log to AGENTS.md with delegation pattern | | Model behavior surprise | Log to SOUL.md with expected vs actual | | Skill issue | Log to `improvement/*.md` or report upstream | ## Verification Check hook is registered: ```bash oclaw hooks list ``` Check skill is loaded: ```bash oclaw status ``` ## Troubleshooting ### Hook not firing 1. Ensure hooks enabled in config 2. Restart gateway after config changes 3. Check gateway logs for errors ### Learnings not persisting 1. Verify wiki `improvement/*.md` notes exist 2. Check file permissions 3. Ensure workspace path is configured correctly ### Skill not loading 1. Check skill is in skills directory 2. Verify SKILL.md has correct frontmatter 3. Run `oclaw status` to see loaded skills