cmte
Version:
Design by Committee™ except it's just you and LLMs
108 lines (102 loc) • 3.15 kB
JavaScript
import path from 'path';
import { ensureDir } from '../../utils/fs.js';
/**
* Output path generator for standardizing paths according to the .o.md convention
*/
export class PathGenerator {
constructor(baseOutputPath) {
this.baseOutputPath = baseOutputPath;
}
/**
* Generate a task output path
*
* @param phaseName Phase name
* @param phaseIteration Optional phase iteration name
* @param setName Set name
* @param setIteration Optional set iteration name
* @param taskName Task name
* @param taskIteration Optional task iteration name
* @returns Standardized task output path
*/
generateTaskOutputPath(phaseName, phaseIteration, setName, setIteration, taskName, taskIteration) {
const parts = [phaseName];
if (phaseIteration) {
parts.push(phaseIteration);
}
parts.push(setName);
if (setIteration) {
parts.push(setIteration);
}
parts.push(taskName);
if (taskIteration) {
parts.push(taskIteration);
}
return path.join(this.baseOutputPath, ...parts, `${taskName}.o.md`);
}
/**
* Generate a set output path
*
* @param phaseName Phase name
* @param phaseIteration Optional phase iteration name
* @param setName Set name
* @param setIteration Optional set iteration name
* @returns Standardized set output path
*/
generateSetOutputPath(phaseName, phaseIteration, setName, setIteration) {
const parts = [phaseName];
if (phaseIteration) {
parts.push(phaseIteration);
}
parts.push(setName);
if (setIteration) {
parts.push(setIteration);
}
return path.join(this.baseOutputPath, ...parts, `${setName}.o.md`);
}
/**
* Generate a phase output path
*
* @param phaseName Phase name
* @param phaseIteration Optional phase iteration name
* @returns Standardized phase output path
*/
generatePhaseOutputPath(phaseName, phaseIteration) {
const parts = [phaseName];
if (phaseIteration) {
parts.push(phaseIteration);
}
return path.join(this.baseOutputPath, ...parts, `${phaseName}.o.md`);
}
/**
* Generate an output path for an iterated item
*
* @param phaseName Phase name
* @param setName Set name
* @param itemName Item identifier
* @param taskName Task name
* @returns Standardized output path for an iterated item
*/
generateIteratedTaskOutputPath(phaseName, setName, itemName, taskName) {
return path.join(this.baseOutputPath, phaseName, setName, itemName, `${taskName}.o.md`);
}
/**
* Generate an output path for an iterated set
*
* @param phaseName Phase name
* @param setName Set name
* @param itemName Item identifier
* @returns Standardized output path for an iterated set
*/
generateIteratedSetOutputPath(phaseName, setName, itemName) {
return path.join(this.baseOutputPath, phaseName, setName, `${itemName}.o.md`);
}
/**
* Ensure the directory for an output path exists
*
* @param outputPath Output file path
*/
async ensureOutputDirectory(outputPath) {
const directory = path.dirname(outputPath);
await ensureDir(directory);
}
}