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

@@ -7,42 +7,42 @@ describe("parseCliProfileArgs", () => {
it("leaves gateway --dev for subcommands", () => {
const res = parseCliProfileArgs([
"node",
"moltbot",
"openclaw",
"gateway",
"--dev",
"--allow-unconfigured",
]);
if (!res.ok) throw new Error(res.error);
expect(res.profile).toBeNull();
expect(res.argv).toEqual(["node", "moltbot", "gateway", "--dev", "--allow-unconfigured"]);
expect(res.argv).toEqual(["node", "openclaw", "gateway", "--dev", "--allow-unconfigured"]);
});
it("still accepts global --dev before subcommand", () => {
const res = parseCliProfileArgs(["node", "moltbot", "--dev", "gateway"]);
const res = parseCliProfileArgs(["node", "openclaw", "--dev", "gateway"]);
if (!res.ok) throw new Error(res.error);
expect(res.profile).toBe("dev");
expect(res.argv).toEqual(["node", "moltbot", "gateway"]);
expect(res.argv).toEqual(["node", "openclaw", "gateway"]);
});
it("parses --profile value and strips it", () => {
const res = parseCliProfileArgs(["node", "moltbot", "--profile", "work", "status"]);
const res = parseCliProfileArgs(["node", "openclaw", "--profile", "work", "status"]);
if (!res.ok) throw new Error(res.error);
expect(res.profile).toBe("work");
expect(res.argv).toEqual(["node", "moltbot", "status"]);
expect(res.argv).toEqual(["node", "openclaw", "status"]);
});
it("rejects missing profile value", () => {
const res = parseCliProfileArgs(["node", "moltbot", "--profile"]);
const res = parseCliProfileArgs(["node", "openclaw", "--profile"]);
expect(res.ok).toBe(false);
});
it("rejects combining --dev with --profile (dev first)", () => {
const res = parseCliProfileArgs(["node", "moltbot", "--dev", "--profile", "work", "status"]);
const res = parseCliProfileArgs(["node", "openclaw", "--dev", "--profile", "work", "status"]);
expect(res.ok).toBe(false);
});
it("rejects combining --dev with --profile (profile first)", () => {
const res = parseCliProfileArgs(["node", "moltbot", "--profile", "work", "--dev", "status"]);
const res = parseCliProfileArgs(["node", "openclaw", "--profile", "work", "--dev", "status"]);
expect(res.ok).toBe(false);
});
});
@@ -55,85 +55,85 @@ describe("applyCliProfileEnv", () => {
env,
homedir: () => "/home/peter",
});
const expectedStateDir = path.join("/home/peter", ".clawdbot-dev");
expect(env.CLAWDBOT_PROFILE).toBe("dev");
expect(env.CLAWDBOT_STATE_DIR).toBe(expectedStateDir);
expect(env.CLAWDBOT_CONFIG_PATH).toBe(path.join(expectedStateDir, "moltbot.json"));
expect(env.CLAWDBOT_GATEWAY_PORT).toBe("19001");
const expectedStateDir = path.join("/home/peter", ".openclaw-dev");
expect(env.OPENCLAW_PROFILE).toBe("dev");
expect(env.OPENCLAW_STATE_DIR).toBe(expectedStateDir);
expect(env.OPENCLAW_CONFIG_PATH).toBe(path.join(expectedStateDir, "openclaw.json"));
expect(env.OPENCLAW_GATEWAY_PORT).toBe("19001");
});
it("does not override explicit env values", () => {
const env: Record<string, string | undefined> = {
CLAWDBOT_STATE_DIR: "/custom",
CLAWDBOT_GATEWAY_PORT: "19099",
OPENCLAW_STATE_DIR: "/custom",
OPENCLAW_GATEWAY_PORT: "19099",
};
applyCliProfileEnv({
profile: "dev",
env,
homedir: () => "/home/peter",
});
expect(env.CLAWDBOT_STATE_DIR).toBe("/custom");
expect(env.CLAWDBOT_GATEWAY_PORT).toBe("19099");
expect(env.CLAWDBOT_CONFIG_PATH).toBe(path.join("/custom", "moltbot.json"));
expect(env.OPENCLAW_STATE_DIR).toBe("/custom");
expect(env.OPENCLAW_GATEWAY_PORT).toBe("19099");
expect(env.OPENCLAW_CONFIG_PATH).toBe(path.join("/custom", "openclaw.json"));
});
});
describe("formatCliCommand", () => {
it("returns command unchanged when no profile is set", () => {
expect(formatCliCommand("moltbot doctor --fix", {})).toBe("moltbot doctor --fix");
expect(formatCliCommand("openclaw doctor --fix", {})).toBe("openclaw doctor --fix");
});
it("returns command unchanged when profile is default", () => {
expect(formatCliCommand("moltbot doctor --fix", { CLAWDBOT_PROFILE: "default" })).toBe(
"moltbot doctor --fix",
expect(formatCliCommand("openclaw doctor --fix", { OPENCLAW_PROFILE: "default" })).toBe(
"openclaw doctor --fix",
);
});
it("returns command unchanged when profile is Default (case-insensitive)", () => {
expect(formatCliCommand("moltbot doctor --fix", { CLAWDBOT_PROFILE: "Default" })).toBe(
"moltbot doctor --fix",
expect(formatCliCommand("openclaw doctor --fix", { OPENCLAW_PROFILE: "Default" })).toBe(
"openclaw doctor --fix",
);
});
it("returns command unchanged when profile is invalid", () => {
expect(formatCliCommand("moltbot doctor --fix", { CLAWDBOT_PROFILE: "bad profile" })).toBe(
"moltbot doctor --fix",
expect(formatCliCommand("openclaw doctor --fix", { OPENCLAW_PROFILE: "bad profile" })).toBe(
"openclaw doctor --fix",
);
});
it("returns command unchanged when --profile is already present", () => {
expect(
formatCliCommand("moltbot --profile work doctor --fix", { CLAWDBOT_PROFILE: "work" }),
).toBe("moltbot --profile work doctor --fix");
formatCliCommand("openclaw --profile work doctor --fix", { OPENCLAW_PROFILE: "work" }),
).toBe("openclaw --profile work doctor --fix");
});
it("returns command unchanged when --dev is already present", () => {
expect(formatCliCommand("moltbot --dev doctor", { CLAWDBOT_PROFILE: "dev" })).toBe(
"moltbot --dev doctor",
expect(formatCliCommand("openclaw --dev doctor", { OPENCLAW_PROFILE: "dev" })).toBe(
"openclaw --dev doctor",
);
});
it("inserts --profile flag when profile is set", () => {
expect(formatCliCommand("moltbot doctor --fix", { CLAWDBOT_PROFILE: "work" })).toBe(
"moltbot --profile work doctor --fix",
expect(formatCliCommand("openclaw doctor --fix", { OPENCLAW_PROFILE: "work" })).toBe(
"openclaw --profile work doctor --fix",
);
});
it("trims whitespace from profile", () => {
expect(formatCliCommand("moltbot doctor --fix", { CLAWDBOT_PROFILE: " jbclawd " })).toBe(
"moltbot --profile jbclawd doctor --fix",
expect(formatCliCommand("openclaw doctor --fix", { OPENCLAW_PROFILE: " jbopenclaw " })).toBe(
"openclaw --profile jbopenclaw doctor --fix",
);
});
it("handles command with no args after moltbot", () => {
expect(formatCliCommand("moltbot", { CLAWDBOT_PROFILE: "test" })).toBe(
"moltbot --profile test",
it("handles command with no args after openclaw", () => {
expect(formatCliCommand("openclaw", { OPENCLAW_PROFILE: "test" })).toBe(
"openclaw --profile test",
);
});
it("handles pnpm wrapper", () => {
expect(formatCliCommand("pnpm moltbot doctor", { CLAWDBOT_PROFILE: "work" })).toBe(
"pnpm moltbot --profile work doctor",
expect(formatCliCommand("pnpm openclaw doctor", { OPENCLAW_PROFILE: "work" })).toBe(
"pnpm openclaw --profile work doctor",
);
});
});