agent-toggle 0.19.0__tar.gz → 0.20.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.
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/PKG-INFO +36 -4
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/README.md +35 -3
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/__init__.py +1 -1
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/cli.py +12 -3
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/fs.py +6 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/help.py +21 -8
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/locales/zh_tw_cli.py +9 -3
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/profiles.py +131 -7
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/shims/claude.md.tmpl +9 -1
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/shims/generic.md.tmpl +9 -1
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle.egg-info/PKG-INFO +36 -4
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_profiles.py +107 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/LICENSE +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/__main__.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/backends/__init__.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/backends/flag_json.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/backends/mcp_json.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/backends/mcp_toml.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/backends/plugin_cli.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/companions.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/completions.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/config.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/cost.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/doctor.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/harnesses.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/i18n.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/locales/__init__.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/locales/zh_tw_common.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/locales/zh_tw_config.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/locales/zh_tw_picker.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/mechanisms.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ops.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/output.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/settings.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/spinner.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/store.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/toml_check.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ui/__init__.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ui/config_menu.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ui/logo.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ui/menu.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ui/model.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ui/picker.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/ui/theme.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/undo.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/update_check.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle/update_prompt.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle.egg-info/SOURCES.txt +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle.egg-info/dependency_links.txt +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle.egg-info/entry_points.txt +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle.egg-info/requires.txt +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/agent_toggle.egg-info/top_level.txt +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/pyproject.toml +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/setup.cfg +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_alias.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_all_type.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_backends.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_cli.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_cli_surface.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_color.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_companions.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_completions.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_config.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_config_menu.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_conformance.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_containment.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_cost.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_crash.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_doctor.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_encoding.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_fs.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_harnesses.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_help.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_i18n.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_install.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_logo.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_mechanisms.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_menu.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_mod_version.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_mods.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_picker.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_platform.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_project.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_safety.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_same_name.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_secret_audit.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_settings.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_store.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_theme.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_undo.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_update_check.py +0 -0
- {agent_toggle-0.19.0 → agent_toggle-0.20.0}/tests/test_update_prompt.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-toggle
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.20.0
|
|
4
4
|
Summary: Temporarily disable / re-enable AI-agent skills, agents, commands, rules, plugins and MCP servers across harnesses (Claude Code, Codex, Grok, OpenCode, OpenClaw, Copilot, Vibe, Devin, Antigravity)
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/weskao/agent-toggle
|
|
@@ -218,6 +218,7 @@ agent-toggle <command> [args] # or: python3 agent_toggle.py <command> [
|
|
|
218
218
|
| `enable --all` | put back **every** disabled item (`--harness H` narrows it, `--project <dir>` takes only that project's) |
|
|
219
219
|
| `undo` | reverse the last logged batch (`--dry-run` shows the plan) |
|
|
220
220
|
| `profile save\|apply\|diff\|list\|delete\|rename` | named sets of live items; see [Profiles](#profiles) |
|
|
221
|
+
| `profile bind\|unbind\|auto` | load a profile per project, or a global one; see [Project bindings](#project-bindings) |
|
|
221
222
|
| `config` | settings menu (curses, else a numbered list); `config --json` lists every setting and the package version; see [Settings & config menu](#settings--config-menu) |
|
|
222
223
|
| `config test\|sync-ci` | send one Telegram test message / set the GitHub CI secrets; see [CI notifications](#ci-notifications) |
|
|
223
224
|
| `help [command]` | styled help; `help ui` = `--help ui` = `ui --help`; see [Help](#help) |
|
|
@@ -271,7 +272,7 @@ asked, plus `owner`, the harness whose park dir and state entry hold the item;
|
|
|
271
272
|
unshared).
|
|
272
273
|
|
|
273
274
|
`--dry-run` (`disable` / `enable` / `enable --all` / `undo` / `profile apply` /
|
|
274
|
-
`install-shims` / `ui`) computes the plan --
|
|
275
|
+
`profile auto` / `install-shims` / `ui`) computes the plan --
|
|
275
276
|
moves, companions, backups, MCP edits, warnings -- and writes nothing: no state,
|
|
276
277
|
log, lock or backup, and no chmod; it never shells out to `claude`, except one
|
|
277
278
|
read-only `claude plugin list --json` (up to 30 s) when a killed run left a plugin
|
|
@@ -734,8 +735,8 @@ one batch, logged, undoable with `undo`).
|
|
|
734
735
|
`~/.agent-toggle/profiles`. `..` in a path, and names that are not plain file
|
|
735
736
|
names, are refused (exit `2`), as are a bad version, an unknown harness or
|
|
736
737
|
type, an invalid item name, a duplicate item or a file over 1 MiB.
|
|
737
|
-
- `--out` belongs to `save` only; `--dry-run` to `apply` / `diff`. `--harness H`
|
|
738
|
-
narrows `save`, `apply` and `
|
|
738
|
+
- `--out` belongs to `save` only; `--dry-run` to `apply` / `diff` / `auto`. `--harness H`
|
|
739
|
+
narrows `save`, `apply`, `diff` and `auto` to one harness.
|
|
739
740
|
- `diff` and `apply --dry-run` do not read plugin state (that needs the claude
|
|
740
741
|
CLI, and a dry run never shells out), so profile plugin items show as
|
|
741
742
|
`skipped` there.
|
|
@@ -756,6 +757,36 @@ one batch, logged, undoable with `undo`).
|
|
|
756
757
|
keeps the file byte for byte. Neither takes `--dry-run` or `--project`: a
|
|
757
758
|
project profile is renamed or deleted by its name like any other.
|
|
758
759
|
|
|
760
|
+
### Project bindings
|
|
761
|
+
|
|
762
|
+
Bind a stored profile to a project and a session opened there applies it. A project
|
|
763
|
+
with no binding applies the global profile; with nothing bound, nothing happens.
|
|
764
|
+
|
|
765
|
+
```sh
|
|
766
|
+
agent-toggle profile bind work --dir ~/code/app # default: the current dir
|
|
767
|
+
agent-toggle profile bind base --global # every dir with no binding of its own
|
|
768
|
+
agent-toggle profile list # shows what each profile is bound to
|
|
769
|
+
agent-toggle profile auto --dir ~/code/app/src # applies work, as a session start does
|
|
770
|
+
agent-toggle profile unbind --dir ~/code/app # or: profile unbind --global
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
- **Lookup:** the nearest bound dir at or above the cwd wins, so subdirs and worktrees
|
|
774
|
+
inside it inherit the binding; then the global binding; then nothing (exit `0`, no rows).
|
|
775
|
+
- With the [Claude Code mod](docs/MOD.md), each session start runs `profile auto` for its
|
|
776
|
+
cwd, off the start so it never blocks it, and reloads what changed. Other harnesses can
|
|
777
|
+
run `profile auto` from their own hook.
|
|
778
|
+
- A binding names a stored user-scope profile. A `--project` profile or a file path cannot
|
|
779
|
+
be bound.
|
|
780
|
+
- `delete` drops the bindings to that profile and `rename` moves them. A bound profile
|
|
781
|
+
that is no longer saved gives a `skipped` `auto` row, not a failure.
|
|
782
|
+
- Bindings live in `~/.agent-toggle/profile-bindings.json`, outside `profiles/`: that dir
|
|
783
|
+
may be synced between machines, and these keys are this machine's absolute paths.
|
|
784
|
+
|
|
785
|
+
**Limitation: the last session start wins.** A profile changes shared user state (file
|
|
786
|
+
moves under `~/.claude`, plugin flags), not one session's view. With two sessions in
|
|
787
|
+
different projects, the later start switches the state and the other running session is
|
|
788
|
+
not told. Agents and rules need a new session to change either way.
|
|
789
|
+
|
|
759
790
|
## Undo and `enable --all`
|
|
760
791
|
|
|
761
792
|
`undo` reads `~/.agent-toggle/log.jsonl`, takes the batch of the last
|
|
@@ -940,6 +971,7 @@ bookkeeping.
|
|
|
940
971
|
| `parked/user/<owner>/<dir>/` | user-scope items, e.g. `parked/user/claude/skills/<name>` (`<owner>` = the harness whose home holds the dir; a dir shared by several harnesses parks once, under its owner); an absolute OpenCode `skills.paths` dir parks under `parked/user/opencode/ext-<sha8>/` (`<sha8>` of its resolved path). Nothing is ever parked inside a harness home |
|
|
941
972
|
| `parked/<sha8>/` | items parked by `--project` (`<sha8>` = first 8 hex of the SHA-1 of the resolved project dir) |
|
|
942
973
|
| `profiles/` | `<name>.json` profiles (dir `0700`, files `0600`) |
|
|
974
|
+
| `profile-bindings.json` | which profile each project dir loads, plus the global one ([Project bindings](#project-bindings)); machine-local absolute paths, do not sync |
|
|
943
975
|
| `config.json` | [settings](#settings--config-menu) and the Telegram chat id (mode `0600`, atomic write, unknown keys kept) |
|
|
944
976
|
| `update-check.json` | the [update check](#update-check)'s skipped version (mode `0600`, atomic write) |
|
|
945
977
|
|
|
@@ -184,6 +184,7 @@ agent-toggle <command> [args] # or: python3 agent_toggle.py <command> [
|
|
|
184
184
|
| `enable --all` | put back **every** disabled item (`--harness H` narrows it, `--project <dir>` takes only that project's) |
|
|
185
185
|
| `undo` | reverse the last logged batch (`--dry-run` shows the plan) |
|
|
186
186
|
| `profile save\|apply\|diff\|list\|delete\|rename` | named sets of live items; see [Profiles](#profiles) |
|
|
187
|
+
| `profile bind\|unbind\|auto` | load a profile per project, or a global one; see [Project bindings](#project-bindings) |
|
|
187
188
|
| `config` | settings menu (curses, else a numbered list); `config --json` lists every setting and the package version; see [Settings & config menu](#settings--config-menu) |
|
|
188
189
|
| `config test\|sync-ci` | send one Telegram test message / set the GitHub CI secrets; see [CI notifications](#ci-notifications) |
|
|
189
190
|
| `help [command]` | styled help; `help ui` = `--help ui` = `ui --help`; see [Help](#help) |
|
|
@@ -237,7 +238,7 @@ asked, plus `owner`, the harness whose park dir and state entry hold the item;
|
|
|
237
238
|
unshared).
|
|
238
239
|
|
|
239
240
|
`--dry-run` (`disable` / `enable` / `enable --all` / `undo` / `profile apply` /
|
|
240
|
-
`install-shims` / `ui`) computes the plan --
|
|
241
|
+
`profile auto` / `install-shims` / `ui`) computes the plan --
|
|
241
242
|
moves, companions, backups, MCP edits, warnings -- and writes nothing: no state,
|
|
242
243
|
log, lock or backup, and no chmod; it never shells out to `claude`, except one
|
|
243
244
|
read-only `claude plugin list --json` (up to 30 s) when a killed run left a plugin
|
|
@@ -700,8 +701,8 @@ one batch, logged, undoable with `undo`).
|
|
|
700
701
|
`~/.agent-toggle/profiles`. `..` in a path, and names that are not plain file
|
|
701
702
|
names, are refused (exit `2`), as are a bad version, an unknown harness or
|
|
702
703
|
type, an invalid item name, a duplicate item or a file over 1 MiB.
|
|
703
|
-
- `--out` belongs to `save` only; `--dry-run` to `apply` / `diff`. `--harness H`
|
|
704
|
-
narrows `save`, `apply` and `
|
|
704
|
+
- `--out` belongs to `save` only; `--dry-run` to `apply` / `diff` / `auto`. `--harness H`
|
|
705
|
+
narrows `save`, `apply`, `diff` and `auto` to one harness.
|
|
705
706
|
- `diff` and `apply --dry-run` do not read plugin state (that needs the claude
|
|
706
707
|
CLI, and a dry run never shells out), so profile plugin items show as
|
|
707
708
|
`skipped` there.
|
|
@@ -722,6 +723,36 @@ one batch, logged, undoable with `undo`).
|
|
|
722
723
|
keeps the file byte for byte. Neither takes `--dry-run` or `--project`: a
|
|
723
724
|
project profile is renamed or deleted by its name like any other.
|
|
724
725
|
|
|
726
|
+
### Project bindings
|
|
727
|
+
|
|
728
|
+
Bind a stored profile to a project and a session opened there applies it. A project
|
|
729
|
+
with no binding applies the global profile; with nothing bound, nothing happens.
|
|
730
|
+
|
|
731
|
+
```sh
|
|
732
|
+
agent-toggle profile bind work --dir ~/code/app # default: the current dir
|
|
733
|
+
agent-toggle profile bind base --global # every dir with no binding of its own
|
|
734
|
+
agent-toggle profile list # shows what each profile is bound to
|
|
735
|
+
agent-toggle profile auto --dir ~/code/app/src # applies work, as a session start does
|
|
736
|
+
agent-toggle profile unbind --dir ~/code/app # or: profile unbind --global
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
- **Lookup:** the nearest bound dir at or above the cwd wins, so subdirs and worktrees
|
|
740
|
+
inside it inherit the binding; then the global binding; then nothing (exit `0`, no rows).
|
|
741
|
+
- With the [Claude Code mod](docs/MOD.md), each session start runs `profile auto` for its
|
|
742
|
+
cwd, off the start so it never blocks it, and reloads what changed. Other harnesses can
|
|
743
|
+
run `profile auto` from their own hook.
|
|
744
|
+
- A binding names a stored user-scope profile. A `--project` profile or a file path cannot
|
|
745
|
+
be bound.
|
|
746
|
+
- `delete` drops the bindings to that profile and `rename` moves them. A bound profile
|
|
747
|
+
that is no longer saved gives a `skipped` `auto` row, not a failure.
|
|
748
|
+
- Bindings live in `~/.agent-toggle/profile-bindings.json`, outside `profiles/`: that dir
|
|
749
|
+
may be synced between machines, and these keys are this machine's absolute paths.
|
|
750
|
+
|
|
751
|
+
**Limitation: the last session start wins.** A profile changes shared user state (file
|
|
752
|
+
moves under `~/.claude`, plugin flags), not one session's view. With two sessions in
|
|
753
|
+
different projects, the later start switches the state and the other running session is
|
|
754
|
+
not told. Agents and rules need a new session to change either way.
|
|
755
|
+
|
|
725
756
|
## Undo and `enable --all`
|
|
726
757
|
|
|
727
758
|
`undo` reads `~/.agent-toggle/log.jsonl`, takes the batch of the last
|
|
@@ -906,6 +937,7 @@ bookkeeping.
|
|
|
906
937
|
| `parked/user/<owner>/<dir>/` | user-scope items, e.g. `parked/user/claude/skills/<name>` (`<owner>` = the harness whose home holds the dir; a dir shared by several harnesses parks once, under its owner); an absolute OpenCode `skills.paths` dir parks under `parked/user/opencode/ext-<sha8>/` (`<sha8>` of its resolved path). Nothing is ever parked inside a harness home |
|
|
907
938
|
| `parked/<sha8>/` | items parked by `--project` (`<sha8>` = first 8 hex of the SHA-1 of the resolved project dir) |
|
|
908
939
|
| `profiles/` | `<name>.json` profiles (dir `0700`, files `0600`) |
|
|
940
|
+
| `profile-bindings.json` | which profile each project dir loads, plus the global one ([Project bindings](#project-bindings)); machine-local absolute paths, do not sync |
|
|
909
941
|
| `config.json` | [settings](#settings--config-menu) and the Telegram chat id (mode `0600`, atomic write, unknown keys kept) |
|
|
910
942
|
| `update-check.json` | the [update check](#update-check)'s skipped version (mode `0600`, atomic write) |
|
|
911
943
|
|
|
@@ -25,6 +25,8 @@ Usage:
|
|
|
25
25
|
agent_toggle.py doctor [--harness H] # drift + state check (y/n fixes on a TTY); exit 1 on problems
|
|
26
26
|
agent_toggle.py migrate # import old state, move legacy park dirs
|
|
27
27
|
agent_toggle.py profile save|apply|diff|list|delete|rename [name|file] [new] [--out F] [--dry-run]
|
|
28
|
+
agent_toggle.py profile bind <name> [--dir D | --global] | unbind [--dir D | --global]
|
|
29
|
+
agent_toggle.py profile auto [--dir D] [--dry-run] # apply the profile bound to D, else the global one
|
|
28
30
|
agent_toggle.py install-shims [--dry-run] [--gitignore | --no-gitignore]
|
|
29
31
|
# skill shim per harness; stale .gitignore lines
|
|
30
32
|
agent_toggle.py config [--json] # settings menu (curses, else numbered list)
|
|
@@ -685,13 +687,20 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
685
687
|
help="skip the stale park-dir line check")
|
|
686
688
|
sp.set_defaults(prompt=True) # the config menu passes False: no y/n under curses
|
|
687
689
|
pp = sub.add_parser("profile", parents=[common],
|
|
688
|
-
help="save / apply / diff / list / delete / rename named sets of live
|
|
689
|
-
|
|
690
|
+
help="save / apply / diff / list / delete / rename named sets of live "
|
|
691
|
+
"items; bind one to a project")
|
|
692
|
+
pp.add_argument("action",
|
|
693
|
+
help="save | apply | diff | list | delete | rename | bind | unbind | auto")
|
|
690
694
|
pp.add_argument("target", nargs="?", metavar="name|file")
|
|
691
695
|
pp.add_argument("new_name", nargs="?", metavar="new", help="rename: the new name")
|
|
692
696
|
pp.add_argument("--out", metavar="file", help="save: write the profile here instead")
|
|
693
|
-
pp.add_argument("--dry-run", action="store_true",
|
|
697
|
+
pp.add_argument("--dry-run", action="store_true",
|
|
698
|
+
help="apply / auto: show the plan; change nothing")
|
|
694
699
|
pp.add_argument("--project", metavar="dir", help=PROJECT_HELP)
|
|
700
|
+
pp.add_argument("--dir", metavar="dir",
|
|
701
|
+
help="bind / unbind / auto: the project dir (default: the current one)")
|
|
702
|
+
pp.add_argument("--global", dest="everywhere", action="store_true",
|
|
703
|
+
help="bind / unbind: the profile for every dir with no binding of its own")
|
|
695
704
|
sub.add_parser("doctor", parents=[common],
|
|
696
705
|
help="check harness layouts and state against disk; offers y/n fixes")
|
|
697
706
|
sub.add_parser("update", parents=[common],
|
|
@@ -72,6 +72,12 @@ def profiles_dir() -> Path:
|
|
|
72
72
|
return state_dir() / "profiles"
|
|
73
73
|
|
|
74
74
|
|
|
75
|
+
def bindings_file() -> Path:
|
|
76
|
+
"""Which profile each project dir loads. Outside profiles/: that dir may be synced
|
|
77
|
+
between machines, and these keys are this machine's absolute paths."""
|
|
78
|
+
return state_dir() / "profile-bindings.json"
|
|
79
|
+
|
|
80
|
+
|
|
75
81
|
def parked_dir() -> Path:
|
|
76
82
|
return state_dir() / "parked"
|
|
77
83
|
|
|
@@ -79,20 +79,33 @@ def commands(default_harness: str = "claude") -> dict[str, Cmd]:
|
|
|
79
79
|
options=[_dry_run()],
|
|
80
80
|
examples=["undo --dry-run", "undo"]),
|
|
81
81
|
"profile": Cmd(
|
|
82
|
-
"profile save|apply|diff|list|delete|rename [name|file] [new]
|
|
83
|
-
"[--project dir]",
|
|
84
|
-
t("help.profile.summary", "save / apply / diff / list / delete / rename named sets
|
|
82
|
+
"profile save|apply|diff|list|delete|rename|bind|unbind|auto [name|file] [new] "
|
|
83
|
+
"[--out file] [--dry-run] [--project dir] [--dir dir] [--global]",
|
|
84
|
+
t("help.profile.summary", "save / apply / diff / list / delete / rename named sets "
|
|
85
|
+
"of live items; bind one to a project"),
|
|
85
86
|
t("help.profile.desc", "A profile records which items are live, so a whole "
|
|
86
|
-
"setup can be switched in one step."
|
|
87
|
-
|
|
87
|
+
"setup can be switched in one step. `bind` ties a saved "
|
|
88
|
+
"profile to a project dir (or, with --global, to every dir "
|
|
89
|
+
"that has none); `auto` applies the one bound to a dir, as "
|
|
90
|
+
"the Claude Code plugin does when a session starts there."),
|
|
91
|
+
args=[("save|apply|diff|list|delete|rename|bind|unbind|auto",
|
|
92
|
+
t("help.arg.profile_action", "what to do")),
|
|
88
93
|
("name|file", t("help.arg.profile_target", "a profile name or a JSON file")),
|
|
89
94
|
("new", t("help.arg.profile_new", "rename: the new name"))],
|
|
90
95
|
options=[("--out file", t("help.opt.out", "save: write the profile here instead")),
|
|
91
96
|
("--dry-run", t("help.opt.profile_dry_run",
|
|
92
|
-
"apply: show the plan; change nothing")),
|
|
93
|
-
_project()
|
|
97
|
+
"apply / auto: show the plan; change nothing")),
|
|
98
|
+
_project(),
|
|
99
|
+
("--dir dir", t("help.opt.profile_dir",
|
|
100
|
+
"bind / unbind / auto: the project dir (default: the "
|
|
101
|
+
"current one)")),
|
|
102
|
+
("--global", t("help.opt.profile_global",
|
|
103
|
+
"bind / unbind: the profile for every dir with no "
|
|
104
|
+
"binding of its own"))],
|
|
94
105
|
examples=["profile save work", "profile diff work", "profile apply work --dry-run",
|
|
95
|
-
"profile list", "profile rename work flutter", "profile delete flutter"
|
|
106
|
+
"profile list", "profile rename work flutter", "profile delete flutter",
|
|
107
|
+
"profile bind flutter --dir ~/code/app", "profile bind work --global",
|
|
108
|
+
"profile auto --dry-run", "profile unbind --dir ~/code/app"]),
|
|
96
109
|
"status": Cmd(
|
|
97
110
|
"status",
|
|
98
111
|
t("help.status.summary", "health check"),
|
|
@@ -18,8 +18,12 @@ CATALOG: dict[str, str] = {
|
|
|
18
18
|
"--all 還原全部(可搭配一個 --harness)。",
|
|
19
19
|
"help.undo.summary": "復原最近一次記錄的批次",
|
|
20
20
|
"help.undo.desc": "依記錄復原最近一次 disable/enable 批次。",
|
|
21
|
-
"help.profile.summary": "儲存 / 套用 / 比較 / 列出 / 刪除 /
|
|
22
|
-
|
|
21
|
+
"help.profile.summary": "儲存 / 套用 / 比較 / 列出 / 刪除 / 改名具名的啟用項目組合;"
|
|
22
|
+
"可綁定到專案",
|
|
23
|
+
"help.profile.desc": "設定檔記錄哪些項目是啟用的,讓整組設定一步切換。`bind` 把已儲存的"
|
|
24
|
+
"設定檔綁定到專案目錄(加 --global 則用於所有沒有綁定的目錄);"
|
|
25
|
+
"`auto` 套用某目錄所綁定的設定檔,Claude Code 外掛在該目錄開啟 "
|
|
26
|
+
"session 時就是這麼做。",
|
|
23
27
|
"help.status.summary": "健康檢查",
|
|
24
28
|
"help.status.desc": "顯示狀態檔、每個已安裝的 harness 與其暫存項目,以及值得修正的偏差。",
|
|
25
29
|
"help.list.summary": "目前停用了哪些項目",
|
|
@@ -58,7 +62,9 @@ CATALOG: dict[str, str] = {
|
|
|
58
62
|
"help.arg.profile_target": "設定檔名稱或 JSON 檔",
|
|
59
63
|
"help.arg.profile_new": "rename:新名稱",
|
|
60
64
|
"help.opt.out": "save:改寫到這個檔案",
|
|
61
|
-
"help.opt.profile_dry_run": "apply:只顯示計畫,不做任何變更",
|
|
65
|
+
"help.opt.profile_dry_run": "apply / auto:只顯示計畫,不做任何變更",
|
|
66
|
+
"help.opt.profile_dir": "bind / unbind / auto:專案目錄(預設為目前目錄)",
|
|
67
|
+
"help.opt.profile_global": "bind / unbind:所有沒有自己綁定的目錄都用這個設定檔",
|
|
62
68
|
"help.opt.type": "只看這種類型:%s",
|
|
63
69
|
"help.opt.list_project": "只看這個專案的項目",
|
|
64
70
|
"help.opt.cost_project": "計算此專案的 .claude 與 .mcp.json,而非使用者範圍",
|
|
@@ -4,6 +4,9 @@ A profile holds ONLY {harness, type, name, live} per item -- never a path or a
|
|
|
4
4
|
secret -- so it can sit in a dotfiles repo. `apply` toggles just the items the
|
|
5
5
|
profile mentions: an item installed after the save is never touched, and an item
|
|
6
6
|
the profile names that this machine lacks is skipped, not failed.
|
|
7
|
+
|
|
8
|
+
Bindings (`bind` / `unbind` / `auto`) say which stored profile a project dir loads,
|
|
9
|
+
with one global fallback; `auto` applies the one that matches a dir.
|
|
7
10
|
"""
|
|
8
11
|
from __future__ import annotations
|
|
9
12
|
|
|
@@ -22,7 +25,8 @@ MAX_BYTES = 1 << 20 # a real profile is a few KB
|
|
|
22
25
|
ITEM_KEYS = {"harness", "type", "name", "live"}
|
|
23
26
|
WIN_RESERVED = {"CON", "PRN", "AUX", "NUL", *(f"COM{i}" for i in range(1, 10)),
|
|
24
27
|
*(f"LPT{i}" for i in range(1, 10))} # not valid file names on Windows
|
|
25
|
-
ACTIONS = ("save", "apply", "diff", "list", "delete", "rename")
|
|
28
|
+
ACTIONS = ("save", "apply", "diff", "list", "delete", "rename", "bind", "unbind", "auto")
|
|
29
|
+
NO_TARGET = ("list", "unbind", "auto")
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
def _is_path(arg: str) -> bool:
|
|
@@ -192,14 +196,20 @@ def cmd_list(out: Result) -> None:
|
|
|
192
196
|
files = stored()
|
|
193
197
|
if not files:
|
|
194
198
|
out.say("no profiles saved")
|
|
199
|
+
binds = bindings()
|
|
195
200
|
for p in files:
|
|
196
201
|
try:
|
|
197
202
|
doc = json.loads(p.read_text(encoding="utf-8"))
|
|
198
203
|
detail = f"{len(doc['items'])} items, saved {str(doc.get('saved_at', '?'))[:10]}"
|
|
199
204
|
except (OSError, ValueError, KeyError, TypeError):
|
|
200
205
|
detail = "unreadable"
|
|
206
|
+
dirs = sorted(d for d, n in binds["projects"].items() if n == p.stem)
|
|
207
|
+
bound = {**({"global": True} if binds["global"] == p.stem else {}),
|
|
208
|
+
**({"bound": dirs} if dirs else {})}
|
|
209
|
+
if bound: # an unbound profile's row and line stay as before
|
|
210
|
+
detail += " <- " + ", ".join([*(["global"] if "global" in bound else []), *dirs])
|
|
201
211
|
out.say(f" {p.stem:<24} {detail}")
|
|
202
|
-
out.row(None, None, p.stem, "list", "ok", detail, show=False, path=str(p))
|
|
212
|
+
out.row(None, None, p.stem, "list", "ok", detail, show=False, path=str(p), **bound)
|
|
203
213
|
|
|
204
214
|
|
|
205
215
|
def _existing(name: str) -> Path:
|
|
@@ -218,6 +228,7 @@ def cmd_delete(name: str, out: Result) -> None:
|
|
|
218
228
|
p.unlink()
|
|
219
229
|
except OSError as e:
|
|
220
230
|
die(f"cannot delete profile {name!r}: {e.strerror or e}", 1)
|
|
231
|
+
_rebind(name, None)
|
|
221
232
|
out.say(f"deleted {name} ({p})")
|
|
222
233
|
out.row(None, None, name, "delete", "ok", str(p), show=False, path=str(p))
|
|
223
234
|
|
|
@@ -233,26 +244,139 @@ def cmd_rename(old: str, new: str, out: Result) -> None:
|
|
|
233
244
|
os.rename(src, dst) # shortcut: a profile saved as `new` between the check and here is overwritten on POSIX
|
|
234
245
|
except OSError as e:
|
|
235
246
|
die(f"cannot rename profile {old!r}: {e.strerror or e}", 1)
|
|
247
|
+
_rebind(old, new)
|
|
236
248
|
out.say(f"renamed {old} -> {new} ({dst})")
|
|
237
249
|
out.row(None, None, new, "rename", "ok", f"from {old}", show=False, path=str(dst), old=old)
|
|
238
250
|
|
|
239
251
|
|
|
252
|
+
# ---------------------------------------------------------------- bindings
|
|
253
|
+
|
|
254
|
+
def bindings() -> dict:
|
|
255
|
+
"""{"global": name | None, "projects": {resolved dir: name}}; a missing, corrupt or
|
|
256
|
+
hand-edited file reads as no bindings, entry by entry."""
|
|
257
|
+
try:
|
|
258
|
+
doc = json.loads(fs.bindings_file().read_text(encoding="utf-8"))
|
|
259
|
+
except (OSError, ValueError, RecursionError):
|
|
260
|
+
doc = {}
|
|
261
|
+
doc = doc if isinstance(doc, dict) else {}
|
|
262
|
+
projects = doc.get("projects")
|
|
263
|
+
return {"global": doc["global"] if isinstance(doc.get("global"), str) else None,
|
|
264
|
+
"projects": {d: n for d, n in (projects if isinstance(projects, dict) else {}).items()
|
|
265
|
+
if isinstance(n, str)}}
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def _write_bindings(binds: dict) -> None:
|
|
269
|
+
fs.private_dir(fs.state_dir())
|
|
270
|
+
fs.atomic_write(fs.bindings_file(),
|
|
271
|
+
json.dumps({"version": VERSION, **binds}, indent=2, ensure_ascii=False) + "\n")
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def _rebind(old: str, new: str | None) -> None:
|
|
275
|
+
"""Follow a rename (`new`) or drop a deleted profile's bindings (None)."""
|
|
276
|
+
binds = bindings()
|
|
277
|
+
kept = {"global": new if binds["global"] == old else binds["global"],
|
|
278
|
+
"projects": {d: new if n == old else n for d, n in binds["projects"].items()
|
|
279
|
+
if n != old or new}}
|
|
280
|
+
if kept != binds:
|
|
281
|
+
_write_bindings(kept)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def _dir(arg: str | None) -> Path:
|
|
285
|
+
"""The resolved dir a binding is keyed by (default: the cwd); exit 2 unless it exists."""
|
|
286
|
+
p = Path(arg).expanduser() if arg else Path.cwd()
|
|
287
|
+
if not p.is_dir():
|
|
288
|
+
die(f"not a directory: {arg}", 2)
|
|
289
|
+
return p.resolve()
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def bound_profile(where: Path) -> tuple[str | None, str]:
|
|
293
|
+
"""(profile name, what bound it) for `where`: the nearest bound dir at or above it,
|
|
294
|
+
else the global binding, else (None, "")."""
|
|
295
|
+
binds = bindings()
|
|
296
|
+
by_dir = {os.path.normcase(d): (n, d) for d, n in binds["projects"].items()} # Windows: any case
|
|
297
|
+
for d in (where, *where.parents):
|
|
298
|
+
if os.path.normcase(str(d)) in by_dir:
|
|
299
|
+
return by_dir[os.path.normcase(str(d))]
|
|
300
|
+
return binds["global"], "global" if binds["global"] else ""
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def cmd_bind(name: str, where: str | None, everywhere: bool, out: Result) -> None:
|
|
304
|
+
_existing(name)
|
|
305
|
+
load_scoped(name) # exit 2 for a project-scope or broken profile
|
|
306
|
+
binds = bindings()
|
|
307
|
+
key = "global" if everywhere else str(_dir(where))
|
|
308
|
+
if everywhere:
|
|
309
|
+
binds["global"] = name
|
|
310
|
+
else:
|
|
311
|
+
binds["projects"][key] = name
|
|
312
|
+
_write_bindings(binds)
|
|
313
|
+
out.say(f"bound {name} -> {key}")
|
|
314
|
+
out.row(None, None, name, "bind", "ok", key, show=False)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def cmd_unbind(where: str | None, everywhere: bool, out: Result) -> None:
|
|
318
|
+
binds = bindings()
|
|
319
|
+
if everywhere:
|
|
320
|
+
key, name, binds["global"] = "global", binds["global"], None
|
|
321
|
+
else:
|
|
322
|
+
here = str(_dir(where))
|
|
323
|
+
key = next((d for d in binds["projects"]
|
|
324
|
+
if os.path.normcase(d) == os.path.normcase(here)), here)
|
|
325
|
+
name = binds["projects"].pop(key, None)
|
|
326
|
+
if name is None:
|
|
327
|
+
die(f"no profile is bound to {key} (see: profile list)", 2)
|
|
328
|
+
_write_bindings(binds)
|
|
329
|
+
out.say(f"unbound {name} from {key}")
|
|
330
|
+
out.row(None, None, name, "unbind", "ok", key, show=False)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def cmd_auto(where: str | None, only: str | None, dry_run: bool, out: Result) -> None:
|
|
334
|
+
"""Apply the profile bound to `where` (else the global one). Nothing bound changes
|
|
335
|
+
nothing and exits 0: a session-start hook runs this in every project."""
|
|
336
|
+
name, source = bound_profile(_dir(where))
|
|
337
|
+
if name is None:
|
|
338
|
+
out.say("no profile is bound here and no global profile is set")
|
|
339
|
+
return
|
|
340
|
+
if not (_valid_name(name) and _stored_path(name).is_file()):
|
|
341
|
+
why = f"profile {name!r} (bound to {source}) is not saved; see: profile list"
|
|
342
|
+
out.say(why, warn=True)
|
|
343
|
+
out.row(None, None, name, "auto", "skipped", why, show=False, source=source)
|
|
344
|
+
return
|
|
345
|
+
out.say(f"profile {name} (bound to {source})")
|
|
346
|
+
out.row(None, None, name, "auto", "ok", source, show=False, source=source)
|
|
347
|
+
cmd_apply(name, only, dry_run, out)
|
|
348
|
+
|
|
349
|
+
|
|
240
350
|
def cmd_profile(args, out: Result) -> None:
|
|
241
351
|
action, target = args.action, args.target
|
|
242
352
|
if action not in ACTIONS:
|
|
243
353
|
die(f"unknown profile action {action!r} (expected: {', '.join(ACTIONS)})", 2)
|
|
244
|
-
if (action
|
|
245
|
-
die("profile
|
|
354
|
+
if (action in NO_TARGET) == (target is not None):
|
|
355
|
+
die(f"profile {action} takes no argument" if action in NO_TARGET
|
|
246
356
|
else f"profile {action} needs a <name|file>", 2)
|
|
247
357
|
if (action == "rename") != (args.new_name is not None):
|
|
248
358
|
die("profile rename needs <old> <new>" if action == "rename"
|
|
249
359
|
else f"profile {action} takes one <name|file>", 2)
|
|
250
360
|
if args.out and action != "save":
|
|
251
361
|
die("--out only applies to `profile save`", 2)
|
|
252
|
-
if args.dry_run and action not in ("apply", "diff"):
|
|
253
|
-
die("--dry-run only applies to `profile apply` / `diff`", 2)
|
|
254
|
-
if args.project is not None and action in ("
|
|
362
|
+
if args.dry_run and action not in ("apply", "diff", "auto"):
|
|
363
|
+
die("--dry-run only applies to `profile apply` / `diff` / `auto`", 2)
|
|
364
|
+
if args.project is not None and action not in ("save", "apply", "diff"):
|
|
255
365
|
die(f"--project does not apply to `profile {action}`", 2)
|
|
366
|
+
binding = action in ("bind", "unbind", "auto")
|
|
367
|
+
if (args.dir is not None or args.everywhere) and not binding:
|
|
368
|
+
die("--dir and --global only apply to `profile bind` / `unbind` / `auto`", 2)
|
|
369
|
+
if args.everywhere and (args.dir is not None or action == "auto"):
|
|
370
|
+
die("--global does not go with --dir" if args.dir is not None
|
|
371
|
+
else "--global does not apply to `profile auto`", 2)
|
|
372
|
+
if binding:
|
|
373
|
+
if action == "bind":
|
|
374
|
+
cmd_bind(target, args.dir, args.everywhere, out)
|
|
375
|
+
elif action == "unbind":
|
|
376
|
+
cmd_unbind(args.dir, args.everywhere, out)
|
|
377
|
+
else:
|
|
378
|
+
cmd_auto(args.dir, args.harness, args.dry_run, out)
|
|
379
|
+
return
|
|
256
380
|
project = project_dir(args.project, args.harness)
|
|
257
381
|
if action == "save":
|
|
258
382
|
cmd_save(target, args.out, args.harness, out, project)
|
|
@@ -20,7 +20,7 @@ If `agent-toggle` is not on PATH, ask the user to install it (`uv tool install a
|
|
|
20
20
|
Commands: `status` (run first), `doctor` (read-only health check), `update` (installs the newest release, then refreshes the plugin and shims; run it only when the user asks to update), `list [type]`,
|
|
21
21
|
`cost [--type T]` (startup token estimates, biggest first), `disable <type> <name>...` (type `all`: every type with that name),
|
|
22
22
|
`enable <type> <name>...`, `enable --all`, `undo` (reverse the last batch),
|
|
23
|
-
`profile save|apply|diff|delete <name>`, `profile rename <old> <new>`, `profile list` (see Profiles), `migrate`; add `--harness claude|codex|grok|opencode|openclaw|copilot|vibe|devin|agy`
|
|
23
|
+
`profile save|apply|diff|delete <name>`, `profile rename <old> <new>`, `profile list`, `profile bind|unbind|auto` (see Profiles), `migrate`; add `--harness claude|codex|grok|opencode|openclaw|copilot|vibe|devin|agy`
|
|
24
24
|
(default `claude`) and `--dry-run` to preview. `--project <dir>` targets a repo's own `.claude/` and `.mcp.json`
|
|
25
25
|
(warn the user: git shows the deletion). `<type>` = `skill` / `agent` /
|
|
26
26
|
`command` / `rule` / `plugin` / `mcp`. A colon addresses nesting: `orch:batch`.
|
|
@@ -53,6 +53,9 @@ A profile is a saved snapshot of which items are live, one file per name in
|
|
|
53
53
|
| update ("update work with what I have now") | `profile save <name>`: overwrites it with the live state |
|
|
54
54
|
| rename | `profile rename <old> <new>` (refuses a name that exists) |
|
|
55
55
|
| delete | `profile delete <name>` (removes the file; `undo` does not restore it) |
|
|
56
|
+
| load one per project ("use work in this repo") | `profile bind <name> --dir <project>`; every dir with no binding of its own: `profile bind <name> --global`. A session start there applies it; with two sessions in different projects the last start wins |
|
|
57
|
+
| stop that | `profile unbind --dir <project>` or `profile unbind --global` |
|
|
58
|
+
| apply the bound one now | `profile auto --dir <project>` |
|
|
56
59
|
|
|
57
60
|
Ask with `AskUserQuestion` instead of guessing, and run `profile list --json` first:
|
|
58
61
|
|
|
@@ -109,4 +112,9 @@ paste the JSON. Branch on the exit code:
|
|
|
109
112
|
| 3 | locked | another run is active; retry later |
|
|
110
113
|
| 4 | unsupported pair / harness missing | tell the user; do not retry |
|
|
111
114
|
|
|
115
|
+
A `disable` row failing because the item is already off (`... is already false in <file>`,
|
|
116
|
+
or the harness CLI says it is already disabled) while `list` shows no record of it: it was
|
|
117
|
+
turned off outside agent-toggle, so `enable` has nothing to restore from. To bring it under
|
|
118
|
+
agent-toggle (with the user's go-ahead): `enable` it by hand first, then `disable` it here.
|
|
119
|
+
|
|
112
120
|
Rollback is `undo` or `enable <type> <name>`. State lives in `~/.agent-toggle/`.
|
|
@@ -23,7 +23,7 @@ Commands: `status` (run first; shows which types this harness supports),
|
|
|
23
23
|
`doctor` (read-only health check), `update` (installs the newest release, then refreshes the plugin and shims; run it only when the user asks to update), `list [type]`, `cost [--type T]` (startup
|
|
24
24
|
token estimates, biggest first), `disable <type> <name>...` (type `all`: every type with that name), `enable <type> <name>...`,
|
|
25
25
|
`enable --all`, `undo` (reverse the last batch), `profile save|apply|diff|delete <name>`,
|
|
26
|
-
`profile rename <old> <new>`, `profile list` (see Profiles); add `--dry-run` to preview. `<type>` = `skill` / `agent` /
|
|
26
|
+
`profile rename <old> <new>`, `profile list`, `profile bind|unbind|auto` (see Profiles); add `--dry-run` to preview. `<type>` = `skill` / `agent` /
|
|
27
27
|
`command` / `rule` / `plugin` / `mcp`. A colon addresses nesting: `orch:batch`.
|
|
28
28
|
A row with `shared_with` means another harness reads the same directory: the
|
|
29
29
|
change affects them too, so say so. `ui` is an interactive picker for the user, not for you.
|
|
@@ -41,6 +41,9 @@ A profile is a saved snapshot of which items are live, one file per name in
|
|
|
41
41
|
| update ("update work with what I have now") | `profile save <name>`: overwrites it with the live state |
|
|
42
42
|
| rename | `profile rename <old> <new>` (refuses a name that exists) |
|
|
43
43
|
| delete | `profile delete <name>` (removes the file; `undo` does not restore it) |
|
|
44
|
+
| load one per project ("use work in this repo") | `profile bind <name> --dir <project>`; every dir with no binding of its own: `profile bind <name> --global`. Only the Claude Code mod applies it at session start; elsewhere run `profile auto` |
|
|
45
|
+
| stop that | `profile unbind --dir <project>` or `profile unbind --global` |
|
|
46
|
+
| apply the bound one now | `profile auto --dir <project>` |
|
|
44
47
|
|
|
45
48
|
Ask instead of guessing: use your harness's question tool (multiple choice) if it
|
|
46
49
|
has one, else a short numbered list the user answers by number. Run `profile list --json` first.
|
|
@@ -97,4 +100,9 @@ paste the JSON. Branch on the exit code:
|
|
|
97
100
|
| 3 | locked | another run is active; retry later |
|
|
98
101
|
| 4 | unsupported pair / harness missing | tell the user; do not retry |
|
|
99
102
|
|
|
103
|
+
A `disable` row failing because the item is already off (`... is already false in <file>`,
|
|
104
|
+
or the harness CLI says it is already disabled) while `list` shows no record of it: it was
|
|
105
|
+
turned off outside agent-toggle, so `enable` has nothing to restore from. To bring it under
|
|
106
|
+
agent-toggle (with the user's go-ahead): `enable` it by hand first, then `disable` it here.
|
|
107
|
+
|
|
100
108
|
Rollback is `undo` or `enable <type> <name> --harness __HARNESS__`. State lives in `~/.agent-toggle/`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-toggle
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.20.0
|
|
4
4
|
Summary: Temporarily disable / re-enable AI-agent skills, agents, commands, rules, plugins and MCP servers across harnesses (Claude Code, Codex, Grok, OpenCode, OpenClaw, Copilot, Vibe, Devin, Antigravity)
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/weskao/agent-toggle
|
|
@@ -218,6 +218,7 @@ agent-toggle <command> [args] # or: python3 agent_toggle.py <command> [
|
|
|
218
218
|
| `enable --all` | put back **every** disabled item (`--harness H` narrows it, `--project <dir>` takes only that project's) |
|
|
219
219
|
| `undo` | reverse the last logged batch (`--dry-run` shows the plan) |
|
|
220
220
|
| `profile save\|apply\|diff\|list\|delete\|rename` | named sets of live items; see [Profiles](#profiles) |
|
|
221
|
+
| `profile bind\|unbind\|auto` | load a profile per project, or a global one; see [Project bindings](#project-bindings) |
|
|
221
222
|
| `config` | settings menu (curses, else a numbered list); `config --json` lists every setting and the package version; see [Settings & config menu](#settings--config-menu) |
|
|
222
223
|
| `config test\|sync-ci` | send one Telegram test message / set the GitHub CI secrets; see [CI notifications](#ci-notifications) |
|
|
223
224
|
| `help [command]` | styled help; `help ui` = `--help ui` = `ui --help`; see [Help](#help) |
|
|
@@ -271,7 +272,7 @@ asked, plus `owner`, the harness whose park dir and state entry hold the item;
|
|
|
271
272
|
unshared).
|
|
272
273
|
|
|
273
274
|
`--dry-run` (`disable` / `enable` / `enable --all` / `undo` / `profile apply` /
|
|
274
|
-
`install-shims` / `ui`) computes the plan --
|
|
275
|
+
`profile auto` / `install-shims` / `ui`) computes the plan --
|
|
275
276
|
moves, companions, backups, MCP edits, warnings -- and writes nothing: no state,
|
|
276
277
|
log, lock or backup, and no chmod; it never shells out to `claude`, except one
|
|
277
278
|
read-only `claude plugin list --json` (up to 30 s) when a killed run left a plugin
|
|
@@ -734,8 +735,8 @@ one batch, logged, undoable with `undo`).
|
|
|
734
735
|
`~/.agent-toggle/profiles`. `..` in a path, and names that are not plain file
|
|
735
736
|
names, are refused (exit `2`), as are a bad version, an unknown harness or
|
|
736
737
|
type, an invalid item name, a duplicate item or a file over 1 MiB.
|
|
737
|
-
- `--out` belongs to `save` only; `--dry-run` to `apply` / `diff`. `--harness H`
|
|
738
|
-
narrows `save`, `apply` and `
|
|
738
|
+
- `--out` belongs to `save` only; `--dry-run` to `apply` / `diff` / `auto`. `--harness H`
|
|
739
|
+
narrows `save`, `apply`, `diff` and `auto` to one harness.
|
|
739
740
|
- `diff` and `apply --dry-run` do not read plugin state (that needs the claude
|
|
740
741
|
CLI, and a dry run never shells out), so profile plugin items show as
|
|
741
742
|
`skipped` there.
|
|
@@ -756,6 +757,36 @@ one batch, logged, undoable with `undo`).
|
|
|
756
757
|
keeps the file byte for byte. Neither takes `--dry-run` or `--project`: a
|
|
757
758
|
project profile is renamed or deleted by its name like any other.
|
|
758
759
|
|
|
760
|
+
### Project bindings
|
|
761
|
+
|
|
762
|
+
Bind a stored profile to a project and a session opened there applies it. A project
|
|
763
|
+
with no binding applies the global profile; with nothing bound, nothing happens.
|
|
764
|
+
|
|
765
|
+
```sh
|
|
766
|
+
agent-toggle profile bind work --dir ~/code/app # default: the current dir
|
|
767
|
+
agent-toggle profile bind base --global # every dir with no binding of its own
|
|
768
|
+
agent-toggle profile list # shows what each profile is bound to
|
|
769
|
+
agent-toggle profile auto --dir ~/code/app/src # applies work, as a session start does
|
|
770
|
+
agent-toggle profile unbind --dir ~/code/app # or: profile unbind --global
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
- **Lookup:** the nearest bound dir at or above the cwd wins, so subdirs and worktrees
|
|
774
|
+
inside it inherit the binding; then the global binding; then nothing (exit `0`, no rows).
|
|
775
|
+
- With the [Claude Code mod](docs/MOD.md), each session start runs `profile auto` for its
|
|
776
|
+
cwd, off the start so it never blocks it, and reloads what changed. Other harnesses can
|
|
777
|
+
run `profile auto` from their own hook.
|
|
778
|
+
- A binding names a stored user-scope profile. A `--project` profile or a file path cannot
|
|
779
|
+
be bound.
|
|
780
|
+
- `delete` drops the bindings to that profile and `rename` moves them. A bound profile
|
|
781
|
+
that is no longer saved gives a `skipped` `auto` row, not a failure.
|
|
782
|
+
- Bindings live in `~/.agent-toggle/profile-bindings.json`, outside `profiles/`: that dir
|
|
783
|
+
may be synced between machines, and these keys are this machine's absolute paths.
|
|
784
|
+
|
|
785
|
+
**Limitation: the last session start wins.** A profile changes shared user state (file
|
|
786
|
+
moves under `~/.claude`, plugin flags), not one session's view. With two sessions in
|
|
787
|
+
different projects, the later start switches the state and the other running session is
|
|
788
|
+
not told. Agents and rules need a new session to change either way.
|
|
789
|
+
|
|
759
790
|
## Undo and `enable --all`
|
|
760
791
|
|
|
761
792
|
`undo` reads `~/.agent-toggle/log.jsonl`, takes the batch of the last
|
|
@@ -940,6 +971,7 @@ bookkeeping.
|
|
|
940
971
|
| `parked/user/<owner>/<dir>/` | user-scope items, e.g. `parked/user/claude/skills/<name>` (`<owner>` = the harness whose home holds the dir; a dir shared by several harnesses parks once, under its owner); an absolute OpenCode `skills.paths` dir parks under `parked/user/opencode/ext-<sha8>/` (`<sha8>` of its resolved path). Nothing is ever parked inside a harness home |
|
|
941
972
|
| `parked/<sha8>/` | items parked by `--project` (`<sha8>` = first 8 hex of the SHA-1 of the resolved project dir) |
|
|
942
973
|
| `profiles/` | `<name>.json` profiles (dir `0700`, files `0600`) |
|
|
974
|
+
| `profile-bindings.json` | which profile each project dir loads, plus the global one ([Project bindings](#project-bindings)); machine-local absolute paths, do not sync |
|
|
943
975
|
| `config.json` | [settings](#settings--config-menu) and the Telegram chat id (mode `0600`, atomic write, unknown keys kept) |
|
|
944
976
|
| `update-check.json` | the [update check](#update-check)'s skipped version (mode `0600`, atomic write) |
|
|
945
977
|
|
|
@@ -359,6 +359,113 @@ class ValidationTest(ProfileCase):
|
|
|
359
359
|
self.assert_usage("profile", "rename", "work", "a:b")
|
|
360
360
|
|
|
361
361
|
|
|
362
|
+
class BindingTest(ProfileCase):
|
|
363
|
+
"""bind / unbind / auto: a project dir loads its own profile, any other dir the global one."""
|
|
364
|
+
|
|
365
|
+
def setUp(self) -> None:
|
|
366
|
+
super().setUp()
|
|
367
|
+
self.skill = self.home / "skills" / "demo-skill"
|
|
368
|
+
self.proj = self.tmp / "work" / "app"
|
|
369
|
+
(self.proj / "lib").mkdir(parents=True)
|
|
370
|
+
self.other = self.tmp / "work" / "other"
|
|
371
|
+
self.other.mkdir()
|
|
372
|
+
self.run_cli("profile", "save", "full") # demo-skill live
|
|
373
|
+
self.run_cli("disable", "skill", "demo-skill")
|
|
374
|
+
self.run_cli("profile", "save", "lean") # demo-skill parked
|
|
375
|
+
|
|
376
|
+
def auto(self, where: Path, *flags: str) -> tuple[int, list[dict]]:
|
|
377
|
+
rc, env = self.run_json("profile", "auto", "--dir", str(where), *flags)
|
|
378
|
+
return rc, env["results"]
|
|
379
|
+
|
|
380
|
+
def test_a_bound_dir_gets_its_profile_and_any_other_dir_the_global_one(self) -> None:
|
|
381
|
+
self.assertEqual(self.run_cli("profile", "bind", "lean", "--dir", str(self.proj))[0], 0)
|
|
382
|
+
self.assertEqual(self.run_cli("profile", "bind", "full", "--global")[0], 0)
|
|
383
|
+
rc, rows = self.auto(self.other)
|
|
384
|
+
self.assertEqual((rc, rows[0]["name"], rows[0]["action"], rows[0]["source"]),
|
|
385
|
+
(0, "full", "auto", "global"))
|
|
386
|
+
self.assertTrue(self.skill.exists())
|
|
387
|
+
rc, rows = self.auto(self.proj / "lib") # a dir inside the bound one
|
|
388
|
+
self.assertEqual((rc, rows[0]["name"], rows[0]["source"]),
|
|
389
|
+
(0, "lean", str(self.proj.resolve())))
|
|
390
|
+
self.assertEqual([(r["type"], r["name"], r["action"], r["status"]) for r in rows[1:]],
|
|
391
|
+
[("skill", "demo-skill", "disable", "ok")])
|
|
392
|
+
self.assertFalse(self.skill.exists())
|
|
393
|
+
|
|
394
|
+
def test_the_nearest_bound_dir_wins(self) -> None:
|
|
395
|
+
self.run_cli("profile", "bind", "full", "--dir", str(self.proj))
|
|
396
|
+
self.run_cli("profile", "bind", "lean", "--dir", str(self.proj / "lib"))
|
|
397
|
+
self.assertEqual(self.auto(self.proj / "lib", "--dry-run")[1][0]["name"], "lean")
|
|
398
|
+
self.assertEqual(self.auto(self.proj, "--dry-run")[1][0]["name"], "full")
|
|
399
|
+
|
|
400
|
+
def test_nothing_bound_changes_nothing_and_exits_0(self) -> None:
|
|
401
|
+
before = snapshot(self.tmp)
|
|
402
|
+
self.assertEqual(self.auto(self.proj), (0, []))
|
|
403
|
+
self.assertEqual(snapshot(self.tmp), before)
|
|
404
|
+
self.assertIn("no profile is bound", self.run_cli("profile", "auto", "--dir", str(self.proj))[1])
|
|
405
|
+
|
|
406
|
+
def test_auto_dry_run_writes_nothing(self) -> None:
|
|
407
|
+
self.run_cli("profile", "bind", "full", "--global")
|
|
408
|
+
before = snapshot(self.tmp)
|
|
409
|
+
rc, rows = self.auto(self.proj, "--dry-run")
|
|
410
|
+
self.assertEqual((rc, [r["status"] for r in rows]), (0, ["ok", "planned"]))
|
|
411
|
+
self.assertEqual(snapshot(self.tmp), before)
|
|
412
|
+
|
|
413
|
+
def test_unbind_falls_back_to_the_global_profile_then_to_nothing(self) -> None:
|
|
414
|
+
self.run_cli("profile", "bind", "lean", "--dir", str(self.proj))
|
|
415
|
+
self.run_cli("profile", "bind", "full", "--global")
|
|
416
|
+
self.assertEqual(self.run_cli("profile", "unbind", "--dir", str(self.proj))[0], 0)
|
|
417
|
+
self.assertEqual(self.auto(self.proj, "--dry-run")[1][0]["name"], "full")
|
|
418
|
+
self.assertEqual(self.run_cli("profile", "unbind", "--global")[0], 0)
|
|
419
|
+
self.assertEqual(self.auto(self.proj, "--dry-run"), (0, []))
|
|
420
|
+
|
|
421
|
+
def test_rename_follows_a_binding_and_delete_drops_it(self) -> None:
|
|
422
|
+
self.run_cli("profile", "bind", "lean", "--dir", str(self.proj))
|
|
423
|
+
self.run_cli("profile", "bind", "lean", "--global")
|
|
424
|
+
self.run_cli("profile", "rename", "lean", "slim")
|
|
425
|
+
self.assertEqual(self.auto(self.proj, "--dry-run")[1][0]["name"], "slim")
|
|
426
|
+
self.assertEqual(self.auto(self.other, "--dry-run")[1][0]["name"], "slim")
|
|
427
|
+
self.run_cli("profile", "delete", "slim")
|
|
428
|
+
self.assertEqual(self.auto(self.proj, "--dry-run"), (0, []))
|
|
429
|
+
|
|
430
|
+
def test_a_binding_to_a_profile_that_is_gone_is_skipped_not_failed(self) -> None:
|
|
431
|
+
self.run_cli("profile", "bind", "lean", "--global")
|
|
432
|
+
(fs.profiles_dir() / "lean.json").unlink() # removed by hand, not by `delete`
|
|
433
|
+
before = snapshot(self.tmp)
|
|
434
|
+
rc, rows = self.auto(self.proj)
|
|
435
|
+
self.assertEqual((rc, [(r["name"], r["action"], r["status"]) for r in rows]),
|
|
436
|
+
(0, [("lean", "auto", "skipped")]))
|
|
437
|
+
self.assertEqual(snapshot(self.tmp), before)
|
|
438
|
+
|
|
439
|
+
def test_list_names_what_a_profile_is_bound_to(self) -> None:
|
|
440
|
+
self.run_cli("profile", "bind", "lean", "--dir", str(self.proj))
|
|
441
|
+
self.run_cli("profile", "bind", "lean", "--global")
|
|
442
|
+
rows = {r["name"]: r for r in self.run_json("profile", "list")[1]["results"]}
|
|
443
|
+
self.assertEqual((rows["lean"]["global"], rows["lean"]["bound"]),
|
|
444
|
+
(True, [str(self.proj.resolve())]))
|
|
445
|
+
self.assertFalse({"global", "bound"} & set(rows["full"]))
|
|
446
|
+
self.assertIn(f"<- global, {self.proj.resolve()}", self.run_cli("profile", "list")[1])
|
|
447
|
+
|
|
448
|
+
def test_a_corrupt_bindings_file_reads_as_no_bindings(self) -> None:
|
|
449
|
+
fs.bindings_file().write_text('{"global": 3, "projects": [1]', encoding="utf-8")
|
|
450
|
+
self.assertEqual(self.auto(self.proj), (0, []))
|
|
451
|
+
|
|
452
|
+
def test_misuse_exits_2_and_changes_nothing(self) -> None:
|
|
453
|
+
proj = self.tmp / "repo"
|
|
454
|
+
(proj / ".claude" / "skills").mkdir(parents=True)
|
|
455
|
+
self.run_cli("profile", "save", "scoped", "--project", str(proj))
|
|
456
|
+
before = snapshot(self.tmp)
|
|
457
|
+
for argv in (("bind",), ("bind", "nope"), ("bind", "scoped"), ("bind", "x.json"),
|
|
458
|
+
("bind", "lean", "--dir", str(self.tmp / "missing")),
|
|
459
|
+
("bind", "lean", "--global", "--dir", str(self.proj)),
|
|
460
|
+
("bind", "lean", "--project", str(proj)),
|
|
461
|
+
("unbind",), ("unbind", "--global"), ("unbind", "lean"),
|
|
462
|
+
("auto", "lean"), ("auto", "--global"),
|
|
463
|
+
("list", "--dir", str(self.proj)), ("apply", "lean", "--global")):
|
|
464
|
+
rc, env = self.run_json("profile", *argv)
|
|
465
|
+
self.assertEqual((rc, env["ok"]), (2, False), argv)
|
|
466
|
+
self.assertEqual(snapshot(self.tmp), before)
|
|
467
|
+
|
|
468
|
+
|
|
362
469
|
@unittest.skipIf(os.name == "nt", "POSIX modes")
|
|
363
470
|
class ModeTest(ProfileCase):
|
|
364
471
|
def test_stored_profile_is_private(self) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|