agentvfs 0.1.6

Virtual filesystem CLI backed by embedded databases for AI agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# Command Reference

Complete reference for all avfs commands. All commands can be run with `avfs <command>` or directly in the interactive shell.

## Navigation Commands

### ls - List directory contents

```bash
avfs ls [OPTIONS] [PATH]
```

**Options:**
- `-l, --long` - Show detailed information (size, date, type)
- `-a, --all` - Include hidden files (starting with `.`)
- `-R, --recursive` - List subdirectories recursively
- `-t, --time` - Sort by modification time
- `-S, --size` - Sort by size

**Examples:**
```bash
avfs ls                    # List current directory
avfs ls /docs              # List specific directory
avfs ls -l /docs           # Detailed listing
avfs ls -laR /             # Full recursive listing
```

### cd - Change directory

```bash
avfs cd [PATH]
```

**Examples:**
```bash
avfs cd /docs              # Change to /docs
avfs cd ..                 # Go up one level
avfs cd                    # Go to root (/)
```

### pwd - Print working directory

```bash
avfs pwd
```

### tree - Display directory tree

```bash
avfs tree [OPTIONS] [PATH]
```

**Options:**
- `-L, --level <N>` - Limit depth to N levels
- `-d, --dirs-only` - Show only directories
- `--size` - Show file sizes

**Examples:**
```bash
avfs tree                  # Tree from current directory
avfs tree -L 2 /           # Tree with max depth 2
avfs tree --size /docs     # Tree with file sizes
```

## File Operations

### cat - Display file contents

```bash
avfs cat [OPTIONS] <PATH>...
```

**Options:**
- `-n, --number` - Number output lines
- `-v, --version <N>` - Show specific version

**Examples:**
```bash
avfs cat /docs/readme.txt          # Show file contents
avfs cat -n /src/main.rs           # With line numbers
avfs cat -v 3 /docs/readme.txt     # Show version 3
avfs cat file1.txt file2.txt       # Concatenate multiple files
```

### write - Write content to a file

```bash
avfs write [OPTIONS] <PATH> [CONTENT]
```

**Options:**
- `-a, --append` - Append instead of overwrite
- `--stdin` - Read content from stdin

**Examples:**
```bash
avfs write /docs/new.txt "Hello, World!"
avfs write -a /docs/log.txt "New line"
echo "piped content" | avfs write --stdin /docs/file.txt
```

### touch - Create empty file or update timestamp

```bash
avfs touch <PATH>...
```

**Examples:**
```bash
avfs touch /docs/newfile.txt
avfs touch file1.txt file2.txt file3.txt
```

### cp - Copy files or directories

```bash
avfs cp [OPTIONS] <SOURCE>... <DEST>
```

**Options:**
- `-r, --recursive` - Copy directories recursively
- `-n, --no-clobber` - Don't overwrite existing files
- `-v, --verbose` - Show files as they're copied

**Examples:**
```bash
avfs cp /docs/file.txt /backup/
avfs cp -r /docs /backup/docs
avfs cp file1.txt file2.txt /dest/
```

### mv - Move or rename files

```bash
avfs mv [OPTIONS] <SOURCE>... <DEST>
```

**Options:**
- `-n, --no-clobber` - Don't overwrite existing files
- `-v, --verbose` - Show files as they're moved

**Examples:**
```bash
avfs mv /docs/old.txt /docs/new.txt    # Rename
avfs mv /docs/file.txt /archive/        # Move
avfs mv file1.txt file2.txt /dest/      # Move multiple
```

### rm - Remove files or directories

```bash
avfs rm [OPTIONS] <PATH>...
```

**Options:**
- `-r, --recursive` - Remove directories recursively
- `-f, --force` - Don't prompt for confirmation
- `-v, --verbose` - Show files as they're removed

**Examples:**
```bash
avfs rm /docs/old.txt
avfs rm -r /temp
avfs rm -rf /cache/*
```

## Directory Operations

### mkdir - Create directories

```bash
avfs mkdir [OPTIONS] <PATH>...
```

**Options:**
- `-p, --parents` - Create parent directories as needed

**Examples:**
```bash
avfs mkdir /docs
avfs mkdir -p /deep/nested/directory
avfs mkdir dir1 dir2 dir3
```

### rmdir - Remove empty directories

```bash
avfs rmdir <PATH>...
```

**Examples:**
```bash
avfs rmdir /empty-dir
avfs rmdir dir1 dir2
```

## Comparison

### diff - Compare files

```bash
avfs diff [OPTIONS] <FILE1> <FILE2>
```

**Options:**
- `-u, --unified` - Unified diff format (default)
- `-c, --context` - Context diff format
- `--color` - Colorize output
- `-v, --version <N>` - Compare with version N

