Skip to content

Commit 3a5fc83

Browse files
committed
feat: integrate PR pablodelucca#156 standalone web app server
2 parents b1124e8 + 48826c1 commit 3a5fc83

File tree

16 files changed

+2173
-63
lines changed

16 files changed

+2173
-63
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# More Pixel Agents — Design
2+
3+
## Overview
4+
5+
A standalone browser-based pixel art office that visualizes all active Claude Code agents across your machine. Fork of [pixel-agents](https://github.com/pablodelucca/pixel-agents) with three core features and one stretch goal.
6+
7+
## Goals
8+
9+
1. **Browser-based standalone app** — Run outside VS Code as a local web server (`localhost:3100`)
10+
2. **Auto-discover all active sessions** — Scan `~/.claude/projects/` for any session active in the last 30 minutes
11+
3. **Click-to-focus terminal** — Click an agent to switch to its Ghostty/iTerm/VS Code/Terminal.app tab
12+
4. **Character-to-folder config** — Assign specific character sprites to project folders
13+
5. **Mini sub-agents (stretch)** — Show smaller pixel characters when agents spawn sub-agents
14+
15+
## Approach
16+
17+
Cherry-pick/merge existing PRs into the fork, then build new features on top:
18+
19+
- **PR #156** — Standalone Node.js HTTP + WebSocket server serving the webview
20+
- **PR #157**`scanAllProjectDirs()` to watch all `~/.claude/projects/` directories
21+
- **PR #141** — External terminal detection (adapt for Ghostty focus logic)
22+
- **PR #143** — Already merged in main; browser preview foundation with `shared/` modules
23+
24+
## Architecture
25+
26+
### Standalone Server (from PR #156)
27+
28+
- Node.js HTTP server serves the built webview at `localhost:3100`
29+
- WebSocket bridge replaces VS Code's `postMessage` API
30+
- `vscodeApi.ts` auto-detects environment (VS Code vs browser) and switches transport
31+
32+
### Multi-Folder File Watcher (from PR #157)
33+
34+
- `scanAllProjectDirs()` scans all directories under `~/.claude/projects/`
35+
- Creates virtual agents for each active session (transcript modified < 30 min ago)
36+
- Watches for new JSONL transcript entries to update agent state (typing, reading, idle, etc.)
37+
38+
### Terminal Focus (new)
39+
40+
Detection flow:
41+
1. Parse session's working directory from `~/.claude/projects/` path
42+
2. Use `pgrep`/`ps` to find Claude Code processes and their parent PIDs
43+
3. Cache the session → terminal mapping
44+
45+
Focus logic (macOS, via `osascript`):
46+
- **Ghostty:** Activate app, match tab by PID or window title
47+
- **iTerm2:** Rich AppleScript support, focus tab by PID
48+
- **Terminal.app:** AppleScript to focus window
49+
- **VS Code:** `code` CLI or AppleScript
50+
- **Fallback:** Tooltip with working directory
51+
52+
### Character Config (new)
53+
54+
Config file at `~/.config/more-pixel-agents/config.json` mapping folder paths to character IDs.
55+
56+
### Mini Sub-Agents (stretch goal)
57+
58+
Detect `Agent` tool invocations, render at ~60% scale, cap at 4 per parent.
59+
60+
## Implementation Order
61+
62+
1. Fork repo, integrate PRs #156 + #157
63+
2. Add character-to-folder config system
64+
3. Build terminal detection + focus-switching
65+
4. (Stretch) Mini sub-agent rendering

standalone/build.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import esbuild from 'esbuild';
2+
3+
await esbuild.build({
4+
entryPoints: ['src/server.ts'],
5+
bundle: true,
6+
format: 'esm',
7+
platform: 'node',
8+
target: 'node20',
9+
outfile: 'dist/server.js',
10+
sourcemap: true,
11+
banner: {
12+
js: `
13+
import { createRequire } from 'module';
14+
import { fileURLToPath as ___fileURLToPath } from 'url';
15+
import { dirname as ___dirname } from 'path';
16+
const require = createRequire(import.meta.url);
17+
const __filename = ___fileURLToPath(import.meta.url);
18+
const __dirname = ___dirname(__filename);
19+
`,
20+
},
21+
external: [],
22+
});
23+
24+
console.log('Build complete: dist/server.js');

0 commit comments

Comments
 (0)