@cydm/pie 1.0.17 → 1.0.19
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/dist/builtin/extensions/ask-user/index.js +3 -3
- package/dist/builtin/extensions/plan-mode/index.js +3 -3
- package/dist/builtin/extensions/subagent/index.js +4 -4
- package/dist/builtin/extensions/todo/index.js +3 -3
- package/dist/chunks/{chunk-VE2HDCNB.js → chunk-2R3XTLE2.js} +1 -1
- package/dist/chunks/{chunk-B4VUX6SD.js → chunk-GZVSE44O.js} +500 -129
- package/dist/chunks/{chunk-4MIOCDBV.js → chunk-KZ54RSWP.js} +2 -2
- package/dist/chunks/{chunk-5DA2D3K2.js → chunk-Q2N6B5JN.js} +277 -0
- package/dist/chunks/{src-6WPNVGT2.js → src-7UV3KKGU.js} +2 -2
- package/dist/chunks/{test-stream-ZSKNLUEJ.js → test-stream-PP63L7MK.js} +1 -1
- package/dist/cli.js +37 -11
- package/package.json +1 -1
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
createSharedWebSearchTool,
|
|
9
9
|
interpretShellExit,
|
|
10
10
|
requestInteraction
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GZVSE44O.js";
|
|
12
12
|
import {
|
|
13
13
|
Type
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Q2N6B5JN.js";
|
|
15
15
|
|
|
16
16
|
// src/config.ts
|
|
17
17
|
import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
|
|
@@ -3107,6 +3107,27 @@ function calculateCost(model, usage) {
|
|
|
3107
3107
|
};
|
|
3108
3108
|
}
|
|
3109
3109
|
|
|
3110
|
+
// ../../packages/platform/src/text-hash.ts
|
|
3111
|
+
function createTextHasher() {
|
|
3112
|
+
let hash = 2166136261;
|
|
3113
|
+
return {
|
|
3114
|
+
update(text) {
|
|
3115
|
+
for (let index = 0; index < text.length; index++) {
|
|
3116
|
+
hash ^= text.charCodeAt(index);
|
|
3117
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
3118
|
+
}
|
|
3119
|
+
},
|
|
3120
|
+
digest() {
|
|
3121
|
+
return hash.toString(16).padStart(8, "0");
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
}
|
|
3125
|
+
function hashText(text) {
|
|
3126
|
+
const hasher = createTextHasher();
|
|
3127
|
+
hasher.update(text);
|
|
3128
|
+
return hasher.digest();
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3110
3131
|
// ../../packages/platform/src/detector.ts
|
|
3111
3132
|
function isPuerTS() {
|
|
3112
3133
|
try {
|
|
@@ -3252,6 +3273,17 @@ function convertStats(stats) {
|
|
|
3252
3273
|
mtime: stats.mtime
|
|
3253
3274
|
};
|
|
3254
3275
|
}
|
|
3276
|
+
function byteLength(text) {
|
|
3277
|
+
return Buffer.byteLength(text, "utf-8");
|
|
3278
|
+
}
|
|
3279
|
+
function normalizeRangeOptions(options) {
|
|
3280
|
+
return {
|
|
3281
|
+
offsetLine: Math.max(0, Math.floor(options?.offsetLine ?? 0)),
|
|
3282
|
+
limitLines: options?.limitLines === void 0 ? Number.POSITIVE_INFINITY : Math.max(0, Math.floor(options.limitLines)),
|
|
3283
|
+
maxOutputLines: Math.max(0, Math.floor(options?.maxOutputLines ?? Number.POSITIVE_INFINITY)),
|
|
3284
|
+
maxOutputBytes: Math.max(0, Math.floor(options?.maxOutputBytes ?? Number.POSITIVE_INFINITY))
|
|
3285
|
+
};
|
|
3286
|
+
}
|
|
3255
3287
|
var NodeFileSystem = class {
|
|
3256
3288
|
platform = "node";
|
|
3257
3289
|
sep;
|
|
@@ -3266,6 +3298,142 @@ var NodeFileSystem = class {
|
|
|
3266
3298
|
readFileSync(path, encoding = "utf-8") {
|
|
3267
3299
|
return getNodeFs().readFileSync(path, encoding);
|
|
3268
3300
|
}
|
|
3301
|
+
async readTextRange(path, options, signal) {
|
|
3302
|
+
const fs = getNodeFs();
|
|
3303
|
+
const range = normalizeRangeOptions(options);
|
|
3304
|
+
const stat = await fs.promises.stat(path);
|
|
3305
|
+
const fullHasher = createTextHasher();
|
|
3306
|
+
const selectedHasher = createTextHasher();
|
|
3307
|
+
const outputLines = [];
|
|
3308
|
+
let lineStarted = false;
|
|
3309
|
+
let currentLineSelected = false;
|
|
3310
|
+
let currentLineBytes = 0;
|
|
3311
|
+
let currentOutputLine = "";
|
|
3312
|
+
let currentOutputLineBytes = 0;
|
|
3313
|
+
let currentOutputPrefixBytes = 0;
|
|
3314
|
+
let currentLineCanOutput = false;
|
|
3315
|
+
let lineIndex = 0;
|
|
3316
|
+
let selectedLines = 0;
|
|
3317
|
+
let selectedBytes = 0;
|
|
3318
|
+
let firstLineBytes = 0;
|
|
3319
|
+
let outputBytes = 0;
|
|
3320
|
+
let truncated = false;
|
|
3321
|
+
let truncatedBy = null;
|
|
3322
|
+
let firstLineExceedsLimit = false;
|
|
3323
|
+
const selectedEndLine = Number.isFinite(range.limitLines) ? range.offsetLine + range.limitLines : Number.POSITIVE_INFINITY;
|
|
3324
|
+
const startLine = () => {
|
|
3325
|
+
if (lineStarted) return;
|
|
3326
|
+
currentLineSelected = lineIndex >= range.offsetLine && lineIndex < selectedEndLine;
|
|
3327
|
+
currentLineBytes = 0;
|
|
3328
|
+
currentOutputLine = "";
|
|
3329
|
+
currentOutputLineBytes = 0;
|
|
3330
|
+
currentOutputPrefixBytes = outputLines.length > 0 ? 1 : 0;
|
|
3331
|
+
currentLineCanOutput = false;
|
|
3332
|
+
lineStarted = true;
|
|
3333
|
+
if (!currentLineSelected) return;
|
|
3334
|
+
if (selectedLines > 0) {
|
|
3335
|
+
selectedHasher.update("\n");
|
|
3336
|
+
selectedBytes += 1;
|
|
3337
|
+
}
|
|
3338
|
+
if (!truncated && !firstLineExceedsLimit) {
|
|
3339
|
+
if (outputLines.length >= range.maxOutputLines) {
|
|
3340
|
+
truncated = true;
|
|
3341
|
+
truncatedBy = "lines";
|
|
3342
|
+
} else {
|
|
3343
|
+
currentLineCanOutput = true;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
};
|
|
3347
|
+
const scanLineChar = (char) => {
|
|
3348
|
+
startLine();
|
|
3349
|
+
if (!currentLineSelected) return;
|
|
3350
|
+
selectedHasher.update(char);
|
|
3351
|
+
const charBytes = byteLength(char);
|
|
3352
|
+
currentLineBytes += charBytes;
|
|
3353
|
+
selectedBytes += charBytes;
|
|
3354
|
+
if (selectedLines === 0 && currentLineBytes > range.maxOutputBytes) {
|
|
3355
|
+
firstLineExceedsLimit = true;
|
|
3356
|
+
truncated = true;
|
|
3357
|
+
truncatedBy = "bytes";
|
|
3358
|
+
currentLineCanOutput = false;
|
|
3359
|
+
currentOutputLine = "";
|
|
3360
|
+
currentOutputLineBytes = 0;
|
|
3361
|
+
return;
|
|
3362
|
+
}
|
|
3363
|
+
if (!currentLineCanOutput) return;
|
|
3364
|
+
const candidateOutputBytes = outputBytes + currentOutputPrefixBytes + currentOutputLineBytes + charBytes;
|
|
3365
|
+
if (candidateOutputBytes > range.maxOutputBytes) {
|
|
3366
|
+
truncated = true;
|
|
3367
|
+
truncatedBy = "bytes";
|
|
3368
|
+
currentLineCanOutput = false;
|
|
3369
|
+
currentOutputLine = "";
|
|
3370
|
+
currentOutputLineBytes = 0;
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
currentOutputLine += char;
|
|
3374
|
+
currentOutputLineBytes += charBytes;
|
|
3375
|
+
};
|
|
3376
|
+
const finishLine = () => {
|
|
3377
|
+
startLine();
|
|
3378
|
+
if (currentLineSelected) {
|
|
3379
|
+
if (selectedLines === 0) {
|
|
3380
|
+
firstLineBytes = currentLineBytes;
|
|
3381
|
+
}
|
|
3382
|
+
if (currentLineCanOutput) {
|
|
3383
|
+
const candidateOutputBytes = outputBytes + currentOutputPrefixBytes + currentOutputLineBytes;
|
|
3384
|
+
if (candidateOutputBytes > range.maxOutputBytes) {
|
|
3385
|
+
truncated = true;
|
|
3386
|
+
truncatedBy = "bytes";
|
|
3387
|
+
currentLineCanOutput = false;
|
|
3388
|
+
} else {
|
|
3389
|
+
outputLines.push(currentOutputLine);
|
|
3390
|
+
outputBytes = candidateOutputBytes;
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
selectedLines++;
|
|
3394
|
+
}
|
|
3395
|
+
lineStarted = false;
|
|
3396
|
+
lineIndex++;
|
|
3397
|
+
};
|
|
3398
|
+
const stream = fs.createReadStream(path, { encoding: "utf-8" });
|
|
3399
|
+
try {
|
|
3400
|
+
for await (const chunk of stream) {
|
|
3401
|
+
if (signal?.aborted) {
|
|
3402
|
+
stream.destroy();
|
|
3403
|
+
throw new Error("Operation aborted");
|
|
3404
|
+
}
|
|
3405
|
+
const text = String(chunk);
|
|
3406
|
+
fullHasher.update(text);
|
|
3407
|
+
for (const char of text) {
|
|
3408
|
+
if (char === "\n") {
|
|
3409
|
+
finishLine();
|
|
3410
|
+
} else {
|
|
3411
|
+
scanLineChar(char);
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
finishLine();
|
|
3416
|
+
} finally {
|
|
3417
|
+
stream.destroy();
|
|
3418
|
+
}
|
|
3419
|
+
return {
|
|
3420
|
+
content: outputLines.join("\n"),
|
|
3421
|
+
contentHash: fullHasher.digest(),
|
|
3422
|
+
selectedContentHash: selectedHasher.digest(),
|
|
3423
|
+
totalLines: lineIndex,
|
|
3424
|
+
totalBytes: stat.size,
|
|
3425
|
+
selectedLines,
|
|
3426
|
+
selectedBytes,
|
|
3427
|
+
firstLineBytes,
|
|
3428
|
+
outputLines: outputLines.length,
|
|
3429
|
+
outputBytes,
|
|
3430
|
+
truncated,
|
|
3431
|
+
truncatedBy,
|
|
3432
|
+
firstLineExceedsLimit,
|
|
3433
|
+
mtimeMs: stat.mtime.getTime(),
|
|
3434
|
+
size: stat.size
|
|
3435
|
+
};
|
|
3436
|
+
}
|
|
3269
3437
|
async writeFile(path, data, encoding = "utf-8") {
|
|
3270
3438
|
return getNodeFs().promises.writeFile(path, data, encoding);
|
|
3271
3439
|
}
|
|
@@ -3392,6 +3560,87 @@ function convertBridgeStatResult(result) {
|
|
|
3392
3560
|
mtime: new Date((Number(result?.LastWriteTicksUtc || 0) - 621355968e9) / 1e4)
|
|
3393
3561
|
};
|
|
3394
3562
|
}
|
|
3563
|
+
function normalizeOptionalNumber(value, fallback) {
|
|
3564
|
+
if (value === void 0 || !Number.isFinite(value)) {
|
|
3565
|
+
return fallback;
|
|
3566
|
+
}
|
|
3567
|
+
return Math.max(0, Math.floor(value));
|
|
3568
|
+
}
|
|
3569
|
+
function convertTextRangeResult(result) {
|
|
3570
|
+
return {
|
|
3571
|
+
content: String(result?.Content ?? ""),
|
|
3572
|
+
contentHash: String(result?.ContentHash ?? ""),
|
|
3573
|
+
selectedContentHash: String(result?.SelectedContentHash ?? ""),
|
|
3574
|
+
totalLines: Number(result?.TotalLines ?? 0),
|
|
3575
|
+
totalBytes: Number(result?.TotalBytes ?? 0),
|
|
3576
|
+
selectedLines: Number(result?.SelectedLines ?? 0),
|
|
3577
|
+
selectedBytes: Number(result?.SelectedBytes ?? 0),
|
|
3578
|
+
firstLineBytes: Number(result?.FirstLineBytes ?? 0),
|
|
3579
|
+
outputLines: Number(result?.OutputLines ?? 0),
|
|
3580
|
+
outputBytes: Number(result?.OutputBytes ?? 0),
|
|
3581
|
+
truncated: !!result?.Truncated,
|
|
3582
|
+
truncatedBy: result?.TruncatedBy ? String(result.TruncatedBy) : null,
|
|
3583
|
+
firstLineExceedsLimit: !!result?.FirstLineExceedsLimit,
|
|
3584
|
+
mtimeMs: (Number(result?.LastWriteTicksUtc || 0) - 621355968e9) / 1e4,
|
|
3585
|
+
size: Number(result?.Size ?? 0)
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
function byteLength2(text) {
|
|
3589
|
+
if (typeof Buffer !== "undefined") {
|
|
3590
|
+
return Buffer.byteLength(text, "utf-8");
|
|
3591
|
+
}
|
|
3592
|
+
return unescape(encodeURIComponent(text)).length;
|
|
3593
|
+
}
|
|
3594
|
+
function buildTextRangeFallback(content, stat, offsetLine, limitLines, maxOutputLines, maxOutputBytes) {
|
|
3595
|
+
const lines = content.split("\n");
|
|
3596
|
+
const endLine = Number.isFinite(limitLines) ? Math.min(lines.length, offsetLine + limitLines) : lines.length;
|
|
3597
|
+
const selectedLinesArray = offsetLine >= lines.length ? [] : lines.slice(offsetLine, endLine);
|
|
3598
|
+
const selectedContent = selectedLinesArray.join("\n");
|
|
3599
|
+
const outputLines = [];
|
|
3600
|
+
let outputBytes = 0;
|
|
3601
|
+
let truncated = false;
|
|
3602
|
+
let truncatedBy = null;
|
|
3603
|
+
let firstLineExceedsLimit = false;
|
|
3604
|
+
for (const line of selectedLinesArray) {
|
|
3605
|
+
const lineBytes = byteLength2(line);
|
|
3606
|
+
if (outputLines.length === 0 && lineBytes > maxOutputBytes) {
|
|
3607
|
+
firstLineExceedsLimit = true;
|
|
3608
|
+
truncated = true;
|
|
3609
|
+
truncatedBy = "bytes";
|
|
3610
|
+
break;
|
|
3611
|
+
}
|
|
3612
|
+
if (outputLines.length >= maxOutputLines) {
|
|
3613
|
+
truncated = true;
|
|
3614
|
+
truncatedBy = "lines";
|
|
3615
|
+
break;
|
|
3616
|
+
}
|
|
3617
|
+
const candidateBytes = lineBytes + (outputLines.length > 0 ? 1 : 0);
|
|
3618
|
+
if (outputBytes + candidateBytes > maxOutputBytes) {
|
|
3619
|
+
truncated = true;
|
|
3620
|
+
truncatedBy = "bytes";
|
|
3621
|
+
break;
|
|
3622
|
+
}
|
|
3623
|
+
outputLines.push(line);
|
|
3624
|
+
outputBytes += candidateBytes;
|
|
3625
|
+
}
|
|
3626
|
+
return {
|
|
3627
|
+
content: outputLines.join("\n"),
|
|
3628
|
+
contentHash: hashText(content),
|
|
3629
|
+
selectedContentHash: hashText(selectedContent),
|
|
3630
|
+
totalLines: lines.length,
|
|
3631
|
+
totalBytes: stat.size,
|
|
3632
|
+
selectedLines: selectedLinesArray.length,
|
|
3633
|
+
selectedBytes: byteLength2(selectedContent),
|
|
3634
|
+
firstLineBytes: selectedLinesArray.length > 0 ? byteLength2(selectedLinesArray[0]) : 0,
|
|
3635
|
+
outputLines: outputLines.length,
|
|
3636
|
+
outputBytes,
|
|
3637
|
+
truncated,
|
|
3638
|
+
truncatedBy,
|
|
3639
|
+
firstLineExceedsLimit,
|
|
3640
|
+
mtimeMs: stat.mtime.getTime(),
|
|
3641
|
+
size: stat.size
|
|
3642
|
+
};
|
|
3643
|
+
}
|
|
3395
3644
|
function convertDateTime(dateTime) {
|
|
3396
3645
|
if (!dateTime) return /* @__PURE__ */ new Date(0);
|
|
3397
3646
|
const ticks = dateTime.get_Ticks?.() || 0;
|
|
@@ -3457,6 +3706,33 @@ var PuerTSFileSystem = class {
|
|
|
3457
3706
|
}
|
|
3458
3707
|
return IO.File.ReadAllText(normalizedPath);
|
|
3459
3708
|
}
|
|
3709
|
+
async readTextRange(path, options, signal) {
|
|
3710
|
+
if (signal?.aborted) {
|
|
3711
|
+
throw new Error("Operation aborted");
|
|
3712
|
+
}
|
|
3713
|
+
const bridge = getPieFileBridge();
|
|
3714
|
+
const normalizedPath = this.normalizePath(path);
|
|
3715
|
+
if (typeof bridge.ReadTextRangeAsync !== "function") {
|
|
3716
|
+
const content = await this.readFile(path, "utf-8");
|
|
3717
|
+
const stat = await this.stat(path);
|
|
3718
|
+
const offsetLine = normalizeOptionalNumber(options?.offsetLine, 0);
|
|
3719
|
+
const limitLines = options?.limitLines === void 0 ? Number.POSITIVE_INFINITY : normalizeOptionalNumber(options.limitLines, 0);
|
|
3720
|
+
const maxOutputLines = normalizeOptionalNumber(options?.maxOutputLines, Number.POSITIVE_INFINITY);
|
|
3721
|
+
const maxOutputBytes = normalizeOptionalNumber(options?.maxOutputBytes, Number.POSITIVE_INFINITY);
|
|
3722
|
+
return buildTextRangeFallback(content, stat, offsetLine, limitLines, maxOutputLines, maxOutputBytes);
|
|
3723
|
+
}
|
|
3724
|
+
const payload = await taskToPromise(bridge.ReadTextRangeAsync(
|
|
3725
|
+
normalizedPath,
|
|
3726
|
+
normalizeOptionalNumber(options?.offsetLine, 0),
|
|
3727
|
+
options?.limitLines === void 0 ? -1 : normalizeOptionalNumber(options.limitLines, 0),
|
|
3728
|
+
normalizeOptionalNumber(options?.maxOutputLines, -1),
|
|
3729
|
+
normalizeOptionalNumber(options?.maxOutputBytes, -1)
|
|
3730
|
+
));
|
|
3731
|
+
if (signal?.aborted) {
|
|
3732
|
+
throw new Error("Operation aborted");
|
|
3733
|
+
}
|
|
3734
|
+
return convertTextRangeResult(JSON.parse(String(payload ?? "{}")));
|
|
3735
|
+
}
|
|
3460
3736
|
async writeFile(path, data, encoding = "utf-8") {
|
|
3461
3737
|
const bridge = getPieFileBridge();
|
|
3462
3738
|
const normalizedPath = this.normalizePath(path);
|
|
@@ -9121,6 +9397,7 @@ registerApiProvider({
|
|
|
9121
9397
|
});
|
|
9122
9398
|
|
|
9123
9399
|
export {
|
|
9400
|
+
hashText,
|
|
9124
9401
|
detectPlatform,
|
|
9125
9402
|
createLogger,
|
|
9126
9403
|
setLogger,
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
getSettingsPath,
|
|
15
15
|
getThemesDir,
|
|
16
16
|
migrateConfigFromAgentDir
|
|
17
|
-
} from "./chunks/chunk-
|
|
17
|
+
} from "./chunks/chunk-KZ54RSWP.js";
|
|
18
18
|
import {
|
|
19
19
|
AGENTS_CONTEXT_FILE_NAME,
|
|
20
20
|
AgentSessionController,
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
createEmptyExecutionState,
|
|
32
32
|
createExecutionStateFromTodos,
|
|
33
33
|
createExecutionStateStore,
|
|
34
|
+
createFileObservationState,
|
|
34
35
|
createPolicyEnforcedTools,
|
|
35
36
|
createReadFileUnderstandingHandler,
|
|
36
37
|
createSessionManager,
|
|
@@ -55,8 +56,8 @@ import {
|
|
|
55
56
|
selectToolsForRuntimePolicy,
|
|
56
57
|
shouldPreserveExecutionStateForUserText,
|
|
57
58
|
supersedeExecutionState
|
|
58
|
-
} from "./chunks/chunk-
|
|
59
|
-
import "./chunks/chunk-
|
|
59
|
+
} from "./chunks/chunk-GZVSE44O.js";
|
|
60
|
+
import "./chunks/chunk-2R3XTLE2.js";
|
|
60
61
|
import {
|
|
61
62
|
Deref,
|
|
62
63
|
Errors,
|
|
@@ -90,7 +91,7 @@ import {
|
|
|
90
91
|
setLogger,
|
|
91
92
|
sortToolModelCandidatesByCapability,
|
|
92
93
|
type_exports
|
|
93
|
-
} from "./chunks/chunk-
|
|
94
|
+
} from "./chunks/chunk-Q2N6B5JN.js";
|
|
94
95
|
import {
|
|
95
96
|
resolveCliProjectRoot
|
|
96
97
|
} from "./chunks/chunk-NTYHFBUA.js";
|
|
@@ -61258,6 +61259,7 @@ async function handleCompactCommand(host) {
|
|
|
61258
61259
|
host.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore);
|
|
61259
61260
|
const compactedMessages = host.sessionManager.getMessages();
|
|
61260
61261
|
host.replaceAgentMessagesAndMarkSynced(compactedMessages);
|
|
61262
|
+
host.resetFileObservationState();
|
|
61261
61263
|
host.streamingComponent = void 0;
|
|
61262
61264
|
host.pendingTools.clear();
|
|
61263
61265
|
host.chatContainer.clear();
|
|
@@ -64017,6 +64019,10 @@ function buildCodingAgentGuidelinesSection(tools = []) {
|
|
|
64017
64019
|
if (hasGrep || hasFind || hasList) {
|
|
64018
64020
|
guidelines.push("Prefer grep_text, find_files, and list_dir for workspace exploration when they are sufficient.");
|
|
64019
64021
|
}
|
|
64022
|
+
if (hasGrep) {
|
|
64023
|
+
guidelines.push("Use grep_text outputMode='files_with_matches' to find candidate files, outputMode='count' to estimate impact, and outputMode='content' when you need matching lines and context.");
|
|
64024
|
+
guidelines.push("After a broad grep_text search, narrow the path, glob, pattern, outputMode, offset, or limit instead of repeating the same broad search.");
|
|
64025
|
+
}
|
|
64020
64026
|
if (hasWebResearch) {
|
|
64021
64027
|
guidelines.push("Use web_research for general public web research, current information, official docs, news, releases, issues, or webpage summaries; it searches, fetches, and returns cited sources.");
|
|
64022
64028
|
guidelines.push("When web_research returns fetched sources that answer the request, synthesize the answer from that pack instead of calling web_search or web_fetch again.");
|
|
@@ -64036,20 +64042,26 @@ function buildCodingAgentGuidelinesSection(tools = []) {
|
|
|
64036
64042
|
guidelines.push("Read the current file before edit_file changes, then use a precise unique replacement.");
|
|
64037
64043
|
}
|
|
64038
64044
|
if (hasRead) {
|
|
64045
|
+
guidelines.push("Use read_file offset/limit for large files; if read_file says a range is unchanged, do not repeat the same read and choose a different range or search instead.");
|
|
64039
64046
|
guidelines.push("Use read_file directly for media and documents when the file-understanding route is available.");
|
|
64040
64047
|
}
|
|
64041
64048
|
if (hasEdit) {
|
|
64042
|
-
guidelines.push("If edit_file fails because text is missing
|
|
64049
|
+
guidelines.push("If edit_file fails because text is missing, read the current file and retry with exact text copied from the latest file contents.");
|
|
64050
|
+
guidelines.push("If edit_file fails because text is not unique, read the current file and retry with a larger exact block, or set replaceAll to true if every occurrence should be replaced.");
|
|
64043
64051
|
}
|
|
64044
64052
|
if (hasWrite) {
|
|
64045
|
-
guidelines.push("Use write_file for new files or complete rewrites
|
|
64053
|
+
guidelines.push("Use write_file for new files or true complete rewrites; before overwriting an existing file, read the current full file with read_file, and prefer edit_file for targeted changes.");
|
|
64046
64054
|
}
|
|
64047
64055
|
if (hasBash) {
|
|
64048
64056
|
guidelines.push("Pass only executable shell commands to bash, not numbered plan items, headings, or prose.");
|
|
64057
|
+
if (hasWrite || hasEdit) {
|
|
64058
|
+
guidelines.push("Do not use shell redirection, cat > file, tee, or heredoc to create or overwrite files when write_file or edit_file can do it; never use Bash to bypass write_file overwrite guards.");
|
|
64059
|
+
}
|
|
64049
64060
|
guidelines.push("If bash times out or truncates output, adjust the command or inspect the reported full output path instead of repeating the same command.");
|
|
64050
64061
|
}
|
|
64051
64062
|
if (hasTodo) {
|
|
64052
|
-
guidelines.push("Use manage_todo_list for multi-step work: create the list, complete only the current item,
|
|
64063
|
+
guidelines.push("Use manage_todo_list only for multi-step work: create the list, complete only the current item when it is genuinely done, and let the tool advance the next item.");
|
|
64064
|
+
guidelines.push("Do not complete a todo item while implementation is partial, tests or verification are failing, or the required verification has not run.");
|
|
64053
64065
|
}
|
|
64054
64066
|
guidelines.push(
|
|
64055
64067
|
"Once the root cause or required change is clear, make a small concrete edit instead of continuing unrelated exploration.",
|
|
@@ -65056,6 +65068,7 @@ function createInteractiveAgentSessionController(host) {
|
|
|
65056
65068
|
host.footer.setState({ status: "ready" });
|
|
65057
65069
|
return;
|
|
65058
65070
|
}
|
|
65071
|
+
host.resetFileObservationState();
|
|
65059
65072
|
const contextUsage = host.calculateContextUsage();
|
|
65060
65073
|
const contextWindow = host.options.model?.contextWindow ?? 0;
|
|
65061
65074
|
const contextPercent = contextWindow > 0 && contextUsage.tokens !== null ? contextUsage.tokens / contextWindow * 100 : 0;
|
|
@@ -66810,6 +66823,7 @@ var InteractiveMode = class {
|
|
|
66810
66823
|
allowlistedDirs
|
|
66811
66824
|
}),
|
|
66812
66825
|
configDir: this.options.configDir,
|
|
66826
|
+
fileObservationState: this.options.fileObservationState,
|
|
66813
66827
|
getAgentModel: () => this.options.model,
|
|
66814
66828
|
getSessionId: () => this.sessionManager.getActiveSessionId() || void 0,
|
|
66815
66829
|
resolveToolModel: (purpose) => this.options.modelRegistry.resolveToolModel(purpose, this.options.model),
|
|
@@ -66837,6 +66851,9 @@ var InteractiveMode = class {
|
|
|
66837
66851
|
)
|
|
66838
66852
|
};
|
|
66839
66853
|
}
|
|
66854
|
+
resetFileObservationState() {
|
|
66855
|
+
this.options.fileObservationState.clear();
|
|
66856
|
+
}
|
|
66840
66857
|
getRuntimeModeState() {
|
|
66841
66858
|
const pendingTransition = this.getPendingRuntimeModeTransition();
|
|
66842
66859
|
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || "local";
|
|
@@ -66945,7 +66962,7 @@ var InteractiveMode = class {
|
|
|
66945
66962
|
if (savedLevel) {
|
|
66946
66963
|
this.thinkingLevel = savedLevel;
|
|
66947
66964
|
}
|
|
66948
|
-
const { Agent } = await import("./chunks/src-
|
|
66965
|
+
const { Agent } = await import("./chunks/src-7UV3KKGU.js");
|
|
66949
66966
|
const activeSession = this.sessionManager.getActiveSession();
|
|
66950
66967
|
this.agent = new Agent({
|
|
66951
66968
|
initialState: {
|
|
@@ -67375,6 +67392,7 @@ async function composeCliRuntime(params) {
|
|
|
67375
67392
|
}
|
|
67376
67393
|
syncSessionModelMetadata(sessionManager, model, settingsManager.getDefaultThinkingLevel() || "off");
|
|
67377
67394
|
const sessionId = sessionManager.getActiveSession()?.id;
|
|
67395
|
+
const fileObservationState = createFileObservationState();
|
|
67378
67396
|
if (sessionId) {
|
|
67379
67397
|
if (process.env.PIE_DEBUG && !fileLogger.isEnabled()) {
|
|
67380
67398
|
fileLogger.enable();
|
|
@@ -67403,6 +67421,7 @@ async function composeCliRuntime(params) {
|
|
|
67403
67421
|
const fileSystemToolOptions = {
|
|
67404
67422
|
...buildCliFileAccessOptions({ cwd, configDir: paths.configDir, skills, allowlistedDirs: [paths.configDir] }),
|
|
67405
67423
|
configDir: paths.configDir,
|
|
67424
|
+
fileObservationState,
|
|
67406
67425
|
getAgentModel: getCurrentModel,
|
|
67407
67426
|
getSessionId: () => sessionManager.getActiveSessionId() || void 0,
|
|
67408
67427
|
resolveToolModel: (purpose) => modelRegistry.resolveToolModel(purpose, getCurrentModel()),
|
|
@@ -67475,6 +67494,7 @@ async function composeCliRuntime(params) {
|
|
|
67475
67494
|
skillsSection,
|
|
67476
67495
|
knowledgeSection,
|
|
67477
67496
|
tools,
|
|
67497
|
+
fileObservationState,
|
|
67478
67498
|
extensionPaths: params.extensionPaths,
|
|
67479
67499
|
compositionTrace,
|
|
67480
67500
|
createInteractiveOptions() {
|
|
@@ -67482,6 +67502,7 @@ async function composeCliRuntime(params) {
|
|
|
67482
67502
|
model,
|
|
67483
67503
|
apiKey,
|
|
67484
67504
|
tools,
|
|
67505
|
+
fileObservationState,
|
|
67485
67506
|
sessionManager,
|
|
67486
67507
|
skills,
|
|
67487
67508
|
cwd,
|
|
@@ -67612,7 +67633,7 @@ async function runPrintMode(params) {
|
|
|
67612
67633
|
`);
|
|
67613
67634
|
console.log("Assistant: ");
|
|
67614
67635
|
}
|
|
67615
|
-
const { Agent: AgentClass } = await import("./chunks/src-
|
|
67636
|
+
const { Agent: AgentClass } = await import("./chunks/src-7UV3KKGU.js");
|
|
67616
67637
|
let agent;
|
|
67617
67638
|
const printModeExtensions = await loadPrintModeExtensions({
|
|
67618
67639
|
cwd: runtime.cwd,
|
|
@@ -67704,6 +67725,8 @@ async function runPrintMode(params) {
|
|
|
67704
67725
|
console.error(event.failure.kind === "context_overflow" ? "Context overflow detected, compacting..." : "Auto-compacting context before retry...");
|
|
67705
67726
|
} else if (event.type === "auto_compaction_start") {
|
|
67706
67727
|
console.error(event.reason === "overflow" ? "Context overflow detected, compacting..." : "Auto-compacting context...");
|
|
67728
|
+
} else if (event.type === "auto_compaction_end" && !event.errorMessage) {
|
|
67729
|
+
runtime.fileObservationState.clear();
|
|
67707
67730
|
} else if (event.type === "turn_retry_started") {
|
|
67708
67731
|
console.error(`Retrying request (${event.attempt}/${event.maxRetries})...`);
|
|
67709
67732
|
} else if (event.type === "turn_retry_succeeded") {
|
|
@@ -68120,6 +68143,9 @@ async function runJsonEventsMode(params) {
|
|
|
68120
68143
|
}
|
|
68121
68144
|
function handleControllerEvent(event) {
|
|
68122
68145
|
trace?.noteRuntimeEvent(event.type, event);
|
|
68146
|
+
if (event.type === "auto_compaction_end" && !event.errorMessage) {
|
|
68147
|
+
params.runtime?.fileObservationState.clear();
|
|
68148
|
+
}
|
|
68123
68149
|
if (event.type === "turn_settled" && activeTurn) {
|
|
68124
68150
|
finalizePendingTerminal();
|
|
68125
68151
|
writeEvent({
|
|
@@ -68235,7 +68261,7 @@ async function runJsonEventsMode(params) {
|
|
|
68235
68261
|
if (runtime.initialModel.unconfigured) {
|
|
68236
68262
|
return;
|
|
68237
68263
|
}
|
|
68238
|
-
const { Agent: AgentClass } = await import("./chunks/src-
|
|
68264
|
+
const { Agent: AgentClass } = await import("./chunks/src-7UV3KKGU.js");
|
|
68239
68265
|
const jsonModeExtensions = await loadJsonModeExtensions({ runtime, getAgent: () => agent });
|
|
68240
68266
|
const tools = [...runtime.tools, ...jsonModeExtensions.extensionTools];
|
|
68241
68267
|
recordCliCompositionStep(runtime.compositionTrace, {
|
|
@@ -68662,7 +68688,7 @@ async function createCliTestStreamFnFromEnv() {
|
|
|
68662
68688
|
if (!process.env.PIE_TEST_MOCK_STREAM_SEQUENCE) {
|
|
68663
68689
|
return void 0;
|
|
68664
68690
|
}
|
|
68665
|
-
const { createTestStreamFnFromSequenceEnv } = await import("./chunks/test-stream-
|
|
68691
|
+
const { createTestStreamFnFromSequenceEnv } = await import("./chunks/test-stream-PP63L7MK.js");
|
|
68666
68692
|
return createTestStreamFnFromSequenceEnv();
|
|
68667
68693
|
}
|
|
68668
68694
|
async function startChat(initialPrompt, testCommand) {
|