refactor: rename clawdbot to moltbot with legacy compat

This commit is contained in:
Peter Steinberger
2026-01-27 12:19:58 +00:00
parent 83460df96f
commit 6d16a658e5
1839 changed files with 11250 additions and 11199 deletions

View File

@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import type { ClawdbotConfig } from "../../config/config.js";
import type { MoltbotConfig } from "../../config/config.js";
import { handleSlackAction } from "./slack-actions.js";
const deleteSlackMessage = vi.fn(async () => ({}));
@@ -35,7 +35,7 @@ vi.mock("../../slack/actions.js", () => ({
describe("handleSlackAction", () => {
it("adds reactions", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
await handleSlackAction(
{
action: "react",
@@ -49,7 +49,7 @@ describe("handleSlackAction", () => {
});
it("strips channel: prefix for channelId params", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
await handleSlackAction(
{
action: "react",
@@ -63,7 +63,7 @@ describe("handleSlackAction", () => {
});
it("removes reactions on empty emoji", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
await handleSlackAction(
{
action: "react",
@@ -77,7 +77,7 @@ describe("handleSlackAction", () => {
});
it("removes reactions when remove flag set", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
await handleSlackAction(
{
action: "react",
@@ -92,7 +92,7 @@ describe("handleSlackAction", () => {
});
it("rejects removes without emoji", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
await expect(
handleSlackAction(
{
@@ -110,7 +110,7 @@ describe("handleSlackAction", () => {
it("respects reaction gating", async () => {
const cfg = {
channels: { slack: { botToken: "tok", actions: { reactions: false } } },
} as ClawdbotConfig;
} as MoltbotConfig;
await expect(
handleSlackAction(
{
@@ -125,7 +125,7 @@ describe("handleSlackAction", () => {
});
it("passes threadTs to sendSlackMessage for thread replies", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
await handleSlackAction(
{
action: "sendMessage",
@@ -142,7 +142,7 @@ describe("handleSlackAction", () => {
});
it("auto-injects threadTs from context when replyToMode=all", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction(
{
@@ -164,7 +164,7 @@ describe("handleSlackAction", () => {
});
it("replyToMode=first threads first message then stops", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
const hasRepliedRef = { value: false };
const context = {
@@ -199,7 +199,7 @@ describe("handleSlackAction", () => {
});
it("replyToMode=first marks hasRepliedRef even when threadTs is explicit", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
const hasRepliedRef = { value: false };
const context = {
@@ -237,7 +237,7 @@ describe("handleSlackAction", () => {
});
it("replyToMode=first without hasRepliedRef does not thread", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction({ action: "sendMessage", to: "channel:C123", content: "No ref" }, cfg, {
currentChannelId: "C123",
@@ -252,7 +252,7 @@ describe("handleSlackAction", () => {
});
it("does not auto-inject threadTs when replyToMode=off", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction(
{
@@ -274,7 +274,7 @@ describe("handleSlackAction", () => {
});
it("does not auto-inject threadTs when sending to different channel", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction(
{
@@ -296,7 +296,7 @@ describe("handleSlackAction", () => {
});
it("explicit threadTs overrides context threadTs", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction(
{
@@ -319,7 +319,7 @@ describe("handleSlackAction", () => {
});
it("handles channel target without prefix when replyToMode=all", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction(
{
@@ -341,7 +341,7 @@ describe("handleSlackAction", () => {
});
it("adds normalized timestamps to readMessages payloads", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
readSlackMessages.mockResolvedValueOnce({
messages: [{ ts: "1735689600.456", text: "hi" }],
hasMore: false,
@@ -358,7 +358,7 @@ describe("handleSlackAction", () => {
});
it("passes threadId through to readSlackMessages", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
readSlackMessages.mockClear();
readSlackMessages.mockResolvedValueOnce({ messages: [], hasMore: false });
@@ -372,7 +372,7 @@ describe("handleSlackAction", () => {
});
it("adds normalized timestamps to pin payloads", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as ClawdbotConfig;
const cfg = { channels: { slack: { botToken: "tok" } } } as MoltbotConfig;
listSlackPins.mockResolvedValueOnce([
{
type: "message",
@@ -393,7 +393,7 @@ describe("handleSlackAction", () => {
it("uses user token for reads when available", async () => {
const cfg = {
channels: { slack: { botToken: "xoxb-1", userToken: "xoxp-1" } },
} as ClawdbotConfig;
} as MoltbotConfig;
readSlackMessages.mockClear();
readSlackMessages.mockResolvedValueOnce({ messages: [], hasMore: false });
await handleSlackAction({ action: "readMessages", channelId: "C1" }, cfg);
@@ -404,7 +404,7 @@ describe("handleSlackAction", () => {
it("falls back to bot token for reads when user token missing", async () => {
const cfg = {
channels: { slack: { botToken: "xoxb-1" } },
} as ClawdbotConfig;
} as MoltbotConfig;
readSlackMessages.mockClear();
readSlackMessages.mockResolvedValueOnce({ messages: [], hasMore: false });
await handleSlackAction({ action: "readMessages", channelId: "C1" }, cfg);
@@ -415,7 +415,7 @@ describe("handleSlackAction", () => {
it("uses bot token for writes when userTokenReadOnly is true", async () => {
const cfg = {
channels: { slack: { botToken: "xoxb-1", userToken: "xoxp-1" } },
} as ClawdbotConfig;
} as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction({ action: "sendMessage", to: "channel:C1", content: "Hello" }, cfg);
const [, , opts] = sendSlackMessage.mock.calls[0] ?? [];
@@ -427,7 +427,7 @@ describe("handleSlackAction", () => {
channels: {
slack: { userToken: "xoxp-1", userTokenReadOnly: false },
},
} as ClawdbotConfig;
} as MoltbotConfig;
sendSlackMessage.mockClear();
await handleSlackAction({ action: "sendMessage", to: "channel:C1", content: "Hello" }, cfg);
const [, , opts] = sendSlackMessage.mock.calls[0] ?? [];