Zion Boggan zionboggan.com ↗

Create output directories if missing

cd97d36   Zion Boggan committed on Jun 12, 2026 (1 week ago)
src/cli.js +3 -1
@@ -155,6 +155,7 @@ export async function main(argv) {
const requested = requestedArtifacts(opts, artifacts);
if (requested.length) {
for (const artifact of requested) assertClean(artifact.text, decisions, artifact.label);
+ mkdirSync(projectDir, { recursive: true });
mkdirSync(ttDir, { recursive: true });
for (const artifact of requested) writeFileSync(artifact.path, artifact.text);
writeFileSync(decisionsPath, JSON.stringify(decisions, null, 2));
@@ -172,9 +173,10 @@ export async function main(argv) {
for (const artifact of Object.values(artifacts)) assertClean(artifact.text, decisions, artifact.label);
assertClean(report, decisions, 'TREETRACE_REPORT.md');
+ mkdirSync(projectDir, { recursive: true });
+ mkdirSync(ttDir, { recursive: true });
writeFileSync(outPath, md);
writeFileSync(reportPath, report);
- mkdirSync(ttDir, { recursive: true });
writeFileSync(join(ttDir, 'tree.json'), jsonText);
for (const artifact of Object.values(artifacts)) writeFileSync(artifact.path, artifact.text);
test/treetrace.test.js +13 -0
@@ -239,6 +239,19 @@ test('cli: default run writes analysis artifacts with redaction', async () => {
}
});
+test('cli: creates the output directory and .treetrace subdirectory when missing', async () => {
+ const base = mkdtempSync(join(tmpdir(), 'treetrace-'));
+ const dir = join(base, 'does', 'not', 'exist', 'yet');
+ try {
+ assert.ok(!existsSync(dir), 'target dir should not exist before the run');
+ await main(['--file', FIXTURE, '--dir', dir, '--redact-auto', '--quiet']);
+ assert.ok(existsSync(join(dir, 'PROMPT_TREE.md')), 'PROMPT_TREE.md missing');
+ assert.ok(existsSync(join(dir, '.treetrace', 'tree.json')), '.treetrace/tree.json missing');
+ } finally {
+ rmSync(base, { recursive: true, force: true });
+ }
+});
+
test('plain transcript fallback parses User:/Assistant: markers', () => {
const session = parsePlainTranscript(
'User: build me a snake game in python\nAssistant: sure, here is the code...\nUser: make the snake blue\nAssistant: done',