memory-literary-analysis

Analyze a complete literary work into a structured Basic Memory knowledge graph. Covers schema design, entity seeding, chapter-by-chapter processing, cross-referencing, validation, and graph exploration.

By basicmachines-co · 767 installs

npx skills add basicmachines-co/basic-memory --skill memory-literary-analysis

Source repository · Upstream listing

Memory Literary Analysis Transform a complete literary work into a structured knowledge graph. Characters, themes, chapters, locations, symbols, and literary devices become interconnected notes — searchable, validatable, and traversable. Project scope If the project is unknown, discover it with bm project(command="list") . Pass a nonempty project on every note, folder, context and schema call, even with one project or a qualified memory:// URL. Use the chosen project's name, workspace/project , or external ID; <work name below is a placeholder for it. Recent activity also requires project . Search accepts project for one project, projects for selected projects, or all projects=True explicitly. Discovery and bundled manuals need no project. Keep the same scope when following returned paths, paginating, or recovering from a refusal. When to Use Analyzing a novel, play, poem, or non fiction book end to end Building a teaching or study resource for a literary text Creating a book club companion knowledge base Research projects requiring structured close reading Stress testing Basic Memory at scale (~200+ notes, 1000+ relations) Pipeline Overview Tools Writing goes through bm write and bm edit . MCP reads use bm read , bm find , bm search , and bm list . The CLI keeps its POSIX verbs; the table and shell examples below are CLI commands (prefix each verb with bm ): Need Use Instead of A section of a long note cat <note section Observations reading the whole note A line range of the source text cat <source .txt lines 4200 4890 pulling the whole book into context Notes matching frontmatter find meta status=active reading notes to check fields Fields across many notes find meta ... fields pov,setting one read per note Where something lives ls , tree , find name ' .md' listing everything The two rules that matter across a 100+ chapter run: Never read a note to check a field. That is what meta predicates and fields projection are for — one call answers what a read per note loop would cost. Never pull a whole file into context to reach one part of it. Sections and line ranges slice the output : the full note is still fetched, then cut down before it is returned. What they save is context, not I/O — a long chapter or a full source text costs you the tokens of the relevant part, not of the whole file. Two sharp edges to know before you write a query. The first fails quietly — a short answer, exit 0, no warning — so learn it here rather than from a graph you thought you had audited: find pages, and the default page is 10. Any query whose answer is "all N chapters" needs page size 100 (the maximum) and paging — see [Coverage Checks]( coverage checks). name cannot combine with meta . The metadata search has no filename glob. Scope a meta query with the positional path instead: find /characters meta 'note type=character' . That path is matched on a directory boundary against the file path a note is indexed under — where the note actually lives, not its permalink, which stops mirroring the file path once a note pins permalink: in frontmatter or is moved. So /characters reaches everything filed under characters/ (including characters/major/ ), and never characters cut/ . For MCP, use bm read(identifier="<note ", section="Observations", project="<work name ") or start line / end line for slices. Use bm find(filters={"type": "chapter"}, fields=["chapter number", "pov"], project="<work name ") for metadata and bm search(query="doubloon", lines=2, project="<work name ") for matching lines. bm list lists one folder level; bm find recurses. MCP list/find/search pages cap at 100; follow has more through every page. CLI page sizes and flags below are separate from the MCP shapes. Phase 0: Setup Create the Project Use a kebab case slug of the work's title (e.g., great gatsby , hamlet , beloved ). Define Schemas Write 6 schema notes to schema/ . Each schema defines the entity type's fields, observation categories, and relation types. Adapt fields to fit the work — the schemas below are starting points, not rigid templates. Character Schema Add work specific fields as needed — e.g., rank for military fiction, house for family sagas, species for fantasy. Theme Schema Chapter Schema Location Schema Symbol Schema LiteraryDevice Schema Directory Structure Phase 1: Seed Entities Before processing chapters, create stub notes for major entities so [[wiki links]] resolve from the start. Characters (major) For each major character, create a stub with known metadata: Seed Checklist Identify the work's major entities before you start reading. A good starting inventory: Type Typical Count What to Include Characters (major) 8 20 Protagonist, antagonist, key supporting cast Themes 5 12 Central concerns the work explores Locations 4 10 Primary settings, symbolically significant places Symbols 4 10 Recurring objects, images, or motifs with layered meaning Stubs don't need to be complete — they give [[wiki link]] targets and will be enriched during chapter processing. Phase 2: Chapter Processing Source Text Preparation Obtain the full text and identify chapter/section boundaries. For public domain works, Project Gutenberg is a good source. For copyrighted works, work from a physical or licensed digital copy. Put the source text inside the project directory, as .txt , and index it once. bm cat resolves a note identifier , not a filesystem path — it can only reach a file the project index has observed. A one time index pass gives the raw text an entity row, after which the line range slice works against it: Two constraints that make this the right shape, both worth respecting: Keep it .txt , do not convert it to .md . Basic Memory injects frontmatter into markdown notes, which shifts every line number by the height of that block — an offset map built from the original file would then be silently wrong. A .txt is stored verbatim, so its line numbers stay 1:1 with the file on disk. Keep it inside the project. A source text elsewhere on disk is not an entity, and bm cat answers Error: Entity not found . If you must leave it outside, drop the BM verbs for the source and use plain shell ( sed n '4200,4890p' <path ) — the notes still get the BM verbs, only the raw source falls back to the shell. Then build a chapter offset map once, before processing. Scan the text for chapter headings and record the line range of each chapter, then read chapters by range rather than re reading the whole book into context: grep n here is the shell's grep on a filesystem path (this is the map building step, and it needs the file). bm cat then takes the note identifier and returns exactly that slice, numbered, under a Lines 4200 4890 of N header. Pass project <work so it reads from the right project. bm head moby dick.txt n 40 project moby dick is the cheap way to eyeball the heading format before writing the grep pattern. Store the map in the project (a note or a small JSON file) so later batches — and a resumed run after context compaction — do not have to rediscover it. On a long work this is the single largest context saving in the pipeline. Batching Strategy Process ~10 chapters per batch to balance depth with progress. Group by narrative arc or thematic focus: Batch Typical Content 1 Opening: setting, character introductions, world building 2 3 Rising action: conflicts established, relationships develop 4 6 Middle: complications, turning points, thematic deepening 7 8 Climax approach: escalation, revelations, crises Final Climax, resolution, epilogue Adjust batch size based on chapter length and density. Short, action heavy chapters can be batched in larger groups; long, philosophically dense chapters may need smaller batches. Per Chapter Workflow For each chapter: 1. Read the chapter carefully. Read the chapter's line range from the offset map ( bm cat <source .txt lines <start <end ), not the whole file. Read the actual text — never work from memory or a summary; textual evidence is the entire point. 2. Create the chapter note: 3. Enrich related entities: append and prepend do not target a section — they write at the end of the note and the start of the body. Use insert after section / insert before section to land lines under a heading; they fail loudly if the heading is missing. 4. Track progress using the memory tasks skill to create a processing task that survives context compaction. What to Capture Per Chapter Category What to Look For [summary] 1 2 sentence chapter synopsis [event] Key plot events (actions, revelations, arrivals) [tone] Emotional and stylistic atmosphere [technique] Narrative innovations (POV shifts, structural experiments, genre blending) [quote] Memorable or thematically significant passages [significance] Why this chapter matters to the whole [foreshadowing] Hints at future events Entity Enrichment Per Chapter As each chapter is processed, append observations to relevant entities: Characters : [arc] moments, new [trait] revelations, [quote] attributions Themes : [manifestation] in this chapter, [evolution] shifts Symbols : [appearance] with context, new [interpretation] angles Locations : [atmosphere] as described, [significance] in scene Literary devices : [example] from this chapter Adding Prose and Interpretation After the structured observations are in place, consider adding interpretive prose to major entity notes. Insert 2 4 paragraphs of critical essay before the Observations section with bm edit(command="insert before section", section="Observations", content=..., project="<work name ") . This prose should: Argue for a reading of the character, theme, or symbol — not just describe it Connect the entity to the work's larger concerns and to literary tradition Include subjective opinions clearly marked as such ("In my reading...", "I find...") Ground claims in textual evidence cited by chapter number The prose adds the interpretive texture that structured observations alone cannot capture. Phase 3: Cross Referencing After all chapters are processed: Find What Needs Enriching Do not re read every note to decide what is thin. Query for it: A field a note never set comes back as None ( null under json ), so rows with blanks are the work queue. This turns "audit the graph" from a read of every note into one call per question. bm write snake cases note type ( Chapter is stored as chapter ), and meta type predicates are normalized the same way, so either spelling matches. page size 100 is not decoration: without it these return the first 10 rows and the work queue looks ten items long. Character Arcs For each major character, write a full [arc] summary observation covering their trajectory across the work. Theme Evolution For each theme, add [evolution] observations tracing how it develops from introduction to resolution. Chapter Parallels Add parallels and contrasts with relations between structurally similar chapters (e.g., mirrored scenes, repeated settings, thematic echoes). Analysis Notes Create synthesis notes in analysis/ : Recommended analysis notes: Narrative Structure — overall architecture and pacing Work Overview — synthesis of the complete work (summary, thesis, legacy) Critical Reception — historical and contemporary interpretations Discover Emergent Entities During chapter processing, new minor characters, locations, and symbols will em