diff --git a/plan.md b/plan.md index dd51bf8d..36113d76 100644 --- a/plan.md +++ b/plan.md @@ -68,6 +68,7 @@ ## Completed +- [x] Add search capability to miniinventory V2 - [x] Claude Code adapter (original implementation) - [x] Gemini adapter (API integration, Flash-Lite/Pro) - [x] OpenAI adapter (Responses API, cost accounting) diff --git a/problems/miniinventory/SPEC-v2.txt b/problems/miniinventory/SPEC-v2.txt index 2e2c5b67..ccbbb1d4 100644 --- a/problems/miniinventory/SPEC-v2.txt +++ b/problems/miniinventory/SPEC-v2.txt @@ -1,7 +1,7 @@ PROJECT: mini-inventory AUTHOR: Tunahan Caner YILDIZ (251478112) VERSION: v2 -DATE: 2026-03-29 +DATE: 2026-04-19 ======================================== OVERVIEW @@ -10,7 +10,7 @@ OVERVIEW mini-inventory is a command-line inventory manager. It stores product records in a plain text file and supports initializing the system, adding products, listing products, -updating stock quantities, and deleting products. +updating stock quantities, deleting products, and searching products. All data is stored in a directory called .miniinventory/ in the current working directory. @@ -107,6 +107,27 @@ Output: - Error if system is not initialized: "Not initialized. Run: miniinventory init" +--- search --- +Usage: miniinventory search "Pen" + +Searches for products whose name contains the search query. + +Validation and filtering rules: +- The search must be case-insensitive (e.g., searching "pEn" must find "Pencil"). +- Products must be listed in ascending order by ID, matching the exact format of 'list'. +- The query can be a substring anywhere in the product name. + +Output: +- Success matches: + [1] Pencil - Quantity: 50 (2026-03-15) + [3] Blue Pen - Quantity: 10 (2026-03-15) +- No matches found: + "No products match the search." +- Error if arguments are missing: + "Usage: miniinventory search " +- Error if system is not initialized: + "Not initialized. Run: miniinventory init" + ======================================== DATA FORMAT ======================================== @@ -162,14 +183,14 @@ Implemented commands: - list - update - delete +- search v2 TASKS COMPLETED: 1. Implemented the "list" command to display all stored products 2. Implemented the "update" command to modify product quantity 3. Implemented the "delete" command to remove a product +4. Implemented the "search" command to perform case-insensitive substring queries v1 -> v2 SUMMARY: - v1 supported only initialization and adding products -- v2 adds full inventory management through list, update, and delete -- validation rules were clarified to improve consistency and usability - +- v2 adds full inventory management through list, update,, delete, and case-insensitive search logic. diff --git a/problems/miniinventory/problem.json b/problems/miniinventory/problem.json index 4f8e1dcb..a607efbd 100644 --- a/problems/miniinventory/problem.json +++ b/problems/miniinventory/problem.json @@ -6,5 +6,5 @@ "v1_prompt": "Implement {{binary_name}} as described in SPEC-v1.txt using {{language}}. The executable must be named '{{binary_name}}' and be runnable as ./{{binary_name}}. For compiled languages, include a Makefile or build script. For interpreted languages, ensure the {{binary_name}} file has a proper shebang line and is executable. Verify your implementation passes all tests by running: bash test-v1.sh", "v2_spec": "SPEC-v2.txt", "v2_test": "test-v2.sh", - "v2_prompt": "Read SPEC-v2.txt and extend the existing {{binary_name}} implementation. Update the code to implement list, update, and delete commands. Verify your implementation passes all tests by running: bash test-v2.sh" + "v2_prompt": "Read SPEC-v2.txt and extend the existing {{binary_name}} implementation. Update the code to implement list, update, delete, and search commands. Verify your implementation passes all tests by running: bash test-v2.sh" } \ No newline at end of file diff --git a/problems/miniinventory/test-v2.sh b/problems/miniinventory/test-v2.sh index 74c5487e..da89fed1 100644 --- a/problems/miniinventory/test-v2.sh +++ b/problems/miniinventory/test-v2.sh @@ -60,6 +60,7 @@ if ../miniinventory add Pencil 50 2>&1 | grep -q "Not initialized"; then pass "a if ../miniinventory list 2>&1 | grep -q "Not initialized"; then pass "list before init"; else fail "list before init"; fi if ../miniinventory update 1 80 2>&1 | grep -q "Not initialized"; then pass "update before init"; else fail "update before init"; fi if ../miniinventory delete 1 2>&1 | grep -q "Not initialized"; then pass "delete before init"; else fail "delete before init"; fi +if ../miniinventory search Pen 2>&1 | grep -q "Not initialized"; then pass "search before init"; else fail "search before init"; fi ###################################### # Test 3: add and duplicate check @@ -164,7 +165,42 @@ else fi ###################################### -# Test 8: unknown/missing command +# Test 8: search product +###################################### +rm -rf .miniinventory +../miniinventory init >/dev/null 2>&1 +../miniinventory add Pencil 50 >/dev/null 2>&1 +../miniinventory add Notebook 20 >/dev/null 2>&1 +../miniinventory add "Blue Pen" 10 >/dev/null 2>&1 + +OUTPUT=$(../miniinventory search "Notebook" 2>&1) +if echo "$OUTPUT" | grep -q "\[2\] Notebook - Quantity: 20" && ! echo "$OUTPUT" | grep -q "Pencil"; then + pass "search finds exact match" +else + fail "search finds exact match" +fi + +OUTPUT=$(../miniinventory search "pEn" 2>&1) +if echo "$OUTPUT" | grep -q "\[1\] Pencil" && echo "$OUTPUT" | grep -q "\[3\] Blue Pen" && ! echo "$OUTPUT" | grep -q "Notebook"; then + pass "search is case insensitive and finds multiple" +else + fail "search is case insensitive and finds multiple" +fi + +if ../miniinventory search "NotExists" 2>&1 | grep -q "No products match the search."; then + pass "search no match" +else + fail "search no match" +fi + +if ../miniinventory search 2>&1 | grep -q "Usage"; then + pass "search missing arguments" +else + fail "search missing arguments" +fi + +###################################### +# Test 9: unknown/missing command ###################################### if ../miniinventory fly 2>&1 | grep -q "Unknown command: fly"; then pass "unknown command" diff --git a/walkthrough.md b/walkthrough.md index 740d35b4..7ea3fe85 100644 --- a/walkthrough.md +++ b/walkthrough.md @@ -5,6 +5,20 @@ --- +## 2026-04-21 — Upgrade miniinventory V2 with case-insensitive search + +**Contributor**: AI agent (Antigravity) +**What was done**: +- Added case-insensitive product search functionality to `miniinventory` V2 problem specification. +- Updated `problems/miniinventory/SPEC-v2.txt` to define the search command requirements. +- Updated `problems/miniinventory/test-v2.sh` to include comprehensive search command tests (case insensitivity, exact match, empty results, parameter errors). +- Updated `problems/miniinventory/problem.json` to enforce the search requirement. +**Observations**: The search requirement successfully validates that agents can extend simple data structures with substring filtering and case normalization logic. +**Decisions made**: Search was designed as case-insensitive to reflect real-world user expectations for CLI tools. +**Next**: Open PR to merge the updated problem structure into the upstream repository. + +--- + ## 2026-04-20 — V2 Evolution: Gemini Caching, MiniGit Status & Spec Hardening **Contributor**: AI agent (Antigravity)