Skip to content

Commit 11ea9ac

Browse files
committed
Logging fixes for pack installer & rel path
1 parent cd2c6de commit 11ea9ac

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

extensions/vscode/__mocks__/vscode.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export const workspace = {
8282
onDidCreateFiles: noopReturn({ dispose: noop }),
8383
onDidSaveTextDocument: noopReturn({ dispose: noop }),
8484
fs: { stat: noop, readFile: noop, readDirectory: noop },
85+
asRelativePath: (pathOrUri: any) => {
86+
const p = typeof pathOrUri === 'string' ? pathOrUri : pathOrUri?.fsPath ?? String(pathOrUri);
87+
return p;
88+
},
89+
updateWorkspaceFolders: () => true,
8590
};
8691

8792
export const window = {

extensions/vscode/src/bridge/database-watcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ export class DatabaseWatcher extends DisposableObject {
6161
const dbRoot = ymlPath.replace(/\/codeql-database\.yml$/, '');
6262
if (!this.knownDatabases.has(dbRoot)) {
6363
this.knownDatabases.add(dbRoot);
64-
this.logger.info(`Database discovered: ${dbRoot}`);
64+
this.logger.info(`Database discovered: ${vscode.workspace.asRelativePath(dbRoot)}`);
6565
this._onDidChange.fire();
6666
}
6767
}
6868

6969
private handleDatabaseRemoved(ymlPath: string): void {
7070
const dbRoot = ymlPath.replace(/\/codeql-database\.yml$/, '');
7171
if (this.knownDatabases.delete(dbRoot)) {
72-
this.logger.info(`Database removed: ${dbRoot}`);
72+
this.logger.info(`Database removed: ${vscode.workspace.asRelativePath(dbRoot)}`);
7373
this._onDidChange.fire();
7474
}
7575
}

extensions/vscode/src/bridge/query-results-watcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class QueryResultsWatcher extends DisposableObject {
2626
const bqrsWatcher = vscode.workspace.createFileSystemWatcher('**/*.bqrs');
2727
this.push(bqrsWatcher);
2828
bqrsWatcher.onDidCreate((uri) => {
29-
this.logger.info(`Query result (BQRS) created: ${uri.fsPath}`);
29+
this.logger.info(`Query result (BQRS) created: ${vscode.workspace.asRelativePath(uri)}`);
3030
this._onDidChange.fire();
3131
});
3232

@@ -36,7 +36,7 @@ export class QueryResultsWatcher extends DisposableObject {
3636
);
3737
this.push(sarifWatcher);
3838
sarifWatcher.onDidCreate((uri) => {
39-
this.logger.info(`Query result (SARIF) created: ${uri.fsPath}`);
39+
this.logger.info(`Query result (SARIF) created: ${vscode.workspace.asRelativePath(uri)}`);
4040
this._onDidChange.fire();
4141
});
4242

extensions/vscode/src/server/pack-installer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class PackInstaller extends DisposableObject {
176176
return;
177177
}
178178
this.logger.info(
179-
'Pack install did not succeed for all languages — falling back to bundled pack install.',
179+
'Pack download did not succeed for all languages — falling back to bundled pack install.',
180180
);
181181
} else if (actualCliVersion && actualCliVersion === targetCliVersion) {
182182
this.logger.info(
@@ -210,28 +210,28 @@ export class PackInstaller extends DisposableObject {
210210
}
211211

212212
this.logger.info(
213-
`Installing ql-mcp tool query packs v${packVersion} for CodeQL CLI ${cliVersion}...`,
213+
`Downloading ql-mcp tool query packs v${packVersion} for CodeQL CLI ${cliVersion}...`,
214214
);
215215

216216
let allSucceeded = true;
217217
let successCount = 0;
218218
for (const lang of languages) {
219219
const packRef =
220220
`${PackInstaller.PACK_SCOPE}/ql-mcp-${lang}-tools-src@${packVersion}`;
221-
this.logger.info(`Installing ${packRef}...`);
221+
this.logger.info(`Downloading ${packRef}...`);
222222
try {
223223
await this.runCodeqlPackDownload(codeqlPath, packRef);
224-
this.logger.info(`Installed ${packRef}.`);
224+
this.logger.info(`Downloaded ${packRef}.`);
225225
successCount++;
226226
} catch (err) {
227227
this.logger.error(
228-
`Failed to install ${packRef}: ${err instanceof Error ? err.message : String(err)}`,
228+
`Failed to download ${packRef}: ${err instanceof Error ? err.message : String(err)}`,
229229
);
230230
allSucceeded = false;
231231
}
232232
}
233233
this.logger.info(
234-
`Pack install complete: ${successCount}/${languages.length} languages succeeded.`,
234+
`Pack download complete: ${successCount}/${languages.length} languages succeeded.`,
235235
);
236236
return allSucceeded;
237237
}

extensions/vscode/test/server/pack-installer.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,23 +456,23 @@ describe('PackInstaller', () => {
456456
);
457457
});
458458

459-
it('should use install terminology (not download) in pack download logs', async () => {
459+
it('should use download terminology in pack download logs', async () => {
460460
cliResolver.getCliVersion.mockReturnValue('2.24.1');
461461
serverManager.getExtensionVersion.mockReturnValue('2.25.1-next.1');
462462

463463
await installer.installAll({ languages: ['javascript'] });
464464

465-
// Should say "Installing" and "Installed", not "Downloading" / "Downloaded"
465+
// Should say "Downloading" and "Downloaded", not "Installing" / "Installed"
466466
expect(logger.info).toHaveBeenCalledWith(
467-
expect.stringContaining('Installing advanced-security/ql-mcp-javascript-tools-src@2.24.1'),
467+
expect.stringContaining('Downloading advanced-security/ql-mcp-javascript-tools-src@2.24.1'),
468468
);
469469
expect(logger.info).toHaveBeenCalledWith(
470-
expect.stringContaining('Installed advanced-security/ql-mcp-javascript-tools-src@2.24.1'),
470+
expect.stringContaining('Downloaded advanced-security/ql-mcp-javascript-tools-src@2.24.1'),
471471
);
472-
// Should NOT use "Downloading" or "Downloaded" for individual packs
472+
// Should NOT use "Installing" or "Installed" for individual packs
473473
for (const call of logger.info.mock.calls) {
474-
expect(String(call[0])).not.toMatch(/^Downloading advanced-security/);
475-
expect(String(call[0])).not.toMatch(/^Downloaded advanced-security/);
474+
expect(String(call[0])).not.toMatch(/^Installing advanced-security/);
475+
expect(String(call[0])).not.toMatch(/^Installed advanced-security/);
476476
}
477477
});
478478

server/test/src/prompts/workflow-prompts.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ describe('Workflow Prompts', () => {
563563
expect(result.success).toBe(false);
564564
});
565565

566-
it('should accept missing language (auto-derivable from pack metadata)', () => {
566+
it('should accept missing language (optional field)', () => {
567567
const result = explainCodeqlQuerySchema.safeParse({
568568
queryPath: '/q.ql',
569569
});
@@ -633,7 +633,7 @@ describe('Workflow Prompts', () => {
633633
expect(result.success).toBe(false);
634634
});
635635

636-
it('should accept missing language (auto-derivable from pack metadata)', () => {
636+
it('should accept missing language (optional field)', () => {
637637
const result = documentCodeqlQuerySchema.safeParse({ queryPath: '/q.ql' });
638638
expect(result.success).toBe(true);
639639
});
@@ -698,7 +698,7 @@ describe('Workflow Prompts', () => {
698698
}
699699
});
700700

701-
it('should accept missing language (auto-derivable from pack metadata)', () => {
701+
it('should accept missing language (optional field)', () => {
702702
const result = qlLspIterativeDevelopmentSchema.safeParse({ queryPath: '/q.ql' });
703703
expect(result.success).toBe(true);
704704
});

0 commit comments

Comments
 (0)