Skip to content

Commit 3d11c96

Browse files
committed
fix: ehance memory bank prompt for more determinastic file name and path
1 parent de83ec4 commit 3d11c96

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/context/memorybank/memoryBankController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export class MemoryBankController {
115115
`Memory Bank: using ${rankedFilesList.length} files for documentation generation`
116116
)
117117

118-
// Step 5: Create the comprehensive prompt with ranked files
119-
const finalPrompt = MemoryBankPrompts.getCompleteMemoryBankPrompt(rankedFilesList)
118+
// Step 5: Create the comprehensive prompt with ranked files and workspace path
119+
const finalPrompt = MemoryBankPrompts.getCompleteMemoryBankPrompt(rankedFilesList, workspaceFolderUri)
120120
return finalPrompt
121121
} catch (error) {
122122
this.features.logging.error(`Memory Bank preparation failed: ${error}`)

server/aws-lsp-codewhisperer/src/language-server/agenticChat/context/memorybank/memoryBankPrompts.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ${filesString}
3434
/**
3535
* Complete Memory Bank generation - Takes ranked files and generates all 4 memory bank files
3636
*/
37-
static getCompleteMemoryBankPrompt(rankedFiles: string[]): string {
37+
static getCompleteMemoryBankPrompt(rankedFiles: string[], rootPath: string): string {
3838
return `** CRITICAL INSTRUCTION: ALWAYS REGENERATE - NEVER SKIP **
3939
4040
You MUST generate a complete Memory Bank for this project by analyzing the codebase structure and generating comprehensive documentation.
@@ -50,44 +50,55 @@ You MUST generate a complete Memory Bank for this project by analyzing the codeb
5050
**MANDATORY FRESH EXPLORATION POLICY:**
5151
- IGNORE ALL PREVIOUS CHAT HISTORY about this project
5252
- Even if you've analyzed this project before in this conversation, START FRESH
53-
- ALWAYS begin by exploring the project with listDirectory and readFile tools
53+
- ALWAYS begin by exploring the current workspace with listDirectory and readFile tools
5454
- This is REQUIRED even if you think you already know the project structure
5555
- Start with the root directory to understand if this is a multi-package workspace
56-
- Look for package directories, monorepo structure, or multiple components
5756
- Read key configuration files (package.json, README.md, etc.) to understand the project
5857
- This ensures documentation reflects the CURRENT complete codebase structure
5958
6059
**CRITICAL MESSAGING AND TOOL USAGE POLICY:**
6160
- Send your own brief progress messages before using tools (e.g., "Creating product.md - project overview and capabilities...")
61+
- Use ONLY fsWrite tool with command "create" for file creation
62+
- NEVER use fsReplace, fsRead, or other tools for creating memory bank files
6263
- Use tools with ONLY the required parameters: command, path, fileText
6364
- NEVER include the optional "explanation" parameter in any tool call
6465
- Tool calls should be silent - your progress messages provide the user feedback
6566
- Keep progress messages brief and informative
6667
6768
**Directory Structure Ready**
68-
The .amazonq/rules/memory-bank/ directory has been prepared and cleaned. You can directly create files using fsWrite tool.
69+
The .amazonq/rules/memory-bank/ directory has been prepared and cleaned at: ${rootPath}/.amazonq/rules/memory-bank/
70+
71+
You MUST create exactly 4 files using fsWrite tool with these EXACT paths:
72+
- ${rootPath}/.amazonq/rules/memory-bank/product.md
73+
- ${rootPath}/.amazonq/rules/memory-bank/structure.md
74+
- ${rootPath}/.amazonq/rules/memory-bank/tech.md
75+
- ${rootPath}/.amazonq/rules/memory-bank/guidelines.md
6976
7077
**Part 1: Fresh Analysis and Documentation Creation**
7178
7279
FIRST: Start by saying "Now I'll explore the project structure and create the Memory Bank documentation."
7380
74-
THEN: Explore the project structure and create these files (send progress message before each):
81+
THEN: Create these 4 files in exact order:
7582
76-
**product.md** - Project overview with:
77-
- Project purpose and value proposition
83+
**1. product.md** - Project overview with:
84+
- Project purpose and value proposition
7885
- Key features and capabilities
7986
- Target users and use cases
8087
81-
**structure.md** - Project organization with:
88+
**2. structure.md** - Project organization with:
8289
- Directory structure and explanations
83-
- Core components and relationships
90+
- Core components and relationships
8491
- Architectural patterns
8592
86-
**tech.md** - Technology details with:
93+
**3. tech.md** - Technology details with:
8794
- Programming languages and versions
8895
- Build systems and dependencies
8996
- Development commands
9097
98+
**4. guidelines.md** - Development patterns from code analysis (see Part 2 below for analysis process)
99+
100+
Create files 1-3 immediately using fsWrite with command "create" and the exact paths shown above.
101+
91102
**Part 2: Advanced Guidelines Generation Using Iterative Analysis**
92103
93104
THEN: Say "Now I'll analyze the most representative files from the codebase to identify development patterns and create comprehensive guidelines."
@@ -123,11 +134,11 @@ Create comprehensive development guidelines by:
123134
- Analyze patterns in each chunk and build upon previous findings
124135
- Keep track of how many files exhibit each pattern (frequency analysis)
125136
- Build comprehensive guidelines.md iteratively through this process
126-
- When creating guidelines.md, send "Creating guidelines.md - development standards and patterns..." then use fsWrite tool
137+
- Use fsWrite with command "create" and path: ${rootPath}/.amazonq/rules/memory-bank/guidelines.md
127138
128-
**COMPLETION SUMMARY**: After generating all files, provide a brief completion message (maximum 8 lines) that:
129-
- Confirms successful generation
130-
- Lists the 4 files generated with one-line descriptions
139+
**COMPLETION SUMMARY**: After generating all 4 files, provide a brief completion message (maximum 8 lines) that:
140+
- Confirms successful generation of exactly 4 files: product.md, structure.md, tech.md, guidelines.md
141+
- Lists each file with one-line description
131142
- Mentions they're available in Rules panel
132143
- Avoids detailed technical breakdowns
133144

0 commit comments

Comments
 (0)