panopticon-cli 0.1.3 → 0.1.6

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/README.md CHANGED
@@ -31,8 +31,8 @@ Panopticon is a unified orchestration layer for AI coding assistants. It works w
31
31
  # Install Panopticon
32
32
  npm install -g panopticon-cli
33
33
 
34
- # Initialize configuration
35
- pan init
34
+ # Install prerequisites and setup (includes optional HTTPS/Traefik)
35
+ pan install
36
36
 
37
37
  # Sync skills to all AI tools
38
38
  pan sync
@@ -41,12 +41,64 @@ pan sync
41
41
  pan doctor
42
42
  ```
43
43
 
44
+ ### HTTPS Setup (Optional)
45
+
46
+ Panopticon supports local HTTPS via Traefik reverse proxy:
47
+
48
+ ```bash
49
+ # Full install (includes Traefik + mkcert for HTTPS)
50
+ pan install
51
+
52
+ # Add to /etc/hosts (macOS/Linux)
53
+ echo "127.0.0.1 pan.localhost" | sudo tee -a /etc/hosts
54
+
55
+ # Start with HTTPS
56
+ pan up
57
+ # → Dashboard: https://pan.localhost
58
+ # → Traefik UI: https://traefik.pan.localhost:8080
59
+ ```
60
+
61
+ **Minimal install** (skip Traefik, use ports):
62
+ ```bash
63
+ pan install --minimal
64
+ pan up
65
+ # → Dashboard: http://localhost:3010
66
+ ```
67
+
68
+ See [docs/DNS_SETUP.md](docs/DNS_SETUP.md) for detailed DNS configuration (especially for WSL2).
69
+
70
+ ## Supported Platforms
71
+
72
+ | Platform | Support |
73
+ |----------|---------|
74
+ | **Linux** | Full support |
75
+ | **macOS** | Full support |
76
+ | **Windows** | WSL2 required |
77
+
78
+ > **Windows users:** Panopticon requires WSL2 (Windows Subsystem for Linux 2). Native Windows is not supported. [Install WSL2](https://docs.microsoft.com/en-us/windows/wsl/install)
79
+
44
80
  ## Requirements
45
81
 
82
+ ### Required
46
83
  - Node.js 18+
47
- - tmux (for agent sessions)
48
84
  - Git (for worktree-based workspaces)
49
- - Linear API key (for issue tracking)
85
+ - Docker (for Traefik and workspace containers)
86
+ - tmux (for agent sessions)
87
+ - **ttyd** - Web terminal for interactive planning sessions. Auto-installed by `pan install`.
88
+ - **GitHub CLI (`gh`)** - For GitHub integration (issues, PRs, merges). [Install](https://cli.github.com/)
89
+ - **GitLab CLI (`glab`)** - For GitLab integration (if using GitLab). [Install](https://gitlab.com/gitlab-org/cli)
90
+
91
+ ### Optional
92
+ - **mkcert** - For HTTPS certificates (recommended)
93
+ - **Linear API key** - For issue tracking integration
94
+ - **Beads CLI (bd)** - For persistent task tracking across sessions
95
+
96
+ ### Why CLI tools instead of API tokens?
97
+
98
+ Panopticon uses `gh` and `glab` CLIs instead of raw API tokens because:
99
+ - **Better auth**: OAuth tokens that auto-refresh (no expiring PATs)
100
+ - **Simpler setup**: `gh auth login` handles everything
101
+ - **Agent-friendly**: Agents can use them for PRs, merges, reviews
50
102
 
51
103
  ## Configuration
52
104
 
@@ -54,9 +106,44 @@ Create `~/.panopticon.env`:
54
106
 
55
107
  ```bash
56
108
  LINEAR_API_KEY=lin_api_xxxxx
