stayset 0.1.1__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 (75) hide show
  1. stayset-0.1.1/LICENSE +21 -0
  2. stayset-0.1.1/PKG-INFO +300 -0
  3. stayset-0.1.1/README.md +289 -0
  4. stayset-0.1.1/pyproject.toml +304 -0
  5. stayset-0.1.1/pyproject.toml.orig +219 -0
  6. stayset-0.1.1/src/stayset/__init__.py +11 -0
  7. stayset-0.1.1/src/stayset/__main__.py +121 -0
  8. stayset-0.1.1/src/stayset/actions.py +97 -0
  9. stayset-0.1.1/src/stayset/backends/__init__.py +1 -0
  10. stayset-0.1.1/src/stayset/backends/desktop.py +123 -0
  11. stayset-0.1.1/src/stayset/backends/files.py +167 -0
  12. stayset-0.1.1/src/stayset/backends/filesystem.py +268 -0
  13. stayset-0.1.1/src/stayset/backends/packages.py +418 -0
  14. stayset-0.1.1/src/stayset/backends/registry.py +401 -0
  15. stayset-0.1.1/src/stayset/backends/signatures.py +127 -0
  16. stayset-0.1.1/src/stayset/backends/system.py +176 -0
  17. stayset-0.1.1/src/stayset/backup.py +245 -0
  18. stayset-0.1.1/src/stayset/catalog.py +167 -0
  19. stayset-0.1.1/src/stayset/cleanup/__init__.py +1 -0
  20. stayset-0.1.1/src/stayset/cleanup/apps.py +337 -0
  21. stayset-0.1.1/src/stayset/cleanup/builtin.py +138 -0
  22. stayset-0.1.1/src/stayset/cleanup/guard.py +109 -0
  23. stayset-0.1.1/src/stayset/cleanup/jobs.py +278 -0
  24. stayset-0.1.1/src/stayset/cleanup/model.py +229 -0
  25. stayset-0.1.1/src/stayset/cleanup/runner.py +262 -0
  26. stayset-0.1.1/src/stayset/cleanup/service.py +215 -0
  27. stayset-0.1.1/src/stayset/cli.py +593 -0
  28. stayset-0.1.1/src/stayset/codecs.py +216 -0
  29. stayset-0.1.1/src/stayset/commands.py +542 -0
  30. stayset-0.1.1/src/stayset/config.py +422 -0
  31. stayset-0.1.1/src/stayset/context.py +129 -0
  32. stayset-0.1.1/src/stayset/contract.py +157 -0
  33. stayset-0.1.1/src/stayset/custom.py +199 -0
  34. stayset-0.1.1/src/stayset/definitions/__init__.py +1 -0
  35. stayset-0.1.1/src/stayset/definitions/ai.py +169 -0
  36. stayset-0.1.1/src/stayset/definitions/appearance.py +105 -0
  37. stayset-0.1.1/src/stayset/definitions/apps.py +206 -0
  38. stayset-0.1.1/src/stayset/definitions/browsers.py +223 -0
  39. stayset-0.1.1/src/stayset/definitions/explorer.py +163 -0
  40. stayset-0.1.1/src/stayset/definitions/privacy.py +112 -0
  41. stayset-0.1.1/src/stayset/definitions/security.py +177 -0
  42. stayset-0.1.1/src/stayset/definitions/system.py +136 -0
  43. stayset-0.1.1/src/stayset/definitions/windows_update.py +247 -0
  44. stayset-0.1.1/src/stayset/elevation.py +367 -0
  45. stayset-0.1.1/src/stayset/engine.py +302 -0
  46. stayset-0.1.1/src/stayset/exceptions.py +49 -0
  47. stayset-0.1.1/src/stayset/gui/__init__.py +1 -0
  48. stayset-0.1.1/src/stayset/gui/app.py +76 -0
  49. stayset-0.1.1/src/stayset/gui/assets/icon.svg +1 -0
  50. stayset-0.1.1/src/stayset/gui/assets/stayset.ico +0 -0
  51. stayset-0.1.1/src/stayset/gui/core.py +154 -0
  52. stayset-0.1.1/src/stayset/gui/pages.py +1446 -0
  53. stayset-0.1.1/src/stayset/gui/tasks.py +72 -0
  54. stayset-0.1.1/src/stayset/gui/theme.py +119 -0
  55. stayset-0.1.1/src/stayset/gui/widgets.py +287 -0
  56. stayset-0.1.1/src/stayset/gui/window.py +184 -0
  57. stayset-0.1.1/src/stayset/invocation.py +451 -0
  58. stayset-0.1.1/src/stayset/journal.py +194 -0
  59. stayset-0.1.1/src/stayset/kinds/__init__.py +1 -0
  60. stayset-0.1.1/src/stayset/kinds/files.py +184 -0
  61. stayset-0.1.1/src/stayset/kinds/packages.py +105 -0
  62. stayset-0.1.1/src/stayset/kinds/registry.py +445 -0
  63. stayset-0.1.1/src/stayset/models.py +328 -0
  64. stayset-0.1.1/src/stayset/presets.py +128 -0
  65. stayset-0.1.1/src/stayset/py.typed +0 -0
  66. stayset-0.1.1/src/stayset/render.py +558 -0
  67. stayset-0.1.1/src/stayset/scheduler.py +148 -0
  68. stayset-0.1.1/src/stayset/service.py +679 -0
  69. stayset-0.1.1/src/stayset/shell/__init__.py +1 -0
  70. stayset-0.1.1/src/stayset/shell/inventory.py +567 -0
  71. stayset-0.1.1/src/stayset/shell/manager.py +164 -0
  72. stayset-0.1.1/src/stayset/shell/model.py +161 -0
  73. stayset-0.1.1/src/stayset/shell/settings.py +276 -0
  74. stayset-0.1.1/src/stayset/values.py +238 -0
  75. stayset-0.1.1/src/stayset/verify.py +161 -0
