fix(ego-browser): probe the installed skill location for the agent workspace - #223
fix(ego-browser): probe the installed skill location for the agent workspace#223Hotragn wants to merge 1 commit into
Conversation
|
Freshness check, since this has been open a while and the tree has moved elsewhere: the defect is still present on the active line.
So unlike #224/#251/#252 — whose files the rearchitecture removes — this one applies unchanged to whichever branch you take it on. It is still green and conflict-free against (The |
|
Rebased onto the active line and re-verified. A v2-ready branch is pushed: https://github.com/Hotragn/ego-lite/tree/beta/agent-workspace (branched from I could not open a PR for it — |
Summary
In the app-bundled CLI the agent-workspace fallback resolves to a path that does not exist (from a root cwd, literally
/skills/ego-browser), so the entire site-learnings subsystem is unreachable even though the learning packs ship with the app and are present on disk. This PR keeps the existing resolution precedence and adds one narrow step: when neither module-relative candidate exists on disk, probe the user-level location onboarding registers, accepting it only when it actually holdslearnings/.Related issue
Fixes the runtime-side root cause reported in #215. Note the reporter self-closed that issue (before this PR opened) after finding the in-process
process.env.EGO_BROWSER_AGENT_WORKSPACE = ...workaround — the resolution defect itself is still present ondev, and this PR makes the workaround unnecessary for the CLI half. The app-side half (caller env not forwarded into the embedded runtime) remains out of this repo's reach.Changes
src/env.ts—agentWorkspace()keeps the current precedence (env override → skill bundled next to the build output → repo layout). New behavior only starts where the old chain returned a nonexistent path: when neither module-relative candidate exists, it probes~/.local/share/ego/ego-skills(the location onboarding links, per the report in [Bug]: Site learnings unreachable — agent workspace falls back to /skills/ego-browser (filesystem root) in the bundled CLI #215) both as the skill directory itself and as a parent ofego-browser/. A candidate is accepted only when it holdslearnings/, so a stale leftover directory cannot claim the workspace. When nothing exists anywhere, the returned value is byte-identical to today's (the repo-layout path).HOME/USERPROFILEdirectly rather than throughresolvePath("~..."), deliberately: the~-expansion defect inresolvePathis already being fixed by fix(ego-browser): expand ~ paths to the home directory instead of the filesystem root #146 and fix(ego-browser): make the repo build, test, and commit on Windows #148, and this PR must not collide with either.agentWorkspace()gains an injectable{ env, exists }seam (defaulting toprocess.env/existsSync) so the bundled-runtime layout is testable without touching the real filesystem — same injectable-seam pattern asupdate-notice.ts. All call sites are unchanged (agentWorkspace()).src/env.test.mjs— 8 regression tests covering the full decision table: override precedence, bundled candidate, repo-layout candidate, installed-root fallback,ego-browser/subdirectory priority, rejection of an installed directory withoutlearnings/,USERPROFILEresolution, and the nothing-exists default.Note: prettier normalized two pre-existing unformatted blocks in
env.ts(resolvePath,loadEnvFile) because the changed-file style gate checks whole files. Same situation #148 documented.Verification
Run from
package/ego-browser(Windows 11, Node 24; suite is platform-neutral):The new tests fail without the fix: reverting the
src/env.tschange makes "falls back to the installed skill registered by onboarding", "prefers an ego-browser subdirectory inside the install root", and "resolves the home directory from USERPROFILE" fail (the old chain returns the repo-layout path).I don't have a macOS install to run the shipped app against; the repro and paths come from the detailed report in #215. Behavior for repo checkouts is covered by the tests and unchanged.
Impact
Behavior change is strictly additive: the fallback only fires where the previous result was a nonexistent directory, so
learnContext()/runSiteTool/runSiteBrowserToolstart working in the app-bundled CLI withoutEGO_BROWSER_AGENT_WORKSPACE. Repo checkouts, the env override, and the SDK path resolve exactly as before. Composes cleanly with #146/#148 (different functions in the same file; no shared hunks beyond formatting).Checklist
devfor normal changes; onlydevmay targetmain).fix).