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
Copy file name to clipboardExpand all lines: docs/CLI.md
+241Lines changed: 241 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,6 +236,247 @@ Priority (highest to lowest):
236
236
3. Config file (`~/.bpsa.yaml`)
237
237
4. Built-in defaults
238
238
239
+
## Utility CLIs
240
+
241
+
Beyond the main `bpsa` REPL, the project ships lightweight CLI wrappers around commonly used tools from `bp_tools.py`. All are installed automatically via `pip install` and support `--help`.
242
+
243
+
### Quick Reference
244
+
245
+
| Command | Description |
246
+
|---------|-------------|
247
+
|`bptree`| Directory tree with line counts and optional function signatures |
248
+
|`bpgrep`| Search for text patterns in files with extension filtering |
249
+
|`bppack`| Pack a folder's source code into a single tagged string |
250
+
|`bpunpack`| Reconstruct source files from a packed string |
251
+
|`bploc`| Lines-of-code summary broken down by file type |
252
+
|`bpdiff`| Compare two files or two folders (unified diff) |
253
+
|`bpsig`| Extract function/class signatures from a source file |
254
+
|`bppas`| Extract Pascal unit interface sections from a folder |
255
+
256
+
Entry points in `pyproject.toml`:
257
+
```toml
258
+
[project.scripts]
259
+
bptree = "smolagents.bp_tree_cli:main"
260
+
bpgrep = "smolagents.bp_grep_cli:main"
261
+
bppack = "smolagents.bp_pack_cli:main"
262
+
bpunpack = "smolagents.bp_unpack_cli:main"
263
+
bploc = "smolagents.bp_loc_cli:main"
264
+
bpdiff = "smolagents.bp_diff_cli:main"
265
+
bpsig = "smolagents.bp_sig_cli:main"
266
+
bppas = "smolagents.bp_pas_cli:main"
267
+
```
268
+
269
+
---
270
+
271
+
### `bptree` — Directory Tree
272
+
273
+
Displays a tree view of a directory with source-file line counts and optional function signatures. Skips common build/artifact folders by default.
|`-m`, `--max-results N`| Maximum results to return (default: 50) |
315
+
316
+
```bash
317
+
# Search for "def main" in Python files
318
+
bpgrep "def main" src/ -e py
319
+
320
+
# Case-sensitive search with limit
321
+
bpgrep "TODO". -c -m 20
322
+
```
323
+
324
+
---
325
+
326
+
### `bppack` — Pack Source Code
327
+
328
+
Packs all source files in a folder into a single string with `<file filename="...">...</file>` XML-like tags. Useful for feeding entire projects to LLMs or creating context dumps.
Reconstructs source files from a packed string produced by `bppack`. Reads from a file or stdin.
355
+
356
+
```bash
357
+
bpunpack [INPUT] [-o DIR] [--no-overwrite] [-q]
358
+
```
359
+
360
+
| Flag | Description |
361
+
|------|-------------|
362
+
|`INPUT`| Packed file to read (default: stdin) |
363
+
|`-o`, `--output-dir DIR`| Base directory to write into (default: `.`) |
364
+
|`--no-overwrite`| Skip files that already exist |
365
+
|`-q`, `--quiet`| Suppress status messages |
366
+
367
+
```bash
368
+
# Unpack from file into output/
369
+
bpunpack context.txt -o output/
370
+
371
+
# Pipe from bppack
372
+
bppack src/ | bpunpack -o copy/
373
+
374
+
# Unpack without overwriting existing files
375
+
bpunpack context.txt --no-overwrite
376
+
```
377
+
378
+
---
379
+
380
+
### `bploc` — Lines of Code
381
+
382
+
Counts lines of code broken down by file extension. Skips hidden files and directories.
383
+
384
+
```bash
385
+
bploc [FOLDER] [-e EXTS]
386
+
```
387
+
388
+
| Flag | Description |
389
+
|------|-------------|
390
+
|`FOLDER`| Root folder to analyze (default: `.`) |
391
+
|`-e`, `--extensions`| Comma-separated extensions to count (default: `py,js,java,cpp,c,php,rb`) |
392
+
393
+
```bash
394
+
# Count lines in current project
395
+
bploc
396
+
397
+
# Count only Python and TypeScript
398
+
bploc src/ -e py,ts
399
+
```
400
+
401
+
Example output:
402
+
```
403
+
.py 23985 lines
404
+
total 23985 lines
405
+
```
406
+
407
+
---
408
+
409
+
### `bpdiff` — Compare Files or Folders
410
+
411
+
Compares two files or two folders and shows differences in unified diff format. For folders, only source code files are compared.
412
+
413
+
```bash
414
+
bpdiff PATH1 PATH2 [-c CONTEXT]
415
+
```
416
+
417
+
| Flag | Description |
418
+
|------|-------------|
419
+
|`PATH1`| First file or folder |
420
+
|`PATH2`| Second file or folder |
421
+
|`-c`, `--context N`| Context lines around differences (default: 3) |
422
+
423
+
```bash
424
+
# Compare two files
425
+
bpdiff old_version.py new_version.py
426
+
427
+
# Compare two folders with more context
428
+
bpdiff project_v1/ project_v2/ -c 5
429
+
```
430
+
431
+
---
432
+
433
+
### `bpsig` — Function Signatures
434
+
435
+
Extracts function and class signatures from a source file without showing the implementation. Supports Python, JavaScript/TypeScript, Java, PHP, Pascal, C/C++, Markdown (section headers), and a generic fallback.
436
+
437
+
```bash
438
+
bpsig FILE [-l LANGUAGE]
439
+
```
440
+
441
+
| Flag | Description |
442
+
|------|-------------|
443
+
|`FILE`| Source file to extract signatures from |
444
+
|`-l`, `--language`| Programming language (auto-detected from extension if omitted) |
445
+
446
+
```bash
447
+
# Auto-detect language
448
+
bpsig src/main.py
449
+
450
+
# Explicit language
451
+
bpsig utils.inc -l pascal
452
+
```
453
+
454
+
---
455
+
456
+
### `bppas` — Pascal Interfaces
457
+
458
+
Extracts the interface sections (between `interface` and `implementation` keywords) from Pascal source files in a folder. Output uses `<pascal_interface filename="...">` tags.
459
+
460
+
```bash
461
+
bppas FOLDER [--strip-comments] [-o FILE]
462
+
```
463
+
464
+
| Flag | Description |
465
+
|------|-------------|
466
+
|`FOLDER`| Root folder to scan for `.pas`, `.inc`, `.pp`, `.lpr`, `.dpr` files |
467
+
|`--strip-comments`| Remove Pascal comments from extracted interfaces |
468
+
|`-o`, `--output FILE`| Write to a file instead of stdout |
469
+
470
+
```bash
471
+
# Extract interfaces
472
+
bppas pascal_src/
473
+
474
+
# Strip comments and save to file
475
+
bppas lib/ --strip-comments -o interfaces.txt
476
+
```
477
+
478
+
---
479
+
239
480
## Dependencies
240
481
241
482
-`prompt_toolkit` - REPL input handling (optional, falls back to basic `input()`)
0 commit comments