Skip to content

feat: auto-create missing parent directories when writing files - #1065

Merged
7Sageer merged 1 commit into
mainfrom
feat/write-auto-mkdir-parents
Jun 24, 2026
Merged

feat: auto-create missing parent directories when writing files#1065
7Sageer merged 1 commit into
mainfrom
feat/write-auto-mkdir-parents

Conversation

@7Sageer

@7Sageer 7Sageer commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No prior issue — the problem is described below.

Problem

The Write tool failed with a "parent directory does not exist" error whenever it was asked to write into a not-yet-created subfolder. In practice the agent would then run mkdir and retry the same write, adding a redundant round trip for a very common case.

What changed

Write now creates missing parent directories recursively (like mkdir(parents=True, exist_ok=True)) before writing, so writing into a fresh subfolder succeeds in one call. An existing parent path that is not a directory is still a hard error, and the change is covered by updated tests. The tool description and the en/zh reference docs are updated to match.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

The Write tool previously failed when a parent directory was missing, forcing a manual mkdir round trip. It now creates missing parents recursively before writing.
@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3d2e4f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@3d2e4f3
npx https://pkg.pr.new/@moonshot-ai/kimi-code@3d2e4f3

commit: 3d2e4f3

@7Sageer
7Sageer merged commit 4b837d6 into main Jun 24, 2026
9 checks passed
@7Sageer
7Sageer deleted the feat/write-auto-mkdir-parents branch June 24, 2026 06:05
@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
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.

1 participant