Skip to content
Merged
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
16 changes: 16 additions & 0 deletions .promptcode/presets/workspace-info-fix.patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# workspace-info-fix preset
# Generated: 2025-12-01T15:01:17.153Z
# Source: files optimized (6 → 5 patterns)
# Optimization: balanced
# Optimized: 4 files → 5 patterns (saved 0)
# Applied rules:
# - almost-all-exclusion: packages/core/src/types (exclude 1)

packages/core/src/types/**
prompts/xml-outputs.md
src/promptGenerator.ts
src/webview/mergeTab.js
!packages/core/src/types/index.ts
!**/node_modules/**
!**/dist/**
!**/build/**
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed
- **Apply & Review Workspace Resolution**: Generated prompts now include workspace info (name and root path) for each file, enabling LLMs to correctly output `<workspace_name>` and `<workspace_root>` tags. This fixes Apply & Review functionality in multi-root workspace scenarios. ([#58](https://github.com/cogflows/promptcode-vscode/issues/58))

## [0.9.0] - 2025-11-19

### Added
Expand Down
13 changes: 10 additions & 3 deletions src/promptGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,23 @@ export async function generatePrompt(
log(`Adding content for ${selectedFiles.length} selected files...`);
finalPromptText += '<file_contents>\n';
for (const file of selectedFiles) {
// Defensive fallback for missing workspace info
const workspaceName = file.workspaceFolderName || 'workspace';
const workspacePath = file.workspaceFolderRootPath || workspaceRoot;

try {
const fileContent = file.content ?? await readFileContent(file.absolutePath);
const relativePath = path.relative(file.workspaceFolderRootPath, file.absolutePath);
finalPromptText += `File: ${relativePath} (${file.tokenCount} tokens)\n`;
const relativePath = path.relative(workspacePath, file.absolutePath);
finalPromptText += `File: ${relativePath} (${file.tokenCount} tokens)\n`;
finalPromptText += `Workspace: ${workspaceName} (${workspacePath})\n`;
finalPromptText += '```\n';
finalPromptText += fileContent;
finalPromptText += '\n```\n\n';
} catch (error) {
log(`Error adding file content for ${file.absolutePath}:`, error);
finalPromptText += `File: ${file.path}\n<!-- Error reading file content: ${(error as Error).message} -->\n\n`;
finalPromptText += `File: ${file.path}\n`;
finalPromptText += `Workspace: ${workspaceName} (${workspacePath})\n`;
finalPromptText += `<!-- Error reading file content: ${(error as Error).message} -->\n\n`;
}
}
finalPromptText += '</file_contents>\n\n';
Expand Down