mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
- governance/index.js: archive filenames now include ISO timestamp for deterministic sorting (<base>_<ts>_<hash>.md); write .meta.json sidecar on every archive with proposalId, author, reason, and archivedAt - governance/index.js: add listPromptVersions(target) — returns archived versions for a prompt sorted newest-first with sidecar metadata surfaced - cmd-rollback.mjs: add --list flag to list available versions without restoring (delegates to listPromptVersions) - cli-parser.mjs: add --list and --output flags - lib.mjs: pass list flag to cmdRollback; add backup command dispatch - cmd-backup.mjs: new torch-lock backup command — snapshots .scheduler-memory/memory-store.json and scheduler run state to .torch/backups/<timestamp>/; supports --output override and --list - docs/prompt-versioning.md: comprehensive guide to the full proposal → apply → list-versions → rollback workflow, state backup and restore procedure, and storage location reference - test/governance.test.mjs: 7 scenario-based tests (SCN-proposal-create, SCN-proposal-list, SCN-proposal-reject, SCN-archive-naming, SCN-version-list, SCN-rollback-latest, SCN-rollback-hash) https://claude.ai/code/session_01Ndq2D72Kp77BYo4owD63uY
31 lines
964 B
JavaScript
31 lines
964 B
JavaScript
import { rollbackPrompt, listPromptVersions } from './services/governance/index.js';
|
|
import { ExitError } from './errors.mjs';
|
|
|
|
export async function cmdRollback(target, strategy, { list = false } = {}) {
|
|
if (!target) {
|
|
console.error('Usage: torch-lock rollback --target <path> [--strategy <hash|latest>] [--list]');
|
|
throw new ExitError(1, 'Missing target');
|
|
}
|
|
|
|
if (list) {
|
|
try {
|
|
const versions = await listPromptVersions(target);
|
|
console.log(JSON.stringify(versions, null, 2));
|
|
} catch (e) {
|
|
console.error(`Failed to list versions: ${e.message}`);
|
|
throw new ExitError(1, 'List versions failed');
|
|
}
|
|
return;
|
|
}
|
|
|
|
const effectiveStrategy = strategy || 'latest';
|
|
|
|
try {
|
|
const result = await rollbackPrompt(target, effectiveStrategy);
|
|
console.log(JSON.stringify(result, null, 2));
|
|
} catch (e) {
|
|
console.error(`Rollback failed: ${e.message}`);
|
|
throw new ExitError(1, 'Rollback failed');
|
|
}
|
|
}
|