Skip to content

fix: ensure chapters/ and story/ subdirectories are created before writing files (fixes Windows ENOENT)#42

Open
y-chell wants to merge 1 commit intoNarcooo:masterfrom
y-chell:fix/mkdir-on-windows
Open

fix: ensure chapters/ and story/ subdirectories are created before writing files (fixes Windows ENOENT)#42
y-chell wants to merge 1 commit intoNarcooo:masterfrom
y-chell:fix/mkdir-on-windows

Conversation

@y-chell
Copy link

@y-chell y-chell commented Mar 17, 2026

Problem

On Windows, inkos write next and inkos draft fail with ENOENT: no such file or directory because the chapters/ and story/ subdirectories under a book's directory are not created before writing files.

inkos book create only creates the book root directory and book.json. The subdirectories are expected to exist when the writer agent tries to save chapter content and truth files.

Related issue: #41

Root Cause

In packages/core/src/agents/writer.ts, the saveChapter method creates chapters/ with mkdir({ recursive: true }) but does not create story/ before writing current_state.md, particle_ledger.md, and pending_hooks.md.

In packages/core/src/pipeline/runner.ts, there are two additional code paths in runWriteChapter that write to storyDir and chaptersDir without ensuring the directories exist first.

Fix

  • packages/core/src/agents/writer.ts: add await mkdir(storyDir, { recursive: true }) in saveChapter
  • packages/core/src/pipeline/runner.ts: add await mkdir(storyDir, { recursive: true }) in two revise paths, add await mkdir(chaptersDir, { recursive: true }) in the final chapter save path

Testing

Verified on Windows 11 Pro (Node.js v24.12.0, inkos 0.4.5):

  • Before fix: inkos write next fails with ENOENT after LLM generates chapter content
  • After fix: full write next pipeline completes successfully including audit

Closes #41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows: chapters/ and story/ subdirectories not auto-created, causing ENOENT on write/draft

1 participant