Add local agent profile and supporting local agents CLI including codex, claude code, pi, opencode, cursor etc#55
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds markdown-based subagent profile discovery, a SQLite-backed local agent session store, provider adapters and availability checks, ChangesLocal Agent Profiles and CLI
Estimated code review effort: 4 (Complex) | ~75 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as devspace CLI
participant Store as LocalAgentStore
participant Worker as Agent worker
participant Runtime as CodexSdkLocalAgentRuntime
participant Profiles as LocalAgentProfiles
User->>CLI: devspace agents run <profile-or-id> "<prompt>"
CLI->>Profiles: load matching profile
CLI->>Store: create/update session record
CLI->>Worker: spawn detached __worker process
Worker->>Profiles: read profile markdown
Worker->>Runtime: run(prompt, workspace, providerSessionId?)
Runtime-->>Worker: finalResponse + providerSessionId
Worker->>Store: persist status and latestResponse
User->>CLI: devspace agents show <id>
CLI->>Store: poll session record
Store-->>CLI: status / response / error
CLI-->>User: print result
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review it |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/local-agent-profiles.ts (1)
101-173: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the hand-rolled frontmatter parser with a YAML library.
parseSimpleYamlonly handles flat scalars plus one nested map, and it misreads valid YAML like quoted values containing#. A parser such asyamlwould remove these edge cases as profile frontmatter grows.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/local-agent-profiles.ts` around lines 101 - 173, The hand-rolled frontmatter parsing in parseFrontmatter and parseSimpleYaml is too limited and misparses valid YAML edge cases. Replace the custom parsing logic with a real YAML parser (for example, yaml) when reading the frontmatter block, and keep the existing frontmatter/body splitting in parseFrontmatter. Make sure the returned ParsedFrontmatter shape still matches current callers, and remove parseSimpleYaml/parseScalar if they are no longer needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli.ts`:
- Around line 365-370: The reused agent path in the existing-record branch keeps
the previous run’s latestResponse, so the new run can be mistaken for complete
in runAgentsShow. Update the existing store.update call in the existing/
spawnAgentWorker flow to clear latestResponse along with status and error before
restarting, and make sure runAgentsShow only prints latestResponse when it
belongs to the current run state.
In `@src/local-agent-profiles.ts`:
- Around line 77-99: The profile loading flow in
loadProfilesFromDirectory/loadProfileFile is brittle because one malformed .md
can abort the entire agent catalog and workspace creation. Update
loadProfilesFromDirectory to handle errors per entry by wrapping each await
loadProfileFile(filePath) call in its own try/catch, logging or skipping invalid
files while continuing to process the rest. Keep the failure isolated inside
loadProfileFile or its caller so loadLocalAgentProfiles can still return the
valid LocalAgentProfile entries and open_workspace is not blocked by a single
bad profile.
In `@src/local-agent-store.ts`:
- Around line 94-105: The shared store update path in LocalAgentStore.write() is
vulnerable to lost concurrent writes because read() and the atomic rename happen
without any locking. Protect the entire read-modify-write sequence with an
OS-level file lock (or equivalent) around LocalAgentStore.read() and
LocalAgentStore.write(), so concurrent devspace agents run processes cannot
overwrite each other’s changes; keep the fix centered on the LocalAgentStore
class methods that access this file.
In `@src/workspaces.test.ts`:
- Around line 20-35: The workspaces test fixture is still picking up real agent
profiles from the user’s home directory because `loadLocalAgentProfiles()` also
scans `config.devspaceAgentsDir`. Update the test setup in
`src/workspaces.test.ts` to isolate the environment by pinning the global agents
directory or overriding HOME before calling `loadLocalAgentProfiles()`, and keep
the fixture limited to the local `.devspace/agents` files used by the test.
Apply the same isolation to the related assertions in the other affected test
cases so the deep-equal expectations only see the mocked profiles.
---
Nitpick comments:
In `@src/local-agent-profiles.ts`:
- Around line 101-173: The hand-rolled frontmatter parsing in parseFrontmatter
and parseSimpleYaml is too limited and misparses valid YAML edge cases. Replace
the custom parsing logic with a real YAML parser (for example, yaml) when
reading the frontmatter block, and keep the existing frontmatter/body splitting
in parseFrontmatter. Make sure the returned ParsedFrontmatter shape still
matches current callers, and remove parseSimpleYaml/parseScalar if they are no
longer needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e67a7aec-7d41-4390-ab11-7ccc751616df
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (30)
.agents/plan/local-agent-profiles-and-cli-plan.mddocs/agent-profile-schema.mddocs/chatgpt-coding-workflow.mddocs/configuration.mddocs/gotchas.mdexamples/agents/claude-implementer.mdexamples/agents/codex-explorer.mdexamples/agents/codex-worker.mdexamples/agents/copilot-reviewer.mdexamples/agents/cursor-agent-worker.mdexamples/agents/opencode-explorer.mdexamples/agents/pi-reviewer.mdpackage.jsonskills/local-agent-delegation/SKILL.mdsrc/cli.test.tssrc/cli.tssrc/config.test.tssrc/config.tssrc/local-agent-profiles.test.tssrc/local-agent-profiles.tssrc/local-agent-runtime.test.tssrc/local-agent-runtime.tssrc/local-agent-store.test.tssrc/local-agent-store.tssrc/process-sessions.test.tssrc/process-sessions.tssrc/server.tssrc/user-config.tssrc/workspaces.test.tssrc/workspaces.ts
|
Also addressed the frontmatter parser nit in 80ee468 by replacing the hand-rolled YAML subset parser with the |
|
@coderabbitai review the latest commits since the last time you reviewed it |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/local-agent-adapters.test.ts (1)
202-220: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDeduplicate the PATH sanitization helper
src/local-agent-adapters.tsandsrc/local-agent-availability.tsboth implement the samenode_modules/.binfiltering, with slightly different helper logic. Extract it into a shared helper to keep the two paths aligned.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/local-agent-adapters.test.ts` around lines 202 - 220, The PATH sanitization logic is duplicated between piCommandEnvironment and the availability code, with separate helper implementations that can drift. Extract the shared node_modules/.bin filtering into one reusable helper and have both src/local-agent-adapters.ts and src/local-agent-availability.ts call it so the PATH behavior stays identical. Keep the existing piCommandEnvironment behavior and update the related tests in src/local-agent-adapters.test.ts to validate the shared helper’s output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/local-agent-adapters.ts`:
- Around line 304-386: The unguarded JSON parsing in JsonLineRpc.handleStdout
can crash the worker if the pi subprocess emits a non-JSON stdout line. Wrap the
JSON.parse(line) path in a try/catch, treat malformed lines as stderr/debug
output or surface them as a controlled failure, and ensure failAll is used so
pending requests are rejected cleanly instead of letting the 'data' listener
throw. Keep the fix localized to JsonLineRpc.handleStdout and its error handling
around request/event dispatch.
- Around line 55-93: In ClaudeLocalAgentAdapter.run, treat only successful
result messages as final output and reject error result subtypes using the
fields on the message record such as is_error and subtype. Also, before
returning, pass the accumulated finalResponse through requireFinalResponse(...)
so an empty or missing Claude result throws instead of succeeding silently. Keep
the fix localized to ClaudeLocalAgentAdapter.run and preserve
providerSessionId/item collection behavior.
In `@src/local-agent-availability.ts`:
- Around line 101-115: The resolveCommand helper is still invoking a shell on
non-Windows, which allows metacharacters in the command value to be interpreted;
update resolveCommand to avoid shell interpolation by using a shell-free lookup
or a safe sh -c pattern that passes the command as an argument rather than
inline, and make sure the same timeout handling remains in this path. Focus on
the resolveCommand function and its spawnSync call so the command resolution
logic stays equivalent without exposing shell execution.
---
Nitpick comments:
In `@src/local-agent-adapters.test.ts`:
- Around line 202-220: The PATH sanitization logic is duplicated between
piCommandEnvironment and the availability code, with separate helper
implementations that can drift. Extract the shared node_modules/.bin filtering
into one reusable helper and have both src/local-agent-adapters.ts and
src/local-agent-availability.ts call it so the PATH behavior stays identical.
Keep the existing piCommandEnvironment behavior and update the related tests in
src/local-agent-adapters.test.ts to validate the shared helper’s output.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e1e37a7f-1eaf-490a-9a38-f766eccc0aca
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (38)
.agents/plan/local-agent-profiles-and-cli-plan.mddocs/agent-profile-schema.mddocs/chatgpt-coding-workflow.mddocs/configuration.mddocs/gotchas.mdexamples/agents/claude-implementer.mdexamples/agents/codex-explorer.mdexamples/agents/codex-worker.mdexamples/agents/copilot-reviewer.mdexamples/agents/cursor-agent-worker.mdexamples/agents/opencode-explorer.mdexamples/agents/pi-reviewer.mdpackage.jsonskills/subagent-delegation/SKILL.mdsrc/cli.test.tssrc/cli.tssrc/config.test.tssrc/config.tssrc/db/migrations.tssrc/db/schema.tssrc/local-agent-adapters.test.tssrc/local-agent-adapters.tssrc/local-agent-availability.test.tssrc/local-agent-availability.tssrc/local-agent-profiles.test.tssrc/local-agent-profiles.tssrc/local-agent-runtime.test.tssrc/local-agent-runtime.tssrc/local-agent-store.test.tssrc/local-agent-store.tssrc/local-agent-targets.test.tssrc/local-agent-targets.tssrc/oauth-store.test.tssrc/server.tssrc/skills.test.tssrc/skills.tssrc/user-config.tssrc/workspaces.test.ts
💤 Files with no reviewable changes (9)
- examples/agents/cursor-agent-worker.md
- examples/agents/opencode-explorer.md
- examples/agents/claude-implementer.md
- examples/agents/copilot-reviewer.md
- examples/agents/codex-worker.md
- examples/agents/pi-reviewer.md
- src/local-agent-runtime.ts
- examples/agents/codex-explorer.md
- src/local-agent-runtime.test.ts
✅ Files skipped from review due to trivial changes (3)
- docs/gotchas.md
- .agents/plan/local-agent-profiles-and-cli-plan.md
- docs/chatgpt-coding-workflow.md
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
|
Also addressed the PATH sanitization nitpick in f50f02a. Pi runtime and Pi availability now both call the shared removeDevspaceNodeModulesBinFromPath helper in src/local-agent-path.ts, and src/local-agent-adapters.test.ts asserts the shared helper output along with piCommandEnvironment behavior. Validation run after these fixes:
|
Summary
Testing
Stacked on #50.
Summary by CodeRabbit
devspace agentsworkflow to list, run, and show agent sessions.DEVSPACE_WORKSPACE_IDandDEVSPACE_WORKSPACE_ROOT).