Overview

Freeform templates (Template Manager → New Template → Freeform) are written in HTML, CSS and JavaScript. Their JavaScript can use a global alistair object to read the open project: characters, places, scenes, comments, dialogue, word counts and more. Every call returns a promise, so write await alistair.characters(); that works anywhere in the JS tab.

Results are copies of your data. A template reads your project freely, but changes it only after asking you: Alistair shows what it wants to do and lets you allow it once, always, or not at all, and each change comes with Undo. That keeps templates safe to share. The builder's API tab lists every call with an example to insert and a Try it button that runs it on your project; typing alistair. in the editor lists them too, and the Console under the preview shows what your code logs and any errors, with their line.

// A cast list that keeps itself up to date
async function render() {
  const cast = await alistair.characters();
  const list = document.querySelector('#cast');
  list.replaceChildren(...cast.map(c => {
    const li = document.createElement('li');
    li.textContent = c.name + ' (' + c.role + ')';
    li.onclick = () => alistair.open(c.id);
    return li;
  }));
}
render();
alistair.on('change', render);   // re-run whenever anything is saved

Project

The open project as a whole.

alistair.project()

The open project: its name, type and total manuscript words.

Returns

{
  "id": "f3c2…",
  "name": "The Glass Road",
  "type": "manuscript",
  "words": 84210,
  "scenes": 42,
  "createdAt": "2026-03-01T09:12:00Z",
  "lastModified": "2026-10-07T18:40:00Z"
}

Example

const project = await alistair.project();
document.querySelector('#title').textContent = project.name;

alistair.stats()

Counts at a glance: words, scenes by status, and how many characters, locations and so on.

Returns

{
  "words": 84210,
  "scenes": 42,
  "byStatus": {
    "draft": 30,
    "revision": 10,
    "final": 2
  },
  "characters": 18,
  "locations": 11,
  "factions": 4,
  "species": 2,
  "religions": 1,
  "magicSystems": 1,
  "lore": 9
}

Example

const s = await alistair.stats();
document.querySelector('#progress').textContent =
  `${s.words.toLocaleString()} words in ${s.scenes} scenes (${s.byStatus.final || 0} final)`;

alistair.me()

This document (the one using the template): its id and title. null in the builder's preview.

Returns

{
  "id": "9ab1…",
  "title": "Cast Board",
  "type": "custom"
}

Example

const me = await alistair.me();
if (me) document.querySelector('#heading').textContent = me.title;

alistair.settings()

The writer's theme and writing language.

Returns

{
  "theme": "dark",
  "language": "auto"
}

Example

const { theme, language } = await alistair.settings();

Documents

Any document, by type or folder, and text search across the manuscript.

alistair.documents({ type, folder })

Every document in the project, without their contents. Filter by type ('scene', 'character', 'location', …) or folder name. A document made from a custom template has that template's id as template.

Returns

[
  {
    "id": "1d0e…",
    "title": "Chapter 1",
    "type": "scene",
    "folder": "Manuscript",
    "subfolder": "Scenes",
    "status": "draft",
    "order": 0,
    "wordCount": 2310,
    "lastModified": "2026-10-06T21:03:00Z",
    "icon": {
      "name": "flame",
      "color": "#e07a5f",
      "image": null
    },
    "template": null
  }
]

Example

const notes = await alistair.documents({ folder: 'Notes' });
notes.forEach(n => console.log(n.title));

alistair.document(id)

One document in full: its plain text (scenes, notes) or its fields (sheets and templates).

Returns

{
  "id": "1d0e…",
  "title": "Chapter 1",
  "type": "scene",
  "status": "draft",
  "wordCount": 2310,
  "text": "The road was glass…",
  "fields": {}
}

Example

const doc = await alistair.document(id);
console.log(doc.text || doc.fields);

alistair.search(text, { limit })

Finds words or a phrase in the manuscript and returns each place, with the sentence around it.

Returns

[
  {
    "sceneId": "1d0e…",
    "scene": "Chapter 1",
    "snippet": "…she drew the glass sword and…",
    "position": 1834
  }
]

Example