**Examples:**
```bash
avfs diff /docs/v1.txt /docs/v2.txt
avfs diff -v 1 /docs/readme.txt          # Current vs version 1
avfs diff --color file1.txt file2.txt
```

## Search Commands

### grep - Search file contents

```bash
avfs grep [OPTIONS] <PATTERN> [PATH]...
```

**Options:**
- `-i, --ignore-case` - Case-insensitive search
- `-r, --recursive` - Search recursively
- `-l, --files-with-matches` - Show only matching filenames
- `-n, --line-number` - Show line numbers
- `-c, --count` - Show only match count
- `-v, --invert-match` - Show non-matching lines
- `-A, --after <N>` - Show N lines after match
- `-B, --before <N>` - Show N lines before match
- `-C, --context <N>` - Show N lines around match

**Examples:**
```bash
avfs grep "TODO" /src/                 # Search in directory
avfs grep -rn "function" /             # Recursive with line numbers
avfs grep -i "error" /logs/*.log       # Case-insensitive with glob
avfs grep -l "import" /src/**/*.rs     # Files containing pattern
avfs grep -C 3 "bug" /src/main.rs      # With context
```

### search - Full-text search

```bash
avfs search [OPTIONS] <QUERY> [PATH]
```

Full-text search using FTS5 (SQLite) or Tantivy (other backends).

**Options:**
- `-i, --ignore-case` - Case-insensitive search
- `-w, --word` - Match whole words only
- `-l, --files-only` - Show only filenames
- `-c, --count` - Show match counts
- `--limit <N>` - Limit results
- `--rebuild` - Rebuild search index
- `--status` - Show index status

**Examples:**
```bash
avfs search "database connection"      # Search all files
avfs search "TODO" /src/               # Search in directory
avfs search -l "error"                 # Just filenames
avfs search "config NOT test"          # Boolean query
avfs search "data*"                    # Prefix matching
```

### find - Find files by name or attributes

```bash
avfs find [PATH] [OPTIONS]
```

**Options:**
- `-name <PATTERN>` - Match filename pattern (glob)
- `-type <TYPE>` - Filter by type (`f` for file, `d` for directory)
- `-size <SIZE>` - Filter by size (`+1M`, `-100K`)
- `-mtime <DAYS>` - Modified within N days
- `-tag <TAG>` - Filter by tag
- `-exec <CMD>` - Execute command on matches

**Examples:**
```bash
avfs find / -name "*.txt"
avfs find /src -type f -name "*.rs"
avfs find / -size +1M
avfs find / -mtime -7                  # Modified in last 7 days
avfs find / -tag important
avfs find / -name "*.log" -exec rm {}
```

## Vault Management

### vault create - Create a new vault

```bash
avfs vault create <NAME> [OPTIONS]
```

**Options:**
- `--path <PATH>` - Custom database path

**Examples:**
```bash
avfs vault create myproject
avfs vault create backup --path /mnt/external/backup.avfs
avfs vault create fast --backend sled
```

### vault list - List all vaults

```bash
avfs vault list [OPTIONS]
```

**Options:**
- `--json` - JSON output

### vault use - Switch to a vault

```bash
avfs vault use <NAME>
```

### vault delete - Delete a vault

```bash
avfs vault delete <NAME> [OPTIONS]
```

**Options:**
- `--force` - Delete without confirmation

### vault info - Show vault information

```bash
avfs vault info [NAME] [OPTIONS]
```

**Options:**
- `--json` - JSON output

Shows size, file count, version count, limits, and settings.

### vault config - Configure vault settings

```bash
avfs vault config [KEY] [VALUE]
```

View or modify vault settings.

**Examples:**
```bash
avfs vault config                      # Show all settings
avfs vault config max_size_mb 100      # Set max vault size
avfs vault config max_files 10000      # Set max file count
avfs vault config max_file_size_mb 10  # Set max single file size
avfs vault config prune_strategy keep_n
avfs vault config prune_keep_count 10
```

### vault import - Register external vault

```bash
avfs vault import <NAME> <PATH>
```

Register an existing vault database file.

**Examples:**
```bash
avfs vault import shared ~/Downloads/shared.avfs
```

### vault stats - Show detailed statistics

```bash
avfs vault stats [OPTIONS]
```

**Options:**
- `--json` - JSON output
- `--backend-info` - Include backend-specific info
- `--versions` - Show version distribution

**Examples:**
```bash
avfs vault stats                       # Storage breakdown
avfs vault stats --versions            # Files by version count
```

## Import/Export

### import - Import from real filesystem

```bash
avfs import [OPTIONS] <REAL_PATH> <VIRTUAL_PATH>
```

**Options:**
- `-r, --recursive` - Import directories recursively
- `-v, --verbose` - Show files as imported

