@hasna/accounts 0.1.4 → 0.1.6

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
@@ -1,8 +1,8 @@
1
1
  # @hasna/accounts
2
2
 
3
3
  > Manage and switch between multiple AI coding tool profiles/accounts on one
4
- > machine — Claude Code, Codex CLI, opencode, Cursor Agent, Kimi Code, Grok
5
- > Build, and custom tools.
4
+ > machine — Claude Code, Takumi, Codex CLI, Gemini CLI, opencode, Cursor
5
+ > Agent, Pi Coding Agent, Hermes, Kimi Code, Grok Build, and custom tools.
6
6
 
7
7
  `accounts` is a local-first CLI. Each **profile** is an isolated config directory.
8
8
  Switch **in the terminal** with `CLAUDE_CONFIG_DIR`, or **in Cursor / VS Code** with
@@ -11,8 +11,9 @@ Switch **in the terminal** with `CLAUDE_CONFIG_DIR`, or **in Cursor / VS Code**
11
11
  - **Isolated profiles** — separate config dirs (skills, settings, sessions). Nothing leaks.
12
12
  - **Apply mode** — sync OAuth / credentials to live paths for IDEs (Claude-only today).
13
13
  - **Remembers the email** — auto-detected from `.claude.json` when possible.
14
- - **Multi-tool** — first-class built-ins for Claude, Codex, opencode, Cursor Agent,
15
- Kimi Code, and Grok Build; custom tools via `accounts tools add`.
14
+ - **Multi-tool** — first-class built-ins for Claude, Takumi, Codex, Gemini,
15
+ opencode, Cursor Agent, Pi, Hermes, Kimi Code, and Grok Build; custom tools
16
+ via `accounts tools add`.
16
17
  - **Per-tool names** — `work` can exist for Claude, Codex, Cursor, etc.; pass
17
18
  `--tool` when a bare profile name is ambiguous.
18
19
  - **Local-first** — registry at `~/.hasna/accounts/`. No network, no telemetry.
@@ -47,6 +48,11 @@ accounts apply personal
47
48
  # Or terminal-only (parallel sessions OK):
48
49
  accounts launch work --tool claude
49
50
  eval "$(accounts env personal --tool claude)" # other terminal
51
+
52
+ # Or supervised: lets MCP switch/restart this Claude process automatically
53
+ accounts use work --tool claude
54
+ accounts run claude --resume
55
+ accounts switch personal --tool claude --supervisor # from another terminal
50
56
  ```
51
57
 
52
58
  After `accounts login <name> --tool claude`, `accounts` snapshots the auth Claude
@@ -92,6 +98,7 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
92
98
  | `accounts apply <name> --tool claude` | Apply profile auth to live Claude paths (requires snapshot; Claude-only). |
93
99
  | `accounts pick` | Interactive picker; default applies. `--env`, `--no-act`. |
94
100
  | `accounts switch <name> --tool <tool>` | Switch profile and print a restart/resume command. Add `--resume`; add `--launch` to run it. |
101
+ | `accounts switch <name> --tool <tool> --supervisor` | Ask a running `accounts run <tool>` supervisor to restart under that profile. |
95
102
  | `accounts use <name> --tool <tool>` | Mark profile active; prints apply/env hints. |
96
103
  | `accounts list` (`ls`) | List profiles (`●` active, `◉` applied, `●◉` both). |
97
104
  | `accounts show <name> --tool <tool>` | Profile details including active/applied flags. |
@@ -99,7 +106,11 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
99
106
  | `accounts active [tool]` | Print active profile name (scripting). |
100
107
  | `accounts applied [tool]` | Print applied profile name (scripting). |
101
108
  | `accounts env [name] --tool <tool>` | Print one or more `export ...` lines for the profile. |
102
- | `accounts launch\|run <name> --tool <tool>` | Launch tool with profile env. |
109
+ | `accounts launch <name> --tool <tool>` | Launch tool once with profile env. |
110
+ | `accounts run <tool> [args...]` | Run a tool under the supervisor so MCP/CLI can switch and restart it. |
111
+ | `accounts supervisor status [tool]` | Show running supervisors. |
112
+ | `accounts supervisor switch <name> --tool <tool>` | Switch a running supervisor to another profile. |
113
+ | `accounts supervisor stop <tool>` | Stop a running supervisor and its child process. |
103
114
  | `accounts shell <name> --tool <tool>` | Subshell with profile env. |
104
115
  | `accounts hook install` | Install `claude()` wrapper — see [docs/hook.md](docs/hook.md). |
105
116
  | `accounts hook uninstall` | Remove hook script. |
@@ -125,16 +136,29 @@ Add it to Claude/Codex/opencode/Cursor MCP config as a command server named
125
136
  - `current_profile`
126
137
  - `switch_profile`
127
138
 
128
- `switch_profile` applies Claude live auth when the target profile is Claude and
129
- returns a restart handoff command. MCP servers cannot safely kill their parent
130
- agent process, so the tool returns an instruction such as: exit this session and
131
- run `CLAUDE_CONFIG_DIR=... claude --continue`.
139
+ For automatic agent restarts, start the agent through `accounts run`:
140
+
141
+ ```bash
142
+ accounts use account001 --tool claude
143
+ accounts run claude --resume
144
+ ```
145
+
146
+ When `switch_profile` is called from that Claude session, `accounts-mcp` contacts
147
+ the supervisor. The supervisor applies/switches the profile, closes the current
148
+ Claude process, and restarts it with the selected profile. Claude uses
149
+ `claude --continue`; Codex uses `codex resume --last`; opencode uses
150
+ `opencode --continue`; custom tools can define `resumeArgs`.
151
+
152
+ If the agent was not started through `accounts run`, MCP falls back to the safe
153
+ handoff behavior and returns a command such as:
154
+ `CLAUDE_CONFIG_DIR=... claude --continue`.
132
155
 
133
156
  Human equivalent:
134
157
 
135
158
  ```bash
