Skip to content

Commit 6fa24e9

Browse files
committed
Address more PR review comments
1 parent c3abc68 commit 6fa24e9

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

server/dist/codeql-development-mcp-server.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/dist/codeql-development-mcp-server.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "2.23.9",
44
"description": "An MCP server supporting LLM requests for CodeQL development tools and resources.",
55
"main": "dist/codeql-development-mcp-server.js",
6-
"types": "dist/codeql-development-mcp-server.d.ts",
76
"type": "module",
87
"bin": {
98
"codeql-development-mcp-server": "./dist/codeql-development-mcp-server.js"

server/src/lib/cli-executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export function resolveCodeQLBinary(): string {
166166
}
167167

168168
resolvedCodeQLDir = dirname(envPath);
169-
resolvedBinaryResult = envPath;
169+
resolvedBinaryResult = 'codeql';
170170
logger.info(`CodeQL CLI resolved via CODEQL_PATH: ${envPath} (dir: ${resolvedCodeQLDir})`);
171171
return resolvedBinaryResult;
172172
}

server/src/utils/package-paths.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ const __dirname = dirname(__filename);
2525
/**
2626
* Detect whether the current __dirname looks like source code (`src/lib` or
2727
* `src/utils`) vs a bundled flat output directory (`dist/`).
28+
*
29+
* Uses a tail-of-path check so that unrelated `/src/` segments earlier in the
30+
* install path (e.g. `~/src/project/node_modules/.../dist`) don't cause a
31+
* false positive.
2832
*/
2933
function isRunningFromSource(dir: string): boolean {
3034
const normalized = dir.replace(/\\/g, '/');
31-
return normalized.includes('/src/');
35+
return /\/src(\/[^/]+)?$/.test(normalized);
3236
}
3337

3438
/**

server/test/src/lib/cli-executor.test.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
*/
44

55
import { describe, it, expect, beforeAll, afterAll, afterEach, vi } from 'vitest';
6-
import { mkdirSync, writeFileSync, rmSync, chmodSync } from 'fs';
6+
import { writeFileSync, rmSync, chmodSync } from 'fs';
77
import { execFileSync } from 'child_process';
88
import { join } from 'path';
9+
import { createProjectTempDir } from '../../../src/utils/temp-dir';
910
import {
1011
buildCodeQLArgs,
1112
buildQLTArgs,
@@ -603,17 +604,16 @@ describe('resolveCodeQLBinary', () => {
603604
expect(getResolvedCodeQLDir()).toBeNull();
604605
});
605606

606-
it('should return the full path and set dir to parent directory', () => {
607+
it('should return bare codeql command and set dir to parent directory', () => {
607608
// Create a temporary file named "codeql" to pass validation
608-
const tmpDir = join(process.cwd(), '.tmp', 'codeql-path-test');
609+
const tmpDir = createProjectTempDir('codeql-path-test-');
609610
const codeqlPath = join(tmpDir, 'codeql');
610-
mkdirSync(tmpDir, { recursive: true });
611611
writeFileSync(codeqlPath, '#!/bin/sh\necho test', { mode: 0o755 });
612612

613613
try {
614614
process.env.CODEQL_PATH = codeqlPath;
615615
const result = resolveCodeQLBinary();
616-
expect(result).toBe(codeqlPath);
616+
expect(result).toBe('codeql');
617617
expect(getResolvedCodeQLDir()).toBe(tmpDir);
618618
} finally {
619619
rmSync(tmpDir, { recursive: true, force: true });
@@ -696,9 +696,8 @@ describe('CODEQL_PATH - PATH prepend integration', () => {
696696

697697
it('should prepend CODEQL_PATH directory to child process PATH', async () => {
698698
// Create a temporary directory with a fake "codeql" script
699-
const tmpDir = join(process.cwd(), '.tmp', 'codeql-path-prepend-test');
699+
const tmpDir = createProjectTempDir('codeql-path-prepend-test-');
700700
const codeqlPath = join(tmpDir, 'codeql');
701-
mkdirSync(tmpDir, { recursive: true });
702701
writeFileSync(codeqlPath, '#!/bin/sh\necho test', { mode: 0o755 });
703702
chmodSync(codeqlPath, 0o755);
704703

@@ -755,9 +754,8 @@ describe('validateCodeQLBinaryReachable', () => {
755754

756755
it('should throw a descriptive error when codeql is not reachable', async () => {
757756
// Create a temporary directory with a fake "codeql" that exits with error
758-
const tmpDir = join(process.cwd(), '.tmp', 'codeql-unreachable-test');
757+
const tmpDir = createProjectTempDir('codeql-unreachable-test-');
759758
const codeqlPath = join(tmpDir, 'codeql');
760-
mkdirSync(tmpDir, { recursive: true });
761759
// Create a script that fails immediately
762760
writeFileSync(codeqlPath, '#!/bin/sh\nexit 1', { mode: 0o755 });
763761
chmodSync(codeqlPath, 0o755);
@@ -773,9 +771,8 @@ describe('validateCodeQLBinaryReachable', () => {
773771
});
774772

775773
it('should include guidance about CODEQL_PATH in error message', async () => {
776-
const tmpDir = join(process.cwd(), '.tmp', 'codeql-guidance-test');
774+
const tmpDir = createProjectTempDir('codeql-guidance-test-');
777775
const codeqlPath = join(tmpDir, 'codeql');
778-
mkdirSync(tmpDir, { recursive: true });
779776
writeFileSync(codeqlPath, '#!/bin/sh\nexit 1', { mode: 0o755 });
780777
chmodSync(codeqlPath, 0o755);
781778

0 commit comments

Comments
 (0)