Skip to content

Add local agent profile and supporting local agents CLI including codex, claude code, pi, opencode, cursor etc#55

Merged
Waishnav merged 33 commits into
codex/local-agent-examplesfrom
codex/local-agent-profiles-cli
Jul 5, 2026
Merged

Add local agent profile and supporting local agents CLI including codex, claude code, pi, opencode, cursor etc#55
Waishnav merged 33 commits into
codex/local-agent-examplesfrom
codex/local-agent-profiles-cli

Conversation

@Waishnav

@Waishnav Waishnav commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • load user/project local agent profiles and expose a compact catalog from open_workspace
  • add minimal devspace agents ls/run/show workflow with workspace-scoped agent state
  • wire Codex SDK execution plus CLI fallback profiles
  • update local-agent skill, examples, and docs around the minimal workflow

Testing

  • npm run typecheck
  • npm test

Stacked on #50.

Summary by CodeRabbit

  • New Features
    • Added a local agent profile system and a new devspace agents workflow to list, run, and show agent sessions.
    • Workspaces now surface available agent profiles/providers in the workspace view.
    • Added workspace-scoped environment context to command runs (including DEVSPACE_WORKSPACE_ID and DEVSPACE_WORKSPACE_ROOT).
  • Bug Fixes
    • Improved local agent profile discovery, filtering (including disabled profiles), and session tracking/status display.
  • Documentation
    • Updated the subagent profile format, discovery locations, and agent delegation workflow; refreshed starter agent templates accordingly.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aae780a3-dda6-4af9-aa23-a48fd6c114e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds markdown-based subagent profile discovery, a SQLite-backed local agent session store, provider adapters and availability checks, devspace agents commands, workspace/server catalog exposure, and updated docs, skills, and example profiles around the new subagent flow.

Changes

Local Agent Profiles and CLI

