From 0234e52b727b34ade93961eb05b5638685f4406f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 30 May 2026 13:17:47 -0500 Subject: chore(scripts): add drill-deck stats, diff-ids, and sync wrapper I incorporated the flashcard-tooling bundle from the work project's deck-review workflow, validated there against a 93-card deck. Three scripts now live under .ai/scripts/: drill-deck-stats.py (pre-rewrite inventory plus a gate that warns on stray *** Answer headers, missing :ID:, non-prompt headings, and #+TITLE jargon like "org-drill"), drill-deck-diff-ids.py (SRS-state preservation check that flags any :ID: lost across a rewrite), and drill-deck-sync (bash wrapper chaining stats, optional diff-ids, then drill-to-anki, writing to ~/sync/phone/anki/ only when the gates pass). The drill-deck-review.org workflow gains a Helper Scripts section and references the scripts from its phases. I reconciled its output-path prose with the drill-to-anki default that just moved to ~/sync/phone/anki/, so it no longer claims the script still defaults to ~/sync/org/drill/. I added tests for both Python scripts (pure logic plus CLI gate behavior) and a bats suite for the wrapper's guard paths. The clean end-to-end sync path stays uncovered since it needs uv-resolved genanki. --- .ai/scripts/tests/drill-deck-sync.bats | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .ai/scripts/tests/drill-deck-sync.bats (limited to '.ai/scripts/tests/drill-deck-sync.bats') diff --git a/.ai/scripts/tests/drill-deck-sync.bats b/.ai/scripts/tests/drill-deck-sync.bats new file mode 100644 index 0000000..e141cab --- /dev/null +++ b/.ai/scripts/tests/drill-deck-sync.bats @@ -0,0 +1,38 @@ +#!/usr/bin/env bats +# Tests for the drill-deck-sync wrapper: argument handling + the stats gate. +# The clean end-to-end path runs drill-to-anki.py (uv-resolved genanki) and is +# not exercised here; these cover the guard paths that stop before that step. + +setup() { + SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)" + SYNC="$SCRIPT_DIR/drill-deck-sync" + TMP="$(mktemp -d)" +} + +teardown() { + rm -rf "$TMP" +} + +@test "drill-deck-sync: no args exits 2" { + run "$SYNC" + [ "$status" -eq 2 ] +} + +@test "drill-deck-sync: missing source file exits 2" { + run "$SYNC" "$TMP/nope.org" + [ "$status" -eq 2 ] +} + +@test "drill-deck-sync: stats gate failure exits 1 and writes no apkg" { + cat > "$TMP/dirty.org" <<'EOF' +#+TITLE: DeepSat Org-Drill Flashcards + +* Section +** DeepSat :drill: +*** Answer +A satellite company. +EOF + run "$SYNC" "$TMP/dirty.org" + [ "$status" -eq 1 ] + [ ! -f "$HOME/sync/phone/anki/dirty.apkg" ] +} -- cgit v1.2.3