57
- GITHUB_TOKEN=ghp_xxxxx # Optional: for secondary tracker
109
+ GITHUB_TOKEN=ghp_xxxxx # Optional: for GitHub-tracked projects
110
+ ```
111
+
112
+ ### Register Projects
113
+
114
+ Register your local project directories so Panopticon knows where to create workspaces:
115
+
116
+ ```bash
117
+ # Register a project
118
+ pan project add /path/to/your/project --name myproject
119
+
120
+ # List registered projects
121
+ pan project list
122
+ ```
123
+
124
+ ### Map Linear Projects to Local Directories
125
+
126
+ If you have multiple Linear projects, configure which local directory each maps to. Create/edit `~/.panopticon/project-mappings.json`:
127
+
128
+ ```json
129
+ [
130
+ {
131
+ "linearProjectId": "abc123",
132
+ "linearProjectName": "Mind Your Now",
133
+ "linearPrefix": "MIN",
134
+ "localPath": "/home/user/projects/myn"
135
+ },
136
+ {
137
+ "linearProjectId": "def456",
138
+ "linearProjectName": "Househunt",
139
+ "linearPrefix": "HH",
140
+ "localPath": "/home/user/projects/househunt"
141
+ }
142
+ ]
58
143
  ```
59
144
 
145
+ The dashboard uses this mapping to determine where to create workspaces when you click "Create Workspace" or "Start Agent" for an issue.
146
+
60
147
  ## Commands
61
148
 
62
149
  ### Core Commands
@@ -111,6 +198,81 @@ pan work hook push agent-min-123 "Continue with tests"
111
198
  pan work hook mail agent-min-123 "Review feedback received"
112
199
  ```
113
200
 
201
+ ### Workspace Management
202
+
203
+ **Workspaces are git worktrees** - isolated working directories for each issue/feature. Each workspace:
204
+ - Has its own feature branch (e.g., `feature/min-123-add-login`)
205
+ - Shares git history with the main repo (no separate clone)
206
+ - Can run independently (separate node_modules, builds, etc.)
207
+ - Is located at `{project}/workspaces/{issue-id}/`
208
+
209
+ This allows multiple agents to work on different features simultaneously without conflicts.
210
+
211
+ #### Git-Backed Collaborative Planning
212
+
213
+ Planning artifacts are stored **inside the workspace**, making them part of the feature branch:
214
+
215
+ ```
216
+ workspaces/feature-min-123/
217
+ ├── .planning/
218
+ │ ├── output.jsonl # Full conversation history (tool uses + results)
219
+ │ ├── PLANNING_PROMPT.md # Initial planning prompt
220
+ │ ├── CONTINUATION_PROMPT.md # Context for continued sessions
221
+ │ └── output-*.jsonl # Backup of previous rounds
222
+ └── ... (code)
223
+ ```
224
+
225
+ **This enables:**
226
+
227
+ 1. **Collaborative async planning** - Push your branch, someone else pulls and continues the planning session with full context
228
+ 2. **Context recovery** - If Claude's context compacts, the full conversation is preserved in the branch
229
+ 3. **Audit trail** - See how planning decisions were made, what files were explored, what questions were asked
230
+ 4. **Branch portability** - The planning state travels with the feature branch
231
+
232
+ **Dashboard workflow (recommended):**
233
+
234
+ The planning dialog has **Pull** and **Push** buttons that handle git operations automatically:
235
+
236
+ | Button | What it does |
237
+ |--------|--------------|
238
+ | **Pull** | Fetches from origin, creates workspace from remote branch if needed, pulls latest changes |
239
+ | **Push** | Commits `.planning/` artifacts and pushes to origin |
240
+
241
+ 1. Person A starts planning in dashboard, clicks **Push** when interrupted
242
+ 2. Person B opens same issue in dashboard, clicks **Pull** → gets Person A's full context
243
+ 3. Person B continues the planning session and clicks **Push** when done
244
+
245
+ **CLI workflow:**
246
+ ```bash
247
+ # Person A starts planning
248
+ pan work plan MIN-123
249
+ # ... answers discovery questions, gets interrupted ...
250
+
251
+ # Push the branch (includes planning context)
252
+ cd workspaces/feature-min-123
253
+ git add .planning && git commit -m "WIP: planning session"
254
+ git push origin feature/min-123
255
+
256
+ # Person B continues
257
+ git pull origin feature/min-123
258
+ pan work plan MIN-123 --continue
259
+ # Claude has full context from Person A's session
260
+ ```
261
+
262
+ ```bash
263
+ # Create a workspace (git worktree) without starting an agent
264
+ pan workspace create MIN-123
265
+
266
+ # List all workspaces
267
+ pan workspace list
268
+
269
+ # Destroy a workspace
270
+ pan workspace destroy MIN-123
271
+
272
+ # Force destroy (even with uncommitted changes)
273
+ pan workspace destroy MIN-123 --force
274
+ ```
275
+
114
276
  ### Project Management
