Skip to content

feat: implement spawn route#115

Open
2witstudios wants to merge 3 commits intomainfrom
ppg/issue-70-spawn-route
Open

feat: implement spawn route#115
2witstudios wants to merge 3 commits intomainfrom
ppg/issue-70-spawn-route

Conversation

@2witstudios
Copy link
Owner

Summary

  • Add POST /api/spawn Fastify route plugin for creating worktrees and launching agents
  • JSON Schema validation: name (required, non-empty), agent type, prompt/template (one required), base branch, count (1-20 integer), template vars
  • Template variable rendering with {{VAR}} substitution (WORKTREE_PATH, BRANCH, AGENT_ID, PROJECT_ROOT, TASK_NAME, PROMPT, plus user vars)
  • Returns 201 with worktree ID, name, branch, and agent details (IDs, tmux targets, session IDs)

Test plan

  • 17 tests with mocked core modules covering:
    • Successful spawn with prompt and template
    • Multi-agent spawn (count > 1)
    • Template variable substitution
    • Agent type resolution
    • Base branch override and default
    • Schema validation (missing name, empty name, count bounds, non-integer count)
    • Manifest updates and env setup
    • tmux session creation

Closes #70

Add POST /api/spawn endpoint as a Fastify plugin that creates worktrees
and launches agents. Includes JSON Schema validation for request body
(name required, agent type, prompt/template, base branch, count 1-20,
template vars), template variable rendering, and full test coverage
with mocked core modules.

Closes #70
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@2witstudios has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 34deb69 and 13f3a47.

📒 Files selected for processing (5)
  • src/commands/spawn.test.ts
  • src/commands/spawn.ts
  • src/core/spawn.ts
  • src/server/routes/spawn.test.ts
  • src/server/routes/spawn.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ppg/issue-70-spawn-route

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.

❤️ Share

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

Address code review findings:

- Extract spawnNewWorktree and spawnAgentBatch into core/spawn.ts,
  eliminating duplicated orchestration between CLI command and route
- Route accepts projectRoot via plugin options instead of calling
  getRepoRoot() per-request
- Add validateVars() to reject shell metacharacters in var keys/values
  before they reach tmux send-keys
- Add error-path tests: unknown agent type, template not found, tmux
  not available, prompt/template precedence
- Fix pre-existing typecheck error in commands/spawn.test.ts
- Route is now a thin adapter: validate, call core, format response
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.

Implement spawn route

1 participant