The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Other engines' adoption readers out of the core (o5) (#1066)
Dee989872077ac0
diff --git a/cli/src/architecture.spec.ts b/cli/src/architecture.spec.tsindex f23eb80f2..9cae20820 100644--- a/cli/src/architecture.spec.ts+++ b/cli/src/architecture.spec.ts@@ -216,12 +216,7 @@ const EDGE: RegExp[] = [* The edge files the core's process still loads, each with the step of the plan that takes it out. The* list only shrinks: an entry no longer reached fails the test, so remove it with the move that ends it.*/-const CORE_MAY_REACH: Record<string, string> = {- // Devin keeps its conversations in Claude Code's message format, and its search reader replays them with Claude- // Code's normalizer: core reaches both through Devin's reader until adoption loads it lazily.- 'engines/claude/normalize.ts': '(o5) Devin\'s search reader (lib/sessionSearch/externals/devin.ts → engines/devin/normalizer.ts)',- 'lib/normalize.ts': '(o5) Devin\'s search reader, as above',-}+const CORE_MAY_REACH: Record<string, string> = {}/** The other twelve engines' own files: their folders but for the data they declare, their search readers, and the* shared files that hold only their code. */@@ -238,29 +233,7 @@ const theirs = (file: string): boolean => THEIRS.some((pattern) => pattern.test(* (docs/design/2026-10-08-other-engines-out-of-core.md, section 5). The list only shrinks: an entry no longer* reached fails the test, so remove it with the move that ends it. Empty, the core loads none of their code.*/-const OTHER_ENGINES_CORE_MAY_REACH: Record<string, string> = {- 'engines/copilot/normalizer.ts': '(o5) adoption\'s readers',- 'engines/devin/errorLog.ts': '(o5) adoption\'s readers',- 'engines/devin/normalizer.ts': '(o5) adoption\'s readers',- 'engines/devin/reader.ts': '(o5) adoption\'s readers',- 'engines/hermes/normalizer.ts': '(o5) adoption\'s readers',- 'engines/kilo/normalizer.ts': '(o5) adoption\'s readers',- 'engines/kilo/reader.ts': '(o5) adoption\'s readers',- 'engines/opencode/normalizer.ts': '(o5) adoption\'s readers',- 'engines/opencode/reader.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/agy.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/commandcode.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/copilot.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/cursor.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/devin.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/grok.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/hermes.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/muse.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/opencode.ts': '(o5) adoption\'s readers',- 'engines/cursor/home.ts': '(o5) adoption\'s readers, through lib/sessionSearch/externals/index.ts',- 'engines/hermes/reader.ts': '(o5) adoption\'s readers',- 'lib/sessionSearch/externals/pi.ts': '(o5) adoption\'s readers',-}+const OTHER_ENGINES_CORE_MAY_REACH: Record<string, string> = {}/** Core's entries for each facet, and the sub-batch after which they reach none of the other engines' files. */const FACETS_FREE_OF_THEM: Array<[string, string]> = [@@ -303,6 +276,10 @@ const FACETS_FREE_OF_THEM: Array<[string, string]> = [['lib/engineLaunch.ts', '(o6)'],['lib/gridLaunch.ts', '(o6)'],['lib/subscriptionModel.ts', '(o6)'],+ // Adoption: the other engines' readers, each loaded on the first scan or question that needs it.+ ['lib/sessionSearch/externals/index.ts', '(o5)'],+ ['lib/sessionSearch/external.ts', '(o5)'],+ ['core/agents/adopt.ts', '(o5)'],]describe('the daemon\'s shape', () => {@@ -414,9 +391,9 @@ describe('the daemon\'s shape', () => {expect([...closureOf(entry).keys()].filter(file => /^engines\/(?!kit\/|facets\/|types\.ts$)/.test(file)), entry).toEqual([])}expect(parsedFile(join(SRC, 'engines/kit/adoption.ts')).imports.map(path => relative(SRC, path)).filter(file => /^engines\/(?!kit\/|facets\/)/.test(file))).toEqual([])- // Core's adoption reaches the two engines' code only through Devin's reader (CORE_MAY_REACH, (o5)).- const viaDevin = new Set(closureOf('lib/sessionSearch/externals/devin.ts').keys())- expect(theirs('lib/sessionSearch/externals/index.ts').filter(file => !viaDevin.has(file))).toEqual([])+ // Core's adoption reaches none of the two engines' code: Devin's reader, which replays its store with Claude+ // Code's normalizer, is loaded with Devin's code ((o5)).+ expect(theirs('lib/sessionSearch/externals/index.ts')).toEqual([])})it('building a launch loads the engines\' declared launch contracts alone', () => {diff --git a/cli/src/engines/__fixtures__/other-adoption.golden.json b/cli/src/engines/__fixtures__/other-adoption.golden.jsonnew file mode 100644index 000000000..d177f72a7--- /dev/null+++ b/cli/src/engines/__fixtures__/other-adoption.golden.json@@ -0,0 +1,418 @@+{+ "providers": [+ [+ "claude",+ "function",+ "function"+ ],+ [+ "codex",+ "function",+ "function"+ ],+ [+ "cursor",+ "function",+ "function"+ ],+ [+ "grok",+ "function",+ "function"+ ],+ [+ "copilot",+ "function",+ "function"+ ],+ [+ "opencode",+ "function",+ "function"+ ],+ [+ "kilo",+ "function",+ "function"+ ],+ [+ "hermes",+ "function",+ "function"+ ],+ [+ "devin",+ "function",+ "function"+ ],+ [+ "pi",+ "function",+ "function"+ ],+ [+ "commandcode",+ "function",+ "function"+ ],+ [+ "muse",+ "function",+ "function"+ ],+ [+ "agy",+ "function",+ "function"+ ]+ ],+ "scan": [+ {+ "sessionId": "01a0438c-0e05-73b1-98f9-978079f9e0a5",+ "engine": "grok",+ "cwd": "/work/grok",+ "origin": "terminal",+ "title": "Fix the build",+ "mtime": 1789898550000,+ "transcriptPath": "<root>/home/.grok/sessions/%2Fwork%2Fgrok/01a0438c-0e05-73b1-98f9-978079f9e0a5/updates.jsonl",+ "readHistory": null+ },+ {+ "sessionId": "6c3b2a1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d",+ "engine": "cursor",+ "cwd": "/work/cursor",+ "origin": "terminal",+ "title": "Fix the build",+ "mtime": 1789898500000,+ "transcriptPath": "<root>/home/.cursor-data/projects/work-cursor/agent-transcripts/6c3b2a1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d/6c3b2a1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d.jsonl",+ "readHistory": null+ },+ {+ "sessionId": "ae51057a-0000-4000-8000-000000000001",+ "engine": "agy",+ "cwd": "/work/agy",+ "origin": "terminal",+ "title": "",+ "mtime": 1789898460000,+ "transcriptPath": "<root>/home/.gemini/antigravity-cli/brain/ae51057a-0000-4000-8000-000000000001/.system_generated/logs/transcript_full.jsonl",+ "readHistory": null+ },+ {+ "sessionId": "brisk-otter",+ "engine": "devin",+ "cwd": "/work/devin",+ "origin": "terminal",+ "title": "Fix the tests",+ "mtime": 1789898450000,+ "transcriptPath": null,+ "readHistory": [+ "done"+ ]+ },+ {+ "sessionId": "3f2a9c1e-8b4d-4e6f-9a1b-2c3d4e5f6a7b",+ "engine": "hermes",+ "cwd": "/work/hermes",+ "origin": "editor",+ "title": "",+ "mtime": 1789898420000,+ "transcriptPath": null,+ "readHistory": [+ "user_message",+ "done"+ ],+ "aliases": []+ },+ {+ "sessionId": "20260920_100000_a1b2c3",+ "engine": "hermes",+ "cwd": "/work/hermes",+ "origin": "terminal",+ "title": "Repl work",+ "mtime": 1789898410500,+ "transcriptPath": null,+ "readHistory": [+ "user_message",+ "text_delta",+ "done"+ ],+ "aliases": []+ },+ {+ "sessionId": "ses_person",+ "engine": "opencode",+ "cwd": "/work/opencode",+ "origin": "terminal",+ "title": "Fix the build",+ "mtime": 1789898410000,+ "transcriptPath": null,+ "readHistory": [+ "user_message",+ "text_delta",+ "done"+ ]+ },+ {+ "sessionId": "ses_kiloperson",+ "engine": "kilo",+ "cwd": "/work/kilo",+ "origin": "terminal",+ "title": "Fix the build",+ "mtime": 1789898410000,+ "transcriptPath": null,+ "readHistory": [+ "user_message",+ "text_delta",+ "done"+ ]+ },+ {+ "sessionId": "8a5b11e5-5eae-441c-ba9d-903608a9632e",+ "engine": "muse",+ "cwd": "/work/muse",+ "origin": "terminal",+ "title": "",+ "mtime": 1789898405000,+ "transcriptPath": "<root>/home/.muse/sessions/2026/09/20/8a5b11e5-5eae-441c-ba9d-903608a9632e/session.jsonl",+ "readHistory": null+ },+ {+ "sessionId": "019fa2a5-a26d-700c-bf8c-97af19ae3d5f",+ "engine": "pi",+ "cwd": "/work/pi",+ "origin": "terminal",+ "title": "",+ "mtime": 1789898402000,+ "transcriptPath": "<root>/home/.pi/agent/sessions/--work-pi--/2026-09-20T10-00-00-000Z_019fa2a5-a26d-700c-bf8c-97af19ae3d5f.jsonl",+ "readHistory": null+ },+ {+ "sessionId": "34e1385f-c18a-4f54-bf12-f8f57e151a3d",+ "engine": "commandcode",+ "cwd": "/work/commandcode",+ "origin": "terminal",+ "title": "",+ "mtime": 1789898402000,+ "transcriptPath": "<root>/home/.commandcode/projects/work-commandcode/34e1385f-c18a-4f54-bf12-f8f57e151a3d.jsonl",+ "readHistory": null+ },+ {+ "sessionId": "10980e65-1a47-45ff-b666-90b8705efe20",+ "engine": "copilot",+ "cwd": "/work/copilot",+ "origin": "terminal",+ "title": "Greeting reply",+ "mtime": 1789898401000,+ "transcriptPath": "<root>/home/.copilot/session-state/10980e65-1a47-45ff-b666-90b8705efe20/events.jsonl",+ "readHistory": null+ }+ ],+ "aliases": [+ null,+ "20260920_100000_a1b2c3"+ ],+ "scan · Pi moved": [+ {+ "sessionId": "019fa2a6-0000-7000-8000-000000000002",+ "engine": "pi",+ "cwd": "/work/pi-moved",+ "origin": "terminal",+ "title": "",+ "mtime": 1789898403000,+ "transcriptPath": "<root>/home/pi-moved/2026-09-20T10-00-00-000Z_019fa2a6-0000-7000-8000-000000000002.jsonl"+ }+ ],+ "open": [+ [+ "019fa2a5-a26d-700c-bf8c-97af19ae3d5f",+ "maybe"+ ],+ [+ "01a0438c-0e05-73b1-98f9-978079f9e0a5",+ "terminal"+ ],+ [+ "10980e65-1a47-45ff-b666-90b8705efe20",+ "terminal"+ ],+ [+ "20260920_100000_a1b2c3",+ "maybe"+ ],+ [+ "34e1385f-c18a-4f54-bf12-f8f57e151a3d",+ "maybe"+ ],+ [+ "6c3b2a1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d",+ "terminal"+ ],+ [+ "8a5b11e5-5eae-441c-ba9d-903608a9632e",+ "maybe"+ ],+ [+ "ae51057a-0000-4000-8000-000000000001",+ "terminal"+ ],+ [+ "brisk-otter",+ "app"+ ],+ [+ "ses_kiloperson",+ "maybe"+ ],+ [+ "ses_person",+ "harness"+ ],+ [+ "ses_served",+ "app"+ ]+ ],+ "owners": [+ [+ "019fa2a5-a26d-700c-bf8c-97af19ae3d5f",+ {+ "pid": 108,+ "engine": "pi",+ "tty": "/dev/ttys108",+ "record": "<root>/home/.pi/agent/sessions/--work-pi--/2026-09-20T10-00-00-000Z_019fa2a5-a26d-700c-bf8c-97af19ae3d5f.jsonl",+ "fromArgs": true+ },+ true,+ null+ ],+ [+ "01a0438c-0e05-73b1-98f9-978079f9e0a5",+ {+ "pid": 102,+ "engine": "grok",+ "tty": "/dev/ttys102",+ "record": "<root>/home/.grok/sessions/%2Fwork%2Fgrok/01a0438c-0e05-73b1-98f9-978079f9e0a5/updates.jsonl"+ },+ true,+ true+ ],+ [+ "10980e65-1a47-45ff-b666-90b8705efe20",+ {+ "pid": 103,+ "engine": "copilot",+ "tty": "/dev/ttys103",+ "record": "<root>/home/.copilot/session-state/10980e65-1a47-45ff-b666-90b8705efe20/events.jsonl"+ },+ true,+ true+ ],+ [+ "20260920_100000_a1b2c3",+ {+ "pid": 106,+ "engine": "hermes",+ "tty": "/dev/ttys106",+ "record": "<root>/home/.hermes/state.db#20260920_100000_a1b2c3",+ "fromArgs": true+ },+ false,+ null+ ],+ [+ "34e1385f-c18a-4f54-bf12-f8f57e151a3d",+ {+ "pid": 109,+ "engine": "commandcode",+ "tty": "/dev/ttys109",+ "record": "<root>/home/.commandcode/projects/work-commandcode/34e1385f-c18a-4f54-bf12-f8f57e151a3d.jsonl",+ "fromArgs": true+ },+ true,+ null+ ],+ [+ "6c3b2a1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d",+ {+ "pid": 101,+ "engine": "cursor",+ "tty": "/dev/ttys101",+ "record": "<root>/home/.cursor/chats/6796db63ebea901bdfba5b5029cd9bb6/6c3b2a1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d/store.db"+ },+ false,+ false+ ],+ [+ "8a5b11e5-5eae-441c-ba9d-903608a9632e",+ {+ "pid": 110,+ "engine": "muse",+ "tty": "/dev/ttys110",+ "record": "<root>/home/.muse/sessions/2026/09/20/8a5b11e5-5eae-441c-ba9d-903608a9632e/session.jsonl",+ "fromArgs": true+ },+ true,+ null+ ],+ [+ "ae51057a-0000-4000-8000-000000000001",+ {+ "pid": 111,+ "engine": "agy",+ "tty": "/dev/ttys111",+ "record": "<root>/home/.gemini/antigravity-cli/presence/ae51057a-0000-4000-8000-000000000001.lock"+ },+ true,+ null+ ],+ [+ "brisk-otter",+ {+ "pid": 107,+ "engine": "devin",+ "tty": null,+ "record": "<root>/home/.local/share/devin/cli/sessions.db#brisk-otter",+ "fromArgs": true+ },+ false,+ null+ ],+ [+ "ses_kiloperson",+ {+ "pid": 105,+ "engine": "kilo",+ "tty": "/dev/ttys105",+ "record": "<root>/home/.local/share/kilo/kilo.db#ses_kiloperson",+ "fromArgs": true+ },+ false,+ null+ ],+ [+ "ses_person",+ {+ "pid": 104,+ "engine": "opencode",+ "tty": "/dev/ttys104",+ "record": "<root>/home/.local/share/opencode/opencode.db#ses_person",+ "harness": true,+ "fromArgs": true+ },+ false,+ null+ ],+ [+ "ses_served",+ {+ "pid": 112,+ "engine": "opencode",+ "tty": null,+ "record": "<root>/home/.local/share/opencode/opencode.db#ses_served",+ "fromArgs": true+ },+ false,+ null+ ]+ ]+}diff --git a/cli/src/engines/agy/inProcess.ts b/cli/src/engines/agy/inProcess.tsindex d3f9f6458..9357ce3a3 100644--- a/cli/src/engines/agy/inProcess.ts+++ b/cli/src/engines/agy/inProcess.ts@@ -6,3 +6,4 @@export { AgyNormalizer, agyMessagesToEvents, lastAgyTurnText } from './normalizer.js'export { agyPaneIdle, parseAgyFooterProfile } from './runtimeProfile.js'export { agyConversationForPid, findAgyTranscript } from './session.js'+export { agyProvider } from '../../lib/sessionSearch/externals/agy.js'diff --git a/cli/src/engines/commandcode/inProcess.ts b/cli/src/engines/commandcode/inProcess.tsindex f5bd40376..62321914b 100644--- a/cli/src/engines/commandcode/inProcess.ts+++ b/cli/src/engines/commandcode/inProcess.ts@@ -5,3 +5,4 @@*/export { CommandCodeNormalizer, commandCodeRunError, commandCodeRunErrorSummary, commandcodeMessagesToEvents, lastCommandCodeTurnText, windowCommandCodeLines } from './normalizer.js'export { COMMANDCODE_EFFORT_LEVELS, COMMANDCODE_EFFORTS, commandcodeBannerModel, countCommandcodeRefusals, parseCommandcodeModelsOutput } from './runtimeProfile.js'+export { commandcodeProvider } from '../../lib/sessionSearch/externals/commandcode.js'diff --git a/cli/src/engines/copilot/inProcess.ts b/cli/src/engines/copilot/inProcess.tsindex f318ad0bd..4f528b60e 100644--- a/cli/src/engines/copilot/inProcess.ts+++ b/cli/src/engines/copilot/inProcess.ts@@ -5,3 +5,4 @@*/export { CopilotNormalizer, copilotHistoryTurnOpen, copilotMessagesToEvents, lastCopilotTurnText } from './normalizer.js'export { copilotSessionCwd, copilotSessionForPid, findCopilotTranscript } from './session.js'+export { copilotProvider } from '../../lib/sessionSearch/externals/copilot.js'diff --git a/cli/src/engines/cursor/inProcess.ts b/cli/src/engines/cursor/inProcess.tsindex e3da14c97..2296ce9cf 100644--- a/cli/src/engines/cursor/inProcess.ts+++ b/cli/src/engines/cursor/inProcess.ts@@ -9,3 +9,4 @@ export { CursorTaskHookQueue } from './taskHookQueue.js'export { cursorConfigDir, cursorDataDir } from './home.js'export { CursorTranscriptDiscovery, findCursorTranscript } from './discovery.js'export { loadCursorPendingTasks, removeCursorPendingTasks } from './pendingTasks.js'+export { cursorProvider } from '../../lib/sessionSearch/externals/cursor.js'diff --git a/cli/src/engines/devin/inProcess.ts b/cli/src/engines/devin/inProcess.tsindex de7b2cb0d..25dfa52bd 100644--- a/cli/src/engines/devin/inProcess.ts+++ b/cli/src/engines/devin/inProcess.ts@@ -6,3 +6,4 @@export { DevinReader, readDevinMessages } from './reader.js'export { devinMessagesToEvents, lastDevinTurnText, windowDevinMessages } from './normalizer.js'export { DEVIN_EFFORTS, devinFooterModel, devinModelCommandResult, parseDevinModelsOutput } from './runtimeProfile.js'+export { devinProvider } from '../../lib/sessionSearch/externals/devin.js'diff --git a/cli/src/engines/grok/inProcess.ts b/cli/src/engines/grok/inProcess.tsindex 6c7ff9663..fc587dbf0 100644--- a/cli/src/engines/grok/inProcess.ts+++ b/cli/src/engines/grok/inProcess.ts@@ -6,3 +6,4 @@export { GrokNormalizer, grokMessagesToEvents, lastGrokTurnText } from './normalizer.js'export { parseGrokFooterProfile } from './runtimeProfile.js'export { findGrokTranscript } from './session.js'+export { grokProvider } from '../../lib/sessionSearch/externals/grok.js'diff --git a/cli/src/engines/hermes/inProcess.ts b/cli/src/engines/hermes/inProcess.tsindex 7d41312b1..49fd0d392 100644--- a/cli/src/engines/hermes/inProcess.ts+++ b/cli/src/engines/hermes/inProcess.ts@@ -9,3 +9,4 @@ export { HERMES_EFFORTS, hermesStatusModel, parseHermesConfig, parseHermesModels// The half of Hermes's homes that fills the registry's row: Hermes's own lookup, run only for Hermes.export { hermesDbForSession } from '../../lib/hermesHome.js'export { probeHermesHome } from './homeProbe.js'+export { hermesProvider } from '../../lib/sessionSearch/externals/hermes.js'diff --git a/cli/src/engines/kilo/inProcess.ts b/cli/src/engines/kilo/inProcess.tsindex 95320c076..895719893 100644--- a/cli/src/engines/kilo/inProcess.ts+++ b/cli/src/engines/kilo/inProcess.ts@@ -6,3 +6,5 @@export { KiloReader, readKiloMessages } from './reader.js'export { kiloMessagesToEvents, lastKiloTurnText, windowKiloMessages } from './normalizer.js'export { kiloFooterModelId, parseKiloModelsOutput } from './runtimeProfile.js'+// Its adoption reader, which Kilo shares with OpenCode: their stores are one shape.+export { opencodeProvider } from '../../lib/sessionSearch/externals/opencode.js'diff --git a/cli/src/engines/muse/inProcess.ts b/cli/src/engines/muse/inProcess.tsindex 447202fb7..faa11c6e1 100644--- a/cli/src/engines/muse/inProcess.ts+++ b/cli/src/engines/muse/inProcess.ts@@ -6,3 +6,4 @@export { MuseNormalizer, lastMuseTurnText, museMessagesToEvents } from './normalizer.js'export { parseMuseSettings } from './runtimeProfile.js'export { museEvent, museWorkspaceRoot } from './normalizer.js'+export { museProvider } from '../../lib/sessionSearch/externals/muse.js'diff --git a/cli/src/engines/opencode/inProcess.ts b/cli/src/engines/opencode/inProcess.tsindex 6a1c0317c..ed7d61b82 100644--- a/cli/src/engines/opencode/inProcess.ts+++ b/cli/src/engines/opencode/inProcess.ts@@ -9,3 +9,4 @@ export { lastOpencodeTurnText, opencodeMessagesToEvents, windowOpencodeMessagesexport { countOpencodePickers, opencodeFooterModelId, opencodeRowMatches, opencodeRowNamesModel, parseOpencodeFooter, parseOpencodeModelsOutput, parseOpencodePickerRows } from './runtimeProfile.js'export { isOpencodeV2, opencodeMajorVersion } from './version.js'export { applyOpencodeSessionModel, parseOpencodeModelId } from './sessionModel.js'+export { opencodeProvider } from '../../lib/sessionSearch/externals/opencode.js'diff --git a/cli/src/engines/otherAdoption.golden.spec.ts b/cli/src/engines/otherAdoption.golden.spec.tsnew file mode 100644index 000000000..afc72d87c--- /dev/null+++ b/cli/src/engines/otherAdoption.golden.spec.ts@@ -0,0 +1,320 @@+/**+ * What the core's adoption finds of the other engines' conversations, recorded from main before their adoption+ * readers left the core's static imports (docs/design/2026-10-08-other-engines-out-of-core.md, (o5)). Through the+ * core's own entries: the providers `externalProviders` builds from the environment, scanned by `ExternalSessions`+ * (each conversation as the index takes it, and a database engine's history read whole), and asked by+ * `OpenSessions` which process has which open, whether it is mid-turn, and how it is shown.+ *+ * Each engine's store holds conversations in the shapes its own adoption spec builds (externals/<engine>.spec.ts),+ * under a throwaway root named through the environment and pinned whatever the host sets. The process table, open+ * files and terminals are given; the clock, `process.platform` and `TZ` are pinned, file times are set, and no+ * path's length matters. Results name the root `<root>`. `RECORD_OTHER_ENGINES_GOLDEN=1` writes the fixture.+ */+import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, utimesSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { fileURLToPath } from 'node:url'+import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'++const GOLDEN = fileURLToPath(new URL('./__fixtures__/other-adoption.golden.json', import.meta.url))+const RECORD = process.env.RECORD_OTHER_ENGINES_GOLDEN === '1'+const NOW = Date.parse('2026-10-08T12:00:00.000Z')+const T0 = Date.parse('2026-09-20T10:00:00.000Z')+const S0 = T0 / 1000++let root = ''+let golden: Record<string, unknown> = {}+const recorded: Record<string, unknown> = {}+const normalize = (value: unknown): unknown => JSON.parse(JSON.stringify(value ?? null).split(root).join('<root>'))+function check(key: string, value: unknown): void {+ const result = normalize(value)+ recorded[key] = result+ if (!RECORD) expect({ key, result }).toEqual({ key, result: golden[key] })+}++/** A file, written, whose modification time is [seconds] after T0. */+function write(path: string, content: string, seconds = 60): string {+ mkdirSync(join(path, '..'), { recursive: true })+ writeFileSync(path, content)+ utimesSync(path, (T0 + seconds * 1000) / 1000, (T0 + seconds * 1000) / 1000)+ return path+}+const jsonl = (...lines: unknown[]) => `${lines.map((line) => typeof line === 'string' ? line : JSON.stringify(line)).join('\n')}\n`+const iso = (seconds: number) => new Date(T0 + seconds * 1000).toISOString()++const ID = {+ cursor: '6c3b2a1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d', grok: '01a0438c-0e05-73b1-98f9-978079f9e0a5', copilot: '10980e65-1a47-45ff-b666-90b8705efe20',+ opencode: 'ses_person', kilo: 'ses_kiloperson', hermes: '20260920_100000_a1b2c3', hermesAcp: '3f2a9c1e-8b4d-4e6f-9a1b-2c3d4e5f6a7b',+ devin: 'brisk-otter', pi: '019fa2a5-a26d-700c-bf8c-97af19ae3d5f', piMoved: '019fa2a6-0000-7000-8000-000000000002', commandcode: '34e1385f-c18a-4f54-bf12-f8f57e151a3d',+ muse: '8a5b11e5-5eae-441c-ba9d-903608a9632e', agy: 'ae51057a-0000-4000-8000-000000000001',+}++const platform = Object.getOwnPropertyDescriptor(process, 'platform')!+const saved: Record<string, string | undefined> = {}+type Modules = {+ index: typeof import('../lib/sessionSearch/externals/index.js')+ external: typeof import('../lib/sessionSearch/external.js')+}+let m: Modules+const home = (...parts: string[]) => join(root, 'home', ...parts)++/** An OpenCode or Kilo store with one conversation a person started, and its finished turn. */+function opencodeStore(Database: new (path: string, options: { readOnly: boolean }) => { exec(sql: string): void; prepare(sql: string): { all(...args: unknown[]): unknown }; close(): void }, path: string, id: string, cwd: string): void {+ mkdirSync(join(path, '..'), { recursive: true })+ const db = new Database(path, { readOnly: false })+ db.exec(`CREATE TABLE \`project\` (\`id\` text PRIMARY KEY, \`worktree\` text NOT NULL, \`vcs\` text, \`name\` text, \`icon_url\` text,+ \`icon_url_override\` text, \`icon_color\` text, \`time_created\` integer NOT NULL, \`time_updated\` integer NOT NULL,+ \`time_initialized\` integer, \`sandboxes\` text NOT NULL, \`commands\` text);+CREATE TABLE \`message\` (\`id\` text PRIMARY KEY, \`session_id\` text NOT NULL, \`time_created\` integer NOT NULL, \`time_updated\` integer NOT NULL, \`data\` text NOT NULL);+CREATE TABLE \`part\` (\`id\` text PRIMARY KEY, \`message_id\` text NOT NULL, \`session_id\` text NOT NULL, \`time_created\` integer NOT NULL, \`time_updated\` integer NOT NULL, \`data\` text NOT NULL);+CREATE TABLE \`session\` (\`id\` text PRIMARY KEY, \`project_id\` text NOT NULL, \`workspace_id\` text, \`parent_id\` text, \`slug\` text NOT NULL,+ \`directory\` text NOT NULL, \`path\` text, \`title\` text NOT NULL, \`version\` text NOT NULL, \`share_url\` text,+ \`summary_additions\` integer, \`summary_deletions\` integer, \`summary_files\` integer, \`summary_diffs\` text,+ \`metadata\` text, \`cost\` real DEFAULT 0 NOT NULL, \`tokens_input\` integer DEFAULT 0 NOT NULL,+ \`tokens_output\` integer DEFAULT 0 NOT NULL, \`tokens_reasoning\` integer DEFAULT 0 NOT NULL,+ \`tokens_cache_read\` integer DEFAULT 0 NOT NULL, \`tokens_cache_write\` integer DEFAULT 0 NOT NULL, \`revert\` text,+ \`permission\` text, \`agent\` text, \`model\` text, \`time_created\` integer NOT NULL, \`time_updated\` integer NOT NULL,+ \`time_compacting\` integer, \`time_archived\` integer);`)+ db.prepare("INSERT INTO project (id, worktree, time_created, time_updated, sandboxes) VALUES ('p', '/', 0, 0, '[]')").all()+ const session = (sessionId: string, title: string, parent: string | null, updated: number) => db.prepare(+ 'INSERT INTO session (id, project_id, parent_id, slug, directory, title, version, permission, time_created, time_updated, time_archived)'+ + " VALUES (?, 'p', ?, 'slug', ?, ?, '1.18.31', NULL, ?, ?, NULL)",+ ).all(sessionId, parent, cwd, title, T0, updated)+ let seq = 0+ const message = (sessionId: string, data: Record<string, unknown>, at: number, parts: Array<Record<string, unknown>>) => {+ const messageId = `msg_${String(++seq).padStart(4, '0')}`+ db.prepare('INSERT INTO message (id, session_id, time_created, time_updated, data) VALUES (?, ?, ?, ?, ?)').all(messageId, sessionId, at, at, JSON.stringify(data))+ parts.forEach((part, index) => db.prepare('INSERT INTO part (id, message_id, session_id, time_created, time_updated, data) VALUES (?, ?, ?, ?, ?, ?)')+ .all(`prt_${messageId}_${index}`, messageId, sessionId, at + index, at + index, JSON.stringify(part)))+ }+ session(id, 'Fix the build', null, T0 + 10_000)+ message(id, { role: 'user', time: { created: T0 + 5_000 } }, T0 + 5_000, [{ type: 'text', text: 'please fix the build' }])+ message(id, { role: 'assistant', time: { created: T0 + 6_000, completed: T0 + 7_000 }, finish: 'stop' }, T0 + 6_000, [{ type: 'text', text: 'Done.' }, { type: 'step-finish', reason: 'stop' }])+ // A sub-agent's session, which is never offered.+ session(`${id}child`, 'A child', id, T0 + 11_000)+ db.close()+}++beforeAll(async () => {+ root = realpathSync(mkdtempSync(join(tmpdir(), 'other-adoption-golden-')))+ Object.defineProperty(process, 'platform', { ...platform, value: 'linux' })+ vi.useFakeTimers({ toFake: ['Date'], now: NOW })+ const env: Record<string, string | undefined> = {+ HOME: home(), ADAPTER_DATA_DIR: join(root, 'data'), ADAPTER_RUNTIME_DIR: join(root, 'runtime'), TZ: 'UTC',+ CLAUDE_PROJECTS_DIR: home('.claude', 'projects'), CODEX_HOME: home('.codex'), CLAUDE_CONFIG_DIR: undefined,+ CURSOR_HOME: home('.cursor'), CURSOR_CONFIG_DIR: undefined, CURSOR_DATA_DIR: home('.cursor-data'), XDG_CONFIG_HOME: undefined, XDG_DATA_HOME: undefined,+ GROK_HOME: home('.grok'), COPILOT_HOME: home('.copilot'), OPENCODE_DATA_DIR: home('.local', 'share', 'opencode'), OPENCODE_DB: undefined,+ KILO_DATA_DIR: home('.local', 'share', 'kilo'), KILO_DB: undefined, HERMES_HOME: home('.hermes'), DEVIN_HOME: home('.local', 'share', 'devin', 'cli'),+ PI_HOME: home('.pi'), PI_CODING_AGENT_DIR: undefined, PI_CODING_AGENT_SESSION_DIR: undefined, COMMANDCODE_HOME: home('.commandcode'),+ MUSE_HOME: home('.muse'), AGY_HOME: home('.gemini', 'antigravity-cli'),+ }+ for (const [name, value] of Object.entries(env)) {+ saved[name] = process.env[name]+ if (value === undefined) delete process.env[name]; else process.env[name] = value+ }+ for (const dir of ['data', 'runtime', join('home', '.claude', 'projects'), join('home', '.codex')]) mkdirSync(join(root, dir), { recursive: true })+ const { DatabaseSync } = (process as unknown as { getBuiltinModule(name: string): unknown }).getBuiltinModule('node:sqlite') as {+ DatabaseSync: new (path: string, options?: { readOnly: boolean }) => { exec(sql: string): void; prepare(sql: string): { all(...args: unknown[]): unknown }; close(): void }+ }++ // Cursor: a chat with its metadata in its config folder, and its transcript in its data folder, a folder of its own.+ const { createHash } = await import('node:crypto')+ const chat = home('.cursor', 'chats', createHash('md5').update('/work/cursor').digest('hex'), ID.cursor)+ write(join(chat, 'store.db'), '')+ write(join(chat, 'meta.json'), JSON.stringify({ schemaVersion: 1, createdAtMs: T0, hasConversation: true, title: ' Fix the build ', updatedAtMs: T0 + 100_000, cwd: '/work/cursor' }))+ write(home('.cursor-data', 'projects', 'work-cursor', 'agent-transcripts', ID.cursor, `${ID.cursor}.jsonl`), jsonl(+ { role: 'user', message: { content: [{ type: 'text', text: '<user_query>hi</user_query>' }] } },+ { role: 'assistant', message: { content: [{ type: 'text', text: 'hello' }] } },+ { type: 'turn_ended', status: 'success' },+ ))+ // Grok: a session's summary, context and updates, and the list of sessions open now.+ const grokLine = (kind: string, seconds: number, extra: Record<string, unknown>) => ({+ timestamp: S0 + seconds, method: 'session/update',+ params: { sessionId: ID.grok, update: { sessionUpdate: kind, ...extra }, _meta: { eventId: 'e', agentTimestampMs: T0 + seconds * 1000 } },+ })+ const grokDir = home('.grok', 'sessions', encodeURIComponent('/work/grok'), ID.grok)+ write(join(grokDir, 'summary.json'), JSON.stringify({ info: { id: ID.grok, cwd: '/work/grok' }, generated_title: ' Fix the build ', last_active_at: iso(200) }))+ write(join(grokDir, 'prompt_context.json'), JSON.stringify({ audience: 'primary', is_non_interactive: false, working_directory: '/work/grok' }))+ write(join(grokDir, 'updates.jsonl'), jsonl(+ grokLine('user_message_chunk', 100, { content: { type: 'text', text: 'hello' } }),+ grokLine('agent_message_chunk', 150, { content: { type: 'text', text: 'hi' } }),+ ))+ write(home('.grok', 'active_sessions.json'), JSON.stringify([{ session_id: ID.grok, pid: 102, cwd: '/work/grok', opened_at: iso(90) }]))+ // Copilot: a session's events and workspace, and the lock its process holds.+ const copilotEvent = (type: string, data: Record<string, unknown>, seconds: number) => ({ type, data, id: 'e', timestamp: iso(seconds), parentId: null })+ const copilotDir = home('.copilot', 'session-state', ID.copilot)+ write(join(copilotDir, 'events.jsonl'), jsonl(+ copilotEvent('session.start', { sessionId: ID.copilot, version: 1, producer: 'copilot-agent', context: { cwd: '/work/copilot' } }, 0),+ copilotEvent('user.message', { content: 'hello' }, 1),+ copilotEvent('assistant.turn_start', { turnId: '1' }, 2),+ ))+ write(join(copilotDir, 'workspace.yaml'), `id: ${ID.copilot}\ncwd: /work/copilot\nclient_name: cli\nname: Greeting reply\nuser_named: false\nsummary_count: 0\n`)+ write(join(copilotDir, 'inuse.103.lock'), '')+ // OpenCode and Kilo: their stores.+ opencodeStore(DatabaseSync, home('.local', 'share', 'opencode', 'opencode.db'), ID.opencode, '/work/opencode')+ opencodeStore(DatabaseSync, home('.local', 'share', 'kilo', 'kilo.db'), ID.kilo, '/work/kilo')+ // Hermes: a CLI session with a finished turn, an editor's, and a delegated one never offered.+ {+ mkdirSync(home('.hermes'), { recursive: true })+ const db = new DatabaseSync(home('.hermes', 'state.db'), { readOnly: false })+ db.exec(`CREATE TABLE sessions (id TEXT PRIMARY KEY, source TEXT NOT NULL, user_id TEXT, session_key TEXT, chat_id TEXT,+ chat_type TEXT, thread_id TEXT, model TEXT, model_config TEXT, system_prompt TEXT, parent_session_id TEXT,+ started_at REAL NOT NULL, ended_at REAL, end_reason TEXT, message_count INTEGER DEFAULT 0,+ tool_call_count INTEGER DEFAULT 0, input_tokens INTEGER DEFAULT 0, output_tokens INTEGER DEFAULT 0,+ cache_read_tokens INTEGER DEFAULT 0, cache_write_tokens INTEGER DEFAULT 0, reasoning_tokens INTEGER DEFAULT 0,+ cwd TEXT, git_branch TEXT, git_repo_root TEXT, billing_provider TEXT, billing_base_url TEXT, billing_mode TEXT,+ estimated_cost_usd REAL, actual_cost_usd REAL, cost_status TEXT, cost_source TEXT, pricing_version TEXT, title TEXT,+ api_call_count INTEGER DEFAULT 0, handoff_state TEXT, handoff_platform TEXT, handoff_error TEXT,+ compression_failure_cooldown_until REAL, compression_failure_error TEXT, rewind_count INTEGER NOT NULL DEFAULT 0,+ archived INTEGER NOT NULL DEFAULT 0, "display_name" TEXT, "origin_json" TEXT, "expiry_finalized" INTEGER DEFAULT 0,+ "compression_fallback_streak" INTEGER NOT NULL DEFAULT 0, "profile_name" TEXT);+CREATE TABLE messages (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL REFERENCES sessions(id),+ role TEXT NOT NULL, content TEXT, tool_call_id TEXT, tool_calls TEXT, tool_name TEXT, timestamp REAL NOT NULL,+ token_count INTEGER, finish_reason TEXT, reasoning TEXT, reasoning_content TEXT, reasoning_details TEXT,+ codex_reasoning_items TEXT, codex_message_items TEXT, platform_message_id TEXT, observed INTEGER DEFAULT 0,+ active INTEGER NOT NULL DEFAULT 1, compacted INTEGER NOT NULL DEFAULT 0, "effect_disposition" TEXT, "api_content" TEXT);+CREATE TABLE compression_locks (session_id TEXT PRIMARY KEY, holder TEXT NOT NULL, acquired_at REAL NOT NULL, expires_at REAL NOT NULL);`)+ const session = (sessionId: string, source: string, parent: string | null, title: string | null) => db.prepare(+ 'INSERT INTO sessions (id, source, model_config, parent_session_id, started_at, ended_at, end_reason, cwd, git_repo_root, title, archived)'+ + ' VALUES (?, ?, NULL, ?, ?, NULL, NULL, ?, NULL, ?, 0)').all(sessionId, source, parent, S0, '/work/hermes', title)+ const message = (sessionId: string, role: string, at: number, finish: string | null) => db.prepare(+ 'INSERT INTO messages (session_id, role, content, finish_reason, timestamp) VALUES (?, ?, ?, ?, ?)').all(sessionId, role, role === 'user' ? 'please look at the tests' : 'ok', finish, at)+ session(ID.hermes, 'cli', null, 'Repl work')+ message(ID.hermes, 'user', S0 + 10, null)+ message(ID.hermes, 'assistant', S0 + 10.5, 'stop')+ session(ID.hermesAcp, 'acp', null, null)+ message(ID.hermesAcp, 'user', S0 + 20, null)+ session('20260920_100100_d4e5f6', 'subagent', ID.hermes, null)+ message('20260920_100100_d4e5f6', 'user', S0 + 30, null)+ db.close()+ }+ // Devin: its store, a session with a turn.+ {+ const devinHome = home('.local', 'share', 'devin', 'cli')+ mkdirSync(devinHome, { recursive: true })+ const db = new DatabaseSync(join(devinHome, 'sessions.db'), { readOnly: false })+ db.exec(`CREATE TABLE sessions (+ id TEXT PRIMARY KEY, working_directory TEXT NOT NULL, backend_type TEXT NOT NULL, model TEXT NOT NULL,+ agent_mode TEXT NOT NULL, created_at INTEGER NOT NULL, last_activity_at INTEGER NOT NULL, title TEXT,+ main_chain_id INTEGER, hidden INTEGER NOT NULL DEFAULT 0, workspace_dirs TEXT, metadata TEXT);+CREATE TABLE message_nodes (+ row_id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, node_id INTEGER NOT NULL, parent_node_id INTEGER,+ chat_message TEXT NOT NULL, created_at INTEGER NOT NULL, metadata TEXT, UNIQUE(session_id, node_id));+CREATE TABLE tool_call_state (session_id TEXT, tool_call_id TEXT, tool_call_json TEXT, tool_call_update_json TEXT);+CREATE TABLE subagent_heads (session_id TEXT, agent_id TEXT, chain_node_id INTEGER);`)+ db.prepare('INSERT INTO sessions (id, working_directory, backend_type, model, agent_mode, created_at, last_activity_at, title, hidden)'+ + " VALUES (?, '/work/devin', 'cloud', 'swe-1', 'normal', ?, ?, 'Fix the tests', 0)").all(ID.devin, S0, S0 + 50)+ const node = (n: number, message: Record<string, unknown>) => db.prepare('INSERT INTO message_nodes (session_id, node_id, chat_message, created_at) VALUES (?, ?, ?, ?)')+ .all(ID.devin, n, JSON.stringify(message), S0 + n)+ node(1, { role: 'user', content: [{ type: 'text', text: 'fix the tests' }] })+ node(2, { role: 'assistant', content: [{ type: 'text', text: 'Fixed.' }], stop_reason: 'end_turn' })+ db.close()+ }+ // Pi: a session file in its folder for the cwd.+ const piHeader = { type: 'session', version: 3, id: ID.pi, timestamp: iso(0), cwd: '/work/pi' }+ const piMessage = (role: string, seconds: number) => ({ type: 'message', id: `m${seconds}`, parentId: null, timestamp: iso(seconds), message: { role, content: [{ type: 'text', text: 'words' }] } })+ write(home('.pi', 'agent', 'sessions', '--work-pi--', `2026-09-20T10-00-00-000Z_${ID.pi}.jsonl`), jsonl(piHeader, piMessage('user', 1), piMessage('assistant', 2)))+ // …and one in a sessions folder the person moved (`PI_CODING_AGENT_SESSION_DIR`), which Pi keeps flat.+ write(home('pi-moved', `2026-09-20T10-00-00-000Z_${ID.piMoved}.jsonl`), jsonl({ ...piHeader, id: ID.piMoved, cwd: '/work/pi-moved' }, piMessage('user', 3)))+ // Command Code: a v3 transcript in its project folder.+ const ccMessage = (role: string, seconds: number) => ({ type: 'message', id: `m${seconds}`, parentId: null, timestamp: iso(seconds), message: { role, content: [{ type: 'text', text: 'words' }], meta: { source: role === 'user' ? 'user' : 'model' } } })+ write(home('.commandcode', 'projects', 'work-commandcode', `${ID.commandcode}.jsonl`), jsonl(+ { type: 'session', version: 3, id: ID.commandcode, timestamp: iso(0), cwd: '/work/commandcode' }, ccMessage('user', 1), ccMessage('assistant', 2),+ ))+ // Muse: a log whose run started and finished.+ let sequence = 0+ const museRecord = (seconds: number, payload: Record<string, unknown>) => JSON.stringify({+ schema_version: 1, id: `r-${++sequence}`, stream: { kind: 'session', id: ID.muse }, sequence, recorded_at: (T0 + seconds * 1000) * 1000,+ record_type: 'event', durability: 'durable', causation_id: null, payload_type: 'runtime.session', payload_schema_version: 1, payload,+ })+ write(home('.muse', 'sessions', '2026', '09', '20', ID.muse, 'session.jsonl'), jsonl(+ museRecord(0, { kind: 'metadata', record: { workspace_root: '/work/muse', provider_id: 'meta', build: { sha: 'x', semver: '0.1.0' } } }),+ museRecord(1, { kind: 'run', run_id: 'run-1', event: { kind: 'started', prompt: 'hi' } }),+ museRecord(5, { kind: 'run', run_id: 'run-1', event: { kind: 'completed' } }),+ ))+ // agy: a conversation's transcript, its presence lock, and where it was asked from.+ write(home('.gemini', 'antigravity-cli', 'brain', ID.agy, '.system_generated', 'logs', 'transcript_full.jsonl'), jsonl(+ { step_index: 0, source: 'USER_EXPLICIT', type: 'USER_INPUT', status: 'DONE', created_at: iso(0), content: 'words' },+ { step_index: 1, source: 'USER_EXPLICIT', type: 'PLANNER_RESPONSE', status: 'DONE', created_at: iso(1), content: 'words' },+ ))+ write(home('.gemini', 'antigravity-cli', 'presence', `${ID.agy}.lock`), '')+ write(home('.gemini', 'antigravity-cli', 'history.jsonl'), jsonl({ display: 'first', timestamp: T0, workspace: '/work/agy', conversationId: ID.agy }))++ vi.resetModules()+ m = {+ index: await import('../lib/sessionSearch/externals/index.js'),+ external: await import('../lib/sessionSearch/external.js'),+ }+ golden = RECORD ? {} : JSON.parse(readFileSync(GOLDEN, 'utf8')) as Record<string, unknown>+})++afterAll(() => {+ vi.useRealTimers()+ Object.defineProperty(process, 'platform', platform)+ for (const [name, value] of Object.entries(saved)) if (value === undefined) delete process.env[name]; else process.env[name] = value+ if (root) rmSync(root, { recursive: true, force: true })+ if (RECORD) writeFileSync(GOLDEN, JSON.stringify(recorded, null, 1) + '\n')+})++describe('what the core\'s adoption finds of the other engines\' conversations', () => {+ it('lists each engine\'s conversations, and reads a database engine\'s history whole', async () => {+ const providers = m.index.externalProviders(m.index.externalPaths(process.env))+ check('providers', providers.map((provider) => [provider.engine, typeof provider.owners, typeof provider.busy]))+ const sessions = new m.external.ExternalSessions({ providers, excluded: [join(root, 'data')], log: () => {} })+ const found = await sessions.scan()+ const listed: unknown[] = []+ for (const session of found) {+ const history = session.readHistory ? await session.readHistory() : null+ listed.push({ ...session, readHistory: history && history.map((event) => event.type) })+ }+ check('scan', listed.filter((session) => !['claude', 'codex'].includes((session as { engine: string }).engine)))+ check('aliases', ['20260920_100100_d4e5f6', ID.hermes].map((id) => sessions.get(id)?.sessionId ?? null))+ // Pi's sessions in the folder the person moved them to, where its environment says.+ const moved = m.index.externalProviders(m.index.externalPaths({ ...process.env, PI_CODING_AGENT_SESSION_DIR: home('pi-moved') }))+ const movedSessions = await new m.external.ExternalSessions({ providers: moved, excluded: [join(root, 'data')], log: () => {} }).scan()+ check('scan · Pi moved', movedSessions.filter((session) => session.engine === 'pi'))+ }, 60_000)++ it('says which process has which conversation open, whether it is mid-turn, and how it is shown', async () => {+ const providers = m.index.externalProviders(m.index.externalPaths(process.env))+ const row = (pid: number, executable: string, args = executable) => ({ pid, ppid: 1, executable, args })+ const rows = [+ row(101, 'cursor-agent', `cursor-agent --resume ${ID.cursor}`), row(102, 'grok'), row(103, 'copilot'),+ row(104, 'opencode', `opencode --session ${ID.opencode}`), row(105, 'kilo', `kilo -s ${ID.kilo}`),+ row(106, 'python3', `python3 /opt/hermes-agent/hermes --resume ${ID.hermes}`), row(107, 'devin', `devin -r ${ID.devin}`),+ row(108, 'pi', `pi --session ${ID.pi}`), row(109, 'cmd', `cmd --resume ${ID.commandcode}`),+ row(110, 'muse-bin-1.2.3', `muse-bin-1.2.3 resume ${ID.muse}`), row(111, 'agy'),+ row(112, 'opencode', 'opencode serve --session ses_served'),+ ]+ const files = new Map<number, string[]>([+ [101, [join(home('.cursor', 'chats'), (await import('node:crypto')).createHash('md5').update('/work/cursor').digest('hex'), ID.cursor, 'store.db')]],+ [111, [home('.gemini', 'antigravity-cli', 'presence', `${ID.agy}.lock`)]],+ ])+ const view = {+ list: async () => rows,+ openFiles: async (pids: readonly number[]) => new Map(pids.flatMap((pid) => files.has(pid) ? [[pid, files.get(pid)!] as [number, string[]]] : [])),+ openFilesOf: async () => new Map<number, string[]>(),+ alive: () => true,+ }+ const scanned = new m.external.ExternalSessions({ providers, excluded: [join(root, 'data')], log: () => {} })+ await scanned.scan()+ const open = new m.external.OpenSessions({+ providers, view: () => view, now: () => NOW, log: () => {},+ ttys: async (pids) => new Map(pids.map((pid) => [pid, pid === 107 ? null : `/dev/ttys${String(pid).padStart(3, '0')}`])),+ harnessTtys: async () => new Set(['/dev/ttys104']),+ })+ const shown = [...(await open.fresh())].sort(([a], [b]) => a.localeCompare(b))+ const owners: unknown[] = []+ for (const [sessionId] of shown) {+ const owner = await open.owner(sessionId)+ owners.push([sessionId, owner, owner ? await open.busy(owner) : null, await open.working(sessionId)])+ }+ check('open', shown)+ check('owners', owners)+ }, 60_000)++ it('has a recorded outcome for every case, and no other', () => {+ if (RECORD) return+ expect(Object.keys(recorded).sort()).toEqual(Object.keys(golden).sort())+ })+})diff --git a/cli/src/engines/pi/inProcess.ts b/cli/src/engines/pi/inProcess.tsindex 9717ac333..945641d32 100644--- a/cli/src/engines/pi/inProcess.ts+++ b/cli/src/engines/pi/inProcess.ts@@ -5,4 +5,4 @@*/export { PiNormalizer, lastPiTurnText, piMessagesToEvents, windowPiLines } from './normalizer.js'export { PI_EFFORTS, PI_THINKING_LEVELS, parsePiFooterProfile, parsePiModelsOutput, parsePiThinkingSelection, piThinkingSteps } from './runtimeProfile.js'-export { piSessionFolder, readPiHead } from '../../lib/sessionSearch/externals/pi.js'+export { piProvider, piSessionFolder, readPiHead } from '../../lib/sessionSearch/externals/pi.js'diff --git a/cli/src/leanEntry.spec.ts b/cli/src/leanEntry.spec.tsindex ce38d355a..570eea5ae 100644--- a/cli/src/leanEntry.spec.ts+++ b/cli/src/leanEntry.spec.ts@@ -91,8 +91,8 @@ describe('the lean bundle a release carries', () => {// Each a string its module alone holds: lib/questionPane.ts's, lib/hooks.ts's (its Amp plugin's), Amp's thread// export's (engines/amp/threadExport.ts), and the name the bundle keeps for Cursor's sub-agents' reader// (engines/cursor/subagent.ts), Devin's switch reader (engines/devin/runtimeProfile.ts), agy's lock reader- // (engines/agy/session.ts) and Cursor's discovery (engines/cursor/discovery.ts), which the core's own files only- // call.+ // (engines/agy/session.ts), Cursor's discovery (engines/cursor/discovery.ts) and Hermes's adoption reader+ // (lib/sessionSearch/externals/hermes.ts), which the core's own files only call.['pane readers', 'Native screen reader must be injected'],['hook installers', 'Mirrors this Amp thread to the machine adapter'],['own code: Amp\'s', 'AMP_DISABLE_PLUGINS'],@@ -100,6 +100,7 @@ describe('the lean bundle a release carries', () => {['runtime profiles: Devin\'s', '"devinModelCommandResult"'],['identity: agy\'s', '"agyConversationForPid"'],['identity: Cursor\'s discovery', '"CursorTranscriptDiscovery"'],+ ['adoption: Hermes\'s reader', '"hermesProvider"'],])('leaves the other engines\' %s out of the core until it needs them', (_, marker) => {// engines/inProcess.ts imports them (docs/design/2026-10-08-other-engines-out-of-core.md): a file of the// core's own, which Node reads only then.diff --git a/cli/src/lib/sessionSearch/externals/index.spec.ts b/cli/src/lib/sessionSearch/externals/index.spec.tsindex e15bd6fff..045858cc0 100644--- a/cli/src/lib/sessionSearch/externals/index.spec.ts+++ b/cli/src/lib/sessionSearch/externals/index.spec.ts@@ -1,10 +1,18 @@import { join } from 'node:path'-import { describe, expect, it } from 'vitest'+import { describe, expect, it, vi } from 'vitest'import { env } from '../../../config/env.js'+import { loadEngine } from '../../../engines/inProcess.js'+import { scanMemo } from './support.js'import { externalPaths, externalProviders } from './index.js'-import { EXTERNAL_ENGINES } from './types.js'+import { EXTERNAL_ENGINES, type ProcessView } from './types.js'++// The other engines' readers are their own code, loaded on first use; a test may say one could not be.+vi.mock('../../../engines/inProcess.js', async (real) => {+ const actual = await real<typeof import('../../../engines/inProcess.js')>()+ return { ...actual, loadEngine: vi.fn(actual.loadEngine) }+})describe('where each engine keeps its conversations', () => {it("follows each engine's own overrides before Harness's defaults", () => {@@ -43,3 +51,45 @@ describe('where each engine keeps its conversations', () => {expect(externalProviders().length).toBe(EXTERNAL_ENGINES.length)})})++describe('the other engines\' readers, loaded on first use', () => {+ const none: ProcessView = { list: async () => [], openFiles: async () => new Map(), openFilesOf: async () => new Map(), alive: () => true }+ const missing = '/nonexistent/adoption-root'+ const paths = () => externalPaths({ CURSOR_CONFIG_DIR: missing, CURSOR_DATA_DIR: missing, OPENCODE_DB: `${missing}/opencode.db`, KILO_DB: `${missing}/kilo.db`, PI_CODING_AGENT_DIR: missing })++ it('loads nothing until a scan or a question needs a reader, and each engine\'s own code once', async () => {+ vi.mocked(loadEngine).mockClear()+ const providers = externalProviders(paths())+ expect(loadEngine).not.toHaveBeenCalled()+ const cursor = providers.find((provider) => provider.engine === 'cursor')!+ await cursor.scan(scanMemo({ excluded: [] }).context())+ await cursor.owners!(none)+ await cursor.busy!({ pid: 1, record: '' })+ expect(vi.mocked(loadEngine).mock.calls).toEqual([['cursor']])+ // Kilo's reader is OpenCode's, loaded with Kilo's code; Claude Code's and Codex's are declared, and load nothing.+ vi.mocked(loadEngine).mockClear()+ for (const engine of ['kilo', 'claude', 'codex']) await providers.find((provider) => provider.engine === engine)!.owners!(none)+ expect(vi.mocked(loadEngine).mock.calls).toEqual([['kilo']])+ })++ it('lists nothing and holds nothing open for an engine whose code could not be loaded', async () => {+ vi.mocked(loadEngine).mockResolvedValueOnce(null)+ const devin = externalProviders(paths()).find((provider) => provider.engine === 'devin')!+ expect(await devin.scan(scanMemo({ excluded: [] }).context())).toEqual([])+ expect(await devin.owners!(none)).toEqual([])+ expect(await devin.busy!({ pid: 1, record: '' })).toBeNull()+ })++ it('treats a reader that could not be built as that engine unavailable, said once, never as a failed scan', async () => {+ const error = vi.spyOn(console, 'error').mockImplementation(() => {})+ const devinProvider = vi.fn(() => { throw new Error('bad store path') })+ vi.mocked(loadEngine).mockResolvedValueOnce({ devinProvider } as never)+ const devin = externalProviders(paths()).find((provider) => provider.engine === 'devin')!+ for (let scan = 0; scan < 2; scan++) expect(await devin.scan(scanMemo({ excluded: [] }).context())).toEqual([])+ expect(await devin.owners!(none)).toEqual([])+ expect(await devin.busy!({ pid: 1, record: '' })).toBeNull()+ expect(devinProvider).toHaveBeenCalledOnce()+ expect(error.mock.calls).toEqual([['[engine devin] adoption reader unavailable · bad store path']])+ error.mockRestore()+ })+})diff --git a/cli/src/lib/sessionSearch/externals/index.ts b/cli/src/lib/sessionSearch/externals/index.tsindex d16cfd955..90af325ca 100644--- a/cli/src/lib/sessionSearch/externals/index.ts+++ b/cli/src/lib/sessionSearch/externals/index.ts@@ -1,25 +1,20 @@/*** Every engine's discovery, pointed at where that engine keeps its conversations on this machine.* Each path follows the engine's own rules (its env overrides first), not Harness's defaults alone.+ *+ * Claude Code's and Codex's are declared and built here. The other engines' readers are their own code, loaded in+ * this process on the first scan or question that needs them (engines/inProcess.ts;+ * docs/design/2026-10-08-other-engines-out-of-core.md, (o5)).*/import { isAbsolute, join } from 'node:path'-import { cursorConfigDir, cursorDataDir } from '../../../engines/cursor/home.js'+import { cursorConfigDir, cursorDataDir } from '../../../engines/cursor/contract.js'import { env } from '../../../config/env.js'import { adoptionProviderOf } from '../../../engines/adoptions.js'+import { loadEngine, type InProcessModules, type OtherEngine } from '../../../engines/inProcess.js'import { claudeProjectsRoots, codexHomeRoots } from '../../engineHomes.js'-import { agyProvider } from './agy.js'-import { commandcodeProvider } from './commandcode.js'-import { copilotProvider } from './copilot.js'-import { cursorProvider } from './cursor.js'-import { devinProvider } from './devin.js'-import { grokProvider } from './grok.js'-import { hermesProvider } from './hermes.js'-import { museProvider } from './muse.js'-import { opencodeProvider } from './opencode.js'-import { piProvider } from './pi.js'-import type { ExternalProvider } from './types.js'+import type { ExternalEngine, ExternalProvider } from './types.js'export interface ExternalPaths {claudeProjectsDir: string@@ -69,6 +64,33 @@ export function externalPaths(vars: NodeJS.ProcessEnv = process.env): ExternalPa}}+/**+ * An engine's reader, built from its own code the first time a scan or a question needs it, then kept: what it+ * remembers between scans (the files it read, which session is where) stays its own. An engine whose code could not+ * be loaded, or whose reader could not be built from it, lists nothing and holds nothing open, as an engine with no+ * store does. Either failure is logged once (the loader logs the first), and never tried again: a rejection kept+ * for good would fail every scan of that engine instead.+ */+function loaded<Name extends OtherEngine>(engine: ExternalEngine, name: Name, build: (code: InProcessModules[Name]) => ExternalProvider): ExternalProvider {+ let provider: Promise<ExternalProvider | null> | null = null+ const reader = (): Promise<ExternalProvider | null> => provider ??= loadEngine(name).then((code) => {+ if (!code) return null+ try {+ return build(code)+ } catch (error) {+ console.error(`[engine ${name}] adoption reader unavailable · ${error instanceof Error ? error.message : error}`)+ return null+ }+ })+ return {+ engine,+ scan: async (ctx) => await (await reader())?.scan(ctx) ?? [],+ owners: async (view) => await (await reader())?.owners?.(view) ?? [],+ // No answer reads as none, as for an engine whose store cannot say (external.ts `OpenSessions.busy`).+ busy: async (owner) => await (await reader())?.busy?.(owner) ?? null,+ }+}+/** One provider per engine that keeps its conversations on this machine's disk. */export function externalProviders(paths: ExternalPaths = externalPaths()): ExternalProvider[] {return [@@ -78,16 +100,16 @@ export function externalProviders(paths: ExternalPaths = externalPaths()): Exter// folder, its process records beside each; Codex's from each home.adoptionProviderOf('claude', { roots: () => claudeProjectsRoots(paths.claudeProjectsDir) }),adoptionProviderOf('codex', { roots: () => codexHomeRoots(paths.codexHome) }),- cursorProvider({ configDir: paths.cursorConfigDir, dataDir: paths.cursorDataDir }),- grokProvider({ home: paths.grokHome }),- copilotProvider({ home: paths.copilotHome }),- opencodeProvider({ engine: 'opencode', dbPath: paths.opencodeDb }),- opencodeProvider({ engine: 'kilo', dbPath: paths.kiloDb }),- hermesProvider({ root: paths.hermesRoot }),- devinProvider({ home: paths.devinHome }),- piProvider({ agentDir: paths.piAgentDir, ...(paths.piSessionDir ? { sessionDir: paths.piSessionDir } : {}) }),- commandcodeProvider({ home: paths.commandcodeHome }),- museProvider({ home: paths.museHome }),- agyProvider({ home: paths.agyHome }),+ loaded('cursor', 'cursor', (code) => code.cursorProvider({ configDir: paths.cursorConfigDir, dataDir: paths.cursorDataDir })),+ loaded('grok', 'grok', (code) => code.grokProvider({ home: paths.grokHome })),+ loaded('copilot', 'copilot', (code) => code.copilotProvider({ home: paths.copilotHome })),+ loaded('opencode', 'opencode', (code) => code.opencodeProvider({ engine: 'opencode', dbPath: paths.opencodeDb })),+ loaded('kilo', 'kilo', (code) => code.opencodeProvider({ engine: 'kilo', dbPath: paths.kiloDb })),+ loaded('hermes', 'hermes', (code) => code.hermesProvider({ root: paths.hermesRoot })),+ loaded('devin', 'devin', (code) => code.devinProvider({ home: paths.devinHome })),+ loaded('pi', 'pi', (code) => code.piProvider({ agentDir: paths.piAgentDir, ...(paths.piSessionDir ? { sessionDir: paths.piSessionDir } : {}) })),+ loaded('commandcode', 'commandcode', (code) => code.commandcodeProvider({ home: paths.commandcodeHome })),+ loaded('muse', 'muse', (code) => code.museProvider({ home: paths.museHome })),+ loaded('agy', 'agy', (code) => code.agyProvider({ home: paths.agyHome })),]}