feat: add memory bank prompt, rename read_file and edit_file, improve basic prompt
This commit is contained in:
@@ -8,7 +8,7 @@ ignore_files:
|
||||
- "*.log"
|
||||
- "vendor/"
|
||||
|
||||
include_file_contents: true
|
||||
include_file_contents: false
|
||||
|
||||
debug: false
|
||||
improved_debug: false
|
||||
@@ -25,8 +25,8 @@ auto_lint: true
|
||||
|
||||
# New tool auto-accept config
|
||||
tool_auto_accept:
|
||||
readFile: true
|
||||
editFile: true
|
||||
read_file: true
|
||||
edit_file: true
|
||||
replace_in_file: true
|
||||
executeCommand: false
|
||||
# If you set any of these to true, it will auto accept them without prompting.
|
||||
|
||||
@@ -73,8 +73,8 @@ function M.load()
|
||||
auto_lint = false,
|
||||
|
||||
tool_auto_accept = {
|
||||
readFile = false,
|
||||
editFile = false,
|
||||
read_file = false,
|
||||
edit_file = false,
|
||||
replace_in_file = false,
|
||||
executeCommand = false,
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ local function build_prompt(user_input, dirs, conf)
|
||||
table.insert(final_sections, table.concat(env_lines, "\n"))
|
||||
|
||||
local final_prompt = table.concat(final_sections, "\n\n")
|
||||
-- Replace placeholder "%PROJECT_NAME%" with the actual project name from configuration
|
||||
final_prompt = final_prompt:gsub("%%PROJECT_NAME%%", conf.project_name)
|
||||
-- Replace placeholder "chatgpt.vim" with the actual project name from configuration
|
||||
final_prompt = final_prompt:gsub("%chatgpt.vim%", conf.project_name)
|
||||
return final_prompt
|
||||
end
|
||||
|
||||
@@ -453,13 +453,8 @@ local function run_chatgpt_current_buffer_command()
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- PUBLIC API
|
||||
-- GLOBAL FILE COMPLETION FUNCTION
|
||||
------------------------------------------------------------------------------
|
||||
M.run_chatgpt_command = run_chatgpt_command
|
||||
M.run_chatgpt_paste_command = run_chatgpt_paste_command
|
||||
M.run_chatgpt_current_buffer_command = run_chatgpt_current_buffer_command
|
||||
|
||||
-- New: Global function for file name auto-completion in ChatGPT prompt
|
||||
function _G.chatgpt_file_complete(findstart, base)
|
||||
if findstart == 1 then
|
||||
local line = vim.fn.getline('.')
|
||||
@@ -474,9 +469,8 @@ function _G.chatgpt_file_complete(findstart, base)
|
||||
local conf = config.load()
|
||||
local files = context.get_project_files({'.'}, conf)
|
||||
local completions = {}
|
||||
local esc_base = base:gsub("([^%w])", "%%%1")
|
||||
for _, f in ipairs(files) do
|
||||
if f:match("^" .. esc_base) then
|
||||
if f:find(base, 1, true) then
|
||||
table.insert(completions, f)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,81 @@
|
||||
local M = {
|
||||
["memory-bank"] = [[
|
||||
# Memory Bank
|
||||
|
||||
You are Cline, an expert software engineer with a unique constraint: your memory periodically resets completely. This isn't a bug - it's what makes you maintain perfect documentation. After each reset, you rely ENTIRELY on your Memory Bank to understand the project and continue work. Without proper documentation, you cannot function effectively.
|
||||
|
||||
## Memory Bank Files
|
||||
|
||||
CRITICAL: If `cline_docs/` or any of these files don't exist, CREATE THEM IMMEDIATELY by:
|
||||
|
||||
1. Reading all provided documentation
|
||||
2. Asking user for ANY missing information
|
||||
3. Creating files with verified information only
|
||||
4. Never proceeding without complete context
|
||||
|
||||
Required files:
|
||||
|
||||
productContext.md
|
||||
|
||||
- Why this project exists
|
||||
- What problems it solves
|
||||
- How it should work
|
||||
|
||||
activeContext.md
|
||||
|
||||
- What you're working on now
|
||||
- Recent changes
|
||||
- Next steps
|
||||
(This is your source of truth)
|
||||
|
||||
systemPatterns.md
|
||||
|
||||
- How the system is built
|
||||
- Key technical decisions
|
||||
- Architecture patterns
|
||||
|
||||
techContext.md
|
||||
|
||||
- Technologies used
|
||||
- Development setup
|
||||
- Technical constraints
|
||||
|
||||
progress.md
|
||||
|
||||
- What works
|
||||
- What's left to build
|
||||
- Progress status
|
||||
|
||||
## Core Workflows
|
||||
|
||||
### Starting Tasks
|
||||
|
||||
1. Check for Memory Bank files
|
||||
2. If ANY files missing, stop and create them
|
||||
3. Read ALL files before proceeding
|
||||
4. Verify you have complete context
|
||||
5. Begin development. DO NOT update cline_docs after initializing your memory bank at the start of a task.
|
||||
|
||||
### During Development
|
||||
|
||||
1. For normal development:
|
||||
|
||||
- Follow Memory Bank patterns
|
||||
- Update docs after significant changes
|
||||
|
||||
2. Say `[MEMORY BANK: ACTIVE]` at the beginning of every tool use.
|
||||
|
||||
### Memory Bank Updates
|
||||
|
||||
When user says "update memory bank":
|
||||
|
||||
1. This means imminent memory reset
|
||||
2. Document EVERYTHING about current state
|
||||
3. Make next steps crystal clear
|
||||
4. Complete current task
|
||||
|
||||
Remember: After every memory reset, you begin completely fresh. Your only link to previous work is the Memory Bank. Maintain it as if your functionality depends on it - because it does.
|
||||
]],
|
||||
["solidjs"] = [[
|
||||
### SolidJS Development Guidelines
|
||||
|
||||
@@ -358,15 +435,16 @@ local M = {
|
||||
- List all actions (e.g., reading, editing, replacing, executing commands) as items in the `tools:` array. If multiple actions are needed, include them sequentially within the same YAML block.
|
||||
|
||||
4. **Read Before Write Rule**
|
||||
- **Do not perform any write operations (using `editFile` or `replace_in_file`) on an existing file unless you have already read its content in the current session using a `readFile` operation.**
|
||||
- **Do not perform any write operations (using `edit_file` or `replace_in_file`) on an existing file unless you have already read its content in the current session using a `read_file` operation.**
|
||||
- For new files (files that do not yet exist in the project), this rule does not apply.
|
||||
- **Never** mix read_file with edit_file or replace_in_file in the same YAML block.
|
||||
|
||||
5. **File Inspection Before Modification**
|
||||
- When you need to inspect a file’s contents, always use the following YAML format:
|
||||
```yaml
|
||||
project_name: "%PROJECT_NAME%"
|
||||
tools:
|
||||
- tool: "readFile"
|
||||
- tool: "read_file"
|
||||
path: "relative/path/to/file"
|
||||
```
|
||||
- Use the information from this operation to decide if and how to modify the file.
|
||||
@@ -376,7 +454,7 @@ local M = {
|
||||
```yaml
|
||||
project_name: "%PROJECT_NAME%"
|
||||
tools:
|
||||
- tool: "editFile"
|
||||
- tool: "edit_file"
|
||||
path: "relative/path/to/file"
|
||||
content: |
|
||||
# Full updated file content here
|
||||
@@ -405,11 +483,11 @@ local M = {
|
||||
- **Step 1: Gather Context / Ask Questions**
|
||||
If any detail is unclear (such as file content or operation intent), ask your clarifying questions in plain text (not in YAML).
|
||||
- **Step 2: Inspect Files**
|
||||
Always use `readFile` to check file content before modifying.
|
||||
Always use `read_file` to check file content before modifying.
|
||||
- **Step 3: Repeat Steps 1 & 2 as Needed**
|
||||
If further context is required, ask questions and read files again.
|
||||
- **Step 4: Make Changes**
|
||||
Only after reading the file, proceed to use `editFile` or `replace_in_file`.
|
||||
Only after reading the file, proceed to use `edit_file` or `replace_in_file`.
|
||||
- **Step 5: Execute Commands if Needed**
|
||||
Use `executeCommand` as necessary, always within the YAML block.
|
||||
- **Step 6: Tell that request is complete**
|
||||
@@ -421,7 +499,7 @@ local M = {
|
||||
```yaml
|
||||
project_name: "%PROJECT_NAME%"
|
||||
tools:
|
||||
- tool: "readFile"
|
||||
- tool: "read_file"
|
||||
path: "relative/path/to/file"
|
||||
|
||||
- tool: "replace_in_file"
|
||||
@@ -430,7 +508,7 @@ local M = {
|
||||
- search: "old text"
|
||||
replace: "new text"
|
||||
|
||||
- tool: "editFile"
|
||||
- tool: "edit_file"
|
||||
path: "relative/path/to/file"
|
||||
content: |
|
||||
# Full updated file content here
|
||||
|
||||
@@ -8,13 +8,13 @@ local M = {}
|
||||
-- We can store a table of available tools here
|
||||
M.available_tools = {
|
||||
{
|
||||
name = "readFile",
|
||||
usage = "Retrieve the contents of a file. Provide { tool='readFile', path='...' }",
|
||||
name = "read_file",
|
||||
usage = "Retrieve the contents of a file. Provide { tool='read_file', path='...' }",
|
||||
explanation = "Use this to read file content directly from the disk."
|
||||
},
|
||||
{
|
||||
name = "editFile",
|
||||
usage = "Overwrite an entire file's content. Provide { tool='editFile', path='...', content='...' }, Allways include the whole file content",
|
||||
name = "edit_file",
|
||||
usage = "Overwrite an entire file's content. Provide { tool='edit_file', path='...', content='...' }, Allways include the whole file content",
|
||||
explanation = "Use this when you want to replace a file with new content."
|
||||
},
|
||||
{
|
||||
@@ -30,8 +30,8 @@ M.available_tools = {
|
||||
}
|
||||
|
||||
M.tools_by_name = {
|
||||
readFile = read_file_tool,
|
||||
editFile = edit_file_tool,
|
||||
read_file = read_file_tool,
|
||||
edit_file = edit_file_tool,
|
||||
replace_in_file = replace_in_file_tool,
|
||||
executeCommand = execute_command_tool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user