136
159
  accounts switch account001 --tool claude --resume
137
160
  accounts switch account001 --tool claude --resume --launch
161
+ accounts switch account001 --tool claude --supervisor
138
162
  accounts switch codex-work --tool codex --resume
139
163
  accounts switch ops --tool opencode --resume
140
164
  ```
@@ -156,6 +180,9 @@ then invokes the real `claude` binary. Full behavior and footguns: [docs/hook.md
156
180
  ~/.hasna/accounts/
157
181
  accounts.json # registry: profiles, current, applied (mode 600)
158
182
  claude-hook.sh # optional shell wrapper
183
+ supervisors/
184
+ claude.sock # local control socket for `accounts run claude`
185
+ claude.json # supervisor pid/profile/command metadata
159
186
  profiles/
160
187
  claude/<name>/ # managed config dir
161
188
  claude/<name>/.accounts-auth/ # auth snapshots for apply mode
@@ -171,9 +198,13 @@ Overrides: `ACCOUNTS_HOME`, `ACCOUNTS_STORE_PATH`.
171
198
  | Tool | id | Env var | Default dir |
172
199
  |------|----|---------|-------------|
173
200
  | Claude Code | `claude` | `CLAUDE_CONFIG_DIR` | `~/.claude` |
201
+ | Takumi | `takumi` | `TAKUMI_CONFIG_DIR` | `~/.takumi` |
174
202
  | Codex CLI | `codex` | `CODEX_HOME` | `~/.codex` |
203
+ | Gemini CLI | `gemini` | `GEMINI_CONFIG_DIR` | `~/.gemini` |
175
204
  | opencode | `opencode` | `OPENCODE_CONFIG_DIR`, `XDG_CONFIG_HOME`, `XDG_DATA_HOME` | `~/.config/opencode` |
176
205
  | Cursor Agent | `cursor` | `CURSOR_CONFIG_DIR` | `~/.cursor` |
206
+ | Pi Coding Agent | `pi` | `PI_CODING_AGENT_HOME` | `~/.pi` |
207
+ | Hermes | `hermes` | `HERMES_HOME` | `~/.hermes` |
177
208
  | Kimi Code | `kimi` | `KIMI_CODE_HOME` | `~/.kimi-code` |
178
209
  | Grok Build | `grok` | `HOME` (process-scoped) | `~/.grok` |
179
210
 
@@ -181,6 +212,8 @@ Overrides: `ACCOUNTS_HOME`, `ACCOUNTS_STORE_PATH`.
181
212
  For Grok Build, prefer `accounts launch` or `accounts shell`; exporting `HOME`
182
213
  globally is intentionally not recommended.
183
214
 
215
+ Custom tools can join supervised resume switching with `accounts tools add ... --resume-arg <arg>`.
216
+
184
217
  ## Library
185
218
 
186
219
  ```ts