const hits = await alistair.search('glass sword', { limit: 20 });
const list = document.querySelector('#mentions');
list.innerHTML = '';
hits.forEach(h => {
  const li = document.createElement('li');
  li.textContent = `${h.scene}: ${h.snippet}`;
  li.onclick = () => alistair.open(h.sceneId);
  list.appendChild(li);
});

Story

Your cast, world and story structure, as they are on their sheets.

alistair.scenes()

The manuscript's scenes in reading order, with status, word count and who and where appears in each.

Returns

[
  {
    "id": "1d0e…",
    "number": 1,
    "title": "Chapter 1",
    "status": "draft",
    "wordCount": 2310,
    "characters": [
      "Mara Venn",
      "Tom Hale"
    ],
    "locations": [
      "Greyhaven"
    ],
    "lastModified": "2026-10-06T21:03:00Z"
  }
]

Example

const scenes = await alistair.scenes();
const rows = scenes.map(s => `<tr><td>${s.number}</td><td>${s.title}</td><td>${s.status}</td><td>${s.wordCount}</td></tr>`);
document.querySelector('#scene-table tbody').innerHTML = rows.join('');

alistair.characters()

Every character sheet: name, role, age, gender, aliases, traits, motivation, factions and more.

Returns

[
  {
    "id": "7c4a…",
    "name": "Mara Venn",
    "role": "Protagonist",
    "age": "34",
    "gender": "Female",
    "aliases": [
      "Mags"
    ],
    "occupation": "Cartographer",
    "traits": "stubborn, loyal",
    "motivation": "…",
    "species": "Human",
    "factions": [
      {
        "name": "The Ash Guild",
        "id": "…"
      }
    ],
    "color": "#c0392b",
    "relationships": []
  }
]

Example

const cast = await alistair.characters();
const select = document.querySelector('[name="pov_character"]');
cast.forEach(c => select.add(new Option(c.name, c.name)));

alistair.locations()

Every location: name, type, parent location, description, climate, population and aliases.

Returns

[
  {
    "id": "2b9f…",
    "name": "Greyhaven",
    "locationType": "City",
    "parentLocation": "The Northreach",
    "description": "…",
    "climate": "Cold",
    "population": "40,000",
    "aliases": []
  }
]

Example

const places = await alistair.locations();
const cities = places.filter(p => p.locationType === 'City');

alistair.factions()

Every faction: type, leader, seat of power, goals, allies and rivals (as ids).

Returns

[
  {
    "id": "5e1d…",
    "name": "The Ash Guild",
    "factionType": "Guild",
    "leader": "Oren Pike",
    "seat": "Greyhaven",
    "goals": "…",
    "allies": [],
    "rivals": [
      "…"
    ]
  }
]

Example

const factions = await alistair.factions();

alistair.species()

Every Ancestry document (the peoples of your world), with its homeland.

Returns

[
  {
    "id": "…",
    "name": "Selk",
    "homeland": "The Drowned Coast"
  }
]

Example

const species = await alistair.species();

alistair.religions()

Every religion, with the factions tied to it (as ids).

Returns

[
  {
    "id": "…",
    "name": "The Quiet Faith",
    "factionIds": []
  }
]

Example

const religions = await alistair.religions();

alistair.magicSystems()

Every magic system document.

Returns

[
  {
    "id": "…",
    "name": "Glasswork"
  }
]

Example

const systems = await alistair.magicSystems();

alistair.lore()

Every lore entry: category, when it happened, summary, and the characters, locations and factions it involves.

Returns

[
  {
    "id": "…",
    "name": "The Shattering",
    "category": "Event",
    "when": "Year 0",
    "summary": "…",
    "characters": [],
    "locations": [],
    "factions": []
  }
]

Example

const lore = await alistair.lore();
const events = lore.filter(l => l.category === 'Event');

alistair.relationships()

Every relationship recorded on the character sheets, as one flat list.

Returns

[
  {
    "characterId": "7c4a…",
    "character": "Mara Venn",
    "with": "Tom Hale",
    "type": "Ally"
  }
]

Example

const links = await alistair.relationships();
const allies = links.filter(r => /ally/i.test(r.type));

