forked from earendil-works/pi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05-tools.ts
More file actions
56 lines (51 loc) · 1.6 KB
/
Copy path05-tools.ts
File metadata and controls
56 lines (51 loc) · 1.6 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
/**
* Tools Configuration
*
* Use built-in tool sets or individual tools.
*
* IMPORTANT: When using a custom `cwd`, you must use the tool factory functions
* (createCodingTools, createReadOnlyTools, createReadTool, etc.) to ensure
* tools resolve paths relative to your cwd, not process.cwd().
*
* For custom tools, see 06-extensions.ts - custom tools are now registered
* via the extensions system using pi.registerTool().
*/
import {
bashTool,
createAgentSession,
createBashTool,
createCodingTools,
createGrepTool,
createReadTool,
grepTool,
readOnlyTools,
readTool,
SessionManager,
} from "open-pi-coding-agent";
// Read-only mode (no edit/write) - uses process.cwd()
await createAgentSession({
tools: readOnlyTools,
sessionManager: SessionManager.inMemory(),
});
console.log("Read-only session created");
// Custom tool selection - uses process.cwd()
await createAgentSession({
tools: [readTool, bashTool, grepTool],
sessionManager: SessionManager.inMemory(),
});
console.log("Custom tools session created");
// With custom cwd - MUST use factory functions!
const customCwd = "/path/to/project";
await createAgentSession({
cwd: customCwd,
tools: createCodingTools(customCwd), // Tools resolve paths relative to customCwd
sessionManager: SessionManager.inMemory(),
});
console.log("Custom cwd session created");
// Or pick specific tools for custom cwd
await createAgentSession({
cwd: customCwd,
tools: [createReadTool(customCwd), createBashTool(customCwd), createGrepTool(customCwd)],
sessionManager: SessionManager.inMemory(),
});
console.log("Specific tools with custom cwd session created");