diff options
| author | Szymon Szukalski <szymon@szymonszukalski.com> | 2026-04-09 11:22:48 +1000 |
|---|---|---|
| committer | Szymon Szukalski <szymon@szymonszukalski.com> | 2026-04-09 11:22:48 +1000 |
| commit | 08d06ed00c9d6e98f0f8a02d243a2eb36ee4bff1 (patch) | |
| tree | dad98d4ac64219e047223c82564d93c00ddf0501 /docs/plans/2026-04-09-crm-property-completion-implementation.md | |
| parent | bc75732b9d37b77945a977ee9f7892cf6efc79c3 (diff) | |
Improve CRM and journal workflows
Diffstat (limited to 'docs/plans/2026-04-09-crm-property-completion-implementation.md')
| -rw-r--r-- | docs/plans/2026-04-09-crm-property-completion-implementation.md | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/docs/plans/2026-04-09-crm-property-completion-implementation.md b/docs/plans/2026-04-09-crm-property-completion-implementation.md new file mode 100644 index 0000000..88b3d01 --- /dev/null +++ b/docs/plans/2026-04-09-crm-property-completion-implementation.md @@ -0,0 +1,144 @@ +# CRM Property Completion Implementation Plan + +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. + +**Goal:** Add data-driven CRM property completion and inline value creation to `ss-crm-add` without introducing a second source of truth. + +**Architecture:** Extend `lisp/ss-crm.el` with small lookup helpers that build on the existing parsed CRM entry cache, plus a single generic choice reader that handles blank selection, optional freeform values, confirmation, and advisory duplicate warnings. Keep seeded vocabularies in code, wire field-specific readers into `ss-crm-add`, and verify with focused ERT coverage plus batch startup loading. + +**Tech Stack:** Emacs Lisp, Org, ERT, batch Emacs verification + +--- + +### Task 1: Add failing CRM helper tests + +**Files:** +- Create: `tests/ss-crm-tests.el` +- Modify: `lisp/ss-crm.el` + +**Step 1: Write the failing test** + +```elisp +(ert-deftest ss-crm-known-property-values-sorts-and-deduplicates () + (cl-letf (((symbol-function 'ss-crm-entries) + (lambda () + (list (list :role "Engineer") + (list :role " engineer ") + (list :role "Architect") + (list :role nil))))) + (should (equal (ss-crm-known-property-values "ROLE") + '("Architect" "Engineer" " engineer "))))) +``` + +**Step 2: Run test to verify it fails** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-crm-tests.el -f ert-run-tests-batch-and-exit` +Expected: FAIL because the new CRM helper functions do not exist yet. + +**Step 3: Write minimal implementation** + +```elisp +(defun ss-crm-known-property-values (property) + ...) +``` + +**Step 4: Run test to verify it passes** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-crm-tests.el -f ert-run-tests-batch-and-exit` +Expected: PASS for the helper coverage. + +**Step 5: Commit** + +```bash +git add tests/ss-crm-tests.el lisp/ss-crm.el +git commit -m "Add CRM property completion helpers" +``` + +### Task 2: Add completion-reader tests and implement prompt behavior + +**Files:** +- Modify: `tests/ss-crm-tests.el` +- Modify: `lisp/ss-crm.el` + +**Step 1: Write the failing test** + +```elisp +(ert-deftest ss-crm-read-choice-warns-on-new-case-insensitive-duplicate () + (let (warning) + (cl-letf (((symbol-function 'completing-read) (lambda (&rest _) "sydney")) + ((symbol-function 'yes-or-no-p) (lambda (&rest _) t)) + ((symbol-function 'display-warning) + (lambda (_type message &rest _) (setq warning message)))) + (should (equal (ss-crm-read-choice "Location: " '("Sydney") + :allow-blank t + :allow-new t) + "sydney")) + (should (string-match-p "Sydney" warning)))) +``` + +**Step 2: Run test to verify it fails** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-crm-tests.el -f ert-run-tests-batch-and-exit` +Expected: FAIL because `ss-crm-read-choice` does not support the new behavior yet. + +**Step 3: Write minimal implementation** + +```elisp +(defun ss-crm-read-choice (prompt choices &rest plist) + ...) +``` + +**Step 4: Run test to verify it passes** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-crm-tests.el -f ert-run-tests-batch-and-exit` +Expected: PASS for blank selection, existing completion, and new-value confirmation coverage. + +**Step 5: Commit** + +```bash +git add tests/ss-crm-tests.el lisp/ss-crm.el +git commit -m "Add CRM completion prompts" +``` + +### Task 3: Integrate field readers into `ss-crm-add` and verify startup + +**Files:** +- Modify: `lisp/ss-crm.el` +- Review: `README.md` + +**Step 1: Write the failing test** + +```elisp +(ert-deftest ss-crm-read-manager-uses-known-person-names () + (cl-letf (((symbol-function 'ss-crm-known-person-names) + (lambda () '("Alice" "Bob"))) + ((symbol-function 'ss-crm-read-choice) + (lambda (_prompt choices &rest _plist) choices))) + (should (equal (ss-crm-read-manager) '("Alice" "Bob"))))) +``` + +**Step 2: Run test to verify it fails** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-crm-tests.el -f ert-run-tests-batch-and-exit` +Expected: FAIL until the field readers are wired up. + +**Step 3: Write minimal implementation** + +```elisp +(defun ss-crm-read-manager () + (ss-crm-read-choice "Manager: " (ss-crm-known-person-names) + :allow-blank t + :require-match t)) +``` + +**Step 4: Run test to verify it passes** + +Run: `emacs --batch -Q -L . -L lisp -l tests/ss-crm-tests.el -f ert-run-tests-batch-and-exit` +Expected: PASS, then run `emacs --batch -Q --load ./init.el` to confirm startup remains healthy. + +**Step 5: Commit** + +```bash +git add tests/ss-crm-tests.el lisp/ss-crm.el README.md +git commit -m "Guide CRM add-person property entry" +``` |
