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.js |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/workspace/skills/self-improving-agent/hooks/openclaw/handler.js b/workspace/skills/self-improving-agent/hooks/openclaw/handler.js
new file mode 100644
index 0000000..73278ea
--- /dev/null
+++ b/workspace/skills/self-improving-agent/hooks/openclaw/handler.js
@@ -0,0 +1,56 @@
+/**
+ * Self-Improvement Hook for OpenClaw
+ * 
+ * Injects a reminder to evaluate learnings during agent bootstrap.
+ * Fires on agent:bootstrap event before workspace files are injected.
+ */
+
+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.
+`.trim();
+
+const handler = 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;
+  }
+
+  // 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,
+    });
+  }
+};
+
+module.exports = handler;
+module.exports.default = handler;

--
Gitblit v1.9.1