cccc icon indicating copy to clipboard operation
cccc copied to clipboard

cccc_repo_edit mkdir ignores documented exist_ok

Open wva2ccyk-prog opened this issue 2 months ago • 1 comments

Summary

cccc_repo_edit(action="mkdir") documents an exist_ok option with default true, but the implementation ignores the option.

Tested on CCCC v0.4.40.

Reproduction

cccc_repo_edit(action="mkdir", path=".probe", exist_ok=true)
cccc_repo_edit(action="mkdir", path=".probe", exist_ok=true)

The second call fails with:

File exists (os error 17)

Expected

When exist_ok=true (including the documented default), creating an already-existing directory should succeed.

When exist_ok=false, the existing AlreadyExists failure should be preserved.

An existing non-directory at the same path should still fail even with exist_ok=true.

Cause

In crates/cccc-mcp/src/repo.rs, the mkdir branch directly calls:

std::fs::create_dir(&path)

and does not read exist_ok.

The public MCP schema in resources/mcp_tools.json exposes:

exist_ok: boolean
default: true
For action=mkdir

so the schema and implementation disagree.

Local verification

A minimal implementation that treats AlreadyExists as success only when exist_ok=true && path.is_dir() was tested with regression cases for:

  • first mkdir
  • repeated mkdir with default/true
  • repeated mkdir with false
  • existing regular file

All passed.

wva2ccyk-prog avatar Sep 19 '26 04:09 wva2ccyk-prog

Thanks for catching this contract mismatch! The pending fix honors exist_ok=true by default, while preserving errors for exist_ok=false and existing files. Regression tests cover these cases.

ChesterRa avatar Sep 19 '26 08:09 ChesterRa