mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
v1.4.260 moved mobile/src/worktree/agent-row-display.ts under agent-lineage/ and was the first release to keep native chats in SQLite behind worker threads. - Archive both phone row reader locations as optional paths and resolve moved modules under mobile/src through releaseModuleLocation(). - Bundle each SQL-backed release's own journal worker/reader entries and mock its worker-bundle fixture to point at them; read those releases' chats with their own readTestJournalSnapshot instead of journal.snapshot().
79 lines
2.6 KiB
TypeScript
79 lines
2.6 KiB
TypeScript
import { existsSync, readdirSync } from 'node:fs'
|
|
import { join, posix } from 'node:path'
|
|
|
|
export type ReleaseTree = {
|
|
exists: (rootRelativePath: string) => boolean
|
|
/** Root-relative forward-slash paths of every file under `directory`. */
|
|
list: (directory: string) => readonly string[]
|
|
}
|
|
|
|
const listings = new Map<string, readonly string[]>()
|
|
|
|
function checkoutTree(root: string): ReleaseTree {
|
|
return {
|
|
exists: (path) => existsSync(join(root, path)),
|
|
list: (directory) => {
|
|
const key = join(root, directory)
|
|
let files = listings.get(key)
|
|
if (!files) {
|
|
files = existsSync(key)
|
|
? readdirSync(key, { recursive: true, encoding: 'utf8' }).map((entry) =>
|
|
posix.join(directory, entry.split('\\').join('/'))
|
|
)
|
|
: []
|
|
listings.set(key, files)
|
|
}
|
|
return files
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Where the release under `root` defines the module a suite names. Suites name main's path; a
|
|
* release cut before a folder move ships the module elsewhere under the same source root (`src/*`
|
|
* or `mobile/src`), so the one file there with its name is that module. Missing or ambiguous names
|
|
* pass through and fail at import, naming the path the suite asked for.
|
|
*/
|
|
export function releaseModuleLocation(
|
|
root: string,
|
|
rootRelativePath: string,
|
|
tree: ReleaseTree = checkoutTree(root)
|
|
): string {
|
|
const named = rootRelativePath
|
|
.replace(/^[/\\]+/, '')
|
|
.split('\\')
|
|
.join('/')
|
|
const sourceRoot = named.split('/').slice(0, 2).join('/')
|
|
if (tree.exists(named) || !(sourceRoot.startsWith('src/') || sourceRoot === 'mobile/src')) {
|
|
return named
|
|
}
|
|
if (named === 'src/main/runtime/rpc/responses/rpc-response.ts') {
|
|
const legacyResponse = posix.join(posix.dirname(named), '..', 'errors.ts')
|
|
if (tree.exists(legacyResponse)) {
|
|
return legacyResponse
|
|
}
|
|
}
|
|
if (named === 'src/main/runtime/rpc/methods/rpc-method-registry.ts') {
|
|
const legacyRegistry = 'src/main/runtime/rpc/methods/index.ts'
|
|
if (tree.exists(legacyRegistry)) {
|
|
return legacyRegistry
|
|
}
|
|
}
|
|
const name = posix.basename(named)
|
|
const moved = tree.list(sourceRoot).filter((path) => posix.basename(path) === name)
|
|
if (moved.length === 1) {
|
|
return moved[0]!
|
|
}
|
|
if (
|
|
moved.length === 0 &&
|
|
named ===
|
|
'src/renderer/src/runtime/hosted-terminals/streams/registry/remote-runtime-terminal-multiplexer-registry.ts'
|
|
) {
|
|
const legacyRegistry = 'src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts'
|
|
if (tree.exists(legacyRegistry)) {
|
|
return legacyRegistry
|
|
}
|
|
}
|
|
return named
|
|
}
|