chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -22,8 +22,7 @@ import {
|
||||
writeOAuthCredentials,
|
||||
} from "./onboard-auth.js";
|
||||
|
||||
const authProfilePathFor = (agentDir: string) =>
|
||||
path.join(agentDir, "auth-profiles.json");
|
||||
const authProfilePathFor = (agentDir: string) => path.join(agentDir, "auth-profiles.json");
|
||||
const requireAgentDir = () => {
|
||||
const agentDir = process.env.CLAWDBOT_AGENT_DIR;
|
||||
if (!agentDir) throw new Error("CLAWDBOT_AGENT_DIR not set");
|
||||
@@ -85,16 +84,7 @@ describe("writeOAuthCredentials", () => {
|
||||
});
|
||||
|
||||
await expect(
|
||||
fs.readFile(
|
||||
path.join(
|
||||
tempStateDir,
|
||||
"agents",
|
||||
"main",
|
||||
"agent",
|
||||
"auth-profiles.json",
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
fs.readFile(path.join(tempStateDir, "agents", "main", "agent", "auth-profiles.json"), "utf8"),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -128,9 +118,7 @@ describe("setMinimaxApiKey", () => {
|
||||
});
|
||||
|
||||
it("writes to CLAWDBOT_AGENT_DIR when set", async () => {
|
||||
tempStateDir = await fs.mkdtemp(
|
||||
path.join(os.tmpdir(), "clawdbot-minimax-"),
|
||||
);
|
||||
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-minimax-"));
|
||||
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
||||
process.env.CLAWDBOT_AGENT_DIR = path.join(tempStateDir, "custom-agent");
|
||||
process.env.PI_CODING_AGENT_DIR = process.env.CLAWDBOT_AGENT_DIR;
|
||||
@@ -140,10 +128,7 @@ describe("setMinimaxApiKey", () => {
|
||||
const customAuthPath = authProfilePathFor(requireAgentDir());
|
||||
const raw = await fs.readFile(customAuthPath, "utf8");
|
||||
const parsed = JSON.parse(raw) as {
|
||||
profiles?: Record<
|
||||
string,
|
||||
{ type?: string; provider?: string; key?: string }
|
||||
>;
|
||||
profiles?: Record<string, { type?: string; provider?: string; key?: string }>;
|
||||
};
|
||||
expect(parsed.profiles?.["minimax:default"]).toMatchObject({
|
||||
type: "api_key",
|
||||
@@ -152,16 +137,7 @@ describe("setMinimaxApiKey", () => {
|
||||
});
|
||||
|
||||
await expect(
|
||||
fs.readFile(
|
||||
path.join(
|
||||
tempStateDir,
|
||||
"agents",
|
||||
"main",
|
||||
"agent",
|
||||
"auth-profiles.json",
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
fs.readFile(path.join(tempStateDir, "agents", "main", "agent", "auth-profiles.json"), "utf8"),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -184,10 +160,7 @@ describe("applyAuthProfileConfig", () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(next.auth?.order?.anthropic).toEqual([
|
||||
"anthropic:claude-cli",
|
||||
"anthropic:default",
|
||||
]);
|
||||
expect(next.auth?.order?.anthropic).toEqual(["anthropic:claude-cli", "anthropic:default"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -202,9 +175,7 @@ describe("applyMinimaxApiConfig", () => {
|
||||
|
||||
it("sets correct primary model", () => {
|
||||
const cfg = applyMinimaxApiConfig({}, "MiniMax-M2.1-lightning");
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(
|
||||
"minimax/MiniMax-M2.1-lightning",
|
||||
);
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe("minimax/MiniMax-M2.1-lightning");
|
||||
});
|
||||
|
||||
it("does not set reasoning for non-reasoning models", () => {
|
||||
@@ -220,16 +191,12 @@ describe("applyMinimaxApiConfig", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual([
|
||||
"anthropic/claude-opus-4-5",
|
||||
]);
|
||||
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual(["anthropic/claude-opus-4-5"]);
|
||||
});
|
||||
|
||||
it("adds model alias", () => {
|
||||
const cfg = applyMinimaxApiConfig({}, "MiniMax-M2.1");
|
||||
expect(cfg.agents?.defaults?.models?.["minimax/MiniMax-M2.1"]?.alias).toBe(
|
||||
"Minimax",
|
||||
);
|
||||
expect(cfg.agents?.defaults?.models?.["minimax/MiniMax-M2.1"]?.alias).toBe("Minimax");
|
||||
});
|
||||
|
||||
it("preserves existing model params when adding alias", () => {
|
||||
@@ -248,9 +215,10 @@ describe("applyMinimaxApiConfig", () => {
|
||||
},
|
||||
"MiniMax-M2.1",
|
||||
);
|
||||
expect(
|
||||
cfg.agents?.defaults?.models?.["minimax/MiniMax-M2.1"],
|
||||
).toMatchObject({ alias: "Minimax", params: { custom: "value" } });
|
||||
expect(cfg.agents?.defaults?.models?.["minimax/MiniMax-M2.1"]).toMatchObject({
|
||||
alias: "Minimax",
|
||||
params: { custom: "value" },
|
||||
});
|
||||
});
|
||||
|
||||
it("merges existing minimax provider models", () => {
|
||||
@@ -276,9 +244,7 @@ describe("applyMinimaxApiConfig", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(cfg.models?.providers?.minimax?.baseUrl).toBe(
|
||||
"https://api.minimax.io/anthropic",
|
||||
);
|
||||
expect(cfg.models?.providers?.minimax?.baseUrl).toBe("https://api.minimax.io/anthropic");
|
||||
expect(cfg.models?.providers?.minimax?.api).toBe("anthropic-messages");
|
||||
expect(cfg.models?.providers?.minimax?.apiKey).toBe("old-key");
|
||||
expect(cfg.models?.providers?.minimax?.models.map((m) => m.id)).toEqual([
|
||||
@@ -327,9 +293,7 @@ describe("applyMinimaxApiProviderConfig", () => {
|
||||
const cfg = applyMinimaxApiProviderConfig({
|
||||
agents: { defaults: { model: { primary: "anthropic/claude-opus-4-5" } } },
|
||||
});
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(
|
||||
"anthropic/claude-opus-4-5",
|
||||
);
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe("anthropic/claude-opus-4-5");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -344,9 +308,7 @@ describe("applySyntheticConfig", () => {
|
||||
|
||||
it("sets correct primary model", () => {
|
||||
const cfg = applySyntheticConfig({});
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(
|
||||
SYNTHETIC_DEFAULT_MODEL_REF,
|
||||
);
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(SYNTHETIC_DEFAULT_MODEL_REF);
|
||||
});
|
||||
|
||||
it("merges existing synthetic provider models", () => {
|
||||
@@ -372,9 +334,7 @@ describe("applySyntheticConfig", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(cfg.models?.providers?.synthetic?.baseUrl).toBe(
|
||||
"https://api.synthetic.new/anthropic",
|
||||
);
|
||||
expect(cfg.models?.providers?.synthetic?.baseUrl).toBe("https://api.synthetic.new/anthropic");
|
||||
expect(cfg.models?.providers?.synthetic?.api).toBe("anthropic-messages");
|
||||
expect(cfg.models?.providers?.synthetic?.apiKey).toBe("old-key");
|
||||
const ids = cfg.models?.providers?.synthetic?.models.map((m) => m.id);
|
||||
@@ -400,18 +360,14 @@ describe("applyOpencodeZenProviderConfig", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
cfg.agents?.defaults?.models?.["opencode/claude-opus-4-5"]?.alias,
|
||||
).toBe("My Opus");
|
||||
expect(cfg.agents?.defaults?.models?.["opencode/claude-opus-4-5"]?.alias).toBe("My Opus");
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyOpencodeZenConfig", () => {
|
||||
it("sets correct primary model", () => {
|
||||
const cfg = applyOpencodeZenConfig({});
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(
|
||||
"opencode/claude-opus-4-5",
|
||||
);
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe("opencode/claude-opus-4-5");
|
||||
});
|
||||
|
||||
it("preserves existing model fallbacks", () => {
|
||||
@@ -422,9 +378,7 @@ describe("applyOpencodeZenConfig", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual([
|
||||
"anthropic/claude-opus-4-5",
|
||||
]);
|
||||
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual(["anthropic/claude-opus-4-5"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -445,18 +399,14 @@ describe("applyOpenrouterProviderConfig", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
cfg.agents?.defaults?.models?.[OPENROUTER_DEFAULT_MODEL_REF]?.alias,
|
||||
).toBe("Router");
|
||||
expect(cfg.agents?.defaults?.models?.[OPENROUTER_DEFAULT_MODEL_REF]?.alias).toBe("Router");
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyOpenrouterConfig", () => {
|
||||
it("sets correct primary model", () => {
|
||||
const cfg = applyOpenrouterConfig({});
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(
|
||||
OPENROUTER_DEFAULT_MODEL_REF,
|
||||
);
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(OPENROUTER_DEFAULT_MODEL_REF);
|
||||
});
|
||||
|
||||
it("preserves existing model fallbacks", () => {
|
||||
@@ -467,8 +417,6 @@ describe("applyOpenrouterConfig", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual([
|
||||
"anthropic/claude-opus-4-5",
|
||||
]);
|
||||
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual(["anthropic/claude-opus-4-5"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user