opencode-account-manager 0.6.3 → 0.6.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.
Files changed (95) hide show
  1. package/README.md +235 -216
  2. package/README_VI.md +235 -216
  3. package/dist/cli.js +83 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/core/config-store.d.ts +12 -0
  6. package/dist/core/config-store.d.ts.map +1 -1
  7. package/dist/core/config-store.js +98 -0
  8. package/dist/core/config-store.js.map +1 -1
  9. package/dist/core/health-log.d.ts +9 -0
  10. package/dist/core/health-log.d.ts.map +1 -0
  11. package/dist/core/health-log.js +154 -0
  12. package/dist/core/health-log.js.map +1 -0
  13. package/dist/core/health-oauth.d.ts +5 -0
  14. package/dist/core/health-oauth.d.ts.map +1 -0
  15. package/dist/core/health-oauth.js +147 -0
  16. package/dist/core/health-oauth.js.map +1 -0
  17. package/dist/core/health-orchestrator.d.ts +32 -0
  18. package/dist/core/health-orchestrator.d.ts.map +1 -0
  19. package/dist/core/health-orchestrator.js +148 -0
  20. package/dist/core/health-orchestrator.js.map +1 -0
  21. package/dist/core/health-utils.d.ts +15 -0
  22. package/dist/core/health-utils.d.ts.map +1 -0
  23. package/dist/core/health-utils.js +60 -0
  24. package/dist/core/health-utils.js.map +1 -0
  25. package/dist/core/paths.d.ts +1 -0
  26. package/dist/core/paths.d.ts.map +1 -1
  27. package/dist/core/paths.js +4 -0
  28. package/dist/core/paths.js.map +1 -1
  29. package/dist/core/types.d.ts +26 -0
  30. package/dist/core/types.d.ts.map +1 -1
  31. package/dist/tui/Dashboard.d.ts.map +1 -1
  32. package/dist/tui/Dashboard.js +72 -5
  33. package/dist/tui/Dashboard.js.map +1 -1
  34. package/dist/tui/components/AccountList.d.ts +5 -3
  35. package/dist/tui/components/AccountList.d.ts.map +1 -1
  36. package/dist/tui/components/AccountList.js +9 -3
  37. package/dist/tui/components/AccountList.js.map +1 -1
  38. package/dist/tui/components/Box.js +2 -2
  39. package/dist/tui/components/Box.js.map +1 -1
  40. package/dist/tui/components/DashboardView.d.ts +3 -2
  41. package/dist/tui/components/DashboardView.d.ts.map +1 -1
  42. package/dist/tui/components/DashboardView.js +50 -4
  43. package/dist/tui/components/DashboardView.js.map +1 -1
  44. package/dist/tui/components/ExportModal.js +4 -4
  45. package/dist/tui/components/ExportModal.js.map +1 -1
  46. package/dist/tui/components/FileBrowser.js +1 -1
  47. package/dist/tui/components/HealthBadge.d.ts +9 -0
  48. package/dist/tui/components/HealthBadge.d.ts.map +1 -0
  49. package/dist/tui/components/HealthBadge.js +56 -0
  50. package/dist/tui/components/HealthBadge.js.map +1 -0
  51. package/dist/tui/components/ImportModal.js +4 -4
  52. package/dist/tui/components/ImportModal.js.map +1 -1
  53. package/dist/tui/components/PasswordInput.js +2 -2
  54. package/dist/tui/components/PasswordInput.js.map +1 -1
  55. package/dist/tui/components/StatusBadge.d.ts +2 -1
  56. package/dist/tui/components/StatusBadge.d.ts.map +1 -1
  57. package/dist/tui/components/StatusBadge.js +30 -2
  58. package/dist/tui/components/StatusBadge.js.map +1 -1
  59. package/dist/tui/components/index.d.ts +1 -0
  60. package/dist/tui/components/index.d.ts.map +1 -1
  61. package/dist/tui/components/index.js +3 -1
  62. package/dist/tui/components/index.js.map +1 -1
  63. package/docs/BLUEPRINT.md +476 -476
  64. package/docs/ROADMAP.md +125 -107
  65. package/package.json +36 -36
  66. package/src/cli.ts +139 -38
  67. package/src/core/config-store.ts +278 -171
  68. package/src/core/crypto.ts +162 -162
  69. package/src/core/health-log.ts +173 -0
  70. package/src/core/health-oauth.ts +190 -0
  71. package/src/core/health-orchestrator.ts +224 -0
  72. package/src/core/importers/amExport.ts +177 -177
  73. package/src/core/opencode-config.ts +217 -217
  74. package/src/core/paths.ts +10 -6
  75. package/src/core/types.ts +193 -147
  76. package/src/tui/Dashboard.tsx +557 -478
  77. package/src/tui/components/AccountList.tsx +122 -104
  78. package/src/tui/components/ActionPalette.tsx +117 -117
  79. package/src/tui/components/Box.tsx +2 -2
  80. package/src/tui/components/DashboardView.tsx +285 -230
  81. package/src/tui/components/ExportModal.tsx +255 -255
  82. package/src/tui/components/FileBrowser.tsx +393 -393
  83. package/src/tui/components/Header.tsx +26 -26
  84. package/src/tui/components/HealthBadge.tsx +64 -0
  85. package/src/tui/components/ImportModal.tsx +334 -334
  86. package/src/tui/components/McpServerList.tsx +67 -67
  87. package/src/tui/components/Menu.tsx +61 -61
  88. package/src/tui/components/PasswordInput.tsx +159 -159
  89. package/src/tui/components/ProviderList.tsx +59 -59
  90. package/src/tui/components/SectionBox.tsx +35 -35
  91. package/src/tui/components/StatsRow.tsx +33 -33
  92. package/src/tui/components/StatusBadge.tsx +36 -3
  93. package/src/tui/components/index.ts +15 -14
  94. package/test-minimal.js +26 -26
  95. package/test-with-accounts.js +58 -58
