# Rocin — Complete Technical Reference (Papyrus Workspace, Ledger & Scribe CLI) - **Name:** Rocin (`rocin` TUI + `scribe` CLI, featuring the Papyrus editor canvas, Papyrus Decks, and Ledger YAML queries) - **Version:** 0.6.1 - **License:** MIT - **Language & Stack:** Python 3.11+, Textual TUI, PyYAML - **Platforms:** macOS (with native iCloud Drive `.icloud` stub safety) and Linux (automatic `~/Rocin` fallback or `ROCIN_DIR`) - **Install:** `brew install ganymede-lab/tap/rocin` or `pipx install git+https://github.com/Ganymede-Lab/rocin.git@v0.6.1` - **Website:** https://ganymede-lab.github.io/rocin/ - **Repository:** https://github.com/Ganymede-Lab/rocin - **Homebrew Tap:** https://github.com/Ganymede-Lab/homebrew-tap ## 1. What Problem Rocin Solves Long-form writers and worldbuilders often face a forced trade-off: Scrivener offers a great Binder and manuscript compilation but uses a proprietary desktop UI; Obsidian offers YAML metadata, Dataview, and WikiLinks but requires Electron and third-party JavaScript plugins; classic terminal editors like Vim or WordStar are fast and distraction-free but lack chapter organization, live word-goal widgets, and queryable worldbuilding databases. Rocin bridges all three in a single lightweight Python terminal package using 100% plain-text Markdown files with round-trip YAML frontmatter. ## 2. Architecture & File Layout By default on macOS, workspaces live under `~/Library/Mobile Documents/com~apple~CloudDocs/Scribe/` (displayed in Finder as `iCloud Drive/Scribe/`), overridable on macOS or Linux via `ROCIN_DIR` (or `SCRIBE_DIR`): ```text / ├── config.yaml # Theme, help level, active project, HUD visibility ├── templates/ # Global Markdown templates (entry, scene, character, timeline, custom) ├── schemas/ # Global YAML UI widget schemas (.yaml) └── projects// ├── binder.yaml # Hierarchical Draft Parts/Chapters/Scenes order ├── draft/ # Ordered manuscript scenes (.md) ├── characters/ # Character sheets (.md) ├── timelines/ # Timelines (.md) ├── / # Auto-discovered custom Note Type folders (e.g. steeds/, places/) ├── templates/ # Per-project custom templates ├── schemas/ # Per-project YAML UI schemas & Papyrus Decks ├── .snapshots/ # Plain-file timestamped snapshots (diffable & restorable) ├── .trash/ # Safe non-destructive archive for removed notes ├── exports/ # Compiled manuscripts (.md, .html, .pdf, .docx, .epub) └── scratchpad.md # Instant quick-capture scratchpad ``` ## 3. The Papyrus Sheet & Papyrus Decks (`rocin`) - **First-Run Welcome Dialog:** On a fresh workspace with no projects or notes, bare `rocin` offers `[1]` the built-in *Don Quixote* (`la-mancha`) example project (with `Start Here` orientation Sheet), `[2]` creating a new project, or `[3]` the blank global workspace. - **Papyrus Sheet (`Ctrl-O F` Raw YAML toggle):** Clean Prose editor canvas that hides YAML frontmatter while drafting and preserves arbitrary custom YAML keys intact on save. - **Live YAML Header Strip (`Ctrl-O Y` toggle, auto-hidden in Zen Mode `Ctrl-O Z`):** Displays active schema/pinned YAML widgets and real-time word-goal progress bars above the prose on every keystroke, plus a live incoming backlinks count (`^K L Links (N)`). - **Papyrus Decks (`Ctrl-O P`):** Declarative YAML-driven contextual views anchored to the active Papyrus Sheet, defined per note (`papyrus:` frontmatter), per Note Type (`schemas/.yaml`), or built-in defaults. - Creation presets in `Ctrl-K N`: `default`, `scene-command`, `revision-desk`, `research-hub` (World & Lore lookup into Reference Split + `[[WikiLink]]` inserter), and `custom` (opens the visual Deck Builder). - Visual **Deck Builder** (`[C]` inside `Ctrl-O P`): Customize title, widgets, pinned header fields, Ledger table query (validated inline), row action (`open_reference | open_main | insert_link`), and action preset, saved directly to YAML frontmatter. - Switchable multi-deck frontmatter (`[` and `]`): Define multiple named decks on one note (e.g., `Scene Desk` and `Research Hub`). - Strict security allowlist for actions (zero `eval`/shell execution): `set_field`, `cycle_field`, `snapshot`, `open_reference`, `open_main`, `insert_snippet`, `insert_link`, `run_query`, `toggle_view`, and bounded `batch` (max 10 steps). - **In-App Custom Note Types (`Ctrl-N` inside `Ctrl-K N`):** Uses Fish-shell ghost autocomplete (`→` accepts completion while `Tab` stays dedicated to form navigation) and scaffolds both `templates/.md` and `schemas/.yaml` per-project by default (or global). - **Bidirectional `[[WikiLinks]]` & Backlinks:** - `Ctrl-Q L`: Follow `[[Target]]` or `[[Target|Alias]]` under the cursor straight into the Reference Split; if the target note does not exist yet, opens `New Note` pre-filled with that title and creates it directly into Reference Split. - `Ctrl-K L`: Opens the Links & Backlinks modal listing both outgoing links (`[[WikiLinks]]` + YAML `link` fields) and incoming backlinks (from prose `[[links]]` and YAML fields like `pov:` or `pilot:`). ## 4. Declarative YAML UI Widgets (`schemas/.yaml`) 8 native terminal widget types editable with `←`/`→`/`Space` or `Enter` in `Ctrl-K Y` and `Ctrl-O P`: 1. `select` — cycles through `options: [...]` 2. `link` — live-cycles titles of notes matching `source: ` (e.g. `character`, `vehicles`, `*`) 3. `progress` — supports `mode: words` (live note word count vs goal, e.g. `[██████░░░░] 60% (600/1,000w)`) and `mode: value` (numeric progress meter with `max`, `step`, `unit`, e.g. `[███████░░░] 66% (2/3 passes)`) 4. `rating` — star rating `0..max` (`1..10`, e.g. `★★★★☆ (4/5)`) 5. `toggle` — boolean checkbox (`[x] yes` / `[ ] no`) 6. `number` — integer stepper (`step`) 7. `list` — YAML list edited as comma-separated values 8. `text` — freeform string ## 5. Ledger Query Language (`Ctrl-Q D` & `scribe query`) Safe recursive-descent YAML query parser (inspired by Obsidian Dataview, zero `eval()`): - Modes: `TABLE col1, col2 AS Alias ...` or `LIST ...` - `FROM`: `*`, `draft`, `character`, ``, or `:tag` - `WHERE`: `=`, `!=`, `>`, `>=`, `<`, `<=`, `CONTAINS`, `!CONTAINS`, `EXISTS`, `!EXISTS`, `AND`, `OR`, `NOT`, parentheses - `SORT`: multi-column `ASC`/`DESC` - `LIMIT`: integer row limit - Virtual fields: `title`, `kind`, `word_count`, `mtime`, `tags`, `file`, `path`, plus any nested YAML frontmatter key and `{{this.}}` context substitution - Embedded blocks: execute ```` ```ledger ```` (and compatibility ```` ```rocin ```` / ```` ```dataview ````) blocks inside any note via `scribe query --from-note ` or press `0` inside `Ctrl-Q D` to cycle heading-named blocks saved in the active note ## 6. Scribe CLI Reference (`scribe`) Global flag: `-p ` / `--project ` (also accepted by `rocin -p `) - `scribe new "" [-t <template>] [:tag ...] [--set key=val ...] [--no-edit]` - `scribe open [query] [--last]` - `scribe quick "<text>" [:tag ...]` - `scribe list [:tag] [-k <kind>] [--where key=val ...]` - `scribe find "<query>" [--where key=val ...]` - `scribe templates [list | new <name> [--no-edit] | edit <name>]` - `scribe projects [list | new <name> | use <name> | demo [--reset]]` (built-in *Don Quixote* `la-mancha` demo project; also launch via `rocin --demo`) - `scribe snapshot "<query>" [-l <label>]` and `scribe snapshots "<query>"` - `scribe trash [list | restore <query> | empty [--older-than DAYS]]` (backed by `.trash/manifest.yaml`; opt-in `trash_retention_days` in `config.yaml`, default `0` manual) - `scribe compile [-f markdown|html|pdf|docx|epub] [-o <path>] [--title ...] [--author ...]` - `scribe query ["<TABLE/LIST query>"] [--from-note <note>] [--json]` - `scribe schemas [list | new <kind> [--no-edit] | edit <kind> | validate [<kind>]]` ## 7. WordStar 4.0 Chord Summary (`rocin`) - `Ctrl-J` / `F1`: Cycle Help Levels `0` (pure prose), `1` (compact ribbon), `2` (full multi-row menu) - `F2` / `F3` / `F4` (or `Ctrl-Q B / E / V`, `Esc` to editor): Focus Binder / Papyrus / Reference Split - `Ctrl-K`: `S` Save · `D` Save & Quit · `Q` Quit · `N` New Note · `F` New Chapter · `R` Rename · `M` Move to Folder · `U/J` Reorder · `X` Safe Trash (with incoming backlinks warning) · `T` Trash & Recovery Modal · `Y` YAML Properties · `L` Links & Backlinks · `B` Snapshot · `H` Snapshot History · `C` Compile (`O` Open / `R` Finder) · `P` Projects - `Ctrl-Q`: `B/E/V` Focus · `D` Ledger Table · `L` Follow Link · `P/G` Quick Open & YAML Filter · `F` Find (`Ctrl-L` Next) · `K` Open in Ref · `S` Quick Scratch · `R/C` Top/Bottom - `Ctrl-O`: `P` Papyrus Deck · `Y` YAML Header Strip · `B` Binder · `R` Ref Split · `F` Raw YAML · `W` Typewriter Scroll · `T` Theme · `Z` Zen Mode - `Ctrl-P`: `B` Bold · `S` Italic · `H` Heading · `Q` Blockquote · `D` Scene Break (`* * *`) ## 8. Safety & Security Guarantees - Atomic file writes (`os.fsync` + `os.replace`) with symlink refusal - Strict workspace and project path confinement in `binder.yaml`, snapshots, restores, and exports - macOS `.icloud` stub detection prevents pruning offloaded scenes or producing partial compiles - Multi-device `mtime_ns` conflict guard snapshots external edits to `.snapshots/` instead of overwriting - CSS & Typst injection escaping plus `typst --root` and `pandoc --sandbox` during compilation