Revert "Merge pull request #1951 from edxeth/feat/custom-agents"
This reverts commit47e300b17e, reversing changes made to243ce1b7e8.
This commit is contained in:
+2
-162
@@ -1,10 +1,5 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import {
|
||||
detectLikelyBuiltinAgentTypos,
|
||||
detectUnknownBuiltinAgentKeys,
|
||||
mergeConfigs,
|
||||
parseConfigPartially,
|
||||
} from "./plugin-config";
|
||||
import { mergeConfigs, parseConfigPartially } from "./plugin-config";
|
||||
import type { OhMyOpenCodeConfig } from "./config";
|
||||
|
||||
describe("mergeConfigs", () => {
|
||||
@@ -120,27 +115,6 @@ describe("mergeConfigs", () => {
|
||||
expect(result.disabled_hooks).toContain("session-recovery");
|
||||
expect(result.disabled_hooks?.length).toBe(3);
|
||||
});
|
||||
|
||||
it("should deep merge custom_agents", () => {
|
||||
const base: OhMyOpenCodeConfig = {
|
||||
custom_agents: {
|
||||
translator: { model: "google/gemini-3-flash-preview" },
|
||||
},
|
||||
}
|
||||
|
||||
const override: OhMyOpenCodeConfig = {
|
||||
custom_agents: {
|
||||
translator: { temperature: 0 },
|
||||
"database-architect": { model: "openai/gpt-5.3-codex" },
|
||||
},
|
||||
}
|
||||
|
||||
const result = mergeConfigs(base, override)
|
||||
|
||||
expect(result.custom_agents?.translator?.model).toBe("google/gemini-3-flash-preview")
|
||||
expect(result.custom_agents?.translator?.temperature).toBe(0)
|
||||
expect(result.custom_agents?.["database-architect"]?.model).toBe("openai/gpt-5.3-codex")
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -191,9 +165,7 @@ describe("parseConfigPartially", () => {
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.disabled_hooks).toEqual(["comment-checker"]);
|
||||
expect(result!.agents?.oracle?.model).toBe("openai/gpt-5.2");
|
||||
expect(result!.agents?.momus?.model).toBe("openai/gpt-5.2");
|
||||
expect((result!.agents as Record<string, unknown>)?.prometheus).toBeUndefined();
|
||||
expect(result!.agents).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should preserve valid agents when a non-agent section is invalid", () => {
|
||||
@@ -210,36 +182,6 @@ describe("parseConfigPartially", () => {
|
||||
expect(result!.agents?.oracle?.model).toBe("openai/gpt-5.2");
|
||||
expect(result!.disabled_hooks).toEqual(["not-a-real-hook"]);
|
||||
});
|
||||
|
||||
it("should preserve valid built-in agent entries when agents contains unknown keys", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
sisyphus: { model: "openai/gpt-5.3-codex" },
|
||||
sisyphuss: { model: "openai/gpt-5.3-codex" },
|
||||
},
|
||||
};
|
||||
|
||||
const result = parseConfigPartially(rawConfig);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.agents?.sisyphus?.model).toBe("openai/gpt-5.3-codex");
|
||||
expect((result!.agents as Record<string, unknown>)?.sisyphuss).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should preserve valid custom_agents entries when custom_agents contains reserved names", () => {
|
||||
const rawConfig = {
|
||||
custom_agents: {
|
||||
translator: { model: "google/gemini-3-flash-preview" },
|
||||
sisyphus: { model: "openai/gpt-5.3-codex" },
|
||||
},
|
||||
};
|
||||
|
||||
const result = parseConfigPartially(rawConfig);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.custom_agents?.translator?.model).toBe("google/gemini-3-flash-preview");
|
||||
expect((result!.custom_agents as Record<string, unknown>)?.sisyphus).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("completely invalid config", () => {
|
||||
@@ -295,105 +237,3 @@ describe("parseConfigPartially", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("detectLikelyBuiltinAgentTypos", () => {
|
||||
it("detects near-miss builtin agent keys", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
sisyphuss: { model: "openai/gpt-5.2" },
|
||||
},
|
||||
}
|
||||
|
||||
const warnings = detectLikelyBuiltinAgentTypos(rawConfig)
|
||||
|
||||
expect(warnings).toEqual([
|
||||
{
|
||||
key: "sisyphuss",
|
||||
suggestion: "sisyphus",
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it("suggests canonical key casing for OpenCode-Builder typos", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
"opencode-buildr": { model: "openai/gpt-5.2" },
|
||||
},
|
||||
}
|
||||
|
||||
const warnings = detectLikelyBuiltinAgentTypos(rawConfig)
|
||||
|
||||
expect(warnings).toEqual([
|
||||
{
|
||||
key: "opencode-buildr",
|
||||
suggestion: "OpenCode-Builder",
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it("does not flag valid custom agent names", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
translator: { model: "google/gemini-3-flash-preview" },
|
||||
},
|
||||
}
|
||||
|
||||
const warnings = detectLikelyBuiltinAgentTypos(rawConfig)
|
||||
|
||||
expect(warnings).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe("detectUnknownBuiltinAgentKeys", () => {
|
||||
it("returns unknown keys under agents", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
sisyphus: { model: "openai/gpt-5.2" },
|
||||
translator: { model: "google/gemini-3-flash-preview" },
|
||||
},
|
||||
}
|
||||
|
||||
const unknownKeys = detectUnknownBuiltinAgentKeys(rawConfig)
|
||||
|
||||
expect(unknownKeys).toEqual(["translator"])
|
||||
})
|
||||
|
||||
it("returns empty array when all keys are built-ins", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
sisyphus: { model: "openai/gpt-5.2" },
|
||||
prometheus: { model: "openai/gpt-5.2" },
|
||||
},
|
||||
}
|
||||
|
||||
const unknownKeys = detectUnknownBuiltinAgentKeys(rawConfig)
|
||||
|
||||
expect(unknownKeys).toEqual([])
|
||||
})
|
||||
|
||||
it("excludes typo keys when explicitly provided", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
sisyphuss: { model: "openai/gpt-5.2" },
|
||||
translator: { model: "google/gemini-3-flash-preview" },
|
||||
},
|
||||
}
|
||||
|
||||
const unknownKeys = detectUnknownBuiltinAgentKeys(rawConfig, ["sisyphuss"])
|
||||
|
||||
expect(unknownKeys).toEqual(["translator"])
|
||||
})
|
||||
|
||||
it("excludes typo keys case-insensitively", () => {
|
||||
const rawConfig = {
|
||||
agents: {
|
||||
Sisyphuss: { model: "openai/gpt-5.2" },
|
||||
translator: { model: "google/gemini-3-flash-preview" },
|
||||
},
|
||||
}
|
||||
|
||||
const unknownKeys = detectUnknownBuiltinAgentKeys(rawConfig, ["sisyphuss"])
|
||||
|
||||
expect(unknownKeys).toEqual(["translator"])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user