alistair.beats()

The story beats in each scene (Story Arc): name, time, location, who is present and the mood, in reading order.

Returns

[
  {
    "sceneId": "1d0e…",
    "scene": "Chapter 1",
    "number": 1,
    "beats": [
      {
        "name": "The gate",
        "time": "Dawn",
        "location": "Greyhaven",
        "locations": [
          "Greyhaven"
        ],
        "characters": [
          "Mara Venn"
        ],
        "mood": "Tense"
      }
    ]
  }
]

Example

const scenes = await alistair.beats();
const rows = scenes.flatMap(s => s.beats.map(b => `<li><b>${s.scene}</b> · ${b.name || 'Beat'} — ${b.characters.join(', ')}</li>`));
document.querySelector('#beats').innerHTML = rows.join('');

alistair.relationshipHistory()

How relationships change through the story: each change, the scene it happens in and in what order (character sheets come first).

Returns

[
  {
    "sceneId": null,
    "sceneTitle": "Character Sheet",
    "order": -1,
    "character": "Mara Venn",
    "target": "Tom Hale",
    "type": "Ally"
  }
]

Example

const log = await alistair.relationshipHistory();
const maraTom = log.filter(e => e.character === 'Mara Venn' && e.target === 'Tom Hale');

alistair.journeys()

Where each character goes, scene by scene (from the scenes’ story elements).

Returns

{
  "Mara Venn": [
    {
      "id": "1d0e…",
      "title": "Chapter 1",
      "location": "Greyhaven"
    }
  ]
}

Example

const journeys = await alistair.journeys();
const path = (journeys['Mara Venn'] || []).map(step => step.location).join(' → ');

Writing

The manuscript as writing: comments, dialogue, versions and progress.

alistair.comments({ resolved })

Comments across the manuscript, in reading order: the text, the words they are on, replies. Open ones only unless resolved: true.

Returns

[
  {
    "sceneId": "1d0e…",
    "scene": "Chapter 1",
    "id": "c1",
    "text": "Too fast here?",
    "quote": "drew the glass sword",
    "resolved": false,
    "replies": []
  }
]

Example

const todo = await alistair.comments();
document.querySelector('#todo').innerHTML = todo.map(c => `<li>${c.scene}: ${c.text}</li>`).join('');

alistair.dialogue(sceneId)

Every line of dialogue and who speaks it (the Dialogue panel’s speakers), for one scene or, without an id, the whole manuscript.

Returns

[
  {
    "sceneId": "1d0e…",
    "scene": "Chapter 1",
    "speaker": "Mara Venn",
    "text": "“Ready?”",
    "how": "tag"
  }
]

Example

const lines = await alistair.dialogue();
const bySpeaker = {};
lines.forEach(l => { const k = l.speaker || 'Unknown'; bySpeaker[k] = (bySpeaker[k] || 0) + 1; });

alistair.versions(id)

A document's saved versions, oldest first: when, how many words, and whether you saved it or it was automatic.

Returns

[
  {
    "id": "v12",
    "number": 12,
    "createdAt": "2026-10-06T21:03:00Z",
    "wordCount": 2310,
    "type": "manual",
    "label": null
  }
]

Example

const history = await alistair.versions(sceneId);
const growth = history.map(v => v.wordCount);

alistair.progress()

The manuscript's word count at the end of each day, worked out from saved versions. Nothing is tracked or sent anywhere.

Returns

[
  {
    "date": "2026-10-05",
    "words": 81200
  },
  {
    "date": "2026-10-06",
    "words": 84210
  }
]

Example

const days = await alistair.progress();
const today = days[days.length - 1];
const yesterday = days[days.length - 2];
if (today && yesterday) document.querySelector('#today').textContent = `+${today.words - yesterday.words} words today`;

alistair.analyze(text)

Quick numbers for any text: words, sentences, average and longest sentence, reading time, reading ease (English) and the most used words.

Returns

{
  "words": 2310,
  "sentences": 141,
  "paragraphs": 38,
  "averageSentence": 16.4,
  "longestSentence": 52,
  "readingMinutes": 9,
  "readingEase": 71,
  "topWords": [
    {
      "word": "glass",
      "count": 14
    }
  ]
}