**Examples:**
```bash
avfs import ~/documents/report.pdf /docs/
avfs import -r ~/project/src /src
```

### export - Export to real filesystem

```bash
avfs export [OPTIONS] <VIRTUAL_PATH> <REAL_PATH>
```

**Options:**
- `-r, --recursive` - Export directories recursively
- `-v, --verbose` - Show files as exported
- `--version <N>` - Export specific version

**Examples:**
```bash
avfs export /docs/report.pdf ~/Downloads/
avfs export -r /src ~/backup/src
avfs export --version 5 /docs/file.txt ~/old-version.txt
```

## Versioning Commands

### log - Show version history

```bash
avfs log [OPTIONS] <PATH>
```

**Options:**
- `-n, --number <N>` - Show only last N versions
- `--oneline` - Compact format

**Examples:**
```bash
avfs log /docs/readme.txt
avfs log -n 5 /src/main.rs
avfs log --oneline /docs/
```

### checkout - Restore a previous version

```bash
avfs checkout <PATH> <VERSION>
```

**Examples:**
```bash
avfs checkout /docs/readme.txt 3       # Restore version 3
```

### revert - Revert to previous version

```bash
avfs revert <PATH>
```

Reverts to the immediately previous version (creates a new version).

## Metadata Commands

### tag - Add tags to files

```bash
avfs tag [OPTIONS] <PATH> <TAG>...
```

**Options:**
- `-r, --recursive` - Tag files recursively
- `--create <NAME>` - Create a new tag (with optional `--color`)
- `--delete <NAME>` - Delete a tag
- `--rename <OLD> <NEW>` - Rename a tag
- `--list` - List all tags in vault
- `--copy <SRC> <DST>` - Copy tags from one file to another
- `--color <HEX>` - Set tag color (with `--create`)

**Examples:**
```bash
avfs tag /docs/report.pdf important urgent
avfs tag /src/*.rs code rust
avfs tag -r /project/ work             # Recursive
avfs tag --create important --color red
avfs tag --list                        # List all tags
avfs tag --copy /template.txt /new.txt
```

### untag - Remove tags from files

```bash
avfs untag <PATH> <TAG>...
```

### meta - View or set metadata

```bash
avfs meta [OPTIONS] <PATH> [KEY] [VALUE]
```

**Options:**
- `--unset <KEY>` - Remove a metadata key
- `--export <PATH>` - Export metadata to JSON file
- `--import <FILE>` - Import metadata from JSON file
- `--copy <SRC> <DST>` - Copy metadata between files

**Examples:**
```bash
avfs meta /docs/file.txt                     # Show all metadata
avfs meta /docs/file.txt author              # Get specific key
avfs meta /docs/file.txt author "John Doe"   # Set value
avfs meta --unset /docs/file.txt status      # Remove key
avfs meta --export /docs/ > metadata.json    # Export
avfs meta --import metadata.json             # Import
```

## External Commands

### exec - Run external command on a virtual file

```bash
avfs exec [OPTIONS] <VFS_PATH> -- <COMMAND>...
```

Extracts a virtual file to a temp file on the host filesystem, runs an external command, and optionally re-imports the result.

**Options:**
- `--reimport` - Read the temp file back into the vault after the command completes
- `--stdin` - Pass vault file content via stdin instead of as a temp file argument

**Examples:**
```bash
# Process and re-import
avfs exec --reimport /docs/file.txt -- sed -i s/foo/bar/g {}

# Read-only analysis
avfs exec /src/main.rs -- grep "TODO" {}

# Stdin mode
avfs exec --stdin /data/large.txt -- gzip > output.gz
```

Use `{}` in the command to substitute the temp file path. If omitted, the temp path is appended.

### proxy exec - Policy-gated execution inside a mounted workspace

```bash
avfs proxy exec [OPTIONS] -- <COMMAND>...
```

Mounts the vault as a real directory, runs a command inside it, and reports filesystem deltas.

**Options:**
- `--mountpoint <PATH>` - Mount point to use (auto-generated if omitted)
- `--cwd <PATH>` - Working directory inside the mounted vault (default: `/`)
- `--readonly` - Mount the vault read-only
- `--keep-mount` - Keep the mount active after the command exits
- `--timeout <MILLIS>` - Kill command after timeout (default: 300000, 0 disables)
- `--shell <COMMAND>` - Execute a shell command via `$SHELL -lc`

**Examples:**
```bash
avfs proxy exec -- cargo test
avfs proxy exec --shell "make build"
avfs proxy exec --readonly -- cat /docs/readme.txt
avfs proxy exec --timeout 600000 -- ./long-build.sh
```

