@oh-my-pi/pi-coding-agent 8.4.2 → 8.4.5
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 +14 -0
- package/package.json +14 -6
- package/src/cursor.ts +1 -1
- package/src/modes/components/model-selector.ts +43 -14
- package/src/modes/components/tool-execution.ts +1 -3
- package/src/modes/interactive-mode.ts +3 -3
- package/src/prompts/system/plan-mode-active.md +4 -0
- package/src/prompts/tools/enter-plan-mode.md +6 -0
- package/src/prompts/tools/find.md +3 -2
- package/src/prompts/tools/grep.md +1 -1
- package/src/session/agent-session.ts +5 -1
- package/src/session/agent-storage.ts +54 -1
- package/src/task/executor.ts +6 -6
- package/src/task/index.ts +1 -3
- package/src/task/worker-protocol.ts +4 -4
- package/src/task/worker.ts +1 -1
- package/src/tools/bash.ts +1 -3
- package/src/tools/enter-plan-mode.ts +11 -6
- package/src/tools/find.ts +74 -150
- package/src/tools/grep.ts +215 -109
- package/src/tools/index.ts +5 -5
- package/src/tools/output-meta.ts +2 -2
- package/src/tools/plan-mode-guard.ts +1 -1
- package/src/tools/python.ts +1 -3
- package/src/tools/read.ts +30 -20
package/src/tools/read.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { renderCodeCell, renderOutputBlock, renderStatusLine } from "../tui";
|
|
|
16
16
|
import { formatDimensionNote, resizeImage } from "../utils/image-resize";
|
|
17
17
|
import { detectSupportedImageMimeTypeFromFile } from "../utils/mime";
|
|
18
18
|
import { ensureTool } from "../utils/tools-manager";
|
|
19
|
-
import {
|
|
19
|
+
import { runRg } from "./grep";
|
|
20
20
|
import { applyListLimit } from "./list-limit";
|
|
21
21
|
import { LsTool } from "./ls";
|
|
22
22
|
import type { OutputMeta } from "./output-meta";
|
|
@@ -164,18 +164,26 @@ async function listCandidateFiles(
|
|
|
164
164
|
signal?: AbortSignal,
|
|
165
165
|
notify?: (message: string) => void,
|
|
166
166
|
): Promise<{ files: string[]; truncated: boolean; error?: string }> {
|
|
167
|
-
let
|
|
167
|
+
let rgPath: string | undefined;
|
|
168
168
|
try {
|
|
169
|
-
|
|
169
|
+
rgPath = await ensureTool("rg", { silent: true, notify });
|
|
170
170
|
} catch {
|
|
171
|
-
return { files: [], truncated: false, error: "
|
|
171
|
+
return { files: [], truncated: false, error: "rg not available" };
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
if (!
|
|
175
|
-
return { files: [], truncated: false, error: "
|
|
174
|
+
if (!rgPath) {
|
|
175
|
+
return { files: [], truncated: false, error: "rg not available" };
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
const args: string[] = [
|
|
178
|
+
const args: string[] = [
|
|
179
|
+
"--files",
|
|
180
|
+
"--color=never",
|
|
181
|
+
"--hidden",
|
|
182
|
+
"--glob",
|
|
183
|
+
"!**/.git/**",
|
|
184
|
+
"--glob",
|
|
185
|
+
"!**/node_modules/**",
|
|
186
|
+
];
|
|
179
187
|
|
|
180
188
|
const gitignoreFiles = new Set<string>();
|
|
181
189
|
const rootGitignore = path.join(searchRoot, ".gitignore");
|
|
@@ -185,20 +193,19 @@ async function listCandidateFiles(
|
|
|
185
193
|
|
|
186
194
|
try {
|
|
187
195
|
const gitignoreArgs = [
|
|
188
|
-
"--
|
|
189
|
-
"f",
|
|
196
|
+
"--files",
|
|
190
197
|
"--color=never",
|
|
191
198
|
"--hidden",
|
|
192
|
-
"--
|
|
199
|
+
"--no-ignore",
|
|
200
|
+
"--glob",
|
|
201
|
+
"!**/.git/**",
|
|
202
|
+
"--glob",
|
|
203
|
+
"!**/node_modules/**",
|
|
193
204
|
"--glob",
|
|
194
205
|
".gitignore",
|
|
195
|
-
"--exclude",
|
|
196
|
-
"node_modules",
|
|
197
|
-
"--exclude",
|
|
198
|
-
".git",
|
|
199
206
|
searchRoot,
|
|
200
207
|
];
|
|
201
|
-
const { stdout } = await
|
|
208
|
+
const { stdout } = await runRg(rgPath, gitignoreArgs, signal);
|
|
202
209
|
const output = stdout.trim();
|
|
203
210
|
if (output) {
|
|
204
211
|
const nestedGitignores = output
|
|
@@ -224,15 +231,15 @@ async function listCandidateFiles(
|
|
|
224
231
|
args.push("--ignore-file", gitignorePath);
|
|
225
232
|
}
|
|
226
233
|
|
|
227
|
-
args.push(
|
|
234
|
+
args.push(searchRoot);
|
|
228
235
|
|
|
229
|
-
const { stdout, stderr, exitCode } = await
|
|
236
|
+
const { stdout, stderr, exitCode } = await runRg(rgPath, args, signal);
|
|
230
237
|
const output = stdout.trim();
|
|
231
238
|
|
|
232
239
|
if (!output) {
|
|
233
|
-
//
|
|
240
|
+
// rg exit codes: 0 = ok, 1 = no matches, other = error
|
|
234
241
|
if (exitCode !== 0 && exitCode !== 1) {
|
|
235
|
-
return { files: [], truncated: false, error: stderr.trim() || `
|
|
242
|
+
return { files: [], truncated: false, error: stderr.trim() || `rg failed (exit ${exitCode})` };
|
|
236
243
|
}
|
|
237
244
|
return { files: [], truncated: false };
|
|
238
245
|
}
|
|
@@ -242,7 +249,10 @@ async function listCandidateFiles(
|
|
|
242
249
|
.map(line => line.replace(/\r$/, "").trim())
|
|
243
250
|
.filter(line => line.length > 0);
|
|
244
251
|
|
|
245
|
-
|
|
252
|
+
const truncated = files.length > MAX_FUZZY_CANDIDATES;
|
|
253
|
+
const limited = truncated ? files.slice(0, MAX_FUZZY_CANDIDATES) : files;
|
|
254
|
+
|
|
255
|
+
return { files: limited, truncated };
|
|
246
256
|
}
|
|
247
257
|
|
|
248
258
|
async function findReadPathSuggestions(
|