@snappedly-tools/shipyard 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +59 -0
  2. package/NOTICE +4 -0
  3. package/README.md +197 -0
  4. package/dist/MountConfig-bZoCs4Dd.d.ts +26 -0
  5. package/dist/SandboxProvider-KeFp_nju.d.ts +257 -0
  6. package/dist/chunk-4VDXZY7T.js +27624 -0
  7. package/dist/chunk-4VDXZY7T.js.map +1 -0
  8. package/dist/chunk-BU6XJFJ2.js +90 -0
  9. package/dist/chunk-BU6XJFJ2.js.map +1 -0
  10. package/dist/chunk-CP6YEQKU.js +42 -0
  11. package/dist/chunk-CP6YEQKU.js.map +1 -0
  12. package/dist/chunk-OAHPDSOJ.js +407 -0
  13. package/dist/chunk-OAHPDSOJ.js.map +1 -0
  14. package/dist/chunk-SRUH232X.js +26712 -0
  15. package/dist/chunk-SRUH232X.js.map +1 -0
  16. package/dist/chunk-YVJHSJUW.js +127 -0
  17. package/dist/chunk-YVJHSJUW.js.map +1 -0
  18. package/dist/index.d.ts +2780 -0
  19. package/dist/index.js +9843 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/main.d.ts +1 -0
  22. package/dist/main.js +20475 -0
  23. package/dist/main.js.map +1 -0
  24. package/dist/sandboxes/docker.d.ts +125 -0
  25. package/dist/sandboxes/docker.js +9 -0
  26. package/dist/sandboxes/docker.js.map +1 -0
  27. package/dist/sandboxes/no-sandbox.d.ts +37 -0
  28. package/dist/sandboxes/no-sandbox.js +7 -0
  29. package/dist/sandboxes/no-sandbox.js.map +1 -0
  30. package/dist/sandboxes/vercel.d.ts +104 -0
  31. package/dist/sandboxes/vercel.js +188 -0
  32. package/dist/sandboxes/vercel.js.map +1 -0
  33. package/dist/templates/blank/main.mts +13 -0
  34. package/dist/templates/blank/prompt.md +12 -0
  35. package/dist/templates/blank/template.json +4 -0
  36. package/dist/templates/parallel-planner/implement-prompt.md +62 -0
  37. package/dist/templates/parallel-planner/main.mts +205 -0
  38. package/dist/templates/parallel-planner/merge-prompt.md +26 -0
  39. package/dist/templates/parallel-planner/plan-prompt.md +37 -0
  40. package/dist/templates/parallel-planner/template.json +4 -0
  41. package/dist/templates/parallel-planner-with-review/CODING_STANDARDS.md +27 -0
  42. package/dist/templates/parallel-planner-with-review/implement-prompt.md +62 -0
  43. package/dist/templates/parallel-planner-with-review/main.mts +227 -0
  44. package/dist/templates/parallel-planner-with-review/merge-prompt.md +26 -0
  45. package/dist/templates/parallel-planner-with-review/plan-prompt.md +37 -0
  46. package/dist/templates/parallel-planner-with-review/review-prompt.md +55 -0
  47. package/dist/templates/parallel-planner-with-review/template.json +4 -0
  48. package/dist/templates/sequential-reviewer/CODING_STANDARDS.md +27 -0
  49. package/dist/templates/sequential-reviewer/implement-prompt.md +53 -0
  50. package/dist/templates/sequential-reviewer/main.mts +120 -0
  51. package/dist/templates/sequential-reviewer/review-prompt.md +55 -0
  52. package/dist/templates/sequential-reviewer/template.json +4 -0
  53. package/dist/templates/simple-loop/main.mts +51 -0
  54. package/dist/templates/simple-loop/prompt.md +53 -0
  55. package/dist/templates/simple-loop/template.json +4 -0
  56. package/dist/workflow/coordinator/migrations/001_initial.sql +131 -0
  57. package/package.json +103 -0
