Skip to content

Commit f68a2eb

Browse files
DCodeBotdector
andcommitted
docs: update cli compatibility plan
Co-authored-by: D <code@dector.space>
1 parent 90ca641 commit f68a2eb

1 file changed

Lines changed: 64 additions & 66 deletions

File tree

docs/init/PLAN.md

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This plan is organized as small milestones. Each milestone should be implemented
44

55
## Progress
66

7-
- Current milestone: M61Surface persistent forwarding diagnostics.
8-
- Completed milestone range: Milestones 17–60 completed the initial CLI shell/push/pull work, CLI documentation, Linux USB transport design, transport abstraction, Linux USB discovery, Linux usbfs bulk transport, high-level USB connection API, CLI USB connection option, USB documentation, adb-go-specific target listing, explicit ADB authentication support, the client APK install helper, the CLI `install-apk` command, APK install documentation, logcat library/CLI/documentation support, property helpers, screencap support, reboot library/CLI/documentation support, foreground port forwarding support, the minimal adb-god daemon foundation, Linux systemd user-service install/lifecycle controls, Linux systemd user-service status reporting, daemon diagnostics, daemon service logs, daemon service reinstall, CLI version reporting, CLI error-message improvements, integration-test documentation, exported package documentation/examples, the daemon-backed persistent forwarding design, the daemon forwarding protocol model, daemon-owned forwarding listener registration, TCP target bridging for persistent forwards, and CLI persistent forwarding controls.
9-
- Active focus: implement daemon-owned persistent TCP forwarding in small slices while preserving the existing foreground forwarding behavior and avoiding durable daemon-owned ADB state until explicitly designed.
7+
- Current milestone: M62Extract custom CLI mode package.
8+
- Completed milestone range: Milestones 17–61 completed the initial CLI shell/push/pull work, CLI documentation, Linux USB transport design, transport abstraction, Linux USB discovery, Linux usbfs bulk transport, high-level USB connection API, CLI USB connection option, USB documentation, adb-go-specific target listing, explicit ADB authentication support, the client APK install helper, the CLI `install-apk` command, APK install documentation, logcat library/CLI/documentation support, property helpers, screencap support, reboot library/CLI/documentation support, foreground port forwarding support, the minimal adb-god daemon foundation, Linux systemd user-service install/lifecycle controls, Linux systemd user-service status reporting, daemon diagnostics, daemon service logs, daemon service reinstall, CLI version reporting, CLI error-message improvements, integration-test documentation, exported package documentation/examples, the daemon-backed persistent forwarding design, the daemon forwarding protocol model, daemon-owned forwarding listener registration, TCP target bridging for persistent forwards, CLI persistent forwarding controls, and persistent forwarding diagnostics.
9+
- Active focus: split the CLI into clearly separated custom and adb-compatibility modes. Custom mode preserves the current adb-go UX. Compat mode will target current Android SDK Platform-Tools `adb` CLI behavior closely enough that a future `adb` symlink can use adb-go as a drop-in replacement for supported workflows.
1010
- Completed USB direction: Linux-only first, using the kernel usbfs interface under `/dev/bus/usb` behind build tags. This remains pure Go because it talks to device files and ioctls directly instead of linking native USB libraries.
1111

1212
## Milestone template
@@ -45,128 +45,126 @@ Milestone rules:
4545
- Use grouped numbering such as `M40.1`, `M40.2`, and `M41.1` for related slices of one feature area.
4646
- Do not keep fully implemented milestone bodies in this file long term; summarize completed ranges in `Progress` instead.
4747

48-
## M57Add daemon forwarding protocol model
48+
## M62Extract custom CLI mode package
4949

50-
Status: Implemented
50+
Status: Not started
5151

52-
Commit: `feat(daemon): add forwarding protocol model`
52+
Commit: `refactor(cli): extract custom mode package`
5353

5454
Tasks:
5555

56-
- [x] Add daemon request/response types for `forward_create`, `forward_list`, `forward_remove`, and `forward_remove_all`.
57-
- [x] Define stable forwarding error codes such as `address_in_use`, `unsupported_endpoint`, `bad_target`, `rebind_disallowed`, and `forward_not_found`.
58-
- [x] Add validation for the first supported endpoint families without opening listeners or ADB device connections.
59-
- [x] Keep the protocol backward-compatible with existing `ping`, `status`, and `shutdown` commands.
56+
- [ ] Move the current `cmd/adb-go` CLI implementation into `cmd/adb-go/internal/custom`.
57+
- [ ] Expose a `custom.Run(args []string, stdout, stderr io.Writer) int` entrypoint for the moved implementation.
58+
- [ ] Keep the current adb-go custom UX, command names, flags, usage text, and behavior unchanged.
59+
- [ ] Leave `cmd/adb-go/main.go` as a thin compatibility wrapper around custom mode only; do not add mode detection yet.
60+
- [ ] Update package names/imports and test package references after the move.
6061

6162
Tests:
6263

