From 15cb154a19cabb5c3c66491a61f215ef104d5280 Mon Sep 17 00:00:00 2001
From: TevinClaw <510129976@qq.com>
Date: Sat, 14 Mar 2026 13:03:06 +0800
Subject: [PATCH] feat(早报): 增加昨日总结模块
---
workspace/skills/self-improving-agent/hooks/openclaw/handler.ts | 62 +++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/workspace/skills/self-improving-agent/hooks/openclaw/handler.ts b/workspace/skills/self-improving-agent/hooks/openclaw/handler.ts
new file mode 100644
index 0000000..9ec23f3
--- /dev/null
+++ b/workspace/skills/self-improving-agent/hooks/openclaw/handler.ts
@@ -0,0 +1,62 @@
+/**
+ * Self-Improvement Hook for OpenClaw
+ *
+ * Injects a reminder to evaluate learnings during agent bootstrap.
+ * Fires on agent:bootstrap event before workspace files are injected.
+ */
+
+import type { HookHandler } from 'openclaw/hooks';
+
+const REMINDER_CONTENT = `## Self-Improvement Reminder
+
+After completing tasks, evaluate if any learnings should be captured:
+
+**Log when:**
+- User corrects you → \`.learnings/LEARNINGS.md\`
+- Command/operation fails → \`.learnings/ERRORS.md\`
+- User wants missing capability → \`.learnings/FEATURE_REQUESTS.md\`
+- You discover your knowledge was wrong → \`.learnings/LEARNINGS.md\`
+- You find a better approach → \`.learnings/LEARNINGS.md\`
+
+**Promote when pattern is proven:**
+- Behavioral patterns → \`SOUL.md\`
+- Workflow improvements → \`AGENTS.md\`
+- Tool gotchas → \`TOOLS.md\`
+
+Keep entries simple: date, title, what happened, what to do differently.`;
+
+const handler: HookHandler = async (event) => {
+ // Safety checks for event structure
+ if (!event || typeof event !== 'object') {
+ return;
+ }
+
+ // Only handle agent:bootstrap events
+ if (event.type !== 'agent' || event.action !== 'bootstrap') {
+ return;
+ }
+
+ // Safety check for context
+ if (!event.context || typeof event.context !== 'object') {
+ return;
+ }
+
+ // Skip sub-agent sessions to avoid bootstrap issues
+ // Sub-agents have sessionKey patterns like "agent:main:subagent:..."
+ const sessionKey = event.sessionKey || '';
+ if (sessionKey.includes(':subagent:')) {
+ return;
+ }
+
+ // Inject the reminder as a virtual bootstrap file
+ // Check that bootstrapFiles is an array before pushing
+ if (Array.isArray(event.context.bootstrapFiles)) {
+ event.context.bootstrapFiles.push({
+ path: 'SELF_IMPROVEMENT_REMINDER.md',
+ content: REMINDER_CONTENT,
+ virtual: true,
+ });
+ }
+};
+
+export default handler;
--
Gitblit v1.9.1