Skip to content

Commit 795df36

Browse files
committed
chore: commit all current changes
1 parent 8a9303f commit 795df36

File tree

11 files changed

+894
-185
lines changed

11 files changed

+894
-185
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# Project Planning
2-
copilot-context-optimizer-plan.md
3-
41
# GitHub Copilot Instructions
5-
.github/copilot-instructions.md
2+
.github/
63

74
# VS Code Extension Development
85
out/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Copilot Context Optimizer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 671 additions & 0 deletions
Large diffs are not rendered by default.

icon.png

89 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "copilot-context-optimizer",
33
"displayName": "Copilot Context Optimizer",
44
"description": "Specialized tools for GitHub Copilot to efficiently work with files and terminal commands without overwhelming chat context",
5-
"version": "2.0.2",
5+
"version": "2.0.6",
66
"author": "Malak Sedarous",
77
"publisher": "malaksedarous",
88
"icon": "icon.png",

src/shared/validation.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,26 @@ export class InputValidator { static validateFilePath(filePath: string): Valida
1616
if (filePath.includes('..') || filePath.includes('~')) {
1717
return { isValid: false, errors: ['Invalid file path - path traversal not allowed'] };
1818
} // Check for invalid characters (basic check)
19-
// Allow Windows drive letters (C:\) but reject other uses of colon
19+
// Allow Windows drive letters (C:\) and forward slashes for cross-platform compatibility
2020
const windowsDriveLetter = /^[A-Za-z]:\\/;
21-
const pathWithoutDrive = windowsDriveLetter.test(filePath)
22-
? filePath.substring(3) // Remove "C:\" part
23-
: filePath;
21+
const windowsDriveLetterForward = /^[A-Za-z]:\//;
22+
const isWindowsAbsolute = windowsDriveLetter.test(filePath) || windowsDriveLetterForward.test(filePath);
2423

25-
const invalidChars = /[<>:"|?*]/;
26-
if (invalidChars.test(pathWithoutDrive)) {
27-
return { isValid: false, errors: ['File path contains invalid characters'] };
24+
// For Windows absolute paths, we need to be more permissive with path validation
25+
if (isWindowsAbsolute) {
26+
// For Windows paths, only check for truly invalid filename characters
27+
// Allow : in drive letter, allow / and \ as path separators
28+
const invalidCharsWindows = /[<>"|?*]/;
29+
const pathWithoutDrive = filePath.substring(3); // Remove "C:\" or "C:/" part
30+
if (invalidCharsWindows.test(pathWithoutDrive)) {
31+
return { isValid: false, errors: ['File path contains invalid characters'] };
32+
}
33+
} else {
34+
// For relative paths, use stricter validation (no colons allowed)
35+
const invalidChars = /[<>:"|?*]/;
36+
if (invalidChars.test(filePath)) {
37+
return { isValid: false, errors: ['File path contains invalid characters'] };
38+
}
2839
}
2940
// Check for dangerous system paths
3041
const dangerousPatterns = [

src/test/terminalExtractorLanguageModelTools.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,12 @@ suite('Language Model Tools Tests', () => {
300300
const tool = new TerminalExtractorTool();
301301
// Mock TerminalManager to delay output
302302
const fakeOutput = 'line1\nline2\nline3';
303+
const mockTerminal = { dispose: sandbox.stub() } as any;
303304
const executeCommandStub = sandbox.stub(TerminalManager.prototype, 'executeCommand').callsFake(async () => {
304305
await new Promise(res => setTimeout(res, 1500)); // Simulate delay
305-
return { output: fakeOutput, exitCode: 0 };
306+
return { output: fakeOutput, exitCode: 0, terminal: mockTerminal };
306307
});
308+
const disposeTerminalStub = sandbox.stub(TerminalManager.prototype, 'disposeTerminal');
307309
const options: vscode.LanguageModelToolInvocationOptions<object> = {
308310
input: { terminalCommand: 'long-running-cmd', extractionPrompt: 'Show me the raw output' },
309311
toolInvocationToken: undefined,

0 commit comments

Comments
 (0)