Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

FEAT-85: Add GENERATE_PRD command to desktop loop handler - #35

Merged
shafty023 merged 4 commits into
mainfrom
FEAT-85
Mar 20, 2026
Merged

shafty023 merged 4 commits into
mainfrom
FEAT-85

Conversation

@shafty023

Copy link
Copy Markdown
Contributor
  • Add GENERATE_PRD to LoopCommand, VALID_COMMANDS, and LocalJobCommand
  • Create writeArtifactsForGeneratePrd to write context pack files (prompt.md, repo-info.json, artifacts/) under worktreeDir/.claude/context/
  • Create readGeneratePrdOutputs to read prd.md from worktree root and return { prd: { content } } matching generatePrdUploadSchema
  • Add dedicated worktree branch namespace (symphony/generate-prd-) with always-fresh creation to avoid collisions with PLAN/EXECUTE
  • Add prompt validation (400 for missing/empty/non-string prompt)
  • Spawn claude with write-capable tools and cwd: worktreeDir
  • Add cleanupGeneratePrdWorktree helper for worktree removal on both success and failure paths, including pre-spawn early returns
  • Add 7 integration tests covering rejection, context pack layout, upload shape, no-output path, and worktree cleanup

Testing: TypeScript compiles clean, 7/7 new tests pass, 5/5 SSRF regression tests pass

Risks: None identified -- new command path only, existing commands untouched

- Add GENERATE_PRD to LoopCommand, VALID_COMMANDS, and LocalJobCommand
- Create writeArtifactsForGeneratePrd to write context pack files
  (prompt.md, repo-info.json, artifacts/) under worktreeDir/.claude/context/
- Create readGeneratePrdOutputs to read prd.md from worktree root and
  return { prd: { content } } matching generatePrdUploadSchema
- Add dedicated worktree branch namespace (symphony/generate-prd-<key>)
  with always-fresh creation to avoid collisions with PLAN/EXECUTE
- Add prompt validation (400 for missing/empty/non-string prompt)
- Spawn claude with write-capable tools and cwd: worktreeDir
- Add cleanupGeneratePrdWorktree helper for worktree removal on both
  success and failure paths, including pre-spawn early returns
- Add 7 integration tests covering rejection, context pack layout,
  upload shape, no-output path, and worktree cleanup

Testing: TypeScript compiles clean, 7/7 new tests pass, 5/5 SSRF
regression tests pass

Risks: None identified -- new command path only, existing commands
untouched
* Mirrors writeContextPackFiles in harness-agent.mjs (lines 744-816).
* Files go under worktreeDir/.claude/context/ (NOT claudeWorkDir).
*/
async function writeArtifactsForGeneratePrd(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Something like this got refactored in #30

good to synchronize on the correct one-true-way to do this.

@thadeusb thadeusb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one nit about two prs adding very similar funcs

Comment thread apps/desktop/src/server/operations/symphony-loop.ts Outdated
Comment thread apps/desktop/test/symphony-loop-generate-prd.test.ts Outdated
Comment thread apps/desktop/src/server/operations/symphony-loop.ts
Comment thread apps/desktop/src/server/operations/symphony-loop.ts
@closedloop-ai-stage

Copy link
Copy Markdown

Code Review Summary

Status: Needs Attention

Reviewers: Bug Hunter A, Bug Hunter B, Unified Auditor, Premise Reviewer, Gateway Core Architect

Findings

Severity Count
Blocking 0
High 1
Medium 4

HIGH Issues (should fix)

  1. [P1] [apps/desktop/src/main/job-store.ts:10] Missing version bump in apps/desktop/package.json - CI will fail

MEDIUM Issues (consider)

  1. [P2] [apps/desktop/src/server/operations/symphony-loop.ts:1150] Inline stale-worktree removal duplicates cleanupGeneratePrdWorktree
  2. [P2] [apps/desktop/test/symphony-loop-generate-prd.test.ts:674] waitForRequest resolves on started event - cleanup window starts too early (potential flakiness)
  3. [P2] [apps/desktop/src/server/operations/symphony-loop.ts:1179] GENERATE_PRD worktree not cleaned up when assertPathAllowed rejects the path
  4. [P2] [apps/desktop/src/server/operations/symphony-loop.ts:1146] Stale-worktree removal in GENERATE_PRD setup duplicates cleanupGeneratePrdWorktree body

Validation Stats

  • Agent failures: 0 partitions skipped
  • Cross-file grouped: 0 findings consolidated
  • Duplicates merged: 3

Recommendation: Address the HIGH issue (missing version bump) before merging - CI will block without it. The MEDIUM issues around cleanup deduplication and test reliability are worth fixing but not blocking.

@shafty023
shafty023 merged commit 7a66503 into main Mar 20, 2026
2 checks passed
@shafty023
shafty023 deleted the FEAT-85 branch March 20, 2026 21:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants