diff --git a/packages/gittensory-mcp/bin/gittensory-mcp.js b/packages/gittensory-mcp/bin/gittensory-mcp.js index 2733791183..2087bb2dcd 100755 --- a/packages/gittensory-mcp/bin/gittensory-mcp.js +++ b/packages/gittensory-mcp/bin/gittensory-mcp.js @@ -2004,9 +2004,8 @@ function initClient(options) { function resolveAgentProfile(profileId) { if (!profileId) return null; const id = String(profileId).trim().toLowerCase(); - const profile = AGENT_PROFILES[id]; - if (!profile) throw new Error(`Unsupported agent profile: ${profileId}. Use ${AGENT_PROFILE_IDS.join(", ")}.`); - return profile; + if (!Object.hasOwn(AGENT_PROFILES, id)) throw new Error(`Unsupported agent profile: ${profileId}. Use ${AGENT_PROFILE_IDS.join(", ")}.`); + return AGENT_PROFILES[id]; } function formatAgentProfile(profile) { diff --git a/test/unit/mcp-cli.test.ts b/test/unit/mcp-cli.test.ts index 72e5401808..91359b9bd5 100644 --- a/test/unit/mcp-cli.test.ts +++ b/test/unit/mcp-cli.test.ts @@ -1106,7 +1106,10 @@ describe("gittensory-mcp CLI", () => { }); it("rejects unsupported agent profiles", () => { - expect(() => run(["init-client", "--print", "codex", "--agent-profile", "autopilot"])).toThrow(/Unsupported agent profile/); + for (const profile of ["autopilot", "__proto__", "constructor"]) { + expect(() => run(["init-client", "--print", "codex", "--agent-profile", profile])).toThrow(/Unsupported agent profile/); + expect(() => run(["init-client", "--print", "codex", "--agent-profile", profile, "--json"])).toThrow(/Unsupported agent profile/); + } }); it("reports the package version via version, --version, and -v", () => {