stayset-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mike Hill
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.
stayset-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,300 @@
1
+ Metadata-Version: 2.4
2
+ Name: stayset
3
+ Version: 0.1.1
4
+ Summary: Windows settings that stay set: declarative, self-healing, reversible, private.
5
+ Author: Mike Hill
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Dist: pyside6-essentials>=6.9
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+
12
+ <!-- markdownlint-disable-next-line MD041 -->
13
+ <picture>
14
+ <source media="(prefers-color-scheme: dark)" srcset="docs/brand/wordmark-dark.svg">
15
+ <img alt="Stayset" src="docs/brand/wordmark-light.svg" height="72">
16
+ </picture>
17
+
18
+ [![CI](https://github.com/mikejhill/stayset/actions/workflows/ci.yml/badge.svg)](https://github.com/mikejhill/stayset/actions/workflows/ci.yml)
19
+ [![Release](https://img.shields.io/github/v/release/mikejhill/stayset?color=0F766E)](https://github.com/mikejhill/stayset/releases)
20
+ [![CodeQL](https://github.com/mikejhill/stayset/actions/workflows/codeql.yml/badge.svg)](https://github.com/mikejhill/stayset/actions/workflows/codeql.yml)
21
+ [![License: MIT](https://img.shields.io/badge/license-MIT-0F766E)](LICENSE)
22
+ ![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-0F766E)
23
+ ![Windows](https://img.shields.io/badge/platform-Windows%2010%20%7C%2011-0F766E)
24
+
25
+ **Windows settings that stay set.**
26
+
27
+ Stayset is a declarative, self-healing settings manager for Windows. You
28
+ write down how a machine should be in one JSON file. `stayset doctor` checks
29
+ every setting, repairs anything that drifted, journals what it changed, and
30
+ can undo it. The CLI and a native Windows app have identical capabilities.
31
+ Stayset sends nothing over the network.
32
+
33
+ > Formerly `machine-settings`. The `machine-settings` and `mset` commands
34
+ > still work and print a notice; an existing `~/.config/machine-settings`
35
+ > folder keeps being used until you rename it to `~/.config/stayset`. See
36
+ > [the rename decision](docs/decisions/0001-rename-to-stayset.md).
37
+
38
+ Tools like WinAeroTweaker are *imperative*: you click a tweak, it is applied
39
+ once, and the next Windows update can silently revert it. Stayset treats
40
+ settings like infrastructure as code instead. Its principles are in
41
+ [docs/design/philosophy.md](docs/design/philosophy.md).
42
+
43
+ | Idea | What it means here |
44
+ | --- | --- |
45
+ | **Desired state, not tweaks** | The config says what *should* be true. `doctor` converges the machine to it, as often as you like. |
46
+ | **Drift detection** | `doctor --check` shows exactly which settings Windows (or an app) changed back, with no writes. |
47
+ | **Every change is undoable** | Each run is journaled with the exact raw before-state; `undo` restores it losslessly (even values it did not understand). |
48
+ | **One file, many machines** | `extends` a shared baseline (e.g. in OneDrive) and add `machines.<HOSTNAME>` overrides. Edits never touch the shared file. |
49
+ | **Editor-native config** | A JSON Schema is generated beside the config, so VS Code autocompletes ids, documents each setting on hover, and flags typos and bad values. |
50
+ | **Safe sandbox** | `--backend sandbox:FILE` swaps the registry for a JSON file, so you can try everything (or test it) on any OS. |
51
+ | **One contract** | Every setting - registry, Group Policy, app JSON file, or command - implements the same five-part contract, so new settings are added in isolation. |
52
+ | **Keeps itself applied** | `schedule install` registers a Task Scheduler job that runs `doctor --quiet` at sign-in or daily. |
53
+
54
+ No `.exe` is built: it is a pure-Python package with no runtime dependencies.
55
+
56
+ ## Install (Windows)
57
+
58
+ ```powershell
59
+ # with uv (https://docs.astral.sh/uv/)
60
+ uv tool install path\to\stayset
61
+ stayset --help
62
+ ```
63
+
64
+ Python 3.12+ is required. Run from an **elevated** terminal for machine-wide
65
+ settings (HKLM, Group Policy); per-user settings work without elevation, and
66
+ `doctor --elevate` relaunches itself through the UAC prompt.
67
+
68
+ ## Quick start
69
+
70
+ ```powershell
71
+ stayset init --recommended # create ~/.config/stayset/config.json
72
+ stayset doctor --check # preview: what would change (exit 3 if anything drifted)
73
+ stayset doctor # apply
74
+ stayset undo # changed your mind? revert that run
75
+ stayset ui # same thing, in the app window
76
+ stayset schedule install # re-apply at every sign-in
77
+ ```
78
+
79
+ Other everyday commands:
80
+
81
+ ```powershell
82
+ stayset list edge # browse (search words, --category, --managed, --json)
83
+ stayset show explorer.classic_context_menu
84
+ stayset set taskbar.alignment left --apply
85
+ stayset set edge.sidebar null # require the policy to be *absent*
86
+ stayset set appearance.theme dark --machine # only on this PC
87
+ stayset unset taskbar.alignment # stop managing (machine left as-is)
88
+ stayset capture "explorer.*" # adopt this PC's current values into the config
89
+ stayset history # every run and what it changed
90
+ stayset config validate # typos, unknown ids, bad values
91
+ ```
92
+
93
+ Exit codes: `0` healthy, `1` error, `2` usage error, `3` problems remain
94
+ (drift, needs admin, failures). Data goes to stdout, diagnostics to stderr.
95
+
96
+ ## The config file
97
+
98
+ `~/.config/stayset/config.json` (override with `--config`,
99
+ `STAYSET_HOME`, or `XDG_CONFIG_HOME`):
100
+
101
+ ```json
102
+ {
103
+ "$schema": "./config.schema.json",
104
+ "version": 1,
105
+ "extends": ["C:/Users/me/OneDrive/settings/baseline.json"],
106
+ "settings": {
107
+ "explorer.show_file_extensions": true,
108
+ "taskbar.alignment": "left",
109
+ "edge.startup_boost": false,
110
+ "windows_update.active_hours": "8-23",
111
+ "privacy.copilot_disabled": null
112
+ },
113
+ "machines": {
114
+ "GAMING-PC": { "settings": { "input.mouse_acceleration": false } }
115
+ },
116
+ "custom_settings": []
117
+ }
118
+ ```
119
+
120
+ * A value means "make it so"; `null` means "make sure there is **no**
121
+ explicit value" (e.g. remove a policy); leaving an id out means "don't manage".
122
+ * Layers, lowest priority first: each `extends` file, then `settings`, then
123
+ `machines.<this hostname>`. `stayset config show` prints the result
124
+ and where each value came from.
125
+
126
+ ## The setting contract
127
+
128
+ Every setting is a `Setting` (`src/stayset/contract.py`):
129
+
130
+ | Part | Purpose | Default provided? |
131
+ | --- | --- | --- |
132
+ | `info` | id, title, summary, category, mechanism, admin, restart needed, risk, recommended value, docs links, reversibility and recovery, undocumented flag, side-effect actions | no |
133
+ | `spec` | the value shape (`BoolSpec`, `ChoiceSpec`, `IntSpec`, `StringSpec`) - drives validation, CLI parsing, UI controls and the JSON Schema | no |
134
+ | `read(ctx)` | current state as an `Observation(value, present, raw)` | no |
135
+ | `apply(ctx, value)` | make it so (`None` removes) | no |
136
+ | `validate(value)` | reject bad desired values | yes (from `spec`) |
137
+ | `verify(ctx, value)` | read back and compare | yes |
138
+ | `snapshot` / `restore` | lossless undo | yes |
139
+ | `unsupported_reason(ctx)` | e.g. "needs git" | yes (from `info.requires`) |
140
+
141
+ Settings never touch `winreg` or `subprocess` directly: they use the
142
+ backends in `ctx` (registry, AppX packages, command runner, environment),
143
+ which is what makes the sandbox and the tests possible.
144
+
145
+ Three safety fields make every risk visible in `show`, `list`, the web UI, and
146
+ doctor output:
147
+
148
+ | Field | Meaning |
149
+ | --- | --- |
150
+ | `reversible=False` + `recovery` | Stayset cannot undo the change (for example, removing a Store app); the recovery text says how to get it back. Requires `Risk.HIGH`. |
151
+ | `undocumented=True` | Microsoft does not document the value; Windows may ignore or reset it, which `doctor --check` reports as drift. |
152
+ | `actions` | Side effects run once per doctor run after a repair: stop a process or restart a service. `doctor --check` lists them as "Will ...". The sandbox never runs them. |
153
+
154
+ ### Adding a setting (pick the lightest option)
155
+
156
+ 1. **One line in a built-in module.** Any module in
157
+ `src/stayset/definitions/` exporting `SETTINGS` is discovered
158
+ automatically:
159
+
160
+ ```python
161
+ ADVANCED.boolean(
162
+ "explorer.compact_mode",
163
+ "UseCompactMode",
164
+ "Compact view",
165
+ "Tighter spacing between items in File Explorer.",
166
+ absent=False,
167
+ )
168
+ ```
169
+
170
+ `RegistryGroup` also has `choice`, `integer`, `text`, and `presence`.
171
+ Keys under `...\Policies\...` are automatically treated as Group Policy
172
+ (needs admin).
173
+
174
+ 2. **No Python: declare it in the config** under `custom_settings`
175
+ (registry or JSON-file values):
176
+
177
+ ```json
178
+ {"id": "custom.menu_delay", "title": "Menu show delay", "type": "registry",
179
+ "hive": "HKCU", "key": "Control Panel\\Desktop", "name": "MenuShowDelay",
180
+ "value": {"type": "int", "min": 0, "max": 4000}}
181
+ ```
182
+
183
+ 3. **A plugin file**: drop `~/.config/stayset/plugins/anything.py`
184
+ that defines `SETTINGS`.
185
+
186
+ 4. **A custom class** for anything unusual: subclass `Setting` and implement
187
+ `info`, `spec`, `read`, `apply` (see `definitions/windows_update.py` and
188
+ `definitions/system.py` for multi-value and command-driven examples).
189
+
190
+ The contract test (`tests/unit/test_definitions.py`) automatically holds every
191
+ built-in setting to the rules: valid metadata, every representative value
192
+ applies and verifies, undo restores the exact original state, removal works.
193
+
194
+ ## Presets
195
+
196
+ A preset is a named, curated set of desired values. Adding one only writes
197
+ the values into your config; `doctor --check` previews and `doctor` applies.
198
+
199
+ ```powershell
200
+ stayset preset list
201
+ stayset preset show copilot-plus-ai-off # every value, with admin/undo/support flags
202
+ stayset preset add copilot-plus-ai-off # add to the shared config (or --machine)
203
+ stayset doctor --check # preview, including actions
204
+ stayset doctor --elevate # apply (machine-wide values need admin)
205
+ ```
206
+
207
+ `copilot-plus-ai-off` turns off the Copilot+ PC AI features: the Settings
208
+ agent, Click to Do, Recall (enablement and snapshots), semantic indexing
209
+ (undocumented), Copilot, Bing in Start search, cloud search, and search
210
+ history, and removes the per-user `Microsoft.BingSearch` app (no undo: reinstall
211
+ from the Microsoft Store). It never touches Windows AI component packages or
212
+ the `WSAIFabricSvc` service. The applying procedure for a real machine is in
213
+ [docs/guides/copilot-plus-ai-off.md](docs/guides/copilot-plus-ai-off.md).
214
+
215
+ ## What's in the catalog (92 settings)
216
+
217
+ | Area | Examples |
218
+ | --- | --- |
219
+ | Browsers (23) | Edge: startup boost, sidebar, shopping, recommendations, tracking prevention, Copilot icon, SmartScreen; Chrome: background mode, metrics, sign-in; Firefox: telemetry, Pocket |
220
+ | Explorer / taskbar / Start (13) | file extensions, hidden files, classic context menu, open to This PC, taskbar alignment, end task, web results in search, widgets |
221
+ | Security (12) | UAC level / secure desktop, AutoRun, RDP + NLA, SMBv1, LLMNR, WDigest, LSA protection, Windows Script Host, Defender PUA |
222
+ | Privacy (12) | diagnostic data level, advertising ID, activity history, suggested app installs, Recall, Copilot, DiagTrack service, Bing in Start search, cloud search, search history |
223
+ | AI features (6) | Settings agent, Click to Do, Recall enablement, semantic indexing, Copilot shell integration, Bing Search app (AppX) |
224
+ | Windows Update (7) | no auto-restart, update mode, exclude drivers, feature/quality deferral, active hours, Delivery Optimization |
225
+ | Apps (7) | Windows Terminal (theme, font, copy on select), VS Code (telemetry, format on save, auto save), OneDrive |
226
+ | Developer / system (8) | git (autocrlf, default branch, pull.rebase, long paths), Developer Mode, long paths, hibernation, Fast Startup |
227
+ | Appearance / input (4) | dark mode, transparency, mouse acceleration, Sticky Keys shortcut |
228
+
229
+ ## The App
230
+
231
+ `stayset ui` (or `stayset gui`, or the Start-menu shortcut from
232
+ `stayset ui --install-shortcut`) opens a native window built with Qt
233
+ (PySide6). It follows the Windows light or dark theme and can do everything
234
+ the CLI can: search (`/`), filter by area or "needs attention", set and apply
235
+ values, check and repair, capture, history and undo, presets, the context
236
+ menu manager, clean-up and uninstall, backup and verify, config tools, and
237
+ scheduling. `Ctrl+1` to `Ctrl+7` switch sections; `F5` reloads.
238
+
239
+ The app runs as a standard user. Buttons that may need administrator rights
240
+ carry the Windows shield. The first such action asks for UAC once and starts
241
+ a small elevated helper that accepts only a fixed list of operations, over a
242
+ private named pipe with a per-session key, and exits with the app (see
243
+ [ADR-0008](docs/decisions/0008-native-qt-app.md)). **Restart as
244
+ administrator** in Setup runs the whole app elevated instead.
245
+
246
+ Screenshots: `docs/screenshots/`.
247
+
248
+ ## Group Policy note
249
+
250
+ "GPO" settings are written the way local Group Policy stores them: as
251
+ registry values under `...\Policies\...`, which Windows and the apps read
252
+ directly. They are **not** written into `registry.pol`, so `gpedit.msc` will
253
+ not display them, and a domain GPO will override them (doctor then reports
254
+ `failed: ... another policy may be overriding it`).
255
+
256
+ ## Development
257
+
258
+ Built to the `python-development` standards: uv, ruff with a broad rule set,
259
+ ty with every rule as an error, poe tasks, `src/` layout, class-based design,
260
+ typed CLI settings (one frozen dataclass per subcommand), and pytest with a
261
+ 90% branch-coverage gate. The app uses PySide6 (LGPL, used unmodified as a
262
+ dependency).
263
+
264
+ ```bash
265
+ uv sync # Create .venv and install all dependencies
266
+ uv run stayset # Run the CLI
267
+ uv run poe # List available tasks
268
+ uv run poe fix # Format and auto-fix lint
269
+ uv run poe check # Format check, lint, strict type check, tests with coverage
270
+ uv run poe test-windows # Only the real-Windows suite
271
+ uv run poe screenshots # Regenerate docs/screenshots from the app (Windows)
272
+ uv run poe lint-workflows # actionlint + zizmor over .github/workflows
273
+ uv build && uv run poe verify-dist # Build and check the wheel and sdist
274
+ uv sync --group mutation && uv run poe mutation # mutmut (Linux, macOS, or WSL)
275
+ uv run poe mutation-score --floor 60 # Score the last mutation run
276
+ ```
277
+
278
+ Tests run in random order (`pytest-randomly`); `poe test` also writes
279
+ `coverage.xml` and `reports/junit.xml`.
280
+
281
+ The app tests drive the Qt window offscreen (`QT_QPA_PLATFORM=offscreen`)
282
+ with pytest-qt, so they need no display.
283
+
284
+ | Suite | What it covers |
285
+ | --- | --- |
286
+ | `tests/unit` | every class; the contract test over all 92 settings and every preset; property-based tests (Hypothesis) for JSONC parsing and value parsing |
287
+ | `tests/integration` | sandbox registry file persisting across processes, layered configs, plugins + custom settings, real files with comments, **real git** |
288
+ | `tests/e2e` | the CLI as a subprocess: first run, drift by an outside change, repair, undo, errors, the hidden helper command, the `copilot-plus-ai-off` journey including a Windows Update reset |
289
+ | `tests/ux` | CLI help, exit codes, ASCII fallback, stdout versus stderr, and every operation reachable from both the CLI and the app |
290
+ | `tests/gui` | the Qt app offscreen: the GUI-completeness gate (every CLI path maps to named controls), flows on every page, elevation through the helper, accessible names, keyboard shortcuts, and both themes |
291
+ | `tests/perf` | budgets: 5,000-setting check/fix/undo, catalog load, 1 MB JSONC, CLI cold start, linear scaling |
292
+ | `tests/windows` | real `winreg` round trips, a doctor + undo on the real registry, Task Scheduler query, read-only `Get-AppxPackage` queries (Windows only) |
293
+ | mutation | `mutmut` over `src/stayset` (Qt shell and OS adapters excluded) against the unit suite; see [docs/releasing.md](docs/releasing.md#mutation-testing) |
294
+
295
+ | Workflow | Runs | What it does |
296
+ | --- | --- | --- |
297
+ | `ci.yml` | Pull requests, `main`, merge queue | Conventional PR title; `poe check` on Windows and Linux with Python 3.12 and 3.14 and a JUnit report; build, `twine check`, `verify-dist`, and a smoke test of the wheel; markdownlint, actionlint, and zizmor; 100% coverage of changed lines; one `CI passed` check |
298
+ | `codeql.yml` | Pull requests, `main`, weekly | CodeQL for Python, JavaScript, and workflows |
299
+ | `mutation.yml` | `main`, weekly, on demand | mutmut with a score floor; never gates a pull request |
300
+ | `release.yml` | `main` | Release Please; on release: CI again, build, attest, attach, optional PyPI ([docs/releasing.md](docs/releasing.md)) |
@@ -0,0 +1,289 @@
1
+ <!-- markdownlint-disable-next-line MD041 -->
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="docs/brand/wordmark-dark.svg">
4
+ <img alt="Stayset" src="docs/brand/wordmark-light.svg" height="72">
5
+ </picture>
6
+
7
+ [![CI](https://github.com/mikejhill/stayset/actions/workflows/ci.yml/badge.svg)](https://github.com/mikejhill/stayset/actions/workflows/ci.yml)
8
+ [![Release](https://img.shields.io/github/v/release/mikejhill/stayset?color=0F766E)](https://github.com/mikejhill/stayset/releases)
9
+ [![CodeQL](https://github.com/mikejhill/stayset/actions/workflows/codeql.yml/badge.svg)](https://github.com/mikejhill/stayset/actions/workflows/codeql.yml)
10
+ [![License: MIT](https://img.shields.io/badge/license-MIT-0F766E)](LICENSE)
11
+ ![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-0F766E)
12
+ ![Windows](https://img.shields.io/badge/platform-Windows%2010%20%7C%2011-0F766E)
13
+
14
+ **Windows settings that stay set.**
15
+
16
+ Stayset is a declarative, self-healing settings manager for Windows. You
17
+ write down how a machine should be in one JSON file. `stayset doctor` checks
18
+ every setting, repairs anything that drifted, journals what it changed, and
19
+ can undo it. The CLI and a native Windows app have identical capabilities.
20
+ Stayset sends nothing over the network.
21
+
22
+ > Formerly `machine-settings`. The `machine-settings` and `mset` commands
23
+ > still work and print a notice; an existing `~/.config/machine-settings`
24
+ > folder keeps being used until you rename it to `~/.config/stayset`. See
25
+ > [the rename decision](docs/decisions/0001-rename-to-stayset.md).
26
+
27
+ Tools like WinAeroTweaker are *imperative*: you click a tweak, it is applied
28
+ once, and the next Windows update can silently revert it. Stayset treats
29
+ settings like infrastructure as code instead. Its principles are in
30
+ [docs/design/philosophy.md](docs/design/philosophy.md).
31
+
32
+ | Idea | What it means here |
33
+ | --- | --- |
34
+ | **Desired state, not tweaks** | The config says what *should* be true. `doctor` converges the machine to it, as often as you like. |
35
+ | **Drift detection** | `doctor --check` shows exactly which settings Windows (or an app) changed back, with no writes. |
36
+ | **Every change is undoable** | Each run is journaled with the exact raw before-state; `undo` restores it losslessly (even values it did not understand). |
37
+ | **One file, many machines** | `extends` a shared baseline (e.g. in OneDrive) and add `machines.<HOSTNAME>` overrides. Edits never touch the shared file. |
38
+ | **Editor-native config** | A JSON Schema is generated beside the config, so VS Code autocompletes ids, documents each setting on hover, and flags typos and bad values. |
39
+ | **Safe sandbox** | `--backend sandbox:FILE` swaps the registry for a JSON file, so you can try everything (or test it) on any OS. |
40
+ | **One contract** | Every setting - registry, Group Policy, app JSON file, or command - implements the same five-part contract, so new settings are added in isolation. |
41
+ | **Keeps itself applied** | `schedule install` registers a Task Scheduler job that runs `doctor --quiet` at sign-in or daily. |
42
+
43
+ No `.exe` is built: it is a pure-Python package with no runtime dependencies.
44
+
45
+ ## Install (Windows)
46
+
47
+ ```powershell
48
+ # with uv (https://docs.astral.sh/uv/)
49
+ uv tool install path\to\stayset
50
+ stayset --help
51
+ ```
52
+
53
+ Python 3.12+ is required. Run from an **elevated** terminal for machine-wide
54
+ settings (HKLM, Group Policy); per-user settings work without elevation, and
55
+ `doctor --elevate` relaunches itself through the UAC prompt.
56
+
57
+ ## Quick start
58
+
59
+ ```powershell
60
+ stayset init --recommended # create ~/.config/stayset/config.json
61
+ stayset doctor --check # preview: what would change (exit 3 if anything drifted)
62
+ stayset doctor # apply
63
+ stayset undo # changed your mind? revert that run
64
+ stayset ui # same thing, in the app window
65
+ stayset schedule install # re-apply at every sign-in
66
+ ```
67
+
68
+ Other everyday commands:
69
+
70
+ ```powershell
71
+ stayset list edge # browse (search words, --category, --managed, --json)
72
+ stayset show explorer.classic_context_menu
73
+ stayset set taskbar.alignment left --apply
74
+ stayset set edge.sidebar null # require the policy to be *absent*
75
+ stayset set appearance.theme dark --machine # only on this PC
76
+ stayset unset taskbar.alignment # stop managing (machine left as-is)
77
+ stayset capture "explorer.*" # adopt this PC's current values into the config
78
+ stayset history # every run and what it changed
79
+ stayset config validate # typos, unknown ids, bad values
80
+ ```
81
+
82
+ Exit codes: `0` healthy, `1` error, `2` usage error, `3` problems remain
83
+ (drift, needs admin, failures). Data goes to stdout, diagnostics to stderr.
84
+
85
+ ## The config file
86
+
87
+ `~/.config/stayset/config.json` (override with `--config`,
88
+ `STAYSET_HOME`, or `XDG_CONFIG_HOME`):
89
+
90
+ ```json
91
+ {
92
+ "$schema": "./config.schema.json",
93
+ "version": 1,
94
+ "extends": ["C:/Users/me/OneDrive/settings/baseline.json"],
95
+ "settings": {
96
+ "explorer.show_file_extensions": true,
97
+ "taskbar.alignment": "left",
98
+ "edge.startup_boost": false,
99
+ "windows_update.active_hours": "8-23",
100
+ "privacy.copilot_disabled": null
101
+ },
102
+ "machines": {
103
+ "GAMING-PC": { "settings": { "input.mouse_acceleration": false } }
104
+ },
105
+ "custom_settings": []
106
+ }
107
+ ```
108
+
109
+ * A value means "make it so"; `null` means "make sure there is **no**
110
+ explicit value" (e.g. remove a policy); leaving an id out means "don't manage".
111
+ * Layers, lowest priority first: each `extends` file, then `settings`, then
112
+ `machines.<this hostname>`. `stayset config show` prints the result
113
+ and where each value came from.
114
+
115
+ ## The setting contract
116
+
117
+ Every setting is a `Setting` (`src/stayset/contract.py`):
118
+
119
+ | Part | Purpose | Default provided? |
120
+ | --- | --- | --- |
121
+ | `info` | id, title, summary, category, mechanism, admin, restart needed, risk, recommended value, docs links, reversibility and recovery, undocumented flag, side-effect actions | no |
122
+ | `spec` | the value shape (`BoolSpec`, `ChoiceSpec`, `IntSpec`, `StringSpec`) - drives validation, CLI parsing, UI controls and the JSON Schema | no |
123
+ | `read(ctx)` | current state as an `Observation(value, present, raw)` | no |
124
+ | `apply(ctx, value)` | make it so (`None` removes) | no |
125
+ | `validate(value)` | reject bad desired values | yes (from `spec`) |
126
+ | `verify(ctx, value)` | read back and compare | yes |
127
+ | `snapshot` / `restore` | lossless undo | yes |
128
+ | `unsupported_reason(ctx)` | e.g. "needs git" | yes (from `info.requires`) |
129
+
130
+ Settings never touch `winreg` or `subprocess` directly: they use the
131
+ backends in `ctx` (registry, AppX packages, command runner, environment),
132
+ which is what makes the sandbox and the tests possible.
133
+
134
+ Three safety fields make every risk visible in `show`, `list`, the web UI, and
135
+ doctor output:
136
+
137
+ | Field | Meaning |
138
+ | --- | --- |
139
+ | `reversible=False` + `recovery` | Stayset cannot undo the change (for example, removing a Store app); the recovery text says how to get it back. Requires `Risk.HIGH`. |
140
+ | `undocumented=True` | Microsoft does not document the value; Windows may ignore or reset it, which `doctor --check` reports as drift. |
141
+ | `actions` | Side effects run once per doctor run after a repair: stop a process or restart a service. `doctor --check` lists them as "Will ...". The sandbox never runs them. |
142
+
143
+ ### Adding a setting (pick the lightest option)
144
+
145
+ 1. **One line in a built-in module.** Any module in
146
+ `src/stayset/definitions/` exporting `SETTINGS` is discovered
147
+ automatically:
148
+
149
+ ```python
150
+ ADVANCED.boolean(
151
+ "explorer.compact_mode",
152
+ "UseCompactMode",
153
+ "Compact view",
154
+ "Tighter spacing between items in File Explorer.",
155
+ absent=False,
156
+ )
157
+ ```
158
+
159
+ `RegistryGroup` also has `choice`, `integer`, `text`, and `presence`.
160
+ Keys under `...\Policies\...` are automatically treated as Group Policy
161
+ (needs admin).
162
+
163
+ 2. **No Python: declare it in the config** under `custom_settings`
164
+ (registry or JSON-file values):
165
+
166
+ ```json
167
+ {"id": "custom.menu_delay", "title": "Menu show delay", "type": "registry",
168
+ "hive": "HKCU", "key": "Control Panel\\Desktop", "name": "MenuShowDelay",
169
+ "value": {"type": "int", "min": 0, "max": 4000}}
170
+ ```
171
+
172
+ 3. **A plugin file**: drop `~/.config/stayset/plugins/anything.py`
173
+ that defines `SETTINGS`.
174
+
175
+ 4. **A custom class** for anything unusual: subclass `Setting` and implement
176
+ `info`, `spec`, `read`, `apply` (see `definitions/windows_update.py` and
177
+ `definitions/system.py` for multi-value and command-driven examples).
178
+
179
+ The contract test (`tests/unit/test_definitions.py`) automatically holds every
180
+ built-in setting to the rules: valid metadata, every representative value
181
+ applies and verifies, undo restores the exact original state, removal works.
182
+
183
+ ## Presets
184
+
185
+ A preset is a named, curated set of desired values. Adding one only writes
186
+ the values into your config; `doctor --check` previews and `doctor` applies.
187
+
188
+ ```powershell
189
+ stayset preset list
190
+ stayset preset show copilot-plus-ai-off # every value, with admin/undo/support flags
191
+ stayset preset add copilot-plus-ai-off # add to the shared config (or --machine)
192
+ stayset doctor --check # preview, including actions
193
+ stayset doctor --elevate # apply (machine-wide values need admin)
194
+ ```
195
+
196
+ `copilot-plus-ai-off` turns off the Copilot+ PC AI features: the Settings
197
+ agent, Click to Do, Recall (enablement and snapshots), semantic indexing
198
+ (undocumented), Copilot, Bing in Start search, cloud search, and search
199
+ history, and removes the per-user `Microsoft.BingSearch` app (no undo: reinstall
200
+ from the Microsoft Store). It never touches Windows AI component packages or
201
+ the `WSAIFabricSvc` service. The applying procedure for a real machine is in
202
+ [docs/guides/copilot-plus-ai-off.md](docs/guides/copilot-plus-ai-off.md).
203
+
204
+ ## What's in the catalog (92 settings)
205
+
206
+ | Area | Examples |
207
+ | --- | --- |
208
+ | Browsers (23) | Edge: startup boost, sidebar, shopping, recommendations, tracking prevention, Copilot icon, SmartScreen; Chrome: background mode, metrics, sign-in; Firefox: telemetry, Pocket |
209
+ | Explorer / taskbar / Start (13) | file extensions, hidden files, classic context menu, open to This PC, taskbar alignment, end task, web results in search, widgets |
210
+ | Security (12) | UAC level / secure desktop, AutoRun, RDP + NLA, SMBv1, LLMNR, WDigest, LSA protection, Windows Script Host, Defender PUA |
211
+ | Privacy (12) | diagnostic data level, advertising ID, activity history, suggested app installs, Recall, Copilot, DiagTrack service, Bing in Start search, cloud search, search history |
212
+ | AI features (6) | Settings agent, Click to Do, Recall enablement, semantic indexing, Copilot shell integration, Bing Search app (AppX) |
213
+ | Windows Update (7) | no auto-restart, update mode, exclude drivers, feature/quality deferral, active hours, Delivery Optimization |
214
+ | Apps (7) | Windows Terminal (theme, font, copy on select), VS Code (telemetry, format on save, auto save), OneDrive |
215
+ | Developer / system (8) | git (autocrlf, default branch, pull.rebase, long paths), Developer Mode, long paths, hibernation, Fast Startup |
216
+ | Appearance / input (4) | dark mode, transparency, mouse acceleration, Sticky Keys shortcut |
217
+
218
+ ## The App
219
+
220
+ `stayset ui` (or `stayset gui`, or the Start-menu shortcut from
221
+ `stayset ui --install-shortcut`) opens a native window built with Qt
222
+ (PySide6). It follows the Windows light or dark theme and can do everything
223
+ the CLI can: search (`/`), filter by area or "needs attention", set and apply
224
+ values, check and repair, capture, history and undo, presets, the context
225
+ menu manager, clean-up and uninstall, backup and verify, config tools, and
226
+ scheduling. `Ctrl+1` to `Ctrl+7` switch sections; `F5` reloads.
227
+
228
+ The app runs as a standard user. Buttons that may need administrator rights
229
+ carry the Windows shield. The first such action asks for UAC once and starts
230
+ a small elevated helper that accepts only a fixed list of operations, over a
231
+ private named pipe with a per-session key, and exits with the app (see
232
+ [ADR-0008](docs/decisions/0008-native-qt-app.md)). **Restart as
233
+ administrator** in Setup runs the whole app elevated instead.
234
+
235
+ Screenshots: `docs/screenshots/`.
236
+
237
+ ## Group Policy note
238
+
239
+ "GPO" settings are written the way local Group Policy stores them: as
240
+ registry values under `...\Policies\...`, which Windows and the apps read
241
+ directly. They are **not** written into `registry.pol`, so `gpedit.msc` will
242
+ not display them, and a domain GPO will override them (doctor then reports
243
+ `failed: ... another policy may be overriding it`).
244
+
245
+ ## Development
246
+
247
+ Built to the `python-development` standards: uv, ruff with a broad rule set,
248
+ ty with every rule as an error, poe tasks, `src/` layout, class-based design,
249
+ typed CLI settings (one frozen dataclass per subcommand), and pytest with a
250
+ 90% branch-coverage gate. The app uses PySide6 (LGPL, used unmodified as a
251
+ dependency).
252
+
253
+ ```bash
254
+ uv sync # Create .venv and install all dependencies
255
+ uv run stayset # Run the CLI
256
+ uv run poe # List available tasks
257
+ uv run poe fix # Format and auto-fix lint
258
+ uv run poe check # Format check, lint, strict type check, tests with coverage
259
+ uv run poe test-windows # Only the real-Windows suite
260
+ uv run poe screenshots # Regenerate docs/screenshots from the app (Windows)
261
+ uv run poe lint-workflows # actionlint + zizmor over .github/workflows
262
+ uv build && uv run poe verify-dist # Build and check the wheel and sdist
263
+ uv sync --group mutation && uv run poe mutation # mutmut (Linux, macOS, or WSL)
264
+ uv run poe mutation-score --floor 60 # Score the last mutation run
265
+ ```
266
+
267
+ Tests run in random order (`pytest-randomly`); `poe test` also writes
268
+ `coverage.xml` and `reports/junit.xml`.
269
+
270
+ The app tests drive the Qt window offscreen (`QT_QPA_PLATFORM=offscreen`)
271
+ with pytest-qt, so they need no display.
272
+
273
+ | Suite | What it covers |
274
+ | --- | --- |
275
+ | `tests/unit` | every class; the contract test over all 92 settings and every preset; property-based tests (Hypothesis) for JSONC parsing and value parsing |
276
+ | `tests/integration` | sandbox registry file persisting across processes, layered configs, plugins + custom settings, real files with comments, **real git** |
277
+ | `tests/e2e` | the CLI as a subprocess: first run, drift by an outside change, repair, undo, errors, the hidden helper command, the `copilot-plus-ai-off` journey including a Windows Update reset |
278
+ | `tests/ux` | CLI help, exit codes, ASCII fallback, stdout versus stderr, and every operation reachable from both the CLI and the app |
279
+ | `tests/gui` | the Qt app offscreen: the GUI-completeness gate (every CLI path maps to named controls), flows on every page, elevation through the helper, accessible names, keyboard shortcuts, and both themes |
280
+ | `tests/perf` | budgets: 5,000-setting check/fix/undo, catalog load, 1 MB JSONC, CLI cold start, linear scaling |
281
+ | `tests/windows` | real `winreg` round trips, a doctor + undo on the real registry, Task Scheduler query, read-only `Get-AppxPackage` queries (Windows only) |
282
+ | mutation | `mutmut` over `src/stayset` (Qt shell and OS adapters excluded) against the unit suite; see [docs/releasing.md](docs/releasing.md#mutation-testing) |
283
+
284
+ | Workflow | Runs | What it does |
285
+ | --- | --- | --- |
286
+ | `ci.yml` | Pull requests, `main`, merge queue | Conventional PR title; `poe check` on Windows and Linux with Python 3.12 and 3.14 and a JUnit report; build, `twine check`, `verify-dist`, and a smoke test of the wheel; markdownlint, actionlint, and zizmor; 100% coverage of changed lines; one `CI passed` check |
287
+ | `codeql.yml` | Pull requests, `main`, weekly | CodeQL for Python, JavaScript, and workflows |
288
+ | `mutation.yml` | `main`, weekly, on demand | mutmut with a score floor; never gates a pull request |
289
+ | `release.yml` | `main` | Release Please; on release: CI again, build, attest, attach, optional PyPI ([docs/releasing.md](docs/releasing.md)) |