Skip to content

feat(cli): default 'add' to raw/ with summary + cleanup, auto_delete_added_files config - #232

Open
sebastianbraun25 wants to merge 4 commits into
VectifyAI:mainfrom
sebastianbraun25:feat/issue-231-add-all-command
Open

feat(cli): default 'add' to raw/ with summary + cleanup, auto_delete_added_files config#232
sebastianbraun25 wants to merge 4 commits into
VectifyAI:mainfrom
sebastianbraun25:feat/issue-231-add-all-command

Conversation

@sebastianbraun25

@sebastianbraun25 sebastianbraun25 commented Aug 27, 2026

Copy link
Copy Markdown

Note

This PR was created in collaboration between a human and AI: implementation, tests, and
PR text were created by an AI assistant under the guidance and review of the human author.

Problem

The openkb add command supports adding directories recursively, but users who frequently
download documents to raw/ had to manually invoke openkb add raw/ and then manually
delete processed files. There was no batch-processing shortcut for the raw/ staging
directory, no summary of the outcome, and no configuration option to auto-delete successfully
ingested files and duplicates.

An earlier version of this PR addressed this by adding a separate openkb add-all command.
On further review this duplicated almost the entire add directory-processing code path
(same file walk, same filtering, same per-file ingestion call). This PR now consolidates that
functionality directly into add instead of introducing a second, largely redundant command.

Solution / Changes

openkb add (no changes for existing usage):

  • add <path> behaves exactly as before for files, directories, and URLs.
  • add with no PATH argument (and no --from-pageindex-cloud) now defaults to the
    KB's raw/ directory, walks it recursively, and ingests all supported file types
    (PDF, Markdown, DOCX, PPTX, XLSX, XLS, HTML, TXT, CSV).
  • When processing a directory (default raw/ or an explicit path), add now prints an
    aggregated summary at the end: Added: X, Skipped: Y, Failed: Z, Deleted: W.
  • If auto_delete_added_files is enabled, now-empty subdirectories are cleaned up after a
    directory run (in addition to per-file deletion, which already existed).

New configuration parameter:

  • auto_delete_added_files (boolean, default: false)
  • When enabled, add automatically deletes files after processing
  • Deletes on both "added" (successful ingestion) and "skipped" (duplicate/already in KB)
  • Preserves "failed" files to allow user retries
  • Applies to all ingest methods: direct files, directories (including the default raw/), and URLs

Implementation:

  • Added _delete_if_auto_cleanup_enabled() helper function to handle cleanup logic
  • Added _cleanup_empty_directories() for post-run empty-subdirectory cleanup
  • Removed the standalone add-all command entirely (unreleased, no deprecation/alias needed)
    in favor of add with no PATH argument
  • Updated add's docstring to document the default-raw/, summary, and cleanup behavior
  • Updated tests and README accordingly

Issues

@sebastianbraun25
sebastianbraun25 force-pushed the feat/issue-231-add-all-command branch from eecc0bc to 680c04b Compare August 28, 2026 14:14
@sebastianbraun25

Copy link
Copy Markdown
Author

Rewrote this branch's history to remove unrelated commits.

The branch had accidentally picked up commits from the (now-withdrawn, see
#229/#230) retry-timeout work as ancestors — likely from being built on top
of a local integration branch at the time rather than directly off
main. That made this PR's diff show unrelated changes to
openkb/agent/compiler.py and a new tests/test_compiler_retry.py
that have nothing to do with add-all/auto-delete.

Rebuilt cleanly from current main with only the two commits that
actually belong to this feature (add-all command + the
auto-delete-on-skipped follow-up fix). Diff now only touches
openkb/cli.py and openkb/config.py as expected. No functional
changes to the add-all feature itself — force-pushed the same branch name so
this PR stays open with its history/comments intact.

@sebastianbraun25
sebastianbraun25 force-pushed the feat/issue-231-add-all-command branch from 0885647 to 153149c Compare August 31, 2026 08:46
Sebastian Braun added 3 commits August 31, 2026 14:27
…ption

- New 'openkb add-all' command processes all files in raw/ directory
- New config parameter 'auto_delete_added_files' (default: false)
- When enabled, both 'add' and 'add-all' automatically delete successfully ingested files
- Updated help texts to document the new cleanup behavior
- Config applies to all ingest methods: direct files, directories, and URLs
Duplicates (skipped files) should also be auto-deleted when auto_delete_added_files
is enabled, so raw/ stays clean. Only 'failed' status files are preserved to allow
retries. Updated docstrings and helper function logic accordingly.
When auto_delete_added_files is enabled, the add-all command now recursively
cleans up empty subdirectories in raw/ after file deletion. Directories are
deleted from deepest to shallowest to ensure proper cleanup. Added summary
output showing count of cleaned directories.
@sebastianbraun25
sebastianbraun25 force-pushed the feat/issue-231-add-all-command branch from 153149c to a57bcd9 Compare August 31, 2026 12:31
@sebastianbraun25 sebastianbraun25 changed the title feat(cli): add 'add-all' command and auto_delete_added_files config feat(cli): default 'add' to raw/ with summary + cleanup, auto_delete_added_files config Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): add-all command and auto_delete_added_files config

1 participant