dear-claude 1.0.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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +605 -0
  3. package/dist/index.js +32747 -0
  4. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shantanu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,605 @@
1
+ <p align="center">
2
+ <img src="assets/marketing/hero-poster.png" alt="Dear Claude - Just say Dear Claude" width="500">
3
+ </p>
4
+
5
+ <h1 align="center">Dear Claude</h1>
6
+
7
+ <p align="center">
8
+ <strong>MCP server that triggers local Claude Code instances from external platforms.</strong><br>
9
+ Say "Dear Claude" in Linear, GitHub, Jira, GitLab, Notion, Obsidian, or Gmail — and a Claude Code instance spins up to handle it.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <em>Your notes become architecture. Your tasks become pull requests.</em>
14
+ </p>
15
+
16
+ ---
17
+
18
+ ## What is this?
19
+
20
+ Dear Claude is an MCP (Model Context Protocol) server that watches your project management tools for the phrase **"Dear Claude"**. When detected, it spawns a local Claude Code instance that:
21
+
22
+ - Reads the issue/comment/note context
23
+ - Executes the requested task (code, review, create tasks, etc.)
24
+ - Posts results back to the originating platform
25
+ - Persists sessions for 7 days so you can have multi-turn conversations
26
+
27
+ **No Anthropic API keys needed.** Works with your existing Claude Code subscription. 100% local and private — your code never leaves your machine.
28
+
29
+ ## Supported Platforms
30
+
31
+ | Platform | Trigger on issue/PR | Trigger on comment | Comment back | Emoji reactions | Sub-tasks | PR/MR review |
32
+ |----------|:------------------:|:-----------------:|:------------:|:--------------:|:---------:|:------------:|
33
+ | GitHub | Yes | Yes | Yes | Yes | - | Yes |
34
+ | Linear | Yes | Yes | Yes | Yes | Yes | - |
35
+ | Jira | Yes | Yes | Yes | - | Yes | - |
36
+ | GitLab | Yes | Yes | Yes | Yes | - | Yes |
37
+ | Notion | Yes | Yes | Yes | - | - | - |
38
+ | Obsidian | Yes | - | Yes | - | - | - |
39
+ | Gmail | Yes | - | Yes | - | - | - |
40
+
41
+ ## Cross-Platform Orchestration
42
+
43
+ Instances from **any** platform get API access to **all** configured platforms. This enables workflows like:
44
+
45
+ 1. Write a spec in **Obsidian** → "Dear Claude, create these tasks in Linear"
46
+ 2. Discuss on **Linear** → "Dear Claude, code this on GitHub"
47
+ 3. Review on **GitHub** → "Dear Claude, resolve the merge conflicts"
48
+ 4. **Parallel coding** → Claude spawns multiple instances, one per branch, using git worktrees
49
+
50
+ ## Quick Start
51
+
52
+ ### Prerequisites
53
+
54
+ - [Bun](https://bun.sh) runtime
55
+ - [Claude Code](https://claude.ai/claude-code) CLI installed (`claude` command available)
56
+ - [Tailscale](https://tailscale.com/download) with Funnel enabled (for webhooks from external platforms)
57
+
58
+ ### 1. Install
59
+
60
+ ```bash
61
+ bun install
62
+ ```
63
+
64
+ ### 2. Add to Claude Code as MCP Server
65
+
66
+ Add to `~/.claude.json` under `mcpServers`:
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "dear-claude": {
72
+ "command": "bun",
73
+ "args": ["run", "/path/to/dear-claude/src/index.ts", "start", "--mcp"],
74
+ "env": {
75
+ "DEAR_CLAUDE_PORT": "3334",
76
+ "GITHUB_CLIENT_ID": "...",
77
+ "GITHUB_CLIENT_SECRET": "...",
78
+ "GITHUB_WEBHOOK_SECRET": "...",
79
+ "LINEAR_CLIENT_ID": "...",
80
+ "LINEAR_CLIENT_SECRET": "...",
81
+ "LINEAR_WEBHOOK_SECRET": "..."
82
+ }
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### 3. Start Claude Code
89
+
90
+ ```bash
91
+ claude
92
+ ```
93
+
94
+ The MCP server starts automatically, sets up Tailscale Funnel, and prints your public webhook URLs.
95
+
96
+ ---
97
+
98
+ ## Platform Setup
99
+
100
+ ### Tailscale Funnel
101
+
102
+ Dear Claude uses [Tailscale Funnel](https://tailscale.com/kb/1223/funnel) for stable public HTTPS URLs to receive webhooks. Setup is mostly automatic.
103
+
104
+ 1. **Install Tailscale**:
105
+ ```bash
106
+ # macOS
107
+ brew install tailscale
108
+
109
+ # Linux
110
+ curl -fsSL https://tailscale.com/install.sh | sh
111
+ ```
112
+
113
+ 2. **Authenticate**: `tailscale up`
114
+
115
+ 3. **Enable Funnel** in the admin console: https://login.tailscale.com/admin/acls
116
+ - Add the `"funnel"` capability to your ACL policy
117
+
118
+ 4. The server auto-configures Funnel on startup. Your public URL will be:
119
+ ```
120
+ https://<your-hostname>.ts.net/dc
121
+ ```
122
+
123
+ > **Tip**: Run `tailscale serve status --json` to verify your config. The health check auto-repairs the Funnel config every 10 seconds.
124
+
125
+ ---
126
+
127
+ ### GitHub
128
+
129
+ #### Option A: GitHub App (recommended)
130
+
131
+ 1. Go to **GitHub Settings** → **Developer settings** → **GitHub Apps** → **New GitHub App**
132
+ 2. Set these fields:
133
+ - **Homepage URL**: `https://<your-hostname>.ts.net/dc`
134
+ - **Callback URL**: `https://<your-hostname>.ts.net/dc/oauth/callback/github`
135
+ - **Webhook URL**: `https://<your-hostname>.ts.net/dc/webhook/github`
136
+ - **Webhook secret**: generate a random string
137
+ 3. Under **Permissions**:
138
+ - Repository: Issues (Read & Write), Pull Requests (Read & Write), Contents (Read & Write)
139
+ 4. Under **Subscribe to events**:
140
+ - Issue comments, Pull request review comments
141
+ 5. Copy credentials and set env vars:
142
+ ```bash
143
+ GITHUB_CLIENT_ID=Iv1.abc123...
144
+ GITHUB_CLIENT_SECRET=abc123...
145
+ GITHUB_WEBHOOK_SECRET=your-webhook-secret
146
+ ```
147
+ 6. Install the app on your repos
148
+ 7. Complete OAuth: visit `https://<your-hostname>.ts.net/dc/setup/github`
149
+
150
+ #### Option B: Personal Access Token (simpler, no webhooks)
151
+
152
+ 1. Go to **GitHub Settings** → **Developer settings** → **Personal access tokens** → **Tokens (classic)**
153
+ 2. Create a token with scopes: `repo`, `write:discussion`
154
+ 3. Set: `GITHUB_ACCESS_TOKEN=ghp_...`
155
+
156
+ > **Note**: With a PAT alone you won't get webhook-triggered instances. You'd use the `spawn_instance` MCP tool or `/api/spawn` endpoint instead.
157
+
158
+ | Environment Variable | Description |
159
+ |---------------------|-------------|
160
+ | `GITHUB_CLIENT_ID` | GitHub App client ID |
161
+ | `GITHUB_CLIENT_SECRET` | GitHub App client secret |
162
+ | `GITHUB_WEBHOOK_SECRET` | Webhook signature verification secret |
163
+ | `GITHUB_ACCESS_TOKEN` | Personal access token (alternative to OAuth) |
164
+
165
+ ---
166
+
167
+ ### Linear
168
+
169
+ 1. Go to **Linear Settings** → **API** → **OAuth Applications** → **New Application**
170
+ 2. Set the callback URL: `https://<your-hostname>.ts.net/dc/oauth/callback/linear`
171
+ 3. Copy **Client ID** and **Client Secret**
172
+ 4. Enable the **Webhooks** toggle on the OAuth app
173
+ 5. Go to **Linear Settings** → **API** → **Webhooks** → **New Webhook**:
174
+ - URL: `https://<your-hostname>.ts.net/dc/webhook/linear`
175
+ - Copy the **Signing Secret**
176
+ - Enable events: **Comments** (create), **Issues** (create, update)
177
+ 6. Set env vars:
178
+ ```bash
179
+ LINEAR_CLIENT_ID=your-client-id
180
+ LINEAR_CLIENT_SECRET=your-client-secret
181
+ LINEAR_WEBHOOK_SECRET=your-signing-secret
182
+ ```
183
+ 7. Complete OAuth: visit `https://<your-hostname>.ts.net/dc/setup/linear`
184
+
185
+ After OAuth, only issues/comments from your authenticated Linear account trigger Claude.
186
+
187
+ **Alternative**: Use a Personal API Key (`LINEAR_ACCESS_TOKEN=lin_api_...`) from Linear Settings → Account → API.
188
+
189
+ | Environment Variable | Description |
190
+ |---------------------|-------------|
191
+ | `LINEAR_CLIENT_ID` | OAuth client ID |
192
+ | `LINEAR_CLIENT_SECRET` | OAuth client secret |
193
+ | `LINEAR_WEBHOOK_SECRET` | Webhook signing secret |
194
+ | `LINEAR_ACCESS_TOKEN` | Personal API key (alternative to OAuth) |
195
+
196
+ ---
197
+
198
+ ### Jira Cloud
199
+
200
+ 1. **Create an API token** at https://id.atlassian.com/manage-profile/security/api-tokens
201
+ 2. Set env vars:
202
+ ```bash
203
+ JIRA_DOMAIN=mycompany # Your Jira subdomain (mycompany.atlassian.net)
204
+ JIRA_USER_EMAIL=you@example.com # Your Atlassian account email
205
+ JIRA_API_TOKEN=ATATT3x... # The API token you just created
206
+ JIRA_WEBHOOK_SECRET=optional-secret # Optional shared secret
207
+ ```
208
+ 3. **Create a webhook** in Jira:
209
+ - Go to **Jira Admin** → **System** → **Webhooks** → **Create webhook**
210
+ - URL: `https://<your-hostname>.ts.net/dc/webhook/jira`
211
+ - If using `JIRA_WEBHOOK_SECRET`, append it: `?secret=YOUR_SECRET`
212
+ - Select events: `issue_created`, `issue_updated`, `comment_created`
213
+ 4. Save the webhook
214
+
215
+ Claude can create sub-tasks, transition issue status, and add comments via the Jira REST API v2.
216
+
217
+ | Environment Variable | Description |
218
+ |---------------------|-------------|
219
+ | `JIRA_DOMAIN` | Jira subdomain (e.g. `mycompany` for mycompany.atlassian.net) |
220
+ | `JIRA_USER_EMAIL` | Your Atlassian email |
221
+ | `JIRA_API_TOKEN` | API token from Atlassian |
222
+ | `JIRA_WEBHOOK_SECRET` | Optional shared secret for webhook verification |
223
+
224
+ ---
225
+
226
+ ### GitLab
227
+
228
+ 1. **Create a Personal Access Token** at GitLab → **Settings** → **Access Tokens**
229
+ - Scopes: `api`, `read_repository`, `write_repository`
230
+ 2. Set env vars:
231
+ ```bash
232
+ GITLAB_ACCESS_TOKEN=glpat-...
233
+ GITLAB_WEBHOOK_SECRET=your-secret
234
+ ```
235
+ 3. **Add a webhook** to your project (or group):
236
+ - Go to **Settings** → **Webhooks**
237
+ - URL: `https://<your-hostname>.ts.net/dc/webhook/gitlab`
238
+ - Secret token: same as `GITLAB_WEBHOOK_SECRET`
239
+ - Trigger events: **Comments**, **Issues events**, **Merge request events**
240
+ 4. Save
241
+
242
+ For self-hosted GitLab, also set `GITLAB_URL=https://your-gitlab-instance.com`.
243
+
244
+ | Environment Variable | Description |
245
+ |---------------------|-------------|
246
+ | `GITLAB_ACCESS_TOKEN` | Personal access token |
247
+ | `GITLAB_WEBHOOK_SECRET` | Webhook secret token |
248
+ | `GITLAB_URL` | GitLab instance URL (default: `https://gitlab.com`) |
249
+
250
+ ---
251
+
252
+ ### Notion
253
+
254
+ #### Option A: Internal Integration (simpler)
255
+
256
+ 1. Go to https://www.notion.so/my-integrations → **New integration**
257
+ 2. Give it a name, select your workspace
258
+ 3. Copy the **Internal Integration Secret**
259
+ 4. Set: `NOTION_ACCESS_TOKEN=ntn_...`
260
+ 5. **Share pages/databases** with the integration (click "..." on a page → Connections → Add your integration)
261
+
262
+ #### Option B: OAuth (public app)
263
+
264
+ 1. Create an OAuth integration at https://www.notion.so/my-integrations
265
+ 2. Set callback URL: `https://<your-hostname>.ts.net/dc/oauth/callback/notion`
266
+ 3. Set env vars:
267
+ ```bash
268
+ NOTION_CLIENT_ID=your-client-id
269
+ NOTION_CLIENT_SECRET=your-secret
270
+ ```
271
+ 4. Complete OAuth: visit `https://<your-hostname>.ts.net/dc/setup/notion`
272
+
273
+ #### Webhook setup
274
+
275
+ Notion doesn't have native webhooks yet. To trigger Claude from Notion:
276
+ - Use Notion's automation rules with a webhook action (if available)
277
+ - Or use a third-party service like Zapier/Make to POST to `https://<your-hostname>.ts.net/dc/webhook/notion`
278
+ - Set `NOTION_WEBHOOK_SECRET` if you want signature verification
279
+
280
+ | Environment Variable | Description |
281
+ |---------------------|-------------|
282
+ | `NOTION_ACCESS_TOKEN` | Internal integration token |
283
+ | `NOTION_CLIENT_ID` | OAuth client ID |
284
+ | `NOTION_CLIENT_SECRET` | OAuth client secret |
285
+ | `NOTION_WEBHOOK_SECRET` | Webhook verification secret |
286
+
287
+ ---
288
+
289
+ ### Obsidian
290
+
291
+ Obsidian integration works via **filesystem watching** — no webhooks needed. Claude watches your vault for files containing "Dear Claude" and responds by appending to the same file.
292
+
293
+ 1. Set env var with the absolute path to your vault:
294
+ ```bash
295
+ OBSIDIAN_VAULT_PATH=/Users/yourname/Documents/MyVault
296
+ ```
297
+ 2. That's it! Write "Dear Claude, ..." in any `.md` file and save.
298
+
299
+ Claude's response appears as a callout block appended to the same note. The frontmatter gets a `claude-status` field (`processing` → `done` / `error`).
300
+
301
+ **How it works**:
302
+ - Watches for `.md` file changes in the vault
303
+ - Ignores files in `.obsidian/`, `.trash/`, and dotfile directories
304
+ - 2-second debounce to avoid triggering on every keystroke
305
+ - Supports wikilink references (`[[other-note]]`) — Claude resolves and reads them
306
+ - Supports embedded images — Claude can see and analyze them
307
+
308
+ | Environment Variable | Description |
309
+ |---------------------|-------------|
310
+ | `OBSIDIAN_VAULT_PATH` | Absolute path to your Obsidian vault |
311
+ | `OBSIDIAN_WATCH_DEBOUNCE_MS` | Debounce delay in ms (default: `2000`) |
312
+
313
+ ---
314
+
315
+ ### Gmail
316
+
317
+ 1. **Create OAuth credentials** in [Google Cloud Console](https://console.cloud.google.com/apis/credentials):
318
+ - Create a project (or use existing)
319
+ - Enable the **Gmail API**
320
+ - Create **OAuth 2.0 Client ID** (Web application type)
321
+ - Add authorized redirect URI: `https://<your-hostname>.ts.net/dc/oauth/callback/gmail`
322
+ 2. Set env vars:
323
+ ```bash
324
+ GOOGLE_CLIENT_ID=123456789-abc.apps.googleusercontent.com
325
+ GOOGLE_CLIENT_SECRET=GOCSPX-...
326
+ ```
327
+ 3. **(Optional) Set up Pub/Sub** for real-time push notifications:
328
+ - Create a Pub/Sub topic in Google Cloud Console
329
+ - Set: `GOOGLE_PUBSUB_TOPIC=projects/your-project/topics/your-topic`
330
+ 4. Complete OAuth: visit `https://<your-hostname>.ts.net/dc/setup/gmail`
331
+
332
+ | Environment Variable | Description |
333
+ |---------------------|-------------|
334
+ | `GOOGLE_CLIENT_ID` | OAuth client ID |
335
+ | `GOOGLE_CLIENT_SECRET` | OAuth client secret |
336
+ | `GOOGLE_ACCESS_TOKEN` | Access token (skip OAuth) |
337
+ | `GOOGLE_REFRESH_TOKEN` | Refresh token |
338
+ | `GOOGLE_PUBSUB_TOPIC` | Pub/Sub topic for push notifications |
339
+
340
+ ---
341
+
342
+ ## Usage
343
+
344
+ ### Trigger Format
345
+
346
+ Write **"Dear Claude"** (case-insensitive, with a space) anywhere in:
347
+ - GitHub issue/PR comments
348
+ - Linear issue descriptions or comments
349
+ - Jira issue descriptions or comments
350
+ - GitLab issue/MR descriptions or comments
351
+ - Notion page comments
352
+ - Obsidian `.md` files
353
+ - Gmail emails
354
+
355
+ ### Example
356
+
357
+ **GitHub PR Comment:**
358
+ ```
359
+ Dear Claude, please review this code for bugs and security issues.
360
+ ```
361
+
362
+ **Claude responds on GitHub:**
363
+ > Claude Instance Started (Instance: `abc12345`)
364
+ > Processing your request...
365
+
366
+ > **Task Completed**
367
+ > Found 2 issues:
368
+ > 1. SQL injection in `user.ts:45`
369
+ > 2. Missing input validation in `api.ts:102`
370
+ >
371
+ > Created PR #15 with fixes.
372
+
373
+ ### Instance Orchestration
374
+
375
+ Claude instances can **spawn other instances** for parallel work:
376
+
377
+ ```
378
+ Dear Claude, code tasks 1-5 in parallel. Each task should be a separate branch.
379
+ ```
380
+
381
+ Claude will:
382
+ 1. Parse the tasks
383
+ 2. Spawn 5 child instances via the `/api/spawn` endpoint
384
+ 3. Each child works in its own git worktree (same repo, different branch)
385
+ 4. Each child creates a PR when done
386
+ 5. Parent polls child statuses
387
+
388
+ ---
389
+
390
+ ## All Environment Variables
391
+
392
+ ```bash
393
+ # Server
394
+ DEAR_CLAUDE_PORT=3334
395
+ TAILSCALE_HOSTNAME= # Optional: auto-detected
396
+
397
+ # GitHub
398
+ GITHUB_CLIENT_ID=
399
+ GITHUB_CLIENT_SECRET=
400
+ GITHUB_WEBHOOK_SECRET=
401
+ GITHUB_ACCESS_TOKEN=
402
+
403
+ # Linear
404
+ LINEAR_CLIENT_ID=
405
+ LINEAR_CLIENT_SECRET=
406
+ LINEAR_WEBHOOK_SECRET=
407
+ LINEAR_ACCESS_TOKEN=
408
+
409
+ # Jira Cloud
410
+ JIRA_DOMAIN=mycompany
411
+ JIRA_USER_EMAIL=you@example.com
412
+ JIRA_API_TOKEN=
413
+ JIRA_WEBHOOK_SECRET=
414
+
415
+ # GitLab
416
+ GITLAB_ACCESS_TOKEN=
417
+ GITLAB_WEBHOOK_SECRET=
418
+ GITLAB_URL= # Default: https://gitlab.com
419
+
420
+ # Notion
421
+ NOTION_CLIENT_ID=
422
+ NOTION_CLIENT_SECRET=
423
+ NOTION_WEBHOOK_SECRET=
424
+ NOTION_ACCESS_TOKEN=
425
+
426
+ # Obsidian
427
+ OBSIDIAN_VAULT_PATH=
428
+ OBSIDIAN_WATCH_DEBOUNCE_MS=2000
429
+
430
+ # Gmail/Google
431
+ GOOGLE_CLIENT_ID=
432
+ GOOGLE_CLIENT_SECRET=
433
+ GOOGLE_ACCESS_TOKEN=
434
+ GOOGLE_REFRESH_TOKEN=
435
+ GOOGLE_PUBSUB_TOPIC=
436
+
437
+ # Optional
438
+ GIPHY_API_KEY= # For fun GIF reactions in responses
439
+ ```
440
+
441
+ ## CLI Commands
442
+
443
+ ```bash
444
+ # Start the server (standalone mode)
445
+ bun run src/index.ts start
446
+
447
+ # Start as MCP server (stdio, for Claude Code)
448
+ bun run src/index.ts start --mcp
449
+
450
+ # Check server and platform status
451
+ bun run src/index.ts status
452
+
453
+ # List instances
454
+ bun run src/index.ts instances
455
+
456
+ # Setup instructions for a platform
457
+ bun run src/index.ts setup <platform>
458
+ ```
459
+
460
+ ## MCP Tools
461
+
462
+ When running as an MCP server inside Claude Code, these tools are available:
463
+
464
+ | Tool | Description |
465
+ |------|-------------|
466
+ | `list_platforms` | List configured platforms and their status |
467
+ | `list_instances` | List all Claude instances (filter by status) |
468
+ | `get_instance_status` | Get detailed status of a specific instance |
469
+ | `get_instance_messages` | Get conversation history for an instance |
470
+ | `kill_instance` | Terminate a running instance |
471
+ | `get_running_instances` | List currently running instance IDs |
472
+ | `spawn_instance` | Spawn a new Claude instance for a task |
473
+ | `get_project_instances` | List all instances in a project group |
474
+
475
+ ## HTTP API
476
+
477
+ The server also exposes REST endpoints on `localhost:3334`:
478
+
479
+ | Endpoint | Method | Description |
480
+ |----------|--------|-------------|
481
+ | `/health` | GET | Health check + platform status |
482
+ | `/webhook/:platform` | POST | Webhook receiver |
483
+ | `/api/instances` | GET | List instances (`?project_id=` filter) |
484
+ | `/api/instances/:id` | GET | Get instance details + children |
485
+ | `/api/instances/:id/kill` | POST | Kill a running instance |
486
+ | `/api/spawn` | POST | Spawn a new instance programmatically |
487
+ | `/api/platforms` | GET | List configured platforms |
488
+ | `/setup/:platform` | GET | Start OAuth flow |
489
+ | `/oauth/callback/:platform` | GET | OAuth callback |
490
+
491
+ ### POST /api/spawn
492
+
493
+ ```json
494
+ {
495
+ "prompt": "Implement the login page",
496
+ "repo_url": "https://github.com/owner/repo",
497
+ "branch": "feature/login",
498
+ "base_branch": "main",
499
+ "parent_instance_id": "optional-parent-id",
500
+ "project_id": "optional-project-id"
501
+ }
502
+ ```
503
+
504
+ ## Architecture
505
+
506
+ ```
507
+ Webhooks / File Watcher
508
+ ┌────────┐ ┌────────┐ ┌──────┐ ┌────────┐ ┌──────────┐ ┌──────┐
509
+ │ GitHub │ │ Linear │ │ Jira │ │ GitLab │ │ Obsidian │ │Gmail │
510
+ └───┬────┘ └───┬────┘ └──┬───┘ └───┬────┘ └────┬─────┘ └──┬───┘
511
+ │ │ │ │ │ │
512
+ └──────────┴────┬────┴─────────┴────────────┴───────────┘
513
+
514
+
515
+ ┌─────────────────────┐
516
+ │ Tailscale Funnel │
517
+ │ (Public HTTPS URL) │
518
+ └─────────┬───────────┘
519
+
520
+
521
+ ┌─────────────────────┐
522
+ │ dear-claude │
523
+ │ MCP Server │
524
+ │ │
525
+ │ • Trigger detection │
526
+ │ • Instance manager │
527
+ │ • Platform adapters │
528
+ │ • Spawn API │
529
+ │ • SQLite DB │
530
+ └─────────┬───────────┘
531
+
532
+
533
+ ┌─────────────────────┐
534
+ │ Claude Code │
535
+ │ Instances │
536
+ │ (Agent SDK) │
537
+ │ │
538
+ │ • Git worktrees │
539
+ │ • Cross-platform │
540
+ │ API access │
541
+ │ • Child spawning │
542
+ └─────────────────────┘
543
+ ```
544
+
545
+ ## Instance Lifecycle
546
+
547
+ ```
548
+ PENDING → RUNNING → IDLE → (follow-up) → RUNNING → IDLE → ... → EXPIRED (7 days)
549
+ ↘ COMPLETED
550
+ ↘ FAILED
551
+ ```
552
+
553
+ - **PENDING**: Trigger detected, instance queued
554
+ - **RUNNING**: Claude Code actively processing
555
+ - **IDLE**: Waiting for follow-up "Dear Claude" mentions
556
+ - **COMPLETED**: Task finished successfully
557
+ - **FAILED**: Error occurred
558
+ - **EXPIRED**: 7-day TTL exceeded, instance cleaned up
559
+
560
+ ## Development
561
+
562
+ ```bash
563
+ # Install dependencies
564
+ bun install
565
+
566
+ # Run dev mode
567
+ bun run dev
568
+
569
+ # Type check
570
+ bunx tsc --noEmit
571
+
572
+ # Build
573
+ bun run build
574
+
575
+ # Run tests
576
+ bun test
577
+ ```
578
+
579
+ ## Troubleshooting
580
+
581
+ ### Tailscale
582
+
583
+ - **"Tailscale not running"**: Open the Tailscale app (macOS) or `sudo systemctl start tailscaled && tailscale up` (Linux)
584
+ - **"Funnel not enabled"**: Visit https://login.tailscale.com/admin/acls and add Funnel capability
585
+ - **Funnel disappears**: Another `tailscale serve`/`tailscale funnel` command may have overwritten it. The health check auto-repairs within 10 seconds. Verify with `tailscale serve status --json`.
586
+
587
+ ### Webhooks
588
+
589
+ - **Not triggering**: Check `bun run src/index.ts status` to verify the server is up. Test with `curl https://<your-hostname>.ts.net/dc/health`.
590
+ - **"Invalid signature"**: Verify the webhook secret matches in both the platform config and your env vars.
591
+ - **GitHub**: The app subscribes to `issue_comment` events. To trigger on a new PR, post a comment — PR descriptions alone won't trigger.
592
+
593
+ ### OAuth
594
+
595
+ - **Token expired**: Re-visit `https://<your-hostname>.ts.net/dc/setup/<platform>` to re-authenticate.
596
+ - **401 errors**: The stored OAuth token may have been revoked. Delete the stale token from `data/dear-claude.db` and re-authenticate.
597
+
598
+ ### Instances
599
+
600
+ - **Stuck in PENDING**: Check that Claude Code CLI (`claude`) is installed and accessible in your PATH.
601
+ - **Working directory issues**: Instances create workspaces under `data/workspaces/`. Ensure write permissions.
602
+
603
+ ## License
604
+
605
+ MIT