Skip to content

feat(cli): beautify forkd images + add forkd rmi <tag>#139

Merged
WaylandYang merged 1 commit into
mainfrom
feat/cli-images-tag-rm
May 21, 2026
Merged

feat(cli): beautify forkd images + add forkd rmi <tag>#139
WaylandYang merged 1 commit into
mainfrom
feat/cli-images-tag-rm

Conversation

@WaylandYang
Copy link
Copy Markdown
Contributor

Summary

Two snapshot-management polish items.

1. `forkd images` table revamped

Before:
```
TAG SIZE ROOTFS?
coding-agent-fork-prewarm-v1 2.4 GiB yes
```

After (live on dev box, 65 snapshots, 41.75 GiB total):
```
TAG SIZE MEMORY CREATED ROOTFS
branch-sb-6a0e9444-0027-1779340356 512.0 MiB 512.0 MiB 1h ago —
speculative-1779338575690 512.0 MiB 512.0 MiB 2h ago —
cli-diff-test 512.0 MiB 512.0 MiB 12h ago —
...
65 snapshots · 41.75 GiB total
```

Changes:

  • New MEMORY column (memory.bin size — distinct from total which includes rootfs)
  • New CREATED column (relative age: "1h ago", "3d ago", etc.)
  • Dynamic TAG width
  • Sort most-recent-first (was alphabetic)
  • Footer with snapshot count + total bytes

2. New `forkd rmi ...` subcommand (docker-style)

```
$ forkd rmi probe-5-1779263791772987781 probe-6-1779263795516612417
✓ probe-5-1779263791772987781 (daemon)
✓ probe-6-1779263795516612417 (daemon)

$ forkd rmi nonexistent-tag
✗ nonexistent-tag (snapshot nonexistent-tag not found (no daemon entry, no disk dir at ...))
Error: 1 of 1 removals failed
```

  • Tries daemon DELETE /v1/snapshots/:tag first (clean: registry entry + disk files removed atomically)
  • Falls back to direct `rm -rf` on the snapshot dir when daemon is unreachable, or when daemon returns 404 (e.g., snapshot created via CLI local-boot path that never registered with the daemon)
  • Reports source per tag: "(daemon)", "(disk)", or "(disk (daemon unreachable))"
  • Validates the tag against the same rules the daemon enforces (1-64 chars, alnum/dash/underscore)

Files

  • `crates/forkd-cli/src/hub.rs` — extended `LocalSnapshotInfo` (memory_bytes, created_at_unix); new `human_age` formatter; sort by recency
  • `crates/forkd-cli/src/main.rs` — new `Cmd::Rmi` variant + `rmi_cmd` + `fallback_remove` (~70 lines); rewritten `images_cmd` (~25 lines)

Total: 167 insertions, 6 deletions.

🤖 Generated with Claude Code

Two polish items on snapshot management:

1. \`forkd images\` table output revamped:
   - new columns: MEMORY (memory.bin size) and CREATED (relative age)
   - dynamic TAG column width
   - sorted most-recent-first instead of alphabetical
   - footer with snapshot count + total bytes

   Before:
     TAG                               SIZE  ROOTFS?
     coding-agent-fork-prewarm-v1   2.4 GiB  yes

   After:
     TAG                                  SIZE      MEMORY     CREATED  ROOTFS
     coding-agent-fork-prewarm-v1      2.4 GiB   512.0 MiB     3d ago  yes
     python-numpy                      1.8 GiB   512.0 MiB    12h ago  yes

     2 snapshots · 4.2 GiB total

2. New \`forkd rmi <TAG>...\` subcommand (docker-style):
   - tries DELETE /v1/snapshots/:tag first (clean: daemon removes
     registry entry + on-disk files atomically)
   - falls back to direct disk removal when the daemon is unreachable
     or doesn't know the tag (404)
   - reports source per tag: \"(daemon)\", \"(disk)\", or
     \"(disk (daemon unreachable))\"

   Examples:
     forkd rmi pyagent
     forkd rmi pyagent langgraph python-numpy

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@WaylandYang WaylandYang force-pushed the feat/cli-images-tag-rm branch from 329f5d6 to e1ff849 Compare May 21, 2026 07:14
@WaylandYang WaylandYang merged commit d9fac14 into main May 21, 2026
2 checks passed
@WaylandYang WaylandYang deleted the feat/cli-images-tag-rm branch May 21, 2026 07:42
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.

1 participant