Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/__tests__/command-mentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe("Command Mentions", () => {
false, // showRooIgnoredFiles
true, // includeDiagnosticMessages
50, // maxDiagnosticMessages
undefined, // maxReadFileLine
)
}

Expand Down
94 changes: 0 additions & 94 deletions src/core/mentions/__tests__/processUserContentMentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,97 +26,6 @@ describe("processUserContentMentions", () => {
vi.mocked(parseMentions).mockImplementation(async (text) => `parsed: ${text}`)
})

describe("maxReadFileLine parameter", () => {
it("should pass maxReadFileLine to parseMentions when provided", async () => {
const userContent = [
{
type: "text" as const,
text: "<task>Read file with limit</task>",
},
]

await processUserContentMentions({
userContent,
cwd: "/test",
urlContentFetcher: mockUrlContentFetcher,
fileContextTracker: mockFileContextTracker,
rooIgnoreController: mockRooIgnoreController,
maxReadFileLine: 100,
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Read file with limit</task>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
mockRooIgnoreController,
false,
true, // includeDiagnosticMessages
50, // maxDiagnosticMessages
100,
)
})

it("should pass undefined maxReadFileLine when not provided", async () => {
const userContent = [
{
type: "text" as const,
text: "<task>Read file without limit</task>",
},
]

await processUserContentMentions({
userContent,
cwd: "/test",
urlContentFetcher: mockUrlContentFetcher,
fileContextTracker: mockFileContextTracker,
rooIgnoreController: mockRooIgnoreController,
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Read file without limit</task>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
mockRooIgnoreController,
false,
true, // includeDiagnosticMessages
50, // maxDiagnosticMessages
undefined,
)
})

it("should handle UNLIMITED_LINES constant correctly", async () => {
const userContent = [
{
type: "text" as const,
text: "<task>Read unlimited lines</task>",
},
]

await processUserContentMentions({
userContent,
cwd: "/test",
urlContentFetcher: mockUrlContentFetcher,
fileContextTracker: mockFileContextTracker,
rooIgnoreController: mockRooIgnoreController,
maxReadFileLine: -1,
})

expect(parseMentions).toHaveBeenCalledWith(
"<task>Read unlimited lines</task>",
"/test",
mockUrlContentFetcher,
mockFileContextTracker,
mockRooIgnoreController,
false,
true, // includeDiagnosticMessages
50, // maxDiagnosticMessages
-1,
)
})
})

describe("content processing", () => {
it("should process text blocks with <task> tags", async () => {
const userContent = [
Expand Down Expand Up @@ -273,7 +182,6 @@ describe("processUserContentMentions", () => {
cwd: "/test",
urlContentFetcher: mockUrlContentFetcher,
fileContextTracker: mockFileContextTracker,
maxReadFileLine: 50,
})

expect(parseMentions).toHaveBeenCalledTimes(2)
Expand Down Expand Up @@ -316,7 +224,6 @@ describe("processUserContentMentions", () => {
false, // showRooIgnoredFiles should default to false
true, // includeDiagnosticMessages
50, // maxDiagnosticMessages
undefined,
)
})

Expand Down Expand Up @@ -345,7 +252,6 @@ describe("processUserContentMentions", () => {
false,
true, // includeDiagnosticMessages
50, // maxDiagnosticMessages
undefined,
)
})
})
Expand Down
16 changes: 5 additions & 11 deletions src/core/mentions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export async function parseMentions(
showRooIgnoredFiles: boolean = false,
includeDiagnosticMessages: boolean = true,
maxDiagnosticMessages: number = 50,
maxReadFileLine?: number,
): Promise<string> {
const mentions: Set<string> = new Set()
const validCommands: Map<string, Command> = new Map()
Expand Down Expand Up @@ -182,13 +181,7 @@ export async function parseMentions(
} else if (mention.startsWith("/")) {
const mentionPath = mention.slice(1)
try {
const content = await getFileOrFolderContent(
mentionPath,
cwd,
rooIgnoreController,
showRooIgnoredFiles,
maxReadFileLine,
)
const content = await getFileOrFolderContent(mentionPath, cwd, rooIgnoreController, showRooIgnoredFiles)
if (mention.endsWith("/")) {
parsedText += `\n\n<folder_content path="${mentionPath}">\n${content}\n</folder_content>`
} else {
Expand Down Expand Up @@ -265,7 +258,6 @@ async function getFileOrFolderContent(
cwd: string,
rooIgnoreController?: any,
showRooIgnoredFiles: boolean = false,
maxReadFileLine?: number,
): Promise<string> {
const unescapedPath = unescapeSpaces(mentionPath)
const absPath = path.resolve(cwd, unescapedPath)
Expand All @@ -278,7 +270,8 @@ async function getFileOrFolderContent(
return `(File ${mentionPath} is ignored by .rooignore)`
}
try {
const content = await extractTextFromFile(absPath, maxReadFileLine)
// Always read full file for @ mentions (bypass maxReadFileLine)
const content = await extractTextFromFile(absPath, -1)
return content
} catch (error) {
return `(Failed to read contents of ${mentionPath}): ${error.message}`
Expand Down Expand Up @@ -318,7 +311,8 @@ async function getFileOrFolderContent(
if (isBinary) {
return undefined
}
const content = await extractTextFromFile(absoluteFilePath, maxReadFileLine)
// Always read full file for @ mentions (bypass maxReadFileLine)
const content = await extractTextFromFile(absoluteFilePath, -1)
return `<file_content path="${filePath.toPosix()}">\n${content}\n</file_content>`
} catch (error) {
return undefined
Expand Down
5 changes: 0 additions & 5 deletions src/core/mentions/processUserContentMentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export async function processUserContentMentions({
showRooIgnoredFiles = false,
includeDiagnosticMessages = true,
maxDiagnosticMessages = 50,
maxReadFileLine,
}: {
userContent: Anthropic.Messages.ContentBlockParam[]
cwd: string
Expand All @@ -25,7 +24,6 @@ export async function processUserContentMentions({
showRooIgnoredFiles?: boolean
includeDiagnosticMessages?: boolean
maxDiagnosticMessages?: number
maxReadFileLine?: number
}) {
// Process userContent array, which contains various block types:
// TextBlockParam, ImageBlockParam, ToolUseBlockParam, and ToolResultBlockParam.
Expand Down Expand Up @@ -58,7 +56,6 @@ export async function processUserContentMentions({
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
maxReadFileLine,
),
}
}
Expand All @@ -78,7 +75,6 @@ export async function processUserContentMentions({
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
maxReadFileLine,
),
}
}
Expand All @@ -99,7 +95,6 @@ export async function processUserContentMentions({
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
maxReadFileLine,
),
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
showRooIgnoredFiles = false,
includeDiagnosticMessages = true,
maxDiagnosticMessages = 50,
maxReadFileLine = -1,
} = (await this.providerRef.deref()?.getState()) ?? {}

const parsedUserContent = await processUserContentMentions({
Expand All @@ -2180,7 +2179,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
maxReadFileLine,
})

const environmentDetails = await getEnvironmentDetails(this, currentIncludeFileDetails)
Expand Down
Loading