fix(audit): expand home paths across phase0 CLI scripts

Apply HOME-based ~ expansion to summarize/drift/prune audit scripts for input/output path flags to match capture behavior and avoid literal ~/ path bugs. Architecture/protocol diagrams reviewed; no updates needed for this path-resolution change.
This commit is contained in:
William Valentin
2026-02-27 13:30:08 -08:00
parent c91262ac30
commit 576b11106f
4 changed files with 57 additions and 9 deletions
+14 -3
View File
@@ -30,6 +30,17 @@ function isoDateTagNow(): string {
return new Date().toISOString().slice(0, 10);
}
function expandHomePath(pathValue: string): string {
if (!pathValue.startsWith('~')) {
return pathValue;
}
const home = process.env.HOME;
if (!home) {
return pathValue;
}
return resolve(home, pathValue.slice(1));
}
function parseOptionalInteger(raw: string | undefined, flag: string): number | undefined {
if (!raw) {
return undefined;
@@ -111,7 +122,7 @@ async function main(): Promise<void> {
return;
}
const artifactsDir = resolve(values['artifacts-dir'] ?? 'docs/plans/artifacts');
const artifactsDir = resolve(expandHomePath(values['artifacts-dir'] ?? 'docs/plans/artifacts'));
const keepPerFamily = parseOptionalInteger(values['keep-per-family'], '--keep-per-family') ?? 8;
const apply = Boolean(values.apply);
const format = values.format ?? 'text';
@@ -124,12 +135,12 @@ async function main(): Promise<void> {
const defaultBaseName = resolve(artifactsDir, `phase0_baseline_live_prune_${reportTag}`);
const summaryJsonOut = values['summary-json-out']
? resolve(values['summary-json-out'])
? resolve(expandHomePath(values['summary-json-out']))
: writeDefaultArtifacts
? `${defaultBaseName}.json`
: undefined;
const summaryMdOut = values['summary-md-out']
? resolve(values['summary-md-out'])
? resolve(expandHomePath(values['summary-md-out']))
: writeDefaultArtifacts
? `${defaultBaseName}.md`
: undefined;