-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcli.ts
More file actions
4905 lines (4563 loc) · 229 KB
/
Copy pathcli.ts
File metadata and controls
4905 lines (4563 loc) · 229 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env node
import { Buffer } from "node:buffer";
import { spawnSync } from "node:child_process";
import fs from "node:fs";
import net from "node:net";
import path from "node:path";
import YAML from "yaml";
import {
CURSOR_CLOUD_HELP,
CursorCloudUsageError,
runCursorCloud,
} from "./cursorCloud";
import { type JsonRpcHandler, type JsonRpcId, type JsonRpcRequest } from "./jsonrpc";
import { isAdeMcpNamedPipePath } from "../../desktop/src/shared/adeMcpIpc";
type JsonObject = Record<string, unknown>;
type GlobalOptions = {
projectRoot: string | null;
workspaceRoot: string | null;
role: "cto" | "orchestrator" | "agent" | "external" | "evaluator";
headless: boolean;
requireSocket: boolean;
pretty: boolean;
text: boolean;
timeoutMs: number;
};
type ParsedCli = {
options: GlobalOptions;
command: string[];
};
type InvocationStep = {
key: string;
method: string;
params?: JsonObject;
unwrapToolResult?: boolean;
optional?: boolean;
};
type FormatterId =
| "status"
| "doctor"
| "auth"
| "lanes"
| "lane-detail"
| "git-status"
| "diff-summary"
| "file-read"
| "files-tree"
| "files-search"
| "prs-list"
| "pr-detail"
| "pr-checks"
| "pr-comments"
| "run-defs"
| "run-runtime"
| "chat-list"
| "tests-runs"
| "proof-list"
| "ios-sim-status"
| "ios-sim-devices"
| "ios-sim-apps"
| "ios-sim-stream"
| "ios-sim-snapshot"
| "ios-sim-selection"
| "ios-sim-preview"
| "app-control-status"
| "app-control-snapshot"
| "app-control-selection"
| "browser-status"
| "terminal-list"
| "terminal-read"
| "actions-list"
| "action-result"
| "automation-run-detail";
type CliPlan =
| { kind: "help"; text: string }
| { kind: "execute"; label: string; steps: InvocationStep[]; visualizer?: "lanes"; summary?: "status" | "doctor" | "auth"; formatter?: FormatterId; preferHeadless?: boolean }
| { kind: "cursor-cloud"; rest: string[] };
type CliConnection = {
mode: "desktop-socket" | "headless";
projectRoot: string;
workspaceRoot: string;
socketPath: string;
request: (method: string, params?: JsonObject) => Promise<unknown>;
close: () => Promise<void> | void;
};
class CliUsageError extends Error {}
class CliToolError extends Error {
details: unknown;
constructor(message: string, details: unknown) {
super(message);
this.details = details;
}
}
class CliExecutionError extends Error {
details: JsonObject;
constructor(message: string, details: JsonObject) {
super(message);
this.details = details;
}
}
type ReadinessCheck = {
ready: boolean;
status: "ready" | "warning" | "missing" | "unavailable";
message: string;
nextAction?: string;
details?: JsonObject;
};
const VERSION = "0.0.0";
const PROTOCOL_VERSION = "2025-06-18";
const SOURCE_FALLBACK_ENV = "ADE_CLI_SOURCE_FALLBACK_ACTIVE";
const CLI_ENTRY_PATH = typeof process.argv[1] === "string" ? path.resolve(process.argv[1]) : "";
const CLI_PACKAGE_ROOT = resolveCliPackageRoot(CLI_ENTRY_PATH);
const CLI_DIST_PATH = path.join(CLI_PACKAGE_ROOT, "dist", "cli.cjs");
function resolveCliPackageRoot(entryPath: string): string {
const seen = new Set<string>();
const starts = [
entryPath ? path.dirname(entryPath) : null,
process.cwd(),
];
for (const start of starts) {
if (!start) continue;
let cursor = path.resolve(start);
while (!seen.has(cursor)) {
seen.add(cursor);
const packageJson = path.join(cursor, "package.json");
const srcCli = path.join(cursor, "src", "cli.ts");
if (fs.existsSync(packageJson) && fs.existsSync(srcCli)) {
return cursor;
}
const parent = path.dirname(cursor);
if (parent === cursor) break;
cursor = parent;
}
}
return path.resolve(process.cwd(), "apps", "ade-cli");
}
function isSourceCliEntryPath(modulePath: string): boolean {
return /[/\\]src[/\\]cli\.ts$/i.test(modulePath);
}
function isSourceRuntimeInteropError(value: unknown): boolean {
const message = typeof value === "string"
? value
: value instanceof Error
? value.message
: "";
if (!message.length) return false;
const lower = message.toLowerCase();
return lower.includes("__filename is not defined in es module scope")
|| lower.includes("__filename is not defined")
|| lower.includes("__dirname is not defined");
}
function formatSpawnFailure(result: ReturnType<typeof spawnSync>, fallbackCommand: string): string {
if (result.error) {
return result.error.message;
}
const status = typeof result.status === "number" ? result.status : "unknown";
const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
const stdout = typeof result.stdout === "string" ? result.stdout.trim() : "";
const detail = stderr || stdout || "No output captured.";
return `${fallbackCommand} exited with status ${status}: ${detail}`;
}
function latestMtimeMs(root: string): number {
let latest = 0;
let entries: fs.Dirent[];
try {
entries = fs.readdirSync(root, { withFileTypes: true });
} catch {
return latest;
}
for (const entry of entries) {
const fullPath = path.join(root, entry.name);
if (entry.isDirectory()) {
latest = Math.max(latest, latestMtimeMs(fullPath));
continue;
}
if (!entry.isFile()) continue;
try {
latest = Math.max(latest, fs.statSync(fullPath).mtimeMs);
} catch {
// Ignore files that disappear while checking freshness.
}
}
return latest;
}
function isBuiltCliFresh(): boolean {
try {
const distMtime = fs.statSync(CLI_DIST_PATH).mtimeMs;
const sourceMtime = latestMtimeMs(path.join(CLI_PACKAGE_ROOT, "src"));
return distMtime >= sourceMtime;
} catch {
return false;
}
}
function maybeRunBuiltCliFallback(error: unknown, argv: string[]): { stdout: string; stderr: string; exitCode: number } | null {
if (!(error instanceof CliExecutionError)) return null;
if (process.env[SOURCE_FALLBACK_ENV] === "1") return null;
if (!isSourceCliEntryPath(CLI_ENTRY_PATH)) return null;
if (!isSourceRuntimeInteropError(asString(error.details.cause) ?? error.message)) return null;
if (!isBuiltCliFresh()) {
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
const buildResult = spawnSync(npmCommand, ["run", "build", "--silent"], {
cwd: CLI_PACKAGE_ROOT,
env: process.env,
encoding: "utf8",
});
if (buildResult.error || buildResult.status !== 0 || !isBuiltCliFresh()) {
error.details.nextAction = "Run `npm --prefix apps/ade-cli run build` and retry the command.";
error.details.fallback = formatSpawnFailure(buildResult, "npm run build --silent");
return null;
}
}
const rerun = spawnSync(process.execPath, [CLI_DIST_PATH, ...argv], {
cwd: process.cwd(),
env: {
...process.env,
[SOURCE_FALLBACK_ENV]: "1",
},
encoding: "utf8",
});
if (rerun.error) {
error.details.nextAction = "Run `node apps/ade-cli/dist/cli.cjs ...` directly to inspect the runtime failure.";
error.details.fallback = rerun.error.message;
return null;
}
return {
stdout: typeof rerun.stdout === "string" ? rerun.stdout : "",
stderr: typeof rerun.stderr === "string" ? rerun.stderr : "",
exitCode: rerun.status ?? 1,
};
}
const ADE_BANNER = String.raw`
_ ____ _____
/ \ | _ \| ____|
/ _ \ | | | | _|
/ ___ \| |_| | |___
/_/ \_\____/|_____|
`;
const TOP_LEVEL_HELP = `${ADE_BANNER}
Agent-focused command-line interface for ADE.
ADE CLI commands operate on the same project database and live desktop socket
used by the ADE app. By default the CLI connects to the app socket when it is
running; otherwise it falls back to a headless runtime for local-safe actions.
$ ade help <command...> Display help for a command
$ ade auth status Check local ADE CLI readiness
$ ade doctor Inspect project, socket, runtime, and tool availability
$ ade lanes list | show | create | child Work with lanes and lane stacks
$ ade git status | commit | push | stash Run ADE-aware git operations
$ ade diff changes | file Inspect lane diffs
$ ade files tree | read | write | search Read and edit lane workspaces
$ ade prs list | create | path-to-merge Manage PRs, queues, and Path to Merge repair rounds
$ ade run defs | ps | start | logs Manage Run tab process definitions and runtime
$ ade shell start | write | resize | close Launch and control tracked shell sessions
$ ade terminal list | read | write | signal Control the active in-chat terminal
$ ade chat list | create | send | interrupt Work with ADE agent chats
$ ade agent spawn --lane <id> --prompt <text> Launch an agent session in ADE
$ ade cto state | chats Operate CTO state and Work chats
$ ade linear workflows | run | sync Operate Linear routing and sync workflows
$ ade automations list | create | run | runs Manage automation rules
$ ade coordinator <tool> Call coordinator runtime tools
$ ade tests list | run | stop | runs | logs Run configured test suites
$ ade proof status | list | screenshot | record Manage proof and computer-use artifacts
$ ade ios-sim devices | apps | launch | tap Control iOS Simulator apps, capture, and input
$ ade app-control launch | snapshot | click Inspect and drive Electron apps
$ ade browser open | tabs | screenshot Use ADE's built-in browser pane
$ ade memory add | search | pin Use ADE memory
$ ade settings action <method> Call project config actions
$ ade actions list | run | status Escape hatch for every ADE service action
$ ade cursor cloud agents | runs | artifacts | repos | models | me
Drive Cursor Cloud agents via @cursor/sdk
Global options:
--project-root <path> ADE project root. Inside .ade/worktrees/<lane>, this resolves to the parent project.
--workspace-root <path> Lane/worktree to treat as the active workspace.
--headless Skip the desktop socket and run an in-process ADE runtime.
--socket Require the desktop socket; fail instead of falling back to headless.
--json Print machine-readable JSON. This is the default output mode.
--text Print a compact human-readable summary when a formatter exists.
--timeout-ms <ms> Per-request timeout. Long agent/PR workflows may need several minutes.
Common agent flows:
$ ade doctor --text
$ ade lanes list --text
$ ade lanes create --name fix-login --description "Repair login redirect"
$ ade git status --lane <lane> --text
$ ade git stage --lane <lane> src/index.ts
$ ade git commit --lane <lane> -m "Fix login redirect"
$ ade prs create --lane <lane> --base main --draft
$ ade prs path-to-merge <pr-id-or-number-or-url> --model <model> --max-rounds 3 --no-auto-merge
$ ade proof record --seconds 20
$ ade ios-sim apps --text
$ ade ios-sim launch --target <id> --text
$ ade app-control launch --command "pnpm dev" --text
$ ade --socket browser open http://localhost:5173 --new-tab --text
$ ade terminal read --chat-session <id> --text
Generic ADE action JSON contract:
Object-shaped call:
$ ade actions run git.push --input-json '{"laneId":"lane-1","setUpstream":true}'
$ ade actions run git.push --arg laneId=lane-1 --arg setUpstream=true
JSON value fields:
$ ade actions run pr.setLabels --arg prId=123 --arg-json 'labels=["ready","ship"]'
Multi-parameter service call:
$ ade actions run issue_inventory.savePipelineSettings --args-list-json '["pr-1",{"maxRounds":3}]'
Single scalar parameter:
$ ade actions run mission.get --scalar mission-1
$ ade actions list --text
$ ade actions list --domain pr --text
$ ade actions run <domain.action> --input-json '{"key":"value"}'
Start with: ade doctor --text
`;
const IOS_SIMULATOR_SUBCOMMAND_HELP: Record<string, string> = {
status: `${ADE_BANNER}
iOS Simulator: status
Shows macOS support, Xcode/idb/ffmpeg readiness, the active booted device,
and the drawer's active simulator session. Start here when a simulator action
fails or when an agent needs to know whether ADE owns a running session.
$ ade --socket ios-sim status --text
Flags:
--text Compact human-readable readiness summary.
--json Full JSON payload with tool install hints.
`,
devices: `${ADE_BANNER}
iOS Simulator: devices
Lists available iOS simulator devices. Aliases: list, ls.
$ ade --socket ios-sim devices --text
Flags:
--text Compact table.
--json Full device records.
`,
apps: `${ADE_BANNER}
iOS Simulator: apps
Lists launchable app targets from Xcode projects, DerivedData, and apps
already installed on the selected simulator. Aliases: targets, launchable,
launchables.
$ ade --socket ios-sim apps --device <udid> --text
Flags:
--device, --udid <id> Simulator device to inspect.
--project-root <path> ADE project root to scan for iOS projects.
--text Compact table with target ids.
`,
launch: `${ADE_BANNER}
iOS Simulator: launch
Boots the simulator, resolves/builds/installs a target, launches the app, and
claims the ADE drawer session. Use --socket when the drawer and agents should
share one long-lived simulator service. Alias: open.
$ ade --socket ios-sim launch --target <id> --text
$ ade --socket ios-sim launch --bundle-id com.example.app --no-build --text
Flags:
--device, --udid <id> Simulator device.
--target, --target-id <id> Target id from "ios-sim apps".
--bundle-id, --bundle <id> Launch an installed app by bundle id.
--app-bundle, --app <path> Install/launch a built .app bundle.
--project, --xcodeproj <p> Xcode project path.
--scheme <name> Xcode scheme.
--project-root <path> ADE project root.
--lane, --lane-id <id> Lane to bind this simulator session to.
--chat-session <id> Owner chat session for the single-owner lock.
--no-build Skip xcodebuild.
--mode snapshot|live Inspector launch mode; default live.
--foreground Open and bring Simulator.app forward.
--arg KEY=VALUE Extra service args for advanced launch options.
`,
shutdown: `${ADE_BANNER}
iOS Simulator: shutdown
Stops streams, releases the drawer session, and tears down simulator helper processes.
Aliases: stop, teardown, end, end-session.
$ ade --socket ios-sim shutdown --text
$ ade --socket ios-sim shutdown --force --text
Flags:
--force, -f Release a session owned by another chat.
--device, --udid <id> Optional device context for cleanup.
`,
actions: `${ADE_BANNER}
iOS Simulator: actions
Lists every callable ios_simulator action exposed through ADE's generic action
bridge. Use this when a typed subcommand is missing a niche argument.
$ ade --socket ios-sim actions --text
$ ade actions run ios_simulator.getStatus --text
`,
screenshot: `${ADE_BANNER}
iOS Simulator: screenshot
Captures a one-shot PNG from the simulator via simctl. Alias: capture.
$ ade --socket ios-sim screenshot --device <udid> --text
Flags:
--device, --udid <id> Simulator device; defaults to the active session or booted device.
`,
snapshot: `${ADE_BANNER}
iOS Simulator: snapshot
Captures screenshot + ADEInspector/accessibility elements for the current
simulator screen. Use this before asking an agent to find the current screen
in SwiftUI code. Aliases: screen, elements.
$ ade --socket ios-sim snapshot --text
Flags:
--device, --udid <id> Simulator device.
--project-root <path> Project root for source matching.
--arg x=<n> --arg y=<n> Optional hit-test point in screenshot pixels.
`,
inspector: `${ADE_BANNER}
iOS Simulator: inspector
Reads the DEBUG ADEInspector snapshot published by the launched app. This is
lower-level than "snapshot" and does not include screenshot/accessibility fallback.
$ ade --socket ios-sim inspector --text
Flags:
--device, --udid <id> Simulator device.
`,
inspect: `${ADE_BANNER}
iOS Simulator: inspect
Hit-tests a point and returns the best matching context item without committing
it to the drawer composer. Aliases: hit-test, hover.
$ ade --socket ios-sim inspect --x 120 --y 420 --screenshot --text
Flags:
--x <n> --y <n> Required screenshot-pixel coordinates.
--device, --udid <id> Simulator device.
--project-root <path> Project root for Swift source matching.
--screenshot Include screenshot data in the context result.
`,
"preview-status": `${ADE_BANNER}
iOS Simulator: preview-status
Checks Xcode Preview Lab readiness: Xcode version, mcpbridge availability,
Xcode running state, selected project window, setup warnings, and docs URL.
Alias: preview-doctor.
$ ade --socket ios-sim preview-status --source apps/ios/ADE/Views/Home.swift --line 42 --text
Flags:
--project-root <path> ADE project root.
--source, --file <p> Swift file used to bias preview discovery.
--line <n> Source line used to bias preview discovery.
`,
previews: `${ADE_BANNER}
iOS Simulator: previews
Lists discoverable #Preview and PreviewProvider definitions, ranked around a
selected Swift file when supplied. Aliases: preview-list, list-previews.
$ ade --socket ios-sim previews --source apps/ios/ADE/Views/Home.swift --text
Flags:
--project-root <path> ADE project root.
--source, --file <p> Swift file to rank nearby previews.
--line <n> Optional source line.
`,
"preview-render": `${ADE_BANNER}
iOS Simulator: preview-render
Renders a SwiftUI preview through Xcode MCP and returns the snapshot path/data.
This is the final command agents should run after finding or adding a preview.
Aliases: render-preview, preview.
$ ade --socket ios-sim preview-render --source apps/ios/ADE/Views/Home.swift --index 0 --text
Flags:
--source, --file <p> Required Swift source file. Absolute, project-relative,
or Xcode-project-relative paths are accepted.
--index <n> Preview definition index in the file; default 0.
--tab, --tab-identifier <id> Xcode window tab from preview-status.
--timeout <sec> Render timeout, 5-240 seconds; default 120.
--project-root <path> ADE project root.
`,
"preview-open": `${ADE_BANNER}
iOS Simulator: preview-open
Opens apps/ios/ADE.xcodeproj in Xcode so Xcode MCP Preview Lab can connect.
Aliases: open-preview-workspace, open-xcode.
$ ade ios-sim preview-open --project-root <path> --text
Flags:
--project-root <path> ADE project root.
`,
"stream-start": `${ADE_BANNER}
iOS Simulator: stream-start
Starts a visual stream. auto resolves to iosurface-indigo first when full
Xcode supports ADE's private helpers, then Simulator.app window capture when
visible-window capture is allowed, then idb MJPEG, then simctl screenshot
polling. The H.264+ffmpeg idb stream is recovery-only after idb MJPEG fails.
Aliases:
start-stream, stream, window-start,
start-window, mirror-start, live-start, start-live, preview-start, start-preview.
$ ade --socket ios-sim window-start --fps 60 --text
$ ade --socket ios-sim live-start --fps 30 --text
$ ade --socket ios-sim preview-start --fps 8 --text
Flags:
--device, --udid <id> Simulator device.
--fps <n> Target fps.
--backend auto|iosurface-indigo|simulator-window-capture|idb-mjpeg|idb-h264-ffmpeg-mjpeg|simctl-screenshot-poll
--window, --mirror Force window capture.
--idb, --live Use auto backend resolution.
--simctl, --preview Force simctl screenshot polling.
`,
"stream-status": `${ADE_BANNER}
iOS Simulator: stream-status
Shows running backend, fallback/degradation reason, helper pid, fps, latency,
stream URL, frame count, input backend, and last error. Low idle fps is normal
on iosurface-indigo because frames are event-driven when the simulator is still.
$ ade --socket ios-sim stream-status --text
`,
"stream-stop": `${ADE_BANNER}
iOS Simulator: stream-stop
Stops the visual stream without necessarily releasing the simulator session.
Aliases: stop-stream, preview-stop, stop-preview, live-stop, stop-live.
$ ade --socket ios-sim stream-stop --text
`,
select: `${ADE_BANNER}
iOS Simulator: select
Hit-tests a point, emits a drawer selection event, and attaches the resulting
iOS context to the active chat composer. Use --socket so the drawer receives it.
$ ade --socket ios-sim select --x 120 --y 420 --text
Flags:
--x <n> --y <n> Required screenshot-pixel coordinates.
--device, --udid <id> Simulator device.
--project-root <path> Project root for Swift source matching.
`,
tap: `${ADE_BANNER}
iOS Simulator: tap
Sends a tap through the active input backend, preferring Indigo with idb fallback.
$ ade --socket ios-sim tap --x 120 --y 420 --text
$ ade --socket ios-sim tap 120 420 --text
Flags:
--x <n> --y <n> Required point coordinates.
--device, --udid <id> Simulator device.
--project-root <path> Project root.
`,
drag: `${ADE_BANNER}
iOS Simulator: drag / swipe
Sends a swipe through the active input backend. "swipe" is an alias of drag.
$ ade --socket ios-sim drag --start-x 120 --start-y 700 --end-x 120 --end-y 250 --text
$ ade --socket ios-sim swipe 120 700 120 250 --duration-ms 250 --text
Flags:
--start-x <n> --start-y <n> Required start coordinates.
--end-x <n> --end-y <n> Required end coordinates.
--duration-ms <n> Swipe duration in milliseconds.
--device, --udid <id> Simulator device.
--project-root <path> Project root.
`,
type: `${ADE_BANNER}
iOS Simulator: type
Types text through idb into the active launched app. Alias: text.
$ ade --socket ios-sim type "hello" --text
$ ade --socket ios-sim type --value "hello" --text
Flags:
--value, --message <v> Text to type. --text <value> is also accepted for
compatibility, but --text by itself controls ADE's
human-readable output mode.
--device, --udid <id> Simulator device.
--project-root <path> Project root.
`,
};
const IOS_SIMULATOR_HELP_ALIASES: Record<string, string> = {
list: "devices",
ls: "devices",
targets: "apps",
launchable: "apps",
launchables: "apps",
open: "launch",
stop: "shutdown",
teardown: "shutdown",
end: "shutdown",
"end-session": "shutdown",
capture: "screenshot",
screen: "snapshot",
elements: "snapshot",
"hit-test": "inspect",
hover: "inspect",
"preview-doctor": "preview-status",
"preview-list": "previews",
"list-previews": "previews",
"render-preview": "preview-render",
preview: "preview-render",
"open-preview-workspace": "preview-open",
"open-xcode": "preview-open",
"start-stream": "stream-start",
stream: "stream-start",
"window-start": "stream-start",
"start-window": "stream-start",
"mirror-start": "stream-start",
"start-mirror": "stream-start",
"live-start": "stream-start",
"start-live": "stream-start",
"preview-start": "stream-start",
"start-preview": "stream-start",
"stop-stream": "stream-stop",
"preview-stop": "stream-stop",
"stop-preview": "stream-stop",
"live-stop": "stream-stop",
"stop-live": "stream-stop",
swipe: "drag",
text: "type",
};
const HELP_BY_COMMAND: Record<string, string> = {
lanes: `${ADE_BANNER}
Lanes
Lanes are ADE-managed worktrees and branches. Most commands accept either
--lane <lane-id> or a positional lane id.
$ ade lanes list --text Show lane stack graph and branch names
$ ade lanes show <lane> --text Inspect one lane status
$ ade lanes create --name <name> Create a lane from the current project context
$ ade lanes child --lane <parent> --name <name> Create a child lane under a parent
$ ade lanes import --branch <branch> Register an existing branch/worktree
$ ade lanes archive <lane> Archive a lane in ADE
$ ade lanes unarchive <lane> Restore an archived lane
$ ade lanes attach --path <worktree> --name <n> Attach an external worktree
$ ade lanes actions --text List callable lane service methods
`,
git: `${ADE_BANNER}
Git
Git commands run in the lane worktree and record ADE operations so the app can
refresh lane state. Use --lane for anything other than the active workspace.
$ ade git status --lane <lane> --text Show ADE-aware sync status
$ ade git stage --lane <lane> src/file.ts Stage one file
$ ade git stage-all --lane <lane> Stage all current changes
$ ade git unstage --lane <lane> src/file.ts Unstage one file
$ ade git commit --lane <lane> [-m <message>] Commit, generating a message when omitted
$ ade git push --lane <lane> --set-upstream Push through ADE
$ ade git branches --lane <lane> --text List branches with last-commit metadata
$ ade git user-identity --lane <lane> --text Read lane checkout's git user.name/email
$ ade git stash push|list|apply|pop Use ADE lane stash actions
$ ade git rebase --lane <lane> --ai Rebase with ADE conflict support
$ ade diff changes --lane <lane> --text Inspect changed files
`,
diff: `${ADE_BANNER}
Diffs
$ ade diff changes --lane <lane> --text Summarize staged/unstaged file changes
$ ade diff file --lane <lane> <path> --text Show one file diff
$ ade diff file --mode staged <path> Inspect staged diff for one file
$ ade diff actions --text List diff service actions
`,
prs: `${ADE_BANNER}
Pull requests
PR identifiers may be ADE PR ids, GitHub PR numbers, #numbers, or full PR URLs.
Creating or linking a PR persists the lane mapping in ADE so the PR tab tracks it.
$ ade prs list --text List PRs known to ADE
$ ade prs list-open --text List every open GitHub PR in the repo, keyed by head branch
$ ade prs create --lane <lane> --base main Open and map a GitHub PR from a lane
$ ade prs link --lane <lane> --url <pr-url> Map an existing GitHub PR to a lane
$ ade prs checks <pr> --text Show check status
$ ade prs comments <pr> --text Show unresolved review work
$ ade prs inventory <pr> Refresh ADE issue inventory
$ ade prs path-to-merge <pr> --model <model> --max-rounds 3 --no-auto-merge
$ ade prs resolve-thread <pr> --thread <id> Resolve a review thread
$ ade prs labels set <pr> ready-to-merge Replace labels
$ ade prs reviewers request <pr> alice bob Request reviewers
`,
run: `${ADE_BANNER}
Run tab
Run tab commands mirror ADE desktop process definitions and runtime state.
They require the desktop socket when live process state is needed.
$ ade run defs --text List configured run commands
$ ade run ps --lane <lane> --text List process runtime state
$ ade run start <process> --lane <lane> Start a process in a lane
$ ade run stop <process> --lane <lane> Stop a process in a lane
$ ade run logs <process> --run <run> --text Tail process logs
$ ade run stack start --stack <id> --lane <lane> Start a process stack
$ ade run start-all --lane <lane> Start all configured processes
`,
shell: `${ADE_BANNER}
Shell sessions
Shell commands create tracked PTY sessions that ADE can display and audit.
$ ade shell start --lane <lane> -- npm test Start a tracked shell session
$ ade shell start --lane <lane> -c "npm test" Start with a command string
$ ade shell write <pty-id> --data "q" Write data to a PTY
$ ade shell resize <pty-id> --cols 120 --rows 36
$ ade shell close <pty-id> Dispose a PTY
`,
terminal: `${ADE_BANNER}
Chat terminal
Terminal commands control the active in-chat terminal for an ADE chat. Use
desktop socket mode when you want the same terminal the user sees in the app.
$ ade terminal list --chat-session <id> --text List terminals for a chat
$ ade terminal active --chat-session <id> --text Show the active chat terminal
$ ade terminal read --terminal <id> --text Read terminal scrollback
$ ade app-control logs --text Read the active App Control launch terminal
$ ade terminal write --terminal <id> --data "y\\n"
$ ade terminal signal --terminal <id> --signal SIGINT
`,
files: `${ADE_BANNER}
Files
File commands operate inside an ADE workspace id, usually a lane id.
$ ade files workspaces --text List workspace roots
$ ade files tree --workspace <lane> --path src Show a workspace tree
$ ade files read --workspace <lane> <path> --text Read a file
$ ade files write --workspace <lane> <path> --stdin
$ ade files write --workspace <lane> <path> --text "new content"
$ ade files create --workspace <lane> <path> --text "content"
$ ade files mkdir --workspace <lane> src/new
$ ade files search --workspace <lane> -q <text> Search text in a workspace
$ ade files quick-open --workspace <lane> -q app
`,
chat: `${ADE_BANNER}
Work chats
Chat commands use ADE agent chat sessions. Live provider-backed chat normally
requires the desktop socket because the app owns provider/session state.
$ ade chat list --text List chat sessions
$ ade chat create --lane <lane> --provider codex --model <model>
$ ade chat send <session> --text "next step" Send a message
$ ade chat interrupt <session> Stop an active turn
$ ade chat resume <session> Resume a session
$ ade agent spawn --lane <lane> --prompt "fix" Start a new agent work session
`,
agent: `${ADE_BANNER}
Agent sessions
$ ade agent spawn --lane <lane> --prompt "Fix the failing test"
$ ade agent spawn --lane <lane> --provider codex --model <model> --permissions workspace-write
$ ade agent spawn --lane <lane> --context-file docs/context.md --prompt "continue"
$ ade agent spawn --lane <lane> --tool=git --tool=files --prompt "review changes"
`,
proof: `${ADE_BANNER}
Proof and computer use
Proof commands capture or ingest reviewer-visible evidence for ADE work.
Prefer screenshots/images, screen recordings, and browser captures/traces.
Console logs are supporting diagnostics, not a replacement for visual proof.
Local screenshot/video fallback is macOS-only and runs headless by default
unless --socket is explicitly requested. Desktop socket mode has the best
parity for UI-owned proof state.
$ ade proof status --text Show proof backend capabilities
$ ade proof list --text List captured artifacts
$ ade proof capture --caption "Done" Capture a screenshot artifact
$ ade proof attach /tmp/proof.png --caption "Done" Attach an existing image/video
$ ade proof record --seconds 20 Capture a short video proof
$ ade proof launch --app "ADE" Launch an app for proof capture
$ ade proof ingest --input-json '{"artifacts":[]}' Ingest external visual proof artifacts
`,
"ios-sim": `${ADE_BANNER}
iOS Simulator
iOS simulator commands build, launch, mirror, inspect, and control the ADE
drawer simulator. Aliases: \`ade ios\` and \`ade simulator\` route to the same
surface. For drawer/shared session state, prefer desktop socket mode
(--socket) so launch/select/tap operate on the same long-lived ADE service.
Launch is headless by default; use --foreground only when you
need the native Simulator window in front. idb is optional for direct
pointer/text control and the low-latency MJPEG live stream.
Single-owner lock: a launched session is owned by one --chat-session at a time.
If another session tries to launch with a different chatSessionId, the call
fails with code IOS_SIMULATOR_OWNED_BY_OTHER_SESSION. Run "ios-sim shutdown"
(or "shutdown --force") to release before re-launching from a different chat.
Discovery and lifecycle:
$ ade ios-sim status --text Show Xcode/idb readiness (getStatus)
$ ade ios-sim devices --text List installed/available simulators (listDevices)
$ ade ios-sim apps --device <udid> --text List launchable apps (listLaunchTargets)
$ ade --socket ios-sim launch --target <id> Build/install/launch and update drawer state
$ ade --socket ios-sim launch --bundle-id com.example Launch installed app
$ ade --socket ios-sim shutdown Tear down session, streams, helper processes (alias: stop)
$ ade --socket ios-sim shutdown --force Force-release a session owned by another chat
$ ade ios-sim actions --text List every callable ios_simulator action
Capture and inspection:
$ ade ios-sim screenshot --text One-shot PNG via simctl (screenshot)
$ ade ios-sim snapshot --text Screenshot + selectable elements (getScreenSnapshot)
$ ade ios-sim inspector --text Published ADEInspector frames (getInspectorSnapshot)
$ ade ios-sim inspect --x 120 --y 420 --text Hit-test a point in the inspector (inspectPoint)
$ ade ios-sim preview-status --text Xcode MCP readiness for Preview Lab
$ ade ios-sim previews --source <file> --text List nearby #Preview definitions
$ ade ios-sim preview-render --source <file> Render a SwiftUI preview through Xcode MCP
Streaming:
$ ade ios-sim live-start --fps 30 Auto live stream (IOSurface first)
$ ade ios-sim preview-start --fps 8 simctl screenshot-poll fallback
$ ade ios-sim window-start --fps 60 Native Simulator.app window capture diagnostic
$ ade ios-sim stream-status --text Backend/fps/latency/URL (getStreamStatus)
$ ade ios-sim stream-stop Stop preview/live streaming (stopStream)
Input and selection:
$ ade --socket ios-sim select --x 120 --y 420 Add UI context to drawer chat (selectPoint)
$ ade ios-sim tap 120 420 Tap active simulator app (tap)
$ ade ios-sim drag 120 700 120 250 Drag active simulator app (drag)
$ ade ios-sim swipe 120 700 120 250 Swipe active simulator app (swipe)
$ ade ios-sim type "hello" --text Type into the launched app (typeText)
`,
"app-control": `${ADE_BANNER}
App Control
App Control is ADE's bridge for developer-owned app sessions. The first
supported kind is Electron: ADE can launch or connect to an Electron renderer
that exposes a Chrome DevTools Protocol port, then capture screenshots, DOM
elements, selected UI context, and basic input in the same style as the iOS
simulator drawer. App Control is intentionally a bridge: Playwright,
agent-browser, Computer Use, and other tools may also attach to the same app;
ADE keeps the launch/session state and turns snapshots into chat context.
Launching runs the command in the chat terminal instead of a hidden child
process. ADE sets ADE_APP_CONTROL_CDP_PORT and ADE_APP_CONTROL_DEBUG_FLAGS in
the environment and auto-forwards debug flags for common npm/pnpm/yarn/bun
script launches and direct electron commands. Custom launchers should forward
ADE_APP_CONTROL_DEBUG_FLAGS or ADE_APP_CONTROL_CDP_PORT. You can also put
{ADE_APP_CONTROL_DEBUG_FLAGS} in the command string for explicit substitution.
Reuse a Run-tab command: list configured processes with
\`ade settings get --text\`, then pass \`--cwd\` so the launch runs from the
same directory the Run tab uses. Relative cwds resolve against the lane root.
Discovery and lifecycle:
$ ade app-control status --text Show active session and provider readiness
$ ade app-control launch --command "npm run dev" --text
$ ade app-control launch pnpm dev --text Launch via the visible chat terminal
$ ade app-control launch --command "pnpm dev" --cwd apps/desktop --text
$ ade app-control launch --command "/path/script.sh {ADE_APP_CONTROL_DEBUG_FLAGS}"
$ ade app-control connect --cdp-port 9222 Attach to an already-running app
$ ade app-control targets --text List debuggable CDP targets
$ ade app-control attach-target --target <id> Attach to one renderer target
$ ade app-control logs --text Read the active App Control launch terminal
$ ade app-control terminal write --data "y\\n" Answer a prompt in that terminal
$ ade app-control stop --text Signal the App Control terminal session
$ ade app-control actions --text List every callable app_control action
$ ade terminal read --terminal <id> --text Read a specific chat terminal
$ ade terminal write --chat-session <id> --data "y\\n" Answer a prompt
Capture and context:
$ ade app-control screenshot --text Capture the active renderer screenshot
$ ade app-control snapshot --text Screenshot + DOM element refs
$ ade app-control inspect --x 120 --y 420 Hit-test a point without committing context
$ ade app-control select --x 120 --y 420 Add selected app context to the drawer chat
Input:
$ ade app-control click 120 420 Click screenshot coordinates
$ ade app-control scroll --x 120 --y 420 --delta-y 600
$ ade app-control key --key Enter
$ ade app-control type "hello" --text Type text into the focused element
`,
browser: `${ADE_BANNER}
ADE browser
Browser commands control ADE's global built-in browser pane. Use desktop
socket mode so CLI calls, chat link clicks, terminal localhost links, and the
Work sidebar all share the same browser tabs. The browser is global, not
lane-scoped.
Tabs and navigation:
$ ade --socket browser status --text Show active tab and tab list
$ ade --socket browser open https://example.com --text
$ ade --socket browser open localhost:5173 --new-tab --text
$ ade --socket browser new-tab --url https://example.com
$ ade --socket browser switch --tab <tab-id>
$ ade --socket browser close --tab <tab-id>
$ ade --socket browser actions --text List built_in_browser actions
Page controls:
$ ade --socket browser reload
$ ade --socket browser back
$ ade --socket browser forward
$ ade --socket browser stop
Capture and context:
$ ade --socket browser screenshot --text Capture the active browser tab
$ ade --socket browser select --x 120 --y 420 Attach DOM context at a viewport point
$ ade --socket browser inspect-start Start DOM inspect mode
$ ade --socket browser inspect-stop Stop DOM inspect mode
$ ade --socket browser select-current --text Return the selected DOM item
$ ade --socket browser clear-selection
Flags:
--url <url> URL for open/new-tab. Bare localhost gets http://.
--new-tab Open navigation in a new tab instead of active tab.
--tab, --tab-id <id> Target tab for switch/close/open.
`,
tests: `${ADE_BANNER}
Tests
$ ade tests list --text List configured test suites
$ ade tests run --lane <lane> --suite unit Run a configured suite
$ ade tests run --lane <lane> --command "npm test" --wait
$ ade tests runs --lane <lane> --text List recent test runs
$ ade tests logs <run-id> --text Tail a test run log
$ ade tests stop <run-id> Stop an active test run
`,
memory: `${ADE_BANNER}
Memory
$ ade memory add --category fact --content "User prefers concise summaries"
$ ade memory search -q "release process" --text
$ ade memory pin <memory-id>
$ ade memory core --arg projectSummary="Current focus"
`,
cto: `${ADE_BANNER}
CTO and Work state
$ ade cto state --text Read CTO identity, core memory, and recent sessions
$ ade cto chats list --text List CTO work chats
$ ade cto chats spawn --lane <lane> --prompt "plan this"
$ ade cto chats send <session> --text "continue"
$ ade actions run cto_state.updateCoreMemory --input-json '{"projectSummary":"..."}'
$ ade actions run worker_agent.listAgents --input-json '{"includeDeleted":false}'
`,
linear: `${ADE_BANNER}
Linear workflows
$ ade linear workflows --text List configured workflows
$ ade linear sync dashboard --text Show sync dashboard
$ ade linear sync run Trigger a sync run
$ ade linear sync queue --text List sync queue items
$ ade linear sync resolve --queue-item <id> --action approve
$ ade linear route worker --input-json '{"issueId":"LIN-123","workerId":"worker-1"}'
`,
flow: `${ADE_BANNER}
Flow policy
$ ade flow policy get --text Read current workflow policy