forked from 1jehuang/jcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_help.rs
More file actions
246 lines (224 loc) · 12.8 KB
/
debug_help.rs
File metadata and controls
246 lines (224 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
pub(super) fn parse_namespaced_command(command: &str) -> (&str, &str) {
let trimmed = command.trim();
if let Some(idx) = trimmed.find(':') {
let namespace = &trimmed[..idx];
let rest = &trimmed[idx + 1..];
match namespace {
"server" | "client" | "tester" => (namespace, rest),
_ => ("server", trimmed),
}
} else {
("server", trimmed)
}
}
pub(super) fn debug_help_text() -> String {
r#"Debug socket commands (namespaced):
SERVER COMMANDS (server: prefix or no prefix):
state - Get agent state
history - Get conversation history
tools - List available tools (names only)
tools:full - List tools with full definitions (input_schema)
mcp:servers - List configured + connected MCP servers
last_response - Get last assistant response
message:<text> - Send message to agent
message_async:<text> - Send message async (returns job id)
swarm_message:<text> - Plan and run subtasks via swarm workers, then integrate
swarm_message_async:<text> - Async swarm message (returns job id)
tool:<name> <json> - Execute tool directly
cancel - Cancel in-flight generation (urgent interrupt)
clear - Clear conversation history
agent:info - Get comprehensive agent internal state
agent:memory - Get process + session memory breakdown
allocator - Get allocator info and jemalloc stats, if available
allocator:purge - Flush/purge jemalloc arenas to test retained-memory behavior
allocator:decay:<ms> - Set jemalloc dirty/muzzy decay for all arenas to <ms>
allocator:profile:on - Enable jemalloc sampling at runtime (jemalloc-prof builds)
allocator:profile:off - Disable jemalloc sampling at runtime (jemalloc-prof builds)
allocator:profile:prefix:<prefix> - Set jemalloc heap dump filename prefix
allocator:profile:dump [path] - Write jemalloc heap profile to default or explicit path
jobs - List async debug jobs
job_status:<id> - Get async job status/output
job_wait:<id> - Wait for async job to finish
job_cancel:<id> - Cancel a running job
jobs:purge - Remove completed/failed jobs
jobs:session:<id> - List jobs for a session
background:tasks - List background tasks
server:memory - Get global server memory breakdown
server:memory-history - Recent server process memory samples
embeddings:stats - Get embedding model/cache runtime stats
embeddings:load - Force-load the shared embedding model
embeddings:unload - Force-unload the shared embedding model and cache
sessions - List all sessions (with full metadata)
clients - List connected TUI clients
clients:map - Map connected clients to sessions
server:info - Server identity, health, uptime
swarm - List swarm members + status (alias: swarm:members)
swarm:help - Full swarm command reference
create_session - Create headless session
create_session:<path> - Create session with working dir
create_session:selfdev:<path> - Create headless self-dev session
destroy_session:<id> - Destroy a session
set_model:<model> - Switch model (may change provider)
set_provider:<name> - Switch provider (claude/openai/openrouter/cursor/copilot/gemini/antigravity)
trigger_extraction - Force end-of-session memory extraction
available_models - List all available models
reload - Trigger server reload with current binary
SWARM COMMANDS (swarm: prefix):
swarm:members - List all swarm members with details
swarm:list - List all swarms with member counts
swarm:info:<swarm_id> - Full info for a swarm
swarm:coordinators - List all coordinators
swarm:roles - List all members with roles
swarm:plans - List all swarm plans
swarm:plan_version:<id> - Show plan version for a swarm
swarm:proposals - List pending plan proposals
swarm:context - List all shared context
swarm:touches - List all file touches
swarm:conflicts - Files touched by multiple sessions
swarm:channels - List channel subscriptions
swarm:broadcast:<msg> - Broadcast to swarm members
swarm:notify:<sid> <msg> - Send DM to specific session
swarm:help - Full swarm command reference
AMBIENT COMMANDS (ambient: prefix):
ambient:status - Ambient + schedule runner state, counts, next due items
ambient:queue - Scheduled queue contents with target/session metadata
ambient:trigger - Manually trigger an ambient cycle
ambient:log - Recent transcript summaries
ambient:permissions - List pending permission requests
ambient:approve:<id> - Approve a permission request
ambient:deny:<id> [reason] - Deny a permission request (optional reason)
ambient:start - Start/restart ambient mode
ambient:stop - Stop ambient mode
ambient:help - Ambient command reference
EVENTS COMMANDS (events: prefix):
events:recent - Get recent events (default 50)
events:recent:<N> - Get recent N events
events:since:<id> - Get events since event ID
events:count - Event count and latest ID
events:types - List available event types
events:subscribe - Subscribe to all events (streaming)
events:subscribe:<types> - Subscribe filtered (e.g. status_change,member_change)
CLIENT COMMANDS (client: prefix):
client:state - Get TUI state
client:frame - Get latest visual debug frame (JSON)
client:frame-normalized - Get normalized frame (for diffs)
client:screen - Dump visual debug to file
client:layout - Get latest layout JSON
client:margins - Get layout margins JSON
client:widgets - Get info widget summary/placements
client:render-stats - Get render timing + order JSON
client:render-order - Get render order list
client:anomalies - Get latest visual debug anomalies
client:theme - Get palette snapshot
client:mermaid:stats - Get mermaid render/cache stats
client:mermaid:memory - Mermaid memory profile (RSS + cache estimates)
client:mermaid:memory-bench [n] - Synthetic Mermaid memory benchmark
client:mermaid:flicker-bench [n] - Benchmark viewport protocol churn / flicker risk
client:mermaid:ui-bench[:<j>] - Benchmark live Mermaid UI render path
client:mermaid:cache - List mermaid cache entries
client:mermaid:state - Get image state (resize modes)
client:mermaid:test - Render test diagram
client:mermaid:scroll - Run scroll simulation test
client:mermaid:render <c> - Render arbitrary mermaid
client:mermaid:evict - Clear mermaid cache
client:markdown:stats - Get markdown render stats
client:markdown:memory - Markdown highlight cache memory estimate
client:memory - Aggregate client memory profile
client:memory-history - Recent client process memory samples
client:flicker-frames [n] - Recent frame-stability / flicker records
client:slow-frames [n] - Recent slow-frame records
client:overlay:on/off - Toggle overlay boxes
client:input - Get current input buffer
client:set_input:<text> - Set input buffer
client:keys:<keyspec> - Inject key events
client:message:<text> - Inject and submit message
client:inject:<role>:<t> - Inject display message (no send)
client:scroll:<dir> - Scroll (up/down/top/bottom)
client:scroll-test[:<j>] - Run offscreen scroll+diagram test
client:scroll-suite[:<j>] - Run scroll+diagram test suite
client:side-panel-latency[:<j>] - Benchmark headless side-panel input->frame latency
client:side-panel:stats - Current side-panel debug snapshot, including live Mermaid utilization
client:diagram-pane:stats - Current pinned diagram pane snapshot, including live Mermaid utilization
client:wait - Check if processing
client:history - Get display messages
client:help - Client command help
TESTER COMMANDS (tester: prefix):
tester:spawn - Spawn new tester instance
tester:list - List active testers
tester:<id>:frame - Get frame from tester
tester:<id>:message:<t> - Send message to tester
tester:<id>:inject:<t> - Inject display message (no send)
tester:<id>:state - Get tester state
tester:<id>:scroll-test - Run offscreen scroll+diagram test
tester:<id>:scroll-suite - Run scroll+diagram test suite
tester:<id>:side-panel-latency - Benchmark headless side-panel input->frame latency
tester:<id>:mermaid-ui-bench - Benchmark live Mermaid UI render path
tester:<id>:stop - Stop tester
Examples:
{"type":"debug_command","id":1,"command":"state"}
{"type":"debug_command","id":2,"command":"client:frame"}
{"type":"debug_command","id":3,"command":"tester:list"}
{"type":"debug_command","id":4,"command":"set_provider:openai","session_id":"..."}
{"type":"debug_command","id":5,"command":"swarm:info:/home/user/project"}"#
.to_string()
}
pub(super) fn swarm_debug_help_text() -> String {
r#"Swarm debug commands (swarm: prefix):
MEMBERS & STRUCTURE:
swarm - List all swarm members (alias for swarm:members)
swarm:members - List all swarm members with full details
swarm:list - List all swarm IDs with member counts and coordinators
swarm:info:<swarm_id> - Full info: members, coordinator, plan, context, conflicts
COORDINATORS & ROLES:
swarm:coordinators - List all coordinators (swarm_id -> session_id)
swarm:coordinator:<id> - Get coordinator for specific swarm
swarm:clear_coordinator:<id> - Admin: forcibly clear coordinator so any session can self-promote
swarm:roles - List all members with their roles
PLANS (server-scoped plan items):
swarm:plans - List all swarm plans with item counts
swarm:plan:<swarm_id> - Get plan items for specific swarm
swarm:plan_version:<id> - Show current plan version for a swarm
PLAN PROPOSALS (pending approval):
swarm:proposals - List all pending proposals across swarms
swarm:proposals:<swarm> - List proposals for a specific swarm (with items)
swarm:proposals:<sess> - Get detailed proposal from a session
SHARED CONTEXT (key-value store):
swarm:context - List all shared context entries
swarm:context:<swarm_id> - List context for specific swarm
swarm:context:<swarm_id>:<key> - Get specific context value
FILE TOUCHES (conflict detection):
swarm:touches - List all file touches (path, session, op, age, timestamp)
swarm:touches:<path> - Get touches for specific file
swarm:touches:swarm:<id> - Get touches filtered by swarm members
swarm:conflicts - List files touched by multiple sessions
NOTIFICATIONS:
swarm:broadcast:<msg> - Broadcast message to all members of your swarm
swarm:broadcast:<swarm_id> <msg> - Broadcast to specific swarm
swarm:notify:<session_id> <msg> - Send direct message to specific session
EXECUTION STATE:
swarm:session:<id> - Detailed session state (interrupts, provider, usage)
swarm:interrupts - List pending interrupts across all sessions
CHANNELS:
swarm:channels - List channel subscriptions per swarm
OPERATIONS (debug-only, bypass tool:communicate):
swarm:set_context:<sess> <key> <value> - Set shared context as session
swarm:approve_plan:<coord> <proposer> - Approve plan proposal (coordinator only)
swarm:reject_plan:<coord> <proposer> [reason] - Reject plan proposal
UTILITIES:
swarm:id:<path> - Compute swarm_id for a path and show provenance
REAL-TIME EVENTS:
events:recent - Get recent 50 events
events:recent:<N> - Get recent N events
events:since:<id> - Get events since event ID (for polling)
events:count - Get event count and latest ID
events:types - List available event types
events:subscribe - Subscribe to all events (streaming, keeps connection open)
events:subscribe:<types> - Subscribe filtered (e.g. events:subscribe:status_change,member_change)
Examples:
{"type":"debug_command","id":1,"command":"swarm:list"}
{"type":"debug_command","id":2,"command":"swarm:info:/home/user/myproject"}
{"type":"debug_command","id":3,"command":"swarm:plan:/home/user/myproject"}
{"type":"debug_command","id":4,"command":"swarm:broadcast:Build complete, ready for review"}
{"type":"debug_command","id":5,"command":"swarm:notify:session_fox_123 Please review PR #42"}"#
.to_string()
}