Skip to content

TextFlow is IWE with an AI writing assistant that edits manuscripts through chat commands, tracks story consistency automatically.

License

Notifications You must be signed in to change notification settings

KazKozDev/textflow

Repository files navigation

txt

When Intelligence Meets Prose

TextFlow is an LLM-powered Integrated Writing Environment (IWE) for professional literary editing — just as Windsurf and Cursor bring cascaded AI assistance to code, TextFlow brings the same approach to prose.

Who Is This For?

  • Writers — working on novels and long-form fiction
  • Editors — professional literary editing
  • Screenwriters — screenplay and dramatic works
  • Authors — any structured manuscript requiring consistency

TextFlow is not just a set of LLM tools for text editing. It is a convenient environment for working with manuscripts. It features a natural language chat interface for agent control, similar to Visual Studio Copilot or Cursor.

The system includes Story Bible, which automatically generates and maintains knowledge bases for characters, world-building, and timeline consistency. Every change goes through the Patch System, allowing you to review changes with a clear rationale for each change. Quality Metrics offers a quantitative assessment of the manuscript based on parameters such as clarity, tension, and pacing, while a complete version history with semantic versioning provides full rollback capability.

Screenshot 2025-10-08 at 18 54 21

How it works. Type natural language commands: "Remove passive voice from Chapter 3" or "Make the dialogue more authentic. Agent understands context and manuscript structure. Get instant feedback and execution plans. Review changes before applying them.

Examples:

"Strengthen the opening hook"
"Add more sensory details to the forest scene"
"Check if Emma's character development is consistent"
"Improve pacing in the action sequence"
"Find all instances of telling instead of showing"

The AI agent operates through a chat interface and has access to several core functions: it can retrieve specific manuscript fragments with editing rules and Story Bible data, execute structured edit plans with patch validation, update the Story Bible with new information, and analyze the entire manuscript to build or refine the Story Bible. You simply send a request — for instance, “analyze character development” or “remove passive voice” — and the agent autonomously determines which tools to use, retrieving context, generating edits, and applying them where needed.

There are no mode switches or manual configurations — it’s a single intelligent system that understands your intent and performs the necessary operations. Just like Cursor or Windsurf handle multiple coding tasks through one unified assistant, this agent brings the same seamless workflow to literary editing.

Quick Commands

Pre-built prompts for common editing tasks (accessible via chat):

Category Commands
Foundation • Build Story Bible
• Update timeline consistency
• Track character development
Structure Analysis • Analyze character arcs
• Identify plot holes
• Check continuity errors
Story Flow • Evaluate pacing and tension
• Strengthen opening hook
• Improve scene transitions
Scene Polish • Review dialogue authenticity
• Add sensory details
• Enhance character voice
Line Editing • Tighten prose
• Fix passive voice
• Remove redundant adverbs

Import/Export

Import:

  • Files: .txt, .docx, .pdf
  • URLs with AI-powered HTML parsing

Export formats:

  • PDF — print-ready
  • EPUB — e-readers
  • DOCX — Microsoft Word
  • IDML — Adobe InDesign
  • TXT — plain text
  • JSON — full project backup

🏗️ Cascade Architecture

Why Cascade?

Traditional AI editors work like this:

User Request → AI Response → Done

TextFlow's cascade ensures quality:

Chat Command → Analyze → Generate → Validate → Report

The Four-Stage Pipeline

Stage 1: Analyze & Plan

  • Agent receives editing instruction via chat
  • Calls get_document_context to retrieve text, rules, and memory
  • Creates actionable TODO list with specific steps

Stage 2: Generate Patches

For each plan item, the agent generates:

{
  "before_anchor": "context before target",
  "before_excerpt": "text to replace",
  "after_anchor": "context after target",
  "after_proposed": "new text",
  "rationale": "why this change improves the text"
}

Stage 3: Execute with Validation

Calls execute_edit_plan tool which runs:

  • ✅ Anchor validation — ensures correct location
  • ✅ Style checks — no new passive voice, minimal adverbs
  • ✅ POV checks — maintains narrative consistency
  • ✅ Metrics calculation — before/after quality scores

Only validated patches are applied.

Stage 4: Report

Agent presents results in chat:

  • Natural language summary
  • Comprehensive JSON report
  • Applied patches with reasons
  • Skipped patches with explanations
  • Metrics comparison

Benefits of Cascade Architecture

🔍 Auditability — Every change has rationale and validation trail

🛡️ Safety — Multi-layer checks prevent quality degradation

📖 Transparency — Users see exactly what changed and why

⏮️ Revertibility — All changes tracked in semantic version history

🎯 Precision — Anchor-based patches remain valid even during concurrent edits


Quick Start

Prerequisites

  • Node.js 18+ (download)
  • Google AI API key (get here)
  • Safari browser (recommended for best performance and compatibility)

Installation

1. Clone the repository

git clone https://github.com/KazKozDev/textflow.git
cd textflow

2. Install dependencies

npm install

3. Start development server

npm run dev

App opens at: http://localhost:5173

Quick Start (macOS)

Double-click Start.command file — it will automatically:

  • Install dependencies
  • Start dev server
  • Open app in browser

Inline Editing

Quick edits without patch review:

  1. Select text
  2. Press Cmd+I (or Ctrl+I)
  3. Enter instruction
  4. AI replaces instantly

Semantic Search

Search by meaning, not just keywords:

  • Search "betrayal" finds thematically related passages
  • AI understands context and concepts

🛠️ Tech Stack

  • React 18 + TypeScript — UI with strict typing
  • Vite — build tool and dev server
  • Google Gemini 2.5 Flash — AI model with function calling
  • react-window — virtualization for large documents
  • localStorage — persistent state management

No backend required — fully client-side application.


📄 License

Business Source License 1.1

TextFlow is licensed under the Business Source License 1.1, which allows:

Free use for non-production purposes:

  • Personal projects
  • Research and education
  • Testing and evaluation
  • Internal development

Production use requires a commercial license

🔓 Automatic transition to Apache 2.0 on January 1, 2029

For full license terms, see the LICENSE file.

For commercial licensing inquiries, contact: Artem Kazakov Kozlov (KazKozDev)


If you like this project, please give it a star ⭐

For questions, feedback, or support, reach out to:

Artem KK

About

TextFlow is IWE with an AI writing assistant that edits manuscripts through chat commands, tracks story consistency automatically.

Topics

Resources

License

Stars

Watchers

Forks