Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
test: CI portability — macOS cwd gate, Windows file modes and locked temp dirs
Salman Qureshid1271e0d75ef
diff --git a/src/capabilities/permissions.test.ts b/src/capabilities/permissions.test.tsindex 7060f9d5..b8fdfc90 100644--- a/src/capabilities/permissions.test.ts+++ b/src/capabilities/permissions.test.ts@@ -506,11 +506,13 @@ describe('safe-read classifier: residual side-effect flags (table)', () => {['curl -sSLJO http://example.com', 'curl -J/-O inside a cluster'],['curl --output out.html http://example.com', 'curl --output'],['curl --remote-name http://example.com/x', 'curl --remote-name'],- ['curl --output-dir /tmp -O http://example.com/x', 'curl --output-dir'],+ // Relative paths on purpose: an absolute path outside the cwd is denied+ // by the cwd gate before the classifier can prompt (macOS /tmp → /private/tmp).+ ['curl --output-dir downloads -O http://example.com/x', 'curl --output-dir'],['wget -O out.html http://example.com', 'wget -O'],['wget --output-document=out.html http://example.com', 'wget --output-document='],['wget -o log.txt http://example.com', 'wget -o writes a log file'],- ['wget -P /tmp http://example.com', 'wget -P chooses the download directory'],+ ['wget -P downloads http://example.com', 'wget -P chooses the download directory'],['wget -qO- http://example.com', 'wget -O inside a cluster'],];diff --git a/src/channels/choice-prompt-timeout.test.ts b/src/channels/choice-prompt-timeout.test.tsindex 497c6695..d24f74aa 100644--- a/src/channels/choice-prompt-timeout.test.ts+++ b/src/channels/choice-prompt-timeout.test.ts@@ -78,7 +78,9 @@ describe('choice prompt timeout / dismissal', () => {const messages = channel.getTuiState().chatMessages;expect(messages.some(m => m.role === 'agent' && m.content === 'visible reply')).toBe(true);} finally {- rmSync(tmpDir, { recursive: true, force: true });+ // enterMercuryCode kicks off an async `git` read with cwd=tmpDir; on+ // Windows the directory stays locked until that child exits.+ rmSync(tmpDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });}});});\ No newline at end of filediff --git a/src/core/board-db.test.ts b/src/core/board-db.test.tsindex 54dfd946..337d0200 100644--- a/src/core/board-db.test.ts+++ b/src/core/board-db.test.ts@@ -34,7 +34,7 @@ afterEach(() => {if (savedBackend === undefined) delete process.env[SQLITE_BACKEND_ENV];else process.env[SQLITE_BACKEND_ENV] = savedBackend;resetSqliteDriverForTests();- rmSync(home, { recursive: true, force: true });+ rmSync(home, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });});describe('BoardDB', () => {@@ -63,6 +63,9 @@ describe('BoardDB', () => {// A second instance sees the committed state (no in-memory cache).const again = createBoardDB();expect(again.loadAll().map((b) => b.id)).toEqual(['b2']);+ // Release the handles: Windows refuses to delete a DB that is still open.+ db.close();+ again.close();});it('falls back to JSON files when storage is JSON-only', () => {diff --git a/src/core/board-db.ts b/src/core/board-db.tsindex 85d5e6de..805acd3a 100644--- a/src/core/board-db.ts+++ b/src/core/board-db.ts@@ -30,6 +30,8 @@ export interface BoardDB {saveContext(boardId: string, context: BoardContext): void;getContext(boardId: string): BoardContext | undefined;flush(): void;+ /** Release file handles (SQLite) after a final flush. Safe to call twice. */+ close(): void;}// ── JSON Fallback (optimized with write debouncing) ──────────────@@ -125,6 +127,10 @@ class JSONBoardDB implements BoardDB {}writeFileSync(this.contextPath, JSON.stringify(ctxData, null, 2), 'utf-8');}++ close(): void {+ this.flush();+ }}// ── SQLite Backend (when available) ──────────────────────────────@@ -201,6 +207,10 @@ class SQLiteBoardDB implements BoardDB {flush(): void {// SQLite is already durable per write}++ close(): void {+ this.db.close();+ }}// ── Factory ──────────────────────────────────────────────────────diff --git a/src/ui/input-history-store.test.ts b/src/ui/input-history-store.test.tsindex 18810f9c..2482570c 100644--- a/src/ui/input-history-store.test.ts+++ b/src/ui/input-history-store.test.ts@@ -36,7 +36,8 @@ describe('persistent input history (~/.mercury/history)', () => {lines = appendInputHistory(lines, ' ', file); // blanks are skippedexpect(lines).toEqual(['first', 'second\nline']);expect(loadInputHistory(file)).toEqual(['first', 'second\nline']);- expect(statSync(file).mode & 0o777).toBe(0o600);+ // Windows has no POSIX modes (stat reports 0666 for any writable file).+ if (process.platform !== 'win32') expect(statSync(file).mode & 0o777).toBe(0o600);});it('keeps only the newest HISTORY_LIMIT lines on disk and on load', () => {@@ -52,7 +53,7 @@ describe('persistent input history (~/.mercury/history)', () => {expect(loaded[loaded.length - 1]).toBe(`x${HISTORY_LIMIT + 9}`);});- it('tightens the mode of a pre-existing world-readable file', () => {+ it.skipIf(process.platform === 'win32')('tightens the mode of a pre-existing world-readable file', () => {saveInputHistory(['a'], file);writeFileSync(file, 'a\n', { mode: 0o644 });// chmod on an existing path: writeFileSync keeps 0o644 unless we fix it