Skip to content

irspec edit move --to and remove (roadmap 1a, third part) - #5

Merged
aliperdehan merged 1 commit into
mainfrom
claude/edit-move-remove
Oct 24, 2026
Merged

aliperdehan merged 1 commit into
mainfrom
claude/edit-move-remove

Conversation

@aliperdehan

Copy link
Copy Markdown
Owner

What

Two more subcommands of irspec edit (manifest only, src/irspec/edit.py):

  • irspec edit DIR FILE move --to POSITION: puts the entry at POSITION (1 = first, last, a number past the end means last, below 1 or a non-number is exit 2). Every other entry keeps its order and bytes; moving to where it already is changes nothing (file untouched, says so). --json: {"file", "changes": [{"key": "position", "old", "new"}]}.
  • irspec edit DIR FILE remove: writes the manifest without the entry, then moves the spectrum to DIR/removed/ (same name, folder created). Nothing is deleted or overwritten: if removed/NAME exists, exit 2 and nothing changes; if the move fails, the manifest is put back and exit 2. csv/ and plain/ files are left alone. --json: {"file", "removed": <whole entry>, "moved_to": "removed/NAME"}. A path that resolves outside DIR is never moved; an entry whose file is already gone is just taken out (moved_to: null).

session.spectra_on_disk scans only SPA/, jdx/, img/, and session.organize only files at the top level, so removed/ is neither re-listed nor filed into other/ (tested).

Not included, as specified: rename (it is set name=), --no-build, restore, batch removal. No version bump, tag or release.

README (irspec edit section, roadmap list), CHANGELOG (## Unreleased), docs/roadmap.md 1a and the cli.py docstring are updated.

Tests

tests/test_edit_move_remove.py, 23 tests on a session folder built from the sample .SPA and the .jdx fixtures: move first/middle/last/past the end/0 and other bad values/already there/twice/layout/--json; remove, then session again (spectrum stays out, removed/ not filed, a second run stable); name collision; failed move restores the manifest; manifest written before the move; unknown FILE; broken manifest; outside-folder path; --json.

Mutation-checked: 14 deliberate breaks of edit.py (off-by-one insert, no clamp, accepting 0, rewrite on no-op, last ignored, entry kept, overwrite on collision, no restore, file moved before the manifest, path escape, wrong folder name, --to on other verbs, extra args accepted, --json dropping the entry), each failed at least one test; code restored.

Full suite locally in a throwaway venv: Ran 199 tests ... OK (skipped=18) (no lualatex/R/poppler here, so the tests needing them skipped).


Generated by Claude Code

…d file its spectrum in removed/

move puts the entry at POSITION (1, last, past the end = last, below 1 exits 2) and keeps the order
of the others. remove writes the manifest without the entry, then moves the spectrum to
DIR/removed/ (never overwritten; manifest restored if the move fails). session does not scan
removed/, so the spectrum does not come back. Third part of roadmap 1a.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WkkvyTJhY9v6rrMJ4A4Wsb
@aliperdehan
aliperdehan merged commit cacede2 into main Oct 24, 2026
4 checks passed
@aliperdehan
aliperdehan deleted the claude/edit-move-remove branch October 24, 2026 09:30
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.

2 participants