@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,55 @@
1
+ # TASK
2
+
3
+ Review the code changes on branch `{{BRANCH}}` and improve code clarity, consistency, and maintainability while preserving exact functionality.
4
+
5
+ # CONTEXT
6
+
7
+ ## Branch diff
8
+
9
+ !`git diff {{TARGET_BRANCH}}...{{BRANCH}}`
10
+
11
+ ## Commits on this branch
12
+
13
+ !`git log {{TARGET_BRANCH}}..{{BRANCH}} --oneline`
14
+
15
+ # REVIEW PROCESS
16
+
17
+ 1. **Understand the change**: Read the diff and commits above to understand the intent.
18
+
19
+ 2. **Analyze for improvements**: Look for opportunities to:
20
+ - Reduce unnecessary complexity and nesting
21
+ - Eliminate redundant code and abstractions
22
+ - Improve readability through clear variable and function names
23
+ - Consolidate related logic
24
+ - Remove unnecessary comments that describe obvious code
25
+ - Avoid nested ternary operators - prefer switch statements or if/else chains
26
+ - Choose clarity over brevity - explicit code is often better than overly compact code
27
+
28
+ 3. **Check correctness**:
29
+ - Does the implementation match the intent? Are edge cases handled?
30
+ - Are new/changed behaviours covered by tests?
31
+ - Are there unsafe casts, `any` types, or unchecked assumptions?
32
+ - Does the change introduce injection vulnerabilities, credential leaks, or other security issues?
33
+
34
+ 4. **Maintain balance**: Avoid over-simplification that could:
35
+ - Reduce code clarity or maintainability
36
+ - Create overly clever solutions that are hard to understand
37
+ - Combine too many concerns into single functions or components
38
+ - Remove helpful abstractions that improve code organization
39
+ - Make the code harder to debug or extend
40
+
41
+ 5. **Apply project standards**: Follow the coding standards defined in @.shipyard/CODING_STANDARDS.md
42
+
43
+ 6. **Preserve functionality**: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
44
+
45
+ # EXECUTION
46
+
47
+ If you find improvements to make:
48
+
49
+ 1. Make the changes directly on this branch
50
+ 2. Run tests and type checking to ensure nothing is broken
51
+ 3. Commit describing the refinements
52
+
53
+ If the code is already clean and well-structured, do nothing.
54
+
55
+ Once complete, output <promise>COMPLETE</promise>.
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "parallel-planner-with-review",
3
+ "description": "Plans parallelizable issues, executes with per-branch review, 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,53 @@
1
+ # Context
2
+
3
+ ## Open issues
4
+
5
+ !`{{LIST_TASKS_COMMAND}}`
6
+
7
+ The list above has already been filtered to issues ready for work and is the sole source of truth for what work exists. Do not run your own unfiltered query to find more issues — if the list is empty, there is nothing to do.
8
+
9
+ ## Recent RALPH commits (last 10)
10
+
11
+ !`git log --oneline --grep="RALPH" -10`
12
+
13
+ # Task
14
+
15
+ You are RALPH — an autonomous coding agent working through issues one at a time.
16
+
17
+ ## Priority order
18
+
19
+ Work on issues in this order:
20
+
21
+ 1. **Bug fixes** — broken behaviour affecting users
22
+ 2. **Tracer bullets** — thin end-to-end slices that prove an approach works
23
+ 3. **Polish** — improving existing functionality (error messages, UX, docs)
24
+ 4. **Refactors** — internal cleanups with no user-visible change
25
+
26
+ Pick the highest-priority open issue that is not blocked by another open issue.
27
+
28
+ ## Workflow
29
+
30
+ 1. **Explore** — read the issue carefully. Pull in the parent PRD if referenced. Read the relevant source files and tests before writing any code.
31
+ 2. **Plan** — decide what to change and why. Keep the change as small as possible.
32
+ 3. **Execute** — use RGR (Red → Green → Repeat → Refactor): write a failing test first, then write the implementation to pass it.
33
+ 4. **Verify** — 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 proceeding.
34
+ 5. **Commit** — make a single git commit. The message MUST:
35
+ - Start with `RALPH:` prefix
36
+ - Include the task completed and any PRD reference
37
+ - List key decisions made
38
+ - List files changed
39
+ - Note any blockers for the next iteration
40
+ 6. **Close** — close the issue with `{{CLOSE_TASK_COMMAND}}` explaining what was done.
41
+
42
+ ## Rules
43
+
44
+ - Work on **one issue per iteration**. Do not attempt multiple issues in a single iteration.
45
+ - Do not close an issue until you have committed the fix and verified tests pass.
46
+ - Do not leave commented-out code or TODO comments in committed code.
47
+ - If you are blocked (missing context, failing tests you cannot fix, external dependency), leave a comment on the issue and move on — do not close it.
48
+
49
+ # Done
50
+
51
+ When all actionable issues are complete (or you are blocked on all remaining ones), or the open-issues block at the top of this prompt is empty, output the completion signal:
52
+
53
+ <promise>COMPLETE</promise>
@@ -0,0 +1,120 @@
1
+ // Sequential Reviewer — implement-then-review loop
2
+ //
3
+ // This template drives a two-phase workflow per issue:
4
+ // Phase 1 (Implement): A Codex agent picks an open issue, works on it
5
+ // on a dedicated branch, commits the changes, and signals
6
+ // completion.
7
+ // Phase 2 (Review): A second Codex agent reviews the branch diff and either
8
+ // approves it or makes corrections directly on the branch.
9
+ //
10
+ // Both phases share a single sandbox created via createSandbox(), so the
11
+ // implementer and reviewer work on the same explicit branch.
12
+ //
13
+ // The outer loop repeats up to MAX_ITERATIONS times, processing one issue per
14
+ // iteration and stopping early once the backlog is exhausted (an implement
15
+ // phase that produces no commits). This is a middle-complexity option between
16
+ // the simple-loop (no review gate) and the parallel-planner (concurrent
17
+ // execution with a planning phase).
18
+ // Generated entrypoint: .shipyard/main.mts
19
+ //
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
+
28
+ // ---------------------------------------------------------------------------
29
+ // Configuration
30
+ // ---------------------------------------------------------------------------
31
+
32
+ // Maximum number of implement→review cycles to run before stopping.
33
+ // Each cycle works on one issue. Raise this to process more issues per run.
34
+ const MAX_ITERATIONS = 10;
35
+
36
+ // Hooks run inside the sandbox before the agent starts each iteration.
37
+ // npm install ensures the sandbox always has fresh dependencies.
38
+ const hooks = {
39
+ sandbox: { onSandboxReady: [{ command: "npm install" }] },
40
+ };
41
+
42
+ // Copy node_modules from the host into the worktree before each sandbox
43
+ // starts. Avoids a full npm install from scratch; the hook above handles
44
+ // platform-specific binaries and any packages added since the last copy.
45
+ const copyToWorktree = ["node_modules"];
46
+
47
+ // ---------------------------------------------------------------------------
48
+ // Main loop
49
+ // ---------------------------------------------------------------------------
50
+
51
+ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
52
+ console.log(`\n=== Iteration ${iteration}/${MAX_ITERATIONS} ===\n`);
53
+
54
+ // Generate a unique branch name for this iteration.
55
+ const branch = `shipyard/sequential-reviewer/${Date.now()}`;
56
+
57
+ // Create a single sandbox that both the implementer and reviewer share.
58
+ // This gives both agents a real, named branch that persists across phases.
59
+ const sandbox = await shipyard.createSandbox({
60
+ branch,
61
+ sandbox: docker(),
62
+ hooks,
63
+ copyToWorktree,
64
+ });
65
+
66
+ try {
67
+ // -----------------------------------------------------------------------
68
+ // Phase 1: Implement
69
+ //
70
+ // A Codex agent picks the next open issue, writes the
71
+ // implementation (using RGR: Red → Green → Repeat → Refactor), and
72
+ // commits the result.
73
+ //
74
+ // The agent signals completion via <promise>COMPLETE</promise> when done.
75
+ // -----------------------------------------------------------------------
76
+ // One iteration so each outer pass implements a single issue on its own
77
+ // branch, then hands it to the reviewer. A higher value lets the agent
78
+ // drain the whole backlog onto this one branch in a single pass, which
79
+ // defeats the per-issue review.
80
+ const implement = await sandbox.run({
81
+ name: "implementer",
82
+ maxIterations: 1,
83
+ agent: shipyard.codex(shipyard.CODEX_MODELS.routine),
84
+ promptFile: "./.shipyard/implement-prompt.md",
85
+ });
86
+
87
+ if (!implement.commits.length) {
88
+ // No commits means the backlog is empty or every remaining issue is
89
+ // blocked — there is nothing left to implement or review, so stop.
90
+ console.log("Implementation agent made no commits. Stopping.");
91
+ break;
92
+ }
93
+
94
+ console.log(`\nImplementation complete on branch: ${branch}`);
95
+ console.log(`Commits: ${implement.commits.length}`);
96
+
97
+ // -----------------------------------------------------------------------
98
+ // Phase 2: Review
99
+ //
100
+ // A second Codex agent reviews the diff of the branch produced by
101
+ // Phase 1. It uses the {{BRANCH}} prompt argument to inspect the right
102
+ // branch, and either approves or makes corrections directly on the branch.
103
+ // -----------------------------------------------------------------------
104
+ await sandbox.run({
105
+ name: "reviewer",
106
+ maxIterations: 1,
107
+ agent: shipyard.codex(shipyard.CODEX_MODELS.strong),
108
+ promptFile: "./.shipyard/review-prompt.md",
109
+ promptArgs: {
110
+ BRANCH: branch,
111
+ },
112
+ });
113
+
114
+ console.log("\nReview complete.");
115
+ } finally {
116
+ await sandbox.close();
117
+ }
118
+ }
119
+
120
+ console.log("\nAll done.");
@@ -0,0 +1,55 @@
1
+ # TASK
2
+
3
+ Review the code changes on branch `{{BRANCH}}` and improve code clarity, consistency, and maintainability while preserving exact functionality.
4
+
5
+ # CONTEXT
6
+
7
+ ## Branch diff
8
+
9
+ !`git diff {{TARGET_BRANCH}}...{{BRANCH}}`
10
+
11
+ ## Commits on this branch
12
+
13
+ !`git log {{TARGET_BRANCH}}..{{BRANCH}} --oneline`
14
+
15
+ # REVIEW PROCESS
16
+
17
+ 1. **Understand the change**: Read the diff and commits above to understand the intent.
18
+
19
+ 2. **Analyze for improvements**: Look for opportunities to:
20
+ - Reduce unnecessary complexity and nesting
21
+ - Eliminate redundant code and abstractions
22
+ - Improve readability through clear variable and function names
23
+ - Consolidate related logic
24
+ - Remove unnecessary comments that describe obvious code
25
+ - Avoid nested ternary operators - prefer switch statements or if/else chains
26
+ - Choose clarity over brevity - explicit code is often better than overly compact code
27
+
28
+ 3. **Check correctness**:
29
+ - Does the implementation match the intent? Are edge cases handled?
30
+ - Are new/changed behaviours covered by tests?
31
+ - Are there unsafe casts, `any` types, or unchecked assumptions?
32
+ - Does the change introduce injection vulnerabilities, credential leaks, or other security issues?
33
+
34
+ 4. **Maintain balance**: Avoid over-simplification that could:
35
+ - Reduce code clarity or maintainability
36
+ - Create overly clever solutions that are hard to understand
37
+ - Combine too many concerns into single functions or components
38
+ - Remove helpful abstractions that improve code organization
39
+ - Make the code harder to debug or extend
40
+
41
+ 5. **Apply project standards**: Follow the coding standards defined in @.shipyard/CODING_STANDARDS.md
42
+
43
+ 6. **Preserve functionality**: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
44
+
45
+ # EXECUTION
46
+
47
+ If you find improvements to make:
48
+
49
+ 1. Make the changes directly on this branch
50
+ 2. Run tests and type checking to ensure nothing is broken
51
+ 3. Commit describing the refinements
52
+
53
+ If the code is already clean and well-structured, do nothing.
54
+
55
+ Once complete, output <promise>COMPLETE</promise>.
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "sequential-reviewer",
3
+ "description": "Implements issues one by one, with a code review step after each"
4
+ }
@@ -0,0 +1,51 @@
1
+ import { CODEX_MODELS, run, codex } from "@snappedly-tools/shipyard";
2
+ import { docker } from "@snappedly-tools/shipyard/sandboxes/docker";
3
+
4
+ // Simple loop: an agent that picks open issues one by one and closes them.
5
+ // Generated entrypoint: .shipyard/main.mts
6
+ // Run this with: npx shipyard run
7
+ // Or add to package.json scripts: "shipyard": "shipyard run"
8
+
9
+ await run({
10
+ // A name for this run, shown as a prefix in log output.
11
+ name: "worker",
12
+
13
+ // Sandbox provider — runs the agent inside an isolated container.
14
+ sandbox: docker(),
15
+
16
+ // The agent provider. The routine configured Codex model runs at max
17
+ // reasoning by default. Switch to CODEX_MODELS.strong for more demanding
18
+ // planning or review work.
19
+ agent: codex(CODEX_MODELS.routine),
20
+
21
+ // Path to the prompt file. Shell expressions inside are evaluated inside the
22
+ // sandbox at the start of each iteration, so the agent always sees fresh data.
23
+ promptFile: "./.shipyard/prompt.md",
24
+
25
+ // Maximum number of iterations (agent invocations) to run in a session.
26
+ // Each iteration works on a single issue. Increase this to process more issues
27
+ // per run, or set it to 1 for a single-shot mode.
28
+ maxIterations: 3,
29
+
30
+ // Branch strategy — merge-to-head creates a temporary branch for the agent
31
+ // to work on, then merges the result back to HEAD when the run completes.
32
+ // This is required when using copyToWorktree, since head mode bind-mounts
33
+ // the host directory directly (no worktree to copy into).
34
+ branchStrategy: { type: "merge-to-head" },
35
+
36
+ // Copy node_modules from the host into the worktree before the sandbox
37
+ // starts. This avoids a full npm install from scratch on every iteration.
38
+ // The onSandboxReady hook still runs npm install as a safety net to handle
39
+ // platform-specific binaries and any packages added since the last copy.
40
+ copyToWorktree: ["node_modules"],
41
+
42
+ // Lifecycle hooks — commands grouped by where they run (host or sandbox).
43
+ hooks: {
44
+ sandbox: {
45
+ // onSandboxReady runs once after the sandbox is initialised and the repo is
46
+ // synced in, before the agent starts. Use it to install dependencies or run
47
+ // any other setup steps your project needs.
48
+ onSandboxReady: [{ command: "npm install" }],
49
+ },
50
+ },
51
+ });
@@ -0,0 +1,53 @@
1
+ # Context
2
+
3
+ ## Open issues
4
+
5
+ !`{{LIST_TASKS_COMMAND}}`
6
+
7
+ The list above has already been filtered to issues ready for work and is the sole source of truth for what work exists. Do not run your own unfiltered query to find more issues — if the list is empty, there is nothing to do.
8
+
9
+ ## Recent RALPH commits (last 10)
10
+
11
+ !`git log --oneline --grep="RALPH" -10`
12
+
13
+ # Task
14
+
15
+ You are RALPH — an autonomous coding agent working through issues one at a time.
16
+
17
+ ## Priority order
18
+
19
+ Work on issues in this order:
20
+
21
+ 1. **Bug fixes** — broken behaviour affecting users
22
+ 2. **Tracer bullets** — thin end-to-end slices that prove an approach works
23
+ 3. **Polish** — improving existing functionality (error messages, UX, docs)
24
+ 4. **Refactors** — internal cleanups with no user-visible change
25
+
26
+ Pick the highest-priority open issue that is not blocked by another open issue.
27
+
28
+ ## Workflow
29
+
30
+ 1. **Explore** — read the issue carefully. Pull in the parent PRD if referenced. Read the relevant source files and tests before writing any code.
31
+ 2. **Plan** — decide what to change and why. Keep the change as small as possible.
32
+ 3. **Execute** — use RGR (Red → Green → Repeat → Refactor): write a failing test first, then write the implementation to pass it.
33
+ 4. **Verify** — 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 proceeding.
34
+ 5. **Commit** — make a single git commit. The message MUST:
35
+ - Start with `RALPH:` prefix
36
+ - Include the task completed and any PRD reference
37
+ - List key decisions made
38
+ - List files changed
39
+ - Note any blockers for the next iteration
40
+ 6. **Close** — close the issue with `{{CLOSE_TASK_COMMAND}}` explaining what was done.
41
+
42
+ ## Rules
43
+
44
+ - Work on **one issue per iteration**. Do not attempt multiple issues in a single iteration.
45
+ - Do not close an issue until you have committed the fix and verified tests pass.
46
+ - Do not leave commented-out code or TODO comments in committed code.
47
+ - If you are blocked (missing context, failing tests you cannot fix, external dependency), leave a comment on the issue and move on — do not close it.
48
+
49
+ # Done
50
+
51
+ When all actionable issues are complete (or you are blocked on all remaining ones), or the open-issues block at the top of this prompt is empty, output the completion signal:
52
+
53
+ <promise>COMPLETE</promise>
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "simple-loop",
3
+ "description": "Picks issues one by one and closes them"
4
+ }
@@ -0,0 +1,131 @@
1
+ -- Shipyard coordinator storage schema. Apply with a transaction-capable
2
+ -- PostgreSQL client selected by the host; the package does not provision a
3
+ -- database or embed credentials.
4
+
5
+ CREATE TABLE IF NOT EXISTS shipyard_events (
6
+ id TEXT PRIMARY KEY,
7
+ delivery_id TEXT NOT NULL UNIQUE,
8
+ repository TEXT NOT NULL,
9
+ item_id TEXT NOT NULL,
10
+ brief_revision INTEGER NOT NULL,
11
+ phase TEXT NOT NULL,
12
+ relevant_revision TEXT NOT NULL,
13
+ observed_at TIMESTAMPTZ NOT NULL,
14
+ source_state TEXT,
15
+ brief JSONB NOT NULL,
16
+ policy JSONB NOT NULL,
17
+ status TEXT NOT NULL,
18
+ ignore_reason TEXT,
19
+ job_id TEXT,
20
+ received_at TIMESTAMPTZ NOT NULL,
21
+ payload JSONB
22
+ );
23
+
24
+ CREATE TABLE IF NOT EXISTS shipyard_jobs (
25
+ id TEXT PRIMARY KEY,
26
+ repository TEXT NOT NULL,
27
+ item_id TEXT NOT NULL,
28
+ item_kind TEXT NOT NULL,
29
+ brief_revision INTEGER NOT NULL,
30
+ phase TEXT NOT NULL,
31
+ relevant_revision TEXT NOT NULL,
32
+ brief JSONB NOT NULL,
33
+ policy JSONB NOT NULL,
34
+ state TEXT NOT NULL,
35
+ control TEXT NOT NULL,
36
+ phase_attempts JSONB NOT NULL,
37
+ repair_batches INTEGER NOT NULL DEFAULT 0,
38
+ follow_ups INTEGER NOT NULL DEFAULT 0,
39
+ infrastructure_retries INTEGER NOT NULL DEFAULT 0,
40
+ infrastructure_retry_limit INTEGER NOT NULL,
41
+ assignments JSONB NOT NULL,
42
+ phase_results JSONB NOT NULL,
43
+ active_assignment_id TEXT,
44
+ latest_observed_at TIMESTAMPTZ NOT NULL,
45
+ created_at TIMESTAMPTZ NOT NULL,
46
+ updated_at TIMESTAMPTZ NOT NULL,
47
+ version INTEGER NOT NULL
48
+ );
49
+
50
+ CREATE INDEX IF NOT EXISTS shipyard_jobs_identity_idx
51
+ ON shipyard_jobs (repository, item_id, item_kind, updated_at DESC);
52
+
53
+ CREATE INDEX IF NOT EXISTS shipyard_jobs_key_idx
54
+ ON shipyard_jobs (
55
+ repository,
56
+ item_id,
57
+ brief_revision,
58
+ phase,
59
+ relevant_revision,
60
+ updated_at DESC
61
+ );
62
+
63
+ CREATE UNIQUE INDEX IF NOT EXISTS shipyard_jobs_work_key_idx
64
+ ON shipyard_jobs (
65
+ repository,
66
+ item_id,
67
+ item_kind,
68
+ brief_revision,
69
+ phase,
70
+ relevant_revision
71
+ );
72
+
73
+ CREATE TABLE IF NOT EXISTS shipyard_dispatches (
74
+ id TEXT PRIMARY KEY,
75
+ dedupe_key TEXT NOT NULL UNIQUE,
76
+ job_id TEXT NOT NULL REFERENCES shipyard_jobs(id),
77
+ repository TEXT NOT NULL,
78
+ item_id TEXT NOT NULL,
79
+ brief_revision INTEGER NOT NULL,
80
+ phase TEXT NOT NULL,
81
+ relevant_revision TEXT NOT NULL,
82
+ status TEXT NOT NULL,
83
+ assignment JSONB,
84
+ worker_id TEXT,
85
+ claimed_at BIGINT,
86
+ claim_expires_at BIGINT,
87
+ error TEXT,
88
+ created_at TIMESTAMPTZ NOT NULL,
89
+ updated_at TIMESTAMPTZ NOT NULL
90
+ );
91
+
92
+ CREATE TABLE IF NOT EXISTS shipyard_effects (
93
+ id TEXT PRIMARY KEY,
94
+ job_id TEXT NOT NULL REFERENCES shipyard_jobs(id),
95
+ kind TEXT NOT NULL,
96
+ marker TEXT NOT NULL,
97
+ payload JSONB,
98
+ status TEXT NOT NULL,
99
+ external_ref JSONB,
100
+ worker_id TEXT,
101
+ fencing_token BIGINT,
102
+ claimed_at BIGINT,
103
+ claim_expires_at BIGINT,
104
+ error TEXT,
105
+ created_at TIMESTAMPTZ NOT NULL,
106
+ updated_at TIMESTAMPTZ NOT NULL,
107
+ UNIQUE (job_id, kind, marker)
108
+ );
109
+
110
+ CREATE TABLE IF NOT EXISTS shipyard_branch_leases (
111
+ resource_key TEXT PRIMARY KEY,
112
+ lease_id TEXT NOT NULL UNIQUE,
113
+ repository TEXT NOT NULL,
114
+ branch TEXT NOT NULL,
115
+ job_id TEXT NOT NULL REFERENCES shipyard_jobs(id),
116
+ worker_id TEXT NOT NULL,
117
+ fencing_token BIGINT NOT NULL,
118
+ acquired_at BIGINT NOT NULL,
119
+ heartbeat_at BIGINT NOT NULL,
120
+ expires_at BIGINT NOT NULL
121
+ );
122
+
123
+ CREATE UNIQUE INDEX IF NOT EXISTS shipyard_branch_leases_branch_idx
124
+ ON shipyard_branch_leases (repository, branch);
125
+
126
+ CREATE TABLE IF NOT EXISTS shipyard_repository_controls (
127
+ repository TEXT PRIMARY KEY,
128
+ stopped BOOLEAN NOT NULL,
129
+ reason TEXT,
130
+ updated_at TIMESTAMPTZ NOT NULL
131
+ );
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@snappedly-tools/shipyard",
3
+ "version": "0.2.0",
4
+ "description": "Run AI coding agents in isolated sandboxes",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./sandboxes/docker": {
14
+ "import": "./dist/sandboxes/docker.js",
15
+ "types": "./dist/sandboxes/docker.d.ts"
16
+ },
17
+ "./sandboxes/vercel": {
18
+ "import": "./dist/sandboxes/vercel.js",
19
+ "types": "./dist/sandboxes/vercel.d.ts"
20
+ },
21
+ "./sandboxes/no-sandbox": {
22
+ "import": "./dist/sandboxes/no-sandbox.js",
23
+ "types": "./dist/sandboxes/no-sandbox.d.ts"
24
+ }
25
+ },
26
+ "bin": {
27
+ "shipyard": "dist/main.js"
28
+ },
29
+ "scripts": {
30
+ "build": "tsup",
31
+ "postbuild": "rm -rf dist/templates && cp -r src/templates dist/templates && mkdir -p dist/workflow/coordinator/migrations && cp -r src/workflow/coordinator/migrations/*.sql dist/workflow/coordinator/migrations/ && node scripts/check-public-types-effect-free.mjs",
32
+ "test": "vitest run",
33
+ "test:watch": "vitest",
34
+ "version-packages": "changeset version",
35
+ "typecheck": "tsgo --noEmit",
36
+ "format": "prettier --write .",
37
+ "format:check": "prettier --check .",
38
+ "check": "npm run format:check && npm run typecheck && npm run build && npm test",
39
+ "prepare": "husky",
40
+ "shipyard": "npm run build && tsx .shipyard/run.ts"
41
+ },
42
+ "keywords": [
43
+ "cli",
44
+ "sandbox",
45
+ "docker",
46
+ "ai",
47
+ "agent"
48
+ ],
49
+ "packageManager": "npm@12.0.2",
50
+ "engines": {
51
+ "node": ">=18"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/snappedly/shipyard.git"
56
+ },
57
+ "homepage": "https://github.com/snappedly/shipyard#readme",
58
+ "bugs": {
59
+ "url": "https://github.com/snappedly/shipyard/issues"
60
+ },
61
+ "author": "Snappedly",
62
+ "license": "SEE LICENSE IN LICENSE",
63
+ "publishConfig": {
64
+ "access": "public",
65
+ "provenance": true
66
+ },
67
+ "devDependencies": {
68
+ "@changesets/cli": "^3.0.3",
69
+ "@effect/cli": "^0.77.2",
70
+ "@effect/platform": "^0.97.2",
71
+ "@effect/platform-node": "^0.108.2",
72
+ "@effect/printer": "^0.51.0",
73
+ "@effect/printer-ansi": "^0.51.0",
74
+ "@types/node": "^26.6.1",
75
+ "@typescript/native-preview": "^7.0.0-dev.20260707.2",
76
+ "effect": "^3.22.2",
77
+ "husky": "^9.1.7",
78
+ "lint-staged": "^17.5.1",
79
+ "prettier": "~3.8.1",
80
+ "tsup": "^8.5.1",
81
+ "typescript": "^6.0.3",
82
+ "vitest": "^5.0.1",
83
+ "zod": "^4.6.5"
84
+ },
85
+ "dependencies": {
86
+ "@clack/prompts": "^1.8.1",
87
+ "tsx": "^4.23.13"
88
+ },
89
+ "peerDependencies": {
90
+ "@vercel/sandbox": ">=1.0.0"
91
+ },
92
+ "peerDependenciesMeta": {
93
+ "@vercel/sandbox": {
94
+ "optional": true
95
+ }
96
+ },
97
+ "files": [
98
+ "dist",
99
+ "LICENSE",
100
+ "NOTICE"
101
+ ],
102
+ "private": false
103
+ }