# AetherDesk User Quote Library

The User Quote Library is the writing voice lane for books, fiction, nonfiction, narration, and YouTube adaptation.

Run:

```powershell
npm run aetherdesk:quote-library
```

Outputs:

- `artifacts/aetherdesk_user_quote_library/latest.json`
- `artifacts/aetherdesk_user_quote_library/latest.md`
- `artifacts/aetherdesk_user_quote_library/latest.receipts.json`
- `artifacts/aetherdesk_user_quote_library/latest-action-cards.json`
- `artifacts/aetherdesk_user_quote_library/latest-agent-prompt.txt`
- `artifacts/aetherdesk_user_quote_library/latest.chapter-use.json`
- `artifacts/aetherdesk_user_quote_library/latest.chapter-use.md`
- `artifacts/aetherdesk_user_quote_library/latest.obsidian.md`
- `artifacts/aetherdesk_user_quote_library/latest.style-fingerprint.json`

Policy:

- `original_quote` is canonical exact source text and must not be discarded.
- `raw_quote`, `corrected_quote`, and `normalized_quote` are spelling-only working copies for drafting and display.
- `edit_receipt` keeps the before/after spelling corrections so user habits remain available for error correction, voice navigation, and faithful final assembly.
- Source files are read by bounded exact paths and are not modified.
- Missing cloud-placeholder files are reported as blockers, not treated as failures that stop the lane.
- Drafting, KDP prep, and YouTube adaptation should cite `source_path` and `section` when a quote is book/canon critical.
- Agents should read the fast chapter-use packet before falling back to full note/source reads.

Current seed/exact sources include:

- `C:\Users\issda\OneDrive\Documents\GitHub\Avalon\archive\Here is your updated Chronological quotes.txt`
- known Avalon, Obsidian, style, theory, and training-message files when present

Bounded note discovery also scans these roots by default:

- `C:\Users\issda\.codex\attachments`
- `C:\Users\issda\Avalon Files (consolidated)`
- `C:\Users\issda\Documents\Avalon Files`
- `C:\Users\issda\OneDrive\Documents\Obsidian Vault`
- `C:\Users\issda\OneDrive\Documents\GitHub\Avalon`
- `C:\Users\issda\book-backups`

It reads supported local files only (`.md`, `.markdown`, `.txt`, `.csv`, `.json`), ranks likely quote/style/note files, and writes receipts. It does not broadly recurse all of OneDrive.

To add exact files without broad scanning:

```powershell
$env:AETHERDESK_QUOTE_SOURCES='C:\path\quotes.md;C:\path\message-dump.txt'
npm run aetherdesk:quote-library
```

To add a bounded Obsidian vault, Readwise export folder, Kindle highlights folder, or Google Docs export folder:

```powershell
$env:AETHERDESK_QUOTE_NOTE_ROOTS='C:\path\ObsidianVault;C:\path\ReadwiseExport'
npm run aetherdesk:quote-library
```

Tuning knobs:

- `AETHERDESK_QUOTE_CARD_LIMIT` controls the final card count, default `140`.
- `AETHERDESK_QUOTE_NOTE_SCAN_LIMIT` controls how many note files are visited, default `650`.
- `AETHERDESK_QUOTE_NOTE_SOURCE_LIMIT` controls how many discovered files become sources, default `48`.
- `AETHERDESK_QUOTE_NOTE_MAX_BYTES` skips oversized discovered files, default `2500000`.

## Writing Harness

The lane now uses the practical pattern from current AI writing tools:

1. Braindump/source notes become codex cards.
2. Codex cards hold people, places, objects, lore, subplots, methods, and other source rules.
3. Scene beats define POV, setting, conflict, quote anchor, canon anchor, and continuity checks before prose.
4. Drafting runs through style guard and source trace gates.
5. KDP/YouTube publishing actions stay human-only; the lane creates prep packets and receipts.

Generated packets:

- `fiction_chapter_packet`
- `nonfiction_section_packet`
- `youtube_episode_voice_packet`
- `kdp_prepub_voice_packet`

## Original and Corrected Layers

Each quote card now carries both the source signal and the clean drafting layer:

- `original_quote`: exact text as found or typed, including misspellings and letter-order habits.
- `corrected_quote`: spelling-fixed version for clean prose.
- `raw_quote`: current working quote text, same as `corrected_quote` for compatibility with older UI surfaces.
- `normalized_quote`: older helper alias, same spelling-only corrected layer.
- `edit_receipt`: deterministic correction list with `from`, `to`, `offset`, and correction type.

This keeps the user's words as source paint while still allowing the final page, caption, chapter, or KDP text to read cleanly. The original layer helps future correction, text navigation, and before/after assembly review.

## Obsidian / Markdown

The file `latest.obsidian.md` is a vault-friendly markdown handoff with YAML frontmatter, theme index, style fingerprint, writing harness, and top quote cards. If a local `.obsidian` vault is found in bounded roots, the JSON artifact includes `obsidian://open` URI examples. The file is also useful as plain markdown if Obsidian is not open.

## Research Notes

Patterns copied into the harness:

- Sudowrite Story Bible: https://docs.sudowrite.com/using-sudowrite/1ow1qkGqof9rtcyGnrWUBS/what-is-story-bible/jmWepHcQdJetNrE991fjJC
- Sudowrite Scenes and Draft: https://docs.sudowrite.com/using-sudowrite/1ow1qkGqof9rtcyGnrWUBS/scenes--draft/49p5MTVxTKkVFEC5rVUzpY
- Novelcrafter Codex: https://www.novelcrafter.com/help/docs/codex/the-codex
- Obsidian URI handoff: https://obsidian.md/help/uri
