refactor(command-config): use getAgentListDisplayName for consistent naming
Update command config handler and tests to use getAgentListDisplayName for proper agent name resolution in command configurations. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -9,6 +9,7 @@ import type { PluginComponents } from "./plugin-components-loader";
|
|||||||
import { applyCommandConfig } from "./command-config-handler";
|
import { applyCommandConfig } from "./command-config-handler";
|
||||||
import {
|
import {
|
||||||
getAgentDisplayName,
|
getAgentDisplayName,
|
||||||
|
getAgentListDisplayName,
|
||||||
} from "../shared/agent-display-names";
|
} from "../shared/agent-display-names";
|
||||||
|
|
||||||
function createPluginComponents(): PluginComponents {
|
function createPluginComponents(): PluginComponents {
|
||||||
@@ -107,7 +108,7 @@ describe("applyCommandConfig", () => {
|
|||||||
expect(commandConfig["agents-global-skill"]?.description).toContain("Agents global skill");
|
expect(commandConfig["agents-global-skill"]?.description).toContain("Agents global skill");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("normalizes Atlas command agents to the clean display name used by opencode command routing", async () => {
|
test("normalizes Atlas command agents to the runtime list name used by opencode command routing", async () => {
|
||||||
// given
|
// given
|
||||||
loadBuiltinCommandsSpy.mockReturnValue({
|
loadBuiltinCommandsSpy.mockReturnValue({
|
||||||
"start-work": {
|
"start-work": {
|
||||||
@@ -129,10 +130,10 @@ describe("applyCommandConfig", () => {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
const commandConfig = config.command as Record<string, { agent?: string }>;
|
const commandConfig = config.command as Record<string, { agent?: string }>;
|
||||||
expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"));
|
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas"));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("normalizes legacy display-name command agents to the clean display name", async () => {
|
test("normalizes legacy display-name command agents to the runtime list name", async () => {
|
||||||
// given
|
// given
|
||||||
loadBuiltinCommandsSpy.mockReturnValue({
|
loadBuiltinCommandsSpy.mockReturnValue({
|
||||||
"start-work": {
|
"start-work": {
|
||||||
@@ -154,6 +155,6 @@ describe("applyCommandConfig", () => {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
const commandConfig = config.command as Record<string, { agent?: string }>;
|
const commandConfig = config.command as Record<string, { agent?: string }>;
|
||||||
expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"));
|
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { OhMyOpenCodeConfig } from "../config";
|
import type { OhMyOpenCodeConfig } from "../config";
|
||||||
import {
|
import {
|
||||||
getAgentConfigKey,
|
getAgentConfigKey,
|
||||||
getAgentDisplayName,
|
getAgentListDisplayName,
|
||||||
} from "../shared/agent-display-names";
|
} from "../shared/agent-display-names";
|
||||||
import {
|
import {
|
||||||
loadUserCommands,
|
loadUserCommands,
|
||||||
@@ -99,7 +99,7 @@ export async function applyCommandConfig(params: {
|
|||||||
function remapCommandAgentFields(commands: Record<string, Record<string, unknown>>): void {
|
function remapCommandAgentFields(commands: Record<string, Record<string, unknown>>): void {
|
||||||
for (const cmd of Object.values(commands)) {
|
for (const cmd of Object.values(commands)) {
|
||||||
if (cmd?.agent && typeof cmd.agent === "string") {
|
if (cmd?.agent && typeof cmd.agent === "string") {
|
||||||
cmd.agent = getAgentDisplayName(getAgentConfigKey(cmd.agent));
|
cmd.agent = getAgentListDisplayName(getAgentConfigKey(cmd.agent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user