Example

const doc = await alistair.document(sceneId);
const stats = await alistair.analyze(doc.text);
document.querySelector('#ease').textContent = stats.readingEase ?? '—';

Changes

Making a document, changing a field or a status: Alistair asks the writer first (Allow, Always allow this template, or Don't allow), and every change can be undone from the message that follows it. A template's own store needs no question.

alistair.createDocument({ title, template, type, fields, text, open })

Makes a new document: from a template (this one, unless you name another with template: its id) or a built-in kind with type: character, location, faction, magic_system, religion, species, lore or note. fields fills a template's fields; text is a note's text; open: true opens it. Alistair asks the writer first.

Returns

{
  "id": "7c2e…",
  "title": "Fireball"
}

Example

const spell = await alistair.createDocument({ title: 'Fireball', fields: { kind: 'Instant' } });
alistair.notify(`Made ${spell.title}`);

alistair.setField(id, field, value)

Changes one field of another document made from a template (this document's own fields are on the page). Alistair asks the writer first.

Returns

{
  "id": "7c2e…",
  "field": "kind",
  "value": "Ritual"
}

Example

await alistair.setField(spellId, 'kind', 'Ritual');

alistair.setStatus(id, status)

Sets a document's status: draft, revision, review, final or published. Alistair asks the writer first.

Returns

{
  "id": "1d0e…",
  "status": "final"
}

Example

await alistair.setStatus(sceneId, 'revision');

alistair.getData(key)

Reads this template's own store in the project (a goal, a setting, a list). Without a key, everything in it.

Returns

50000

Example

const goal = (await alistair.getData('goal')) ?? 50000;

alistair.setData(key, value)

Keeps a value in this template's own store in the project, up to 100 KB in all; null removes it. Only this template uses it, so Alistair doesn't ask.

Returns

{
  "goal": 60000
}

Example

await alistair.setData('goal', 60000);

Actions

Opening documents, messages and the clipboard. None of them change your project.

alistair.open(id)

Opens a document in its own editor (this one is saved first).

Returns

true

Example

link.addEventListener('click', () => alistair.open(character.id));

alistair.openInNewTab(id)

Opens a document in a new tab, leaving this one where it is.

Returns

true

Example

alistair.openInNewTab(scene.id);

alistair.notify(message, kind)

Shows a short message in Alistair. kind is 'info', 'success', 'warning' or 'error'.

Returns

true

Example

alistair.notify('Name copied', 'success');

alistair.copy(text)

Copies text to the clipboard.

Returns

true

Example

await alistair.copy(generatedName);
alistair.notify('Copied ' + generatedName, 'success');

Events

alistair.on(name, fn) returns a function that stops listening.

alistair.on('change', fn)

Runs fn whenever a document in the project is saved, here or in another tab. fn receives { type, id }.

Example

alistair.on('change', () => refresh());

alistair.on('load', fn)

Runs fn once this document's saved values are back in its fields, so code that reads a field (a goal, a search) can run again with them. Not in the builder's preview.

Example

alistair.on('load', () => refresh());

alistair.on('theme', fn)

Runs fn when the writer switches between light and dark. fn receives 'light' or 'dark'.

Example

alistair.on('theme', theme => document.body.dataset.theme = theme);

Examples to start from

New Template offers these under "Built on your project's data". Each is a working template to save as it is or take apart.

Cast Board

Every character as a card with role and color. Filter by role; click a card to open the sheet.

Scene Tracker

Scenes in columns by status (draft, revision, final) with word counts and overall progress.

Mentions Finder

Find every place a name, object or phrase appears in the manuscript, with the sentence around it.

Word Goal

Set a target and a deadline; see progress, the daily pace you need, and your words over time.

Dialogue Balance

Who speaks how much, across the manuscript or in one scene, using the Dialogue panel’s speakers.

Editorial To-Do

Every open comment in the manuscript, by scene, with the words it is on. Click one to go there.

Name Generator

Names built from syllables with a chosen sound, or your own; keep the ones you like.