63-
- [x] Unit tests cover JSON request/response handling for forwarding commands.
64-
- [x] Unit tests cover validation and stable daemon error codes.
65-
- [x] Existing daemon protocol tests continue to pass.
66-
- [x] `go test ./...` passes
64+
- [ ] Existing CLI tests pass without intentional expectation changes.
65+
- [ ] `go test ./...` passes
6766

6867
Done when:
6968

70-
- [x] The daemon protocol can parse, validate, and report forwarding commands without yet owning real listeners.
69+
- [ ] The current adb-go CLI behavior is preserved exactly while the code lives under `cmd/adb-go/internal/custom`.
7170

72-
## M58 — Add daemon forwarding registry and TCP listener ownership
71+
## M63 — Add CLI mode router
7372

74-
Status: Implemented
73+
Status: Not started
7574

76-
Commit: `feat(daemon): add forwarding listener registry`
75+
Commit: `feat(cli): add custom and compat mode router`
7776

7877
Tasks:
7978

80-
- [x] Add an in-memory daemon forwarding registry keyed by generated ID and local endpoint.
81-
- [x] Implement daemon-owned loopback TCP listener creation for supported local `tcp:PORT` endpoints.
82-
- [x] Implement list, remove-by-ID, remove-by-local, and remove-all behavior against daemon-owned listeners.
83-
- [x] Implement rebind and `norebind` semantics for daemon-owned forwards only.
84-
- [x] Ensure daemon shutdown closes forwarding listeners and active registry entries.
79+
- [ ] Replace `cmd/adb-go/main.go` with a tiny router that only detects mode and dispatches to the selected implementation.
80+
- [ ] Select compat mode when `ADB_GO_MODE=compat` or the executable basename is exactly `adb` or `adb.exe`.
81+
- [ ] Select custom mode when `ADB_GO_MODE=custom` or when no compat signal is present.
82+
- [ ] Reject any other non-empty `ADB_GO_MODE` value with exit code `2`.
83+
- [ ] Do not support bootstrap flags such as `--compat` or `--custom`.
84+
- [ ] Add a temporary compat placeholder that returns a clear “compat mode is not implemented yet” error with exit code `1`.
8585

8686
Tests:
8787

88-
- [x] Daemon tests cover create/list/remove/remove-all with isolated local TCP ports.
89-
- [x] Daemon tests cover ephemeral `tcp:0`, address-in-use, and rebind-disallowed behavior.
90-
- [x] Daemon shutdown tests cover listener cleanup.
91-
- [x] `go test ./...` passes
88+
- [ ] Router tests cover default custom mode, `ADB_GO_MODE=custom`, `ADB_GO_MODE=compat`, invalid `ADB_GO_MODE`, and `adb`/`adb.exe` basename detection.
89+
- [ ] Existing custom mode CLI tests continue to pass.
90+
- [ ] `go test ./...` passes
9291

9392
Done when:
9493

95-
- [x] `adb-god` can own and manage persistent local TCP listener registrations through the daemon protocol, without bridging ADB traffic yet.
94+
- [ ] The binary can route cleanly between custom mode and a compat placeholder without changing custom behavior.
9695

97-
## M59Bridge daemon forwards to TCP ADB targets
96+
## M64Add adb-compatible CLI skeleton
9897

99-
Status: Implemented
98+
Status: Not started
10099

101-
Commit: `feat(daemon): bridge persistent forwards`
100+
Commit: `feat(cli): add adb compat skeleton`
102101

103102
Tasks:
104103

105-
- [x] For each accepted daemon-owned local TCP connection, connect to the explicit TCP ADB target from the forwarding registration.
106-
- [x] Open the configured remote `tcp:PORT` ADB service for each accepted host connection.
107-
- [x] Copy bytes in both directions and close both sides when either side finishes.
108-
- [x] Track active connection counts and last connection/setup errors for list diagnostics.
109-
- [x] Keep USB target persistence out of scope for this first bridge slice.
104+
- [ ] Add `cmd/adb-go/internal/compat` with an independent `compat.Run(args []string, stdout, stderr io.Writer) int` implementation.
105+
- [ ] Implement compat `help`, `--help`, no-args, unknown command, and `version` behavior using the current Android SDK Platform-Tools `adb` output shape as the reference.
106+
- [ ] Make compat `version` adb-shaped but explicit that the implementation is adb-go, for example with an `(adb-go compat)` marker or equivalent wording.
107+
- [ ] Keep custom-only commands and flags such as `targets`, `daemon`, `install-apk`, `--addr`, `--usb`, and `ADB_GO_ADDR` out of compat mode.
108+
- [ ] Parse official-style global options enough for host-only skeleton commands, including `-H` and `-P` before `version`.
110109

111110
Tests:
112111

113-
- [x] Tests use fake ADB and local TCP clients to verify bidirectional forwarding through the daemon.
114-
- [x] Tests cover failed target dial/service-open behavior without dropping the local listener.
115-
- [x] Tests cover remove/shutdown closing active bridged connections.
116-
- [x] `go test ./...` passes
112+
- [ ] Compat tests cover `help`, `--help`, no args, `-h`, unknown commands, `version`, and global `-H`/`-P` with `version`.
113+
- [ ] Snapshot-style assertions cover important stdout/stderr placement and exit codes from the captured official adb reference.
114+
- [ ] `go test ./...` passes
117115

