project-compass 4.3.6 → 4.3.8

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 (41) hide show
  1. package/AGENTS.md +1121 -22
  2. package/ARCHITECTURE.md +826 -10
  3. package/CONTRIBUTING.md +974 -10
  4. package/PROJECT_CONTEXT.md +404 -0
  5. package/README.md +637 -67
  6. package/assets/screenshots/ai_mode.png +0 -0
  7. package/assets/screenshots/art_bar.png +0 -0
  8. package/assets/screenshots/help_structure.png +0 -0
  9. package/assets/screenshots/home.png +0 -0
  10. package/assets/screenshots/languages_checker_omni_studio.png +0 -0
  11. package/assets/screenshots/task_manager.png +0 -0
  12. package/commands.md +841 -104
  13. package/package.json +5 -4
  14. package/src/cli.js +310 -169
  15. package/src/components/AIHorizon.js +138 -255
  16. package/src/components/Footer.js +8 -64
  17. package/src/components/Header.js +8 -47
  18. package/src/components/Navigator.js +16 -70
  19. package/src/components/PackageRegistry.js +4 -3
  20. package/src/components/ProjectArchitect.js +6 -1
  21. package/src/components/TaskManager.js +12 -70
  22. package/src/detectors/dotnet.js +3 -2
  23. package/src/detectors/frameworks.js +28 -28
  24. package/src/detectors/go.js +6 -6
  25. package/src/detectors/java.js +2 -1
  26. package/src/detectors/node.js +3 -2
  27. package/src/detectors/php.js +1 -1
  28. package/src/detectors/python.js +11 -4
  29. package/src/detectors/ruby.js +1 -1
  30. package/src/detectors/rust.js +2 -2
  31. package/src/detectors/utils.js +6 -7
  32. package/src/projectDetection.js +41 -5
  33. package/assets/screenshots/architect.jpg +0 -0
  34. package/assets/screenshots/artboard.jpg +0 -0
  35. package/assets/screenshots/exit-confirm.jpg +0 -0
  36. package/assets/screenshots/navigator.jpg +0 -0
  37. package/assets/screenshots/overlays.jpg +0 -0
  38. package/assets/screenshots/registry.jpg +0 -0
  39. package/assets/screenshots/studio.jpg +0 -0
  40. package/assets/screenshots/taskmanager.jpg +0 -0
  41. package/src/store/useProjectStore.js +0 -32