package/README.md CHANGED
@@ -1,232 +1,251 @@
1
- # OpenCode Account Manager (OCAM)
2
-
3
- <div align="center">
4
- <h3>TUI Dashboard for OpenCode Account Management</h3>
5
- <p>Manage providers, MCP servers, and plugin accounts in one place.</p>
6
-
7
- <p>
8
- <a href="https://www.npmjs.com/package/opencode-account-manager">
9
- <img src="https://img.shields.io/npm/v/opencode-account-manager.svg" alt="npm version">
10
- </a>
11
- <a href="https://www.npmjs.com/package/opencode-account-manager">
12
- <img src="https://img.shields.io/npm/dw/opencode-account-manager.svg" alt="npm downloads">
13
- </a>
14
- <a href="https://github.com/d-init-d/opencode-account-manager/blob/main/LICENSE">
15
- <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License">
16
- </a>
17
- </p>
18
-
19
- <p>
20
- <strong>English</strong> |
21
- <a href="./README_VI.md">Tiếng Việt</a>
22
- </p>
23
- </div>
24
-
25
- ---
26
-
27
- ## Features
28
-
29
- - **Providers View**: See all AI providers (Google, Ollama, Anthropic, etc.) with model counts
1
+ # OpenCode Account Manager (OCAM)
2
+
3
+ <div align="center">
4
+ <h3>TUI Dashboard for OpenCode Account Management</h3>
5
+ <p>Manage providers, MCP servers, and plugin accounts in one place.</p>
6
+
7
+ <p>
8
+ <a href="https://www.npmjs.com/package/opencode-account-manager">
9
+ <img src="https://img.shields.io/npm/v/opencode-account-manager.svg" alt="npm version">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/opencode-account-manager">
12
+ <img src="https://img.shields.io/npm/dw/opencode-account-manager.svg" alt="npm downloads">
13
+ </a>
14
+ <a href="https://github.com/d-init-d/opencode-account-manager/blob/main/LICENSE">
15
+ <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License">
16
+ </a>
17
+ </p>
18
+
19
+ <p>
20
+ <strong>English</strong> |
21
+ <a href="./README_VI.md">Tiếng Việt</a>
22
+ </p>
23
+ </div>
24
+
25
+ ---
26
+
27
+ ## Features
28
+
29
+ - **Providers View**: See all AI providers (Google, Ollama, Anthropic, etc.) with model counts
30
30
  - **MCP Servers**: View enabled/disabled status of MCP servers
31
31
  - **Plugin Accounts**: Manage Google accounts connected to OpenCode
