Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix: handle dotted reserved snapshot names

Affaan Mustafa841beea45cb2
diff --git a/scripts/loop-status.js b/scripts/loop-status.js
index 6c7128b15..16c0d6987 100644
--- a/scripts/loop-status.js
+++ b/scripts/loop-status.js
@@ -626,7 +626,12 @@ function sanitizeSnapshotName(value, fallback = 'session') {
return sanitized;
}
if (sanitized && isWindowsReservedBasename(sanitized)) {
- return `${sanitized}-${hashString(raw).slice(0, 8)}`;
+ const firstDotIndex = sanitized.indexOf('.');
+ const hashSuffix = hashString(raw).slice(0, 8);
+ if (firstDotIndex === -1) {
+ return `${sanitized}-${hashSuffix}`;
+ }
+ return `${sanitized.slice(0, firstDotIndex)}-${hashSuffix}${sanitized.slice(firstDotIndex)}`;
}
const prefix = sanitized ? sanitized.slice(0, 48).replace(/[._-]+$/g, '') : fallback;
diff --git a/tests/scripts/loop-status.test.js b/tests/scripts/loop-status.test.js
index a3da4b89c..63cb1c6aa 100644
--- a/tests/scripts/loop-status.test.js
+++ b/tests/scripts/loop-status.test.js
@@ -642,6 +642,9 @@ function runTests() {
writeTranscript(homeDir, '-Users-affoon-project-windows-name', 'con.jsonl', [
assistantMessage('2026-04-30T09:55:00.000Z', 'con', 'Loop checkpoint.'),
]);
+ writeTranscript(homeDir, '-Users-affoon-project-windows-name', 'con-txt.jsonl', [
+ assistantMessage('2026-04-30T09:56:00.000Z', 'con.txt', 'Loop checkpoint.'),
+ ]);
const result = run([
'--home',
@@ -657,13 +660,17 @@ function runTests() {
const indexPath = path.join(snapshotDir, 'index.json');
const indexPayload = JSON.parse(fs.readFileSync(indexPath, 'utf8'));
- const snapshotName = path.basename(indexPayload.sessions[0].snapshotPath);
- assert.strictEqual(indexPayload.sessions[0].sessionId, 'con');
- assert.notStrictEqual(snapshotName.toLowerCase(), 'con.json');
+ assert.strictEqual(indexPayload.sessions.length, 2);
- const snapshotPayload = JSON.parse(fs.readFileSync(indexPayload.sessions[0].snapshotPath, 'utf8'));
- assert.strictEqual(snapshotPayload.schemaVersion, 'ecc.loop-status.session.v1');
- assert.strictEqual(snapshotPayload.session.sessionId, 'con');
+ for (const sessionIndex of indexPayload.sessions) {
+ const snapshotName = path.basename(sessionIndex.snapshotPath);
+ assert.notStrictEqual(snapshotName.toLowerCase(), `${sessionIndex.sessionId}.json`);
+ assert.ok(!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(snapshotName.split('.')[0]));
+
+ const snapshotPayload = JSON.parse(fs.readFileSync(sessionIndex.snapshotPath, 'utf8'));
+ assert.strictEqual(snapshotPayload.schemaVersion, 'ecc.loop-status.session.v1');
+ assert.strictEqual(snapshotPayload.session.sessionId, sessionIndex.sessionId);
+ }
} finally {
fs.rmSync(homeDir, { recursive: true, force: true });
fs.rmSync(snapshotDir, { recursive: true, force: true });