@@ -0,0 +1,404 @@
1
+ # Project Compass - Context Document
2
+
3
+ ## Overview
4
+ Project Compass is a terminal UI (TUI) workspace navigator and runner built with **Ink (React for CLI)**. It automatically detects projects across multiple languages and provides an interface to manage, run, and analyze them with optional AI integration.
5
+
6
+ **Version:** 4.3.6
7
+ **Author:** Satyaa & Clawdy
8
+ **License:** MIT
9
+
10
+ ---
11
+
12
+ ## Architecture
13
+
14
+ ### Entry Point
15
+ - **`src/cli.js`** - Main entry point with argument parsing and the root `Compass` React component
16
+ - Handles: `--dir`, `--mode test`, `--studio`, `--ai`, `--task`, `--help`, `--version`
17
+ - Renders the Ink application with the `Compass` component
18
+
19
+ ### Core Detection System
20
+ - **`src/projectDetection.js`** - Orchestrates project discovery
21
+ - Uses `fast-glob` to scan for manifest files
22
+ - Runs detectors in priority order (higher priority wins)
23
+ - Applies framework plugins after detection
24
+ - Exports `discoverProjects(root)` async function
25
+
26
+ ### Detectors (`src/detectors/`)
27
+ Each detector exports an object with:
28
+ - `type` - Language identifier
29
+ - `label` - Display name
30
+ - `icon` - Emoji icon
31
+ - `priority` - Numeric priority (higher = preferred)
32
+ - `files` - Manifest files to match
33
+ - `binaries` - Required binaries to check
34
+ - `build(projectPath, manifest)` - Async function returning project object
35
+
36
+ **Available Detectors:**
37
+ | Detector | Priority | Manifest Files | Package Manager |
38
+ |----------|----------|----------------|-----------------|
39
+ | `node.js` | 100 | `package.json` | Auto-detects: npm/yarn/pnpm/bun |
40
+ | `python.js` | 95 | `pyproject.toml`, `requirements.txt`, `setup.py`, `Pipfile`, `manage.py` | Auto-detects: uv/poetry/pipenv/pip |
41
+ | `rust.js` | 90 | `Cargo.toml` | cargo |
42
+ | `go.js` | 85 | `go.mod` | go |
43
+ | `java.js` | 80 | `pom.xml`, `build.gradle` | maven/gradle |
44
+ | `php.js` | 75 | `composer.json` | composer |
45
+ | `ruby.js` | 70 | `Gemfile` | bundler |
46
+ | `dotnet.js` | 65 | `*.csproj`, `*.fsproj` | dotnet |
47
+ | `generic.js` | 10 | Various | None |
48
+
49
+ ### Framework Plugins (`src/detectors/frameworks.js`)
50
+ Built-in framework detection with 40+ frameworks:
51
+ - **Node.js:** Next.js, React, Vue, Express, Fastify, Koa, NestJS, Svelte, Astro, Nuxt, Vite, Tailwind, Prisma, tRPC, GraphQL
52
+ - **Python:** FastAPI, Flask, Django, AioHTTP, Sanic, Tornado, Pytest, SQLAlchemy
53
+ - **Rust:** Actix, Rocket, Axum, Warp, Tokio
54
+ - **Go:** Gin, Echo, Fiber, Chi
55
+ - **Java:** Spring Boot, Quarkus, Micronaut
56
+ - **PHP:** Laravel, Symfony, CodeIgniter
57
+ - **Ruby:** Rails, Sinatra
58
+ - **.NET:** ASP.NET Core, Blazor
59
+ - **ML/Data:** Pandas, PyTorch, TensorFlow
60
+
61
+ **Plugin System:** Users can add custom frameworks via `~/.project-compass/plugins.json`
62
+
63
+ ### Components (`src/components/`)
64
+ All components use `React.createElement` directly (no JSX) with Ink's `Box` and `Text`.
65
+
66
+ | Component | Purpose | Key Props |
67
+ |-----------|---------|-----------|
68
+ | `Navigator.js` | Project list with pagination (maxVisibleProjects) | `projects`, `selectedIndex`, `rootPath`, `loading`, `error`, `maxVisibleProjects` |
69
+ | `Header.js` | Top bar with logo, status, time | `projectCountLabel`, `rootPath`, `running`, `toggleHint`, `orbitHint` |
70
+ | `Footer.js` | Bottom bar with stdin input | `toggleHint`, `running`, `stdinBuffer`, `stdinCursor`, `CursorText` |
71
+ | `TaskManager.js` | Orbit Task Manager for background processes | `tasks`, `activeTaskId`, `renameMode`, `renameInput`, `renameCursor`, `CursorText` |
72
+ | `PackageRegistry.js` | Dependency management (add/remove) | `selectedProject`, `projects`, `onRunCommand`, `CursorText`, `onSelectProject` |
73
+ | `ProjectArchitect.js` | Scaffolding/new project templates | `rootPath`, `onRunCommand`, `CursorText`, `onReturn` |
74
+ | `AIHorizon.js` | AI-powered project analysis | `selectedProject`, `CursorText`, `config`, `setConfig`, `saveConfig` |
75
+ | `Studio.js` | Environment health check (runtimes) | None (checks binaries) |
76
+
77
+ ### State Management
78
+ - **Primary State:** Held in `Compass` component (`src/cli.js`)
79
+ - `projects` - Detected projects array
80
+ - `selectedIndex` - Currently selected project index
81
+ - `viewMode` - 'list' or 'detail'
82
+ - `mainView` - 'navigator', 'tasks', 'registry', 'architect', 'ai', 'studio'
83
+ - `tasks` - Array of running/completed tasks
84
+ - `activeTaskId` - Currently selected task
85
+ - `config` - Loaded from `~/.project-compass/config.json`
86
+
87
+ - **Config Persistence:** `src/configPaths.js`
88
+ - Config dir: `~/.project-compass/`
89
+ - Config file: `config.json`
90
+ - Plugin file: `plugins.json`
91
+
92
+ ---
93
+
94
+ ## Data Flow
95
+
96
+ ### Project Detection Flow
97
+ ```
98
+ User runs project-compass
99
+
100
+ cli.js: main() → discoverProjects(rootPath)
101
+
102
+ projectDetection.js: Iterates detectors[]
103
+
104
+ For each detector: fast-glob → find manifest files → detector.build()
105
+
106
+ Apply framework plugins (frameworks.js + plugins.json)
107
+
108
+ Return sorted array (by priority) → stored in Compass state
109
+ ```
110
+
111
+ ### Command Execution Flow
112
+ ```
113
+ User presses key (b/t/r/i or Enter on detail view)
114
+
115
+ useInput handler in Compass component
116
+
117
+ runProjectCommand(commandMeta, project)
118
+
119
+ execa spawns subprocess with:
120
+ - cwd: project.path
121
+ - stdin: 'pipe' (for interactive input)
122
+ - detached: true (on non-Windows)
123
+
124
+ stdout/stderr → addLogToTask(taskId, line)
125
+
126
+ Task status updates: 'running' → 'finished'/'failed'/'killed'
127
+ ```
128
+
129
+ ### Task Management
130
+ - Tasks stored in `tasks` array with shape:
131
+ ```javascript
132
+ {
133
+ id: 'task-' + Date.now(),
134
+ name: 'Project · Command',
135
+ status: 'running' | 'finished' | 'failed' | 'killed',
136
+ logs: string[],
137
+ project: 'Project Name'
138
+ }
139
+ ```
140
+ - Process references stored in `runningProcessMap` (useRef Map)
141
+ - Log buffer capped at 500 lines
142
+
143
+ ---
144
+
145
+ ## Keyboard Shortcuts
146
+
147
+ ### Global Navigation
148
+ | Key | Action |
149
+ |-----|--------|
150
+ | `↑` / `↓` | Navigate projects |
151
+ | `PgUp` / `PgDn` | Jump pages (maxVisibleProjects) |
152
+ | `Enter` | Toggle detail view |
153
+ | `Esc` | Back to navigator / cancel input |
154
+ | `?` | Toggle help overlay |
155
+
156
+ ### Quick Actions (in detail view)
157
+ | Key | Action |
158
+ |-----|--------|
159
+ | `B` | Build |
160
+ | `T` | Test |
161
+ | `R` | Run |
162
+ | `I` | Install |
163
+ | `0` | AI Analysis (switches to AI view) |
164
+
165
+ ### Number Keys (detail view)
166
+ | Key | Action |
167
+ |-----|--------|
168
+ | `1-9` | Run numbered commands |
169
+ | `Shift+1-9` (A-Z) | Run commands 10+ |
170
+
171
+ ### Shift Combinations
172
+ | Key | Action |
173
+ |-----|--------|
174
+ | `Shift+H` | Toggle help cards |
175
+ | `Shift+S` | Toggle structure guide |
176
+ | `Shift+A` | Toggle Studio view |
177
+ | `Shift+P` | Package Registry |
178
+ | `Shift+N` | Project Architect |
179
+ | `Shift+O` | AI Horizon |
180
+ | `Shift+T` | Task Manager |
181
+ | `Shift+Q` | Quit (with confirmation if tasks running) |
182
+ | `Shift+B` | Toggle Art Board |
183
+ | `Shift+X` | Clear active log |
184
+ | `Shift+E` | Export logs to file |
185
+ | `Shift+D` | Detach from task |
186
+ | `Shift+L` | Re-run last command |
187
+ | `Shift+C` | Add custom command |
188
+ | `Shift+R` (tasks) | Rename task |
189
+ | `Shift+K` (tasks) | Kill task |
190
+ | `Shift+↑/↓` | Scroll output logs |
191
+
192
+ ### Custom Input Modes
193
+ - **Custom Command:** `Shift+C` → `label|command` format
194
+ - **Port Config:** `Shift+R` in detail → enter port number
195
+ - **Rename Task:** `Shift+R` in tasks → enter new name
196
+ - **Stdin Input:** When process running → type → Enter to send
197
+
198
+ ---
199
+
200
+ ## Recent Fixes (2026-05-08)
201
+
202
+ ### 1. Framework Hallucination Bug FIXED
203
+ **Problem:** Projects without frameworks were showing random frameworks (e.g., simple Python project with `main.py` was detected as FastAPI).
204
+
205
+ **Root Cause:** Framework matchers in `frameworks.js` used file existence (`hasProjectFile`) instead of dependency matching.
206
+
207
+ **Fix Applied:**
208
+ - `fastapi` matcher: Removed `|| hasProjectFile(project.path, 'main.py')` (line 328)
209
+ - `django` matcher: Removed `|| hasProjectFile(project.path, 'manage.py')` (line 370)
210
+ - `spring-boot` matcher: Removed `|| hasProjectFile(project.path, 'pom.xml') || hasProjectFile(project.path, 'build.gradle')`
211
+ - `quarkus` matcher: Removed `|| hasProjectFile(project.path, 'pom.xml')`
212
+ - `micronaut` matcher: Removed `|| hasProjectFile(project.path, 'pom.xml')`
213
+ - `rails` matcher: Changed to use `dependencyMatches(project, 'rails')` instead of file checks
214
+ - `sinatra` matcher: Removed `|| hasProjectFile(project.path, 'config.ru')`
215
+ - `.NET` matchers: Now use dependency checks instead of `*.csproj` file existence
216
+
217
+ **Result:** Projects without explicit framework dependencies now correctly show `Frameworks: none`.
218
+
219
+ ### 2. compass-config.js Integration
220
+ **Problem:** `compass-config.js` existed but was never integrated into project detection.
221
+
222
+ **Fix Applied:**
223
+ - Added import of `loadProjectConfig` in `projectDetection.js`
224
+ - Integrated into `discoverProjects()` function to load `compass.config.js` from project directories
225
+ - Project-specific commands and frameworks from `compass.config.js` are now merged into project data
226
+
227
+ ### 3. AI Horizon Improvements
228
+ **Problem:** AI Horizon didn't properly show raw AI output and had poor JSON parsing.
229
+
230
+ **Fix Applied:**
231
+ - Added `rawAIResponse` state to store raw AI output
232
+ - Improved JSON parsing to handle markdown code blocks (```json ... ```)
233
+ - Raw AI response is now displayed in the UI during review step
234
+ - Better error messages showing partial AI response if JSON parsing fails
235
+
236
+ ### 4. Node.js Framework Detection
237
+ **Problem:** `node.js` detector was adding "Node.js" as a framework.
238
+
239
+ **Fix Applied:**
240
+ - Detector now only adds framework if it's not the generic "Node.js" type
241
+ - Projects using plain Node.js without frameworks now show `Frameworks: none`
242
+
243
+ ### 5. Framework Deduplication
244
+ **Problem:** `applyFrameworkPlugins()` could add duplicate frameworks.
245
+
246
+ **Fix Applied:**
247
+ - Added check to avoid adding duplicate frameworks
248
+ - Now preserves detector-detected frameworks and merges with plugin-detected ones
249
+
250
+ ---
251
+
252
+ ## Common Patterns
253
+
254
+ ### Component Creation
255
+ All components use `React.createElement` (aliased as `create`):
256
+ ```javascript
257
+ const create = React.createElement;
258
+ // ...
259
+ create(Box, {flexDirection: 'column'},
260
+ create(Text, {color: 'cyan'}, 'Hello'))
261
+ ```
262
+
263
+ ### Input Handling
264
+ Components use Ink's `useInput` hook:
265
+ ```javascript
266
+ useInput((input, key) => {
267
+ if (key.return) { /* handle enter */ }
268
+ if (key.escape) { /* handle escape */ }
269
+ if (key.upArrow) { /* handle up */ }
270
+ if (input) { /* handle character input */ }
271
+ });
272
+ ```
273
+
274
+ ### Cursor Text Input
275
+ Reusable `CursorText` component for text input with cursor:
276
+ ```javascript
277
+ <CursorText value={input} cursorIndex={cursor} active={isActive} />
278
+ ```
279
+
280
+ ### Command Structure
281
+ Commands are stored as:
282
+ ```javascript
283
+ {
284
+ label: 'Display Name',
285
+ command: ['executable', 'arg1', 'arg2'], // Array form
286
+ source: 'builtin' | 'custom' | 'framework' | 'plugin' | 'ai'
287
+ }
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Potential Bug Areas
293
+
294
+ ### 1. **Config Loading**
295
+ - `loadConfig()` is called in `useState(() => loadConfig())`
296
+ - If config file is corrupted, falls back to defaults but doesn't persist the fix
297
+
298
+ ### 2. **Process Killing on Windows**
299
+ - Line 242: `execa('taskkill', ['/pid', proc.pid, '/f', '/t'])`
300
+ - May not properly kill child processes
301
+
302
+ ### 3. **Log Buffer Memory**
303
+ - Capped at 500 lines, but truncation happens in `addLogToTask`
304
+ - If many tasks run simultaneously, memory could grow
305
+
306
+ ### 4. **fast-glob Depth**
307
+ - `projectDetection.js` line 155: `deep: 5`
308
+ - Could miss deeply nested projects or be slow on large directories
309
+
310
+ ### 5. **AI JSON Parsing**
311
+ - `AIHorizon.js` line 173: `aiText.match(/{[\s\S]*?}/)`
312
+ - Regex may fail on malformed JSON or if AI returns code blocks
313
+
314
+ ---
315
+
316
+ ## Enhancement Opportunities
317
+
318
+ ### 1. **Add More Detectors**
319
+ - Flutter (`pubspec.yaml`)
320
+ - Elixir (`mix.exs`)
321
+ - Swift (`Package.swift`)
322
+ - Haskell (`stack.yaml` or `.cabal`)
323
+
324
+ ### 3. **Improve Log Viewing**
325
+ - Add search/filter in log panel
326
+ - Click to expand collapsed logs
327
+ - Export per-task logs (currently exports active only)
328
+
329
+ ### 4. **Enhanced AI Integration**
330
+ - Stream AI responses (currently waits for full response)
331
+ - Support more AI providers (OpenAI, Anthropic directly)
332
+ - Cache AI suggestions per project
333
+
334
+ ### 5. **Configuration UI**
335
+ - Add a settings view to configure:
336
+ - maxVisibleProjects
337
+ - AI provider settings
338
+ - Custom keybindings
339
+ - Theme/colors
340
+
341
+ ### 6. **Task Dependencies**
342
+ - Allow tasks to depend on other tasks
343
+ - Sequential task execution
344
+
345
+ ### 7. **Project Groups/Tags**
346
+ - Allow users to tag projects
347
+ - Filter projects by tag
348
+
349
+ ### 8. **WebSocket/Real-time Updates**
350
+ - Watch for file changes and re-detect projects
351
+ - Hot-reload when `plugins.json` changes
352
+
353
+ ---
354
+
355
+ ## File Reference Quick Links
356
+
357
+ | File | Line Numbers | Purpose |
358
+ |------|-------------|---------|
359
+ | `src/cli.js` | 1-840 | Main app, all state, input handling |
360
+ | `src/projectDetection.js` | 1-189 | Detection orchestrator |
361
+ | `src/detectors/utils.js` | 1-148 | Shared utilities |
362
+ | `src/detectors/frameworks.js` | 1-877 | Framework plugins |
363
+ | `src/detectors/node.js` | 1-140 | Node.js detection |
364
+ | `src/detectors/python.js` | 1-208 | Python detection |
365
+ | `src/components/Navigator.js` | 1-110 | Project list |
366
+ | `src/components/TaskManager.js` | 1-82 | Task management |
367
+ | `src/components/AIHorizon.js` | 1-426 | AI analysis |
368
+ | `src/configPaths.js` | 1-13 | Config file paths |
369
+
370
+ ---
371
+
372
+ ## Development Commands
373
+
374
+ ```bash
375
+ # Start the app
376
+ node src/cli.js
377
+
378
+ # Test project detection only
379
+ node src/cli.js --mode test
380
+
381
+ # Lint
382
+ npm run lint
383
+
384
+ # Directories
385
+ ~/.project-compass/config.json # User config
386
+ ~/.project-compass/plugins.json # Custom framework plugins
387
+ ```
388
+
389
+ ---
390
+
391
+ ## Key Dependencies
392
+
393
+ | Package | Version | Purpose |
394
+ |---------|---------|---------|
395
+ | `ink` | ^5.1.0 | React for CLI (TUI) |
396
+ | `react` | ^18.2.0 | UI framework |
397
+ | `execa` | ^9.5.2 | Process execution |
398
+ | `fast-glob` | ^3.3.3 | File searching |
399
+ | `kleur` | ^4.1.5 | Terminal colors |
400
+
401
+ ---
402
+
403
+ **Last Updated:** 2026-05-08
404
+ **Context For:** Bug fixes, enhancements, feature development