Skip to content

Commit e4bac4f

Browse files
committed
simple implementation
1 parent 2285015 commit e4bac4f

File tree

25 files changed

+96
-1437
lines changed

25 files changed

+96
-1437
lines changed

src/core/tools/__tests__/contextValidator.test.ts

Lines changed: 0 additions & 476 deletions
This file was deleted.

src/core/tools/__tests__/readFileTool.spec.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ describe("read_file tool XML output structure", () => {
13761376
vi.mocked(contextValidatorModule.validateFileSizeForContext).mockResolvedValue({
13771377
shouldLimit: true,
13781378
safeContentLimit: 2000,
1379-
reason: "File exceeds available context space. Can read 2000 of 500000 characters (40%). Context usage: 10000/100000 tokens (10%).",
1379+
reason: "This is a partial read - the remaining content cannot be accessed due to context limitations.",
13801380
})
13811381

13821382
// Mock readPartialContent to return truncated content
@@ -1394,11 +1394,11 @@ describe("read_file tool XML output structure", () => {
13941394
{ totalLines: 10000, maxReadFileLine: -1 },
13951395
)
13961396

1397-
// Verify the result contains the partial read notice for multi-line files
1397+
// Verify the result contains the simplified partial read notice
13981398
expect(result).toContain("<notice>")
1399-
expect(result).toContain("tools:readFile.partialReadMultiLine")
1400-
// The current implementation doesn't include contextLimitInstructions
1401-
expect(result).not.toContain("tools:readFile.contextLimitInstructions")
1399+
expect(result).toContain(
1400+
"This is a partial read - the remaining content cannot be accessed due to context limitations.",
1401+
)
14021402
})
14031403

14041404
it("should not show any special notice when file fits in context", async () => {
@@ -1427,7 +1427,7 @@ describe("read_file tool XML output structure", () => {
14271427
vi.mocked(contextValidatorModule.validateFileSizeForContext).mockResolvedValue({
14281428
shouldLimit: true,
14291429
safeContentLimit: 5000,
1430-
reason: "Large single-line file (likely minified) exceeds available context space. Only the first 50% (5000 of 10000 characters) can be loaded. This is a hard limit - no additional content from this file can be accessed.",
1430+
reason: "This is a partial read - the remaining content cannot be accessed due to context limitations.",
14311431
})
14321432

14331433
// Mock readPartialContent to return truncated content for single-line file
@@ -1445,11 +1445,11 @@ describe("read_file tool XML output structure", () => {
14451445
{ totalLines: 1, maxReadFileLine: -1 },
14461446
)
14471447

1448-
// Verify the result contains the notice but NOT the line_range instructions
1448+
// Verify the result contains the simplified partial read notice
14491449
expect(result).toContain("<notice>")
1450-
expect(result).toContain("tools:readFile.partialReadSingleLine")
1451-
expect(result).not.toContain("tools:readFile.contextLimitInstructions")
1452-
expect(result).not.toContain("Use line_range")
1450+
expect(result).toContain(
1451+
"This is a partial read - the remaining content cannot be accessed due to context limitations.",
1452+
)
14531453
})
14541454

14551455
it("should include line_range instructions for multi-line files that exceed context", async () => {
@@ -1460,7 +1460,7 @@ describe("read_file tool XML output structure", () => {
14601460
vi.mocked(contextValidatorModule.validateFileSizeForContext).mockResolvedValue({
14611461
shouldLimit: true,
14621462
safeContentLimit: 50000,
1463-
reason: "File exceeds available context space. Can read 50000 of 250000 characters (20%). Context usage: 50000/100000 tokens (50%).",
1463+
reason: "This is a partial read - the remaining content cannot be accessed due to context limitations.",
14641464
})
14651465

14661466
// Mock readPartialContent to return truncated content
@@ -1478,11 +1478,11 @@ describe("read_file tool XML output structure", () => {
14781478
{ totalLines: 5000, maxReadFileLine: -1 },
14791479
)
14801480

1481-
// Verify the result contains the partial read notice for multi-line files
1481+
// Verify the result contains the simplified partial read notice
14821482
expect(result).toContain("<notice>")
1483-
expect(result).toContain("tools:readFile.partialReadMultiLine")
1484-
// The current implementation doesn't include contextLimitInstructions
1485-
expect(result).not.toContain("tools:readFile.contextLimitInstructions")
1483+
expect(result).toContain(
1484+
"This is a partial read - the remaining content cannot be accessed due to context limitations.",
1485+
)
14861486
})
14871487

14881488
it("should handle normal file read section for single-line files with validation notice", async () => {
@@ -1493,7 +1493,7 @@ describe("read_file tool XML output structure", () => {
14931493
vi.mocked(contextValidatorModule.validateFileSizeForContext).mockResolvedValue({
14941494
shouldLimit: true,
14951495
safeContentLimit: 8000,
1496-
reason: "Large single-line file (likely minified) exceeds available context space. Only the first 80% (8000 of 10000 characters) can be loaded.",
1496+
reason: "This is a partial read - the remaining content cannot be accessed due to context limitations.",
14971497
})
14981498

14991499
// Mock readPartialContent for single-line file
@@ -1511,10 +1511,11 @@ describe("read_file tool XML output structure", () => {
15111511
{ totalLines: 1, maxReadFileLine: -1 },
15121512
)
15131513

1514-
// Verify single-line file notice doesn't include line_range instructions
1514+
// Verify the result contains the simplified partial read notice
15151515
expect(result).toContain("<notice>")
1516-
expect(result).toContain("tools:readFile.partialReadSingleLine")
1517-
expect(result).not.toContain("tools:readFile.contextLimitInstructions")
1516+
expect(result).toContain(
1517+
"This is a partial read - the remaining content cannot be accessed due to context limitations.",
1518+
)
15181519
})
15191520
})
15201521
})

0 commit comments

Comments
 (0)