@mariozechner/pi-coding-agent 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/core/agent-session.d.ts +7 -5
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +49 -15
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/hooks/index.d.ts +1 -1
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js.map +1 -1
- package/dist/core/hooks/runner.d.ts +3 -3
- package/dist/core/hooks/runner.d.ts.map +1 -1
- package/dist/core/hooks/runner.js +7 -3
- package/dist/core/hooks/runner.js.map +1 -1
- package/dist/core/hooks/types.d.ts +30 -24
- package/dist/core/hooks/types.d.ts.map +1 -1
- package/dist/core/hooks/types.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +6 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +149 -144
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +7 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +105 -102
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +7 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +128 -124
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +11 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +198 -194
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +19 -7
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +43 -17
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +6 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +90 -86
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts +6 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +17 -5
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts +7 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +118 -115
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +6 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +63 -59
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +5 -5
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +8 -3
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +73 -47
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +26 -9
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +10 -2
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +5 -5
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +7 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/hooks.md +42 -28
- package/docs/rpc.md +26 -6
- package/docs/sdk.md +47 -2
- package/examples/hooks/README.md +19 -3
- package/examples/hooks/auto-commit-on-exit.ts +50 -0
- package/examples/hooks/confirm-destructive.ts +62 -0
- package/examples/hooks/dirty-repo-guard.ts +59 -0
- package/examples/hooks/git-checkpoint.ts +6 -5
- package/examples/sdk/05-tools.ts +30 -4
- package/examples/sdk/12-full-control.ts +12 -4
- package/package.json +4 -4
package/examples/sdk/05-tools.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Tools Configuration
|
|
3
3
|
*
|
|
4
4
|
* Use built-in tool sets, individual tools, or add custom tools.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: When using a custom `cwd`, you must use the tool factory functions
|
|
7
|
+
* (createCodingTools, createReadOnlyTools, createReadTool, etc.) to ensure
|
|
8
|
+
* tools resolve paths relative to your cwd, not process.cwd().
|
|
5
9
|
*/
|
|
6
10
|
|
|
7
11
|
import { Type } from "@sinclair/typebox";
|
|
@@ -9,28 +13,50 @@ import {
|
|
|
9
13
|
createAgentSession,
|
|
10
14
|
discoverCustomTools,
|
|
11
15
|
SessionManager,
|
|
12
|
-
codingTools, // read, bash, edit, write (
|
|
13
|
-
readOnlyTools, // read,
|
|
16
|
+
codingTools, // read, bash, edit, write - uses process.cwd()
|
|
17
|
+
readOnlyTools, // read, grep, find, ls - uses process.cwd()
|
|
18
|
+
createCodingTools, // Factory: creates tools for specific cwd
|
|
19
|
+
createReadOnlyTools, // Factory: creates tools for specific cwd
|
|
20
|
+
createReadTool,
|
|
21
|
+
createBashTool,
|
|
22
|
+
createGrepTool,
|
|
14
23
|
readTool,
|
|
15
24
|
bashTool,
|
|
16
25
|
grepTool,
|
|
17
26
|
type CustomAgentTool,
|
|
18
27
|
} from "../../src/index.js";
|
|
19
28
|
|
|
20
|
-
// Read-only mode (no edit/write)
|
|
29
|
+
// Read-only mode (no edit/write) - uses process.cwd()
|
|
21
30
|
const { session: readOnly } = await createAgentSession({
|
|
22
31
|
tools: readOnlyTools,
|
|
23
32
|
sessionManager: SessionManager.inMemory(),
|
|
24
33
|
});
|
|
25
34
|
console.log("Read-only session created");
|
|
26
35
|
|
|
27
|
-
// Custom tool selection
|
|
36
|
+
// Custom tool selection - uses process.cwd()
|
|
28
37
|
const { session: custom } = await createAgentSession({
|
|
29
38
|
tools: [readTool, bashTool, grepTool],
|
|
30
39
|
sessionManager: SessionManager.inMemory(),
|
|
31
40
|
});
|
|
32
41
|
console.log("Custom tools session created");
|
|
33
42
|
|
|
43
|
+
// With custom cwd - MUST use factory functions!
|
|
44
|
+
const customCwd = "/path/to/project";
|
|
45
|
+
const { session: customCwdSession } = await createAgentSession({
|
|
46
|
+
cwd: customCwd,
|
|
47
|
+
tools: createCodingTools(customCwd), // Tools resolve paths relative to customCwd
|
|
48
|
+
sessionManager: SessionManager.inMemory(),
|
|
49
|
+
});
|
|
50
|
+
console.log("Custom cwd session created");
|
|
51
|
+
|
|
52
|
+
// Or pick specific tools for custom cwd
|
|
53
|
+
const { session: specificTools } = await createAgentSession({
|
|
54
|
+
cwd: customCwd,
|
|
55
|
+
tools: [createReadTool(customCwd), createBashTool(customCwd), createGrepTool(customCwd)],
|
|
56
|
+
sessionManager: SessionManager.inMemory(),
|
|
57
|
+
});
|
|
58
|
+
console.log("Specific tools with custom cwd session created");
|
|
59
|
+
|
|
34
60
|
// Inline custom tool (needs TypeBox schema)
|
|
35
61
|
const weatherTool: CustomAgentTool = {
|
|
36
62
|
name: "get_weather",
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Replace everything - no discovery, explicit configuration.
|
|
5
5
|
* Still uses OAuth from ~/.pi/agent for convenience.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: When providing `tools` with a custom `cwd`, use the tool factory
|
|
8
|
+
* functions (createReadTool, createBashTool, etc.) to ensure tools resolve
|
|
9
|
+
* paths relative to your cwd.
|
|
6
10
|
*/
|
|
7
11
|
|
|
8
12
|
import { Type } from "@sinclair/typebox";
|
|
@@ -13,8 +17,8 @@ import {
|
|
|
13
17
|
findModel,
|
|
14
18
|
SessionManager,
|
|
15
19
|
SettingsManager,
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
createReadTool,
|
|
21
|
+
createBashTool,
|
|
18
22
|
type HookFactory,
|
|
19
23
|
type CustomAgentTool,
|
|
20
24
|
} from "../../src/index.js";
|
|
@@ -60,8 +64,11 @@ const settingsManager = SettingsManager.inMemory({
|
|
|
60
64
|
retry: { enabled: true, maxRetries: 2 },
|
|
61
65
|
});
|
|
62
66
|
|
|
67
|
+
// When using a custom cwd with explicit tools, use the factory functions
|
|
68
|
+
const cwd = process.cwd();
|
|
69
|
+
|
|
63
70
|
const { session } = await createAgentSession({
|
|
64
|
-
cwd
|
|
71
|
+
cwd,
|
|
65
72
|
agentDir: "/tmp/my-agent",
|
|
66
73
|
|
|
67
74
|
model,
|
|
@@ -71,7 +78,8 @@ const { session } = await createAgentSession({
|
|
|
71
78
|
systemPrompt: `You are a minimal assistant.
|
|
72
79
|
Available: read, bash, status. Be concise.`,
|
|
73
80
|
|
|
74
|
-
|
|
81
|
+
// Use factory functions with the same cwd to ensure path resolution works correctly
|
|
82
|
+
tools: [createReadTool(cwd), createBashTool(cwd)],
|
|
75
83
|
customTools: [{ tool: statusTool }],
|
|
76
84
|
hooks: [{ factory: auditHook }],
|
|
77
85
|
skills: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mariozechner/pi-coding-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"prepublishOnly": "npm run clean && npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@mariozechner/pi-agent-core": "^0.
|
|
43
|
-
"@mariozechner/pi-ai": "^0.
|
|
44
|
-
"@mariozechner/pi-tui": "^0.
|
|
42
|
+
"@mariozechner/pi-agent-core": "^0.27.0",
|
|
43
|
+
"@mariozechner/pi-ai": "^0.27.0",
|
|
44
|
+
"@mariozechner/pi-tui": "^0.27.0",
|
|
45
45
|
"chalk": "^5.5.0",
|
|
46
46
|
"cli-highlight": "^2.1.11",
|
|
47
47
|
"diff": "^8.0.2",
|