Skip to content

Commit ae00226

Browse files
Cheticclaude
andcommitted
feat: add --list-files CLI command to show indexed documents
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 26ca3ee commit ae00226

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/chunksilo/cli.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def main():
4646
help="Download required ML models, then exit")
4747
parser.add_argument("--dump-defaults", action="store_true",
4848
help="Print all default configuration values as YAML, then exit")
49+
parser.add_argument("--list-files", action="store_true",
50+
help="List all indexed file paths, then exit")
4951

5052
args = parser.parse_args()
5153

@@ -62,6 +64,23 @@ def main():
6264

6365
config_path = Path(args.config) if args.config else None
6466

67+
if args.list_files:
68+
from .cfgload import load_config
69+
from .index import IngestionState
70+
71+
cfg = load_config(config_path)
72+
state_db = Path(cfg["storage"]["storage_dir"]) / "ingestion_state.db"
73+
if not state_db.exists():
74+
print("No index found. Run chunksilo --build-index first.", file=sys.stderr)
75+
sys.exit(1)
76+
paths = sorted(IngestionState(state_db).get_all_files().keys())
77+
if args.json:
78+
print(json.dumps(paths, indent=2))
79+
else:
80+
for p in paths:
81+
print(p)
82+
return
83+
6584
if args.build_index or args.download_models:
6685
# Suppress 3rd-party native output when IndexingUI owns the terminal
6786
if not args.verbose:
@@ -78,7 +97,7 @@ def main():
7897
return
7998

8099
if not args.query:
81-
parser.error("query is required (or use --build-index / --download-models)")
100+
parser.error("query is required (or use --build-index / --list-files / --download-models)")
82101

83102
from .search import run_search
84103

0 commit comments

Comments
 (0)