**Output (with `--json`):**
```json
{
  "schema_version": 1,
  "kind": "proxy_exec_result",
  "success": true,
  "request": { ... },
  "result": {
    "vault": "myproject",
    "command": "cargo test",
    "exit_code": 0,
    "stdout": "...",
    "stderr": "...",
    "changed_files": ["/src/lib.rs"],
    "checkpoint": "checkpoint-20260404-120000",
    "timed_out": false,
    "state": "completed"
  }
}
```

### pipe - Pipe operations (via shell)

```bash
avfs cat <PATH> | <command> | avfs write <PATH>
```

**Examples:**
```bash
avfs cat /data.txt | sort | uniq | avfs write /sorted.txt
avfs cat /log.txt | grep ERROR | avfs write /errors.txt
```

## Mount Commands (requires `fuse` feature)

### mount - Mount vault as real directory

```bash
avfs mount [OPTIONS] <MOUNTPOINT>
```

Mounts the active vault as a FUSE filesystem at the given path.

**Options:**
- `--readonly` - Mount read-only
- `--allow-other` - Allow other users to access the mount

**Examples:**
```bash
avfs mount /mnt/myvault
avfs mount --readonly /mnt/myvault-ro
```

### unmount - Unmount a vault

```bash
avfs unmount <MOUNTPOINT>
```

Unmounts a previously mounted vault.

## Maintenance Commands

### prune - Remove old versions

```bash
avfs prune [OPTIONS]
```

**Options:**
- `--keep <N>` - Keep last N versions per file
- `--older-than <DAYS>` - Remove versions older than N days
- `--dry-run` - Show what would be removed

### compact - Reclaim space

```bash
avfs compact
```

Removes unreferenced content and optimizes storage (VACUUM for SQLite, compaction for others).

### gc - Garbage collection

```bash
avfs gc [OPTIONS]
```

**Options:**
- `--dry-run` - Show what would be removed
- `--stats` - Show garbage collection statistics

### maintain - Full maintenance routine

```bash
avfs maintain [OPTIONS]
```

Runs prune, gc, and compact in sequence.

**Options:**
- `--dry-run` - Show what would be done

## Shell Commands

### shell - Start interactive shell

```bash
avfs shell
```

Launches REPL where commands work without `avfs` prefix.

### aliases - Generate shell aliases

```bash
avfs aliases [OPTIONS]
```

**Options:**
- `--format <FMT>` - Shell format (`bash`, `zsh`, `fish`)
- `--prefix <PREFIX>` - Command prefix (default: none)

**Examples:**
```bash
eval "$(avfs aliases)"                 # Activate aliases
eval "$(avfs aliases --prefix avfs-)"   # Use avfs-ls, avfs-cp, etc.
```

## Snapshot Commands

### snapshot save - Create a snapshot

```bash
avfs snapshot save [NAME]
```

Saves the current vault state. If no name is given, an auto-generated name is used.

**Examples:**
```bash
avfs snapshot save before-experiment
avfs snapshot save                      # Auto-generated name
```

### snapshot list - List snapshots

```bash
avfs snapshot list [OPTIONS]
```

**Options:**
- `--json` - JSON output

### snapshot restore - Restore a snapshot

```bash
avfs snapshot restore <NAME>
```

Restores vault to a previous snapshot. Current state is auto-saved before restore.

**Examples:**
```bash
avfs snapshot restore before-experiment
```

### snapshot delete - Delete a snapshot

```bash
avfs snapshot delete <NAME>
```

## Audit Commands

### audit - View operation history

```bash
avfs audit [OPTIONS]
```

**Options:**
- `--json` - JSON output
- `--limit <N>` - Show last N entries (default: 50)
- `--op <OP>` - Filter by operation (can repeat)
- `--path <PATH>` - Filter by path prefix
- `--since <TIMESTAMP>` - Filter by time

**Examples:**
```bash
avfs audit                              # Recent operations
avfs audit --json --limit 100           # JSON output
avfs audit --op write --op rm           # Only write/rm operations
avfs audit --path /docs/                # Operations in /docs
```

### audit clear - Clear audit log

```bash
avfs audit clear
```

## Global Options

These options work with all commands:

- `--vault <NAME>` - Use specific vault
- `--json` - Output in JSON format (for programmatic use)
- `--help` - Show help for command
- `--version` - Show avfs version
- `--quiet` - Suppress non-error output
- `--verbose` - Show detailed output

## JSON Output

When `--json` is specified, all commands output structured JSON:

```bash
# Success
$ avfs ls --json /docs
{
  "path": "/docs",
  "entries": [...]
}

# Error
$ avfs cat --json /nonexistent
{
  "error": "NotFound",
  "message": "File not found: /nonexistent"
}
```

Exit codes: `0` for success, `1` for errors. Always check both exit code and JSON.