summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/atCommandProcessor.ts
diff options
context:
space:
mode:
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 ---' });