impeccable project-wide (#27)

Reviewed-on: #27
Co-authored-by: vickydotbat <vickydotbat@tutamail.com>
Co-committed-by: vickydotbat <vickydotbat@tutamail.com>
This commit was merged in pull request #27.
This commit is contained in:
2026-07-16 22:12:56 +00:00
committed by archvillainette
parent 60bcd589c0
commit 1b99c93193
106 changed files with 51536 additions and 0 deletions
@@ -0,0 +1,51 @@
#!/usr/bin/env node
/**
* CLI helper: discard pending manual edits from the buffer without applying.
*
* Reads .impeccable/live/pending-manual-edits.json, drops entries, writes back.
* No source-file writes. Use this when the user wants to throw away unsaved
* manual edits.
*
* Trigger: only when the user explicitly asks the AI to discard / throw away /
* clear pending manual edits.
*
* Usage:
* node live-discard-manual-edits.mjs # discard all pending
* node live-discard-manual-edits.mjs --page-url=/ # discard only entries for "/"
*
* Output JSON: { discarded: N, entries: [...discardedEntries], totalCount: N }
*/
import { readBuffer, removeEntries, truncateBuffer } from './live/manual-edits-buffer.mjs';
function argVal(args, name) {
const prefix = name + '=';
for (const a of args) {
if (a === name) return true;
if (a.startsWith(prefix)) return a.slice(prefix.length);
}
return null;
}
const args = process.argv.slice(2);
if (args.includes('--help') || args.includes('-h')) {
console.log('Usage: node live-discard-manual-edits.mjs [--page-url=<url>]');
process.exit(0);
}
const pageUrlFilter = argVal(args, '--page-url');
const cwd = process.cwd();
let discarded;
let entries;
const buffer = readBuffer(cwd);
if (pageUrlFilter) {
entries = buffer.entries.filter((entry) => entry.pageUrl === pageUrlFilter);
discarded = removeEntries(cwd, (entry) => entry.pageUrl === pageUrlFilter);
} else {
entries = buffer.entries;
discarded = truncateBuffer(cwd);
}
const remaining = readBuffer(cwd).entries.reduce((n, e) => n + e.ops.length, 0);
console.log(JSON.stringify({ discarded, entries, totalCount: remaining }));