115
277
 
116
278
  ```bash
@@ -165,8 +327,17 @@ Start the monitoring dashboard:
165
327
  pan up
166
328
  ```
167
329
 
168
- - Frontend: http://localhost:3001
169
- - API: http://localhost:3002
330
+ **Recommended (containerized with HTTPS):**
331
+ - Dashboard: https://pan.localhost
332
+ - Traefik UI: https://traefik.pan.localhost:8082
333
+
334
+ This runs everything in Docker containers, avoiding port conflicts with your other projects.
335
+
336
+ **Minimal install (no Docker):**
337
+ ```bash
338
+ pan up --minimal
339
+ ```
340
+ - Dashboard: http://localhost:3001
170
341
 
171
342
  Stop with `pan down`.
172
343
 
@@ -187,6 +358,37 @@ Panopticon ships with 10+ high-value skills:
187
358
  | `dependency-update` | Safe dependency updates |
188
359
  | `onboard-codebase` | Understanding new codebases |
189
360
 
361
+ ### Reserved Skill Names
362
+
363
+ Panopticon reserves the following skill names. **Do not use these names for project-specific skills** to avoid conflicts:
364
+
365
+ **Pan operations:**
366
+ `pan-down`, `pan-help`, `pan-install`, `pan-issue`, `pan-plan`, `pan-quickstart`, `pan-setup`, `pan-status`, `pan-up`
367
+
368
+ **Workflow skills:**
369
+ `beads`, `bug-fix`, `code-review`, `code-review-performance`, `code-review-security`, `dependency-update`, `feature-work`, `incident-response`, `onboard-codebase`, `refactor`, `release`, `session-health`, `skill-creator`, `web-design-guidelines`, `work-complete`
370
+
371
+ **Recommendation:** Use a project-specific prefix for your skills (e.g., `myn-standards`, `acme-deployment`) to avoid namespace collisions.
372
+
373
+ ### Project-Specific Skills
374
+
375
+ Projects can have their own skills alongside Panopticon's:
376
+
377
+ ```
378
+ ~/.claude/skills/
379
+ ├── pan-help/ # Symlink → ~/.panopticon/skills/pan-help/
380
+ ├── feature-work/ # Symlink → ~/.panopticon/skills/feature-work/
381
+ └── ... (other pan skills)
382
+
383
+ {project}/.claude/skills/
384
+ ├── myn-standards/ # Project-specific (git-tracked)
385
+ └── myn-api-patterns/ # Project-specific (git-tracked)
386
+ ```
387
+
388
+ Project-specific skills in `{project}/.claude/skills/` are **not managed by Panopticon**. They live in your project's git repo and take precedence over global skills with the same name.
389
+
390
+ ### Skill Distribution
391
+
190
392
  Skills are synced to all supported AI tools via symlinks:
191
393
 
192
394
  ```bash
@@ -197,6 +399,61 @@ Skills are synced to all supported AI tools via symlinks:
197
399
  ~/.gemini/skills/ # Gemini CLI
198
400
  ```
199
401
 
