You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 must manually invoke openkb add raw/ and then manually delete processed files. There is no batch processing command for the /raw staging directory, and no configuration option to auto-delete successfully ingested files and duplicates.
Solution / Changes
New CLI command:
openkb add-all processes all files in the KB's raw/ directory recursively
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.
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 addcommand supports adding directories recursively, but users who frequently download documents to/rawmust manually invokeopenkb add raw/and then manually delete processed files. There is no batch processing command for the/rawstaging directory, and no configuration option to auto-delete successfully ingested files and duplicates.Solution / Changes
New CLI command:
openkb add-allprocesses all files in the KB'sraw/directory recursivelyNew configuration parameter:
auto_delete_added_files(boolean, default:false)addandadd-allautomatically delete files after processingImplementation:
_delete_if_auto_cleanup_enabled()helper function to handle cleanup logicaddandadd-allcommands to use the helper functionIssues