@hienlh/ppm 0.1.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 (159) hide show
  1. package/.claude/agent-memory/tester/MEMORY.md +3 -0
  2. package/.claude/agent-memory/tester/project-ppm-test-conventions.md +32 -0
  3. package/.env.example +1 -0
  4. package/.github/workflows/release.yml +46 -0
  5. package/README.md +349 -0
  6. package/bun.lock +1217 -0
  7. package/components.json +21 -0
  8. package/docs/code-standards.md +574 -0
  9. package/docs/codebase-summary.md +294 -0
  10. package/docs/deployment-guide.md +631 -0
  11. package/docs/design-guidelines.md +661 -0
  12. package/docs/project-overview-pdr.md +142 -0
  13. package/docs/project-roadmap.md +400 -0
  14. package/docs/system-architecture.md +459 -0
  15. package/package.json +68 -0
  16. package/plans/260314-2009-ppm-implementation/phase-01-project-skeleton.md +81 -0
  17. package/plans/260314-2009-ppm-implementation/phase-02-backend-core.md +148 -0
  18. package/plans/260314-2009-ppm-implementation/phase-03-frontend-shell.md +256 -0
  19. package/plans/260314-2009-ppm-implementation/phase-04-file-explorer-editor.md +120 -0
  20. package/plans/260314-2009-ppm-implementation/phase-05-web-terminal.md +174 -0
  21. package/plans/260314-2009-ppm-implementation/phase-06-git-integration.md +244 -0
  22. package/plans/260314-2009-ppm-implementation/phase-07-ai-chat.md +242 -0
  23. package/plans/260314-2009-ppm-implementation/phase-08-cli-commands.md +143 -0
  24. package/plans/260314-2009-ppm-implementation/phase-09-pwa-build-deploy.md +209 -0
  25. package/plans/260314-2009-ppm-implementation/phase-10-testing.md +311 -0
  26. package/plans/260314-2009-ppm-implementation/plan.md +202 -0
  27. package/plans/260315-0356-project-scoped-api-refactor/phase-01-backend-project-router.md +145 -0
  28. package/plans/260315-0356-project-scoped-api-refactor/phase-02-frontend-api-migration.md +107 -0
  29. package/plans/260315-0356-project-scoped-api-refactor/phase-03-per-project-tabs.md +100 -0
  30. package/plans/260315-0356-project-scoped-api-refactor/phase-04-websocket-migration.md +66 -0
  31. package/plans/260315-0356-project-scoped-api-refactor/plan.md +87 -0
  32. package/plans/reports/brainstorm-260314-1938-final-techstack.md +342 -0
  33. package/plans/reports/docs-manager-260315-1314-documentation-creation.md +386 -0
  34. package/plans/reports/fullstack-developer-260314-2252-phase-02-backend-core.md +57 -0
  35. package/plans/reports/fullstack-developer-260314-2253-phase-03-frontend-shell.md +70 -0
  36. package/plans/reports/fullstack-developer-260314-2300-phase-04-05-file-api-terminal-ws.md +49 -0
  37. package/plans/reports/fullstack-developer-260314-2300-phase-04-05-file-explorer-editor-terminal.md +52 -0
  38. package/plans/reports/fullstack-developer-260314-2307-ai-chat-phase7.md +58 -0
  39. package/plans/reports/fullstack-developer-260314-2307-phase-06-git-integration.md +33 -0
  40. package/plans/reports/research-260314-1911-ppm-tech-stack.md +318 -0
  41. package/plans/reports/research-260314-1930-claude-code-integration.md +293 -0
  42. package/plans/reports/researcher-260314-2232-node-pty-bun-crash-analysis.md +305 -0
  43. package/plans/reports/researcher-260314-2232-ui-style.md +942 -0
  44. package/plans/reports/researcher-260315-0300-opcode-claude-interaction.md +745 -0
  45. package/plans/reports/researcher-260315-0303-opcode-deep-analysis.md +742 -0
  46. package/plans/reports/researcher-260315-0305-claude-agent-sdk-github-research.md +423 -0
  47. package/plans/reports/tester-260314-2053-initial-test-suite.md +81 -0
  48. package/ppm.example.yaml +14 -0
  49. package/repomix-output.xml +23745 -0
  50. package/scripts/build.ts +13 -0
  51. package/src/cli/commands/chat-cmd.ts +259 -0
  52. package/src/cli/commands/config-cmd.ts +121 -0
  53. package/src/cli/commands/git-cmd.ts +315 -0
  54. package/src/cli/commands/init.ts +57 -0
  55. package/src/cli/commands/open.ts +19 -0
  56. package/src/cli/commands/projects.ts +100 -0
  57. package/src/cli/commands/start.ts +3 -0
  58. package/src/cli/commands/stop.ts +33 -0
  59. package/src/cli/utils/project-resolver.ts +27 -0
  60. package/src/index.ts +59 -0
  61. package/src/providers/claude-agent-sdk.ts +499 -0
  62. package/src/providers/claude-binary-finder.ts +256 -0
  63. package/src/providers/claude-code-cli.ts +413 -0
  64. package/src/providers/claude-process-registry.ts +106 -0
  65. package/src/providers/mock-provider.ts +171 -0
  66. package/src/providers/provider.interface.ts +10 -0
  67. package/src/providers/registry.ts +45 -0
  68. package/src/server/helpers/resolve-project.ts +22 -0
  69. package/src/server/index.ts +181 -0
  70. package/src/server/middleware/auth.ts +30 -0
  71. package/src/server/routes/chat.ts +153 -0
  72. package/src/server/routes/files.ts +168 -0
  73. package/src/server/routes/git.ts +261 -0
  74. package/src/server/routes/project-scoped.ts +27 -0
  75. package/src/server/routes/projects.ts +57 -0
  76. package/src/server/routes/static.ts +26 -0
  77. package/src/server/ws/chat.ts +130 -0
  78. package/src/server/ws/terminal.ts +89 -0
  79. package/src/services/chat.service.ts +110 -0
  80. package/src/services/claude-usage.service.ts +113 -0
  81. package/src/services/config.service.ts +90 -0
  82. package/src/services/file.service.ts +261 -0
  83. package/src/services/git-dirs.service.ts +112 -0
  84. package/src/services/git.service.ts +372 -0
  85. package/src/services/project.service.ts +107 -0
  86. package/src/services/slash-items.service.ts +184 -0
  87. package/src/services/terminal.service.ts +212 -0
  88. package/src/types/api.ts +37 -0
  89. package/src/types/chat.ts +92 -0
  90. package/src/types/config.ts +41 -0
  91. package/src/types/git.ts +50 -0
  92. package/src/types/project.ts +18 -0
  93. package/src/types/terminal.ts +20 -0
  94. package/src/web/app.tsx +168 -0
  95. package/src/web/components/auth/login-screen.tsx +88 -0
  96. package/src/web/components/chat/attachment-chips.tsx +55 -0
  97. package/src/web/components/chat/chat-placeholder.tsx +10 -0
  98. package/src/web/components/chat/chat-tab.tsx +301 -0
  99. package/src/web/components/chat/file-picker.tsx +126 -0
  100. package/src/web/components/chat/message-input.tsx +420 -0
  101. package/src/web/components/chat/message-list.tsx +838 -0
  102. package/src/web/components/chat/session-picker.tsx +139 -0
  103. package/src/web/components/chat/slash-command-picker.tsx +135 -0
  104. package/src/web/components/chat/usage-badge.tsx +186 -0
  105. package/src/web/components/editor/code-editor.tsx +329 -0
  106. package/src/web/components/editor/diff-viewer.tsx +276 -0
  107. package/src/web/components/editor/editor-placeholder.tsx +10 -0
  108. package/src/web/components/explorer/file-actions.tsx +191 -0
  109. package/src/web/components/explorer/file-tree.tsx +298 -0
  110. package/src/web/components/git/git-graph.tsx +727 -0
  111. package/src/web/components/git/git-placeholder.tsx +55 -0
  112. package/src/web/components/git/git-status-panel.tsx +850 -0
  113. package/src/web/components/layout/mobile-drawer.tsx +137 -0
  114. package/src/web/components/layout/mobile-nav.tsx +103 -0
  115. package/src/web/components/layout/sidebar.tsx +90 -0
  116. package/src/web/components/layout/tab-bar.tsx +152 -0
  117. package/src/web/components/layout/tab-content.tsx +85 -0
  118. package/src/web/components/projects/dir-suggest.tsx +152 -0
  119. package/src/web/components/projects/project-list.tsx +187 -0
  120. package/src/web/components/settings/settings-tab.tsx +57 -0
  121. package/src/web/components/terminal/terminal-placeholder.tsx +10 -0
  122. package/src/web/components/terminal/terminal-tab.tsx +133 -0
  123. package/src/web/components/ui/button.tsx +64 -0
  124. package/src/web/components/ui/context-menu.tsx +250 -0
  125. package/src/web/components/ui/dialog.tsx +156 -0
  126. package/src/web/components/ui/dropdown-menu.tsx +257 -0
  127. package/src/web/components/ui/input.tsx +21 -0
  128. package/src/web/components/ui/scroll-area.tsx +56 -0
  129. package/src/web/components/ui/separator.tsx +26 -0
  130. package/src/web/components/ui/sonner.tsx +40 -0
  131. package/src/web/components/ui/tabs.tsx +91 -0
  132. package/src/web/components/ui/tooltip.tsx +57 -0
  133. package/src/web/hooks/use-chat.ts +420 -0
  134. package/src/web/hooks/use-terminal.ts +182 -0
  135. package/src/web/hooks/use-url-sync.ts +66 -0
  136. package/src/web/hooks/use-websocket.ts +48 -0
  137. package/src/web/index.html +16 -0
  138. package/src/web/lib/api-client.ts +90 -0
  139. package/src/web/lib/file-support.ts +68 -0
  140. package/src/web/lib/utils.ts +6 -0
  141. package/src/web/lib/ws-client.ts +100 -0
  142. package/src/web/main.tsx +10 -0
  143. package/src/web/public/icon-192.svg +5 -0
  144. package/src/web/public/icon-512.svg +5 -0
  145. package/src/web/stores/file-store.ts +81 -0
  146. package/src/web/stores/project-store.ts +50 -0
  147. package/src/web/stores/settings-store.ts +65 -0
  148. package/src/web/stores/tab-store.ts +187 -0
  149. package/src/web/styles/globals.css +227 -0
  150. package/src/web/vite-env.d.ts +1 -0
  151. package/tests/integration/api/chat-routes.test.ts +95 -0
  152. package/tests/integration/claude-agent-sdk-integration.test.ts +228 -0
  153. package/tests/integration/ws/chat-websocket.test.ts +312 -0
  154. package/tests/test-setup.ts +5 -0
  155. package/tests/unit/providers/claude-agent-sdk.test.ts +339 -0
  156. package/tests/unit/providers/mock-provider.test.ts +143 -0
  157. package/tests/unit/services/chat-service.test.ts +100 -0
  158. package/tsconfig.json +32 -0
  159. package/vite.config.ts +62 -0
