Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

refactor(core): finish phase-1 extraction — docs + reverse-import guard

enes9d20927bb4d2
diff --git a/src/main/context-link.cli.test.ts b/src/core/context-link.cli.test.ts
similarity index 98%
rename from src/main/context-link.cli.test.ts
rename to src/core/context-link.cli.test.ts
index 208c3528e..4a6ba5681 100644
--- a/src/main/context-link.cli.test.ts
+++ b/src/core/context-link.cli.test.ts
@@ -3,7 +3,7 @@ import { execFileSync } from 'node:child_process'
import { mkdtempSync, writeFileSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
-import { CLI_SCRIPT } from '../core/context-link-core'
+import { CLI_SCRIPT } from './context-link-core'
let dir: string
diff --git a/src/core/no-electron.test.ts b/src/core/no-electron.test.ts
index c23643107..d28b74ac6 100644
--- a/src/core/no-electron.test.ts
+++ b/src/core/no-electron.test.ts
@@ -9,11 +9,42 @@ function walk(dir: string): string[] {
})
}
+// Catches: bare `electron`, electron subpaths (`electron/main`), and any reach-back
+// into the Electron shell (`../main/`, `../../main/`) — via import or require.
+const OFFENDERS =
+ /from ['"]electron(\/[^'"]*)?['"]|require\(['"]electron(\/[^'"]*)?['"]\)|from ['"](\.\.\/)+main\//
+
describe('core boundary', () => {
- it('no file under src/core imports electron', () => {
- const offenders = walk(__dirname).filter((f) =>
- /from ['"]electron['"]|require\(['"]electron['"]\)/.test(fs.readFileSync(f, 'utf8'))
- )
+ it('no file under src/core imports electron or reaches back into ../main', () => {
+ const offenders = walk(__dirname)
+ // This test file itself contains sample offender strings (below) to prove the regex.
+ .filter((f) => f !== __filename)
+ .filter((f) => OFFENDERS.test(fs.readFileSync(f, 'utf8')))
expect(offenders).toEqual([])
})
+
+ it('offenders regex catches electron, electron subpaths, and ../main reach-backs', () => {
+ // These must all be flagged:
+ for (const bad of [
+ `import { app } from 'electron'`,
+ `import { BrowserWindow } from "electron"`,
+ `const { ipcMain } = require('electron')`,
+ `import { x } from 'electron/main'`,
+ `const y = require("electron/common")`,
+ `import { PtyManager } from '../main/pty-manager'`,
+ `import { z } from '../../main/index'`
+ ]) {
+ expect(OFFENDERS.test(bad), bad).toBe(true)
+ }
+ // These must NOT be flagged (legitimate core imports):
+ for (const ok of [
+ `import fs from 'fs'`,
+ `import { CorePlatform } from './platform'`,
+ `import { foo } from '../core/foo'`,
+ `import { bar } from '@shared/ipc'`,
+ `import electronBuilder from 'electron-builder'`
+ ]) {
+ expect(OFFENDERS.test(ok), ok).toBe(false)
+ }
+ })
})