refactor: rename to openclaw

This commit is contained in:
Peter Steinberger
2026-01-30 03:15:10 +01:00
parent 4583f88626
commit 9a7160786a
2357 changed files with 16688 additions and 16788 deletions

View File

@@ -1,15 +1,15 @@
---
name: session-memory
description: "Save session context to memory when /new command is issued"
homepage: https://docs.molt.bot/hooks#session-memory
homepage: https://docs.openclaw.ai/hooks#session-memory
metadata:
{
"moltbot":
"openclaw":
{
"emoji": "💾",
"events": ["command:new"],
"requires": { "config": ["workspace.dir"] },
"install": [{ "id": "bundled", "kind": "bundled", "label": "Bundled with Moltbot" }],
"install": [{ "id": "bundled", "kind": "bundled", "label": "Bundled with OpenClaw" }],
},
}
---
@@ -82,7 +82,7 @@ Example configuration:
The hook automatically:
- Uses your workspace directory (`~/clawd` by default)
- Uses your workspace directory (`~/.openclaw/workspace` by default)
- Uses your configured LLM for slug generation
- Falls back to timestamp slugs if LLM is unavailable
@@ -91,7 +91,7 @@ The hook automatically:
To disable this hook:
```bash
moltbot hooks disable session-memory
openclaw hooks disable session-memory
```
Or remove it from your config:

View File

@@ -5,7 +5,7 @@ import { describe, expect, it } from "vitest";
import handler from "./handler.js";
import { createHookEvent } from "../../hooks.js";
import type { ClawdbotConfig } from "../../../config/config.js";
import type { OpenClawConfig } from "../../../config/config.js";
import { makeTempWorkspace, writeWorkspaceFile } from "../../../test-helpers/workspace.js";
/**
@@ -33,7 +33,7 @@ function createMockSessionContent(
describe("session-memory hook", () => {
it("skips non-command events", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const event = createHookEvent("agent", "bootstrap", "agent:main:main", {
workspaceDir: tempDir,
@@ -47,7 +47,7 @@ describe("session-memory hook", () => {
});
it("skips commands other than new", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const event = createHookEvent("command", "help", "agent:main:main", {
workspaceDir: tempDir,
@@ -61,7 +61,7 @@ describe("session-memory hook", () => {
});
it("creates memory file with session content on /new command", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const sessionsDir = path.join(tempDir, "sessions");
await fs.mkdir(sessionsDir, { recursive: true });
@@ -78,7 +78,7 @@ describe("session-memory hook", () => {
content: sessionContent,
});
const cfg: ClawdbotConfig = {
const cfg: OpenClawConfig = {
agents: { defaults: { workspace: tempDir } },
};
@@ -106,7 +106,7 @@ describe("session-memory hook", () => {
});
it("filters out non-message entries (tool calls, system)", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const sessionsDir = path.join(tempDir, "sessions");
await fs.mkdir(sessionsDir, { recursive: true });
@@ -124,7 +124,7 @@ describe("session-memory hook", () => {
content: sessionContent,
});
const cfg: ClawdbotConfig = {
const cfg: OpenClawConfig = {
agents: { defaults: { workspace: tempDir } },
};
@@ -153,7 +153,7 @@ describe("session-memory hook", () => {
});
it("filters out command messages starting with /", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const sessionsDir = path.join(tempDir, "sessions");
await fs.mkdir(sessionsDir, { recursive: true });
@@ -169,7 +169,7 @@ describe("session-memory hook", () => {
content: sessionContent,
});
const cfg: ClawdbotConfig = {
const cfg: OpenClawConfig = {
agents: { defaults: { workspace: tempDir } },
};
@@ -196,7 +196,7 @@ describe("session-memory hook", () => {
});
it("respects custom messages config (limits to N messages)", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const sessionsDir = path.join(tempDir, "sessions");
await fs.mkdir(sessionsDir, { recursive: true });
@@ -213,7 +213,7 @@ describe("session-memory hook", () => {
});
// Configure to only include last 3 messages
const cfg: ClawdbotConfig = {
const cfg: OpenClawConfig = {
agents: { defaults: { workspace: tempDir } },
hooks: {
internal: {
@@ -247,7 +247,7 @@ describe("session-memory hook", () => {
});
it("filters messages before slicing (fix for #2681)", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const sessionsDir = path.join(tempDir, "sessions");
await fs.mkdir(sessionsDir, { recursive: true });
@@ -274,7 +274,7 @@ describe("session-memory hook", () => {
// Request 3 messages - if we sliced first, we'd only get 1-2 messages
// because the last 3 lines include tool entries
const cfg: ClawdbotConfig = {
const cfg: OpenClawConfig = {
agents: { defaults: { workspace: tempDir } },
hooks: {
internal: {
@@ -307,7 +307,7 @@ describe("session-memory hook", () => {
});
it("handles empty session files gracefully", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const sessionsDir = path.join(tempDir, "sessions");
await fs.mkdir(sessionsDir, { recursive: true });
@@ -317,7 +317,7 @@ describe("session-memory hook", () => {
content: "",
});
const cfg: ClawdbotConfig = {
const cfg: OpenClawConfig = {
agents: { defaults: { workspace: tempDir } },
};
@@ -339,7 +339,7 @@ describe("session-memory hook", () => {
});
it("handles session files with fewer messages than requested", async () => {
const tempDir = await makeTempWorkspace("clawdbot-session-memory-");
const tempDir = await makeTempWorkspace("openclaw-session-memory-");
const sessionsDir = path.join(tempDir, "sessions");
await fs.mkdir(sessionsDir, { recursive: true });
@@ -354,7 +354,7 @@ describe("session-memory hook", () => {
content: sessionContent,
});
const cfg: ClawdbotConfig = {
const cfg: OpenClawConfig = {
agents: { defaults: { workspace: tempDir } },
};

View File

@@ -9,7 +9,7 @@ import fs from "node:fs/promises";
import path from "node:path";
import os from "node:os";
import { fileURLToPath } from "node:url";
import type { MoltbotConfig } from "../../../config/config.js";
import type { OpenClawConfig } from "../../../config/config.js";
import { resolveAgentWorkspaceDir } from "../../../agents/agent-scope.js";
import { resolveAgentIdFromSessionKey } from "../../../routing/session-key.js";
import { resolveHookConfig } from "../../config.js";
@@ -71,11 +71,11 @@ const saveSessionToMemory: HookHandler = async (event) => {
console.log("[session-memory] Hook triggered for /new command");
const context = event.context || {};
const cfg = context.cfg as MoltbotConfig | undefined;
const cfg = context.cfg as OpenClawConfig | undefined;
const agentId = resolveAgentIdFromSessionKey(event.sessionKey);
const workspaceDir = cfg
? resolveAgentWorkspaceDir(cfg, agentId)
: path.join(os.homedir(), "clawd");
: path.join(os.homedir(), ".openclaw", "workspace");
const memoryDir = path.join(workspaceDir, "memory");
await fs.mkdir(memoryDir, { recursive: true });
@@ -117,8 +117,8 @@ const saveSessionToMemory: HookHandler = async (event) => {
// Dynamically import the LLM slug generator (avoids module caching issues)
// When compiled, handler is at dist/hooks/bundled/session-memory/handler.js
// Going up ../.. puts us at dist/hooks/, so just add llm-slug-generator.js
const moltbotRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const slugGenPath = path.join(moltbotRoot, "llm-slug-generator.js");
const openclawRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const slugGenPath = path.join(openclawRoot, "llm-slug-generator.js");
const { generateSlugViaLLM } = await import(slugGenPath);
// Use LLM to generate a descriptive slug