@schoolai/shipyard-mcp 0.1.0-next.433
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.
- package/LICENSE.md +105 -0
- package/README.md +221 -0
- package/apps/hook/README.md +273 -0
- package/apps/hook/dist/index.js +3078 -0
- package/apps/server/.env.example +20 -0
- package/apps/server/dist/chunk-7GPZDCWI.js +158 -0
- package/apps/server/dist/chunk-EBNL5ZX7.js +120 -0
- package/apps/server/dist/chunk-GSGLHRWX.js +62 -0
- package/apps/server/dist/chunk-JSBRDJBE.js +30 -0
- package/apps/server/dist/chunk-LTC26IRQ.js +2930 -0
- package/apps/server/dist/chunk-N44DCU4J.js +284 -0
- package/apps/server/dist/dist-LQBXUHLR.js +409 -0
- package/apps/server/dist/index.js +5450 -0
- package/apps/server/dist/input-request-manager-MVKPYLFW.js +9 -0
- package/apps/server/dist/server-identity-KUXYHULN.js +10 -0
- package/apps/server/dist/session-registry-DMV543RG.js +40 -0
- package/package.json +74 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright ${year} ${licensor name}
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="apps/web/public/icon.svg" alt="Shipyard Logo" width="120" height="120">
|
|
3
|
+
<h1>Shipyard</h1>
|
|
4
|
+
<p><strong>Verify AI agent work with collaborative review and proof-of-work artifacts</strong></p>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://github.com/SchoolAI/shipyard/actions"><img src="https://img.shields.io/github/actions/workflow/status/SchoolAI/shipyard/deploy.yml?branch=main&label=deploy" alt="Deploy Status"></a>
|
|
8
|
+
<img src="https://img.shields.io/badge/TypeScript-5.6-3178C6?logo=typescript&logoColor=white" alt="TypeScript">
|
|
9
|
+
<img src="https://img.shields.io/badge/pnpm-10.x-F69220?logo=pnpm&logoColor=white" alt="pnpm">
|
|
10
|
+
<a href="./LICENSE.md"><img src="https://img.shields.io/badge/license-FSL--1.1-blue" alt="License"></a>
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## The Problem
|
|
17
|
+
|
|
18
|
+
AI agents can generate implementation tasks, but there's no good way to:
|
|
19
|
+
- **Verify** the agent actually did what it claimed
|
|
20
|
+
- **Review** tasks collaboratively with humans in real-time
|
|
21
|
+
- **Provide feedback** that agents can act on
|
|
22
|
+
|
|
23
|
+
Shipyard solves this with P2P collaborative review and proof-of-work artifacts.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **Real-time collaboration** — Multiple reviewers sync via WebRTC, no server required
|
|
28
|
+
- **Proof-of-work artifacts** — Screenshots, videos, test results stored in GitHub
|
|
29
|
+
- **MCP integration** — Works with Claude Code, Cursor, and any MCP-compatible agent
|
|
30
|
+
- **Zero infrastructure** — GitHub Pages + local MCP server, no paid services
|
|
31
|
+
- **BlockNote editor** — Notion-like editing with inline comments and threads
|
|
32
|
+
- **Offline-first** — IndexedDB persistence, works without network
|
|
33
|
+
|
|
34
|
+
## Platform Support
|
|
35
|
+
|
|
36
|
+
| Platform | Status | Installation | Notes |
|
|
37
|
+
|----------|--------|--------------|-------|
|
|
38
|
+
| **Claude Code** | ✅ Full support | GitHub plugin | Complete integration with hooks + skills |
|
|
39
|
+
| **OpenCode** | ⚠️ Experimental | npm + config | Native plan mode, testing in progress |
|
|
40
|
+
| **Cursor** | ⚠️ MCP only | npm + config | Works via MCP tools, manual workflow |
|
|
41
|
+
| **Windsurf** | ⚠️ MCP only | npm + config | Works via MCP tools, testing needed |
|
|
42
|
+
| **Devin** | ⚠️ MCP only | npm + config | API-only mode has limitations |
|
|
43
|
+
| **Replit Agent** | ⚠️ MCP only | npm + config | Basic functionality |
|
|
44
|
+
| **GitHub Copilot** | ⚠️ MCP only | npm + config | Basic functionality |
|
|
45
|
+
| **Gemini Code Assist** | ⚠️ MCP only | npm + config | Basic functionality |
|
|
46
|
+
| **Codex (OpenAI)** | ❓ Research needed | TBD | Feature completeness assessment in progress |
|
|
47
|
+
|
|
48
|
+
**Key:** Only Claude Code provides the full experience with automatic plan creation and approval workflows. Other platforms work via manual MCP tool invocation.
|
|
49
|
+
|
|
50
|
+
See [Platform Compatibility Matrix](./docs/INSTALLATION.md#platform-compatibility-matrix) for detailed feature comparison.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
### For Claude Code Users
|
|
55
|
+
|
|
56
|
+
Install the complete Shipyard plugin (MCP server + hooks + skills):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Step 1: Add the marketplace
|
|
60
|
+
/plugin marketplace add SchoolAI/shipyard
|
|
61
|
+
|
|
62
|
+
# Step 2: Install the plugin
|
|
63
|
+
/plugin install shipyard@schoolai-shipyard
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> **Note:** Claude Code requires adding a marketplace before installing plugins from it. This is intentional design (similar to app stores).
|
|
67
|
+
|
|
68
|
+
**Enable auto-updates:** After installing, run `/plugin` → Marketplaces tab → select `schoolai-shipyard` → "Enable auto-update" to receive updates automatically.
|
|
69
|
+
|
|
70
|
+
<details>
|
|
71
|
+
<summary>Troubleshooting: If Step 1 fails with a cache error</summary>
|
|
72
|
+
|
|
73
|
+
There's a known Claude Code bug (#14696) with case-sensitive GitHub org names. Try the full git URL instead:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
/plugin marketplace add https://github.com/SchoolAI/shipyard.git
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If that stalls, start a fresh Claude Code session and try again.
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
This gives you:
|
|
83
|
+
- ✅ MCP tools for creating and managing plans
|
|
84
|
+
- ✅ Automatic hooks for plan creation workflow
|
|
85
|
+
- ✅ Skills for collaborative planning
|
|
86
|
+
|
|
87
|
+
### For Other Platforms (Cursor, Windsurf, Replit, etc.)
|
|
88
|
+
|
|
89
|
+
Install the MCP server via npm:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx @schoolai/shipyard-mcp mcp-server-shipyard
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Then configure in your platform's MCP settings:
|
|
96
|
+
|
|
97
|
+
**Cursor** (`~/.cursor/mcp.json`):
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"shipyard": {
|
|
102
|
+
"command": "npx",
|
|
103
|
+
"args": ["-y", "@schoolai/shipyard-mcp", "mcp-server-shipyard"]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Windsurf** (`~/.windsurf/settings.json`):
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcp.servers": {
|
|
113
|
+
"shipyard": {
|
|
114
|
+
"command": "npx @schoolai/shipyard-mcp mcp-server-shipyard"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
See **[docs/INSTALLATION.md](./docs/INSTALLATION.md)** for comprehensive platform-specific guides.
|
|
121
|
+
|
|
122
|
+
### For Development
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Clone and install
|
|
126
|
+
git clone https://github.com/SchoolAI/shipyard.git
|
|
127
|
+
cd shipyard
|
|
128
|
+
pnpm install
|
|
129
|
+
|
|
130
|
+
# Start all services
|
|
131
|
+
pnpm dev:all
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Important:** Do NOT install the `shipyard` plugin if you're developing this repo. The plugin is for end users only. Local hooks/skills/MCP are always used from the project directory.
|
|
135
|
+
|
|
136
|
+
See **[SETUP.md](./docs/SETUP.md)** for full development setup.
|
|
137
|
+
|
|
138
|
+
## How It Works
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
┌─────────────────┐ MCP ┌─────────────────┐
|
|
142
|
+
│ AI Agent │─────────────►│ MCP Server │
|
|
143
|
+
│ (Claude, etc.) │ │ (localhost) │
|
|
144
|
+
└─────────────────┘ └────────┬────────┘
|
|
145
|
+
│ WebSocket
|
|
146
|
+
▼
|
|
147
|
+
┌─────────────────┐ WebRTC ┌─────────────────┐
|
|
148
|
+
│ Remote Reviewer │◄───────────►│ Author Browser │
|
|
149
|
+
│ Browser │ (P2P) │ │
|
|
150
|
+
└─────────────────┘ └─────────────────┘
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
1. Agent creates a task via MCP tool → Browser opens automatically
|
|
154
|
+
2. Reviewers join via shared URL → Real-time P2P sync
|
|
155
|
+
3. Add comments, approve, or request changes → Agent sees feedback
|
|
156
|
+
4. Agent uploads artifacts (screenshots, etc.) → Stored in GitHub
|
|
157
|
+
|
|
158
|
+
## Packages
|
|
159
|
+
|
|
160
|
+
| Package | Description |
|
|
161
|
+
|---------|-------------|
|
|
162
|
+
| [`@shipyard/server`](./apps/server) | MCP server with task tools |
|
|
163
|
+
| [`@shipyard/web`](./apps/web) | React app with BlockNote editor |
|
|
164
|
+
| [`@shipyard/schema`](./packages/schema) | Shared types, Yjs helpers, URL encoding |
|
|
165
|
+
| [`@shipyard/signaling`](./apps/signaling) | WebRTC signaling server (Cloudflare Worker) |
|
|
166
|
+
| [`@shipyard/hook`](./apps/hook) | Claude Code hooks for auto-task creation |
|
|
167
|
+
|
|
168
|
+
## Documentation
|
|
169
|
+
|
|
170
|
+
| Doc | Description |
|
|
171
|
+
|-----|-------------|
|
|
172
|
+
| [SETUP.md](./docs/SETUP.md) | Installation, configuration, troubleshooting |
|
|
173
|
+
| [BRIEF.md](./docs/BRIEF.md) | 30-second project context |
|
|
174
|
+
| [architecture.md](./docs/architecture.md) | Data model, sync topology, tech choices |
|
|
175
|
+
| [milestones/](./docs/milestones/) | Implementation phases and progress |
|
|
176
|
+
|
|
177
|
+
## Why "Shipyard"?
|
|
178
|
+
|
|
179
|
+
The name captures two ideas:
|
|
180
|
+
1. **Workspace metaphor** — A shipyard is where work is built
|
|
181
|
+
2. **Dev culture** — "Shipping" is how developers talk about delivering value
|
|
182
|
+
|
|
183
|
+
The Penrose triangle logo represents the "impossible triangle" of AI development: **quality**, **speed**, and **low effort**. Traditionally you sacrifice one. Shipyard enables all three through collaborative verification loops.
|
|
184
|
+
|
|
185
|
+
> *See [ADR-0005](./docs/decisions/0005-rebrand-peer-plan-to-shipyard.md) for the full naming rationale.*
|
|
186
|
+
|
|
187
|
+
## Claude Cowork Integration
|
|
188
|
+
|
|
189
|
+
Use Shipyard with Claude Cowork via the included skill:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
skills/shipyard/
|
|
193
|
+
├── SKILL.md # Instructions for Claude
|
|
194
|
+
├── README.md # Setup guide
|
|
195
|
+
└── examples/ # Usage examples
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
See [skills/shipyard/README.md](./skills/shipyard/README.md) for setup.
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
We welcome contributions! Please read the codebase first:
|
|
203
|
+
|
|
204
|
+
1. [BRIEF.md](./docs/BRIEF.md) — Understand the project
|
|
205
|
+
2. [engineering-standards.md](./docs/engineering-standards.md) — Code quality expectations
|
|
206
|
+
3. [architecture.md](./docs/architecture.md) — How it all fits together
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
[FSL-1.1-ALv2](./LICENSE.md) (Functional Source License)
|
|
211
|
+
|
|
212
|
+
- **Free** for all non-competing use
|
|
213
|
+
- **Converts to Apache 2.0** automatically in 2 years
|
|
214
|
+
|
|
215
|
+
We chose this to ensure that all core improvements help grow this main repository while keeping it free for developers.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
<div align="center">
|
|
220
|
+
<sub>Built with Yjs, BlockNote, and the MCP protocol</sub>
|
|
221
|
+
</div>
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
// TODO: Convert to a runbook
|
|
2
|
+
|
|
3
|
+
# @shipyard/hook
|
|
4
|
+
|
|
5
|
+
Claude Code integration hook for shipyard. Automatically creates and syncs plans when agents enter plan mode.
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
This hook intercepts Claude Code events and bridges them to the shipyard system:
|
|
10
|
+
|
|
11
|
+
1. **EnterPlanMode** → Creates plan, opens browser, sets "Claude is here" presence
|
|
12
|
+
2. **Write/Edit** (in plan mode) → Syncs content in real-time
|
|
13
|
+
3. **ExitPlanMode** → Blocks until human reviews and approves
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### Prerequisites
|
|
18
|
+
|
|
19
|
+
- Node.js 22+ (LTS)
|
|
20
|
+
- shipyard MCP server running (`@shipyard/server`)
|
|
21
|
+
|
|
22
|
+
### Option 1: npm Global Install (Recommended for Users)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g @shipyard/hook
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The postinstall script automatically configures Claude Code hooks in `~/.claude/settings.json`. Just restart Claude Code after installation.
|
|
29
|
+
|
|
30
|
+
If the automatic setup didn't work, you can manually run:
|
|
31
|
+
```bash
|
|
32
|
+
shipyard-hook-install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Option 2: Plugin Directory (Testing/Development)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Build the hook first
|
|
39
|
+
cd /path/to/shipyard
|
|
40
|
+
pnpm build
|
|
41
|
+
|
|
42
|
+
# Run Claude Code with explicit plugin directory
|
|
43
|
+
claude --plugin-dir ./apps/hook
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This loads the plugin without global installation - useful for testing.
|
|
47
|
+
|
|
48
|
+
### Option 3: Local Development
|
|
49
|
+
|
|
50
|
+
For active development on shipyard itself:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cd /path/to/shipyard
|
|
54
|
+
|
|
55
|
+
# One-time: Create global symlink
|
|
56
|
+
pnpm --filter @shipyard/hook dev:link
|
|
57
|
+
|
|
58
|
+
# Run in watch mode (rebuilds on changes)
|
|
59
|
+
pnpm --filter @shipyard/hook dev
|
|
60
|
+
|
|
61
|
+
# The hooks.json expects "shipyard-hook" in PATH
|
|
62
|
+
# pnpm link --global creates this symlink automatically
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Option 4: Manual Configuration
|
|
66
|
+
|
|
67
|
+
If you prefer manual setup, add to `~/.claude/settings.json`:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"hooks": {
|
|
72
|
+
"PermissionRequest": [
|
|
73
|
+
{
|
|
74
|
+
"matcher": "ExitPlanMode",
|
|
75
|
+
"hooks": [{ "type": "command", "command": "shipyard-hook", "timeout": 1800 }]
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"PostToolUse": [
|
|
79
|
+
{
|
|
80
|
+
"matcher": "ExitPlanMode",
|
|
81
|
+
"hooks": [{ "type": "command", "command": "shipyard-hook" }]
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"SessionStart": [
|
|
85
|
+
{
|
|
86
|
+
"hooks": [{ "type": "command", "command": "shipyard-hook --context" }]
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Configuration (Automatic)
|
|
94
|
+
|
|
95
|
+
The install script adds this to `~/.claude/settings.json`:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"hooks": {
|
|
100
|
+
"PreToolUse": [
|
|
101
|
+
{
|
|
102
|
+
"matcher": "*",
|
|
103
|
+
"hooks": [
|
|
104
|
+
{
|
|
105
|
+
"type": "command",
|
|
106
|
+
"command": "shipyard-hook"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"PermissionRequest": [
|
|
112
|
+
{
|
|
113
|
+
"matcher": "ExitPlanMode",
|
|
114
|
+
"hooks": [
|
|
115
|
+
{
|
|
116
|
+
"type": "command",
|
|
117
|
+
"command": "shipyard-hook",
|
|
118
|
+
"timeout": 1800
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Note:** The `matcher: "*"` matches ALL tools, but the hook only acts on plan mode events (checked internally). This ensures Write/Edit trigger the hook while avoiding unnecessary overhead in non-plan modes.
|
|
128
|
+
|
|
129
|
+
## Local Testing
|
|
130
|
+
|
|
131
|
+
### 1. Start the shipyard stack
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
cd /path/to/shipyard
|
|
135
|
+
|
|
136
|
+
# Terminal 1: Start MCP server (includes registry + WebSocket)
|
|
137
|
+
pnpm dev:server
|
|
138
|
+
|
|
139
|
+
# Terminal 2: Start web UI
|
|
140
|
+
pnpm dev:web
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 2. Build the hook
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pnpm --filter @shipyard/hook build
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 3. Run the test harness
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
cd apps/hook/test
|
|
153
|
+
./test-harness.sh
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This simulates the full hook lifecycle:
|
|
157
|
+
- Creates a plan (simulates EnterPlanMode)
|
|
158
|
+
- Updates content (simulates Write)
|
|
159
|
+
- Edits content (simulates Edit)
|
|
160
|
+
- Tries to exit (simulates ExitPlanMode - should block)
|
|
161
|
+
- Tests passthrough (non-plan mode)
|
|
162
|
+
|
|
163
|
+
### 4. Manual Testing with Real Claude Code
|
|
164
|
+
|
|
165
|
+
1. Configure the hook in your Claude Code settings (see Configuration above)
|
|
166
|
+
2. Restart Claude Code: `/quit` then relaunch
|
|
167
|
+
3. Enter plan mode: Press Shift+Tab or use `/mode plan`
|
|
168
|
+
4. Type something to trigger EnterPlanMode
|
|
169
|
+
5. Check that a browser tab opens with your plan
|
|
170
|
+
6. Write to the plan file - content should sync in real-time
|
|
171
|
+
7. Try to exit plan mode - should block until you approve in browser
|
|
172
|
+
|
|
173
|
+
### 5. Debug Logging
|
|
174
|
+
|
|
175
|
+
Enable debug logs to see hook execution:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
export LOG_LEVEL=debug
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The hook logs to stderr, so you can see them in Claude Code's debug output.
|
|
182
|
+
|
|
183
|
+
## State Management
|
|
184
|
+
|
|
185
|
+
The hook maintains session state at:
|
|
186
|
+
```
|
|
187
|
+
~/.shipyard/hook-state.json
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
This file maps session IDs to plan IDs. It's automatically cleaned up after 24 hours.
|
|
191
|
+
|
|
192
|
+
## Architecture
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
Claude Code → Hook CLI → HTTP API → Registry Server → Y.Doc
|
|
196
|
+
↓
|
|
197
|
+
State File
|
|
198
|
+
(~/.shipyard/hook-state.json)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Adapter Pattern
|
|
202
|
+
|
|
203
|
+
The hook uses an adapter pattern to support multiple agent systems:
|
|
204
|
+
|
|
205
|
+
- **Abstract Layer** (`src/adapters/types.ts`) - `AgentAdapter` interface
|
|
206
|
+
- **Claude Code Adapter** (`src/adapters/claude-code.ts`) - Implements Claude Code hook protocol
|
|
207
|
+
- **Future**: Open Agents adapter, custom agents, etc.
|
|
208
|
+
|
|
209
|
+
## Development
|
|
210
|
+
|
|
211
|
+
### Build
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
pnpm build
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Watch Mode
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
pnpm dev
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Type Check
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
pnpm typecheck
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Lint
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
pnpm lint
|
|
233
|
+
pnpm lint:fix
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Troubleshooting
|
|
237
|
+
|
|
238
|
+
### Hook not executing
|
|
239
|
+
|
|
240
|
+
1. Check Claude Code settings are correct
|
|
241
|
+
2. Restart Claude Code after changing settings
|
|
242
|
+
3. Check hook binary exists: `which shipyard-hook`
|
|
243
|
+
4. Check hook binary is executable: `ls -l $(which shipyard-hook)`
|
|
244
|
+
|
|
245
|
+
### Plan not appearing
|
|
246
|
+
|
|
247
|
+
1. Ensure registry server is running: `curl http://localhost:32191/registry`
|
|
248
|
+
2. Check browser console for errors
|
|
249
|
+
3. Check server logs: `LOG_LEVEL=debug pnpm dev:server`
|
|
250
|
+
|
|
251
|
+
### Changes not syncing
|
|
252
|
+
|
|
253
|
+
1. Check WebSocket connection in browser dev tools
|
|
254
|
+
2. Verify plan ID matches between hook state and browser URL
|
|
255
|
+
3. Check `~/.shipyard/hook-state.json` for session mapping
|
|
256
|
+
|
|
257
|
+
### Review not blocking exit
|
|
258
|
+
|
|
259
|
+
1. Check plan status in browser (should be "pending_review" or "changes_requested")
|
|
260
|
+
2. Manually trigger status update in UI
|
|
261
|
+
3. Check server logs for review status endpoint responses
|
|
262
|
+
|
|
263
|
+
## Environment Variables
|
|
264
|
+
|
|
265
|
+
| Variable | Default | Description |
|
|
266
|
+
|----------|---------|-------------|
|
|
267
|
+
| `REGISTRY_PORT` | `32191,32192` | Registry server port |
|
|
268
|
+
| `LOG_LEVEL` | `info` | Log level (debug, info, warn, error) |
|
|
269
|
+
| `SHIPYARD_STATE_DIR` | `~/.shipyard` | State directory |
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT
|