fix: batch — 12 cubic findings from PR #36 + file-tree hardening #40

Merged
FO
5mo ago
+73-11

Summary

Post-merge batch fix for 12 cubic-dev-ai findings from PR #36, plus additional file-tree tool hardening.

Fixed (12 cubic findings)

#FindingStatus
1batch-patch.ts: '' sentinel deletes valid empty files on rollback✅ Fixed
2smart-patch.ts: mixed hunks lose context lines on splice✅ Fixed
3smart-edit.ts: old_string not validated as non-empty✅ Fixed
4solution-confidence.ts: run_tests result parsing missing guard✅ Fixed
5solution-confidence.ts: score can exceed 1.0 via redistribution✅ Fixed
6research.ts: query elements not validated as strings✅ Already validated
7research.ts: scope not validated✅ Already validated
8file-tree.ts: glob regex doesn't escape special chars✅ Fixed
9tests/smart-patch.test.ts: 2x missing await✅ Fixed
10tests/file-tree.test.ts: missing await✅ Fixed
11file-tree.ts: .gitignore claim in description✅ Fixed (removed claim)

Additional file-tree hardening

  • Removed .gitignore dead-code special-casing
  • Unified metadata shape: single files now return metadata.tree (not metadata.entries)
  • Added symlink cycle protection (use lstatSync, skip symlinks)
  • Made SKIP_DIRS unconditional (.git never shown, even with include_hidden: true)
  • Added 5 new tests: filter, depth, hidden files, symlinks, single-file metadata

Test results

  • 110/111 tests pass (1 pre-existing lsp-hover timeout, unrelated)
  • Lint clean on all changed files

Closes #40


Summary by cubic

Batch fixes for 12 findings from PR #36 and hardens the file-tree tool for safer, more consistent output. Addresses #40.

  • Bug Fixes

    • batch-patch: atomic rollback no longer deletes valid empty files (tracks non-existent files as null).
    • smart-patch: preserve context lines; replace only deletions when applying hunks.
    • smart-edit: require non-empty old_string.
    • solution-confidence: guard test result parsing; cap redistributed score at 1.0.
    • file-tree: escape glob patterns; use lstat and skip symlinks; always skip .git, node_modules, vendor; remove .gitignore special-casing; single-file metadata now uses metadata.tree.
    • tests: add cases for filter, depth, hidden files (default off, opt-in via include_hidden), symlinks, and single-file metadata.
  • Migration

    • If you read single-file results, switch from metadata.entries to metadata.tree.
    • .git is always skipped, even with include_hidden: true; symlinked dirs are ignored.

Summary by CodeRabbit

  • Bug Fixes

    • Symbolic links are now properly skipped during directory traversal to prevent cycles
    • Glob pattern filtering now correctly handles special characters in filter expressions
  • Improvements

    • Consistent hidden file handling: dot-prefixed entries are uniformly excluded when hidden files are not requested
    • Enhanced support for directory depth limiting