402
+ ## PRD Convention
403
+
404
+ Panopticon enforces a standard approach to Product Requirements Documents (PRDs) across all managed projects.
405
+
406
+ ### PRD Structure
407
+
408
+ Every project has a **canonical PRD** that defines the core product:
409
+
410
+ ```
411
+ {project}/
412
+ ├── docs/
413
+ │ └── PRD.md # The canonical PRD (core product definition)
414
+ ├── workspaces/
415
+ │ └── feature-{issue}/
416
+ │ └── docs/
417
+ │ └── {ISSUE}-plan.md # Feature PRD (lives in feature branch)
418
+ ```
419
+
420
+ | PRD Type | Location | Purpose |
421
+ |----------|----------|---------|
422
+ | **Canonical PRD** | `docs/PRD.md` | Core product definition, always on main |
423
+ | **Feature PRD** | `workspaces/feature-{issue}/docs/{ISSUE}-plan.md` | Feature spec, lives in feature branch, merged with PR |
424
+
425
+ ### Feature PRDs Live in Workspaces
426
+
427
+ When you start planning an issue, Panopticon creates:
428
+ 1. A git worktree (workspace) for the feature branch
429
+ 2. A planning session that generates a feature PRD
430
+
431
+ The feature PRD **lives in the workspace** (feature branch) because:
432
+ - It gets merged with the PR (documentation travels with code)
433
+ - If you abort planning and delete the workspace, you don't want orphaned PRDs
434
+ - Clean separation - each feature is self-contained
435
+
436
+ ### Project Initialization
437
+
438
+ When registering a new project with Panopticon (`pan project add`), the system will:
439
+
440
+ 1. **Check for existing PRD** - Look for `docs/PRD.md`, `PRD.md`, `README.md`, or similar
441
+ 2. **If found**: Use it to create/update the canonical PRD format, prompting for any missing crucial information
442
+ 3. **If not found**: Generate one by:
443
+ - Analyzing the codebase structure
444
+ - Identifying key technologies and patterns
445
+ - Asking discovery questions about the product
446
+
447
+ This ensures every Panopticon-managed project has a well-defined canonical PRD that agents can reference.
448
+
449
+ ### PRD Naming Convention
450
+
451
+ | Document | Naming | Example |
452
+ |----------|--------|---------|
453
+ | Canonical PRD | `PRD.md` | `docs/PRD.md` |
454
+ | Feature PRD | `{ISSUE}-plan.md` | `MIN-123-plan.md`, `PAN-4-plan.md` |
455
+ | Planning artifacts | In `.planning/{issue}/` | `.planning/min-123/STATE.md` |
456
+
200
457
  ## Architecture
201
458
 