32
32
  - Rate limit status per model (claude, gemini)
33
33
  - Enable/Disable/Delete accounts
34
+ - **Account Health Check**: Validate refresh tokens and flag verification required
34
35
  - **Encrypted Export**: AES-256-GCM encryption with password protection
35
36
  - **Multi-format Import**: Support for encrypted `.ocam`, plain JSON, and Antigravity Manager exports
36
-
37
- ---
38
-
39
- ## Installation
40
-
41
- ### Option A: Let an LLM do it
42
-
43
- Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
44
-
45
- ```
46
- Install opencode-account-manager globally via npm, then run "ocam" to verify installation.
47
- Repository: https://github.com/d-init-d/opencode-account-manager
48
- ```
49
-
50
- ### Option B: Install from npm
51
-
52
- ```bash
53
- npm install -g opencode-account-manager
54
- ```
55
-
56
- ### Option C: Install from GitHub
57
-
58
- ```bash
59
- npm install -g github:d-init-d/opencode-account-manager
60
- ```
61
-
62
- ### Verify installation
63
-
64
- ```bash
65
- ocam --version
66
- ```
67
-
68
- ---
69
-
70
- ## For LLM Agents
71
-
72
- ### Step-by-Step Instructions
73
-
74
- 1. Run `npm install -g opencode-account-manager` to install globally
75
- 2. Run `ocam` to start the TUI dashboard
76
- 3. The dashboard will auto-detect OpenCode config at `~/.config/opencode/opencode.json`
77
-
78
- ### Verification
79
-
80
- ```bash
81
- ocam --version
82
- # Expected output: 0.4.2
83
- ```
84
-
85
- ---
86
-
87
- ## Usage
88
-
89
- ### Start Dashboard
90
-
91
- ```bash
92
- ocam
93
- # or
94
- opencode-account-manager
95
- ```
96
-
97
- ### CLI Commands
98
-
99
- ```bash
100
- # List accounts
101
- ocam list
102
-
103
- # Export accounts
104
- ocam export -o backup.json
105
-
106
- # Import accounts
107
- ocam import backup.json
108
-
37
+
38
+ ---
39
+
40
+ ## Installation
41
+
42
+ ### Option A: Let an LLM do it
43
+
44
+ Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
45
+
46
+ ```
47
+ Install opencode-account-manager globally via npm, then run "ocam" to verify installation.
48
+ Repository: https://github.com/d-init-d/opencode-account-manager
49
+ ```
50
+
51
+ ### Option B: Install from npm
52
+
53
+ ```bash
54
+ npm install -g opencode-account-manager
55
+ ```
56
+
57
+ ### Option C: Install from GitHub
58
+
59
+ ```bash
60
+ npm install -g github:d-init-d/opencode-account-manager
61
+ ```
62
+
63
+ ### Verify installation
64
+
65
+ ```bash
66
+ ocam --version
67
+ ```
68
+
69
+ ---
70
+
71
+ ## For LLM Agents
72
+
73
+ ### Step-by-Step Instructions
74
+
75
+ 1. Run `npm install -g opencode-account-manager` to install globally
76
+ 2. Run `ocam` to start the TUI dashboard
77
+ 3. The dashboard will auto-detect OpenCode config at `~/.config/opencode/opencode.json`
78
+
79
+ ### Verification
80
+
81
+ ```bash
82
+ ocam --version
83
+ # Expected output: 0.4.2
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Usage
89
+
90
+ ### Start Dashboard
91
+
92
+ ```bash
93
+ ocam
94
+ # or
95
+ opencode-account-manager
96
+ ```
97
+
98
+ ### CLI Commands
99
+
100
+ ```bash
101
+ # List accounts
102
+ ocam list
103
+
104
+ # Export accounts
105
+ ocam export -o backup.json
106
+
107
+ # Import accounts
108
+ ocam import backup.json
109
+
109
110
  # Import from Antigravity Manager folder
110
111
  ocam import-am
111
112
 
112
- # Help
113
- ocam --help
114
- ```
115
-
116
- ---
117
-
118
- ## Keyboard Shortcuts
119
-
120
- ### Main Dashboard
121
-
122
- | Key | Action |
123
- |-----|--------|
124
- | `Tab` | Switch section (Providers → Accounts → MCP) |
125
- | `R` | Refresh data |
126
- | `E` | Export accounts |
127
- | `I` | Import accounts |
128
- | `A` | Import from Antigravity Manager |
129
- | `S` | Enter Select Mode |
130
- | `Q` | Quit |
131
-
132
- ### Select Mode (Accounts)
133
-
134
- | Key | Action |
135
- |-----|--------|
136
- | `↑/↓` | Navigate |
137
- | `Space` | Toggle selection |
138
- | `A` | Select all |
139
- | `N` | Deselect all |
140
- | `E` | Enable selected |
141
- | `D` | Disable selected |
142
- | `X` | Export selected |
143
- | `DEL` | Delete selected |
144
- | `Esc` | Exit Select Mode |
145
-
146
- ---
147
-
148
- ## Supported Import Formats
149
-
150
- | Format | Extension | Description |
151
- |--------|-----------|-------------|
152
- | Encrypted | `.ocam` | AES-256-GCM encrypted, password required |
153
- | Portable | `.json` | OpenCode Account Manager plain export |
154
- | AM Export | `.json` | Antigravity Manager app export `[{email, refresh_token}]` |
155
- | Plugin Native | `.json` | `antigravity-accounts.json` format |
156
-
157
- ---
158
-
159
- ## Configuration Paths
160
-
161
- | File | Windows | Linux/Mac |
162
- |------|---------|-----------|
163
- | OpenCode config | `~/.config/opencode/opencode.json` | `~/.config/opencode/opencode.json` |
164
- | Plugin accounts | `%APPDATA%/opencode/antigravity-accounts.json` | `~/.config/opencode/antigravity-accounts.json` |
165
- | OCAM preferences | `%APPDATA%/opencode/ocam-config.json` | `~/.config/opencode/ocam-config.json` |
166
-
167
- > **Note**: `~` on Windows resolves to your user home directory (e.g., `C:\Users\YourName`)
168
-
169
- ---
170
-
171
- ## Requirements
172
-
173
- - **Node.js**: >= 16.x
174
- - **OpenCode**: Installed and configured
175
- - **Terminal**: Unicode and 256 colors support (Windows Terminal, iTerm2, etc.)
176
-
177
- ---
113
+ # Health check
114
+ ocam check
178
115
 
