ScriptForge is a browser-native compiler for handwritten notebook pages. You write a compact, declarative document — prose, LaTeX-style mathematics, diagrams and 2D sketch scenes — and ScriptForge turns it into deterministic hand-drawn ink, lays it out across real notebook pages, and exports a multi-page PDF or PNG. No cloud, no build step, no API key, no drawing tablet. It is a study-guide engine, an…
ScriptForge is a browser-native compiler for handwritten notebook pages. You write a
compact, declarative document — prose, LaTeX-style mathematics, diagrams and 2D sketch
scenes — and ScriptForge turns it into deterministic hand-drawn ink, lays it out across
real notebook pages, and exports a multi-page PDF or PNG. No cloud, no build step, no API
key, no drawing tablet.
It is a study-guide engine, an engineering-diagram compiler and an AI-native note format
in one package.
You describe the page; ScriptForge draws every stroke
A handwriting font repeats the same glyphs
An allographic engine warps every character with unique noise, slant and pressure
Diagrams are separate images
Diagrams, math and prose share one paginated document
Layout is manual
Multi-column flow, floating figures, text wrapping and collision avoidance
Cloud rendering and accounts
100% local rendering, local PDF compilation, local notes
AI generates a wall of text
Agents write validated DSL through an MCP server
The result is not a screenshot of handwriting. It is vector ink generated from geometry:
each glyph, rule line, graph edge and hatching stroke is sampled with a deterministic seed,
so the same document can be reproduced exactly — or resampled with one click.
Why I built this
When I asked an AI to explain something, I usually got a wall of text. Ask for a diagram
and I got blocky architecture boxes; ask for anything else and it reached for SVG, which
burned tokens fast and still did not look like the page I actually revise from.
Handwriting is a compression format. A small page can hold a derivation, a free-body
diagram, a timing waveform and the one sentence that makes it click. ScriptForge exists so
a human or an agent can write the idea in plain text and get that page back — offline,
deterministic and editable.
Fractions, roots, matrices, piecewise cases, integrals, sums and limits, aligned derivations, Greek and set/logic notation — laid out as hand-drawn 2D math
2- and 3-set Venn diagrams with arbitrary Boolean shading, domain/codomain mappings, bottom-up Hasse posets
Physics
Inclined planes with free-body components, Atwood machines, thin-lens ray traces, electrostatic streamlines, vector fields
3D & calculus
Painter-sorted 3D surfaces, midpoint/trapezoid Riemann sums, 2×2 matrix transformations, ODE slope fields with RK4 trajectories
Page design
A4 notebooks, 2-column A4 cheat sheets, 3-column A3 landscape charts, 4-column wall charts, floats, pinned figures and wrapped text
The Demos bar in the studio loads five complete examples: Spatial Cheat Sheet, Organic
Chemistry, CS Systems, Physics & Optics, and 3D & Calculus.
Showcase
Every image below is real output from the running ScriptForge studio — not a mockup,
not a design file, not a screenshot of a different app.
One A3 page, three columns, every engine
@page size=a3-landscape cols=3 — floating text wrap, side-by-side figure shelves, timing
waveforms, stack/heap pointer arrows, a B-tree, linked list, Venn diagram, Hasse lattice,
chair and Newman chemistry, and a Painter-sorted 3D surface on a single page.
A4 two-column: calculus, linear algebra and ODEs
@page size=a4-2col — a 3D saddle mesh with hidden-line occlusion, a 2×2 matrix
transformation grid, an RK4-integrated ODE slope field, and a midpoint Riemann sum with
hatched partitions.
The language in 60 seconds
A ScriptForge document is plain text. This one file mixes frontmatter, prose, display math,
a graph and a sketch:
Rendered output is a handwritten page with a titled heading, ruled paper, hand-set
mathematics, a layered graph and a labelled row of boxes. Change seed and every glyph and
diagram tremor is resampled. Change paper and the stationery changes. Add more content
and ScriptForge paginates automatically — without splitting an equation or a figure across
pages.
[sketch: ...] is the heart of ScriptForge. It is a small declarative geometry language
with anchors, relative placement, obstacle-aware routing, physics solvers and domain-specific
renderers.
Layouts and routing
[sketch:
title "Compiler pipeline"
dag dir=LR edges="Lexer->Parser->AST->Codegen"
]
[sketch:
node A at=(0, 0) "Source"
node Block right="of A" gap=45 "Obstacle"
node B right="of Block" gap=45 "Target"
arrow A -> B route=ortho label="bypass"
arrow A -> A loop=n label="self"
]
Reingold–Tilford trees and BSTs, with _ phantom children and recursion-tree costs.
Sugiyama DAGs with crossing reduction and automatic back-edge loops.
Deterministic force, circular and bipartite graph layouts.
TikZ-style right="of A", between="A,B", alignX and alignY.
place=right / place=left floats beside prose and wraps text around the figure.
place=row packs compact figures side-by-side on a shelf.
place=xy(x,y) / pin=(x,y) pins a figure and resolves collisions.
w=45%, size=sm|md|lg|full and scale=0.5..2 resize any diagram.
[DIAGRAM: ...] accepts the same keys inline.
The compositor tracks per-column exclusions, so text never runs through a figure and
side-by-side diagrams do not overlap. Explicit @page settings override the studio selector.
PDF export uses the active canvas aspect ratio, so A4, 2-column, A3 and wall-chart pages all
export correctly.
Built for agents
ScriptForge is designed to be written by a human or an AI coding agent.
MCP server
A zero-dependency MCP server exposes the note library over stdio. The agent supplies the
model; ScriptForge supplies storage, validation and rendering. There are no API keys,
network calls or shell access in the MCP path.
Tool
Purpose
get_authoring_guide
Full grammar, frontmatter keys and diagram types
list_notes
Public or private notes with title, tags, path and timestamp
read_note
Raw content, frontmatter and body for a slug
create_note
Create a validated note, optionally overwriting
update_note
Replace an existing note with validated content
append_to_note
Append a validated section
delete_note
Delete a note; requires confirm: true
validate_note
Line-numbered validation with a minimal example on failure
Validation is grounded in the renderers: unsupported LaTeX, malformed diagrams, unbalanced
sketch blocks and bad frontmatter are rejected before a note lands. Failures include line
numbers so an agent can correct itself without guessing.
Downloadable skill
The complete agent skill is
skills/scriptforge-notes/SKILL.md. It documents the
workflow, every diagram command, layout rules, the math allowlist, recipes and troubleshooting.
Download it from the AI Skill button in the studio; the fetch is no-store, so it always
matches the running build.
A useful prompt
Call get_authoring_guide. Create a public note dsa/graphs/traversal explaining BFS with a
layered graph diagram and the complexity equation. Validate it, then open
/?note=dsa/graphs/traversal.
Studio features
Live compile — edit the document and pages re-render immediately.
Insert palette — 44 searchable presets across Math, Diagrams, Layouts, CS & Systems,
Chemistry, Discrete, Physics, 3D & Calculus, Page and Text.
Expanded canvas — click any page or Expand for a full-screen, scrollable stack of
every page.
Five complete demos — Spatial Cheat Sheet, Organic Chemistry, CS Systems, Physics &
Optics, 3D & Calculus.
Style presets — Classic Blue, Engineering Grid, Pencil Draft, Cornell Focus, Red Pen
and Clean Print, with full control over ink, paper, hand font, tilt, grain, shadow and
vignette.
Zero-clone proof — the inspector highlights glyph bounding boxes, per-character warp
seeds, slant deltas and scale matrices.
Image tracer — upload a diagram; Zhang–Suen 1px thinning and RDP simplification turn it
into single-pass pen strokes, fully offline.
Notes library — load public notes or local private notes written through MCP/CLI, with
live reload and an agent-skill download.
CLI — create, read, update, append, validate, delete and index notes from any terminal,
with public/private scopes and JSON output.
PDF and PNG export — true multi-page PDF 1.4 built in the browser, one JPEG XObject per
page, plus current-page PNG.
Quick start
Requires Node.js 18+. There are no runtime dependencies.
npm run dev
# open http://localhost:8000
Any static server rooted at the project directory works:
python3 -m http.server 8000
# or
npx serve .
The studio boots with a demo notebook. Edit the markup, use Insert Diagram / Block, switch
canvas size, then export. Native ES modules require HTTP; opening index.html as a file://
URL will not work.
The notes CLI works without an MCP client and has no dependencies beyond Node.js:
npm run notes -- list
npm run notes -- read dsa/graphs
npm run notes -- create dsa/trees --title "Trees" --tags dsa,trees --file section.md
npm run notes -- update dsa/trees --file section.md
npm run notes -- append dsa/trees --file extra.md
npm run notes -- validate --file section.md
npm run notes -- delete dsa/trees --yes
npm run notes -- index
npm run notes -- guide
Useful flags:
Flag
Meaning
--scope public|private
Select the note library
--json
Machine-readable output for agents
--file <path>
Read note content from a file
--force
Overwrite on create
--yes
Confirm delete
Public notes live in notes/<slug>.md and are tracked. Private notes live in
notes/private/<slug>.md and are git-ignored. A slug beginning with private/ selects
private scope automatically. npm run notes -- guide prints the full authoring contract.
If you change Tailwind utility classes, regenerate the stylesheet:
node scripts/build-tailwind.mjs
Security and privacy
Rendering, pagination, PDF compilation, image tracing and note validation all run locally.
The MCP server has no network access, no shell access and no credentials. It reads and
writes only inside notes/; path traversal and absolute paths are rejected.
Writes are capped at 256 KB, validated before they land and performed atomically.
delete_note requires confirm: true.
notes/private/ and its index are git-ignored. Personal PDFs, notebooks, archives and
internal planning material are ignored too.
The image tracer is fully offline (1px Zhang–Suen centerline tracing). No API key is read
or stored.
Lucide icons load from a CDN and fail gracefully offline; everything else is self-hosted.
Known limitations
Pagination uses an upper-bound block estimate, so a page can end slightly early rather than
clip content.
Not every legacy diagram parameter is honoured by every alias; the universal engines
(grid, schematic, canvas2d, graph, svg, sketch) have the widest coverage.
DFA return-arc labels are drawn as curves but are not yet annotated.
The Image Tracer is Alpha: it works best with high-contrast line art; complex photos and
dense shading may produce rough or incomplete strokes.
The zero-clone inspector currently visualises the slant delta only.
The browser reader is read-only. Agents write notes through MCP or the CLI; the studio
loads them and can export the rendered result.
Provenance
ScriptForge was split out of a single 2090-line HTML file. The split was verified
pixel-identical against the original: rendered canvas bytes, interactive control behaviour
and the image-to-diagram pipeline all match. Vendored assets retain their original licences;
see assets/vendor/rough.LICENSE, assets/fonts/OFL.txt and assets/fonts/NOTICE.md.
ScriptForge is an independent open-source project. If you build on it, a link back to the
repository and the live studio is appreciated. Vendored fonts and Rough.js retain their
original licences; see assets/fonts/OFL.txt, assets/fonts/NOTICE.md and
assets/vendor/rough.LICENSE.
评论