diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index cc23561..c82c2ed 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -132,7 +132,7 @@ | PRM-02 | Phase 1 | Complete | | PRM-03 | Phase 1 | Complete | | PRM-04 | Phase 1 | Complete | -| PRM-05 | Phase 2 | Pending | +| PRM-05 | Phase 2 | Complete | | CSV-01 | Phase 1 | Complete | | CSV-02 | Phase 1 | Complete | | CSV-03 | Phase 1 | Complete | @@ -149,7 +149,7 @@ | UI-02 | Phase 1 | Complete | | UI-03 | Phase 1 | Complete | | UI-04 | Phase 1 | Complete | -| UI-05 | Phase 2 | Pending | +| UI-05 | Phase 2 | Complete | | UI-06 | Phase 3 | Pending | | UI-07 | Phase 1 | Complete | | UI-08 | Phase 1 | Complete | @@ -167,4 +167,4 @@ --- *Requirements defined: 2026-03-07* -*Last updated: 2026-03-08 — Phase 1 requirements marked Complete* +*Last updated: 2026-03-08 — Phase 2 requirements marked Complete* diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index be8aabf..0cfbb42 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -13,7 +13,7 @@ PostGenerator trasforma framework strategici di content marketing (Persuasion Nu Decimal phases appear between their surrounding integers in numeric order. - [x] **Phase 1: Core Generation Pipeline** - Infrastruttura + pipeline calendario → LLM → CSV funzionante end-to-end -- [ ] **Phase 2: Prompt Control + Output Review** - Editor prompt via UI e anteprima caroselli prima dell'export +- [x] **Phase 2: Prompt Control + Output Review** - Editor prompt via UI e anteprima caroselli prima dell'export - [ ] **Phase 3: Organization Layer** - Swipe File e gestione storico campagne per workflow sostenibile - [ ] **Phase 4: Enrichment** - Integrazione Unsplash, context injection da Swipe File, polish UI @@ -94,6 +94,6 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 | Phase | Plans Complete | Status | Completed | |-------|----------------|--------|-----------| | 1. Core Generation Pipeline | 4/4 | Complete | 2026-03-08 | -| 2. Prompt Control + Output Review | 0/2 | Not started | - | +| 2. Prompt Control + Output Review | 2/2 | Complete | 2026-03-08 | | 3. Organization Layer | 0/2 | Not started | - | | 4. Enrichment | 0/1 | Not started | - | diff --git a/.planning/phases/02-prompt-control-output-review/02-VERIFICATION.md b/.planning/phases/02-prompt-control-output-review/02-VERIFICATION.md new file mode 100644 index 0000000..57a781e --- /dev/null +++ b/.planning/phases/02-prompt-control-output-review/02-VERIFICATION.md @@ -0,0 +1,111 @@ +--- +phase: 02-prompt-control-output-review +verified: 2026-03-08T19:00:00Z +status: passed +score: 16/16 must-haves verified +--- + +# Phase 2: Prompt Control + Output Review Verification Report + +**Phase Goal:** L'utente puo' modificare i prompt direttamente dalla Web UI senza toccare il codice, rigenerare singoli post insoddisfacenti, e rivedere l'anteprima completa di ogni carosello prima di esportare il CSV. +**Verified:** 2026-03-08 +**Status:** PASSED +**Re-verification:** No -- initial verification + +## Goal Achievement + +### Observable Truths + +| # | Truth | Status | Evidence | +|---|-------|--------|----------| +| 1 | GET /api/prompts ritorna lista dei prompt .txt con flag modificato/default | VERIFIED | backend/routers/prompts.py L98-110: endpoint calls list_prompts() + _is_modified(), returns PromptListResponse | +| 2 | GET /api/prompts/{name} ritorna contenuto grezzo + variabili richieste | VERIFIED | backend/routers/prompts.py L113-138: calls load_prompt(), get_required_variables(), returns PromptDetailResponse | +| 3 | PUT /api/prompts/{name} salva con validazione variabili obbligatorie | VERIFIED | backend/routers/prompts.py L141-174: SavePromptRequest with min_length=10, save_prompt(), returns updated variables | +| 4 | POST /api/prompts/{name}/reset ripristina al default originale | VERIFIED | backend/routers/prompts.py L177-212: reads from _DEFAULT_PROMPTS_DIR, overwrites current, 404 if no default | +| 5 | Utente vede la pagina Prompt Editor nella sidebar e puo' navigarci | VERIFIED | Sidebar.tsx L34-38: NavLink /prompt-editor with Pencil icon; App.tsx L31: Route to PromptEditor | +| 6 | Utente vede la lista dei prompt, seleziona uno, modifica in textarea | VERIFIED | PromptEditor.tsx: two-column layout (L123-159 list, L164-291 editor), monospace textarea L191-197 | +| 7 | Utente vede le variabili richieste con il nome di ciascuna | VERIFIED | PromptEditor.tsx L200-216: clientVariables via live regex extraction, rendered as name chips | +| 8 | Utente salva un prompt modificato e il badge Modificato appare | VERIFIED | PromptEditor.tsx L221-232: Save button calls useSavePrompt; L145-154: amber Modificato badge on list items | +| 9 | Utente puo' resettare al default con pulsante Reset | VERIFIED | PromptEditor.tsx L235-268: Reset button with inline confirmation, calls useResetPrompt, disabled when not modified | +| 10 | Ogni PostCard success mostra bottone Rigenera nell'header | VERIFIED | PostCard.tsx L198-207: RefreshCw button with e.stopPropagation(), toggles showRegenForm | +| 11 | Cliccando Rigenera si apre form inline con topic + note opzionali | VERIFIED | PostCard.tsx L219-273: inline form with Topic alternativo + Note aggiuntive inputs, Rigenera/Annulla buttons | +| 12 | Dopo rigenerazione, post aggiornato sostituisce originale nella griglia | VERIFIED | PostCard.tsx L51-72: handleRegen calls generateSingle.mutateAsync then onRegenerated; OutputReview.tsx L48-53: updates localResults | +| 13 | Post rigenerati hanno badge visivo (RefreshCw icon) | VERIFIED | PostCard.tsx L166-170: isRegenerated prop renders amber RefreshCw icon with title Post rigenerato | +| 14 | Summary counter mostra N post - X rigenerati - Y modificati | VERIFIED | OutputReview.tsx L109-127: counter with total, generati, falliti, rigenerati (amber + RefreshCw), modificati (blue) | +| 15 | Summary counter si aggiorna in tempo reale | VERIFIED | OutputReview.tsx L88-96: regeneratedCount from regeneratedSlots.size, manuallyEditedCount via state-driven JSON comparison | +| 16 | CSV scaricato contiene ultime versioni (originali, rigenerati, modificati inline) | VERIFIED | OutputReview.tsx L55-62: handleDownloadCsv sends localResults (contains all edits/regens) via POST to export endpoint | + +**Score:** 16/16 truths verified + +### Required Artifacts + +| Artifact | Expected | Status | Details | +|----------|----------|--------|---------| +| backend/routers/prompts.py | API CRUD for prompts: list, read, write, reset | VERIFIED (212 lines) | 4 endpoints, Pydantic schemas, helper _is_modified, lazy PromptService init | +| frontend/src/pages/PromptEditor.tsx | Prompt Editor page with list, textarea, variables, save, reset | VERIFIED (294 lines) | Two-column layout, live variable extraction, save/reset with feedback, dirty tracking | +| frontend/src/components/PostCard.tsx | PostCard with Regen button, popover inline, badge | VERIFIED (286 lines) | handleRegen, showRegenForm, isRegenerated prop, inline form with topic/notes | +| frontend/src/pages/OutputReview.tsx | OutputReview with summary counter and regen tracking | VERIFIED (200 lines) | regeneratedSlots Set, regeneratedCount, manuallyEditedCount, summary counter UI | +| frontend/src/types.ts | PromptInfo, PromptListResponse, PromptDetail types | VERIFIED | L167-181: all three interfaces with correct fields | +| frontend/src/api/hooks.ts | usePromptList, usePrompt, useSavePrompt, useResetPrompt hooks | VERIFIED | L195-236: four hooks with correct TanStack Query patterns and cache invalidation | + +### Key Link Verification + +| From | To | Via | Status | Details | +|------|----|-----|--------|---------| +| PromptEditor.tsx | /api/prompts | usePromptList, usePrompt, useSavePrompt, useResetPrompt | WIRED | Imports at L9, hooks used at L15-17, handlers call mutations at L66-94 | +| App.tsx | PromptEditor.tsx | React Router route /prompt-editor | WIRED | Import at L8, Route at L31 | +| Sidebar.tsx | /prompt-editor | NavLink | WIRED | NavItem at L34-38 with Pencil icon | +| backend/main.py | backend/routers/prompts.py | app.include_router(prompts.router) | WIRED | Import at L17, registration at L94 (before SPA catch-all) | +| PostCard.tsx | /api/generate/single | useGenerateSingle mutation | WIRED | Hook at L46, called in handleRegen at L64 via mutateAsync | +| OutputReview.tsx | PostCard.tsx | onRegenerated callback + isRegenerated prop | WIRED | PostCard rendered at L167-177, handleRegenerated updates localResults + regeneratedSlots | +| hooks.ts | client.ts | apiGet, apiPut, apiPost | WIRED | Imports at L13, all four prompt hooks use these helpers | + +### Requirements Coverage + +| Requirement | Status | Blocking Issue | +|-------------|--------|----------------| +| PRM-05: Prompt Editor nella Web UI: visualizza, modifica e salva file prompt | SATISFIED | None | +| UI-05: Prompt Editor: lista, visualizza, modifica e salva prompt | SATISFIED | None | + +### Anti-Patterns Found + +| File | Line | Pattern | Severity | Impact | +|------|------|---------|----------|--------| +| PostCard.tsx | 143 | return null | Info | Guard clause for missing post data on success status -- correct defensive pattern, not a stub | + +No TODO, FIXME, placeholder content, or stub implementations found in any Phase 2 artifact. + +### Human Verification Required + +#### 1. Visual Prompt Editor Layout + +**Test:** Navigate to /postgenerator/prompt-editor, verify two-column layout renders correctly, badges show Modificato/Default with correct colors (amber/stone) +**Expected:** List on left (1/3), editor on right (2/3) on desktop; stacked on mobile +**Why human:** Visual layout verification cannot be done programmatically + +#### 2. Prompt Save Roundtrip + +**Test:** Edit a prompt in the textarea, click Salva, navigate away and return +**Expected:** Modified content persists, badge changes to Modificato, variables re-extracted +**Why human:** Requires running application with backend serving prompt files + +#### 3. Regen Popover UX + +**Test:** On OutputReview, click RefreshCw on a successful post card, fill optional topic, click Rigenera +**Expected:** Popover opens inline (not modal), regeneration calls API, card updates with new content and amber badge +**Why human:** Requires running LLM generation and visual confirmation of inline form behavior + +#### 4. Summary Counter Update + +**Test:** Regenerate a post, then edit another inline; observe summary counter +**Expected:** Counter updates immediately showing X rigenerati (amber) and Y modificati (blue) +**Why human:** Requires real-time interaction to verify state updates + +### Gaps Summary + +No gaps found. All 16 must-haves are verified at all three levels (existence, substantive, wired). The backend has 4 fully implemented CRUD endpoints with proper validation and error handling. The frontend has a complete Prompt Editor page with live variable extraction, dirty tracking, save/reset functionality, and proper sidebar/routing integration. The PostCard regeneration feature includes an inline form with topic/notes override, visual badge for regenerated posts, and a real-time summary counter in OutputReview. The CSV download path correctly uses localResults which reflects all edits and regenerations. + +--- + +_Verified: 2026-03-08_ +_Verifier: Claude (gsd-verifier)_