118116
Done when:
119117

120-
- [x] A daemon-owned background forward can carry TCP traffic from a host client to a device `tcp:PORT` service through an explicit TCP ADB target.
118+
- [ ] Compat mode has a real adb-shaped host-only skeleton while remaining independent from custom mode.
121119

122-
## M60 — Add CLI persistent forwarding controls
120+
## M65 — Add compat daemon/server foundation
123121

124-
Status: Implemented
122+
Status: Not started
125123

126-
Commit: `feat(cli): add persistent forward controls`
124+
Commit: `feat(cli): add compat daemon foundation`
127125

128126
Tasks:
129127

130-
- [x] Add `adb-go forward --background` to create daemon-owned persistent forwards.
131-
- [x] Add `adb-go forward --list`, `--remove LOCAL`, `--remove-id ID`, and `--remove-all` wired to the daemon protocol.
132-
- [x] Keep existing foreground `adb-go forward LOCAL REMOTE` behavior unchanged when daemon flags are absent.
133-
- [x] Print clear setup/list/remove output, including actual bound local address for `tcp:0`.
134-
- [x] Return actionable daemon-unavailable or daemon-too-old hints, such as running `adb-go daemon doctor`.
135-
- [x] Document the new CLI behavior and the non-durable in-memory daemon lifecycle.
128+
- [ ] Add compat implementations for `start-server`, `kill-server`, and `devices` on top of adb-go daemon internals/protocol rather than the official adb server protocol.
129+
- [ ] Auto-start the adb-go daemon for compat commands that need server state.
130+
- [ ] Make `adb devices` show daemon-known TCP devices from prior compat `connect` work and locally discoverable USB devices when available.
131+
- [ ] Keep broad blind TCP/emulator scanning out of the initial compat `devices` behavior.
132+
- [ ] Preserve official adb CLI-facing output shape where practical while allowing different daemon internals.
136133

137134
Tests:
138135

139-
- [x] CLI tests cover argument parsing and daemon requests for background/list/remove/remove-all.
140-
- [x] CLI tests cover foreground forwarding still using the existing process-scoped path.
141-
- [x] CLI tests cover daemon-unavailable or unknown-command error messages.
142-
- [x] `go test ./...` passes
136+
- [ ] Compat tests cover server lifecycle commands and auto-start behavior.
137+
- [ ] Compat tests cover no-device `devices` output matching the official reference shape.
138+
- [ ] Daemon tests cover any new protocol/state needed by compat devices listing.
139+
- [ ] `go test ./...` passes
143140

144141
Done when:
145142

146-
- [x] Users can create, inspect, and remove daemon-owned persistent TCP forwards from the CLI while existing foreground forwarding remains compatible.
143+
- [ ] Compat mode has adb-shaped server lifecycle and device-list foundations backed by adb-go daemon internals.
147144

148-
## M61Surface persistent forwarding diagnostics
145+
## M66Add compat target selection foundation
149146

150-
Status: Implemented
147+
Status: Not started
151148

152-
Commit: `feat(cli): show daemon forwarding diagnostics`
149+
Commit: `feat(cli): add compat target selection`
153150

154151
Tasks:
155152

156-
- [x] Add concise forwarding counts to daemon diagnostics without turning `daemon status` into a full forwarding table.
157-
- [x] Include forwarding state hints in `adb-go daemon doctor` when daemon-owned forwards are degraded.
158-
- [x] Ensure detailed mappings remain available through `adb-go forward --list`.
159-
- [x] Update daemon and CLI documentation with troubleshooting examples for degraded forwards, target disconnects, and lost forwards after daemon restart.
153+
- [ ] Support official target selectors `-s SERIAL`, `-d`, and `-e` in compat mode.
154+
- [ ] Support `$ANDROID_SERIAL`, with `-s SERIAL` taking precedence.
155+
- [ ] Keep `ADB_GO_ADDR` ignored in compat mode.
156+
- [ ] Map selected compat transports onto daemon/device registry entries and adb-go TCP/USB connection options.
157+
- [ ] Defer transport IDs (`-t ID`) unless promoted into this milestone after additional reference capture.
160158

161159
Tests:
162160

163-
- [x] CLI/daemon tests cover forwarding counts in diagnostics.
164-
- [x] CLI tests cover doctor hints for degraded forwarding state.
165-
- [x] `go test ./...` passes
161+
- [ ] Compat parser tests cover selector precedence and no-command help/exit behavior for `-s`, `-d`, and `-e`.
162+
- [ ] Compat command tests cover selected-device resolution against fake daemon/device state.
163+
- [ ] `go test ./...` passes
166164

167165
Done when:
168166

169-
- [x] Support requests can distinguish daemon reachability problems from persistent-forward target/listener problems without exposing payload data.
167+
- [ ] Compat commands can resolve devices using official adb selector mechanisms without exposing custom adb-go target flags.
170168

171169
## Deferred milestones
172170

0 commit comments

Comments
 (0)