did ai's job
This commit is contained in:
@@ -0,0 +1,130 @@
|
|||||||
|
# Manual Slop Edit Tool Workflow
|
||||||
|
|
||||||
|
## The Problem
|
||||||
|
The `manual-slop_edit_file` tool requires **exact string matches** (character-for-character). Whitespace differences cause failures. The Python file uses **1-space indentation**.
|
||||||
|
|
||||||
|
## The Rules
|
||||||
|
|
||||||
|
### 1. ALWAYS Use Small, Incremental Edits
|
||||||
|
**WRONG:** Replace large blocks (50+ lines)
|
||||||
|
**RIGHT:** Replace 3-10 lines at a time, verify, repeat
|
||||||
|
|
||||||
|
### 2. Verify Before Editing
|
||||||
|
Before ANY edit to a function you haven't touched recently:
|
||||||
|
```
|
||||||
|
1. Run: git checkout -- src/gui_2.py
|
||||||
|
2. Run: py_check_syntax on src/gui_2.py
|
||||||
|
3. Get current state with get_file_slice
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Reading Before Editing (CRITICAL)
|
||||||
|
- Use `get_file_slice` to get the EXACT text including all whitespace
|
||||||
|
- Copy text directly from the tool output - do NOT reformat
|
||||||
|
- If using get_definition, verify the text matches before editing
|
||||||
|
|
||||||
|
### 4. The Edit Tool Parameters (snake_case)
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
"path": "src/gui_2.py", # Required: file path
|
||||||
|
"old_string": "exact text", # Required: must match EXACTLY
|
||||||
|
"new_string": "replacement", # Required: replacement text
|
||||||
|
"replace_all": false # Optional: replace all occurrences
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 1-Space Indentation in Python
|
||||||
|
- Class methods: ` def` (0 spaces, then 1)
|
||||||
|
- Method body: ` ` (2 spaces total)
|
||||||
|
- Nested blocks: ` ` (3 spaces total)
|
||||||
|
- NO 4-space indentation anywhere in this file
|
||||||
|
|
||||||
|
## Step-by-Step Workflow for gui_2.py
|
||||||
|
|
||||||
|
### Before ANY edit:
|
||||||
|
```powershell
|
||||||
|
git checkout -- src/gui_2.py
|
||||||
|
```
|
||||||
|
|
||||||
|
### Check current state:
|
||||||
|
```powershell
|
||||||
|
py_check_syntax path=src/gui_2.py
|
||||||
|
get_file_slice path=src/gui_2.py start_line=X end_line=Y
|
||||||
|
```
|
||||||
|
|
||||||
|
### For each edit:
|
||||||
|
1. Make the smallest possible change (3-10 lines)
|
||||||
|
2. Run `py_check_syntax` to verify
|
||||||
|
3. If syntax error, immediately `git checkout -- src/gui_2.py`
|
||||||
|
4. Only proceed if syntax is OK
|
||||||
|
|
||||||
|
### If edit fails with "old_string not found":
|
||||||
|
- The text you're trying to replace doesn't EXACTLY match
|
||||||
|
- Use `get_file_slice` to get the exact text
|
||||||
|
- Copy it character-for-character including whitespace
|
||||||
|
- Try again with exact match
|
||||||
|
|
||||||
|
### If syntax error after edit:
|
||||||
|
```powershell
|
||||||
|
git checkout -- src/gui_2.py
|
||||||
|
```
|
||||||
|
Then try again with smaller edit.
|
||||||
|
|
||||||
|
## Alternative: Update Definition Approach
|
||||||
|
|
||||||
|
For large function rewrites, use `py_update_definition`:
|
||||||
|
```
|
||||||
|
name: function_name
|
||||||
|
path: src/gui_2.py
|
||||||
|
new_content: complete new function source
|
||||||
|
```
|
||||||
|
|
||||||
|
This replaces the entire function at once using AST detection.
|
||||||
|
|
||||||
|
## Context Composition Requirements
|
||||||
|
|
||||||
|
### Current Broken State
|
||||||
|
Files & Media works. Context Composition needs:
|
||||||
|
|
||||||
|
1. Add state tracking at start of function:
|
||||||
|
```python
|
||||||
|
if not hasattr(self, 'ctx_files_open'):
|
||||||
|
self.ctx_files_open = True
|
||||||
|
if not hasattr(self, 'ctx_shots_open'):
|
||||||
|
self.ctx_shots_open = True
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Files section with collapsing header and child window:
|
||||||
|
```python
|
||||||
|
if imgui.collapsing_header("Files", self.ctx_files_open):
|
||||||
|
imgui.begin_child("ctx_files_child", imgui.ImVec2(-1, 200), True)
|
||||||
|
# table code here
|
||||||
|
imgui.end_child()
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Screenshots section with collapsing header and child window:
|
||||||
|
```python
|
||||||
|
if imgui.collapsing_header("Screenshots", self.ctx_shots_open):
|
||||||
|
imgui.begin_child("ctx_shots_child", imgui.ImVec2(-1, 100), True)
|
||||||
|
# screenshot list here
|
||||||
|
imgui.end_child()
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Fixed presets bar with push_item_width(150) on the combo
|
||||||
|
|
||||||
|
5. Remove the batch action bar entirely (Full/Agg/Sig/Def/None/Sel All/Del buttons)
|
||||||
|
|
||||||
|
## Key Files
|
||||||
|
- `src/gui_2.py` - Main GUI (1-space indentation, CRLF)
|
||||||
|
- `src/models.py` - Data models including FileItem
|
||||||
|
- Context Composition function: line ~2748
|
||||||
|
|
||||||
|
## Test Command
|
||||||
|
```powershell
|
||||||
|
uv run sloppy.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## If Everything Goes Wrong
|
||||||
|
```powershell
|
||||||
|
git checkout -- src/gui_2.py
|
||||||
|
git checkout -- src/models.py
|
||||||
|
```
|
||||||
+7
-17
@@ -2747,22 +2747,8 @@ class App:
|
|||||||
imgui.text_disabled("Message & Response panels are detached.")
|
imgui.text_disabled("Message & Response panels are detached.")
|
||||||
|
|
||||||
def _render_context_composition_panel(self) -> None:
|
def _render_context_composition_panel(self) -> None:
|
||||||
imgui.text("Context Composition")
|
if imgui.collapsing_header("Context Composition"):
|
||||||
imgui.separator()
|
#region: Batch Action Bar
|
||||||
|
|
||||||
def _batch_helper(name: str, attr: str):
|
|
||||||
imgui.same_line()
|
|
||||||
if imgui.button(name + "##batch"):
|
|
||||||
for f in self.files:
|
|
||||||
f_path = f.path if hasattr(f, "path") else str(f)
|
|
||||||
if f_path in self.ui_selected_context_files:
|
|
||||||
f.force_full = True
|
|
||||||
f.auto_aggregate = False
|
|
||||||
if hasattr(f, attr):
|
|
||||||
f.ast_signatures = False
|
|
||||||
f.ast_definitions = False
|
|
||||||
|
|
||||||
# Batch Action Bar
|
|
||||||
imgui.text("Batch:")
|
imgui.text("Batch:")
|
||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
if imgui.button("Full##batch"):
|
if imgui.button("Full##batch"):
|
||||||
@@ -2831,6 +2817,7 @@ class App:
|
|||||||
new_files.append(f)
|
new_files.append(f)
|
||||||
self.files = new_files
|
self.files = new_files
|
||||||
self.ui_selected_context_files.clear()
|
self.ui_selected_context_files.clear()
|
||||||
|
#endregion: Batch Action Bar
|
||||||
|
|
||||||
imgui.dummy(imgui.ImVec2(0, 4))
|
imgui.dummy(imgui.ImVec2(0, 4))
|
||||||
|
|
||||||
@@ -2892,8 +2879,11 @@ class App:
|
|||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
_, f_item.ast_definitions = imgui.checkbox(f"Def##cc{i}", f_item.ast_definitions)
|
_, f_item.ast_definitions = imgui.checkbox(f"Def##cc{i}", f_item.ast_definitions)
|
||||||
imgui.end_table()
|
imgui.end_table()
|
||||||
|
# Context Composition collasping header
|
||||||
|
|
||||||
imgui.separator()
|
imgui.separator()
|
||||||
imgui.text("Screenshots")
|
|
||||||
|
if imgui.collapsing_header("Screenshots"):
|
||||||
for i, s in enumerate(self.screenshots):
|
for i, s in enumerate(self.screenshots):
|
||||||
imgui.text(s)
|
imgui.text(s)
|
||||||
imgui.separator()
|
imgui.separator()
|
||||||
|
|||||||
Reference in New Issue
Block a user