How pair-code/wordcraft works
Wordcraft is an LLM-assisted story editor. Writers use editor and sidebar controls to request generation or rewriting, review alternatives, and apply text to the document; they can also save documents and use chat or starred results. Its domain stages are operation selection and state capture, context- and operation-specific prompt construction, Gemini generation and parsing, then editor updates. The graph preserves documented capabilities, but several runtime links are based on README statements because their implementation files were not sampled.
Main entry points: sidebar_right.ts Writing sidebar · operation.ts Operation steps · app.ts Application shell · model.ts Model abstraction
Components 22
Writing interface
- Application shell
app/components/app.ts - Text editor view
app/components/text_editor.ts - Writing sidebar
app/components/sidebar_right.ts - Operation controls
app/components/operations.ts - Choice review
app/components/choices.ts - Writing chat
app/components/chat.ts - Starred results
app/components/starred.ts
Operations and services
- Operation dispatcher
app/core/services/operations_service.ts - Writing operations
app/core/operations - Operation steps
app/core/operations/operation.ts - Operation data processing
app/core/operation_data/processor.ts
Prompt and generation
- Few-shot context
app/context/index.ts - Model service
app/core/services/model_service.ts - Model abstraction
app/models/model.ts - Gemini prompts and parsing
app/models/gemini/index.ts - Gemini API client
app/models/gemini/api.ts
Document and state
- Editor state and edits
app/core/services/text_editor_service.ts - Document persistence
app/core/services/document_store_service.ts - Browser storage
app/core/services/local_storage_service.ts - Sentence analysis
app/core/services/sentences_service.ts
Other components
- Writer
- Gemini
Connections 22
- Writer → Application shell: uses
- Application shell → Text editor view: renders
app/components/app.ts - Application shell → Writing sidebar: renders
app/components/app.ts - Writing sidebar → Operation controls: renders
app/components/sidebar_right.ts - Writing sidebar → Choice review: renders
app/components/sidebar_right.ts - Writing sidebar → Writing chat: renders
app/components/sidebar_right.ts - Writing sidebar → Starred results: renders
app/components/sidebar_right.ts - Writer → Operation dispatcher: requests writing
- Operation dispatcher → Writing operations: dispatches
app/core/services/operations_service.ts - Writing operations → Operation steps: uses lifecycle
app/core/operations/operation.ts - Operation steps → Operation data processing: processes input
app/core/operations/operation.ts - Operation steps → Model service: requests generation
app/core/operations/operation.ts - Model service → Model abstraction: uses model
- Model abstraction → Few-shot context: uses examples
app/models/model.ts - Model abstraction → Gemini prompts and parsing: delegates prompts
app/models/gemini/index.ts - Gemini prompts and parsing → Gemini API client: calls
app/models/gemini/index.ts - Gemini API client → Gemini: queries
- Operation steps → Editor state and edits: updates text
- Text editor view → Editor state and edits: edits document
- Application shell → Document persistence: saves documents
app/components/app.ts - Document persistence → Browser storage: persists state
app/core/services/local_storage_service.ts - Operation steps → Sentence analysis: uses boundaries