@@ -0,0 +1,631 @@
1
+ # PPM Deployment Guide
2
+
3
+ ## Prerequisites
4
+
5
+ ### System Requirements
6
+ - **OS:** Linux or macOS (Windows support planned for v3)
7
+ - **RAM:** 512 MB minimum, 2 GB recommended
8
+ - **Disk:** 500 MB for binary + dependencies
9
+ - **Network:** localhost only (single-machine deployment)
10
+
11
+ ### Required Software
12
+ - **Bun:** v1.3.6 or later (https://bun.sh)
13
+ - **Git:** v2.0+ (for git operations in chat/CLI)
14
+ - **Node.js or Bun:** For running npm/node commands in terminal
15
+
16
+ ### Optional
17
+ - **ngrok or similar:** For exposing to network (not recommended for production)
18
+ - **systemd or launchd:** For daemon management
19
+
20
+ ---
21
+
22
+ ## Installation
23
+
24
+ ### Option 1: Build from Source (Development)
25
+
26
+ #### Prerequisites
27
+ ```bash
28
+ # Check Bun is installed
29
+ bun --version # Should be 1.3.6+
30
+
31
+ # Clone repository
32
+ git clone https://github.com/hienlh/ppm.git
33
+ cd ppm
34
+ ```
35
+
36
+ #### Install & Build
37
+ ```bash
38
+ # Install dependencies
39
+ bun install
40
+
41
+ # Build frontend + CLI binary
42
+ bun run build
43
+
44
+ # Output: dist/ppm (compiled binary)
45
+ ```
46
+
47
+ #### Run
48
+ ```bash
49
+ # Run directly from source (development)
50
+ bun run start
51
+
52
+ # Or use compiled binary
53
+ ./dist/ppm start
54
+ ```
55
+
56
+ ---
57
+
58
+ ### Option 2: Pre-built Binary (Production)
59
+
60
+ #### Download
61
+ ```bash
62
+ # Download latest release from GitHub Releases
63
+ wget https://github.com/hienlh/ppm/releases/download/v2.0/ppm-macos-x64
64
+ chmod +x ppm-macos-x64
65
+
66
+ # Or for Linux
67
+ wget https://github.com/hienlh/ppm/releases/download/v2.0/ppm-linux-x64
68
+ chmod +x ppm-linux-x64
69
+ ```
70
+
71
+ #### Run
72
+ ```bash
73
+ # Copy to PATH for global access
74
+ sudo cp ppm-macos-x64 /usr/local/bin/ppm
75
+
76
+ # Verify installation
77
+ ppm --version
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Configuration
83
+
84
+ ### Initial Setup
85
+
86
+ ```bash
87
+ # Generate config and scan for git repositories
88
+ ppm init
89
+
90
+ # Output: ~/.config/ppm/ppm.yaml (or current directory)
91
+ # Auto-generates auth token
92
+ ```
93
+
94
+ ### Config File Structure (ppm.yaml)
95
+
96
+ ```yaml
97
+ port: 8080
98
+ host: 0.0.0.0
99
+ auth:
100
+ enabled: true
101
+ token: "auto-generated-random-token"
102
+ projects:
103
+ - name: project-a
104
+ path: /path/to/project-a
105
+ - name: project-b
106
+ path: /path/to/project-b
107
+ providers:
108
+ default: claude-agent-sdk # or claude-code-cli for fallback
109
+ ```
110
+
111
+ ### Customize Configuration
112
+
113
+ #### Change Port
114
+ ```bash
115
+ # Edit ppm.yaml manually
116
+ ppm config set port 3000
117
+
118
+ # Or start with custom port (CLI flag)
119
+ ppm start --port 3000
120
+ ```
121
+
122
+ #### Add/Remove Projects
123
+ ```bash
124
+ # Add project
125
+ ppm projects add my-project /path/to/my-project
126
+
127
+ # List projects
128
+ ppm projects list
129
+
130
+ # Remove project
131
+ ppm projects remove my-project
132
+ ```
133
+
134
+ #### Set AI Provider
135
+ ```bash
136
+ # Use Claude Code CLI fallback (for offline environments)
137
+ ppm config set providers.default claude-code-cli
138
+
139
+ # Switch back to SDK (default)
140
+ ppm config set providers.default claude-agent-sdk
141
+ ```
142
+
143
+ #### Change Authentication Token
144
+ ```bash
145
+ # Generate new random token
146
+ ppm config set auth.token "$(openssl rand -hex 32)"
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Running the Server
152
+
153
+ ### Foreground Mode (Development)
154
+
155
+ ```bash
156
+ ppm start
157
+
158
+ # Output:
159
+ # PPM server listening on http://localhost:8080
160
+ # Token: <token from config>
161
+ # Projects: 2
162
+ ```
163
+
164
+ Server runs in foreground. Press `Ctrl+C` to stop.
165
+
166
+ ### Daemon Mode (Production)
167
+
168
+ ```bash
169
+ # Start as background daemon
170
+ ppm start --daemon
171
+
172
+ # Server runs in background
173
+ # Logs written to ~/.ppm/server.log (optional)
174
+
175
+ # Check status
176
+ ps aux | grep ppm
177
+
178
+ # Stop daemon
179
+ ppm stop
180
+
181
+ # Or manually
182
+ kill $(cat ~/.ppm/server.pid)
183
+ ```
184
+
185
+ ### Via systemd (Linux)
186
+
187
+ Create `/etc/systemd/system/ppm.service`:
188
+
189
+ ```ini
190
+ [Unit]
191
+ Description=PPM Web IDE Server
192
+ After=network.target
193
+
194
+ [Service]
195
+ Type=simple
196
+ User=<username>
197
+ WorkingDirectory=/home/<username>
198
+ ExecStart=/usr/local/bin/ppm start
199
+ Restart=always
200
+ RestartSec=10
201
+
202
+ [Install]
203
+ WantedBy=multi-user.target
204
+ ```
205
+
206
+ Then:
207
+ ```bash
208
+ sudo systemctl daemon-reload
209
+ sudo systemctl enable ppm
210
+ sudo systemctl start ppm
211
+
212
+ # Check status
213
+ sudo systemctl status ppm
214
+
215
+ # View logs
216
+ sudo journalctl -u ppm -f
217
+ ```
218
+
219
+ ### Via launchd (macOS)
220
+
221
+ Create `~/Library/LaunchAgents/com.ppm.server.plist`:
222
+
223
+ ```xml
224
+ <?xml version="1.0" encoding="UTF-8"?>
225
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
226
+ <plist version="1.0">
227
+ <dict>
228
+ <key>Label</key>
229
+ <string>com.ppm.server</string>
230
+ <key>ProgramArguments</key>
231
+ <array>
232
+ <string>/usr/local/bin/ppm</string>
233
+ <string>start</string>
234
+ </array>
235
+ <key>RunAtLoad</key>
236
+ <true/>
237
+ <key>KeepAlive</key>
238
+ <true/>
239
+ <key>StandardOutPath</key>
240
+ <string>/tmp/ppm.log</string>
241
+ <key>StandardErrorPath</key>
242
+ <string>/tmp/ppm-error.log</string>
243
+ </dict>
244
+ </plist>
245
+ ```
246
+
247
+ Then:
248
+ ```bash
249
+ launchctl load ~/Library/LaunchAgents/com.ppm.server.plist
250
+ launchctl status com.ppm.server
251
+ ```
252
+
253
+ ---
254
+
255
+ ## Environment Variables
256
+
257
+ ### Optional Configuration via ENV
258
+
259
+ Instead of `ppm.yaml`, configure via environment variables:
260
+
261
+ ```bash
262
+ export PPM_PORT=8080
263
+ export PPM_HOST=0.0.0.0
264
+ export PPM_AUTH_TOKEN="my-secure-token"
265
+ export PPM_DEFAULT_PROVIDER="claude-agent-sdk"
266
+ export PPM_CONFIG_PATH="/etc/ppm/config.yaml" # Custom config location
267
+
268
+ ppm start
269
+ ```
270
+
271
+ ### For Claude Integration
272
+
273
+ If using Claude Agent SDK:
274
+ ```bash
275
+ export ANTHROPIC_API_KEY="sk-ant-..." # Your Anthropic API key
276
+ ppm start
277
+ ```
278
+
279
+ If using Claude CLI fallback:
280
+ ```bash
281
+ export CLAUDE_API_KEY="sk-ant-..."
282
+ # Ensure `claude` CLI is installed and in PATH
283
+ which claude # Should find the binary
284
+ ```
285
+
286
+ ---
287
+
288
+ ## Build & Deployment Commands
289
+
290
+ ### Full Build Pipeline
291
+
292
+ ```bash
293
+ # 1. Install dependencies
294
+ bun install
295
+
296
+ # 2. Type check
297
+ bun run typecheck
298
+
299
+ # 3. Build frontend
300
+ bun run build:web
301
+
302
+ # 4. Compile CLI binary (single executable)
303
+ bun run build
304
+
305
+ # Output: dist/ppm (~50-150 MB depending on platform)
306
+
307
+ # 5. Test (optional, currently partial coverage)
308
+ bun test
309
+ ```
310
+
311
+ ### Output Artifacts
312
+
313
+ After `bun run build`:
314
+
315
+ ```
316
+ dist/
317
+ ├── ppm # Compiled CLI binary (executable)
318
+ └── web/ # Frontend assets (embedded in binary)
319
+ ├── index.html
320
+ ├── assets/
321
+ │ ├── index-*.js # Main JS bundle
322
+ │ ├── index-*.css # Tailwind styles
323
+ │ └── ... # Other chunks
324
+ └── manifest.json # PWA manifest
325
+ ```
326
+
327
+ ### Size Optimization
328
+
329
+ ```bash
330
+ # Check bundle size before/after
331
+ bun run build:web
332
+ du -sh dist/web/assets/
333
+
334
+ # Typical sizes:
335
+ # - JS bundles: 200-300 KB gzipped
336
+ # - CSS: 100-150 KB gzipped
337
+ # - Total frontend: 400-500 KB gzipped
338
+ # - CLI binary: 80-120 MB (includes runtime)
339
+ ```
340
+
341
+ ---
342
+
343
+ ## First-Time Setup Checklist
344
+
345
+ ```bash
346
+ # 1. Install Bun
347
+ curl -fsSL https://bun.sh/install | bash
348
+ source ~/.bashrc # or ~/.zshrc
349
+
350
+ # 2. Clone/build PPM
351
+ git clone https://github.com/hienlh/ppm.git
352
+ cd ppm
353
+ bun install
354
+ bun run build
355
+
356
+ # 3. Initialize config
357
+ ./dist/ppm init
358
+ # Follow prompts to add projects
359
+
360
+ # 4. Start server
361
+ ./dist/ppm start
362
+ # Output: http://localhost:8080 + token
363
+
364
+ # 5. Open browser
365
+ # Navigate to http://localhost:8080
366
+ # Enter token from step 4
367
+ # Select project and start using
368
+
369
+ # 6. Verify functionality
370
+ # - Browse files in file explorer
371
+ # - Open terminal and run commands
372
+ # - Chat with Claude (requires ANTHROPIC_API_KEY)
373
+ ```
374
+
375
+ ---
376
+
377
+ ## Troubleshooting
378
+
379
+ ### Port Already in Use
380
+
381
+ ```bash
382
+ # Check what's using port 8080
383
+ lsof -i :8080
384
+ # Kill process
385
+ kill -9 <PID>
386
+
387
+ # Or use different port
388
+ ppm start --port 3000
389
+ ```
390
+
391
+ ### Permission Denied (File Operations)
392
+
393
+ ```bash
394
+ # Ensure PPM has read/write access to project directory
395
+ chmod -R u+rw /path/to/project
396
+
397
+ # Or run PPM with appropriate user
398
+ sudo -u <username> ppm start
399
+ ```
400
+
401
+ ### Git Commands Failing
402
+
403
+ ```bash
404
+ # Verify git is installed
405
+ git --version
406
+
407
+ # Verify project is git repository
408
+ cd /path/to/project
409
+ git status
410
+
411
+ # If not a repo
412
+ git init
413
+ ```
414
+
415
+ ### Terminal Not Working
416
+
417
+ ```bash
418
+ # Verify shell is available
419
+ which bash zsh
420
+
421
+ # Check PTY support (Linux/macOS only)
422
+ # Windows may require WSL or special configuration
423
+ ```
424
+
425
+ ### Chat/Claude Not Responding
426
+
427
+ ```bash
428
+ # Check API key is set
429
+ echo $ANTHROPIC_API_KEY
430
+
431
+ # Verify network connectivity
432
+ curl https://api.anthropic.com
433
+
434
+ # Check provider is working
435
+ ppm chat send "test message" 2>&1
436
+ ```
437
+
438
+ ### Server Won't Start
439
+
440
+ ```bash
441
+ # Check logs
442
+ tail -f ~/.ppm/server.log # If daemon mode
443
+
444
+ # Verify config is valid YAML
445
+ ppm config get port
446
+
447
+ # Clear cache and restart
448
+ rm -rf ~/.ppm/cache
449
+ ppm start --verbose # Enable debug logging (if available)
450
+ ```
451
+
452
+ ---
453
+
454
+ ## Security Checklist
455
+
456
+ ### Before Production Deployment
457
+
458
+ - [ ] Change default auth token: `ppm config set auth.token "$(openssl rand -hex 32)"`
459
+ - [ ] Verify only necessary projects are in `ppm.yaml`
460
+ - [ ] Set appropriate file permissions: `chmod 600 ~/.config/ppm/ppm.yaml`
461
+ - [ ] Keep Bun updated: `bun upgrade`
462
+ - [ ] Keep dependencies updated: `bun update`
463
+ - [ ] Review firewall rules (localhost only recommended)
464
+ - [ ] Disable password-less sudo if running as daemon
465
+ - [ ] Use HTTPS if exposing to network (via reverse proxy, e.g., nginx)
466
+ - [ ] Regularly backup `ppm.yaml` and project data
467
+
468
+ ### Network Exposure (Not Recommended)
469
+
470
+ If you must expose to network:
471
+
472
+ ```nginx
473
+ # nginx reverse proxy with SSL
474
+ upstream ppm {
475
+ server localhost:8080;
476
+ }
477
+
478
+ server {
479
+ listen 443 ssl http2;
480
+ server_name ppm.example.com;
481
+
482
+ ssl_certificate /etc/letsencrypt/live/ppm.example.com/fullchain.pem;
483
+ ssl_certificate_key /etc/letsencrypt/live/ppm.example.com/privkey.pem;
484
+
485
+ location / {
486
+ proxy_pass http://ppm;
487
+ proxy_http_version 1.1;
488
+ proxy_set_header Upgrade $http_upgrade;
489
+ proxy_set_header Connection "upgrade";
490
+ proxy_set_header Host $host;
491
+ proxy_set_header X-Real-IP $remote_addr;
492
+ }
493
+ }
494
+ ```
495
+
496
+ Then access via `https://ppm.example.com` with SSL certificate.
497
+
498
+ ---
499
+
500
+ ## Upgrade Instructions
501
+
502
+ ### From v1 to v2
503
+
504
+ ```bash
505
+ # 1. Backup existing config
506
+ cp ~/.config/ppm/ppm.yaml ~/.config/ppm/ppm.yaml.backup
507
+
508
+ # 2. Stop running server
509
+ ppm stop
510
+ # Or Ctrl+C if foreground
511
+
512
+ # 3. Download/build v2 binary
513
+ # (See "Installation" section above)
514
+
515
+ # 4. Verify new binary works
516
+ ./dist/ppm --version
517
+ # Should output: v2.0.0
518
+
519
+ # 5. Start new version
520
+ ./dist/ppm start
521
+
522
+ # 6. Test in browser
523
+ # All projects and auth token should carry over
524
+ ```
525
+
526
+ ### Rollback to v1 (If Needed)
527
+
528
+ ```bash
529
+ # 1. Stop v2 server
530
+ ppm stop
531
+
532
+ # 2. Switch back to v1 binary
533
+ # cp path/to/v1/ppm ./ppm-v1
534
+ # ./ppm-v1 start
535
+
536
+ # 3. Restore backup if config changed
537
+ # cp ~/.config/ppm/ppm.yaml.backup ~/.config/ppm/ppm.yaml
538
+ ```
539
+
540
+ ---
541
+
542
+ ## Performance Tuning
543
+
544
+ ### Increase File Descriptor Limit (Linux)
545
+
546
+ ```bash
547
+ # Check current limit
548
+ ulimit -n
549
+
550
+ # Increase to 4096 (temporary)
551
+ ulimit -n 4096
552
+
553
+ # Permanent: edit /etc/security/limits.conf
554
+ # Add: * soft nofile 4096
555
+ # * hard nofile 4096
556
+ ```
557
+
558
+ ### Memory Management
559
+
560
+ ```bash
561
+ # Monitor memory usage
562
+ # Linux
563
+ ps aux | grep ppm
564
+ free -h
565
+
566
+ # macOS
567
+ ps aux | grep ppm
568
+ vm_stat | grep page
569
+
570
+ # If using too much memory:
571
+ # 1. Reduce number of open projects
572
+ # 2. Clear browser cache
573
+ # 3. Restart server
574
+ ```
575
+
576
+ ### Network Latency
577
+
578
+ ```bash
579
+ # Test WebSocket latency
580
+ # From browser console:
581
+ console.time('ws');
582
+ ws.send({type: 'message', content: 'ping'});
583
+ // Measure response time
584
+ ```
585
+
586
+ ---
587
+
588
+ ## Monitoring
589
+
590
+ ### Health Check Endpoint
591
+
592
+ ```bash
593
+ # Health check (no auth required)
594
+ curl http://localhost:8080/api/health
595
+
596
+ # Output: { ok: true, data: { status: "healthy" } }
597
+ ```
598
+
599
+ ### Activity Logging
600
+
601
+ PPM logs to stdout in foreground mode. In daemon mode, configure:
602
+
603
+ ```yaml
604
+ # ppm.yaml
605
+ logging:
606
+ level: info # debug, info, warn, error
607
+ file: ~/.ppm/server.log
608
+ rotation: daily
609
+ retention: 7 # days
610
+ ```
611
+
612
+ ### Metrics Collection
613
+
614
+ For monitoring integrations (Prometheus, DataDog):
615
+
616
+ ```bash
617
+ # Future: /api/metrics endpoint
618
+ # Currently not implemented; planned for v2.1
619
+ ```
620
+
621
+ ---
622
+
623
+ ## Support & Troubleshooting
624
+
625
+ ### Getting Help
626
+
627
+ 1. **GitHub Issues:** https://github.com/hienlh/ppm/issues
628
+ 2. **Logs:** Check `~/.ppm/server.log` for errors
629
+ 3. **Configuration:** Validate `ppm.yaml` syntax
630
+ 4. **Dependencies:** Ensure Bun, Git, Node are installed and up-to-date
631
+