@slycode/slycode 0.1.0 → 0.1.2
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/dist/web/.next/BUILD_ID +1 -1
- package/dist/web/.next/build-manifest.json +2 -2
- package/dist/web/.next/server/app/_global-error.html +2 -2
- package/dist/web/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.html +1 -1
- package/dist/web/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__09aec55a._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__198f01e0._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__2b639eab._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__3b9d3e43._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__3f239285._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__4244617a._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__46b023d4._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__4c7995bf._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__4d0d3464._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__543058c2._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__6d330d40._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__884d73e4._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__9058a007._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__933e6077._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__949bb248._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__949d814c._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__aa814a86._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__ad64e04f._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__b90bbd70._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__baa99257._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__bbb4b3ac._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__bc55c42a._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__bf286c26._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__ce429522._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__d38c7a96._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__e88a19d2._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__e9b0e744._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__f1fe18e6._.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__f59af2bc._.js +1 -1
- package/dist/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_ffc6c790.js +1 -1
- package/dist/web/.next/server/pages/404.html +1 -1
- package/dist/web/.next/server/pages/500.html +2 -2
- package/dist/web/src/app/api/git-status/route.ts +1 -0
- package/dist/web/src/app/api/projects/analyze/route.ts +1 -0
- package/dist/web/src/app/api/projects/route.ts +1 -0
- package/dist/web/src/app/api/transcribe/route.ts +1 -1
- package/dist/web/src/app/api/version-check/route.ts +3 -2
- package/dist/web/src/lib/paths.ts +1 -1
- package/lib/cli/doctor.d.ts.map +1 -1
- package/lib/cli/doctor.js +2 -1
- package/lib/cli/doctor.js.map +1 -1
- package/lib/cli/service.js +3 -3
- package/lib/cli/service.js.map +1 -1
- package/lib/cli/start.d.ts.map +1 -1
- package/lib/cli/start.js +3 -2
- package/lib/cli/start.js.map +1 -1
- package/lib/cli/stop.d.ts.map +1 -1
- package/lib/cli/stop.js +6 -4
- package/lib/cli/stop.js.map +1 -1
- package/lib/cli/update.d.ts.map +1 -1
- package/lib/cli/update.js +11 -8
- package/lib/cli/update.js.map +1 -1
- package/lib/cli/workspace.js +1 -1
- package/lib/cli/workspace.js.map +1 -1
- package/lib/platform/service-macos.js +1 -1
- package/lib/platform/service-macos.js.map +1 -1
- package/lib/platform/service-windows.js +1 -1
- package/lib/platform/service-windows.js.map +1 -1
- package/lib/platform/symlinks.js +1 -1
- package/lib/platform/symlinks.js.map +1 -1
- package/package.json +1 -1
- package/templates/kanban-seed.json +1 -1
- package/templates/tutorial-project/.agents/skills/checkpoint/SKILL.md +43 -0
- package/templates/tutorial-project/.agents/skills/context-priming/SKILL.md +152 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/area-index.md +101 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/areas/claude-actions.md +120 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/areas/messaging.md +177 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/areas/scripts-deployment.md +138 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/areas/skills.md +135 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/areas/terminal-bridge.md +232 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/areas/web-frontend.md +252 -0
- package/templates/tutorial-project/.agents/skills/context-priming/references/maintenance.md +128 -0
- package/templates/tutorial-project/.agents/skills/design/SKILL.md +141 -0
- package/templates/tutorial-project/.agents/skills/feature/SKILL.md +159 -0
- package/templates/tutorial-project/.agents/skills/implement/SKILL.md +132 -0
- package/templates/tutorial-project/.agents/skills/kanban/SKILL.md +264 -0
- package/templates/tutorial-project/.claude/skills/checkpoint/SKILL.md +43 -0
- package/templates/tutorial-project/.claude/skills/context-priming/SKILL.md +152 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/area-index.md +101 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/areas/claude-actions.md +120 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/areas/messaging.md +177 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/areas/scripts-deployment.md +138 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/areas/skills.md +135 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/areas/terminal-bridge.md +232 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/areas/web-frontend.md +252 -0
- package/templates/tutorial-project/.claude/skills/context-priming/references/maintenance.md +128 -0
- package/templates/tutorial-project/.claude/skills/design/SKILL.md +141 -0
- package/templates/tutorial-project/.claude/skills/feature/SKILL.md +159 -0
- package/templates/tutorial-project/.claude/skills/implement/SKILL.md +132 -0
- package/templates/tutorial-project/.claude/skills/kanban/SKILL.md +264 -0
- package/templates/tutorial-project/CLAUDE.md +16 -0
- package/templates/tutorial-project/documentation/designs/example_welcome_dashboard.md +38 -0
- package/templates/tutorial-project/documentation/events.json +1 -0
- package/templates/tutorial-project/documentation/features/example_in_card_deliverable_feature.md +31 -0
- package/templates/tutorial-project/documentation/kanban.json +385 -0
- /package/dist/web/.next/static/{ALUsM8gaUuQnX2hccTsJd → 4GrOHGHgp_-wfmjYR4P3O}/_buildManifest.js +0 -0
- /package/dist/web/.next/static/{ALUsM8gaUuQnX2hccTsJd → 4GrOHGHgp_-wfmjYR4P3O}/_clientMiddlewareManifest.json +0 -0
- /package/dist/web/.next/static/{ALUsM8gaUuQnX2hccTsJd → 4GrOHGHgp_-wfmjYR4P3O}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Terminal Bridge
|
|
2
|
+
|
|
3
|
+
Updated: 2026-02-14
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
PTY bridge server manages AI coding sessions across multiple providers (Claude, Gemini, Codex). Express server spawns/manages PTY processes, streams output via SSE. Provider-agnostic command building via data-driven config (`providers.json`). Includes security hardening (command whitelist, CWD validation, localhost binding), activity tracking with transition logging for debugging, atomic state persistence, bulk session management, and graceful idle timeout handling. React components connect through Next.js API proxy.
|
|
8
|
+
|
|
9
|
+
## Key Files
|
|
10
|
+
|
|
11
|
+
### Bridge Server (Node/Express)
|
|
12
|
+
- `bridge/src/index.ts` - Express server entry, routes setup, localhost binding
|
|
13
|
+
- `bridge/src/session-manager.ts` - Session lifecycle, PTY spawning, provider resolution, activity tracking, atomic state saving
|
|
14
|
+
- `bridge/src/provider-utils.ts` - Provider config loading, command building, session detection helpers
|
|
15
|
+
- `bridge/src/pty-handler.ts` - PTY process wrapper, output buffering
|
|
16
|
+
- `bridge/src/api.ts` - REST endpoints for session CRUD, /stats, stop-all, activity-log
|
|
17
|
+
- `bridge/src/websocket.ts` - WebSocket upgrade handling (legacy, SSE preferred)
|
|
18
|
+
- `bridge/src/claude-utils.ts` - Claude session ID detection from ~/.claude/projects/
|
|
19
|
+
- `bridge/src/types.ts` - Session, BridgeConfig, BridgeStats, ActivityTransition, provider interfaces
|
|
20
|
+
|
|
21
|
+
### Configuration
|
|
22
|
+
- `bridge/bridge-config.json` - Runtime config: allowedCommands (claude, codex, gemini, bash), CORS origins
|
|
23
|
+
- `data/providers.json` - Provider registry: CLI commands, permission flags, resume types, prompt handling, stage defaults
|
|
24
|
+
- `documentation/terminal-classes.json` - Terminal class definitions for command visibility
|
|
25
|
+
- `data/commands.json` - Unified command configuration with visibility per class
|
|
26
|
+
|
|
27
|
+
### Web Components
|
|
28
|
+
- `web/src/components/Terminal.tsx` - xterm.js terminal, SSE via ConnectionManager
|
|
29
|
+
- `web/src/components/ClaudeTerminalPanel.tsx` - Terminal panel with startupCommands/activeCommands
|
|
30
|
+
- `web/src/components/GlobalClaudePanel.tsx` - Floating panel for project-wide session
|
|
31
|
+
- `web/src/app/api/bridge/[...path]/route.ts` - Next.js proxy to bridge server
|
|
32
|
+
|
|
33
|
+
## Key Functions
|
|
34
|
+
|
|
35
|
+
- `SessionManager.createSession()` - Resolves provider, builds command via `buildProviderCommand()`, validates CWD, spawns PTY
|
|
36
|
+
- `SessionManager.resolveSessionName()` - Checks both new (with provider) and legacy session name formats
|
|
37
|
+
- `SessionManager.stopSession()` - Graceful SIGINT, waits for exit
|
|
38
|
+
- `SessionManager.stopAllSessions()` - Bulk stop all running/detached sessions, returns count
|
|
39
|
+
- `SessionManager.getStats()` - Returns BridgeStats with activity info
|
|
40
|
+
- `SessionManager.checkIdleSessions()` - Idle timeout with grace period after disconnect
|
|
41
|
+
- `buildProviderCommand()` - Assembles { command, args } from provider config, handles flag vs subcommand resume
|
|
42
|
+
- `getProvider()` - Loads provider config by ID from providers.json (30s cache)
|
|
43
|
+
- `supportsSessionDetection()` - Check if provider supports GUID-based session detection
|
|
44
|
+
- `Terminal.connectSSE()` - Via ConnectionManager for auto-reconnection
|
|
45
|
+
|
|
46
|
+
## Data Models
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
SessionInfo {
|
|
50
|
+
name, status (running|stopped|detached), pid, connectedClients,
|
|
51
|
+
hasHistory, claudeSessionId, lastOutputAt,
|
|
52
|
+
provider?, skipPermissions?,
|
|
53
|
+
lastOutputSnippet?, lastOutputRawHex?, lastOutputDataLength?
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
BridgeStats {
|
|
57
|
+
bridgeTerminals: number; // Total PTY sessions
|
|
58
|
+
connectedClients: number; // Total SSE/WS connections
|
|
59
|
+
activelyWorking: number; // Sessions with output in last 2s
|
|
60
|
+
sessions: SessionActivity[]; // Per-session activity
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
SessionActivity {
|
|
64
|
+
name, status, lastOutputAt, isActive
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
ActivityTransition {
|
|
68
|
+
timestamp: string;
|
|
69
|
+
from: string; // Previous state
|
|
70
|
+
to: string; // New state
|
|
71
|
+
lastOutputAt: string;
|
|
72
|
+
outputAge: number;
|
|
73
|
+
trigger?: { // Debug info for phantom blips
|
|
74
|
+
snippet: string;
|
|
75
|
+
hex: string;
|
|
76
|
+
dataLength: number;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
BridgeConfig {
|
|
81
|
+
host, port, sessionFile, defaultIdleTimeout, maxSessions
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
BridgeRuntimeConfig {
|
|
85
|
+
allowedCommands: string[]; // e.g., ['claude', 'codex', 'gemini', 'bash']
|
|
86
|
+
cors: { origins: string[] }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
CreateSessionRequest {
|
|
90
|
+
name: string;
|
|
91
|
+
provider?: string; // Provider id from providers.json
|
|
92
|
+
skipPermissions?: boolean; // Whether to add permission-skip flag
|
|
93
|
+
command?: string; // Legacy: direct command (backward compat)
|
|
94
|
+
cwd: string;
|
|
95
|
+
prompt?: string;
|
|
96
|
+
fresh?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
PersistedSession {
|
|
100
|
+
claudeSessionId?, cwd, createdAt, lastActive,
|
|
101
|
+
provider?: string; // Defaults to 'claude' for old sessions
|
|
102
|
+
skipPermissions?: boolean; // Defaults to true for old sessions
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Provider config types (provider-utils.ts)
|
|
106
|
+
ProviderConfig {
|
|
107
|
+
id, displayName, command, install,
|
|
108
|
+
permissions: { flag, label, default },
|
|
109
|
+
resume: { supported, type ('flag'|'subcommand'), flag?, subcommand?, lastFlag?, detectSession, sessionDir? },
|
|
110
|
+
prompt: { type ('positional'|'flag'), interactive?, nonInteractive? }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
ProvidersData {
|
|
114
|
+
providers: Record<string, ProviderConfig>;
|
|
115
|
+
defaults: {
|
|
116
|
+
stages: Record<string, { provider, skipPermissions }>;
|
|
117
|
+
global: { provider, skipPermissions };
|
|
118
|
+
projects: Record<string, { provider, skipPermissions }>;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Security Hardening
|
|
124
|
+
|
|
125
|
+
- **Localhost binding**: HOST defaults to `localhost` (not `0.0.0.0`)
|
|
126
|
+
- **Command whitelist**: Only commands in `bridge-config.json` allowedCommands can be spawned (claude, codex, gemini, bash)
|
|
127
|
+
- **Provider validation**: Provider ID must exist in providers.json; resolved command must be in allowedCommands
|
|
128
|
+
- **CWD validation**: Requires absolute path, verifies exists and is accessible before spawning PTY
|
|
129
|
+
- **CORS origins**: Configured in bridge-config.json, not wide-open
|
|
130
|
+
|
|
131
|
+
## Activity Tracking
|
|
132
|
+
|
|
133
|
+
- `lastOutputAt` timestamp updated on every PTY output
|
|
134
|
+
- `isActive` = output within last 2 seconds (with 1s debounce)
|
|
135
|
+
- `activelyWorking` count in BridgeStats for health monitor
|
|
136
|
+
- Cards with active sessions show pulsing green glow in UI
|
|
137
|
+
- **Activity transitions**: Logged with trigger details (snippet, hex, data length) for debugging phantom blips
|
|
138
|
+
- `GET /activity-log/:name` endpoint exposes transition history per session
|
|
139
|
+
|
|
140
|
+
## State Persistence
|
|
141
|
+
|
|
142
|
+
- Session state saved to bridge-sessions.json via atomic writes (temp file + rename)
|
|
143
|
+
- State file uses `__dirname` resolution for reliable file location
|
|
144
|
+
- Missing file (ENOENT) handled gracefully; corrupt JSON throws fatal error
|
|
145
|
+
- Prevents silent data loss from corrupted state
|
|
146
|
+
|
|
147
|
+
## Race Condition Handling
|
|
148
|
+
|
|
149
|
+
- **Disconnect grace period**: 5 seconds before session eligible for idle timeout
|
|
150
|
+
- **Status transitions**: Protected against reconnect during disconnect
|
|
151
|
+
- **SSE cleanup**: Proper client tracking on connection/disconnection
|
|
152
|
+
|
|
153
|
+
## Terminal Classes
|
|
154
|
+
|
|
155
|
+
Controls which commands appear in each context:
|
|
156
|
+
- `global-terminal` - Dashboard terminal (future)
|
|
157
|
+
- `project-terminal` - Project-level panel at bottom
|
|
158
|
+
- `backlog`, `design`, `implementation`, `testing`, `done` - Card terminals by stage
|
|
159
|
+
- `action-assistant` - Terminal in SlyActionConfigModal
|
|
160
|
+
|
|
161
|
+
## Multi-Provider System
|
|
162
|
+
|
|
163
|
+
### Supported Providers
|
|
164
|
+
- **Claude Code** (`claude`) — Positional prompts, `--resume <GUID>` with auto-detection, `--dangerously-skip-permissions`
|
|
165
|
+
- **Codex CLI** (`codex`) — Positional prompts, `codex resume --last` (subcommand-style), `--yolo`
|
|
166
|
+
- **Gemini CLI** (`gemini`) — Flag-based prompts (`-i`/`-p`), `--resume` (no GUID), `--yolo`
|
|
167
|
+
|
|
168
|
+
### Command Building (`buildProviderCommand`)
|
|
169
|
+
- Returns `{ command, args }` tuple (command can change for Codex resume: `codex resume`)
|
|
170
|
+
- Permission flag added if `skipPermissions: true`
|
|
171
|
+
- Resume: flag-type appends `--resume [GUID]`; subcommand-type prepends `resume [GUID|--last]`
|
|
172
|
+
- Prompt: positional appends as final arg; flag-type uses `-i <prompt>` (interactive)
|
|
173
|
+
- No prompt on resume (user types into running session instead)
|
|
174
|
+
|
|
175
|
+
### Session Name Format
|
|
176
|
+
- **New format**: `{projectId}:{provider}:card:{cardId}` or `{projectId}:{provider}:global`
|
|
177
|
+
- **Legacy format**: `{projectId}:card:{cardId}` or `{projectId}:global`
|
|
178
|
+
- `resolveSessionName()` checks new format first, falls back to legacy via `toLegacySessionName()`
|
|
179
|
+
- Old sessions without provider field default to `provider: "claude"`
|
|
180
|
+
|
|
181
|
+
### GUID Detection (Claude only)
|
|
182
|
+
- `supportsSessionDetection()` checks `provider.resume.detectSession`
|
|
183
|
+
- Watches `~/.claude/projects/` for new `.jsonl` files after spawn
|
|
184
|
+
- `getClaimedGuids()` excludes GUIDs already used by other sessions
|
|
185
|
+
- Gemini/Codex use `--resume --last` (no GUID tracking)
|
|
186
|
+
|
|
187
|
+
### Stage-Based Defaults
|
|
188
|
+
- `providers.json` `defaults.stages` maps each kanban stage → `{ provider, skipPermissions }`
|
|
189
|
+
- UI pre-fills provider dropdown from stage default
|
|
190
|
+
- `defaults.global` for project-level terminals
|
|
191
|
+
- `defaults.projects` reserved for per-project overrides (future)
|
|
192
|
+
|
|
193
|
+
## Patterns & Invariants
|
|
194
|
+
|
|
195
|
+
- Session names include provider segment: `{projectId}:{provider}:card:{cardId}` (new) or legacy `{projectId}:card:{cardId}`
|
|
196
|
+
- Claude prompts passed as positional arg, NOT `-p` flag (that's print mode)
|
|
197
|
+
- Resume behavior is provider-specific: flag vs subcommand, GUID vs latest
|
|
198
|
+
- SSE streams through `/api/bridge/sessions/{name}/stream` proxy
|
|
199
|
+
- Bridge runs on port 3456 (localhost), proxied through Next.js
|
|
200
|
+
- Idle timeout: 4 hours default, checked every 60 seconds
|
|
201
|
+
- Atomic state saves prevent data corruption
|
|
202
|
+
- Provider config cached 30s in provider-utils.ts
|
|
203
|
+
|
|
204
|
+
## API Endpoints
|
|
205
|
+
|
|
206
|
+
- `GET /sessions` - List all sessions
|
|
207
|
+
- `GET /sessions/:name` - Get session info
|
|
208
|
+
- `POST /sessions` - Create session (validates command + CWD)
|
|
209
|
+
- `DELETE /sessions/:name` - Stop or delete session
|
|
210
|
+
- `POST /sessions/:name/input` - Send input to PTY
|
|
211
|
+
- `POST /sessions/:name/resize` - Resize terminal
|
|
212
|
+
- `POST /sessions/:name/stop` - Send Escape key to active session (soft stop)
|
|
213
|
+
- `GET /sessions/:name/stream` - SSE output stream
|
|
214
|
+
- `POST /sessions/stop-all` - Bulk stop all running sessions
|
|
215
|
+
- `GET /stats` - BridgeStats with activity info
|
|
216
|
+
- `GET /activity-log/:name` - Activity transition history for debugging
|
|
217
|
+
|
|
218
|
+
## When to Expand
|
|
219
|
+
|
|
220
|
+
- Session not starting → session-manager.ts createSession(), check command whitelist + provider validation
|
|
221
|
+
- Adding new provider → data/providers.json, bridge-config.json allowedCommands
|
|
222
|
+
- Provider command issues → provider-utils.ts buildProviderCommand()
|
|
223
|
+
- Resume not working → provider-utils.ts (flag vs subcommand), claude-utils.ts (GUID detection)
|
|
224
|
+
- Security concerns → bridge-config.json, session-manager.ts validation
|
|
225
|
+
- Activity tracking issues → session-manager.ts handlePtyOutput(), getStats(), ActivityTransition
|
|
226
|
+
- Phantom activity blips → activity-log endpoint, transition trigger data
|
|
227
|
+
- Terminal display issues → Terminal.tsx, xterm setup
|
|
228
|
+
- Connection problems → api/bridge proxy, connection-manager.ts
|
|
229
|
+
- Idle timeout issues → session-manager.ts checkIdleSessions()
|
|
230
|
+
- Bulk operations → stopAllSessions(), /sessions/stop-all
|
|
231
|
+
- State corruption → session-manager.ts loadState/saveState
|
|
232
|
+
- Session name resolution → session-manager.ts resolveSessionName(), toLegacySessionName()
|
package/templates/tutorial-project/.claude/skills/context-priming/references/areas/web-frontend.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Web Frontend
|
|
2
|
+
|
|
3
|
+
Updated: 2026-02-14
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Next.js 16 command center for project management. Features project cards with health scoring, kanban boards with drag-drop, card modals, command configuration, system health monitoring, cross-project toolkit/asset management, global search, activity feed, project scaffolding, and graceful reconnection handling. Neon-minimalist theme (SlyCode Neon) with Tailwind CSS v4, featuring lane-colored gradients, SVG noise textures, and theme-aware terminal styling.
|
|
8
|
+
|
|
9
|
+
## Key Files
|
|
10
|
+
|
|
11
|
+
### Pages & Layout
|
|
12
|
+
- `web/src/app/page.tsx` - Home dashboard, lists projects from registry
|
|
13
|
+
- `web/src/app/project/[id]/page.tsx` - Project detail page with kanban
|
|
14
|
+
- `web/src/components/ProjectPageClient.tsx` - Client wrapper for project pages, global terminal activity polling
|
|
15
|
+
- `web/src/components/ProjectView.tsx` - Project view wrapper, manages archive toggle state
|
|
16
|
+
|
|
17
|
+
### Core Components
|
|
18
|
+
- `web/src/components/Dashboard.tsx` - Project card grid + Toolkit tab, global search, number-key shortcuts
|
|
19
|
+
- `web/src/components/ProjectKanban.tsx` - Kanban board container, drag-drop logic
|
|
20
|
+
- `web/src/components/KanbanColumn.tsx` - Stage columns (backlog, design, impl, testing, done)
|
|
21
|
+
- `web/src/components/KanbanCardItem.tsx` - Individual card, status indicators, active glow effect
|
|
22
|
+
- `web/src/components/CardModal.tsx` - Full card editor with dynamic tabs, edit session protection
|
|
23
|
+
- `web/src/components/ProjectHeader.tsx` - Header with Commands, Archive toggle, HealthMonitor
|
|
24
|
+
|
|
25
|
+
### Project Management
|
|
26
|
+
- `web/src/components/ProjectCard.tsx` - Enhanced project card with health dot, platform badges, edit/delete
|
|
27
|
+
- `web/src/components/AddProjectModal.tsx` - Multi-phase project creation wizard (details → analysis → scaffold → done)
|
|
28
|
+
- `web/src/components/HealthDot.tsx` - Health score indicator with tooltip (green/amber/red)
|
|
29
|
+
- `web/src/components/PlatformBadges.tsx` - Detected AI platform badges (Claude, Gemini, Codex)
|
|
30
|
+
- `web/src/components/SearchBar.tsx` - Global/contextual search across all kanban cards
|
|
31
|
+
|
|
32
|
+
### Terminal & Commands
|
|
33
|
+
- `web/src/components/ClaudeTerminalPanel.tsx` - Reusable terminal with provider selector, startupCommands/activeCommands, card area filtering
|
|
34
|
+
- `web/src/components/Terminal.tsx` - xterm.js terminal with ConnectionManager integration
|
|
35
|
+
- `web/src/components/CommandConfigModal.tsx` - Command configuration UI with Command Assistant terminal
|
|
36
|
+
- `web/src/components/GlobalClaudePanel.tsx` - Floating panel for project-wide session, supports session/CWD/class overrides
|
|
37
|
+
|
|
38
|
+
### Toolkit & Assets
|
|
39
|
+
- `web/src/components/ToolkitTab.tsx` - Asset management tab with matrix view and pending changes
|
|
40
|
+
- `web/src/components/AssetMatrix.tsx` - Cross-project asset deployment matrix with click-to-deploy/remove
|
|
41
|
+
- `web/src/components/AssetViewer.tsx` - Modal viewer for asset content with frontmatter display
|
|
42
|
+
|
|
43
|
+
### Activity & Content
|
|
44
|
+
- `web/src/components/ActivityFeed.tsx` - Collapsible event log with day grouping and stage indicators
|
|
45
|
+
- `web/src/components/MarkdownContent.tsx` - Markdown renderer using react-markdown with GFM support
|
|
46
|
+
|
|
47
|
+
### Health & Connection
|
|
48
|
+
- `web/src/components/HealthMonitor.tsx` - System stats widget (CPU, memory, terminals)
|
|
49
|
+
- `web/src/components/ConnectionStatusIndicator.tsx` - Reconnection toast indicator
|
|
50
|
+
- `web/src/lib/connection-manager.ts` - Centralized SSE reconnection with Page Visibility API
|
|
51
|
+
|
|
52
|
+
### Hooks
|
|
53
|
+
- `web/src/hooks/useConnectionStatus.ts` - Hook for connection state subscription
|
|
54
|
+
- `web/src/hooks/useKeyboardShortcuts.ts` - Keyboard navigation (1-9 project jump, Escape)
|
|
55
|
+
- `web/src/hooks/useCommandsConfig.ts` - Polling-based commands config loader (30s intervals)
|
|
56
|
+
- `web/src/hooks/usePolling.ts` - Generic polling hook
|
|
57
|
+
|
|
58
|
+
### Utilities
|
|
59
|
+
- `web/src/lib/types.ts` - All shared types (see Data Models)
|
|
60
|
+
- `web/src/lib/claude-actions.ts` - getStartupCommands(), getActiveCommands(), renderTemplate()
|
|
61
|
+
- `web/src/lib/registry.ts` - Project registry loader with kanban, health scoring, platform detection
|
|
62
|
+
- `web/src/lib/paths.ts` - Dynamic path resolution for SlyCode root and project directories
|
|
63
|
+
- `web/src/lib/kanban-paths.ts` - Project-aware kanban file path resolution with tiered backup
|
|
64
|
+
- `web/src/lib/asset-scanner.ts` - Asset scanning, frontmatter parsing, version comparison, platform detection
|
|
65
|
+
- `web/src/lib/event-log.ts` - Append-only activity log with filtering/querying (500 event cap)
|
|
66
|
+
- `web/src/lib/health-score.ts` - Health score calculator with configurable weights
|
|
67
|
+
- `web/src/lib/tab-sync.ts` - Cross-tab synchronization using BroadcastChannel API
|
|
68
|
+
|
|
69
|
+
### API Routes
|
|
70
|
+
- `web/src/app/api/kanban/route.ts` - Kanban CRUD
|
|
71
|
+
- `web/src/app/api/bridge/[...path]/route.ts` - Bridge proxy
|
|
72
|
+
- `web/src/app/api/commands/route.ts` - Commands CRUD
|
|
73
|
+
- `web/src/app/api/commands/stream/route.ts` - SSE for command file changes
|
|
74
|
+
- `web/src/app/api/system-stats/route.ts` - CPU/memory metrics
|
|
75
|
+
- `web/src/app/api/areas/route.ts` - Available areas list
|
|
76
|
+
- `web/src/app/api/terminal-classes/route.ts` - Terminal class definitions
|
|
77
|
+
- `web/src/app/api/claude-actions/route.ts` - Commands in ClaudeActionsConfig format
|
|
78
|
+
- `web/src/app/api/toolkit/route.ts` - Scan all project assets, build matrix
|
|
79
|
+
- `web/src/app/api/toolkit/sync/route.ts` - Batch deploy/remove assets
|
|
80
|
+
- `web/src/app/api/toolkit/import/route.ts` - Import asset from project to ClaudeMaster
|
|
81
|
+
- `web/src/app/api/events/route.ts` - Query activity log with filters
|
|
82
|
+
- `web/src/app/api/search/route.ts` - Cross-project card search
|
|
83
|
+
- `web/src/app/api/projects/route.ts` - List/create projects
|
|
84
|
+
- `web/src/app/api/projects/[id]/route.ts` - GET/PUT/DELETE individual project
|
|
85
|
+
- `web/src/app/api/projects/analyze/route.ts` - Analyze directory before scaffolding
|
|
86
|
+
- `web/src/app/api/providers/route.ts` - GET/PUT for providers.json (provider list + stage defaults)
|
|
87
|
+
- `web/src/app/api/file/route.ts` - Read files from approved directories
|
|
88
|
+
- `web/src/app/api/git-status/route.ts` - Git status for projects
|
|
89
|
+
|
|
90
|
+
## Key Functions
|
|
91
|
+
|
|
92
|
+
- `ProjectKanban.handleDragEnd()` - Reorders cards, handles cross-column moves
|
|
93
|
+
- `ConnectionManager.createManagedEventSource()` - Auto-reconnecting SSE with backoff
|
|
94
|
+
- `getStartupCommands(commands, terminalClass, hasHistory)` - Filter commands for session start
|
|
95
|
+
- `getActiveCommands(commands, terminalClass)` - Filter commands for running session toolbar
|
|
96
|
+
- `scanProjectAssets()` - Scan commands/skills/agents across projects, build matrix
|
|
97
|
+
- `calculateHealthScore()` - Score 0-100 based on configurable weighted factors
|
|
98
|
+
|
|
99
|
+
## CardModal Tabs
|
|
100
|
+
|
|
101
|
+
- **Details** - Edit fields, dropdowns for stage/priority, editable areas/tags chips, delete button
|
|
102
|
+
- **Design** - Shows if `design_ref` exists, renders markdown with copy path button
|
|
103
|
+
- **Feature** - Shows if `feature_ref` exists, renders markdown
|
|
104
|
+
- **Test** - Shows if `test_ref` exists, renders markdown
|
|
105
|
+
- **Checklist** - Interactive checkboxes with progress bar (uses ref-based state for rapid clicks)
|
|
106
|
+
- **Terminal** - AI session with provider selector, auto-connect, startupCommands/activeCommands
|
|
107
|
+
|
|
108
|
+
CardModal uses edit session protection: last-known-value tracking, 2000ms grace period for field editing, prevents overwriting active edits from external updates.
|
|
109
|
+
|
|
110
|
+
## Health Scoring
|
|
111
|
+
|
|
112
|
+
- **Factors**: outdated assets, stale cards, unresolved problems, missing CLAUDE.md, non-compliant frontmatter
|
|
113
|
+
- **Levels**: green (≥80), amber (≥50), red (<50)
|
|
114
|
+
- **Display**: HealthDot component with tooltip showing score breakdown
|
|
115
|
+
- Located on ProjectCard in Dashboard
|
|
116
|
+
|
|
117
|
+
## Toolkit (Asset Management)
|
|
118
|
+
|
|
119
|
+
- Scans commands/skills/agents across all projects
|
|
120
|
+
- Frontmatter validation: name, version, updated, description required
|
|
121
|
+
- Version comparison for detecting outdated assets
|
|
122
|
+
- Matrix view: rows=assets, columns=projects, cells=status
|
|
123
|
+
- Batch operations: deploy to / remove from projects
|
|
124
|
+
- Import from project back to ClaudeMaster
|
|
125
|
+
|
|
126
|
+
## Connection Management
|
|
127
|
+
|
|
128
|
+
- `ConnectionManager` - Singleton managing all SSE connections
|
|
129
|
+
- Page Visibility API detection for sleep/wake cycles
|
|
130
|
+
- Exponential backoff with jitter (1s initial, 30s max)
|
|
131
|
+
- `ConnectionStatusIndicator` - Toast showing "Reconnecting..." during recovery
|
|
132
|
+
|
|
133
|
+
## Data Models
|
|
134
|
+
|
|
135
|
+
- `KanbanCard` - id, title, description, type, priority, order, areas[], tags[], problems[], checklist[], archived?, design_ref?, feature_ref?, test_ref?, claude_session?
|
|
136
|
+
- `Command` - label, description, group, cardTypes[], prompt, visibleIn, scope, sessionState
|
|
137
|
+
- `BridgeStats` - bridgeTerminals, connectedClients, activelyWorking, sessions[]
|
|
138
|
+
- `SystemStats` - cpu (0-100), memory {used, total}, swap {used, total}
|
|
139
|
+
- `SessionActivity` - name, status, lastOutputAt, isActive
|
|
140
|
+
- `AssetInfo` - name, type, version, updated, description, filePath, frontmatter
|
|
141
|
+
- `AssetCell` - status (present|outdated|missing|extra), masterVersion?, projectVersion?
|
|
142
|
+
- `ToolkitData` - rows (AssetRow[]), projects (string[])
|
|
143
|
+
- `HealthScore` - score (0-100), level (green|amber|red), factors[]
|
|
144
|
+
- `ActivityEvent` - type, timestamp, project, detail, cardId?
|
|
145
|
+
- `SearchResult` - card, project, matchedFields[]
|
|
146
|
+
- `ProjectWithBacklog` - extends Project with assets, gitUncommitted, healthScore, platforms, lastActivity, activeSessions
|
|
147
|
+
- `ProvidersData` - providers (Record<id, ProviderConfig>), defaults (stages, global, projects)
|
|
148
|
+
- `ProviderConfig` - id, displayName, command, permissions, resume, prompt
|
|
149
|
+
|
|
150
|
+
## Design System — SlyCode Neon Theme
|
|
151
|
+
|
|
152
|
+
### Philosophy
|
|
153
|
+
Neon-minimalist aesthetic. Clean surfaces with subtle texture for life and depth. Never sterile/flat, never over-the-top. The theme should feel like a premium tool — atmospheric but professional. Light mode is clean with color; dark mode is moody with glow.
|
|
154
|
+
|
|
155
|
+
### Color Palette
|
|
156
|
+
- **Neon Blue** (`--neon-blue: #00bfff`) — Primary accent, design/implementation lanes, links, active states
|
|
157
|
+
- **Neon Orange** (`--neon-orange: #ff8c00`) — Global/project terminal headers, warnings
|
|
158
|
+
- **Red-Orange** (`#ff6a33`) — Testing lane (NOT standard orange, which looks brown in dark mode)
|
|
159
|
+
- **Green** — Done lane, success states, running indicators
|
|
160
|
+
- **Void** — Neutral grey scale for backgrounds, borders, muted text
|
|
161
|
+
- **Red** (`#ff3b5c`) — Critical/bug indicators, stop buttons
|
|
162
|
+
|
|
163
|
+
### Critical Color Lesson
|
|
164
|
+
Dark-end scale colors (e.g. `neon-orange-950 = #2b1700`) are inherently brown. For vibrant dark mode colors, use the BRIGHT color at LOW OPACITY (e.g. `neon-orange-400/15`) instead of dark scale values.
|
|
165
|
+
|
|
166
|
+
### Texture System (globals.css)
|
|
167
|
+
Three-layer texture approach for gradient surfaces:
|
|
168
|
+
|
|
169
|
+
1. **Fine grain** (`.grain`) — High-frequency SVG feTurbulence noise (`baseFrequency: 0.65`), overlay blend. Desaturate with `feColorMatrix type='saturate' values='0'` when color neutrality matters.
|
|
170
|
+
2. **Perlin noise** (`.depth-glow`) — Low-frequency organic texture (`baseFrequency: 0.015` light, `0.012` dark), large 400px tiles. Light mode uses `screen` blend (lightens), dark mode uses `soft-light`. Masked with left-to-right gradient fade.
|
|
171
|
+
3. **Terminal texture** (`.terminal-texture`) — CRT-like grain + vignette + lane-colored tint via `--terminal-tint` CSS variable. Box-shaped mask (edges visible, centre clear). Light: `soft-light` blend. Dark: `screen` blend (avoids warm/red cast from `soft-light` on dark backgrounds).
|
|
172
|
+
|
|
173
|
+
### Blend Mode Rules
|
|
174
|
+
- `soft-light` on dark backgrounds produces warm/red cast — avoid for dark mode textures
|
|
175
|
+
- `overlay` is neutral but can be invisible on very dark surfaces
|
|
176
|
+
- `screen` always adds light — use for dark mode when you need visible texture
|
|
177
|
+
- `mix-blend-multiply` makes white backgrounds transparent (light mode logos)
|
|
178
|
+
- `mix-blend-lighten` makes black backgrounds transparent (dark mode logos)
|
|
179
|
+
- `filter: drop-shadow()` traces the ALPHA boundary — creates rectangular glow on images with opaque backgrounds. Incompatible with blend-mode logo transparency.
|
|
180
|
+
|
|
181
|
+
### Logo Handling
|
|
182
|
+
Logos have opaque backgrounds (white for light, black for dark). Two `<img>` tags per location:
|
|
183
|
+
- Light: `mix-blend-multiply dark:hidden`
|
|
184
|
+
- Dark: `mix-blend-lighten hidden dark:block`
|
|
185
|
+
- All CSS drop-shadow/filter glow DISABLED (creates rectangular artifacts with blend modes). Logos have baked-in glow.
|
|
186
|
+
- Files: `slycode_light.png` / `slycode.png` (hero), `slycode_logo_light.png` / `slycode_logo.png` (nav)
|
|
187
|
+
|
|
188
|
+
### Lane-Colored Theming
|
|
189
|
+
Stage colors flow through multiple layers:
|
|
190
|
+
- **KanbanColumn headers** — `colorClasses` map with header gradient, text, count badge, border
|
|
191
|
+
- **CardModal header/tabs** — `stageModalStyles` map with gradients, borders per stage. Uses transparency (85% → 50%) for subtle glass quality
|
|
192
|
+
- **CardModal footer** — `stageTerminalColors` with colored top border
|
|
193
|
+
- **Terminal tint** — `stageTerminalTint` map provides rgba color → passed as `tintColor` prop → sets `--terminal-tint` CSS variable on terminal overlay
|
|
194
|
+
|
|
195
|
+
### Gradient Direction Convention
|
|
196
|
+
Left-to-right, vibrant-to-soft. The left/start side is always the stronger color, fading lighter toward the right. Never center-out fades (looks artificial).
|
|
197
|
+
|
|
198
|
+
### Button Aesthetic — Neon Glass
|
|
199
|
+
Terminal/action buttons use semi-transparent backgrounds with colored borders and hover glow:
|
|
200
|
+
```
|
|
201
|
+
border border-{color}-400/40 bg-{color}-400/15 text-{color}-400
|
|
202
|
+
hover:bg-{color}-400/25 hover:shadow-[0_0_12px_rgba(...,0.3)]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Health Monitor
|
|
206
|
+
Uses inline gradient fills + glow shadows (not flat CSS classes):
|
|
207
|
+
- Normal: `linear-gradient(90deg, #00e676, #00bfff)` + blue glow
|
|
208
|
+
- Warning: `linear-gradient(90deg, #ff8c00, #ffaa00)` + orange glow
|
|
209
|
+
- Critical: `linear-gradient(90deg, #ff3b5c, #ff6b81)` + red glow
|
|
210
|
+
|
|
211
|
+
### Terminal Background
|
|
212
|
+
Theme-aware: `#222228` (light mode, slightly lighter) / `#1a1a1a` (dark mode). Detected at xterm mount via `document.documentElement.classList.contains('dark')`. Wrapper divs use `bg-[#222228] dark:bg-[#1a1a1a]`.
|
|
213
|
+
|
|
214
|
+
### Dark Mode Borders
|
|
215
|
+
Card modals get colored outer borders in dark mode (`dark:border dark:border-{color}/25-30`). Section dividers (header/tabs/terminal) use lane colors in both modes.
|
|
216
|
+
|
|
217
|
+
## Patterns & Invariants
|
|
218
|
+
|
|
219
|
+
- Cards auto-save on changes via `/api/kanban` PUT
|
|
220
|
+
- Kanban data stored in `documentation/kanban.json` per project
|
|
221
|
+
- Stage order: backlog → design → implementation → testing → done
|
|
222
|
+
- Active glow: `active-glow-card` CSS class with pulse animation (2s activity threshold)
|
|
223
|
+
- Commands use `startupCommands` (session start) and `activeCommands` (running toolbar)
|
|
224
|
+
- SSE connections managed centrally via ConnectionManager for reconnection
|
|
225
|
+
- Dynamic path resolution via paths.ts (no hardcoded paths)
|
|
226
|
+
- Cross-tab sync via BroadcastChannel API
|
|
227
|
+
- Number keys 1-9 jump to projects, Escape closes modals
|
|
228
|
+
- Event log capped at 500 entries, append-only
|
|
229
|
+
- Session names include provider segment: `{projectId}:{provider}:card:{cardId}`
|
|
230
|
+
- Provider selector shown on no-session screen, pre-filled from stage defaults
|
|
231
|
+
- CardModal detects existing session's provider from session name for pre-selection
|
|
232
|
+
- ProjectKanban/ProjectPageClient use regex patterns to match both new and legacy session names
|
|
233
|
+
|
|
234
|
+
## When to Expand
|
|
235
|
+
|
|
236
|
+
- Editing card behavior → CardModal.tsx
|
|
237
|
+
- Kanban drag/drop issues → ProjectKanban.tsx, KanbanColumn.tsx
|
|
238
|
+
- Adding new card fields → types.ts, CardModal.tsx
|
|
239
|
+
- Command configuration → CommandConfigModal.tsx, data/commands.json
|
|
240
|
+
- Health monitoring → HealthMonitor.tsx, /api/system-stats
|
|
241
|
+
- Connection issues → connection-manager.ts, ConnectionStatusIndicator.tsx
|
|
242
|
+
- Terminal panel behavior → ClaudeTerminalPanel.tsx
|
|
243
|
+
- Provider selection → ClaudeTerminalPanel.tsx, /api/providers, data/providers.json
|
|
244
|
+
- Provider detection for existing sessions → CardModal.tsx (session name parsing)
|
|
245
|
+
- Asset management → asset-scanner.ts, ToolkitTab.tsx, AssetMatrix.tsx
|
|
246
|
+
- Health scoring → health-score.ts, HealthDot.tsx
|
|
247
|
+
- Activity feed → event-log.ts, ActivityFeed.tsx
|
|
248
|
+
- Project scaffolding → AddProjectModal.tsx, /api/projects
|
|
249
|
+
- Search → SearchBar.tsx, /api/search
|
|
250
|
+
- Path resolution → paths.ts, kanban-paths.ts
|
|
251
|
+
- Keyboard shortcuts → useKeyboardShortcuts.ts
|
|
252
|
+
- Theme/design system → globals.css (texture classes), CardModal.tsx (stageModalStyles), KanbanColumn.tsx (colorClasses), GlobalClaudePanel.tsx (terminal header), Terminal.tsx (tintColor, terminal-texture)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Maintenance Doctrine
|
|
2
|
+
|
|
3
|
+
Rules for maintaining context-priming references. Changes to this file require user approval.
|
|
4
|
+
|
|
5
|
+
## Area File Structure
|
|
6
|
+
|
|
7
|
+
Area files should be as lean as the area requires. Include sections that add value; omit those that don't.
|
|
8
|
+
|
|
9
|
+
**Always include:**
|
|
10
|
+
```markdown
|
|
11
|
+
# [Area Name]
|
|
12
|
+
|
|
13
|
+
Updated: YYYY-MM-DD
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
What this area does, boundaries. 2-3 sentences.
|
|
17
|
+
|
|
18
|
+
## Key Files
|
|
19
|
+
- `file.py` - purpose
|
|
20
|
+
[Most important files/modules]
|
|
21
|
+
|
|
22
|
+
## When to Expand
|
|
23
|
+
- [task] → [files to open]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Include when relevant:**
|
|
27
|
+
|
|
28
|
+
| Section | When to include |
|
|
29
|
+
|---------|-----------------|
|
|
30
|
+
| Key Functions | Area has important entry points, APIs, or non-obvious control flow |
|
|
31
|
+
| Data Models | Area defines data structures used internally or externally |
|
|
32
|
+
| Shared Objects | Area defines or consumes objects used across multiple areas |
|
|
33
|
+
| Patterns & Invariants | Area has critical rules that must hold |
|
|
34
|
+
| Interfaces | Area connects to other areas with data flow |
|
|
35
|
+
|
|
36
|
+
**Section formats (when used):**
|
|
37
|
+
|
|
38
|
+
```markdown
|
|
39
|
+
## Key Functions
|
|
40
|
+
- `process_message()` in handlers.py - entry point for incoming messages
|
|
41
|
+
|
|
42
|
+
## Data Models
|
|
43
|
+
- `Message` (models.py) - id, content, sender_id, timestamp | core envelope
|
|
44
|
+
|
|
45
|
+
## Shared Objects
|
|
46
|
+
- `Message` - DEFINED HERE, used by: frontend, api, workers
|
|
47
|
+
- `Config` - defined in core, IMPORTED HERE
|
|
48
|
+
|
|
49
|
+
## Patterns & Invariants
|
|
50
|
+
- Auth middleware runs before handlers
|
|
51
|
+
|
|
52
|
+
## Interfaces
|
|
53
|
+
- → frontend: sends Message via WebSocket
|
|
54
|
+
- ← api: receives Request, returns Response
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Keep area files under 200 lines. Simple areas may be 20-30 lines; complex areas will be longer.
|
|
58
|
+
|
|
59
|
+
**Shared Objects note**: When present, prevents duplicate definitions. Mark canonical location.
|
|
60
|
+
|
|
61
|
+
## Defragmentation
|
|
62
|
+
|
|
63
|
+
**When to defrag an area:**
|
|
64
|
+
- Information is scattered/duplicated within the file
|
|
65
|
+
- Sections contain outdated content mixed with current
|
|
66
|
+
- File has grown beyond 200 lines
|
|
67
|
+
- Reading the file doesn't quickly answer "what do I need to know?"
|
|
68
|
+
|
|
69
|
+
**Defrag process:**
|
|
70
|
+
1. Read the entire area file
|
|
71
|
+
2. Identify: duplicates, outdated info, poor organization
|
|
72
|
+
3. Consolidate related information
|
|
73
|
+
4. Remove obsolete content (don't comment it out - delete)
|
|
74
|
+
5. Verify remaining content is accurate against current code
|
|
75
|
+
6. Update the `Updated` date
|
|
76
|
+
|
|
77
|
+
**Consult user before defragging if:**
|
|
78
|
+
- Multiple areas need simultaneous restructuring
|
|
79
|
+
- Unsure whether information is obsolete or still relevant
|
|
80
|
+
- Defrag would take significant time
|
|
81
|
+
|
|
82
|
+
## Area Separation
|
|
83
|
+
|
|
84
|
+
**Heuristics for deciding areas:**
|
|
85
|
+
- Group by logical module/subsystem, not by file type
|
|
86
|
+
- An area should be loadable and useful independently
|
|
87
|
+
- If two areas are always loaded together, consider merging
|
|
88
|
+
- If an area covers unrelated concerns, consider splitting
|
|
89
|
+
|
|
90
|
+
**When to split an area:**
|
|
91
|
+
- File exceeds 200 lines despite being concise
|
|
92
|
+
- Contains distinct subsystems that don't interact
|
|
93
|
+
- Load-when triggers have diverged (some tasks need part A, others need part B)
|
|
94
|
+
|
|
95
|
+
**When to merge areas:**
|
|
96
|
+
- Two areas are nearly always loaded together
|
|
97
|
+
- Combined size would still be under 150 lines
|
|
98
|
+
- Separation creates artificial boundaries
|
|
99
|
+
|
|
100
|
+
**Cross-references:**
|
|
101
|
+
- Areas can note "see also: [other-area]" for related context
|
|
102
|
+
- Don't auto-load chains - let the index's load-when guide loading
|
|
103
|
+
- If area A heavily depends on area B, note this in A's Interfaces section
|
|
104
|
+
|
|
105
|
+
## Note Pruning
|
|
106
|
+
|
|
107
|
+
Notes in area-index.md capture learnings. Prune when:
|
|
108
|
+
- Note contradicts newer information (keep newer)
|
|
109
|
+
- Code changed and note no longer applies
|
|
110
|
+
- Note is vague or not actionable
|
|
111
|
+
- Area exceeds 10 notes
|
|
112
|
+
|
|
113
|
+
**Pruning is lightweight** - remove stale notes during routine updates, don't treat as separate task.
|
|
114
|
+
|
|
115
|
+
## New Project Initialization
|
|
116
|
+
|
|
117
|
+
When skill is introduced to a new codebase:
|
|
118
|
+
|
|
119
|
+
1. Clear `areas/` directory
|
|
120
|
+
2. Reset area-index.md to template state
|
|
121
|
+
3. Keep SKILL.md and maintenance.md intact
|
|
122
|
+
4. Scan project structure:
|
|
123
|
+
- Look for obvious module boundaries (directories, packages)
|
|
124
|
+
- Check build configs (package.json, pyproject.toml, etc.)
|
|
125
|
+
- Read CLAUDE.md for existing documentation pointers
|
|
126
|
+
5. Propose 3-6 initial areas to user
|
|
127
|
+
6. After approval, create area files with initial discovery
|
|
128
|
+
7. Mark all as freshly created - validate through actual use
|