@@ -0,0 +1,205 @@
1
+ // Parallel Planner — three-phase orchestration loop
2
+ //
3
+ // This template drives a multi-phase workflow:
4
+ // Phase 1 (Plan): A strong Codex agent analyzes open issues, builds a dependency
5
+ // graph, and outputs a <plan> JSON listing unblocked issues
6
+ // with their target branch names.
7
+ // Phase 2 (Execute): N routine Codex agents run in parallel via Promise.allSettled,
8
+ // each working a single issue on its own branch.
9
+ // Phase 3 (Merge): A strong Codex agent merges all branches that produced commits.
10
+ //
11
+ // The outer loop repeats up to MAX_ITERATIONS times so that newly unblocked
12
+ // issues are picked up after each round of merges.
13
+ //
14
+ // Generated entrypoint: .shipyard/main.mts
15
+ // Usage:
16
+ // npx shipyard run
17
+ // Or add to package.json:
18
+ // "scripts": { "shipyard": "shipyard run" }
19
+
20
+ import * as shipyard from "@snappedly-tools/shipyard";
21
+ import { docker } from "@snappedly-tools/shipyard/sandboxes/docker";
22
+ import { z } from "zod";
23
+
24
+ // The planner emits its plan as JSON inside <plan> tags; Output.object extracts
25
+ // and validates it against this schema. We use Zod here, but any Standard
26
+ // Schema validator works just as well — Valibot, ArkType, etc. See
27
+ // https://standardschema.dev.
28
+ const planSchema = z.object({
29
+ issues: z.array(
30
+ z.object({ id: z.string(), title: z.string(), branch: z.string() }),
31
+ ),
32
+ });
33
+
34
+ // ---------------------------------------------------------------------------
35
+ // Configuration
36
+ // ---------------------------------------------------------------------------
37
+
38
+ // Maximum number of plan→execute→merge cycles before stopping.
39
+ // Raise this if your backlog is large; lower it for a quick smoke-test run.
40
+ const MAX_ITERATIONS = 10;
41
+
42
+ // Hooks run inside the sandbox before the agent starts each iteration.
43
+ // npm install ensures the sandbox always has fresh dependencies.
44
+ const hooks = {
45
+ sandbox: { onSandboxReady: [{ command: "npm install" }] },
46
+ };
47
+
48
+ // Copy node_modules from the host into the worktree before each sandbox
49
+ // starts. Avoids a full npm install from scratch; the hook above handles
50
+ // platform-specific binaries and any packages added since the last copy.
51
+ const copyToWorktree = ["node_modules"];
52
+
53
+ // ---------------------------------------------------------------------------
54
+ // Main loop
55
+ // ---------------------------------------------------------------------------
56
+
57
+ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
58
+ console.log(`\n=== Iteration ${iteration}/${MAX_ITERATIONS} ===\n`);
59
+
60
+ // -------------------------------------------------------------------------
61
+ // Phase 1: Plan
62
+ //
63
+ // The planning agent (GPT-5.6 Sol, for deeper reasoning) reads the open issue list,
64
+ // builds a dependency graph, and selects the issues that can be worked in
65
+ // parallel right now (i.e., no blocking dependencies on other open issues).
66
+ //
67
+ // It outputs a <plan> JSON block — Output.object parses and validates it.
68
+ // -------------------------------------------------------------------------
69
+ const plan = await shipyard.run({
70
+ hooks,
71
+ sandbox: docker(),
72
+ name: "planner",
73
+ // One iteration is enough: the planner just needs to read and reason,
74
+ // not write code. (Structured output requires maxIterations: 1.)
75
+ maxIterations: 1,
76
+ // Strong Codex for planning: dependency analysis benefits from deeper reasoning.
77
+ agent: shipyard.codex(shipyard.CODEX_MODELS.strong),
78
+ promptFile: "./.shipyard/plan-prompt.md",
79
+ // Extract and validate the <plan> JSON into a typed object. Throws
80
+ // StructuredOutputError if the tag is missing, the JSON is malformed, or
81
+ // validation fails — which aborts the loop.
82
+ output: shipyard.Output.object({ tag: "plan", schema: planSchema }),
83
+ });
84
+
85
+ const issues = plan.output.issues;
86
+
87
+ if (issues.length === 0) {
88
+ // No unblocked work — either everything is done or everything is blocked.
89
+ console.log("No unblocked issues to work on. Exiting.");
90
+ break;
91
+ }
92
+
93
+ console.log(
94
+ `Planning complete. ${issues.length} issue(s) to work in parallel:`,
95
+ );
96
+ for (const issue of issues) {
97
+ console.log(` ${issue.id}: ${issue.title} → ${issue.branch}`);
98
+ }
99
+
100
+ // -------------------------------------------------------------------------
101
+ // Phase 2: Execute
102
+ //
103
+ // Spawn one GPT-5.6 Luna agent per issue, all running concurrently.
104
+ // Each agent works on its own branch so there are no conflicts during
105
+ // execution — merging happens in Phase 3.
106
+ //
107
+ // Promise.allSettled means one failing agent doesn't cancel the others.
108
+ // -------------------------------------------------------------------------
109
+ const settled = await Promise.allSettled(
110
+ issues.map((issue) =>
111
+ shipyard.run({
112
+ hooks,
113
+ copyToWorktree,
114
+ // Each agent starts on its own branch via branchStrategy on run().
115
+ sandbox: docker(),
116
+ branchStrategy: { type: "branch", branch: issue.branch },
117
+ name: "implementer",
118
+ // Give each agent plenty of room to implement and iterate on tests.
119
+ maxIterations: 100,
120
+ // Routine Codex for execution: fast and capable enough for typical issue work.
121
+ agent: shipyard.codex(shipyard.CODEX_MODELS.routine),
122
+ promptFile: "./.shipyard/implement-prompt.md",
123
+ // Prompt arguments substitute {{TASK_ID}}, {{ISSUE_TITLE}},
124
+ // and {{BRANCH}} placeholders in implement-prompt.md before the
125
+ // agent sees the prompt.
126
+ promptArgs: {
127
+ TASK_ID: issue.id,
128
+ ISSUE_TITLE: issue.title,
129
+ BRANCH: issue.branch,
130
+ },
131
+ }),
132
+ ),
133
+ );
134
+
135
+ // Log any agents that threw (network error, sandbox crash, etc.).
136
+ for (const [i, outcome] of settled.entries()) {
137
+ if (outcome.status === "rejected") {
138
+ console.error(
139
+ ` ✗ ${issues[i]!.id} (${issues[i]!.branch}) failed: ${outcome.reason}`,
140
+ );
141
+ }
142
+ }
143
+
144
+ // Only pass branches that actually produced commits to the merge phase.
145
+ // An agent that ran successfully but made no commits has nothing to merge.
146
+ const completedIssues = settled
147
+ .map((outcome, i) => ({ outcome, issue: issues[i]! }))
148
+ .filter(
149
+ (
150
+ entry,
151
+ ): entry is {
152
+ outcome: PromiseFulfilledResult<
153
+ Awaited<ReturnType<typeof shipyard.run>>
154
+ >;
155
+ issue: (typeof issues)[number];
156
+ } =>
157
+ entry.outcome.status === "fulfilled" &&
158
+ entry.outcome.value.commits.length > 0,
159
+ )
160
+ .map((entry) => entry.issue);
161
+
162
+ const completedBranches = completedIssues.map((i) => i.branch);
163
+
164
+ console.log(
165
+ `\nExecution complete. ${completedBranches.length} branch(es) with commits:`,
166
+ );
167
+ for (const branch of completedBranches) {
168
+ console.log(` ${branch}`);
169
+ }
170
+
171
+ if (completedBranches.length === 0) {
172
+ // All agents ran but none made commits — nothing to merge this cycle.
173
+ console.log("No commits produced. Nothing to merge.");
174
+ continue;
175
+ }
176
+
177
+ // -------------------------------------------------------------------------
178
+ // Phase 3: Merge
179
+ //
180
+ // One GPT-5.6 Sol agent merges all completed branches into the current branch,
181
+ // resolving any conflicts and running tests to confirm everything still works.
182
+ //
183
+ // The {{BRANCHES}} and {{ISSUES}} prompt arguments are lists that the agent
184
+ // uses to know which branches to merge and which issues to close.
185
+ // -------------------------------------------------------------------------
186
+ await shipyard.run({
187
+ hooks,
188
+ sandbox: docker(),
189
+ name: "merger",
190
+ maxIterations: 1,
191
+ // Strong Codex handles merge conflict resolution and validation.
192
+ agent: shipyard.codex(shipyard.CODEX_MODELS.strong),
193
+ promptFile: "./.shipyard/merge-prompt.md",
194
+ promptArgs: {
195
+ // A markdown list of branch names, one per line.
196
+ BRANCHES: completedBranches.map((b) => `- ${b}`).join("\n"),
197
+ // A markdown list of issue IDs and titles, one per line.
198
+ ISSUES: completedIssues.map((i) => `- ${i.id}: ${i.title}`).join("\n"),
199
+ },
200
+ });
201
+
202
+ console.log("\nBranches merged.");
203
+ }
204
+
205
+ console.log("\nAll done.");
@@ -0,0 +1,26 @@
1
+ # TASK
2
+
3
+ Merge the following branches into the current branch:
4
+
5
+ {{BRANCHES}}
6
+
7
+ For each branch:
8
+
9
+ 1. Run `git merge <branch> --no-edit`
10
+ 2. If there are merge conflicts, resolve them intelligently by reading both sides and choosing the correct resolution
11
+ 3. After resolving conflicts, read the repository's configured feedback-loop contract and run every applicable check for the merged change
12
+ 4. If a check fails, fix the issue before proceeding to the next branch
13
+
14
+ After all branches are merged, make a single commit summarizing the merge.
15
+
16
+ # CLOSE ISSUES
17
+
18
+ For each branch that was merged, close its issue using the following command:
19
+
20
+ `{{CLOSE_TASK_COMMAND}}`
21
+
22
+ Here are all the issues:
23
+
24
+ {{ISSUES}}
25
+
26
+ Once you've merged everything you can, output <promise>COMPLETE</promise>.
@@ -0,0 +1,37 @@
1
+ # ISSUES
2
+
3
+ Here are the open issues in the repo:
4
+
5
+ <issues-json>
6
+
7
+ !`{{LIST_TASKS_COMMAND}}`
8
+
9
+ </issues-json>
10
+
11
+ The list above has already been filtered to issues ready for work.
12
+
13
+ # TASK
14
+
15
+ Analyze the open issues and build a dependency graph. For each issue, determine whether it **blocks** or **is blocked by** any other open issue.
16
+
17
+ An issue B is **blocked by** issue A if:
18
+
19
+ - B requires code or infrastructure that A introduces
20
+ - B and A modify overlapping files or modules, making concurrent work likely to produce merge conflicts
21
+ - B's requirements depend on a decision or API shape that A will establish
22
+
23
+ An issue is **unblocked** if it has zero blocking dependencies on other open issues.
24
+
25
+ For each unblocked issue, assign a branch name using the exact format `shipyard/issue-{id}` (no slug or other suffix). This must be deterministic so that re-planning the same issue always produces the same branch name and accumulated progress is preserved.
26
+
27
+ # OUTPUT
28
+
29
+ Output your plan as a JSON object wrapped in `<plan>` tags:
30
+
31
+ <plan>
32
+ {"issues": [{"id": "42", "title": "Fix auth bug", "branch": "shipyard/issue-42"}]}
33
+ </plan>
34
+
35
+ Include only unblocked issues. If every issue is blocked, include the single highest-priority candidate (the one with the fewest or weakest dependencies).
36
+
37
+ Always emit the `<plan>` tags, even when there is nothing to do. If there are no issues to work on at all, output `<plan>{"issues": []}</plan>` so the run can exit cleanly.
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "parallel-planner",
3
+ "description": "Plans parallelizable issues, executes on separate branches, merges"
4
+ }
@@ -0,0 +1,27 @@
1
+ # Coding Standards
2
+
3
+ <!-- Customize this file with your project's coding standards.
4
+ The reviewer agent loads it during code review via @.shipyard/CODING_STANDARDS.md
5
+ so these standards are enforced during review without costing tokens during implementation. -->
6
+
7
+ ## Style
8
+
9
+ <!-- Example:
10
+ - Use camelCase for variables and functions
11
+ - Use PascalCase for classes and types
12
+ - Prefer named exports over default exports
13
+ -->
14
+
15
+ ## Testing
16
+
17
+ <!-- Example:
18
+ - Every public function must have at least one test
19
+ - Use descriptive test names that explain the expected behavior
20
+ -->
21
+
22
+ ## Architecture
23
+
24
+ <!-- Example:
25
+ - Keep modules focused on a single responsibility
26
+ - Prefer composition over inheritance
27
+ -->
@@ -0,0 +1,62 @@
1
+ # TASK
2
+
3
+ Fix issue {{TASK_ID}}: {{ISSUE_TITLE}}
4
+
5
+ Pull in the issue using `{{VIEW_TASK_COMMAND}}`. If it has a parent PRD, pull that in too.
6
+
7
+ Only work on the issue specified.
8
+
9
+ Work on branch {{BRANCH}}. Make commits and run tests.
10
+
11
+ # CONTEXT
12
+
13
+ Here are the last 10 commits:
14
+
15
+ <recent-commits>
16
+
17
+ !`git log -n 10 --format="%H%n%ad%n%B---" --date=short`
18
+
19
+ </recent-commits>
20
+
21
+ # EXPLORATION
22
+
23
+ Explore the repo and fill your context window with relevant information that will allow you to complete the task.
24
+
25
+ Pay extra attention to test files that touch the relevant parts of the code.
26
+
27
+ # EXECUTION
28
+
29
+ If applicable, use RGR to complete the task.
30
+
31
+ 1. RED: write one test
32
+ 2. GREEN: write the implementation to pass that test
33
+ 3. REPEAT until done
34
+ 4. REFACTOR the code
35
+
36
+ # FEEDBACK LOOPS
37
+
38
+ Before committing, read the repository's configured feedback-loop contract and run every applicable check for this change. Use the configured static check and focused behavior tests when they exist; include formatting, build, or broader checks when the contract or change requires them. Fix failures before committing.
39
+
40
+ # COMMIT
41
+
42
+ Make a git commit. The commit message must:
43
+
44
+ 1. Start with `RALPH:` prefix
45
+ 2. Include task completed + PRD reference
46
+ 3. Key decisions made
47
+ 4. Files changed
48
+ 5. Blockers or notes for next iteration
49
+
50
+ Keep it concise.
51
+
52
+ # THE ISSUE
53
+
54
+ If the task is not complete, leave a comment on the issue with what was done.
55
+
56
+ Do not close the issue - this will be done later.
57
+
58
+ Once complete, output <promise>COMPLETE</promise>.
59
+
60
+ # FINAL RULES
61
+
62
+ ONLY WORK ON A SINGLE TASK.
@@ -0,0 +1,227 @@
1
+ // Parallel Planner with Review — four-phase orchestration loop
2
+ //
3
+ // This template drives a multi-phase workflow:
4
+ // Phase 1 (Plan): A strong Codex agent analyzes open issues, builds a
5
+ // dependency graph, and outputs a <plan> JSON
6
+ // listing unblocked issues with branch names.
7
+ // Phase 2 (Execute + Review): For each issue, a sandbox is created via
8
+ // createSandbox(). The implementer runs first
9
+ // (100 iterations). If it produces commits, a
10
+ // reviewer runs in the same sandbox on the same
11
+ // branch (1 iteration). All issue pipelines run
12
+ // concurrently via Promise.allSettled().
13
+ // Phase 3 (Merge): A strong Codex agent merges all completed
14
+ // branches into the current branch.
15
+ //
16
+ // The outer loop repeats up to MAX_ITERATIONS times so that newly unblocked
17
+ // issues are picked up after each round of merges.
18
+ //
19
+ // Generated entrypoint: .shipyard/main.mts
20
+ // Usage:
21
+ // npx shipyard run
22
+ // Or add to package.json:
23
+ // "scripts": { "shipyard": "shipyard run" }
24
+
25
+ import * as shipyard from "@snappedly-tools/shipyard";
26
+ import { docker } from "@snappedly-tools/shipyard/sandboxes/docker";
27
+ import { z } from "zod";
28
+
29
+ // The planner emits its plan as JSON inside <plan> tags; Output.object extracts
30
+ // and validates it against this schema. We use Zod here, but any Standard
31
+ // Schema validator works just as well — Valibot, ArkType, etc. See
32
+ // https://standardschema.dev.
33
+ const planSchema = z.object({
34
+ issues: z.array(
35
+ z.object({ id: z.string(), title: z.string(), branch: z.string() }),
36
+ ),
37
+ });
38
+
39
+ // ---------------------------------------------------------------------------
40
+ // Configuration
41
+ // ---------------------------------------------------------------------------
42
+
43
+ // Maximum number of plan→execute→merge cycles before stopping.
44
+ // Raise this if your backlog is large; lower it for a quick smoke-test run.
45
+ const MAX_ITERATIONS = 10;
46
+
47
+ // Hooks run inside the sandbox before the agent starts each iteration.
48
+ // npm install ensures the sandbox always has fresh dependencies.
49
+ const hooks = {
50
+ sandbox: { onSandboxReady: [{ command: "npm install" }] },
51
+ };
52
+
53
+ // Copy node_modules from the host into the worktree before each sandbox
54
+ // starts. Avoids a full npm install from scratch; the hook above handles
55
+ // platform-specific binaries and any packages added since the last copy.
56
+ const copyToWorktree = ["node_modules"];
57
+
58
+ // ---------------------------------------------------------------------------
59
+ // Main loop
60
+ // ---------------------------------------------------------------------------
61
+
62
+ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
63
+ console.log(`\n=== Iteration ${iteration}/${MAX_ITERATIONS} ===\n`);
64
+
65
+ // -------------------------------------------------------------------------
66
+ // Phase 1: Plan
67
+ //
68
+ // The planning agent (GPT-5.6 Sol, for deeper reasoning) reads the open issue list,
69
+ // builds a dependency graph, and selects the issues that can be worked in
70
+ // parallel right now (i.e., no blocking dependencies on other open issues).
71
+ //
72
+ // It outputs a <plan> JSON block — Output.object parses and validates it.
73
+ // -------------------------------------------------------------------------
74
+ const plan = await shipyard.run({
75
+ hooks,
76
+ sandbox: docker(),
77
+ name: "planner",
78
+ // One iteration is enough: the planner just needs to read and reason,
79
+ // not write code. (Structured output requires maxIterations: 1.)
80
+ maxIterations: 1,
81
+ // Strong Codex for planning: dependency analysis benefits from deeper reasoning.
82
+ agent: shipyard.codex(shipyard.CODEX_MODELS.strong),
83
+ promptFile: "./.shipyard/plan-prompt.md",
84
+ // Extract and validate the <plan> JSON into a typed object. Throws
85
+ // StructuredOutputError if the tag is missing, the JSON is malformed, or
86
+ // validation fails — which aborts the loop.
87
+ output: shipyard.Output.object({ tag: "plan", schema: planSchema }),
88
+ });
89
+
90
+ const issues = plan.output.issues;
91
+
92
+ if (issues.length === 0) {
93
+ // No unblocked work — either everything is done or everything is blocked.
94
+ console.log("No unblocked issues to work on. Exiting.");
95
+ break;
96
+ }
97
+
98
+ console.log(
99
+ `Planning complete. ${issues.length} issue(s) to work in parallel:`,
100
+ );
101
+ for (const issue of issues) {
102
+ console.log(` ${issue.id}: ${issue.title} → ${issue.branch}`);
103
+ }
104
+
105
+ // -------------------------------------------------------------------------
106
+ // Phase 2: Execute + Review
107
+ //
108
+ // For each issue, create a sandbox via createSandbox() so the implementer
109
+ // and reviewer share the same sandbox instance per branch. The implementer
110
+ // runs first; if it produces commits, the reviewer runs in the same sandbox.
111
+ //
112
+ // Promise.allSettled means one failing pipeline doesn't cancel the others.
113
+ // -------------------------------------------------------------------------
114
+
115
+ const settled = await Promise.allSettled(
116
+ issues.map(async (issue) => {
117
+ const sandbox = await shipyard.createSandbox({
118
+ branch: issue.branch,
119
+ sandbox: docker(),
120
+ hooks,
121
+ copyToWorktree,
122
+ });
123
+
124
+ try {
125
+ // Run the implementer
126
+ const implement = await sandbox.run({
127
+ name: "implementer",
128
+ maxIterations: 100,
129
+ agent: shipyard.codex(shipyard.CODEX_MODELS.routine),
130
+ promptFile: "./.shipyard/implement-prompt.md",
131
+ promptArgs: {
132
+ TASK_ID: issue.id,
133
+ ISSUE_TITLE: issue.title,
134
+ BRANCH: issue.branch,
135
+ },
136
+ });
137
+
138
+ // Only review if the implementer produced commits
139
+ if (implement.commits.length > 0) {
140
+ const review = await sandbox.run({
141
+ name: "reviewer",
142
+ maxIterations: 1,
143
+ agent: shipyard.codex(shipyard.CODEX_MODELS.strong),
144
+ promptFile: "./.shipyard/review-prompt.md",
145
+ promptArgs: {
146
+ BRANCH: issue.branch,
147
+ },
148
+ });
149
+
150
+ // Merge commits from both runs so the merge phase sees all of them.
151
+ // Each sandbox.run() only returns commits from its own run.
152
+ return {
153
+ ...review,
154
+ commits: [...implement.commits, ...review.commits],
155
+ };
156
+ }
157
+
158
+ return implement;
159
+ } finally {
160
+ await sandbox.close();
161
+ }
162
+ }),
163
+ );
164
+
165
+ // Log any agents that threw (network error, sandbox crash, etc.).
166
+ for (const [i, outcome] of settled.entries()) {
167
+ if (outcome.status === "rejected") {
168
+ console.error(
169
+ ` ✗ ${issues[i]!.id} (${issues[i]!.branch}) failed: ${outcome.reason}`,
170
+ );
171
+ }
172
+ }
173
+
174
+ // Only pass branches that actually produced commits to the merge phase.
175
+ // An agent that ran successfully but made no commits has nothing to merge.
176
+ const completedIssues = settled
177
+ .map((outcome, i) => ({ outcome, issue: issues[i]! }))
178
+ .filter(
179
+ (entry) =>
180
+ entry.outcome.status === "fulfilled" &&
181
+ entry.outcome.value.commits.length > 0,
182
+ )
183
+ .map((entry) => entry.issue);
184
+
185
+ const completedBranches = completedIssues.map((i) => i.branch);
186
+
187
+ console.log(
188
+ `\nExecution complete. ${completedBranches.length} branch(es) with commits:`,
189
+ );
190
+ for (const branch of completedBranches) {
191
+ console.log(` ${branch}`);
192
+ }
193
+
194
+ if (completedBranches.length === 0) {
195
+ // All agents ran but none made commits — nothing to merge this cycle.
196
+ console.log("No commits produced. Nothing to merge.");
197
+ continue;
198
+ }
199
+
200
+ // -------------------------------------------------------------------------
201
+ // Phase 3: Merge
202
+ //
203
+ // One GPT-5.6 Sol agent merges all completed branches into the current branch,
204
+ // resolving any conflicts and running tests to confirm everything works.
205
+ //
206
+ // The {{BRANCHES}} and {{ISSUES}} prompt arguments are lists that the agent
207
+ // uses to know which branches to merge and which issues to close.
208
+ // -------------------------------------------------------------------------
209
+ await shipyard.run({
210
+ hooks,
211
+ sandbox: docker(),
212
+ name: "merger",
213
+ maxIterations: 1,
214
+ agent: shipyard.codex(shipyard.CODEX_MODELS.strong),
215
+ promptFile: "./.shipyard/merge-prompt.md",
216
+ promptArgs: {
217
+ // A markdown list of branch names, one per line.
218
+ BRANCHES: completedBranches.map((b) => `- ${b}`).join("\n"),
219
+ // A markdown list of issue IDs and titles, one per line.
220
+ ISSUES: completedIssues.map((i) => `- ${i.id}: ${i.title}`).join("\n"),
221
+ },
222
+ });
223
+
224
+ console.log("\nBranches merged.");
225
+ }
226
+
227
+ console.log("\nAll done.");
@@ -0,0 +1,26 @@
1
+ # TASK
2
+
3
+ Merge the following branches into the current branch:
4
+
5
+ {{BRANCHES}}
6
+
7
+ For each branch:
8
+
9
+ 1. Run `git merge <branch> --no-edit`
10
+ 2. If there are merge conflicts, resolve them intelligently by reading both sides and choosing the correct resolution
11
+ 3. After resolving conflicts, read the repository's configured feedback-loop contract and run every applicable check for the merged change
12
+ 4. If a check fails, fix the issue before proceeding to the next branch
13
+
14
+ After all branches are merged, make a single commit summarizing the merge.
15
+
16
+ # CLOSE ISSUES
17
+
18
+ For each branch that was merged, close its issue using the following command:
19
+
20
+ `{{CLOSE_TASK_COMMAND}}`
21
+
22
+ Here are all the issues:
23
+
24
+ {{ISSUES}}
25
+
26
+ Once you've merged everything you can, output <promise>COMPLETE</promise>.
@@ -0,0 +1,37 @@
1
+ # ISSUES
2
+
3
+ Here are the open issues in the repo:
4
+
5
+ <issues-json>
6
+
7
+ !`{{LIST_TASKS_COMMAND}}`
8
+
9
+ </issues-json>
10
+
11
+ The list above has already been filtered to issues ready for work.
12
+
13
+ # TASK
14
+
15
+ Analyze the open issues and build a dependency graph. For each issue, determine whether it **blocks** or **is blocked by** any other open issue.
16
+
17
+ An issue B is **blocked by** issue A if:
18
+
19
+ - B requires code or infrastructure that A introduces
20
+ - B and A modify overlapping files or modules, making concurrent work likely to produce merge conflicts
21
+ - B's requirements depend on a decision or API shape that A will establish
22
+
23
+ An issue is **unblocked** if it has zero blocking dependencies on other open issues.
24
+
25
+ For each unblocked issue, assign a branch name using the exact format `shipyard/issue-{id}` (no slug or other suffix). This must be deterministic so that re-planning the same issue always produces the same branch name and accumulated progress is preserved.
26
+
27
+ # OUTPUT
28
+
29
+ Output your plan as a JSON object wrapped in `<plan>` tags:
30
+
31
+ <plan>
32
+ {"issues": [{"id": "42", "title": "Fix auth bug", "branch": "shipyard/issue-42"}]}
33
+ </plan>
34
+
35
+ Include only unblocked issues. If every issue is blocked, include the single highest-priority candidate (the one with the fewest or weakest dependencies).
36
+
37
+ Always emit the `<plan>` tags, even when there is nothing to do. If there are no issues to work on at all, output `<plan>{"issues": []}</plan>` so the run can exit cleanly.