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
- Ensure
renders/does not exist. - Run
ai text hello -o ./renders/with a valid provider key. - 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
0No activity yet.