Layer / File(s) Summary
Planning document
.agents/plan/local-agent-profiles-and-cli-plan.md
Adds the subagent profile and CLI design note covering discovery, schema, compact catalog exposure, and non-goals.
Config and delegation skill switch
src/user-config.ts, src/config.ts, src/skills.ts, src/skills.test.ts, skills/subagent-delegation/SKILL.md, skills/local-agent-delegation/SKILL.md, src/config.test.ts, src/workspaces.test.ts
Replaces the local-agent flag/skill wiring with subagent equivalents, adds the agents-directory helper, and updates skill loading tests and workspace profile fixtures.
Profiles, store, runtime, and adapters
src/local-agent-profiles.ts, src/local-agent-profiles.test.ts, src/local-agent-store.ts, src/local-agent-store.test.ts, src/local-agent-runtime.ts, src/local-agent-runtime.test.ts, src/local-agent-adapters.ts, src/local-agent-adapters.test.ts, src/local-agent-availability.ts, src/local-agent-availability.test.ts, src/local-agent-targets.ts, src/local-agent-targets.test.ts, package.json
Adds markdown profile loading, SQLite session storage, Codex runtime execution, provider adapters, provider availability checks, target parsing, and the matching tests plus SDK dependency/script updates.
CLI, process sessions, workspace, and server
src/cli.ts, src/cli.test.ts, src/process-sessions.ts, src/process-sessions.test.ts, src/workspaces.ts, src/server.ts, src/db/schema.ts, src/db/migrations.ts, src/oauth-store.test.ts
Adds the devspace agents CLI flow, workspace-root process scoping, workspace profile loading, server-side catalog exposure, and the local-agent session schema/migration.
Example agent profiles and delegation skill
examples/agents/*.md, skills/subagent-delegation/SKILL.md, skills/local-agent-delegation/SKILL.md
Rewrites example agent profiles to the new minimal profile format and replaces the delegation skill content with the subagent workflow.
Documentation updates
docs/agent-profile-schema.md, docs/chatgpt-coding-workflow.md, docs/configuration.md, docs/gotchas.md
Updates the docs to describe subagent profile discovery, compact open_workspace metadata, and the revised devspace agents workflow.

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
Loading

Poem

A rabbit tapped the markdown door,
And subagents hopped out to explore.
The CLI said run, the store said stay,
The workspace whispered root today.
With profiles, prompts, and hops so light,
The burrow glows with agents bright. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding local agent profiles and a new agents CLI workflow with multiple providers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/local-agent-profiles-cli

Comment @coderabbitai help to get the list of available commands.

@Waishnav

Waishnav commented Jul 2, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review it

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

@Waishnav Sure, I'll review the changes in this PR now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/local-agent-profiles.ts (1)

101-173: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the hand-rolled frontmatter parser with a YAML library.
parseSimpleYaml only handles flat scalars plus one nested map, and it misreads valid YAML like quoted values containing #. A parser such as yaml would 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c43606 and 4650806.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (30)
  • .agents/plan/local-agent-profiles-and-cli-plan.md
  • docs/agent-profile-schema.md
  • docs/chatgpt-coding-workflow.md
  • docs/configuration.md
  • docs/gotchas.md
  • examples/agents/claude-implementer.md
  • examples/agents/codex-explorer.md
  • examples/agents/codex-worker.md
  • examples/agents/copilot-reviewer.md
  • examples/agents/cursor-agent-worker.md
  • examples/agents/opencode-explorer.md
  • examples/agents/pi-reviewer.md
  • package.json
  • skills/local-agent-delegation/SKILL.md
  • src/cli.test.ts
  • src/cli.ts
  • src/config.test.ts
  • src/config.ts
  • src/local-agent-profiles.test.ts
  • src/local-agent-profiles.ts
  • src/local-agent-runtime.test.ts
  • src/local-agent-runtime.ts
  • src/local-agent-store.test.ts
  • src/local-agent-store.ts
  • src/process-sessions.test.ts
  • src/process-sessions.ts
  • src/server.ts
  • src/user-config.ts
  • src/workspaces.test.ts
  • src/workspaces.ts

Comment thread src/cli.ts
Comment thread src/local-agent-profiles.ts
Comment thread src/local-agent-store.ts Outdated
Comment thread src/workspaces.test.ts
@Waishnav Waishnav changed the title Add local agent profile catalog and CLI Add local agent profile and supporting local agents CLI including codex, claude code, pi, opencode, cursor etc Jul 4, 2026
@Waishnav

Waishnav commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Also addressed the frontmatter parser nit in 80ee468 by replacing the hand-rolled YAML subset parser with the yaml package. The profile test now covers a quoted # value so descriptions like "Reviewer #1" are preserved correctly.

@Waishnav

Waishnav commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review the latest commits since the last time you reviewed it

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

@Waishnav Sure, I'll review the latest commits since the last review, including the frontmatter parser change in 80ee468.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/local-agent-adapters.test.ts (1)

202-220: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Deduplicate the PATH sanitization helper

src/local-agent-adapters.ts and src/local-agent-availability.ts both implement the same node_modules/.bin filtering, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4650806 and 7197629.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (38)
  • .agents/plan/local-agent-profiles-and-cli-plan.md
  • docs/agent-profile-schema.md
  • docs/chatgpt-coding-workflow.md
  • docs/configuration.md
  • docs/gotchas.md
  • examples/agents/claude-implementer.md
  • examples/agents/codex-explorer.md
  • examples/agents/codex-worker.md
  • examples/agents/copilot-reviewer.md
  • examples/agents/cursor-agent-worker.md
  • examples/agents/opencode-explorer.md
  • examples/agents/pi-reviewer.md
  • package.json
  • skills/subagent-delegation/SKILL.md
  • src/cli.test.ts
  • src/cli.ts
  • src/config.test.ts
  • src/config.ts
  • src/db/migrations.ts
  • src/db/schema.ts
  • src/local-agent-adapters.test.ts
  • src/local-agent-adapters.ts
  • src/local-agent-availability.test.ts
  • src/local-agent-availability.ts
  • src/local-agent-profiles.test.ts
  • src/local-agent-profiles.ts
  • src/local-agent-runtime.test.ts
  • src/local-agent-runtime.ts
  • src/local-agent-store.test.ts
  • src/local-agent-store.ts
  • src/local-agent-targets.test.ts
  • src/local-agent-targets.ts
  • src/oauth-store.test.ts
  • src/server.ts
  • src/skills.test.ts
  • src/skills.ts
  • src/user-config.ts
  • src/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

Comment thread src/local-agent-adapters.ts
Comment thread src/local-agent-adapters.ts
Comment thread src/local-agent-availability.ts
@Waishnav

Waishnav commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

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:

  • npx tsx src/local-agent-adapters.test.ts
  • npx tsx src/local-agent-availability.test.ts
  • npm run typecheck
  • npm test

@Waishnav Waishnav merged commit eaddcb1 into codex/local-agent-examples Jul 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant