Skip to content

feat: headless --clean mode for AI tool post-session hooks - #18

Merged
kunjee17 merged 1 commit into
mainfrom
feat/headless-clean
Jul 26, 2026
Merged

kunjee17 merged 1 commit into
mainfrom
feat/headless-clean

Conversation

@kunjee17

Copy link
Copy Markdown
Owner

Closes #15.

What

irona --clean <path> scans, deletes every artifact directory it finds, prints one summary line, and never enters raw mode or the alternate screen — so it works from a Claude Code Stop hook or any non-interactive context.

irona --clean ~/Workspace                   # scan, delete, report
irona --clean --dry-run ~/Workspace         # report only, delete nothing
irona --clean --include-gitignored ~/W      # also sweep gitignore-only matches

Decisions

Answering the issue's open questions:

  • Flag, not subcommand. Keeps the existing irona <path> positional working with no clap restructuring.
  • --dry-run included. The safety valve before wiring a destructive command into a hook.
  • Exit 0 on nothing-found, 1 only when a delete failed. A clean workspace must not fail a hook noisily.
  • --only rust,node deferred. Needs a name parser for all fifteen Language variants and nothing depends on it yet.

One decision not in the issue: gitignore-detected directories are excluded by default in headless mode. In the TUI a person reads the list before selecting; unattended, a gitignored data/, logs/, or secrets/ would be deleted with nobody watching. --include-gitignored restores the full sweep. TUI behaviour is unchanged.

Structure

New src/headless.rs drives the existing scanner::scan and deleter::delete_all, which were already TUI-independent. format_bytes moves from render.rs to a new src/format.rs so headless output does not depend on the rendering module.

Verification

  • cargo nextest run — 68 tests pass (51 before, 17 new)
  • cargo clippy --all-targets -- -D warnings — clean
  • pre-commit hook passed: fmt, clippy, build
  • smoke-tested end to end: dry run leaves target/ in place, real run deletes it and exits 0, second run reports nothing-to-clean and exits 0, --dry-run without --clean exits 2 with a clap error, and --include-gitignored deletes a gitignored dist/ that the default run leaves alone

Note

PR #17 also edits the Args struct in main.rs to add --mcp. Whichever merges second needs a small conflict resolution there; nothing structural overlaps.

🤖 Generated with Claude Code

Adds `irona --clean <path>`, which scans, deletes every artifact
directory it finds, and prints one summary line without touching the
terminal — usable from an AI tool's session-end hook.

`--dry-run` reports without deleting. Gitignore-only matches are skipped
by default since an unattended sweep could take out a gitignored data/
or secrets/ directory; `--include-gitignored` opts back in.

Exit code is 0 on success including nothing-found, 1 if a delete failed.

Moves format_bytes out of render.rs into src/format.rs so headless
output does not depend on the ratatui rendering module.

Closes #15

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kunjee17
kunjee17 force-pushed the feat/headless-clean branch from 3f8c5da to 537a66d Compare July 26, 2026 17:24
@kunjee17
kunjee17 merged commit c808dc5 into main Jul 26, 2026
1 check failed
@kunjee17
kunjee17 deleted the feat/headless-clean branch July 26, 2026 17:26
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.

feat: headless / non-interactive mode for AI tool post-session hooks

1 participant