#100

Bug: missing output directories are treated as files

Opendajiaohuangopened 1mo ago

Summary

When -o or AI_CLI_OUTPUT_DIR points to a directory that does not yet exist, the CLI treats the path as the output file. isDirectory() only recognizes an existing directory and returns false when statSync() fails. The writeOutput() false branch then writes to that path directly instead of creating a directory and placing generated output inside it. This conflicts with the documented behavior that -o <dir> saves inside the directory.

Steps to reproduce

  1. Ensure renders/ does not exist.
  2. Run ai text hello -o ./renders/ with a valid provider key.
  3. Inspect renders.

Expected behavior

Create renders/ and write the generated file inside it.

Actual behavior

Static review of main at 088d76493e30595f07bf5fddca8f9073a821af4b shows the missing path fails statSync, selects the file path branch, and writes to renders itself. I have not run the CLI; this behavior is inferred from that source path.

Version / environment

ai-cli 0.5.2; main 088d76493e30595f07bf5fddca8f9073a821af4b. The package declares Node.js >=22.

Co-contributor credit

No, do not credit me.

Activity

0

No activity yet.