diff --git a/src/mcp/cli-suffix.test.ts b/src/mcp/cli-suffix.test.ts index f0435d430..9e8d60ab6 100644 --- a/src/mcp/cli-suffix.test.ts +++ b/src/mcp/cli-suffix.test.ts @@ -29,4 +29,21 @@ describe("hasCliSuffix", () => { // then expect(result).toBe(false) }) + + // regression: issue #4220 — ast_grep MCP failed on Windows because the older + // dist used `path.endsWith("dist/cli.js")`. `hasCliSuffix` must match Windows + // backslash paths against the POSIX-shaped `dist/cli.js` suffix. + it("matches the ast_grep dist cli suffix on Windows path separators", () => { + // given + const windowsPath = "C:\\Users\\test\\AppData\\Local\\cache\\oh-my-opencode\\dist\\packages\\ast-grep-mcp\\dist\\cli.js" + + // when: matched against just the trailing `dist/cli.js` segment + const matchesShortSuffix = hasCliSuffix(windowsPath, "dist/cli.js") + // and the fully-qualified package suffix + const matchesPackageSuffix = hasCliSuffix(windowsPath, "packages/ast-grep-mcp/dist/cli.js") + + // then: both must succeed despite the backslashes + expect(matchesShortSuffix).toBe(true) + expect(matchesPackageSuffix).toBe(true) + }) })