179
- ## Troubleshooting
116
+ # Health check (specific emails)
117
+ ocam check --emails user1@example.com,user2@example.com
180
118
 
181
- ### "command not found: ocam"
182
-
183
- ```bash
184
- npm install -g opencode-account-manager
119
+ # Health check (bypass cache)
120
+ ocam check --force
121
+
122
+ # Help
123
+ ocam --help
185
124
  ```
186
125
 
187
- ### "Plugin accounts file not found"
126
+ **Health Check OAuth Config**
127
+ Set OAuth client credentials via environment variables:
188
128
 
189
- Login at least one account first:
190
-
191
- ```bash
192
- opencode auth login
193
129
  ```
194
-
195
- ### "Cannot find module"
196
-
197
- Reinstall the package:
198
-
199
- ```bash
200
- npm uninstall -g opencode-account-manager
201
- npm install -g opencode-account-manager
130
+ OCAM_OAUTH_CLIENT_ID=...
131
+ OCAM_OAUTH_CLIENT_SECRET=...
132
+ OCAM_OAUTH_TOKEN_ENDPOINT=https://oauth2.googleapis.com/token
202
133
  ```
203
-
204
- ---
205
-
206
- ## Documentation
207
-
208
- - [ROADMAP.md](./docs/ROADMAP.md) - Version history and plans
209
- - [BLUEPRINT.md](./docs/BLUEPRINT.md) - Technical architecture
210
-
211
- ---
212
-
213
- ## Contributing
214
-
215
- 1. Fork the repo
216
- 2. Create branch: `git checkout -b feature/your-feature`
217
- 3. Commit: `git commit -m "feat: description"`
218
- 4. Push: `git push origin feature/your-feature`
219
- 5. Create Pull Request
220
-
221
- ---
222
-
223
- ## License
224
-
225
- MIT License. See [LICENSE](./LICENSE) for details.
226
-
227
- ---
228
-
229
- ## Credits
230
-
231
- - [OpenCode](https://opencode.ai) - The AI coding assistant this tool is built for
232
- - [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) - Optional plugin for Google OAuth authentication
134
+
135
+ ---
136
+
137
+ ## Keyboard Shortcuts
138
+
139
+ ### Main Dashboard
140
+
141
+ | Key | Action |
142
+ |-----|--------|
143
+ | `Tab` | Switch section (Providers → Accounts → MCP) |
144
+ | `R` | Refresh data |
145
+ | `E` | Export accounts |
146
+ | `I` | Import accounts |
147
+ | `A` | Import from Antigravity Manager |
148
+ | `S` | Enter Select Mode |
149
+ | `Q` | Quit |
150
+
151
+ ### Select Mode (Accounts)
152
+
153
+ | Key | Action |
154
+ |-----|--------|
155
+ | `↑/↓` | Navigate |
156
+ | `Space` | Toggle selection |
157
+ | `A` | Select all |
158
+ | `N` | Deselect all |
159
+ | `E` | Enable selected |
160
+ | `D` | Disable selected |
161
+ | `X` | Export selected |
162
+ | `DEL` | Delete selected |
163
+ | `Esc` | Exit Select Mode |
164
+
165
+ ---
166
+
167
+ ## Supported Import Formats
168
+
169
+ | Format | Extension | Description |
170
+ |--------|-----------|-------------|
171
+ | Encrypted | `.ocam` | AES-256-GCM encrypted, password required |
172
+ | Portable | `.json` | OpenCode Account Manager plain export |
173
+ | AM Export | `.json` | Antigravity Manager app export `[{email, refresh_token}]` |
174
+ | Plugin Native | `.json` | `antigravity-accounts.json` format |
175
+
176
+ ---
177
+
178
+ ## Configuration Paths
179
+
180
+ | File | Windows | Linux/Mac |
181
+ |------|---------|-----------|
182
+ | OpenCode config | `~/.config/opencode/opencode.json` | `~/.config/opencode/opencode.json` |
183
+ | Plugin accounts | `%APPDATA%/opencode/antigravity-accounts.json` | `~/.config/opencode/antigravity-accounts.json` |
184
+ | OCAM preferences | `%APPDATA%/opencode/ocam-config.json` | `~/.config/opencode/ocam-config.json` |
185
+
186
+ > **Note**: `~` on Windows resolves to your user home directory (e.g., `C:\Users\YourName`)
187
+
188
+ ---
189
+
190
+ ## Requirements
191
+
192
+ - **Node.js**: >= 16.x
193
+ - **OpenCode**: Installed and configured
194
+ - **Terminal**: Unicode and 256 colors support (Windows Terminal, iTerm2, etc.)
195
+
196
+ ---
197
+
198
+ ## Troubleshooting
199
+
200
+ ### "command not found: ocam"
201
+
202
+ ```bash
203
+ npm install -g opencode-account-manager
204
+ ```
205
+
206
+ ### "Plugin accounts file not found"
207
+
208
+ Login at least one account first:
209
+
210
+ ```bash
211
+ opencode auth login
212
+ ```
213
+
214
+ ### "Cannot find module"
215
+
216
+ Reinstall the package:
217
+
218
+ ```bash
219
+ npm uninstall -g opencode-account-manager
220
+ npm install -g opencode-account-manager
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Documentation
226
+
227
+ - [ROADMAP.md](./docs/ROADMAP.md) - Version history and plans
228
+ - [BLUEPRINT.md](./docs/BLUEPRINT.md) - Technical architecture
229
+
230
+ ---
231
+
232
+ ## Contributing
233
+
234
+ 1. Fork the repo
235
+ 2. Create branch: `git checkout -b feature/your-feature`
236
+ 3. Commit: `git commit -m "feat: description"`
237
+ 4. Push: `git push origin feature/your-feature`
238
+ 5. Create Pull Request
239
+
240
+ ---
241
+
242
+ ## License
243
+
244
+ MIT License. See [LICENSE](./LICENSE) for details.
245
+
246
+ ---
247
+
248
+ ## Credits
249
+
250
+ - [OpenCode](https://opencode.ai) - The AI coding assistant this tool is built for
251
+ - [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) - Optional plugin for Google OAuth authentication