mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-14 09:11:54 +00:00
* fix(desktop): honor default project directory for new sessions The Settings picker persisted project-dir.json but the renderer kept seeding new chats from sticky localStorage home. Prefer the configured default on boot and session.create, pin TERMINAL_CWD at backend spawn, and reject packaged install-dir paths that regressed after #37536. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(desktop): address review on default project dir PR Add workspace cwd precedence tests, extract isPackagedInstallPath for platform test coverage, and stop rewriting live $currentCwd when a session is already active (cache-only until the next new chat). Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
748 B
JavaScript
38 lines
748 B
JavaScript
const path = require('node:path')
|
|
|
|
/** True when `dir` lives inside a packaged app bundle / install tree. */
|
|
function isPackagedInstallPath(dir, { installRoots, isPackaged }) {
|
|
if (!isPackaged || !dir) {
|
|
return false
|
|
}
|
|
|
|
let resolved
|
|
|
|
try {
|
|
resolved = path.resolve(String(dir))
|
|
} catch {
|
|
return false
|
|
}
|
|
|
|
const roots = new Set(
|
|
(installRoots ?? [])
|
|
.filter(Boolean)
|
|
.map(candidate => path.resolve(String(candidate)))
|
|
)
|
|
|
|
for (const root of roots) {
|
|
if (resolved === root) {
|
|
return true
|
|
}
|
|
|
|
const rel = path.relative(root, resolved)
|
|
|
|
if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
module.exports = { isPackagedInstallPath }
|