Skip to content

sqlite card updates#6

Merged
sysid merged 5 commits into
mainfrom
001-sqlite-card-updates
Apr 12, 2026
Merged

sqlite card updates#6
sysid merged 5 commits into
mainfrom
001-sqlite-card-updates

Conversation

@sysid
Copy link
Copy Markdown
Owner

@sysid sysid commented Apr 12, 2026

Summary

Add tag management, editor-based note editing, and bulk tag operations to ankiview. This extends the direct SQLite approach (via the anki crate) with update capabilities that were previously missing.

New CLI commands

  • ankiview tag add <NOTE_ID> <TAGS...> — add tags to a note (merge, no duplicates)
  • ankiview tag remove <NOTE_ID> <TAGS...> — remove tags from a note
  • ankiview tag replace --old <OLD> --new <NEW> [--query <Q>] — rename, bulk-add (--old ""), or bulk-remove (--new "") tags across notes, with optional Anki search query filter
  • ankiview edit <NOTE_ID> — open note in $EDITOR with a type-aware template (Basic→Front/Back, Cloze→Text/Extra), validates against Anki invariants on save

Changed behavior

  • collect now merges tags from markdown onto existing notes (additive only — tags are never removed by collect). Previously, tag changes in markdown were silently ignored on re-import.

Design decisions

  • Merge-only tags during collect: collect adds tags from markdown but never removes them. This prevents collect from wiping CLI-added tags. Tag removal is exclusively via tag remove.
  • Editor template pattern: Follows bkmr's === SECTION === delimiter pattern. Raw HTML content, no lossy conversion.
  • Cloze validation: Editor rejects Cloze notes missing {{c1::...}} syntax.
  • All note types supported: Editor template adapts field names to the note type.

sysid added 5 commits April 12, 2026 13:25
Add four new trait methods to NoteRepository (add_tags, remove_tags,
update_note_fields_and_tags, replace_tag) with full implementations
on AnkiRepository. replace_tag supports three modes: rename, bulk add
(empty old), and bulk remove (empty new) with optional query filtering.

Update MockNoteRepository to implement all new trait methods.
New CLI commands:
- `tag add/remove` for per-note tag management
- `tag replace` with rename, bulk-add, bulk-remove modes and --query filter
- `edit` opens $EDITOR with type-aware template (Basic→Front/Back, Cloze→Text/Extra)

Collect now merges tags from markdown onto existing notes (additive only,
never removes). This closes the gap where tag changes in markdown were
ignored on re-import.

Editor template follows bkmr's section-delimited pattern with validation
against Anki invariants (empty sort field, missing cloze deletions).

New application layer: NoteUpdater, TagManager, NoteEditor use cases.
New infrastructure: NoteTemplate with rendering, parsing, and validation.
@sysid sysid merged commit ef70936 into main Apr 12, 2026
1 check passed
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