Blueprint v2.4-2.6: Style Rules UI, Lore RAG, Thread Tracking, Redo Book

v2.4 — Item 7: Refresh Style Guidelines
- web/routes/admin.py: Added /admin/refresh-style-guidelines route (AJAX-aware)
- templates/system_status.html: Added 'Refresh Style Rules' button with spinner

v2.5 — Item 8: Lore & Location RAG-Lite
- story/bible_tracker.py: Added update_lore_index() — extracts location/item
  descriptions from chapters into tracking_lore.json
- story/writer.py: Reads chapter locations/key_items, builds LORE_CONTEXT block
  injected into the prompt (graceful degradation if no tags)
- cli/engine.py: Loads tracking_lore.json on resume, calls update_lore_index
  after each chapter, saves tracking_lore.json

v2.5 — Item 9: Structured Story State (Thread Tracking)
- story/state.py (new): load_story_state, update_story_state (extracts
  active_threads, immediate_handoff, resolved_threads via model_logic),
  format_for_prompt (structured context replacing the prev_sum blob)
- cli/engine.py: Loads story_state.json on resume, uses format_for_prompt as
  summary_ctx for write_chapter, updates state after each chapter accepted

v2.6 — Item 10: Redo Book
- templates/consistency_report.html: Added 'Redo Book' form with instruction
  input and confirmation dialog
- web/routes/run.py: Added revise_book route — creates new Run, queues
  generate_book_task with user instruction as feedback

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 01:35:43 -05:00
parent 2db7a35a66
commit 83a6a4315b
9 changed files with 291 additions and 27 deletions

View File

@@ -27,7 +27,15 @@
</ul>
</div>
<div class="card-footer bg-light">
<small class="text-muted">Tip: Use the "Read & Edit" feature to fix these issues manually, or use "Modify & Re-run" to have AI rewrite sections.</small>
<small class="text-muted mb-3 d-block">Tip: Use the "Read &amp; Edit" feature to fix issues manually, or use the form below to queue a full AI book revision.</small>
<form action="{{ url_for('run.revise_book', run_id=run.id, book_folder=book_folder) }}" method="POST" onsubmit="return confirm('This will start a new run to regenerate this book with your instruction applied. Continue?');">
<div class="input-group">
<input type="text" name="instruction" class="form-control" placeholder="e.g. Fix the timeline contradictions in the middle chapters" required>
<button type="submit" class="btn btn-warning">
<i class="fas fa-sync-alt me-2"></i>Redo Book
</button>
</div>
</form>
</div>
</div>
</div>

View File

@@ -8,6 +8,11 @@
</div>
<div class="col-md-4 text-end">
<a href="{{ url_for('project.index') }}" class="btn btn-outline-secondary me-2">Back to Dashboard</a>
<button id="styleBtn" class="btn btn-outline-info me-2" onclick="refreshStyleGuidelines()">
<span id="styleIcon"><i class="fas fa-filter me-2"></i></span>
<span id="styleSpinner" class="spinner-border spinner-border-sm me-2 d-none" role="status"></span>
<span id="styleLabel">Refresh Style Rules</span>
</button>
<button id="refreshBtn" class="btn btn-primary" onclick="refreshModels()">
<span id="refreshIcon"><i class="fas fa-sync me-2"></i></span>
<span id="refreshSpinner" class="spinner-border spinner-border-sm me-2 d-none" role="status"></span>
@@ -226,6 +231,34 @@ async function refreshModels() {
}
}
async function refreshStyleGuidelines() {
const btn = document.getElementById('styleBtn');
const icon = document.getElementById('styleIcon');
const spinner = document.getElementById('styleSpinner');
const label = document.getElementById('styleLabel');
btn.disabled = true;
icon.classList.add('d-none');
spinner.classList.remove('d-none');
label.textContent = 'Updating...';
try {
const resp = await fetch("{{ url_for('admin.refresh_style_guidelines_route') }}", {
method: 'POST',
headers: { 'X-Requested-With': 'XMLHttpRequest' }
});
const data = await resp.json();
showToast(data.message, resp.ok ? 'bg-success text-white' : 'bg-danger text-white');
} catch (err) {
showToast('Request failed: ' + err.message, 'bg-danger text-white');
} finally {
btn.disabled = false;
icon.classList.remove('d-none');
spinner.classList.add('d-none');
label.textContent = 'Refresh Style Rules';
}
}
function showToast(message, classes) {
const toast = document.getElementById('refreshToast');
const body = document.getElementById('toastBody');