Skip to content

Commit 357fe59

Browse files
committed
Fix get_changed_files_prompt to return ALL staged files
The function was incorrectly subtracting the baseline files from the current staged files, which meant modified files were never detected (they appear in both sets and get subtracted out). Now the function simply returns ALL files with staged changes, which is what trigger/safety, set, and pair mode rules need to detect file modifications during the agent response. The baseline file is only used by get_created_files_prompt() to detect truly NEW files for created: mode rules. This completes the fix for the created mode rules bug - both issues are now resolved: 1. Baseline captures ALL tracked files (not just changed) 2. Changed files detection returns ALL staged files (not just new)
1 parent 5f96ca7 commit 357fe59

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/deepwork/hooks/rules_check.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,16 @@ def get_changed_files_default_tip() -> list[str]:
199199

200200

201201
def get_changed_files_prompt() -> list[str]:
202-
"""Get files changed since prompt was submitted."""
203-
baseline_path = Path(".deepwork/.last_work_tree")
202+
"""Get files changed since prompt was submitted.
203+
204+
Returns ALL files with staged changes (modified, added, deleted).
205+
This is used by trigger/safety, set, and pair mode rules to detect
206+
file modifications during the agent response.
204207
208+
Note: The baseline file (.last_work_tree) is NOT used here - it's only
209+
used by get_created_files_prompt() to detect truly NEW files for
210+
created: mode rules.
211+
"""
205212
try:
206213
subprocess.run(["git", "add", "-A"], capture_output=True, check=False)
207214

@@ -214,13 +221,7 @@ def get_changed_files_prompt() -> list[str]:
214221
current_files = set(result.stdout.strip().split("\n")) if result.stdout.strip() else set()
215222
current_files = {f for f in current_files if f}
216223

217-
if baseline_path.exists():
218-
baseline_files = set(baseline_path.read_text().strip().split("\n"))
219-
baseline_files = {f for f in baseline_files if f}
220-
new_files = current_files - baseline_files
221-
return sorted(new_files)
222-
else:
223-
return sorted(current_files)
224+
return sorted(current_files)
224225

225226
except (subprocess.CalledProcessError, OSError):
226227
return []

0 commit comments

Comments
 (0)