summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/atCommandProcessor.ts
diff options
context:
space:
mode:
authorSeth Troisi <[email protected]>2025-06-12 16:08:27 -0700
committerGitHub <[email protected]>2025-06-12 23:08:27 +0000
commitb7daa7c7021691e3466c4b629e600b7b3af949f0 (patch)
tree535f4f65b70a634bce4ab644428e68639e8c2ef8 /packages/cli/src/ui/hooks/atCommandProcessor.ts
parent61d0cc39fdf69f5f7be5171c44cee6323303b8fe (diff)
Fixed @ file content not being added or sent to server (#962)
Diffstat (limited to 'packages/cli/src/ui/hooks/atCommandProcessor.ts')
-rw-r--r--packages/cli/src/ui/hooks/atCommandProcessor.ts42
1 files changed, 13 insertions, 29 deletions
diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.ts b/packages/cli/src/ui/hooks/atCommandProcessor.ts
index f96f6635..04e64f45 100644
--- a/packages/cli/src/ui/hooks/atCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/atCommandProcessor.ts
@@ -366,38 +366,22 @@ export async function handleAtCommand({
confirmationDetails: undefined,
};
- if (
- result.llmContent &&
- typeof result.llmContent === 'string' &&
- result.llmContent.trim() !== ''
- ) {
+ if (Array.isArray(result.llmContent)) {
+ const fileContentRegex = /^--- (.*?) ---\n\n([\s\S]*?)\n\n$/;
processedQueryParts.push({
text: '\n--- Content from referenced files ---',
});
- const fileContentRegex =
- /\n--- (.*?) ---\n([\s\S]*?)(?=\n--- .*? ---\n|$)/g;
- let match;
- const foundContentForSpecs = new Set<string>();
- while ((match = fileContentRegex.exec(result.llmContent)) !== null) {
- const filePathSpecInContent = match[1]; // This is a resolved pathSpec
- const fileActualContent = match[2].trim();
- if (pathSpecsToRead.includes(filePathSpecInContent)) {
- // Ensure we only add content for paths we requested
- processedQueryParts.push({
- text: `\nContent from @${filePathSpecInContent}:\n`,
- });
- processedQueryParts.push({ text: fileActualContent });
- foundContentForSpecs.add(filePathSpecInContent);
- }
- }
- // Check if any requested pathSpecs didn't yield content in the parsed block, could indicate an issue.
- for (const requestedSpec of pathSpecsToRead) {
- if (!foundContentForSpecs.has(requestedSpec)) {
- onDebugMessage(
- `Content for @${requestedSpec} was expected but not found in read_many_files output.`,
- );
- // Optionally add a note about missing content for this spec
- // processedQueryParts.push({ text: `\nContent for @${requestedSpec} not found or empty.\n` });
+ for (const part of result.llmContent) {
+ if (typeof part === 'string') {
+ const match = fileContentRegex.exec(part);
+ if (match) {
+ const filePathSpecInContent = match[1]; // This is a resolved pathSpec
+ const fileActualContent = match[2].trim();
+ processedQueryParts.push({
+ text: `\nContent from @${filePathSpecInContent}:\n`,
+ });
+ processedQueryParts.push({ text: fileActualContent });
+ }
}
}
processedQueryParts.push({ text: '\n--- End of content ---' });