202
459
  ```
@@ -237,6 +494,148 @@ GUPP ensures agents are self-propelling:
237
494
  3. Pending work is injected into the agent's prompt
238
495
  4. Completed work is popped from the hook
239
496
 
240
- ## License
497
+ ## Development
498
+
499
+ ### Dev vs Production Strategy
241
500
 
242
- MIT
501
+ Panopticon uses a **shared config, switchable CLI** approach:
502
+
503
+ ```
504
+ ~/.panopticon/ # Shared by both dev and prod
505
+ ├── config.toml # Settings
506
+ ├── projects.json # Registered projects
507
+ ├── project-mappings.json # Linear → local path mappings
508
+ ├── agents/ # Agent state
509
+ └── skills/ # Shared skills
510
+ ```
511
+
512
+ Both dev and production versions read/write the same config, so you can switch between them freely.
513
+
514
+ ### Running in Development Mode
515
+
516
+ ```bash
517
+ # Clone and setup
518
+ git clone https://github.com/eltmon/panopticon.git
519
+ cd panopticon
520
+ npm install
521
+
522
+ # Link dev version globally (makes 'pan' use your local code)
523
+ npm link
524
+
525
+ # Start the dashboard (with hot reload)
526
+ cd src/dashboard
527
+ npm run install:all
528
+ npm run dev
529
+ # → Frontend: http://localhost:3010
530
+ # → API: http://localhost:3011
531
+ ```
532
+
533
+ ### Switching Between Dev and Prod
534
+
535
+ ```bash
536
+ # Use dev version (from your local repo)
537
+ cd /path/to/panopticon && npm link
538
+
539
+ # Switch back to stable release
540
+ npm unlink panopticon-cli
541
+ npm install -g panopticon-cli
542
+ ```
543
+
544
+ ### Dashboard Modes
545
+
546
+ | Mode | Command | Use Case |
547
+ |------|---------|----------|
548
+ | **Production** | `pan up` | Daily usage, containerized, HTTPS at https://pan.localhost |
549
+ | **Dev** | `cd src/dashboard && npm run dev` | Only for active development on Panopticon itself |
550
+
551
+ **Note:** Use `pan up` for normal usage - it runs in Docker and won't conflict with your project's ports. Only use dev mode when actively working on Panopticon's codebase.
552
+
553
+ ### Working on Panopticon While Using It
554
+
555
+ If you're both developing Panopticon AND using it for your own projects:
556
+
557
+ 1. **Use `npm link`** so CLI changes take effect immediately
558
+ 2. **Run dashboard from source** for hot reload on UI changes
559
+ 3. **Config is shared** - workspaces/agents work the same either way
560
+ 4. **Test in a real project** - your own usage is the best test
561
+
562
+ ## Troubleshooting
563
+
564
+ ### Slow Vite/React Frontend with Multiple Workspaces
565
+
566
+ If running multiple containerized workspaces with Vite/React frontends, you may notice CPU spikes and slow HMR. This is because Vite's default file watching polls every 100ms, which compounds with multiple instances.
567
+
568
+ **Fix:** Increase the polling interval in your `vite.config.mjs`:
569
+
570
+ ```javascript
571
+ server: {
572
+ watch: {
573
+ usePolling: true,
574
+ interval: 3000, // Poll every 3s instead of 100ms default
575
+ },
576
+ }
577
+ ```
578
+
579
+ A 3000ms interval supports 4-5 concurrent workspaces comfortably while maintaining acceptable HMR responsiveness.
580
+
581
+ ### Corrupted Workspaces
582
+
583
+ A workspace can become "corrupted" when it exists as a directory but is no longer a valid git worktree. The dashboard will show a yellow "Workspace Corrupted" warning with an option to clean and recreate.
584
+
585
+ **Symptoms:**
586
+ - Dashboard shows "Workspace Corrupted" warning
587
+ - `git status` in the workspace fails with "not a git repository"
588
+ - The `.git` file is missing from the workspace directory
589
+
590
+ **Common Causes:**
591
+
592
+ | Cause | Description |
593
+ |-------|-------------|
594
+ | **Interrupted creation** | `pan workspace create` was killed mid-execution (Ctrl+C, system crash) |
595
+ | **Manual .git deletion** | Someone accidentally deleted the `.git` file in the workspace |
596
+ | **Disk space issues** | Ran out of disk space during workspace creation |
597
+ | **Git worktree pruning** | Running `git worktree prune` in the main repo removed the worktree link |
598
+ | **Force-deleted main repo** | The main repository was moved or deleted while workspaces existed |
599
+
600
+ **Resolution:**
601
+
602
+ 1. **Via Dashboard (recommended):**
603
+ - Click on the issue to open the detail panel
604
+ - Click "Clean & Recreate" button
605
+ - Review the files that will be deleted
606
+ - Check "Create backup" to preserve your work (recommended)
607
+ - Click "Backup & Recreate"
608
+
609
+ 2. **Via CLI:**
610
+ ```bash
611
+ # Option 1: Manual cleanup
612
+ rm -rf /path/to/project/workspaces/feature-issue-123
613
+ pan workspace create ISSUE-123
614
+
615
+ # Option 2: Backup first
616
+ cp -r /path/to/project/workspaces/feature-issue-123 /tmp/backup-issue-123
617
+ rm -rf /path/to/project/workspaces/feature-issue-123
618
+ pan workspace create ISSUE-123
619
+ # Then manually restore files from backup
620
+ ```
621
+
622
+ **Prevention:**
623
+ - Don't interrupt `pan workspace create` commands
624
+ - Don't run `git worktree prune` in the main repo without checking for active workspaces
625
+ - Ensure adequate disk space before creating workspaces
626
+
627
+ ## ⭐ Star History
628
+
629
+ <a href="https://star-history.com/#eltmon/panopticon&Date">
630
+ <picture>
631
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=eltmon/panopticon&type=Date&theme=dark" />
632
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=eltmon/panopticon&type=Date" />
633
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=eltmon/panopticon&type=Date" />
634
+ </picture>
635
+ </a>
636
+
637
+ ## ⚖️ License
638
+
639
+ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
640
+
641
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)