fix(cli): anchor engine cwd and rewrite bundled config with absolute paths#892
fix(cli): anchor engine cwd and rewrite bundled config with absolute paths#892rohitg00 wants to merge 1 commit into
Conversation
…paths The bundled iii-config.yaml uses cwd-relative paths and the engine was spawned without a cwd, so on global and npx installs ./data/state_store.db and ./data/stream_store landed in whatever directory the user ran the CLI from, and the iii-exec supervision block (src/**/*.ts watch, node dist/index.mjs exec) never resolved, meaning the engine never supervised a worker and nothing respawned it after the in-process worker died. That surfaced as all data gone reports against a live REST port. startIiiBin now prepares the launch: when the resolved config is the bundled one it writes ~/.agentmemory/iii-config.runtime.yaml (regenerated each boot) with absolute data paths under ~/.agentmemory/data and an absolute node exec line for the installed worker entry, copies any legacy ./data stores from the invocation directory on first run, and spawns the engine with cwd anchored at ~/.agentmemory. Repo checkouts keep the cwd config and repo-root cwd, so dev behavior is unchanged. User overrides via env or ~/.agentmemory/iii-config.yaml are passed through verbatim. agentmemory remove gains a plan item for the generated runtime config. Covered by test/engine-launch.test.ts including a drift guard that rewrites the repo's real iii-config.yaml and asserts no relative paths remain.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR resolves native engine supervision by preparing a runtime launch directory and rewriting bundled ChangesEngine launch directory and config management
Sequence DiagramsequenceDiagram
participant CLI
participant prepareEngineLaunch
participant resolveEngineCwd
participant rewriteBundledConfig
participant legacyDataMigrations
participant spawnEngineBackground
CLI->>prepareEngineLaunch: prepareEngineLaunch(configPath)
prepareEngineLaunch->>resolveEngineCwd: resolve engine working directory
alt is bundled config
prepareEngineLaunch->>rewriteBundledConfig: rewrite to absolute paths
prepareEngineLaunch->>legacyDataMigrations: enumerate data migrations
prepareEngineLaunch->>prepareEngineLaunch: copy legacy data from→to
end
prepareEngineLaunch->>prepareEngineLaunch: write runtime config
prepareEngineLaunch-->>CLI: return {configPath, cwd}
CLI->>spawnEngineBackground: spawn engine with cwd
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #844, closes #700, closes #303.
The bundled iii-config.yaml uses cwd-relative paths and the engine was spawned without a cwd. On global and npx installs, ./data stores landed in whatever directory the user ran the CLI from, and the iii-exec supervision block (src watch, node dist/index.mjs exec) never resolved, so the engine never supervised a worker and nothing respawned it after the in-process worker died. That is the mechanism behind the data-loss-on-restart reports against a live REST port.
startIiiBin now writes ~/.agentmemory/iii-config.runtime.yaml (regenerated each boot) with absolute data paths and an absolute worker exec line whenever the bundled config is in play, copies legacy ./data stores from the invocation directory on first run, and spawns the engine with cwd anchored at ~/.agentmemory. Repo checkouts keep the cwd config and repo-root cwd, so dev behavior is unchanged. User overrides via AGENTMEMORY_III_CONFIG or ~/.agentmemory/iii-config.yaml pass through verbatim. agentmemory remove gains a plan item for the generated file.
Tested by test/engine-launch.test.ts including a drift guard that rewrites the repo's real iii-config.yaml and asserts no relative paths remain.
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests