roonctl 1.0.0__tar.gz

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.
Files changed (96) hide show
  1. roonctl-1.0.0/.gitignore +25 -0
  2. roonctl-1.0.0/ARCHITECTURE.md +215 -0
  3. roonctl-1.0.0/CHANGELOG.md +77 -0
  4. roonctl-1.0.0/CODE_OF_CONDUCT.md +86 -0
  5. roonctl-1.0.0/CONTRIBUTING.md +90 -0
  6. roonctl-1.0.0/LICENSE +21 -0
  7. roonctl-1.0.0/PKG-INFO +446 -0
  8. roonctl-1.0.0/README.md +406 -0
  9. roonctl-1.0.0/SECURITY.md +57 -0
  10. roonctl-1.0.0/docs/agent-usage.md +150 -0
  11. roonctl-1.0.0/docs/api-coverage.md +217 -0
  12. roonctl-1.0.0/docs/assets/social-preview.png +0 -0
  13. roonctl-1.0.0/docs/commands.md +1236 -0
  14. roonctl-1.0.0/docs/live-test-matrix.md +187 -0
  15. roonctl-1.0.0/docs/skill-load-proof.md +66 -0
  16. roonctl-1.0.0/examples/now-playing.sh +9 -0
  17. roonctl-1.0.0/examples/snapshot-restore.sh +22 -0
  18. roonctl-1.0.0/pyproject.toml +172 -0
  19. roonctl-1.0.0/scripts/capture-golden.py +33 -0
  20. roonctl-1.0.0/scripts/check-matrix.sh +18 -0
  21. roonctl-1.0.0/scripts/check.sh +83 -0
  22. roonctl-1.0.0/scripts/gen-command-docs.py +113 -0
  23. roonctl-1.0.0/scripts/prove-skill-loads.sh +634 -0
  24. roonctl-1.0.0/scripts/release.sh +24 -0
  25. roonctl-1.0.0/scripts/skill_load_stub.py +140 -0
  26. roonctl-1.0.0/src/roonctl/__init__.py +7 -0
  27. roonctl-1.0.0/src/roonctl/__main__.py +3 -0
  28. roonctl-1.0.0/src/roonctl/browsing.py +1072 -0
  29. roonctl-1.0.0/src/roonctl/cli/__init__.py +412 -0
  30. roonctl-1.0.0/src/roonctl/cli/admin.py +547 -0
  31. roonctl-1.0.0/src/roonctl/cli/control.py +916 -0
  32. roonctl-1.0.0/src/roonctl/cli/filteropts.py +125 -0
  33. roonctl-1.0.0/src/roonctl/cli/live.py +104 -0
  34. roonctl-1.0.0/src/roonctl/cli/media.py +141 -0
  35. roonctl-1.0.0/src/roonctl/cli/playall.py +241 -0
  36. roonctl-1.0.0/src/roonctl/cli/read.py +310 -0
  37. roonctl-1.0.0/src/roonctl/cli/skillcmd.py +465 -0
  38. roonctl-1.0.0/src/roonctl/client.py +265 -0
  39. roonctl-1.0.0/src/roonctl/config.py +332 -0
  40. roonctl-1.0.0/src/roonctl/data/SKILL.md +256 -0
  41. roonctl-1.0.0/src/roonctl/discovery.py +708 -0
  42. roonctl-1.0.0/src/roonctl/errors.py +179 -0
  43. roonctl-1.0.0/src/roonctl/filters.py +177 -0
  44. roonctl-1.0.0/src/roonctl/models.py +408 -0
  45. roonctl-1.0.0/src/roonctl/moo.py +554 -0
  46. roonctl-1.0.0/src/roonctl/playall.py +374 -0
  47. roonctl-1.0.0/src/roonctl/render.py +280 -0
  48. roonctl-1.0.0/src/roonctl/resolve.py +259 -0
  49. roonctl-1.0.0/src/roonctl/schemas.py +518 -0
  50. roonctl-1.0.0/src/roonctl/services.py +278 -0
  51. roonctl-1.0.0/src/roonctl/skilltargets.py +399 -0
  52. roonctl-1.0.0/src/roonctl/sood.py +225 -0
  53. roonctl-1.0.0/src/roonctl/spec.py +392 -0
  54. roonctl-1.0.0/src/roonctl/tokens.py +108 -0
  55. roonctl-1.0.0/src/roonctl/verify.py +239 -0
  56. roonctl-1.0.0/src/roonctl/volume.py +185 -0
  57. roonctl-1.0.0/src/roonctl/watch.py +468 -0
  58. roonctl-1.0.0/tests/__init__.py +0 -0
  59. roonctl-1.0.0/tests/command_cases.py +92 -0
  60. roonctl-1.0.0/tests/conftest.py +79 -0
  61. roonctl-1.0.0/tests/fake_core.py +1260 -0
  62. roonctl-1.0.0/tests/fixtures/windows-netip-report.json +86 -0
  63. roonctl-1.0.0/tests/golden/commands.json +185 -0
  64. roonctl-1.0.0/tests/golden.py +156 -0
  65. roonctl-1.0.0/tests/helpers.py +42 -0
  66. roonctl-1.0.0/tests/test_browsing.py +345 -0
  67. roonctl-1.0.0/tests/test_cli_admin.py +367 -0
  68. roonctl-1.0.0/tests/test_cli_admin_extra.py +176 -0
  69. roonctl-1.0.0/tests/test_cli_control.py +811 -0
  70. roonctl-1.0.0/tests/test_cli_playall.py +292 -0
  71. roonctl-1.0.0/tests/test_cli_read.py +209 -0
  72. roonctl-1.0.0/tests/test_cli_state.py +497 -0
  73. roonctl-1.0.0/tests/test_client_extra.py +284 -0
  74. roonctl-1.0.0/tests/test_command_golden.py +40 -0
  75. roonctl-1.0.0/tests/test_discovery.py +758 -0
  76. roonctl-1.0.0/tests/test_docs_drift.py +295 -0
  77. roonctl-1.0.0/tests/test_extra.py +272 -0
  78. roonctl-1.0.0/tests/test_fake_core.py +41 -0
  79. roonctl-1.0.0/tests/test_filters.py +131 -0
  80. roonctl-1.0.0/tests/test_hygiene.py +87 -0
  81. roonctl-1.0.0/tests/test_models_negative.py +239 -0
  82. roonctl-1.0.0/tests/test_moo.py +172 -0
  83. roonctl-1.0.0/tests/test_moo_internals.py +295 -0
  84. roonctl-1.0.0/tests/test_moo_property.py +67 -0
  85. roonctl-1.0.0/tests/test_playall.py +210 -0
  86. roonctl-1.0.0/tests/test_render.py +221 -0
  87. roonctl-1.0.0/tests/test_schema_drift.py +183 -0
  88. roonctl-1.0.0/tests/test_services.py +201 -0
  89. roonctl-1.0.0/tests/test_skill_targets.py +273 -0
  90. roonctl-1.0.0/tests/test_sood_discover.py +297 -0
  91. roonctl-1.0.0/tests/test_typing_boundary.py +58 -0
  92. roonctl-1.0.0/tests/test_units.py +282 -0
  93. roonctl-1.0.0/tests/test_verify.py +95 -0
  94. roonctl-1.0.0/tests/test_watch.py +175 -0
  95. roonctl-1.0.0/tests/test_watch_soak.py +79 -0
  96. roonctl-1.0.0/tests/test_watch_unit.py +457 -0
@@ -0,0 +1,25 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ .venv-*/
9
+ .mypy_cache/
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .coverage
13
+ coverage.xml
14
+ htmlcov/
15
+
16
+ # Tooling
17
+ .idea/
18
+ .vscode/
19
+ .DS_Store
20
+
21
+ # Local agent state and secrets
22
+ .env
23
+ *.token
24
+ tokens.json
25
+ config.toml
@@ -0,0 +1,215 @@
1
+ # Architecture
2
+
3
+ roonctl is a one-shot CLI over Roon's Extension API. It has no daemon, no database and
4
+ no background sync. This document explains the pieces and the decisions behind them.
5
+
6
+ ## Layers
7
+
8
+ ```
9
+ ┌─────────────────────────────────────────────────────────────┐
10
+ │ cli/ click commands, JSON/human output, exit codes│
11
+ ├─────────────────────────────────────────────────────────────┤
12
+ │ spec.py command metadata, exit-code table │
13
+ │ schemas.py JSON Schema for every output shape │
14
+ │ render.py human tables and lines │
15
+ ├─────────────────────────────────────────────────────────────┤
16
+ │ resolve.py name -> one zone/output/item, or ambiguity │
17
+ │ volume.py percent <-> native volume scales │
18
+ │ browsing.py browse stack, item search, play actions │
19
+ │ playall.py plan a multi-item play, then execute it │
20
+ │ filters.py repeatable --match/--exclude predicates │
21
+ │ verify.py read the zone back and prove the effect │
22
+ │ watch.py NDJSON event pump, keepalive and reconnect │
23
+ ├─────────────────────────────────────────────────────────────┤
24
+ │ client.py registry handshake, token storage, services │
25
+ │ services.py transport, browse, image wrappers │
26
+ │ discovery.py interfaces, unicast fallback, TCP identify │
27
+ │ models.py typed access to Core payloads, never KeyError│
28
+ │ skilltargets.py one row per agent and its skill path │
29
+ ├─────────────────────────────────────────────────────────────┤
30
+ │ moo.py MOO/1 framing over WebSocket │
31
+ │ sood.py UDP discovery │
32
+ │ config.py XDG config, multi-Core, profiles │
33
+ │ tokens.py owner-only token file │
34
+ ├─────────────────────────────────────────────────────────────┤
35
+ │ errors.py one error type and the exit-code table │
36
+ └─────────────────────────────────────────────────────────────┘
37
+ ```
38
+
39
+ Dependencies point downward. `errors.py` is the floor: every layer raises the same
40
+ error types, so it sits below even the protocol layer. The CLI knows about services;
41
+ services know about MOO; nothing above MOO knows about WebSockets.
42
+
43
+ ## Zero-config discovery
44
+
45
+ SOOD multicast is one packet on one interface, and it is often dropped: containers,
46
+ VLANs, WSL's NAT and VPNs all break it. `discovery.py` treats multicast as the first
47
+ phase, not the only one:
48
+
49
+ 1. Every up IPv4 interface gets a multicast query with `IP_MULTICAST_IF` set, plus its
50
+ own broadcast address.
51
+ 2. A bounded unicast sweep covers the default-route interface's /24 (or the interface's
52
+ subnet when narrower), then other interfaces, then the Tailscale peers read from
53
+ `tailscale status --json`. Container bridges are skipped for unicast because a
54
+ developer machine can have dozens; they still get the broadcast.
55
+ 3. Hosts that stay silent get a TCP check of 9330 and a read-only `registry:1/info`.
56
+ A Core that answers there is identified without registering or pairing.
57
+
58
+ The sweep is capped at 256 hosts and only ports 9003 (UDP) and 9330 (TCP) are touched.
59
+ When no Core is configured, `State.core_config` calls `auto_configure`: one Core is
60
+ saved and used, several raise `several_cores` with the candidates, none raises
61
+ `core_not_found` with the `--host` fallback. The Core's unique id is stored in the
62
+ config, so a later command can find it at a new address; `reconcile` does the same for
63
+ `discover`.
64
+
65
+ ## Why a typed client instead of `roonapi`
66
+
67
+ `roonapi` (pyroon) is the library Home Assistant uses and it covers the same protocol,
68
+ but its PyPI release is from December 2023 and it is not typed. roonctl needs strict
69
+ types, precise timeouts, subscription control and a stable error model. The protocol is
70
+ small and documented, so roonctl implements MOO/1 directly:
71
+
72
+ - `moo.py` encodes `MOO/1 REQUEST|COMPLETE|CONTINUE` frames with `Request-Id` and
73
+ `Content-Length` counted in UTF-8 bytes, and parses replies on a reader thread.
74
+ - Requests are synchronous: send, then wait for the matching `COMPLETE`. `CONTINUE`
75
+ frames for a request are delivered to an optional callback (used for pairing).
76
+ - Subscriptions (`subscribe_zones`, `subscribe_queue`) register a handler keyed by the
77
+ request id. A `COMPLETE Subscribed` resolves the subscribe request; later `CONTINUE`
78
+ frames go to the handler; `Unsubscribed` ends it.
79
+ - Requests and replies are WebSocket **binary** frames carrying MOO text (the same
80
+ opcode pyroon uses). A TEXT frame is accepted by the socket but Roon never answers it.
81
+
82
+ ## Connection lifecycle
83
+
84
+ Every command is connect, act, exit:
85
+
86
+ 1. `RoonClient.connect` opens one socket, asks `registry:1/info` for the Core id, then
87
+ sends `registry:1/register` with the extension description and, if present, the
88
+ token for that Core.
89
+ 2. `Registered` carries a token when the Core issues or refreshes one; it is written to
90
+ the token store. `Waiting` means a human must tap Enable; `Unauthorized` maps to exit
91
+ code 4.
92
+ 3. The command runs against `transport`, `browse` and `image` services.
93
+ 4. The connection closes. Click's context close hook guarantees this even when a command
94
+ raises.
95
+
96
+ There is no retry in any control path. A retried "next" is a double skip, and a retried
97
+ "play" can restart a track. If the reply is lost, the command fails with exit 8 and the
98
+ caller decides. `watch` is the sole exception: it is a long-lived stream, so it reconnects
99
+ and re-subscribes rather than ending on the first dropped socket.
100
+
101
+ ## Errors
102
+
103
+ `errors.py` defines one exception type, `RoonctlError`, carrying:
104
+
105
+ - a stable machine `code` (`zone_not_found`, `auth_timeout`, `volume_unsupported`, ...),
106
+ - a human `message`, an optional `hint`, and structured `details`,
107
+ - an `ExitCode` from the documented table.
108
+
109
+ `cli.run` is the only place that prints an error. It emits one JSON object on stderr
110
+ when JSON mode is on (or a one-line message otherwise), never a traceback unless
111
+ `--verbose` is passed. Unexpected exceptions become `internal_error` with exit 1.
112
+
113
+ ## Name resolution
114
+
115
+ Agents retry and guess; a silent pick between "Zone One" and "Zone One Upstairs" is
116
+ worse than an error. `resolve.match_one` tries, in order:
117
+
118
+ 1. exact match, case-insensitive;
119
+ 2. unique prefix;
120
+ 3. unique substring.
121
+
122
+ More than one match at any stage raises `AmbiguousError` with the candidate list. A
123
+ zone also resolves through its outputs' names, because people say "the Zone One speaker"
124
+ when the zone is called something else. Output-name matches are deduplicated by zone.
125
+
126
+ ## Volume
127
+
128
+ Roon reports volume on three scales: `number` (often 0–100), `db` (negative, sometimes
129
+ with headroom) and `incremental` (no absolute value). The CLI speaks percent and converts
130
+ at the boundary:
131
+
132
+ - `percent -> raw` uses the output's own `min`/`max` and snaps to its native `step`;
133
+ - `raw -> percent` is the inverse, clamped to 0–100;
134
+ - relative changes convert the percent delta into native units, rounding to at least one
135
+ native step so "+1%" never becomes a no-op;
136
+ - `--step` sends `relative_step` for incremental controls that only accept steps.
137
+
138
+ `--dry-run` computes the exact raw value and reports `before_percent`/`target_percent`
139
+ without sending anything.
140
+
141
+ ## Browse
142
+
143
+ Roon's browse API is a per-connection stack, not a tree query. `browsing.Browser` keeps
144
+ the stack explicit:
145
+
146
+ - `reset()` sends `pop_all`;
147
+ - `enter(item)` selects an item and expects a list level;
148
+ - `load_all()` pages through the current level with `browse:1/load` (100 items per page,
149
+ bounded by `--limit`), so a target past the displayed page is still found;
150
+ - `walk(path)` enters each title in turn, and the final component must be a list, not an
151
+ action (selecting an action starts playback).
152
+
153
+ `play_item` selects an item, lists its actions, chooses "Play Now" (or `--action`), and
154
+ selects that action. An item whose hint is `action` (an internet radio station, for
155
+ example) is itself the action; in `--dry-run` it is never selected, which is why
156
+ `--item-key` needs `--item-hint` for a safe plan.
157
+
158
+ ## Watch
159
+
160
+ `watch` subscribes to zones (and optionally the queue), emits one JSON object per line,
161
+ and flushes each line. Heartbeats keep the stream visibly alive. SIGINT exits 0 with a
162
+ final `{"event": "end"}` line; `--duration` and `--max-events` bound a run for scripts
163
+ and agents.
164
+
165
+ `recv` does not fail on a half-open TCP link, so silence is the only signal available.
166
+ After `--keepalive` seconds without a frame, `watch` sends the Core's own
167
+ `com.roonlabs.ping:1/ping`. Two unanswered pings mean the connection is lost: it emits
168
+ `end.reason = "connection_lost"` and exits 3. With the default `--reconnect`, it first
169
+ replaces the socket (`--reconnect-attempts`, default 3), re-subscribes and emits a fresh
170
+ `snapshot`, so a Core restart or a NAT timeout does not silently produce heartbeats on
171
+ a dead stream. `--no-reconnect` fails as degraded instead.
172
+
173
+ A silent Core reaches exit 3 in about 19 s at the defaults, and about 12 s with
174
+ `--no-reconnect`: that is two `--keepalive` waits plus two `--ping-timeout` replies
175
+ (12 s), plus the bounded reconnect window (`keepalive + ping_timeout`, 7 s). The
176
+ defaults are deliberately patient because a high-latency link (Tailscale, a VPN, a
177
+ sleeping laptop) can take close to a second per round trip. For a fast failure pass
178
+ `--keepalive 1 --ping-timeout 1`, which brings the same exit to about 5 s (3 s with
179
+ `--no-reconnect`).
180
+
181
+ ## Configuration and secrets
182
+
183
+ - Config is TOML at `$XDG_CONFIG_HOME/roonctl/config.toml`. Unknown keys are rejected so
184
+ a typo cannot silently do nothing.
185
+ - Tokens are a separate JSON map (`core_id -> token`) at
186
+ `$XDG_CONFIG_HOME/roonctl/tokens.json`, written atomically with mode 0600. `audit()`
187
+ repairs a loose mode and reports it. Tokens never appear in `config show`, errors or
188
+ logs.
189
+ - Multiple Cores and profiles are first-class; a profile is a named set of defaults
190
+ (Core, zone, output, volume step), not a Roon profile.
191
+
192
+ ## Testing
193
+
194
+ `tests/fake_core.py` is a real WebSocket server on loopback that speaks MOO/1, runs the
195
+ registry handshake (including `Waiting` and `Unauthorized`), keeps a browse stack,
196
+ answers transport calls, records every request, and can emit subscription events and
197
+ binary images. It parses requests with its own decoder, not `roonctl.moo`, so an encoder
198
+ and parser that agree only with each other cannot pass. It rejects TEXT frames, closes on
199
+ an unparseable request, records unknown requests and internal exceptions, and the `core`
200
+ fixture fails a test if any of those lists is non-empty. Tests drive the real client and
201
+ the real CLI entry point against it, so framing bugs surface without a Roon Core.
202
+
203
+ The default gate requires no network beyond loopback and no Roon. Live tests are marked
204
+ `live`, are opt-in, and restore the state they touch.
205
+
206
+ ## Decisions
207
+
208
+ - **Official Extension API only.** Roon's port-9332 protocol is internal and not
209
+ supported for third parties.
210
+ - **No daemon.** One process per command; `watch` is the only long-lived mode.
211
+ - **No retries.** Correctness over convenience in control paths.
212
+ - **JSON by default when piped.** Human output is opt-in with `--human`, so scripts and
213
+ agents get a stable document without extra flags.
214
+ - **Fail loudly on ambiguity.** Candidate lists instead of guesses.
215
+ - **Strict config.** Unknown keys are errors.
@@ -0,0 +1,77 @@
1
+ # Changelog
2
+
3
+ All notable changes are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [semantic versioning](https://semver.org/).
6
+
7
+ ## [1.0.0] - 2026-12-05
8
+
9
+ The first stable release. roonctl is an unofficial command-line client for Roon's
10
+ official Extension API: it finds a Core, pairs once, and then controls zones and reads
11
+ the library from a shell or from an AI agent. No daemon, no GUI, no vendor SDK.
12
+
13
+ ### Added
14
+
15
+ - **Three operating systems.** Linux, macOS and native Windows 10/11 are tested in CI
16
+ on Python 3.11, 3.12 and 3.13. macOS reads `ifconfig -a` and `route -n get default`;
17
+ Windows asks the built-in PowerShell for one JSON report of addresses, adapter state
18
+ and the default route, so real netmasks and per-interface broadcast work there
19
+ without a new runtime dependency. Discovery also survives the ICMP port-unreachable
20
+ that Windows reports as `WSAECONNRESET`, so a unicast sweep to an empty host cannot
21
+ end the listen early, and a pending reset cannot swallow the next query. `install.sh`
22
+ stays macOS/Linux; `uv tool install`
23
+ and `pipx install` are the cross-platform installs.
24
+ - **Discovery and pairing.** SOOD discovery on every up interface (multicast, per-
25
+ interface broadcast, a bounded unicast sweep of the local /24s, a TCP 9330 registry
26
+ check, and Tailscale peers when available). One Core is used automatically, several
27
+ are listed, and a discovered Core is remembered by its stable unique id. `pair`
28
+ registers the extension and stores one token per Core at mode 0600, never printed.
29
+ - **Zones, outputs and transport.** `zones`, `outputs`, `now`, `play`, `play-radio`,
30
+ `resume`, `pause`, `playpause`, `stop`, `next`, `previous`, `seek`, `shuffle`,
31
+ `loop`, `auto-radio` and `pause-all`, with name resolution that fails loudly on
32
+ ambiguity instead of guessing.
33
+ - **Volume and room control.** Absolute, relative, native-step and raw volume; mute per
34
+ output; standby, toggle-standby, convenience-switch; grouping, ungrouping and
35
+ transfer between zones.
36
+ - **Queue.** Reading with paging, and `play-from-here` by real queue item id or 1-based
37
+ `--position`, validated against the whole queue and verified after sending.
38
+ - **Browse and search.** `browse`, `search` and the library shortcuts (`albums`,
39
+ `artists`, `tracks`, `genres`, `composers`, `playlists`, `internet-radio`), field
40
+ filters, regular expressions, `--index`, and `play-all` to play or queue a filtered
41
+ set. `action` runs any named browse action on an item.
42
+ - **Media and live events.** Album art and image fetch at a chosen size or original
43
+ resolution, and `watch`: an NDJSON event stream with keepalive, bounded reconnect and
44
+ a clean `end` event.
45
+ - **An agent contract.** JSON on stdout whenever stdout is not a TTY, one JSON document
46
+ per invocation, a single documented error object, stable exit codes, `commands --json`
47
+ and `schema <name>` for introspection, and `--dry-run` on every state-changing
48
+ command.
49
+ - **A bundled skill.** `roonctl skill show`, `path`, `targets` and `install` cover about
50
+ thirty agent harnesses; ten are load-proven with each agent's own discovery code.
51
+ - **Stability policy.** From 1.0, command names, flags, JSON schemas and exit codes are
52
+ stable; breaking any of them needs a major version.
53
+
54
+ ### Security
55
+
56
+ - Pairing tokens live in a separate file, written atomically with mode 0600, and never
57
+ appear in output, errors or logs.
58
+ - Discovery trusts the UDP source address, not a reply's self-declared `_replyaddr`. A
59
+ configured Core that appears at a new address must prove the same core id over TCP
60
+ before the address changes, and a stored token is never sent to a host that reports a
61
+ different id.
62
+ - Human-readable output replaces terminal control characters, so a Core name or a track
63
+ tag cannot retitle the window, clear the screen or set the clipboard.
64
+ - The installer pins the release tag `v1.0.0` by default, and the release workflow
65
+ refuses a tag that does not match `pyproject.toml` or is not on `main`.
66
+ - The Roon extension registration carries no email address: the Core's required `email`
67
+ field is sent as an empty string, and the contact points at the repository.
68
+ - CI runs CodeQL, gitleaks over the full history, `pip-audit` against the lock, and
69
+ dependency review on pull requests. Releases publish to PyPI through Trusted
70
+ Publishing (OIDC) from a protected `pypi` environment, with no stored token.
71
+
72
+ ### Notes
73
+
74
+ - 740 tests, 96% branch coverage, gate green on Python 3.11, 3.12 and 3.13 from the
75
+ committed `uv.lock`.
76
+ - MIT licensed. Unofficial; not affiliated with or endorsed by Roon Labs. Roon is a
77
+ trademark of Roon Labs.
@@ -0,0 +1,86 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our pledge
4
+
5
+ We as members, contributors and leaders pledge to make participation in our community a
6
+ harassment-free experience for everyone, regardless of age, body size, visible or
7
+ invisible disability, ethnicity, sex characteristics, gender identity and expression,
8
+ level of experience, education, socio-economic status, nationality, personal appearance,
9
+ race, caste, colour, religion, or sexual identity and orientation.
10
+
11
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse,
12
+ inclusive and healthy community.
13
+
14
+ ## Our standards
15
+
16
+ Examples of behaviour that contributes to a positive environment:
17
+
18
+ - Demonstrating empathy and kindness toward other people.
19
+ - Being respectful of differing opinions, viewpoints and experiences.
20
+ - Giving and gracefully accepting constructive feedback.
21
+ - Accepting responsibility and apologising to those affected by our mistakes, and
22
+ learning from the experience.
23
+ - Focusing on what is best not just for us as individuals but for the overall community.
24
+
25
+ Examples of unacceptable behaviour:
26
+
27
+ - The use of sexualised language or imagery, and sexual attention or advances of any kind.
28
+ - Trolling, insulting or derogatory comments, and personal or political attacks.
29
+ - Public or private harassment.
30
+ - Publishing others' private information, such as a physical or email address, without
31
+ their explicit permission.
32
+ - Other conduct which could reasonably be considered inappropriate in a professional
33
+ setting.
34
+
35
+ ## Enforcement responsibilities
36
+
37
+ Community leaders are responsible for clarifying and enforcing our standards of
38
+ acceptable behaviour and will take appropriate and fair corrective action in response to
39
+ any behaviour that they deem inappropriate, threatening, offensive or harmful.
40
+
41
+ Community leaders have the right and responsibility to remove, edit or reject comments,
42
+ commits, code, wiki edits, issues and other contributions that are not aligned to this
43
+ Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
44
+
45
+ ## Scope
46
+
47
+ This Code of Conduct applies within all community spaces, and also applies when an
48
+ individual is officially representing the community in public spaces. Examples of
49
+ representing our community include using an official email address, posting via an
50
+ official social media account, or acting as an appointed representative at an online or
51
+ offline event.
52
+
53
+ ## Enforcement
54
+
55
+ Instances of abusive, harassing or otherwise unacceptable behaviour may be reported to
56
+ the community leaders responsible for enforcement at the address in `pyproject.toml`.
57
+ All complaints will be reviewed and investigated promptly and fairly.
58
+
59
+ All community leaders are obligated to respect the privacy and security of the reporter
60
+ of any incident.
61
+
62
+ ## Enforcement guidelines
63
+
64
+ Community leaders will follow these Community Impact Guidelines in determining the
65
+ consequences for any action they deem in violation of this Code of Conduct:
66
+
67
+ 1. **Correction**: a private, written warning from community leaders, providing clarity
68
+ around the nature of the violation and an explanation of why the behaviour was
69
+ inappropriate. A public apology may be requested.
70
+ 2. **Warning**: a warning with consequences for continued behaviour. No interaction with
71
+ the people involved for a specified period of time. This includes avoiding
72
+ interactions in community spaces as well as external channels like social media.
73
+ 3. **Temporary ban**: a temporary ban from any sort of interaction or public
74
+ communication with the community for a specified period of time.
75
+ 4. **Permanent ban**: a permanent ban from any sort of public interaction within the
76
+ community.
77
+
78
+ ## Attribution
79
+
80
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1,
81
+ available at <https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.
82
+
83
+ Community Impact Guidelines were inspired by
84
+ [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
85
+
86
+ [homepage]: https://www.contributor-covenant.org
@@ -0,0 +1,90 @@
1
+ # Contributing to roonctl
2
+
3
+ Thanks for helping. This project favours small, typed changes with tests that prove
4
+ behaviour, and it never requires a real Roon Core to run the gate.
5
+
6
+ ## Set up
7
+
8
+ ```console
9
+ git clone https://github.com/vikesh-c/roonctl.git
10
+ cd roonctl
11
+ uv sync --locked --extra dev
12
+ ./scripts/check.sh
13
+ ```
14
+
15
+ `scripts/check.sh` runs, in order:
16
+
17
+ 1. `uv sync --locked --extra dev`
18
+ 2. `ruff check src tests`
19
+ 3. `ruff format --check src tests`
20
+ 4. `mypy` (strict, `src/roonctl` only)
21
+ 5. `scripts/gen-command-docs.py --check`
22
+ 6. `pytest` with branch coverage, minimum 90% (the floor is read from `pyproject.toml`)
23
+
24
+ All six must pass before a pull request, and CI runs the same gate on Python 3.11, 3.12
25
+ and 3.13 from the committed lockfile. `scripts/check-matrix.sh` syncs each interpreter
26
+ once from the lock and runs the gate with `ROONCTL_SKIP_UV_SYNC=1`, so a leg never
27
+ re-syncs the default `.venv`.
28
+
29
+ ## Making a change
30
+
31
+ - Open an issue first for anything larger than a bug fix or a new command.
32
+ - One branch per change; keep pull requests small and focused.
33
+ - Match the existing style: typed public functions, no `Any` at module boundaries,
34
+ dataclasses for values, dependency direction downward (see `ARCHITECTURE.md`).
35
+ - Delete dead code rather than commenting it out.
36
+ - Do not add a dependency without saying, in the pull request, what it replaces or why
37
+ the standard library is insufficient.
38
+
39
+ ## Tests
40
+
41
+ The default suite starts `tests/fake_core.py`, a real WebSocket server on loopback that
42
+ speaks MOO/1, runs the registry handshake, keeps a browse stack and records every
43
+ request. Write tests against it, not against a live Core.
44
+
45
+ - Cover the behaviour, not the implementation. Assert the reply, the recorded request,
46
+ the exit code or the JSON shape.
47
+ - Every new command needs: a success path, a JSON shape test, and a failure path with
48
+ the documented exit code.
49
+ - Every new output needs a schema entry in `schemas.py`; `roonctl schema <name>` is part
50
+ of the contract.
51
+ - Every new state-changing command needs `--dry-run` coverage proving no request was
52
+ sent.
53
+ - Keep the whole suite under roughly 45 seconds on the release machine. The gate runs
54
+ the suite in parallel workers and fails if it takes longer, so shave test setup rather
55
+ than relax this. The serial run (`PYTEST_WORKERS=1`) is the worst case and is the
56
+ number to watch: it currently takes about 29 seconds.
57
+
58
+ Live tests are opt-in and marked `live`; they read `ROONCTL_LIVE_HOST`. They must be
59
+ short, quiet, record the state they change and restore it. Never point them at a Core
60
+ you do not own.
61
+
62
+ ## Commits and pull requests
63
+
64
+ - Plain, imperative commit subjects (`add queue subscription`, `fix volume snapping`).
65
+ - Explain the why in the body when it is not obvious.
66
+ - A pull request says what changed, how it was verified, and what is risky. Include the
67
+ output of `./scripts/check.sh`.
68
+ - Do not commit tokens, config files, personal hosts or library contents.
69
+
70
+ ## Release
71
+
72
+ Releases are cut from `main` with an annotated tag. Pushing the tag runs
73
+ `.github/workflows/release.yml`, which builds the sdist and wheel, runs the gate,
74
+ attaches the artifacts and build provenance to the GitHub release, and publishes to
75
+ PyPI through Trusted Publishing (OIDC) from the protected `pypi` environment. There is
76
+ no API token to store.
77
+
78
+ 1. Update `version` in `pyproject.toml` and `__version__` in `src/roonctl/__init__.py`.
79
+ 2. Update `CHANGELOG.md` and the skill stamp in `src/roonctl/data/SKILL.md`.
80
+ 3. Re-capture the golden output: `.venv/bin/python scripts/capture-golden.py`.
81
+ 4. Run `./scripts/release.sh` to verify the gate and a clean-room build locally.
82
+ 5. Commit, then tag `vX.Y.Z` with `git tag -a` and push the tag.
83
+ 6. Watch the release workflow; it publishes only if the gate and the build pass.
84
+
85
+ Publishing to PyPI and making the repository public are maintainer decisions, not part
86
+ of a normal pull request.
87
+
88
+ ## Code of conduct
89
+
90
+ Participation is covered by [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
roonctl-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 roonctl contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.