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: stabilize windows hook and claw tests

Affaan Mustafad1f44e89e247
diff --git a/scripts/claw.js b/scripts/claw.js
index 03a391756..0ff539b88 100644
--- a/scripts/claw.js
+++ b/scripts/claw.js
@@ -144,10 +144,11 @@ function searchSessions(query, dir) {
const q = String(query || '').toLowerCase().trim();
if (!q) return [];
- const sessions = listSessions(dir);
+ const sessionDir = dir || getClawDir();
+ const sessions = listSessions(sessionDir);
const results = [];
for (const name of sessions) {
- const p = getSessionPath(name);
+ const p = path.join(sessionDir, `${name}.md`);
const content = loadHistory(p);
if (!content) continue;
@@ -212,12 +213,12 @@ function exportSession(filePath, format, outputPath) {
return { ok: false, message: `Unsupported export format: ${format}` };
}
-function branchSession(currentSessionPath, newSessionName) {
+function branchSession(currentSessionPath, newSessionName, targetDir = getClawDir()) {
if (!isValidSessionName(newSessionName)) {
return { ok: false, message: `Invalid branch session name: ${newSessionName}` };
}
- const target = getSessionPath(newSessionName);
+ const target = path.join(targetDir, `${newSessionName}.md`);
fs.mkdirSync(path.dirname(target), { recursive: true });
const content = loadHistory(currentSessionPath);
diff --git a/tests/integration/hooks.test.js b/tests/integration/hooks.test.js
index a53d4b53f..17df089fa 100644
--- a/tests/integration/hooks.test.js
+++ b/tests/integration/hooks.test.js
@@ -100,11 +100,15 @@ function runHookWithInput(scriptPath, input = {}, env = {}, timeoutMs = 10000) {
function runHookCommand(command, input = {}, env = {}, timeoutMs = 10000) {
return new Promise((resolve, reject) => {
const isWindows = process.platform === 'win32';
+ const mergedEnv = { ...process.env, CLAUDE_PLUGIN_ROOT: REPO_ROOT, ...env };
+ const resolvedCommand = isWindows
+ ? command.replace(/\$\{([A-Z_][A-Z0-9_]*)\}/g, (_, name) => String(mergedEnv[name] || ''))
+ : command;
const shell = isWindows ? 'cmd' : 'bash';
- const shellArgs = isWindows ? ['/d', '/s', '/c', command] : ['-lc', command];
+ const shellArgs = isWindows ? ['/d', '/s', '/c', resolvedCommand] : ['-lc', resolvedCommand];
const proc = spawn(shell, shellArgs, {
- env: { ...process.env, CLAUDE_PLUGIN_ROOT: REPO_ROOT, ...env },
+ env: mergedEnv,
stdio: ['pipe', 'pipe', 'pipe']
});
diff --git a/tests/scripts/claw.test.js b/tests/scripts/claw.test.js
index 572638144..b4c0da0b4 100644
--- a/tests/scripts/claw.test.js
+++ b/tests/scripts/claw.test.js
@@ -252,35 +252,31 @@ function runTests() {
if (test('searchSessions finds query in saved session', () => {
const tmpDir = makeTmpDir();
- const originalHome = process.env.HOME;
- process.env.HOME = tmpDir;
try {
- const sessionPath = path.join(tmpDir, '.claude', 'claw', 'alpha.md');
- fs.mkdirSync(path.dirname(sessionPath), { recursive: true });
+ const clawDir = path.join(tmpDir, '.claude', 'claw');
+ const sessionPath = path.join(clawDir, 'alpha.md');
+ fs.mkdirSync(clawDir, { recursive: true });
appendTurn(sessionPath, 'User', 'Need oauth migration');
- const results = searchSessions('oauth');
+ const results = searchSessions('oauth', clawDir);
assert.strictEqual(results.length, 1);
assert.strictEqual(results[0].session, 'alpha');
} finally {
- process.env.HOME = originalHome;
fs.rmSync(tmpDir, { recursive: true, force: true });
}
})) passed++; else failed++;
if (test('branchSession copies history into new branch session', () => {
const tmpDir = makeTmpDir();
- const originalHome = process.env.HOME;
- process.env.HOME = tmpDir;
try {
- const source = path.join(tmpDir, '.claude', 'claw', 'base.md');
- fs.mkdirSync(path.dirname(source), { recursive: true });
+ const clawDir = path.join(tmpDir, '.claude', 'claw');
+ const source = path.join(clawDir, 'base.md');
+ fs.mkdirSync(clawDir, { recursive: true });
appendTurn(source, 'User', 'base content');
- const result = branchSession(source, 'feature-branch');
+ const result = branchSession(source, 'feature-branch', clawDir);
assert.strictEqual(result.ok, true);
const branched = fs.readFileSync(result.path, 'utf8');
assert.ok(branched.includes('base content'));
} finally {
- process.env.HOME = originalHome;
fs.rmSync(tmpDir, { recursive: true, force: true });
}
})) passed++; else failed++;