@hasna/accounts 0.1.3 → 0.1.5

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.
package/README.md CHANGED
@@ -47,6 +47,11 @@ accounts apply personal
47
47
  # Or terminal-only (parallel sessions OK):
48
48
  accounts launch work --tool claude
49
49
  eval "$(accounts env personal --tool claude)" # other terminal
50
+
51
+ # Or supervised: lets MCP switch/restart this Claude process automatically
52
+ accounts use work --tool claude
53
+ accounts run claude --resume
54
+ accounts switch personal --tool claude --supervisor # from another terminal
50
55
  ```
51
56
 
52
57
  After `accounts login <name> --tool claude`, `accounts` snapshots the auth Claude
@@ -91,6 +96,8 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
91
96
  | `accounts login <name> --tool <tool>` | Launch the tool's login flow in an isolated profile dir. |
92
97
  | `accounts apply <name> --tool claude` | Apply profile auth to live Claude paths (requires snapshot; Claude-only). |
93
98
  | `accounts pick` | Interactive picker; default applies. `--env`, `--no-act`. |
99
+ | `accounts switch <name> --tool <tool>` | Switch profile and print a restart/resume command. Add `--resume`; add `--launch` to run it. |
100
+ | `accounts switch <name> --tool <tool> --supervisor` | Ask a running `accounts run <tool>` supervisor to restart under that profile. |
94
101
  | `accounts use <name> --tool <tool>` | Mark profile active; prints apply/env hints. |
95
102
  | `accounts list` (`ls`) | List profiles (`●` active, `◉` applied, `●◉` both). |
96
103
  | `accounts show <name> --tool <tool>` | Profile details including active/applied flags. |
@@ -98,7 +105,11 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
98
105
  | `accounts active [tool]` | Print active profile name (scripting). |
99
106
  | `accounts applied [tool]` | Print applied profile name (scripting). |
100
107
  | `accounts env [name] --tool <tool>` | Print one or more `export ...` lines for the profile. |
101
- | `accounts launch\|run <name> --tool <tool>` | Launch tool with profile env. |
108
+ | `accounts launch <name> --tool <tool>` | Launch tool once with profile env. |
109
+ | `accounts run <tool> [args...]` | Run a tool under the supervisor so MCP/CLI can switch and restart it. |
110
+ | `accounts supervisor status [tool]` | Show running supervisors. |
111
+ | `accounts supervisor switch <name> --tool <tool>` | Switch a running supervisor to another profile. |
112
+ | `accounts supervisor stop <tool>` | Stop a running supervisor and its child process. |
102
113
  | `accounts shell <name> --tool <tool>` | Subshell with profile env. |
103
114
  | `accounts hook install` | Install `claude()` wrapper — see [docs/hook.md](docs/hook.md). |
104
115
  | `accounts hook uninstall` | Remove hook script. |
@@ -108,6 +119,49 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
108
119
 
109
120
  See `accounts --help` for `set`, `rename`, `remove`, `tools`, etc.
110
121
 
122
+ ## Agent / MCP Switching
123
+
124
+ `accounts` ships a stdio MCP server:
125
+
126
+ ```bash
127
+ accounts-mcp
128
+ ```
129
+
130
+ Add it to Claude/Codex/opencode/Cursor MCP config as a command server named
131
+ `accounts`. It exposes:
132
+
133
+ - `list_tools`
134
+ - `list_profiles`
135
+ - `current_profile`
136
+ - `switch_profile`
137
+
138
+ For automatic agent restarts, start the agent through `accounts run`:
139
+
140
+ ```bash
141
+ accounts use account001 --tool claude
142
+ accounts run claude --resume
143
+ ```
144
+
145
+ When `switch_profile` is called from that Claude session, `accounts-mcp` contacts
146
+ the supervisor. The supervisor applies/switches the profile, closes the current
147
+ Claude process, and restarts it with the selected profile. Claude uses
148
+ `claude --continue`; Codex uses `codex resume --last`; opencode uses
149
+ `opencode --continue`; custom tools can define `resumeArgs`.
150
+
151
+ If the agent was not started through `accounts run`, MCP falls back to the safe
152
+ handoff behavior and returns a command such as:
153
+ `CLAUDE_CONFIG_DIR=... claude --continue`.
154
+
155
+ Human equivalent:
156
+
157
+ ```bash
158
+ accounts switch account001 --tool claude --resume
159
+ accounts switch account001 --tool claude --resume --launch
160
+ accounts switch account001 --tool claude --supervisor
161
+ accounts switch codex-work --tool codex --resume
162
+ accounts switch ops --tool opencode --resume
163
+ ```
164
+
111
165
  ## Shell hook (optional)
112
166
 
113
167
  ```bash
@@ -125,6 +179,9 @@ then invokes the real `claude` binary. Full behavior and footguns: [docs/hook.md
125
179
  ~/.hasna/accounts/
126
180
  accounts.json # registry: profiles, current, applied (mode 600)
127
181
  claude-hook.sh # optional shell wrapper
182
+ supervisors/
183
+ claude.sock # local control socket for `accounts run claude`
184
+ claude.json # supervisor pid/profile/command metadata
128
185
  profiles/
129
186
  claude/<name>/ # managed config dir
130
187
  claude/<name>/.accounts-auth/ # auth snapshots for apply mode
@@ -150,6 +207,8 @@ Overrides: `ACCOUNTS_HOME`, `ACCOUNTS_STORE_PATH`.
150
207
  For Grok Build, prefer `accounts launch` or `accounts shell`; exporting `HOME`
151
208
  globally is intentionally not recommended.
152
209
 
210
+ Custom tools can join supervised resume switching with `accounts tools add ... --resume-arg <arg>`.
211
+
153
212
  ## Library
154
213
 
155
214
  ```ts