-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-tools.js
More file actions
94 lines (83 loc) · 2.21 KB
/
Copy pathtest-tools.js
File metadata and controls
94 lines (83 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Quick test script to verify Glob and Grep implementations
* Run with: node test-tools.js
*/
const { ToolExecutor } = require('./dist-electron/main/services/tools/ToolExecutor.js');
const path = require('path');
async function testTools() {
const executor = new ToolExecutor({
enabled: true,
allowedPaths: [process.cwd()],
deniedCommands: [],
});
const context = {
workingDirectory: process.cwd(),
agentId: 'test-agent',
projectId: 'test-project',
};
console.log('Testing Glob tool...');
console.log('===================\n');
// Test 1: Find TypeScript files
const globResult1 = await executor.execute(
{
id: 'glob-1',
name: 'glob',
input: { pattern: 'src/**/*.ts' },
},
context
);
console.log('Pattern: src/**/*.ts');
console.log('Result (first 10 files):');
console.log(globResult1.content.split('\n').slice(0, 10).join('\n'));
console.log('');
// Test 2: Find markdown files
const globResult2 = await executor.execute(
{
id: 'glob-2',
name: 'glob',
input: { pattern: '**/*.md' },
},
context
);
console.log('Pattern: **/*.md');
console.log('Result:');
console.log(globResult2.content);
console.log('\n');
console.log('Testing Grep tool...');
console.log('===================\n');
// Test 3: Search for "ToolExecutor" in TypeScript files
const grepResult1 = await executor.execute(
{
id: 'grep-1',
name: 'grep',
input: {
pattern: 'class ToolExecutor',
path: 'src/main/services/tools',
},
},
context
);
console.log('Pattern: "class ToolExecutor" in src/main/services/tools');
console.log('Result:');
console.log(grepResult1.content);
console.log('');
// Test 4: Case-insensitive search
const grepResult2 = await executor.execute(
{
id: 'grep-2',
name: 'grep',
input: {
pattern: 'CONSTELLATION',
path: 'package.json',
'-i': true,
},
},
context
);
console.log('Pattern: "CONSTELLATION" (case-insensitive) in package.json');
console.log('Result:');
console.log(grepResult2.content);
console.log('\n');
console.log('All tests completed!');
}
testTools().catch(console.error);